예제 #1
0
파일: Page.php 프로젝트: nbourguig/ionize
 /**
  * Returns the medias tag content
  * 
  * @return
  * @attributes	range	Range of media to display. Starts at 0.
  *						If only one number is provided, returns all the medias from this index 
  *						if the attribute "num" is not set
  * 						example of use : 	<ion:medias range="2,4" />
  *											<ion:medias range="2" />
  *
  *				num		Number of pictures to display.
  *						Combined to the "range" attribute, you can display x medias from a given start index.
  * 						example of use : 	Display 2 first medias : 
  *					 						<ion:medias num="2" />
  *											Display 3 medias starting from index 2 :
  *											<ion:medias range="2" num="3" />
  *
  *
  */
 public static function tag_page_medias($tag)
 {
     $medias = !empty($tag->locals->page['medias']) ? $tag->locals->page['medias'] : FALSE;
     if ($medias !== FALSE) {
         return self::wrap($tag, TagManager_Media::get_medias($tag, $medias));
     }
     return;
 }
예제 #2
0
 public static function tag_extend_field_medias(FTL_Binding $tag)
 {
     $str = '';
     $grandParentName = $tag->getParent()->getParentName();
     // Medias asked aren't supposed to be the one linked to the extend
     if (!in_array($grandParentName, array('items', 'item', 'extend'))) {
         return TagManager_Media::tag_medias($tag);
     } else {
         $extend = $tag->get('extend');
         // Medias
         if ($extend['type'] == '8') {
             self::load_model('media_model');
             // Static items already have the 'content' index set.
             // Classical extends have not
             $ids = !empty($extend['content']) ? $extend['content'] : $tag->getValue(self::$extend_field_prefix . $extend['name'], $extend['parent']);
             if (strlen($ids) > 0) {
                 // Tag attributes
                 $type = $tag->getAttribute('type');
                 $limit = $tag->getAttribute('limit', 0);
                 $filter = $tag->getAttribute('filter');
                 if (!is_null($filter)) {
                     $filter = self::process_filter($filter);
                 }
                 $ids_array = explode(',', $ids);
                 $where = array('where_in' => array(self::$ci->media_model->get_table() . '.id_media' => $ids_array), 'order_by' => "field(" . self::$ci->media_model->get_table() . ".id_media, " . $ids . ")");
                 if (!is_null($type)) {
                     $where['type'] = $type;
                 }
                 if ($limit) {
                     $where['limit'] = $limit;
                 }
                 $medias = self::$ci->media_model->get_lang_list($where, Settings::get_lang('current'), $filter);
                 //
                 // From here :
                 // Same than TagManager_Media::tag_medias()
                 //
                 // Extend Fields tags
                 self::create_extend_tags($tag, 'media');
                 // Medias lib, to process the "src" value
                 self::$ci->load->library('medias');
                 // Filter the parent's medias
                 $medias = TagManager_Media::filter_medias($tag, $medias);
                 $count = count($medias);
                 $tag->set('count', $count);
                 // Make medias in random order
                 if ($tag->getAttribute('random') == TRUE) {
                     shuffle($medias);
                 }
                 // Process additional data : src, extension
                 foreach ($medias as $key => $media) {
                     if ($media['provider'] != '') {
                         $src = $media['path'];
                     } else {
                         $src = base_url() . $media['path'];
                     }
                     if ($media['type'] == 'picture') {
                         $settings = TagManager_Media::get_src_settings($tag);
                         if (!empty($settings['size'])) {
                             $src = self::$ci->medias->get_src($media, $settings, Settings::get('no_source_picture'));
                         }
                     }
                     $medias[$key]['src'] = $src;
                 }
                 $tag->set('medias', $medias);
                 foreach ($medias as $key => $media) {
                     // Each media has its index and the number of displayed media
                     $media['index'] = $key + 1;
                     $media['count'] = $count;
                     $tag->set('media', $media);
                     $tag->set('count', $count);
                     $tag->set('index', $key);
                     $str .= $tag->expand();
                 }
             }
             return self::wrap($tag, $str);
         }
     }
     return $str;
 }