コード例 #1
0
ファイル: User.php プロジェクト: pompalini/emngo
 /**
  * More logical key for 'group_name' in group table.
  * @TODO : Correct 'group_name' in DB and replace it by 'title'
  *
  * @param FTL_Binding $tag
  *
  * @return string
  *
  */
 public static function tag_user_group_title(FTL_Binding $tag)
 {
     $group_name = $tag->getValue('group_name', 'group');
     return self::output_value($tag, $group_name);
 }
コード例 #2
0
ファイル: Media.php プロジェクト: rockylo/ionize
 /**
  * @param FTL_Binding $tag
  *
  * @return string
  *
  */
 public static function tag_medias(FTL_Binding $tag)
 {
     $str = '';
     // Get the parent 'medias' data array.
     $medias = $tag->getValue();
     // Get all medias id no parent data
     // @todo : Get only medias if asked for.
     // if (empty($medias))
     if (empty($medias) && $tag->getDataParent() == NULL) {
         $medias = self::get_medias($tag);
     }
     if (!empty($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 = self::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 = self::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);
 }
コード例 #3
0
ファイル: Tagmanager.php プロジェクト: pompalini/emngo
 /**
  * Creates and return one formatted HTML A element
  *
  * @param 	FTL_Binding
  * @param	string
  *
  * @return 	string
  *
  */
 public static function create_href(FTL_Binding $tag, $url)
 {
     if ($tag->getAttribute('href') === TRUE) {
         if (validate_url($url)) {
             $title = $url;
             $title_key = $tag->getAttribute('display', 'title');
             $attributes = $tag->getAttribute('attributes');
             if (!is_null($tag->getValue($title_key))) {
                 $title = $tag->getValue($title_key);
             }
             if ($tag->getAttribute('popup') === TRUE) {
                 $url = anchor_popup($url, $title, $attributes);
             } else {
                 $url = anchor($url, $title, $attributes);
             }
         }
     }
     return $url;
 }
コード例 #4
0
ファイル: Navigation.php プロジェクト: trk/ionize
 /**
  * Returns language's direction : 'ltr' or 'rtl'
  *
  * @param FTL_Binding $tag
  *
  * @return string
  *
  */
 public static function tag_language_dir(FTL_Binding $tag)
 {
     $dir = $tag->getValue('direction');
     $dir = ($dir == 1 or empty($dir)) ? 'ltr' : 'rtl';
     return self::output_value($tag, $dir);
 }
コード例 #5
0
ファイル: Form.php プロジェクト: pompalini/emngo
 /**
  * Returns, depending on the type of the field, the corresponding HTML tag attribute
  * mandatory to decide if the data has to be selected or not.
  *
  * @param FTL_Binding $tag
  * @param             $form_name
  * @param             $type
  *
  * @return string
  *
  */
 protected static function get_form_selected_attribute(FTL_Binding $tag, $form_name, $type)
 {
     // Try to get the "form" tag parent
     $data_parent = $tag->getParent('form')->getParent();
     // Is this value the default one ?
     $default = $tag->getAttribute('default');
     // Value of the selectable (radio, select, checkbox)
     $value = $tag->getAttribute('value');
     if (!is_null($form_name)) {
         $found_value = NULL;
         // The form was posted
         if ($form_name == self::$posting_form_name) {
             $found_value = self::$ci->input->post($tag->name);
             // Multiple data : checkboxes or select multiple
             if (is_array($found_value)) {
                 foreach ($found_value as $val) {
                     if ($value == $val) {
                         $found_value = $val;
                         break;
                     }
                 }
             }
         } else {
             // Try to get one stored value from the parent tag
             if (is_object($data_parent)) {
                 $found_value = $tag->getValue($tag->name, $data_parent->name);
                 // Correct multiple data in the same field
                 // This has no impact if IDs are stored in one relation table.
                 if ($type == 'checkbox' or $type == 'select') {
                     $found_value = explode(',', $found_value);
                     foreach ($found_value as $val) {
                         if ($value == $val) {
                             $found_value = $val;
                             break;
                         }
                     }
                 }
                 // Correct if no value was found in the array
                 if (is_array($found_value)) {
                     $found_value = NULL;
                 }
             }
             // If default is set, Set the default value if nothing was found
             if (!$found_value && !is_null($default)) {
                 $found_value = $value;
             }
         }
         if ($value == $found_value) {
             return self::$input_selected_attributes[$type];
         }
     }
     return '';
 }
コード例 #6
0
ファイル: Tagmanager.php プロジェクト: trk/ionize
 /**
  * Evaluates one expression
  *
  * @param FTL_Binding
  * @param $expression
  *
  * @return bool|null		TRUE if the evaluation returns TRUE
  * 							FALSE if the evaluation returns FALSE
  * 							NULL if the evaluation can't be done (error in expression or $value NULL)
  */
 protected static function eval_expression(FTL_Binding $tag, $expression)
 {
     // Result and return
     $return = NULL;
     $result = FALSE;
     // If no key, we compare the value of the tag name
     $keys = $tag->getAttribute('key');
     if (is_null($keys)) {
         $keys = $tag->name;
     }
     // Make an array from keys
     $keys = explode(',', $keys);
     $test_value = NULL;
     foreach ($keys as $idx => $key) {
         $key = trim($key);
         // 1. Try to get the value from tag's data array
         $value = $tag->getValue($key);
         $expression = str_replace('.gt', '>', $expression);
         $expression = str_replace('.lt', '<', $expression);
         $expression = str_replace('.eq', '==', $expression);
         $expression = str_replace('.neq', '!=', $expression);
         // Not convinced...
         // $expression = str_replace('.leqt', '<=', $expression);
         // $expression = str_replace('.geqt', '>=', $expression);
         // 2. Fall down to to tag's locals
         if (is_null($value)) {
             $value = $tag->get($key);
         }
         if ($idx == 0 && strpos($expression, $key) === FALSE) {
             $expression = $key . $expression;
         }
         $test_value = (!$value == (string) (double) $value or is_null($value) or $value == '') ? "'" . $value . "'" : $value;
         // if (gettype($test_value) == 'string' && $test_value == '') $test_value = "'".$test_value."'";
         $expression = str_replace($key, $test_value, $expression);
     }
     // If at least one tested value was not NULL
     if (!is_null($test_value)) {
         $return = @eval("\$result = (" . $expression . ") ? TRUE : FALSE;");
     }
     if ($return === NULL or is_null($test_value)) {
         if ($result) {
             return TRUE;
         } else {
             return FALSE;
         }
     } else {
         return NULL;
     }
 }
コード例 #7
0
ファイル: Article.php プロジェクト: pompalini/emngo
 /**
  *
  * @param FTL_Binding $tag
  * @return string
  *
  */
 public static function tag_article_deny(FTL_Binding $tag)
 {
     // Set this tag as "process tag"
     $tag->setAsProcessTag();
     // 1. Try to get from tag's data array
     $value = $tag->getValue('deny_code', 'article');
     $resource = 'frontend/article/' . $tag->getValue('id_article', 'article');
     if (Authority::cannot('access', $resource, NULL, TRUE)) {
         return self::output_value($tag, $value);
     } else {
         if ($tag->getAttribute('is') == '') {
             self::$trigger_else = 0;
             return self::wrap($tag, $tag->expand());
         }
     }
     return '';
 }