/** * Returns a dynamic attribute value * Used with attributes which can get data from a database field. * * @param FTL_Binding tag * @param String Attributes name * @param boolean wished return. FALSE by default * * @return Mixed The attribute value of false if nothing is found * protected static function get_attribute(FTL_Binding $tag, $attr, $return=FALSE) { // Try to get the couple array:field // "array" is the data array. For example "page" or "article" // $ar[0] : the data array name // $ar[1] : the field to get $attr = $tag->getAttribute($attr); if ( ! is_null($attr)) { $ar = explode(':', $attr); // If no explode result, simply return the attribute value // In this case, the tag doesn't ask for a dynamic value, but just gives a value // (no ":" separator) if (!isset($ar[1])) { return $attr; } // Here, there is a field to get if (isset($tag->locals->$ar[0])) { // Element can be page, article, etc. $element = $tag->locals->$ar[0]; // First : try to get the field in the standard fields // exemple : $tag->locals->_page[field] if ( ! isset($element[$ar[1]])) { // Second : Try to get the field in the extend fields // exemple : $tag->locals->_page[ion_field] if ( ! isset($element[self::$extend_field_prefix.$ar[1]])) { return FALSE; } else { // Try to get the value if ( ! empty($element[self::$extend_field_prefix.$ar[1]])) { return $element[self::$extend_field_prefix.$ar[1]]; } return FALSE; } } else { // Try to get the value. // Else return false if ( ! empty($element[$ar[1]])) { return $element[$ar[1]]; } else { return FALSE; } } } } return $return; } */ protected function registry($key, $array = NULL) { return self::$context->registry($key, $array); }
/** * Returns a dynamic attribute value * Used with attributes which can get data from a database field. * * @param FTL_Binding tag * @param String Attributes name * @param boolean wished return. FALSE by default * * @return Mixed The attribute value of false if nothing is found * protected static function get_attribute(FTL_Binding $tag, $attr, $return=FALSE) { // Try to get the couple array:field // "array" is the data array. For example "page" or "article" // $ar[0] : the data array name // $ar[1] : the field to get $attr = $tag->getAttribute($attr); if ( ! is_null($attr)) { $ar = explode(':', $attr); // If no explode result, simply return the attribute value // In this case, the tag doesn't ask for a dynamic value, but just gives a value // (no ":" separator) if (!isset($ar[1])) { return $attr; } // Here, there is a field to get if (isset($tag->locals->$ar[0])) { // Element can be page, article, etc. $element = $tag->locals->$ar[0]; // First : try to get the field in the standard fields // exemple : $tag->locals->_page[field] if ( ! isset($element[$ar[1]])) { // Second : Try to get the field in the extend fields // exemple : $tag->locals->_page[ion_field] if ( ! isset($element[self::$extend_field_prefix.$ar[1]])) { return FALSE; } else { // Try to get the value if ( ! empty($element[self::$extend_field_prefix.$ar[1]])) { return $element[self::$extend_field_prefix.$ar[1]]; } return FALSE; } } else { // Try to get the value. // Else return false if ( ! empty($element[$ar[1]])) { return $element[$ar[1]]; } else { return FALSE; } } } } return $return; } */ public static function registry($key, $array = NULL) { return self::$context->registry($key, $array); }