BVB Source Codes

The latest thinkphp v5.2 work order system Show smarty_internal_compile_extends.php Source code

Return Download The latest thinkphp v5.2 work order system: download smarty_internal_compile_extends.php Source code - Download The latest thinkphp v5.2 work order system Source code - Type:.php
  1. <?php
  2.  
  3. /**
  4. * Smarty Internal Plugin Compile extend
  5. *
  6. * Compiles the {extends} tag
  7. *
  8. * @package Smarty
  9. * @subpackage Compiler
  10. * @author Uwe Tews
  11. */
  12.  
  13. /**
  14. * Smarty Internal Plugin Compile extend Class
  15. *
  16. * @package Smarty
  17. * @subpackage Compiler
  18. */
  19. class Smarty_Internal_Compile_Extends extends Smarty_Internal_CompileBase {
  20.  
  21.     /**
  22.     * Attribute definition: Overwrites base class.
  23.     *
  24.     * @var array
  25.     * @see Smarty_Internal_CompileBase
  26.     */
  27.     public $required_attributes = array('file');
  28.     /**
  29.     * Attribute definition: Overwrites base class.
  30.     *
  31.     * @var array
  32.     * @see Smarty_Internal_CompileBase
  33.     */
  34.     public $shorttag_order = array('file');
  35.  
  36.     /**
  37.     * Compiles code for the {extends} tag
  38.     *
  39.     * @param array  $args     array with attributes from parser
  40.     * @param object $compiler compiler object
  41.     * @return string compiled code
  42.     */
  43.     public function compile($args, $compiler)
  44.     {
  45.         static $_is_stringy = array('string' => true, 'eval' => true);
  46.         $this->_rdl = preg_quote($compiler->smarty->right_delimiter);
  47.         $this->_ldl = preg_quote($compiler->smarty->left_delimiter);
  48.         $filepath = $compiler->template->source->filepath;
  49.         // check and get attributes
  50.         $_attr = $this->getAttributes($compiler, $args);
  51.         if ($_attr['nocache'] === true) {
  52.             $compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno);
  53.         }
  54.  
  55.         $_smarty_tpl = $compiler->template;
  56.         $include_file = null;
  57.         if (strpos($_attr['file'], '$_tmp') !== false) {
  58.             $compiler->trigger_template_error('illegal value for file attribute', $compiler->lex->taglineno);
  59.         }
  60.         eval('$include_file = ' . $_attr['file'] . ';');
  61.         // create template object
  62.         $_template = new $compiler->smarty->template_class($include_file, $compiler->smarty, $compiler->template);
  63.         // save file dependency
  64.         if (isset($_is_stringy[$_template->source->type])) {
  65.             $template_sha1 = sha1($include_file);
  66.         } else {
  67.             $template_sha1 = sha1($_template->source->filepath);
  68.         }
  69.         if (isset($compiler->template->properties['file_dependency'][$template_sha1])) {
  70.             $compiler->trigger_template_error("illegal recursive call of \"{$include_file}\"", $compiler->lex->line - 1);
  71.         }
  72.         $compiler->template->properties['file_dependency'][$template_sha1] = array($_template->source->filepath, $_template->source->timestamp, $_template->source->type);
  73.         $_content = substr($compiler->template->source->content, $compiler->lex->counter - 1);
  74.         if (preg_match_all("!({$this->_ldl}block\s(.+?){$this->_rdl})!", $_content, $s) !=
  75.         preg_match_all("!({$this->_ldl}/block{$this->_rdl})!", $_content, $c)) {
  76.             $compiler->trigger_template_error('unmatched {block} {/block} pairs');
  77.         }
  78.         preg_match_all("!{$this->_ldl}block\s(.+?){$this->_rdl}|{$this->_ldl}/block{$this->_rdl}|{$this->_ldl}\*([\S\s]*?)\*{$this->_rdl}!", $_content, $_result, PREG_OFFSET_CAPTURE);
  79.         $_result_count = count($_result[0]);
  80.         $_start = 0;
  81.         while ($_start+1 < $_result_count) {
  82.             $_end = 0;
  83.             $_level = 1;
  84.             if (substr($_result[0][$_start][0],0,strlen($compiler->smarty->left_delimiter)+1) == $compiler->smarty->left_delimiter.'*') {
  85.                 $_start++;
  86.                 continue;
  87.             }
  88.             while ($_level != 0) {
  89.                 $_end++;
  90.                 if (substr($_result[0][$_start + $_end][0],0,strlen($compiler->smarty->left_delimiter)+1) == $compiler->smarty->left_delimiter.'*') {
  91.                     continue;
  92.                 }
  93.                 if (!strpos($_result[0][$_start + $_end][0], '/')) {
  94.                     $_level++;
  95.                 } else {
  96.                     $_level--;
  97.                 }
  98.             }
  99.             $_block_content = str_replace($compiler->smarty->left_delimiter . '$smarty.block.parent' . $compiler->smarty->right_delimiter, '%%%%SMARTY_PARENT%%%%',
  100.             substr($_content, $_result[0][$_start][1] + strlen($_result[0][$_start][0]), $_result[0][$_start + $_end][1] - $_result[0][$_start][1] - + strlen($_result[0][$_start][0])));
  101.             Smarty_Internal_Compile_Block::saveBlockData($_block_content, $_result[0][$_start][0], $compiler->template, $filepath);
  102.             $_start = $_start + $_end + 1;
  103.         }
  104.         if ($_template->source->type == 'extends') {
  105.             $_template->block_data = $compiler->template->block_data;
  106.         }
  107.         $compiler->template->source->content = $_template->source->content;
  108.         if ($_template->source->type == 'extends') {
  109.             $compiler->template->block_data = $_template->block_data;
  110.             foreach ($_template->source->components as $key => $component) {
  111.                 $compiler->template->properties['file_dependency'][$key] = array($component->filepath, $component->timestamp, $component->type);
  112.             }
  113.         }
  114.         $compiler->template->source->filepath = $_template->source->filepath;
  115.         $compiler->abort_and_recompile = true;
  116.         return '';
  117.     }
  118.  
  119. }
  120.  
  121. ?>
downloadsmarty_internal_compile_extends.php Source code - Download The latest thinkphp v5.2 work order system Source code
Related Source Codes/Software:
V3.3.6 Workerman high-performance PHP Socket (framework) - High performance PHP Socket framework Workerman re... 2017-05-03
The phosphor meeting room reservation system MRBS (loop reservation v16.0) - The phosphor meeting room reservation system MRBS ... 2017-05-03
IDC v5.2.3 agent center - IDC Centre IDC for exploitation is a PHP+MySQL age... 2017-05-03
Zen master v9.0.1 project management software - Zen is the first domestic open source project mana... 2017-05-03
Ray speed v7.03 employee files management system - Employee files project is various, and some conten... 2017-05-03
HITCMS Haitian responsive electronic mechanical v3.0 foreign trade website source code - HITCMS Haitian response electronic machinery trade... 2017-05-03
Ray v7.02 speed survey system - Lightning speed survey system is a. NET+MSSQL deve... 2017-05-03
Cool HITCMS reactive black v3.0 enterprise website source code - HITCMS-Haitian response black enterprises website ... 2017-05-03
WebOA v17.2 network office automation system - WebOA network using b/s structure development of o... 2017-05-03
Pure imitation of han site source code, one a 】 【 c9cms kernel v1.0 - Generic http://www.wufazhuce.com/Han one · Config... 2017-05-04
zone.js - Implements Zones for JavaScript ... 2017-05-11
dragonfly - A Ruby gem for on-the-fly processing - suitable fo... 2017-05-11
oh-my-fish - The Fishshell Framework. 2017-05-11
canvas-lms - The open LMS by Instructure, Inc. 2017-05-11
ledger - Double-entry accounting system with a command-line... 2017-05-11
Python - My Python Examples http://w... 2017-05-11
blade - 2017-05-11
LaZagne - Credentials recovery project 2017-05-10
Pull-to-Refresh.Rentals-iOS - This project aims to provide a simple and customiz... 2017-05-10
spoon - Distributing instrumentation tests to all your And... 2017-05-10

 Back to top