private function print_template($template_path, $template, $media_url, $put_block, $obj, $apps, $index, $path_replace = true) { if ($path_replace) { if (isset($apps[$index]['media_path'])) { $media_url = $media_url . \org\rhaco\net\Path::slash($apps[$index]['media_path'], true, false); } if (isset($apps[$index]['template_path'])) { $template_path = $template_path . \org\rhaco\net\Path::slash($apps[$index]['template_path'], false, true); } } if (!empty($put_block)) { $this->template->put_block(\org\rhaco\net\Path::absolute($this->template_path, $put_block)); } if (isset($apps[$index]['template_super'])) { $this->template->template_super($this->template_path . $apps[$index]['template_super']); } if (is_array($obj) && isset($obj[0]) && isset($obj[1])) { foreach (is_array($obj[1]) ? $obj[1] : array($obj[1]) as $o) { $this->template->set_object_module($o); } $obj = $obj[0]; } $this->template->media_url($media_url); $this->template->cp($obj); if (isset($apps[$index]['vars'])) { $this->template->cp($apps[$index]['vars']); } $this->template->vars('t', new \org\rhaco\flow\module\Helper($this->app_url, $media_url, $apps[$index]['name'], $apps[$index]['num'], $this->entry_file(), $apps, $obj)); $src = $this->template->read(\org\rhaco\net\Path::absolute($template_path, $template)); /** * テンプレートの出力 * @param org.rhaco.lang.Str $obj */ $this->object_module('before_flow_print_template', \org\rhaco\lang\Str::ref($obj, $src)); $src = (string) $obj; header('Content-Length: ' . strlen($src)); print $src; exit; }
private function rtblock($src, $filename) { if (strpos($src, 'rt:block') !== false || strpos($src, 'rt:extends') !== false) { $base_filename = $filename; $blocks = $paths = array(); while (Xml::set($e, '<:>' . $this->rtcomment($src) . '</:>', 'rt:extends') !== false) { $href = $this->ab_path(str_replace("\\", '/', dirname($filename)), $e->in_attr('href')); if (!$e->is_attr('href') || !is_file($href)) { throw new \LogicException('href not found ' . $filename); } if ($filename === $href) { throw new \LogicException('Infinite Recursion Error' . $filename); } Xml::set($bx, '<:>' . $this->rtcomment($src) . '</:>', ':'); foreach ($bx->in('rt:block') as $b) { $n = $b->in_attr('name'); if (!empty($n) && !array_key_exists($n, $blocks)) { $blocks[$n] = $b->value(); $paths[$n] = $filename; } } $src = $this->rttemplate($this->replace_xtag($this->read_src($filename = $href))); $this->selected_template = $e->in_attr('name'); } /** * ブロック展開の前処理 * @param org.rhaco.lang.Str $obj */ $this->object_module('before_block_template', \org\rhaco\lang\Str::ref($obj, $src)); $src = (string) $obj; if (empty($blocks)) { if (Xml::set($bx, '<:>' . $src . '</:>')) { foreach ($bx->in('rt:block') as $b) { $src = str_replace($b->plain(), $b->value(), $src); } } } else { if (!empty($this->template_super)) { $src = $this->read_src($this->ab_path(str_replace("\\", '/', dirname($base_filename)), $this->template_super)); } while (Xml::set($b, $src, 'rt:block')) { $n = $b->in_attr('name'); $src = str_replace($b->plain(), array_key_exists($n, $blocks) ? $blocks[$n] : $b->value(), $src); } } $this->file = $filename; } return $src; }