<?php /** * Smarty Internal Plugin Smarty Template Compiler Base * This file contains the basic classes and methods for compiling Smarty templates with lexer/parser * * @package Smarty * @subpackage Compiler * @author Uwe Tews */ /** * Main abstract compiler class * * @package Smarty * @subpackage Compiler * * @property Smarty_Internal_SmartyTemplateCompiler $prefixCompiledCode = ''
return $plugin_object->compile($args, $this); } } throw new SmartyException("Plugin '{$tag}' not callable"); } } $this->trigger_template_error("unknown tag '{$tag}'", null, true); } } }
* @return string compiled code */ public function compileTag($tag, $args, $parameter = array()) { $this->prefixCodeStack[] = $this->prefix_code; $this->prefix_code = array(); $result = $this->compileTag2($tag, $args, $parameter); $this->prefix_code = array_merge($this->prefix_code, array_pop($this->prefixCodeStack)); return $result; } /** * compile variable
$this->_retvalue = $this->compiler->compileTag('private_print_expression', $this->yystack[ $this->yyidx + 0 ]->minor, array('value' => $this->yystack[ $this->yyidx + -1 ]->minor)); } else { $this->_retvalue = $this->compiler->compileTag($this->yystack[ $this->yyidx + -1 ]->minor, $this->yystack[ $this->yyidx + 0 ]->minor); } } // line 406 "../smarty/lexer/smarty_internal_templateparser.y" public function yy_r26() {
self::$yyRuleName[ $yyruleno ]); } $this->_retvalue = $yy_lefthand_side = null; if (isset(self::$yyReduceMap[ $yyruleno ])) { // call the action $this->_retvalue = null; $this->{'yy_r' . self::$yyReduceMap[ $yyruleno ]}(); $yy_lefthand_side = $this->_retvalue; } $yygoto = self::$yyRuleInfo[ $yyruleno ][ 0 ]; $yysize = self::$yyRuleInfo[ $yyruleno ][ 1 ]; $this->yyidx -= $yysize; for ($i = $yysize; $i; $i--) {
if ($yyendofinput && $this->yyidx >= 0) { $yymajor = 0; } else { $yymajor = self::YYNOCODE; } } elseif ($yyact < self::YYNSTATE + self::YYNRULE) { $this->yy_reduce($yyact - self::YYNSTATE); } elseif ($yyact === self::YY_ERROR_ACTION) { if ($this->yyTraceFILE) { fprintf($this->yyTraceFILE, "%sSyntax Error!\n", $this->yyTracePrompt); } if (self::YYERRORSYMBOL) {
// get tokens from lexer and parse them while ($this->parser->lex->yylex()) { if ($this->smarty->_parserdebug) { echo "<pre>Line {$this->parser->lex->line} Parsing {$this->parser->yyTokenName[$this->parser->lex->token]} Token " . htmlentities($this->parser->lex->value) . "</pre>"; } $this->parser->doParse($this->parser->lex->token, $this->parser->lex->value); } // finish parsing process $this->parser->doParse(0, 0); if ($mbEncoding) { mb_internal_encoding($mbEncoding); }
$_content = Smarty_Internal_Compile_Extends::extendsSourceArrayCode($this->template); } else { // get template source $_content = $this->template->source->getContent(); } $_compiled_code = $this->postFilter($this->doCompile($this->preFilter($_content), true)); if (!empty($this->required_plugins[ 'compiled' ]) || !empty($this->required_plugins[ 'nocache' ])) { $_compiled_code = '<?php ' . $this->compileRequiredPlugins() . "?>\n" . $_compiled_code; } } catch (Exception $e) { if ($this->smarty->debugging) { $this->smarty->_debug->end_compile($this->template);
Smarty_Internal_TemplateCompilerBase $parent_compiler = null ) { // get code frame of compiled template $_compiled_code = $template->smarty->ext->_codeFrame->create( $template, $this->compileTemplateSource( $template, $nocache, $parent_compiler ), $this->postFilter($this->blockOrFunctionCode) . join('', $this->mergedSubTemplatesCode), false,
touch($this->filepath); } // compile locking try { // call compiler $_template->loadCompiler(); $this->write($_template, $_template->compiler->compileTemplate($_template)); } catch (Exception $e) { // restore old timestamp in case of error if ($saved_timestamp && is_file($this->filepath)) { touch($this->filepath, $saved_timestamp); } unset($_template->compiler);
if ($source->handler->recompiled) { $source->handler->process($_smarty_tpl); } elseif (!$source->handler->uncompiled) { if (!$this->exists || $smarty->force_compile || ($_smarty_tpl->compile_check && $source->getTimeStamp() > $this->getTimeStamp()) ) { $this->compileTemplateSource($_smarty_tpl); $compileCheck = $_smarty_tpl->compile_check; $_smarty_tpl->compile_check = Smarty::COMPILECHECK_OFF; $this->loadCompiledTemplate($_smarty_tpl); $_smarty_tpl->compile_check = $compileCheck; } else { $_smarty_tpl->mustCompile = true;
if (!isset($_template->smarty->_debug)) { $_template->smarty->_debug = new Smarty_Internal_Debug(); } $_template->smarty->_debug->start_render($_template); } if (!$this->processed) { $this->process($_template); } if (isset($_template->cached)) { $_template->cached->file_dependency = array_merge($_template->cached->file_dependency, $this->file_dependency); } if ($_template->source->handler->uncompiled) {
} $this->cached->render($this, $no_output_filter); } else { if (!isset($this->compiled) || $this->compiled->compile_id !== $this->compile_id) { $this->loadCompiled(true); } $this->compiled->render($this); } // display or fetch if ($display) { if ($this->caching && $this->smarty->cache_modified_check) { $this->smarty->ext->_cacheModify->cacheModifiedCheck( $this->cached,
$smarty->_debug->end_render($tpl); } } else { if (isset($tpl->compiled)) { $tpl->compiled->render($tpl); } else { $tpl->render(); } } } /** * Get called sub-templates and save call count
<?php $_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['comments']->value, 'comment'); $_smarty_tpl->tpl_vars['comment']->do_else = true; if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['comment']->value) { $_smarty_tpl->tpl_vars['comment']->do_else = false; ?> <?php $_smarty_tpl->_subTemplateRender('file:common/comment.tpl', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array('comment'=>$_smarty_tpl->tpl_vars['comment']->value,'level'=>1,'reply'=>$_smarty_tpl->tpl_vars['reply']->value), 0, true); ?> <?php } $_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?> </div> <?php } else { ?>
} if ($_template->startRenderCallbacks) { foreach ($_template->startRenderCallbacks as $callback) { call_user_func($callback, $_template); } } $unifunc($_template); foreach ($_template->endRenderCallbacks as $callback) { call_user_func($callback, $_template); } $_template->isRenderingCache = false; } catch (Exception $e) { $_template->isRenderingCache = false;
$_template->cached->file_dependency = array_merge($_template->cached->file_dependency, $this->file_dependency); } if ($_template->source->handler->uncompiled) { $_template->source->handler->renderUncompiled($_template->source, $_template); } else { $this->getRenderedTemplateCode($_template); } if ($_template->caching && $this->has_nocache_code) { $_template->cached->hashes[ $this->nocache_hash ] = true; } if ($_template->smarty->debugging) { $_template->smarty->_debug->end_render($_template);
} $this->cached->render($this, $no_output_filter); } else { if (!isset($this->compiled) || $this->compiled->compile_id !== $this->compile_id) { $this->loadCompiled(true); } $this->compiled->render($this); } // display or fetch if ($display) { if ($this->caching && $this->smarty->cache_modified_check) { $this->smarty->ext->_cacheModify->cacheModifiedCheck( $this->cached,
} ob_start(); $template->_mergeVars(); if (!empty(Smarty::$global_tpl_vars)) { $template->tpl_vars = array_merge(Smarty::$global_tpl_vars, $template->tpl_vars); } $result = $template->render(false, $function); $template->_cleanUp(); if ($saveVars) { $template->tpl_vars = $savedTplVars; $template->config_vars = $savedConfigVars; } else { if (!$function && !isset(Smarty_Internal_Template::$tplObjCache[ $template->templateId ])) {
* @throws Exception * @throws SmartyException * @return string rendered template output */ public function fetch($template = null, $cache_id = null, $compile_id = null, $parent = null) { $result = $this->_execute($template, $cache_id, $compile_id, $parent, 0); return $result === null ? ob_get_clean() : $result; } /** * displays a Smarty template *
// Make Yii params available as smarty config variables $template->config_vars = Yii::$app->params; $template->assign('app', \Yii::$app); $template->assign('this', $view); return $template->fetch(); } /** * Resolves Yii alias into file path * * @param string $type
if (isset($this->renderers[$ext])) { if (is_array($this->renderers[$ext]) || is_string($this->renderers[$ext])) { $this->renderers[$ext] = Yii::createObject($this->renderers[$ext]); } /* @var $renderer ViewRenderer */ $renderer = $this->renderers[$ext]; $output = $renderer->render($this, $viewFile, $params); } else { $output = $this->renderPhpFile($viewFile, $params); } $this->afterRender($viewFile, $params, $output); }
* @throws InvalidCallException if the view cannot be resolved. * @see renderFile() */ public function render($view, $params = [], $context = null) { $viewFile = $this->findViewFile($view, $context); return $this->renderFile($viewFile, $params, $context); } /** * Finds the view file based on the given view name. * @param string $view the view name or the [path alias](guide:concept-aliases) of the view file. Please refer to [[render()]] * on how to specify this parameter.
* @param array $params the parameters (name-value pairs) that should be made available in the view. * @return string the rendering result. * @throws InvalidArgumentException if the view file does not exist. */ public function render($view, $params = []) { return $this->getView()->render($view, $params, $this); } /** * Renders a view file. * @param string $file the view file to be rendered. This can be either a file path or a [path alias](guide:concept-aliases). * @param array $params the parameters (name-value pairs) that should be made available in the view.
if (Yii::$app->user->id && !empty($this->reply)) { $reply = true; } return $this->render('CommentWidget.tpl', array('post_id' => $this->post, 'post_model' => $this->model, 'model' => $model, 'comments' => $comments, 'reply' => $reply)); } protected function buildTree(array &$elements, $parentId = 0) { $branch = array();
try { /* @var $widget Widget */ $config['class'] = get_called_class(); $widget = Yii::createObject($config); $out = ''; if ($widget->beforeRun()) { $result = $widget->run(); $out = $widget->afterRun($result); } } catch (\Exception $e) { // close the output buffer opened above if it has not been closed already if (ob_get_level() > 0) { ob_end_clean();
> </div> </div> <?php }?> <?php echo frontend\components\CommentWidget::widget(array('model'=>'article','post'=>$_smarty_tpl->tpl_vars['article']->value['id'],'reply'=>$_smarty_tpl->tpl_vars['article']->value['allow_comments']));?> <?php if (empty($_smarty_tpl->tpl_vars['article']->value['full_text']) && !empty($_smarty_tpl->tpl_vars['source']->value)) {?> <div class="panel panel-default"> <div class="panel-heading">Текст статьи</div> <div class="panel-body" style="word-wrap: break-word;">
} if ($_template->startRenderCallbacks) { foreach ($_template->startRenderCallbacks as $callback) { call_user_func($callback, $_template); } } $unifunc($_template); foreach ($_template->endRenderCallbacks as $callback) { call_user_func($callback, $_template); } $_template->isRenderingCache = false; } catch (Exception $e) { $_template->isRenderingCache = false;
$_template->cached->file_dependency = array_merge($_template->cached->file_dependency, $this->file_dependency); } if ($_template->source->handler->uncompiled) { $_template->source->handler->renderUncompiled($_template->source, $_template); } else { $this->getRenderedTemplateCode($_template); } if ($_template->caching && $this->has_nocache_code) { $_template->cached->hashes[ $this->nocache_hash ] = true; } if ($_template->smarty->debugging) { $_template->smarty->_debug->end_render($_template);
} $this->cached->render($this, $no_output_filter); } else { if (!isset($this->compiled) || $this->compiled->compile_id !== $this->compile_id) { $this->loadCompiled(true); } $this->compiled->render($this); } // display or fetch if ($display) { if ($this->caching && $this->smarty->cache_modified_check) { $this->smarty->ext->_cacheModify->cacheModifiedCheck( $this->cached,
} ob_start(); $template->_mergeVars(); if (!empty(Smarty::$global_tpl_vars)) { $template->tpl_vars = array_merge(Smarty::$global_tpl_vars, $template->tpl_vars); } $result = $template->render(false, $function); $template->_cleanUp(); if ($saveVars) { $template->tpl_vars = $savedTplVars; $template->config_vars = $savedConfigVars; } else { if (!$function && !isset(Smarty_Internal_Template::$tplObjCache[ $template->templateId ])) {
* @throws Exception * @throws SmartyException * @return string rendered template output */ public function fetch($template = null, $cache_id = null, $compile_id = null, $parent = null) { $result = $this->_execute($template, $cache_id, $compile_id, $parent, 0); return $result === null ? ob_get_clean() : $result; } /** * displays a Smarty template *
// Make Yii params available as smarty config variables $template->config_vars = Yii::$app->params; $template->assign('app', \Yii::$app); $template->assign('this', $view); return $template->fetch(); } /** * Resolves Yii alias into file path * * @param string $type
if (isset($this->renderers[$ext])) { if (is_array($this->renderers[$ext]) || is_string($this->renderers[$ext])) { $this->renderers[$ext] = Yii::createObject($this->renderers[$ext]); } /* @var $renderer ViewRenderer */ $renderer = $this->renderers[$ext]; $output = $renderer->render($this, $viewFile, $params); } else { $output = $this->renderPhpFile($viewFile, $params); } $this->afterRender($viewFile, $params, $output); }
* @throws InvalidCallException if the view cannot be resolved. * @see renderFile() */ public function render($view, $params = [], $context = null) { $viewFile = $this->findViewFile($view, $context); return $this->renderFile($viewFile, $params, $context); } /** * Finds the view file based on the given view name. * @param string $view the view name or the [path alias](guide:concept-aliases) of the view file. Please refer to [[render()]] * on how to specify this parameter.
* These parameters will not be available in the layout. * @return string the rendering result. * @throws InvalidArgumentException if the view file or the layout file does not exist. */ public function render($view, $params = []) { $content = $this->getView()->render($view, $params, $this); return $this->renderContent($content); } /** * Renders a static string by applying a layout. * @param string $content the static string being rendered
// Похожие статьи $same = $article->getSameArticles(); // Текст $source = ArticleSource::find()->where(['article' => $article->id])->one(); return $this->render('/article/full.tpl', ['article' => $article, 'issue' => $issue, 'same' => $same, 'source' => $source, 'previous_article' => $previous_article, 'next_article' => $next_article]); } public function actionTag($tag, $page = 1) { $tag = Tag::find()->where(['name' => $tag])->one(); if (empty($tag)) {
$args = $this->controller->bindActionParams($this, $params); Yii::debug('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()', __METHOD__); if (Yii::$app->requestedParams === null) { Yii::$app->requestedParams = $args; } return call_user_func_array([$this->controller, $this->actionMethod], $args); } }
} $result = null; if ($runAction && $this->beforeAction($action)) { // run the action $result = $action->runWithParams($params); $result = $this->afterAction($action, $result); // call afterAction on modules foreach ($modules as $module) { /* @var $module Module */
$parts = $this->createController($route); if (is_array($parts)) { /* @var $controller Controller */ list($controller, $actionID) = $parts; $oldController = Yii::$app->controller; Yii::$app->controller = $controller; $result = $controller->runAction($actionID, $params); if ($oldController !== null) { Yii::$app->controller = $oldController; } return $result; }
$params = $this->catchAll; unset($params[0]); } try { Yii::debug("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } $response = $this->getResponse(); if ($result !== null) {
{ try { $this->state = self::STATE_BEFORE_REQUEST; $this->trigger(self::EVENT_BEFORE_REQUEST); $this->state = self::STATE_HANDLING_REQUEST; $response = $this->handleRequest($this->getRequest()); $this->state = self::STATE_AFTER_REQUEST; $this->trigger(self::EVENT_AFTER_REQUEST); $this->state = self::STATE_SENDING_RESPONSE; $response->send();
$config = yii\helpers\ArrayHelper::merge( require(__DIR__ . '/../koncept/common/config/main.php'), require(__DIR__ . '/../koncept/frontend/config/web.php') ); (new yii\web\Application($config))->run();
$_GET = [ 'lang' => '', 'year' => '2014', 'art' => '64373', ];