Hi!
Für V1.7.10 oder höher.
Dieser MOD erweitert die in der Version 1.7.10 enthaltene IPTC funktion um folgendes:
Alle IPTC Daten der Bilder, werden ausgelesen und in die Datenbank geschrieben.
Dadurch können Bilder nach IPTC Daten gesucht werden.
Zu Modifizierenden Dateien:
1.) SQL Table "wordmatch","images" und "images_temp" erstellen.
(im Anhang befindet sich die install_iptc.php um die benötigten Datenbankfelder automatisch anzulegen.)
2.) admin/checkimages.php
3.) includes/db_field_definitions.php
4.) includes/functions.php
5.) root/config.php
6.) IPCT Daten der Bilder in die Datenbank schreiben.
7.) OPTIONAL Member Addon: IPTC Daten werden auch in die Datenbank geschrieben, wenn die Bilder über das Member Uploadformular hoch geladen werden.
Codeupdate: step 5.) 23.06.2011
Codeupdate: step 7.); 7.1); 7.2); 7.3); 8.); 19.07.2011
1.) kopiert die "install_iptc.php" aus dem anhang in euren root und ruft sie auf.
2.) suche in der admin/checkimage.php:
$sql = "INSERT INTO ".IMAGES_TABLE."
füge darüber ein: /insert above:
//############################### Start IPTC ############################################
$src_file = ($big_file) ? MEDIA_PATH."/".$cat_id."/".$big_folder."/".$big_file : $file;
$size = getimagesize ($src_file, $info);
if(isset($info['APP13'])){
$iptc_array = get_iptc_info($info['APP13']);
foreach ($iptc_array as $key => $val) {
$additional_field_sql .= ',image_'.$key;
$additional_value_sql .= ",'".addslashes($val)."'";
}
}
//############################### End IPTC ##############################################
2.1) suche: /search:
add_searchwords($image_id, $search_words);
füge darunter ein: /insert below:
//################################## Start Exif IPTC #########################
$sql = "SELECT image_id".$additional_field_sql."
FROM ".IMAGES_TABLE."
WHERE image_id = $image_id
";
$result = $site_db->query($sql);
while ($row = $site_db->fetch_array($result)) {
$additional_search_words = array();
foreach ($search_match_fields as $image_column => $match_column) {
if (isset($row[$image_column])) {
$additional_search_words[$image_column] = $row[$image_column];
}
}
add_searchwords($image_id, $additional_search_words);
};
//################################## End Exif IPTC ##########################
3.) suche in der includes/db_field_definition.php
?>
füge darüber ein: /insert above:
//################################ Start Iptc ##############################################
$additional_image_fields['image_caption'] = array($lang['iptc_caption'], "text", 0);
$additional_image_fields['image_caption_writer'] = array($lang['iptc_caption_writer'], "text", 0);
$additional_image_fields['image_headline'] = array($lang['iptc_headline'], "text", 0);
$additional_image_fields['image_special_instructions'] = array($lang['iptc_special_instructions'], "text", 0);
$additional_image_fields['image_byline'] = array($lang['iptc_byline'], "text", 0);
$additional_image_fields['image_byline_title'] = array($lang['iptc_byline_title'], "text", 0);
$additional_image_fields['image_credit'] = array($lang['iptc_credit'], "text", 0);
$additional_image_fields['image_source'] = array($lang['iptc_source'], "text", 0);
$additional_image_fields['image_object_name'] = array($lang['iptc_object_name'], "text", 0);
$additional_image_fields['image_date_created'] = array($lang['iptc_date_created'], "text", 0);
$additional_image_fields['image_city'] = array($lang['iptc_city'], "text", 0);
$additional_image_fields['image_state'] = array($lang['iptc_state'], "text", 0);
$additional_image_fields['image_country'] = array($lang['iptc_country'], "text", 0);
$additional_image_fields['image_original_transmission_reference'] = array($lang['iptc_original_transmission_reference'], "text", 0);
$additional_image_fields['image_category'] = array($lang['iptc_category'], "text", 0);
$additional_image_fields['image_supplemental_category'] = array($lang['iptc_supplemental_category'], "text", 0);
$additional_image_fields['image_keyword'] = array($lang['iptc_keyword'], "text", 0);
$additional_image_fields['image_copyright_notice'] = array($lang['iptc_copyright_notice'], "text", 0);
//############################ End IPTC ###############################################################
4.) suche in der includes/functions.php: /search in includes/functions.php:
if ($detailed_view && isset($info['APP13'])) {
$iptc_array = get_iptc_info($info['APP13']);
$bgcounter = 0;
foreach ($iptc_array as $key => $val) {
$row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
$site_template->register_vars(array(
"iptc_value" => format_text($val),
"iptc_name" => $lang['iptc_'.$key],
"row_bg_number" => $row_bg_number
));
$iptc_info .= $site_template->parse_template("iptc_bit");
}
}
und ersetze es mit: /and replace:
//############################ IPTC Start ##################################
if ($detailed_view ) {
global $site_db,$lang,$additional_image_fields,$search_index_types;
$additional_field_sql = "";
foreach ($additional_image_fields as $key => $val){
$additional_field_sql .= ','.$key;
}
$sql = "SELECT image_id".$additional_field_sql."
FROM ".IMAGES_TABLE."
WHERE image_id = '$image_id'";
$result = $site_db->query($sql);
$row = mysql_fetch_object($result);
$bgcounter = 0;
foreach ($row as $key => $val) {
if ($val != "") {
$search_key = $key;
$key = str_replace('image_','',($key));
if(($search_index_types[$search_key]) == 'keywords'){
$split_keyword = explode(",", $val);
array_walk($split_keyword, 'trim_value');
$keyword = "";
foreach ($split_keyword as $val) {
$url_val = $val;
if (strpos($url_val, ' ') !== false) {
$url_val = '"' . $url_val . '"';
}
$keyword.= (($keyword != "") ? ", " :"")."<a href=\"".$site_sess->url(ROOT_PATH."search.php?search_keywords=".urlencode($url_val))."&search_fields=$search_key \">".format_text($val, 2)."</a>";
}
$val = $keyword;
}
if(($search_index_types[$search_key]) == 'phrase'){
$url_val = '"' . $val . '"';
$val= "<a href=\"".$site_sess->url(ROOT_PATH."search.php?search_keywords=".urlencode($url_val))."&search_fields=$search_key \">".format_text($val, 2)."</a>";
}
if(($search_index_types[$search_key]) == 'fulltext'){
$val= format_text($val, 2);
}
if (isset($lang['iptc_'.$key])) {
$row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
$site_template->register_vars(array(
"iptc_value" => $val,
"iptc_name" => $lang['iptc_'.$key],
"row_bg_number" => $row_bg_number
));
$iptc_info .= $site_template->parse_template("iptc_bit");
}
}
}
}
//############################## IPTC END ###################################
5.) suche in der root/config.php: /search in root/config.php:
?>
füge davor ein: /insert above:
$search_index_types = array(
"image_id" => "phrase",
"image_name" => "fulltext",
"image_description" => "fulltext",
"image_keywords" => "keywords",
"image_caption" => "fulltext",
"image_caption_writer" =>"phrase",
"image_headline" =>"phrase",
"image_special_instructions" =>"fulltext",
"image_byline" =>"phrase",
"image_byline_title" =>"phrase",
"image_credit" =>"phrase",
"image_source" =>"phrase",
"image_object_name" =>"keywords",
"image_date_created" =>"phrase",
"image_city" =>"phrase",
"image_state" =>"phrase",
"image_country" =>"phrase",
"image_original_transmission_reference" =>"phrase",
"image_category" =>"phrase",
"image_supplemental_category" =>"phrase",
"image_keyword" =>"keywords",
"image_copyright_notice" =>"fulltext",
);
$search_match_fields = array(
"image_name" => "name_match",
"image_description" => "desc_match",
"image_keywords" => "keys_match",
"image_caption" =>"caption_match",
"image_caption_writer" =>"caption_writer_match",
"image_headline" =>"headline_match",
"image_special_instructions" =>"special_instructions_match",
"image_byline" =>"byline_match",
"image_byline_title" =>"byline_title_match",
"image_credit" =>"credit_match",
"image_source" =>"source_match",
"image_object_name" =>"object_name_match",
"image_date_created" =>"date_created_match",
"image_city" =>"city_match",
"image_state" =>"state_match",
"image_country" =>"country_match",
"image_original_transmission_reference" =>"original_transmission_reference_match",
"image_category" =>"category_match",
"image_supplemental_category" =>"supplemental_category_match",
"image_keyword" =>"keyword_match",
"image_copyright_notice" =>"copyright_notice_match"
);
6.) Kopiert die Datei "create_iptc_data.php" (im Anhang) nach admin/plugins und führ sie 1x aus.
Mit dieser Datei werden die schon vorhanden Bilder der Galerie nach IPTC Daten durchsucht und in die Datenbank geschrieben.
Falls ihr schon IPTC Daten in der Datenbank habt braucht ihr diesen schritt nicht durchführen.
OPTIONAL Member Addon: IPTC Daten werden auch in die Datenbank geschrieben, wenn die Bilder über das Member Uploadformular hoch geladen werden.
7.) suche in der member.php abschnitt($action == "editimage"):
search in member.php section($action == "editimage"):
$txt_clickstream = get_category_path($image_row['cat_id'], 1).$config['category_separator']."<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id)."\" class=\"clickstream\">".format_text($image_row['image_name'], 2)."</a>".$config['category_separator'];
füge darüber ein:
inser above:
//######################### IPTC EXIF #########################################
foreach ($image_row as $key => $val) {
if ($val && (!is_numeric($key))) {
$hidden_fields .= "<input type=\"hidden\" name=\"$key\" value=\"$val\" />\n";
}
}
//######################### IPTC EXIF #########################################
7.1) suche in der member.php abschnitt($action == "editimage"):
search in member.php section($action == "editimage"):
$site_template->register_vars(array(
füge darunter ein:
insert below:
"hidden_fields" => $hidden_fields, //########## IPTC EXIF ################
7.2) suche:
search:
$table = ($direct_upload) ? IMAGES_TABLE : IMAGES_TEMP_TABLE;
füge darüber ein:
insert above:
//############################### Start IPTC ############################################
$src_file = $src;
$size = getimagesize ($src_file, $info);
if(isset($info['APP13'])){
$iptc_array = get_iptc_info($info['APP13']);
foreach ($iptc_array as $key => $val) {
$additional_field_sql .= ',image_'.$key;
$additional_value_sql .= ",'".$val."'";
}
}
//############################### End IPTC #############################################
7.3) suche:
search:
}
add_searchwords($image_id, $search_words);
füge darunter ein:
insert below:
//######################### Start Exif IPTC #########################
$sql = "SELECT image_id".$additional_field_sql."
FROM ".IMAGES_TABLE."
WHERE image_id = $image_id
";
$result = $site_db->query($sql);
while ($row = $site_db->fetch_array($result)) {
$additional_search_words = array();
foreach ($search_match_fields as $image_column => $match_column) {
if (isset($row[$image_column])) {
$additional_search_words[$image_column] = $row[$image_column];
}
}
add_searchwords($image_id, $additional_search_words);
};
//####################### End Exif IPTC #########################
8.) suche in templates/yourTemplates/member_editimage.html:
<form method="post" action="{url_member}" onsubmit="uploadbutton.disabled=true;">
füge darunter ein:
insert below:
{hidden_fields}
mfg Andi