Beispiel #1
0
 public function getItemMultiImage(&$item, $params)
 {
     if (is_int($item)) {
         $item =& $this->getItem($item);
     }
     $elements = isset($params['media_elements']) ? trim($params['media_elements']) : 'image';
     if (!isset($this->_images4[$item->id])) {
         $this->_images4[$item->id] = array();
         if (!isset($item->app)) {
             // set application refer
             $item->app =& $this->_getZooApplication();
             is_string($item->params) && ($item->params = $item->app->parameter->create($item->params));
             is_string($item->elements) && ($item->elements = $item->app->data->create($item->elements));
         }
         $media_elements = $this->_parseValues($elements);
         // $media_elements['_current'] = count($media_elements);
         $item_elements = $item->getElements();
         if ($item_elements) {
             foreach ($item_elements as $element) {
                 $element_class = get_class($element);
                 $eclass_suffix = substr($element_class, 7);
                 $eclass_suffix = strtolower($eclass_suffix);
                 if (array_key_exists($eclass_suffix, $media_elements)) {
                     if (!is_array($media_elements[$eclass_suffix])) {
                         $media_elements[$eclass_suffix] = array();
                     }
                     if ($element->hasValue('file')) {
                         $tmp_url = $element->get('file');
                         if (YTools::isUrl($tmp_url) || file_exists($tmp_url)) {
                             array_push($media_elements[$eclass_suffix], $tmp_url);
                         }
                     }
                 }
             }
             foreach ($media_elements as $element_images) {
                 if (is_array($element_images) && count($element_images)) {
                     foreach ($element_images as $i => $image_url) {
                         array_push($this->_images4[$item->id], $element_images[$i]);
                     }
                 }
             }
         }
         if ($this->getItemDescription($item, $params)) {
             $inline_images = YTools::extractImages($item->description);
             if (!empty($inline_images)) {
                 foreach ($inline_images as $i => $image_url) {
                     if (YTools::isUrl($image_url) || file_exists($image_url)) {
                         array_push($this->_images4[$item->id], $inline_images[$i]);
                     }
                 }
             }
         }
     }
     return $this->_images4[$item->id];
 }
Beispiel #2
0
		public function itemImages($item){
			$_images4 = array();
			if (is_int($item)){
				$item = $this->getItem($item);
			}
			if (!isset($this->_images4[$item->id])){
				$this->_images4[$item->id] = array();
		
				// image extract
				if (strpos($item->images, '{')!==false || strpos($item->images, '[')!==false){
					$json = json_decode($item->images, true);
					
					if (isset($json['image_intro'])){
						if (YTools::isUrl($json['image_intro']) || file_exists($json['image_intro'])){
							array_push($this->_images4[$item->id], $json['image_intro']);
						}
					}
					
					if (isset($json['image_fulltext'])){
						if (YTools::isUrl($json['image_fulltext']) || file_exists($json['image_fulltext'])){
							array_push($this->_images4[$item->id], $json['image_fulltext']);
						}
					}
					
				}
		
				if (!isset($item->image_extracted)){
					$item_images = YTools::extractImages($item->introtext);
					$item->image_extracted = true;
				}
		
				if (isset($item_images) && count($item_images)){
					// get first exists image
					foreach ($item_images as $i => $image_url) {
						if (YTools::isUrl($image_url) || file_exists($image_url)){
							array_push($this->_images4[$item->id], $image_url);
						}
					}
				}
			}
			
			return $this->_images4[$item->id];
		}
Beispiel #3
0
 public function itemImages(&$item)
 {
     if (is_int($item)) {
         $item = $this->getItem($item);
     }
     if (!isset($this->_images4[$item->id])) {
         $this->_images4[$item->id] = array();
         // image extract
         if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'src' . DS . md5("Image" . $item->id) . '.jpg')) {
             array_push($this->_images4[$item->id], 'media/k2/items/src/' . md5("Image" . $item->id) . '.jpg');
         }
         if (!isset($item->image_extracted)) {
             $item_images = YTools::extractImages($item->description);
             $item->image_extracted = true;
         }
         if (isset($item_images) && count($item_images)) {
             // get first exists image
             foreach ($item_images as $i => $image_url) {
                 if (YTools::isUrl($image_url) || file_exists($image_url)) {
                     array_push($this->_images4[$item->id], $image_url);
                 }
             }
         }
     }
     return $this->_images4[$item->id];
 }