/**
  * Read from a file
  *
  * @deprecated  Use img.io.MetaDataReader instead
  * @param   io.File file
  * @param   var default default void what should be returned in case no data is found
  * @return  img.util.IptcData
  * @throws  lang.FormatException in case malformed meta data is encountered
  * @throws  lang.ElementNotFoundException in case no meta data is available
  * @throws  img.ImagingException in case reading meta data fails
  */
 public static function fromFile(File $file)
 {
     if (FALSE === getimagesize($file->getURI(), $info)) {
         $e = new ImagingException('Cannot read image information from ' . $file->getURI());
         xp::gc(__FILE__);
         throw $e;
     }
     if (!isset($info['APP13'])) {
         if (func_num_args() > 1) {
             return func_get_arg(1);
         }
         throw new ElementNotFoundException('Cannot get IPTC information from ' . $file->getURI() . ' (no APP13 marker)');
     }
     if (!($iptc = iptcparse($info['APP13']))) {
         throw new FormatException('Cannot parse IPTC information from ' . $file->getURI());
     }
     // Parse creation date
     if (3 == sscanf(@$iptc['2#055'][0], '%4d%2d%d', $year, $month, $day)) {
         $created = Date::create($year, $month, $day, 0, 0, 0);
     } else {
         $created = NULL;
     }
     with($i = new self());
     $i->setTitle(@$iptc['2#005'][0]);
     $i->setUrgency(@$iptc['2#010'][0]);
     $i->setCategory(@$iptc['2#015'][0]);
     $i->setSupplementalCategories(@$iptc['2#020']);
     $i->setKeywords(@$iptc['2#025']);
     $i->setSpecialInstructions(@$iptc['2#040'][0]);
     $i->setDateCreated($created);
     $i->setAuthor(@$iptc['2#080'][0]);
     $i->setAuthorPosition(@$iptc['2#085'][0]);
     $i->setCity(@$iptc['2#090'][0]);
     $i->setState(@$iptc['2#095'][0]);
     $i->setCountry(@$iptc['2#101'][0]);
     $i->setOriginalTransmissionReference(@$iptc['2#103'][0]);
     $i->setHeadline(@$iptc['2#105'][0]);
     $i->setCredit(@$iptc['2#110'][0]);
     $i->setSource(@$iptc['2#115'][0]);
     $i->setCopyrightNotice(@$iptc['2#116'][0]);
     $i->setCaption(@$iptc['2#120'][0]);
     $i->setWriter(@$iptc['2#122'][0]);
     return $i;
 }
Example #2
0
 /**
  * @param Campaign $campaign
  * @param array $array
  * @return Campaign|Content
  */
 public static function createFromArray(Campaign $campaign = null, array $array = array())
 {
     $defaults = array("view_count" => 0, "like_count" => 0, "dislike_count" => 0, "favorite_count" => 0, "comment_count" => 0, "tw_share_count" => 0, "fb_share_count" => 0);
     $array = array_merge($defaults, $array);
     $content = new self($array['id'], $campaign);
     $content->setSource($array['source']);
     $content->setFoundAt(new \DateTime($array['found_at']));
     $content->setNativeId($array['native_id']);
     $content->setCreatedAt(new \DateTime($array['created_at']));
     $content->setUrl($array['url']);
     $content->setThumb($array['thumb']);
     $content->setVideoSrc($array['video_src']);
     $content->setTitle($array['title']);
     $content->setDescription($array['description']);
     $content->setVideoLength($array['video_length']);
     $content->setUsername($array['username']);
     $content->setViewCount($array['view_count']);
     $content->setLikeCount($array['like_count']);
     $content->setDislikeCount($array['dislike_count']);
     $content->setFavCount($array['favorite_count']);
     $content->setCommentCount($array['comment_count']);
     $content->setTwCount($array['tw_share_count']);
     $content->setFbCount($array['fb_share_count']);
     $content->setProcessed($array['processed']);
     if ($array['processed']) {
         $content->setProcessedAt(new \DateTime($array['processed_at']));
     }
     $content->setKeyword($array['keyword']);
     $content->setUserNativeId($array['user_native_id']);
     if (isset($array['popularity'])) {
         $content->setPopularity($array['popularity']);
     }
     if (isset($array['sr_status'])) {
         $content->setSrStatus($array['sr_status']);
     } else {
         if (isset($array['srstatus'])) {
             $content->setSrStatus($array['srstatus']);
         }
     }
     if (isset($array['followers'])) {
         $content->setUserReach($array['followers']);
     }
     return $content;
 }
Example #3
0
 /**
  * Create a new protected file from an existing file.
  *
  * @param string $path Path to file
  *
  * @return ProtectedFile
  */
 public static function createFromFile($path)
 {
     $file = new self();
     $file->setSource($path);
     return $file;
 }
Example #4
0
 public static function createInstance($sName, $sValue, $sQuoteType = '"', $nPosition = 0, $nLine = 0)
 {
     $aVal = new self($sName, $sQuoteType, $nPosition, $nLine);
     $aVal->setSource($sValue);
     return $aVal;
 }