Author Topic: [Mod] IPTC V1.7.10 Suchfelder erweiterung  (Read 43987 times)

0 Members and 1 Guest are viewing this topic.

Rembrandt

  • Guest
[Mod] IPTC V1.7.10 Suchfelder erweiterung
« on: April 22, 2011, 06:25:30 PM »
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++ % == 0) ? 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))."&amp;search_fields=$search_key \">".format_text($val2)."</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))."&amp;search_fields=$search_key \">".format_text($val2)."</a>";
              }
              
              if((
$search_index_types[$search_key]) == 'fulltext'){
                
$valformat_text($val2);
              }
              
              if (isset(
$lang['iptc_'.$key])) {
                
$row_bg_number = ($bgcounter++ % == 0) ? 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:
Code: [Select]
<form method="post" action="{url_member}" onsubmit="uploadbutton.disabled=true;">
füge darunter ein:
insert below:
Code: [Select]
{hidden_fields}

mfg Andi
« Last Edit: May 05, 2013, 05:05:14 PM by Rembrandt »

Offline Lunis

  • Pre-Newbie
  • Posts: 5
    • View Profile
Re: [Mod] IPTC V1.7.10 Suchfelder erweiterung
« Reply #1 on: July 19, 2011, 08:45:19 AM »
Help :(

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /pub/home/kurzeme6/htdocs/admin/checkimages.php on line 572

Rembrandt

  • Guest
Re: [Mod] IPTC V1.7.10 Suchfelder erweiterung
« Reply #2 on: July 19, 2011, 09:06:21 AM »
Welcome to the Forum!

......

Post your "checkimages.php" and not a image

Offline Lunis

  • Pre-Newbie
  • Posts: 5
    • View Profile
Re: [Mod] IPTC V1.7.10 Suchfelder erweiterung
« Reply #3 on: July 19, 2011, 09:32:18 AM »
O.k post "checkimages.php"  checkimages_bad.zip http://www.fotoklubsogre.lv/draz/checkimages_bad.zip

Rembrandt

  • Guest
Re: [Mod] IPTC V1.7.10 Suchfelder erweiterung
« Reply #4 on: July 19, 2011, 09:35:03 AM »
füge darüber ein =>  insert above
füge darunter ein => insert below

mfg Andi


Offline Lunis

  • Pre-Newbie
  • Posts: 5
    • View Profile
Re: [Mod] IPTC V1.7.10 Suchfelder erweiterung
« Reply #5 on: July 19, 2011, 10:13:10 AM »
füge darüber ein =>  insert above
füge darunter ein => insert below

where it is to write??

Rembrandt

  • Guest
Re: [Mod] IPTC V1.7.10 Suchfelder erweiterung
« Reply #6 on: July 19, 2011, 10:23:05 AM »
this is your code:

                 
if (!$error_major)
                 {
                    
$sql "INSERT INTO ".IMAGES_TABLE."
                    
//############################### 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 .= ",'".$val."'";
                }
              }
//############################### End IPTC ##############################################
                                (cat_id, user_id, image_name, image_description, image_keywords, image_date, image_active, image_media_file, image_thumb_file, image_download_url, image_allow_comments"
.$additional_field_sql.")
                                VALUES
                                (
$cat_id$user_id, '$image_name', '$image_description', '$image_keywords', $image_date$image_active, '".addslashes($image_media_file)."', '".addslashes($image_thumb_file)."', '$image_download_url', $image_allow_comments".$additional_value_sql.")";


you have the code step 2.) insert below
$sql "INSERT INTO ".IMAGES_TABLE."

please read step 2.) again (above)

Offline Lunis

  • Pre-Newbie
  • Posts: 5
    • View Profile
Re: [Mod] IPTC V1.7.10 Suchfelder erweiterung
« Reply #7 on: July 19, 2011, 10:46:41 AM »
O.k , Thanks I will try.

Offline Lunis

  • Pre-Newbie
  • Posts: 5
    • View Profile
Re: [Mod] IPTC V1.7.10 Suchfelder erweiterung
« Reply #8 on: July 21, 2011, 04:39:07 PM »
Opss Ops ops next Error: (


Warning: rename(kuldiga_2011_0001_TESTS.jpg,kuldiga_2011_0001_tests.jpg): Permission denied in /pub/home/kurzeme6/htdocs/admin/checkimages.php on line 203

Warning: imagejpeg(): Unable to open './../data/thumbnails/26/kuldiga_2011_0001_TESTS.jpg' for writing in /pub/home/kurzeme6/htdocs/includes/image_utils.php on line 93

DB Error: Bad SQL Query: INSERT INTO 4images_images (cat_id, user_id, image_name, image_description, image_keywords, image_date, image_active, image_media_file, image_thumb_file, image_download_url, image_allow_comments,image_byline,image_copyright_notice) VALUES (26, 1, 'kuldiga 2011 0001 TESTS', '', '', UNIX_TIMESTAMP('2011-07-21 17:39:53'), 1, 'kuldiga_2011_0001_TESTS.jpg', '', '', 0,'Photographer: Ieva Purina','Copyright: Latvianphoto.com')
Unknown column 'image_byline' in 'field list'
Working on data/media/26/kuldiga_2011_0001_TESTS.jpg file
Error renaming media file from kuldiga_2011_0001_TESTS.jpg to kuldiga_2011_0001_tests.jpg
Error creating thumbnail.
Error adding image.


Warning: imagejpeg(): Unable to open './../data/thumbnails/26/kuldiga_2011_0049.jpg' for writing in /pub/home/kurzeme6/htdocs/includes/image_utils.php on line 93

DB Error: Bad SQL Query: INSERT INTO 4images_images (cat_id, user_id, image_name, image_description, image_keywords, image_date, image_active, image_media_file, image_thumb_file, image_download_url, image_allow_comments,image_caption,image_byline,image_byline_title,image_keyword,image_copyright_notice) VALUES (26, 1, 'kuldiga 2011 0049', 'Dzires Kuldiga , city festival A Feast in Kuldîga', 'Dzires Kuldiga,city festival,A Feast in Kuldîga', UNIX_TIMESTAMP('2011-07-21 17:39:53'), 1, 'kuldiga_2011_0049.jpg', '', '', 0,'Dzires Kuldiga , city festival „A Feast in Kuldîga”','Photographer: Rihards Purins','Dzires Kuldiga 2011','Dzires Kuldiga, city festival, A Feast in Kuldîga”','Copyright: Latvianphoto.com')
Unknown column 'image_caption' in 'field list'
Working on data/media/26/kuldiga_2011_0049.jpg file
Error creating thumbnail.
Error adding image.

No new images added!
------------------------------------------------------------------------------
Error php , http://www.ogresbalss.lv/bacc/Error_php.zip

Rembrandt

  • Guest
Re: [Mod] IPTC V1.7.10 Suchfelder erweiterung
« Reply #9 on: July 21, 2011, 05:40:05 PM »
Warning: rename(kuldiga_2011_0001_TESTS.jpg,kuldiga_2011_0001_tests.jpg): Permission denied in /pub/home/kurzeme6/htdocs/admin/checkimages.php on line 203
Warning: imagejpeg(): Unable to open './../data/thumbnails/26/kuldiga_2011_0001_TESTS.jpg' for writing in /pub/home/kurzeme6/htdocs/includes/image_utils.php on line 93
...Warning: imagejpeg(): Unable to open './../data/thumbnails/26/kuldiga_2011_0049.jpg' for writing in /pub/home/kurzeme6/htdocs/includes/image_utils.php on line 93
....
please read /docs/Installation.english.txt step 5.)

Offline clubbu

  • Newbie
  • *
  • Posts: 47
    • View Profile
Re: [Mod] IPTC V1.7.10 Suchfelder erweiterung
« Reply #10 on: July 22, 2011, 12:17:40 PM »
hello, I do not know what to serve this mod. What is iptc?

Rembrandt

  • Guest
Re: [Mod] IPTC V1.7.10 Suchfelder erweiterung
« Reply #11 on: July 22, 2011, 01:31:46 PM »

Offline MaracujaJoe

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: [Mod] IPTC V1.7.10 Suchfelder erweiterung
« Reply #12 on: January 12, 2012, 04:33:45 PM »
Hallo Rembrandt,

in einer älteren Version dieses MODs muss man auch noch sein Suchformular im Template anpassen.
Ist dies nicht mehr vorgesehen?

Gruß

Rembrandt

  • Guest
Re: [Mod] IPTC V1.7.10 Suchfelder erweiterung
« Reply #13 on: January 12, 2012, 05:03:31 PM »
Willkommen im Forum!
..in einer älteren Version dieses MODs muss man auch noch sein Suchformular im Template anpassen.
Ist dies nicht mehr vorgesehen?
..
Nein, da die Exif und IPTC Daten in dieser neuen Version alle verlinkt sind.
Wie das aussieht b.z.w. funktioniert kannst du dir hier ansehen: DEMO

mfg Andi

Offline MaracujaJoe

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: [Mod] IPTC V1.7.10 Suchfelder erweiterung
« Reply #14 on: January 12, 2012, 05:21:03 PM »
Danke schonmal :-)

In deinem Link gibt es aber auch mehr Felder in der Suche: http://galerie.fotografie-erleben.eu/search.php