Пример #1
0
 /**
  * Parse a found variable, detect indexes and filters.
  * @param array found variable
  * @param bool is variable from [array] tag
  * @return string parsed variable
  */
 private function getVariableTagContent($contentTag, $isArray = false)
 {
     $contentObject = null;
     $contentName = preg_replace('|^\\' . ($isArray ? "[#\\d+-" : "{#") . '([a-z0-9_\\-]+)(.*)$|i', '\\1', $contentTag[0]);
     /** Parse array indexes */
     preg_match_all('|\\[([a-z0-9_\\-]+)\\]|i', $contentTag[0], $dimensions);
     $dimensions = $dimensions[1];
     /** Find object */
     if (!is_object($this->templateParamsTmp) && !isset($this->templateParamsTmp[$contentName])) {
         $contentObject = null;
     } else {
         if (!empty($dimensions)) {
             $contentObject = $this->templateParamsTmp[$contentName];
             foreach ($dimensions as $idx => $dimension) {
                 $contentObject = $contentObject[$dimension];
             }
         } else {
             $contentObject = $this->templateParamsTmp[$contentName];
         }
     }
     if (!$isArray) {
         /** Parse filters */
         preg_match_all('|\\|([a-z0-9_\\-:,\\.\'\\s]+)|i', $contentTag[0], $filters);
         $filters = $filters[1];
         /** Apply filters */
         if (!empty($filters)) {
             foreach ($filters as $filter) {
                 $contentObject = Filters::applyFilter($contentObject, $filter);
             }
         }
     }
     return $contentObject;
 }