private function _get_template_content()
 {
     if ($this->templateContent === false) {
         $content = file_get_contents(PerchUtil::file_path(PERCH_PATH . $this->templatePath));
         // parse subtemplates
         $Template = new PerchTemplate();
         $this->templateContent = $Template->load($content, true);
     }
     return $this->templateContent;
 }
Ejemplo n.º 2
0
 protected function render_related($type, $opening_tag, $condition_contents, $exact_match, $template_contents, $content_vars, $index_in_group)
 {
     $Tag = new PerchXMLTag($opening_tag);
     $out = '';
     if ($Tag->suppress()) {
         return str_replace($exact_match, '', $template_contents);
     }
     if (is_array($content_vars) && isset($content_vars[$Tag->id()]) && PerchUtil::count($content_vars[$Tag->id()])) {
         if (!class_exists('PerchContent_Collections', false)) {
             include_once PERCH_CORE . '/runway/apps/content/PerchContent_Collections.class.php';
             include_once PERCH_CORE . '/runway/apps/content/PerchContent_Collection.class.php';
             include_once PERCH_CORE . '/runway/apps/content/PerchContent_CollectionItems.class.php';
             include_once PERCH_CORE . '/runway/apps/content/PerchContent_CollectionItem.class.php';
         }
         $Collections = $this->_get_cached_object('PerchContent_Collections');
         $value = $Collections->get_data_from_ids_runtime($Tag->collection(), $content_vars[$Tag->id()], $Tag->sort());
         $RelatedTemplate = new PerchTemplate(false, $this->namespace);
         $RelatedTemplate->load($condition_contents);
         if (PerchUtil::bool_val($Tag->scope_parent())) {
             $vars_for_cat = array();
             if (PerchUtil::count($content_vars)) {
                 foreach ($content_vars as $key => $val) {
                     if ($key != $Tag->id() && $key != 'itemJSON') {
                         $vars_for_cat['parent.' . $key] = $val;
                     }
                 }
             }
             $vars_for_cat = array_merge($vars_for_cat, $content_vars[$Tag->id()]);
             foreach ($value as &$item) {
                 $item = array_merge($item, $vars_for_cat);
             }
         }
         $out = $RelatedTemplate->render_group($value, true);
     } else {
         if (strpos($condition_contents, 'perch:noresults')) {
             $s = '/<perch:noresults[^>]*>(.*?)<\\/perch:noresults>/s';
             $count = preg_match_all($s, $condition_contents, $matches, PREG_SET_ORDER);
             if ($count > 0) {
                 foreach ($matches as $match) {
                     $out .= $match[1];
                 }
             }
         }
     }
     return str_replace($exact_match, $out, $template_contents);
 }
 private function _get_template_content()
 {
     if ($this->templateContent === false) {
         $file = PerchUtil::file_path(PERCH_PATH . $this->templatePath);
         if (file_exists($file)) {
             $content = file_get_contents($file);
             // parse subtemplates
             $Template = new PerchTemplate();
             $this->templateContent = $Template->load($content, true);
         } else {
             PerchUtil::debug('Template file not found: ' . $file, 'error');
         }
     }
     return $this->templateContent;
 }
 public function template_attribute($id, $opts)
 {
     $attr_vars = PerchSystem::get_attr_vars();
     if (isset($attr_vars[$id])) {
         return $attr_vars[$id];
     }
     if ($id == 'pageTitle' || $id == 'pageNavText') {
         return $this->details[$id];
     }
     $Template = new PerchTemplate('pages/attributes/' . $opts['template'], 'pages');
     $tag = $Template->find_tag($id, false, true);
     if ($tag) {
         $Template->load($tag);
         return $Template->render($this);
     }
     if (isset($this->details[$id])) {
         return $this->details[$id];
     }
     return false;
 }