/** * Returns a new "image" object based on the file extension * * @param object $album the owner album * @param string $filename the filename * @param bool $quiet set true to supress error messages (used by loadimage) * @return object */ function newImage($album, $filename, $quiet = false) { global $_zp_extra_filetypes, $_zp_missing_image; if (is_array($filename)) { $xalbum = newAlbum($filename['folder'], true, true); $filename = $filename['filename']; } else { if ($album->isDynamic()) { $xalbum = NULL; foreach ($album->getImages() as $image) { if ($filename == $image['filename']) { $xalbum = newAlbum($image['folder']); break; } } } else { $xalbum = $album; } } if (!is_object($xalbum) || !$xalbum->exists || !isAlbumClass($xalbum)) { if (!$quiet) { $msg = sprintf(gettext('Bad album object parameter to newImage(%s)'), $filename); trigger_error($msg, E_USER_NOTICE); } return $_zp_missing_image; } if ($object = Gallery::validImageAlt($filename)) { $image = new $object($xalbum, $filename, $quiet); } else { if (Gallery::validImage($filename)) { $image = new Image($xalbum, $filename, $quiet); } else { $image = NULL; } } if ($image) { if ($album && $album->isDynamic()) { $image->albumname = $album->name; $image->albumlink = $album->linkname; $image->albumnamealbum = $album; } zp_apply_filter('image_instantiate', $image); if ($image->exists) { return $image; } else { return $_zp_missing_image; } } if (!$quiet) { $msg = sprintf(gettext('Bad filename suffix in newImage(%s)'), $filename); trigger_error($msg, E_USER_NOTICE); } return $_zp_missing_image; }
/** * Returns a new "image" object based on the file extension * * @param object $album the owner album * @param string $filename the filename * @param bool $quiet set true to supress error messages (used by loadimage) * @return object */ function newImage($album, $filename = NULL, $quiet = false) { global $_zp_missing_image; if (is_array($album)) { $xalbum = newAlbum($album['folder'], true, true); $filename = $album['filename']; $dyn = false; } else { if (is_array($filename)) { $xalbum = newAlbum($filename['folder'], true, true); $filename = $filename['filename']; $dyn = is_object($album) && $album->isDynamic(); } else { if (is_object($album) && $album->isDynamic()) { $dyn = true; $album->getImages(); $xalbum = array_keys($album->imageNames, $filename); $xalbum = array_shift($xalbum); $xalbum = newAlbum(dirname($xalbum), true, true); } else { $xalbum = $album; $dyn = false; } } } if (!is_object($xalbum) || !$xalbum->exists || !isAlbumClass($xalbum)) { $msg = sprintf(gettext('Bad album object parameter to newImage(%s)'), $filename); } else { if ($object = Gallery::imageObjectClass($filename)) { $image = new $object($xalbum, $filename, $quiet); if ($album && is_subclass_of($album, 'AlbumBase') && $dyn) { $image->albumname = $album->name; $image->albumlink = $album->linkname; $image->albumnamealbum = $album; } zp_apply_filter('image_instantiate', $image); if ($image->exists) { return $image; } return $_zp_missing_image; } $msg = sprintf(gettext('Bad filename suffix in newImage(%s)'), $filename); } if (!$quiet) { zp_error($msg, E_USER_WARNING); } return $_zp_missing_image; }
/** * * Enter description here ... * @param $allow * @param $obj */ function copyLayoutSelection($newid, $obj) { $type = 'multiple_layouts_' . $obj->table; if (getOption($type)) { $result = query_single_row('SELECT * FROM ' . prefix('plugin_storage') . ' WHERE `aux` = ' . $obj->getID() . ' AND type = "' . $type . '"', false); if ($result) { $query = query('INSERT INTO ' . prefix('plugin_storage') . ' (type,aux,data) VALUES ("' . $result['type'] . '", ' . $newid . ', ' . db_quote($result['data']) . ')'); } if (isAlbumClass($obj)) { $result = query_single_row('SELECT * FROM ' . prefix('plugin_storage') . ' WHERE `aux` = ' . $obj->getID() . ' AND type = "multiple_layouts_albums_images"', false); if ($result) { $query = query('INSERT INTO ' . prefix('plugin_storage') . ' (type,aux,data) VALUES ("multiple_layouts_albums_images", ' . $newid . ', ' . db_quote($result['data']) . ')'); } } } return $newid; }
protected static function insert_class($html_original) { global $_zp_current_album, $_zp_current_image; $html = $html_original; if (getOption('flag_thumbnail_flag_new')) { if (isset($_zp_current_image)) { $obj = $_zp_current_image; } else { $obj = $_zp_current_album; } switch (getOption('flag_thumbnail_date')) { case "date": $imagedatestamp = strtotime($obj->getDateTime()); break; case "mtime": $imagedatestamp = $obj->get('mtime'); break; } $not_older_as = 60 * 60 * 24 * getOption('flag_thumbnail_range'); $age = time() - $imagedatestamp; if ($age <= $not_older_as) { if (getOption('flag_thumbnail_use_text')) { $html .= '<span class="textasnewflag" style="position: absolute;top: 10px;right: 6px;">' . getOption('flag_thumbnail_new_text') . "</span>\n"; } else { $html = self::image($html, get_class() . '/' . getOption('flag_thumbnail_new_icon'), 'absolute;top: 4px;right: 4px;'); } } } if (getOption('flag_thumbnail_flag_geodata')) { if (isAlbumClass($obj)) { $obj = $obj->getAlbumThumbImage(); } if (is_object($obj) && get_class($obj) == 'Image') { if ($obj->get('GPSLatitude') && $obj->get('GPSLongitude')) { if (getOption('flag_thumbnail_use_text')) { $html .= '<span class="textasnewflag" style="position: absolute;bottom: 10px;right: 6px;">' . getOption('flag_thumbnail_use_text') . "</span>\n"; } else { $html = self::image($html, get_class() . '/' . getOption('flag_thumbnail_geodata_icon'), 'absolute;bottom: 4px;right: 4px;'); } } } } $i = strpos($html, 'class='); if ($i !== false) { $locked = strpos($html, 'password_protected', $i + 7) !== false; $unpublished = strpos($html, 'not_visible', $i + 7) !== false; if ($locked && getOption('flag_thumbnail_flag_locked')) { if (getOption('flag_thumbnail_use_text')) { $html .= '<span class="textasnewflag" style="position: absolute;bottom: 10px;left: 4px;">' . getOption('flag_thumbnail_locked_text') . "</span>\n"; } else { $html = self::image($html, get_class() . '/' . getOption('flag_thumbnail_locked_icon'), 'absolute;bottom: 4px;left: 4px;'); } } if ($unpublished && getOption('flag_thumbnail_flag_unpublished')) { if (getOption('flag_thumbnail_use_text')) { $html .= '<span class="textasnewflag" style="position: absolute;top: 10px;left: 4px;">' . getOption('flag_thumbnail_unpublished_text') . "</span>\n"; } else { $html = self::image($html, get_class() . '/' . getOption('flag_thumbnail_unpublished_icon'), 'absolute;top: 4px;left: 4px;'); } } } $html = '<span class="flag_thumbnail" style="position:relative; display:block;">' . "\n" . trim($html) . "\n</span>\n"; return $html; }
/** * Gets the feed item data in a gallery feed * * @param object $item Object of an image or album * @return array */ protected function getItemGallery($item) { if ($this->mode == "albums") { $albumobj = newAlbum($item['folder']); $totalimages = $albumobj->getNumImages(); $itemlink = $this->host . pathurlencode($albumobj->getLink()); $thumb = $albumobj->getAlbumThumbImage(); $title = $albumobj->getTitle($this->locale); $filechangedate = filectime(ALBUM_FOLDER_SERVERPATH . internalToFilesystem($albumobj->name)); $latestimage = query_single_row("SELECT mtime FROM " . prefix('images') . " WHERE albumid = " . $albumobj->getID() . " AND `show` = 1 ORDER BY id DESC"); if ($latestimage && $this->sortorder == 'latestupdated') { $count = db_count('images', "WHERE albumid = " . $albumobj->getID() . " AND mtime = " . $latestimage['mtime']); } else { $count = $totalimages; } if ($count != 0) { $imagenumber = sprintf(ngettext('%s (%u image)', '%s (%u images)', $count), $title, $count); } else { $imagenumber = $title; } $feeditem['desc'] = $albumobj->getDesc($this->locale); $feeditem['title'] = $imagenumber; $feeditem['pubdate'] = date("r", strtotime($albumobj->getDateTime())); } else { if (isAlbumClass($item)) { $albumobj = $item; $thumb = $albumobj->getAlbumThumbImage(); } else { $albumobj = $item->getAlbum(); $thumb = $item; } $itemlink = $this->host . $item->getLink(); $title = $item->getTitle($this->locale); $feeditem['desc'] = $item->getDesc($this->locale); $feeditem['title'] = sprintf('%1$s (%2$s)', $item->getTitle($this->locale), $albumobj->getTitle($this->locale)); $feeditem['pubdate'] = date("r", strtotime($item->getDateTime())); } //link $feeditem['link'] = $itemlink; //category $feeditem['category'] = html_encode($albumobj->getTitle($this->locale)); //media content $feeditem['media_content'] = '<image url="' . PROTOCOL . '://' . html_encode($thumb->getCustomImage($this->imagesize, NULL, NULL, NULL, NULL, NULL, NULL, TRUE)) . '" />'; $feeditem['media_thumbnail'] = '<thumbnail url="' . PROTOCOL . '://' . html_encode($thumb->getThumb()) . '" />'; return $feeditem; }
/** * Checks if the item is either expired or in scheduled publishing * A class method wrapper of the functions.php function of the same name * @return boolean */ function checkPublishDates() { $row = array(); if (isAlbumClass($this) || isImageClass($this)) { $row = array('show' => $this->getShow(), 'expiredate' => $this->getExpireDate(), 'publishdate' => $this->getPublishDate()); } else { if ($this->table == 'news' || $this->table == 'pages') { $row = array('show' => $this->getShow(), 'expiredate' => $this->getExpireDate(), 'publishdate' => $this->getDateTime()); } } $check = checkPublishDates($row); if ($check == 1 || $check == 2) { return false; } else { return true; } }
static function publish($object) { $desiredtags = array('copyright' => '<dc:rights>', 'desc' => '<dc:description>', 'title' => '<dc:title>', 'tags' => '<dc:subject>', 'location' => '<Iptc4xmpCore:Location>', 'city' => '<photoshop:City>', 'state' => '<photoshop:State>', 'country' => '<photoshop:Country>', 'title' => '<photoshop:Headline>', 'credit' => '<photoshop:Credit>', 'thumb' => '<zp:Thumbnail>', 'owner' => '<zp:Owner>', 'watermark' => '<zp:Watermark>', 'watermark_use' => '<zp:Watermark_use>', 'watermark_thumb' => '<zp:Watermark_thumb>', 'custom_data' => '<zp:CustomData>', 'codeblock' => '<zp:Codeblock>', 'date' => '<exif:DateTimeOriginal>', 'rating' => '<MicrosoftPhoto:Rating>'); $process = array('dc', 'Iptc4xmpCore', 'photoshop', 'xap'); if (isAlbumClass($object)) { $file = rtrim($object->localpath, '/'); $file .= '.xmp'; } else { $file = stripSuffix($object->localpath) . '.xmp'; } @chmod($file, 0777); $f = fopen($file, 'w'); fwrite($f, '<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 4.2-c020 1.124078, Tue Sep 11 2007 23:21:40 ">' . "\n"); fwrite($f, ' <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">' . "\n"); $last_element = $special = $output = false; foreach ($desiredtags as $field => $elementXML) { $elementXML = substr($elementXML, 1, -1); if ($last_element != $elementXML) { if ($output) { fwrite($f, ' </rdf:Description>' . "\n"); fwrite($f, ' <rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/">' . "\n"); } $last_element = $elementXML; $output = false; } $v = self::encode($object->get($field)); $tag = $elementXML; switch ($elementXML) { case 'dc:creator': $special = 'rdf:Seq'; $tag = 'rdf:li'; if ($v) { fwrite($f, " <{$elementXML}>\n"); fwrite($f, " <{$special}>\n"); fwrite($f, " <{$tag}>{$v}</{$tag}>\n"); fwrite($f, " </{$special}>\n"); fwrite($f, " </{$elementXML}>\n"); $output = true; } break; case 'dc:rights': case 'xapRights:UsageTerms': $special = 'rdf:Alt'; $tag = 'rdf:li'; if ($v) { fwrite($f, " <{$elementXML}>\n"); fwrite($f, " <{$special}>\n"); fwrite($f, " <{$tag}>{$v}</{$tag}>\n"); fwrite($f, " </{$special}>\n"); fwrite($f, " </{$elementXML}>\n"); $output = true; } break; case 'dc:subject': $tags = $object->getTags(); if (!empty($tags)) { fwrite($f, " <{$elementXML}>\n"); fwrite($f, " <rdf:Bag>\n"); foreach ($tags as $tag) { fwrite($f, " <rdf:li>" . self::encode($tag) . "</rdf:li>\n"); } fwrite($f, " </rdf:Bag>\n"); fwrite($f, " </{$elementXML}>\n"); $output = true; } break; default: if ($v) { fwrite($f, " <{$tag}>{$v}</{$tag}>\n"); $output = true; } break; } } fwrite($f, ' </rdf:Description>' . "\n"); fwrite($f, ' </rdf:RDF>' . "\n"); fwrite($f, '</x:xmpmeta>' . "\n"); fclose($f); clearstatcache(); @chmod($file, FILE_MOD); return gettext('Metadata exported'); }
/** * Helper function for getRelatedItems() only. * Returns an array with array for each item with name, album (images only), type and weight (search weight value) * Excludes the current item itself. * * @param array $result array with search results * @param string $type "albums", "images", "news", "pages" */ function createRelatedItemsResultArray($result, $type) { global $_zp_gallery, $_zp_current_album, $_zp_current_image, $_zp_current_zenpage_page, $_zp_current_zenpage_news, $_zp_gallery_page; switch ($_zp_gallery_page) { case 'album.php': $current = $_zp_current_album; break; case 'image.php': $current = $_zp_current_image; break; case 'news.php': $current = $_zp_current_zenpage_news; break; case 'pages.php': $current = $_zp_current_zenpage_page; break; } $results = array(); foreach ($result as $item) { switch ($type) { case 'albums': if (!isAlbumClass($current) || $current->name != $item) { array_push($results, array('name' => $item, 'album' => '', 'type' => $type, 'weight' => '13')); // doesn't have weight so we just add one for sorting later } break; case 'images': if (!isImageClass($current) || $current->filename != $item['filename']) { array_push($results, array('name' => $item['filename'], 'album' => $item['folder'], 'type' => $type, 'weight' => $item['weight'])); } break; case 'news': if (get_class($current) != 'ZenpageNews' || $current->getTitlelink() != $item['titlelink']) { if (!isset($item['weight'])) { $item['weight'] = 13; } // there are circumstances where weights are not generated. array_push($results, array('name' => $item['titlelink'], 'album' => '', 'type' => $type, 'weight' => $item['weight'])); } break; case 'pages': if (get_class($current) != 'ZenpagePage' || $current->getTitlelink() != $item) { array_push($results, array('name' => $item, 'album' => '', 'type' => $type, 'weight' => '13')); // doesn't have weight so we just add one for sorting later } break; } } return $results; }
private static function insert_class($html) { global $_zp_current_album, $_zp_current_image; if (getOption('flag_thumbnail_flag_new')) { if (isset($_zp_current_image)) { $obj = $_zp_current_image; } else { $obj = $_zp_current_album; } $html = '<span class="flag_thumbnail" style="position:relative; display:block;">' . "\n" . $html . "\n"; switch (getOption('flag_thumbnail_date')) { case "date": $imagedatestamp = strtotime($obj->getDateTime()); break; case "mtime": $imagedatestamp = $obj->get('mtime'); break; } $not_older_as = 60 * 60 * 24 * getOption('flag_thumbnail_range'); $age = time() - $imagedatestamp; if ($age <= $not_older_as) { if (getOption('flag_thumbnail_use_text')) { $text = getOption('flag_thumbnail_new_text'); $html .= '<span class="textasnewflag" style="position: absolute;top: 10px;right: 6px;">' . $text . "</span>\n"; } else { $img = getPlugin('flag_thumbnail/' . getOption('flag_thumbnail_new_icon'), false, true); $html .= '<img src="' . $img . '" class="imageasflag" alt="" style="position: absolute;top: 4px;right: 4px;"/>' . "\n"; } } } if (getOption('flag_thumbnail_flag_geodata')) { if (isAlbumClass($obj)) { $obj = $obj->getAlbumThumbImage(); } if (is_object($obj) && get_class($obj) == 'Image') { $exif = $obj->getMetaData(); if (!empty($exif['EXIFGPSLatitude']) && !empty($exif['EXIFGPSLongitude'])) { if (getOption('flag_thumbnail_use_text')) { $text = getOption('flag_thumbnail_geodata_text'); $html .= '<span class="textasnewflag" style="position: absolute;bottom: 10px;right: 6px;">' . $text . "</span>\n"; } else { $img = getPlugin('flag_thumbnail/' . getOption('flag_thumbnail_geodata_icon'), false, true); $html .= '<img src="' . $img . '" class="imageasflag" alt="" style="position: absolute;bottom: 4px;right: 4px;"/>' . "\n"; } } } } $i = strpos($html, 'class='); if ($i !== false) { $locked = strpos($html, 'password_protected', $i + 7) !== false; $unpublished = strpos($html, 'not_visible', $i + 7) !== false; if ($locked && getOption('flag_thumbnail_flag_locked')) { if (getOption('flag_thumbnail_use_text')) { $text = getOption('flag_thumbnail_locked_text'); $html .= '<span class="textasnewflag" style="position: absolute;bottom: 10px;left: 4px;">' . $text . "</span>\n"; } else { $img = getPlugin('flag_thumbnail/' . getOption('flag_thumbnail_locked_icon'), false, true); $html .= '<img src="' . $img . '" class="imageasflag" alt="" style="position: absolute;bottom: 4px;left: 4px;"/>' . "\n"; } } if ($unpublished && getOption('flag_thumbnail_flag_unpublished')) { if (getOption('flag_thumbnail_use_text')) { $text = getOption('flag_thumbnail_unpublished_text'); $html .= '<span class="textasnewflag" style="position: absolute;top: 10px;left: 4px;">' . $text . "</span>\n"; } else { $img = getPlugin('flag_thumbnail/' . getOption('flag_thumbnail_unpublished_icon'), false, true); $html .= '<img src="' . $img . '" class="imageasflag" alt="" style="position: absolute;top: 4px;left: 4px;"/>' . "\n"; } } } $html .= "</span>\n"; return $html; }