/**
 * Returns IPTC metadata to sync from a file, depending on IPTC mapping.
 * @toto : clean code (factorize foreach)
 *
 * @param string $file
 * @return array
 */
function get_sync_iptc_data($file)
{
    global $conf;
    $map = $conf['use_iptc_mapping'];
    $iptc = get_iptc_data($file, $map);
    foreach ($iptc as $pwg_key => $value) {
        if (in_array($pwg_key, array('date_creation', 'date_available'))) {
            if (preg_match('/(\\d{4})(\\d{2})(\\d{2})/', $value, $matches)) {
                $year = $matches[1];
                $month = $matches[2];
                $day = $matches[3];
                if (!checkdate($month, $day, $year)) {
                    // we suppose the year is correct
                    $month = 1;
                    $day = 1;
                }
                $iptc[$pwg_key] = $year . '-' . $month . '-' . $day;
            }
        }
    }
    if (isset($iptc['keywords'])) {
        // official keywords separator is the comma
        $iptc['keywords'] = preg_replace('/[.;]/', ',', $iptc['keywords']);
        $iptc['keywords'] = preg_replace('/,+/', ',', $iptc['keywords']);
        $iptc['keywords'] = preg_replace('/^,+|,+$/', '', $iptc['keywords']);
        $iptc['keywords'] = implode(',', array_unique(explode(',', $iptc['keywords'])));
    }
    foreach ($iptc as $pwg_key => $value) {
        $iptc[$pwg_key] = addslashes($iptc[$pwg_key]);
    }
    return $iptc;
}
Пример #2
0
/**
 * Returns IPTC metadata to sync from a file, depending on IPTC mapping.
 * @toto : clean code (factorize foreach)
 *
 * @param string $file
 * @return array
 */
function get_sync_iptc_data($file)
{
    global $conf;
    $map = $conf['use_iptc_mapping'];
    $iptc = get_iptc_data($file, $map);
    foreach ($iptc as $pwg_key => $value) {
        if (in_array($pwg_key, array('date_creation', 'date_available'))) {
            if (preg_match('/(\\d{4})(\\d{2})(\\d{2})/', $value, $matches)) {
                $year = $matches[1];
                $month = $matches[2];
                $day = $matches[3];
                if (!checkdate($month, $day, $year)) {
                    // we suppose the year is correct
                    $month = 1;
                    $day = 1;
                }
                $iptc[$pwg_key] = $year . '-' . $month . '-' . $day;
            }
        }
    }
    if (isset($iptc['keywords'])) {
        $iptc['keywords'] = metadata_normalize_keywords_string($iptc['keywords']);
    }
    foreach ($iptc as $pwg_key => $value) {
        $iptc[$pwg_key] = addslashes($iptc[$pwg_key]);
    }
    return $iptc;
}
Пример #3
0
                    }
                    $tpl_meta['lines'][$key] = $exif[$field];
                }
            } else {
                $tokens = explode(';', $field);
                if (isset($exif[$field])) {
                    $key = $tokens[1];
                    if (isset($lang['exif_field_' . $key])) {
                        $key = $lang['exif_field_' . $key];
                    }
                    $tpl_meta['lines'][$key] = $exif[$field];
                }
            }
        }
        $template->append('metadata', $tpl_meta);
    }
}
if ($conf['show_iptc']) {
    $iptc = get_iptc_data($picture['current']['src_image']->get_path(), $conf['show_iptc_mapping'], ', ');
    if (count($iptc) > 0) {
        $tpl_meta = array('TITLE' => l10n('IPTC Metadata'), 'lines' => array());
        foreach ($iptc as $field => $value) {
            $key = $field;
            if (isset($lang[$field])) {
                $key = $lang[$field];
            }
            $tpl_meta['lines'][$key] = $value;
        }
        $template->append('metadata', $tpl_meta);
    }
}
Пример #4
0
					$price_contact1 = $_POST['price_contact'];
				}
			}
				
			// START PROCESSING THE PHOTOS
			if($left_over > 0){
			$x = 1;
			$i = 0;
			while($i < $x){		
				$image = "../ftp/" . $img_files[$i];
				
				// IPTC INFORMATION
				if($image != ""){
					# GRAB IPTC INFO
					if(function_exists(get_iptc_data)){
						get_iptc_data($image);
						# ADD IPTC INFO TO OTHER INFO	
						if($iptc_keywords){
							$keywords1= addslashes($iptc_keywords);
						}
						if($iptc_description){
							$description1= addslashes($iptc_description);
						}
						if($iptc_title){
							$title1= addslashes($iptc_title);
						}
					}
				}
				
				if($title1 != ""){
				$title_new = $title1 . $title2;
Пример #5
0
 }
 $prod = $prod2;
 if ($size) {
     foreach ($size as $value) {
         $size2 = $size2 . "," . $value;
     }
 }
 $size = $size2;
 $added = date("Ymd");
 $keywords = strtolower($_POST['keywords']);
 if ($_POST['other_galleries']) {
     $other_galleries2 = "," . implode(",", $_POST['other_galleries']) . ",";
 }
 if ($_FILES['image'] != "") {
     # GRAB IPTC INFO
     get_iptc_data($_FILES['image']['tmp_name']);
     # ADD IPTC INFO TO OTHER INFO
     if ($iptc_keywords) {
         $keywords = addslashes($iptc_keywords);
     }
     if ($iptc_description) {
         $description = addslashes($iptc_description);
     }
     if ($iptc_title) {
         $title = addslashes($iptc_title);
     }
 }
 //ADDED IN PS350 TO CLEANUP DATA ENTRY
 $title = cleanup($title);
 $description = cleanup($description);
 $keywords = cleanup($keywords);
function prepare_file($path)
{
    $iptc = get_iptc_data($path);
    $file = array();
    $file['path'] = $path;
    $file['md5'] = md5_file($path);
    $file['filename'] = basename($path);
    if (!empty($iptc)) {
        if (!empty($iptc['2#120'][0])) {
            $file['caption'] = $iptc['2#120'][0];
        }
        if (!empty($iptc['2#025'])) {
            $file['keywords'] = implode(', ', $iptc['2#025']);
        }
    }
    return $file;
}