Exemplo n.º 1
0
 /**
  * Returns one article's author
  *
  * @param 	FTL_Binding
  *
  * @return 	string
  *
  * @usage	<ion:article:user [who='updater']>
  * 				<ion:name />
  *				<ion:email />
  *				<ion:join_date />
  * 				...
  * 			</ion:article:user>
  *
  */
 public static function tag_writer(FTL_Binding $tag)
 {
     self::load_model('user_model');
     $parent_tag_name = $tag->getParentName();
     $element = $tag->get($parent_tag_name);
     $user_key = $tag->getAttribute('who', 'author');
     if (!is_null($element) && isset($element[$user_key])) {
         $user = self::$ci->user_model->get(array('username' => $element[$user_key]));
         $tag->set('writer', $user);
     }
     return self::wrap($tag, $tag->expand());
 }
Exemplo n.º 2
0
 /**
  * Returns the categories
  *
  * @param	FTL_Binding
  * @param	array/null
  *
  * @return	array
  *
  */
 public static function get_categories(FTL_Binding $tag)
 {
     // Categories model
     self::$ci->load->model('category_model');
     // Current page
     $page = $tag->get('page');
     // Local storage key
     $lsk = '__all__';
     // Get the local cache data
     $element_name = $tag->getParentName();
     $element = $tag->get($element_name);
     if (!is_null($element)) {
         $lsk = '__' . $element_name . '__' . $element['name'];
     }
     // Set the local cache data
     if (!isset(self::$categories[$lsk])) {
         // CSS class to use for the current category
         $active_class = $tag->getAttribute('active_class', 'active');
         // Asked category
         $asked_category_name = self::get_asked_category_uri();
         // Check if the element has one category array (eg. for Articles)
         if (isset($element['categories'])) {
             $categories = $element['categories'];
             // Fix the 'nb' key (nb_articles using this category)
             foreach ($categories as $key => $category) {
                 $categories[$key]['nb'] = '1';
             }
         } else {
             if ($element_name == 'page') {
                 $id_page = !is_null($page) ? $page['id_page'] : NULL;
             } else {
                 $id_page = NULL;
             }
             $categories = self::$ci->category_model->get_categories_list($id_page, Settings::get_lang());
         }
         $page_url = !is_null($page) ? trim($page['absolute_url'], '/') . '/' : Pages::get_home_page_url();
         $category_uri_segment = self::get_config_special_uri_segment('category');
         // Add the URL to the category to each category row
         // Also add the active class
         foreach ($categories as $key => $category) {
             $categories[$key]['url'] = $page_url . $category_uri_segment . '/' . $category['name'];
             $categories[$key]['lang_url'] = $page_url . $category_uri_segment . '/' . $category['name'];
             // Active category ?
             $categories[$key]['active_class'] = $category['name'] == $asked_category_name ? $active_class : '';
             $categories[$key]['is_active'] = !empty($categories[$key]['active_class']) ? TRUE : FALSE;
         }
         self::$categories[$lsk] = array_values($categories);
     }
     return self::$categories[$lsk];
 }
Exemplo n.º 3
0
 /**
  * Outputs the dump of one tag local variable
  *
  * @param FTL_Binding $tag
  *
  * @return string
  *
  */
 public static function tag_trace(FTL_Binding $tag)
 {
     $value = NULL;
     $key = $tag->getAttribute('key');
     $parent = $tag->getAttribute('parent');
     if (is_null($key)) {
         $value = $tag->get($tag->getParentName());
     } else {
         if (!is_null($parent)) {
             $parent = $tag->getParent($parent);
             $value = $parent->get($key);
         } else {
             $value = $tag->get($key);
         }
     }
     $str = '<pre>' . print_r($value, TRUE) . '</pre>';
     return $str;
 }
Exemplo n.º 4
0
 /**
  * Expands if the Form was passed through the validation process
  *
  * @param FTL_Binding $tag
  *
  * @return string
  *
  */
 public static function tag_form_posted(FTL_Binding $tag)
 {
     $form_name = $tag->getParentName();
     $is = $tag->getAttribute('is', TRUE);
     $posted = FALSE;
     if ($form_name == self::$posting_form_name) {
         $posted = TRUE;
     }
     if ($posted == $is) {
         return $tag->expand();
     }
     return '';
 }
Exemplo n.º 5
0
 /**
  * @param FTL_Binding $tag
  *
  * @return string
  *
  */
 public static function tag_static_item_field_options(FTL_Binding $tag)
 {
     $str = '';
     $item = $tag->get('item');
     $field_name = $tag->getParentName();
     if (isset($item['fields'][$field_name])) {
         $field = $item['fields'][$field_name];
         // All available values for this multi-value field
         $all_values = explode("\n", $field['value']);
         foreach ($all_values as $value) {
             $val_label = explode(':', $value);
             $tag->set('value', $val_label[0]);
             $tag->set('label', $val_label[1]);
             $str .= self::wrap($tag, $tag->expand());
         }
     }
     return $str;
 }