コード例 #1
0
 public function render($vars = array())
 {
     $system_vars = PerchSystem::get_vars();
     if (is_array($system_vars) && is_array($vars)) {
         $vars = array_merge($system_vars, $vars);
     }
     $this->content_vars = $vars;
     $contents = $this->template;
     $i = 0;
     while (strpos($contents, 'perch:form') > 0 && $i < 10) {
         $s = '/(<perch:form[^>]*>)((?!perch:form).*?)(<\\/perch:form>)/s';
         $count = preg_match_all($s, $contents, $matches, PREG_SET_ORDER);
         if ($count > 0) {
             foreach ($matches as $match) {
                 $this->submitted = null;
                 $contents = $this->_render_form($match[0], $match[1], $match[2], $match[3], $contents, $vars);
             }
         }
         $i++;
     }
     return $contents;
 }
コード例 #2
0
 public function render($content_vars, $index_in_group = false)
 {
     $system_vars = PerchSystem::get_vars();
     if (is_object($content_vars)) {
         $ids = $this->find_all_tag_ids($this->namespace);
         $content_vars = $content_vars->to_array($ids);
     }
     if (is_array($system_vars) && is_array($content_vars)) {
         $content_vars = array_merge($system_vars, $content_vars);
     }
     if (!is_array($content_vars)) {
         $content_vars = array();
     }
     if ($index_in_group === false && !count($content_vars)) {
         PerchUtil::debug_badge('0');
     }
     $template = str_replace(PERCH_PATH, '', $this->template);
     $path = $this->file;
     $contents = $this->load();
     // API HANDLERS
     $contents = $this->render_template_handlers($content_vars, $contents);
     // BLOCKS
     $contents = $this->parse_blocks($contents, $content_vars);
     // SINGLE BLOCK
     $contents = $this->render_block($contents, $content_vars);
     // REPEATERS
     $contents = $this->parse_repeaters($contents, $content_vars);
     // RELATED
     $contents = $this->parse_related($contents, $content_vars);
     // CATEGORIES
     $contents = $this->parse_categories($contents, $content_vars);
     // FORMS
     if ($template) {
         $contents = str_replace('<perch:form ', '<perch:form template="' . $template . '" ', $contents);
     }
     // BEFORE
     $contents = $this->parse_paired_tags('before', true, $contents, $content_vars, $index_in_group, 'parse_conditional');
     // AFTER
     $contents = $this->parse_paired_tags('after', true, $contents, $content_vars, $index_in_group, 'parse_conditional');
     // IF
     $contents = $this->parse_paired_tags('if', false, $contents, $content_vars, $index_in_group, 'parse_conditional');
     // EVERY
     $contents = $this->parse_paired_tags('every', false, $contents, $content_vars, $index_in_group, 'parse_every');
     // CONTENT
     $contents = $this->replace_content_tags($this->namespace, $content_vars, $contents);
     // SHOW ALL
     $contents = $this->process_show_all($content_vars, $contents);
     // HELP
     $contents = $this->remove_help($contents);
     // NO RESULTS
     $contents = $this->remove_noresults($contents);
     // RUNWAY
     $contents = $this->remove_runway_tags($contents);
     // UNMATCHED TAGS
     $contents = $this->remove_unmatched_tags($contents);
     return $contents;
 }