s
获取当前显示的模板所在的真实路径
@param  string $tpl 模板路径名字
@return string 模板路径
431524
public function template($tpl)
    {
        $extlen = strlen($this->tplext);
        if (substr($tpl, -$extlen) !== $this->tplext) {
            $tpl .= $this->tplext;
        }
        return $this->getTplPath() . DIRECTORY_SEPARATOR . $tpl;
    }
15361
protected function _getTplName()
    {
        // assign template name
        $sTplName = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('tpl');

        if ($sTplName) {
            // security fix so that you cant access files from outside template dir
            $sTplName = basename($sTplName);

            //checking if it is template name, not content id
            if (!getStr()->preg_match("/\.tpl$/", $sTplName)) {
                $sTplName = null;
            } else {
                $sTplName = 'message/' . $sTplName;
            }
        }

        return $sTplName;
    }
143233
public function render($tpl, $data = [])
    {
        $isFirst = false;
        if (!$this->isRending) {
            $this->isRending = $isFirst = true;
            $this->block = new Block();
        }

        if (substr_compare($tpl, $this->ext, -strlen($this->ext)) !== 0) {
            $tpl .= $this->ext;
        }

        if ($this->stacks && $tpl[0] !== '/') {
            $path = dirname(current($this->stacks)) . '/' . $tpl;
        } else {
            $path = $this->getScriptPath() . '/' . $tpl;
        }

        $realPath = realpath($path);
        if ($realPath === false) {
            throw new RenderException('Not found the template: ' . $path);
        }

        array_unshift($this->stacks, $realPath);

        $content = $this->extractRender($realPath, $data);
        if ($isFirst) {
            $content = $this->block->replace($content);
        }

        array_shift($this->stacks);

        return $content;
    }
946333
function(_tpl,_map){
            _map = _map||_o;
            return _tpl.replace(_reg1,function($1,$2){
                var _arr = $2.split('|');
                return _map[_arr[0]]||_arr[1]||'0';
            });
        }
830077
private function gatherTranslationsFromModel (stdClass $model, string $tpl, array $skip)
    {
        $output = '';

        if (array_key_exists ('columns', $model) && !empty($model->columns))
            foreach ($model->columns as $column) {
                if (in_array ($column->Field, $skip))
                    continue;

                $line = str_replace ('{key}', $column->Field, $tpl);
                $line = str_replace ('{value}', str_replace ("_", " ", ucfirst ($column->Field)), $line);

                $output .= $line;
            }

        return $output;
    }
597652
public function fetch($tpl_name, &$tpl_source, &$mtime)
	{
		if(file_exists($tpl_name))
		{
			$tpl_source	= ec(file_get_contents($tpl_name));
			$mtime = filemtime($tpl_name);
			return;
		}

		if(($dirs = $this->smarty->getTemplateVars('template_dirnames')))
		{
			foreach($dirs as $dir)
			{
				if(file_exists($fn = str_replace('xfile:', '', $dir)."/".$tpl_name))
				{
					$tpl_source = ec(file_get_contents($fn));
					$mtime = filemtime($fn);
					return;
				}
			}
		}

		foreach($this->smarty->getTemplateDir() as $d)
		{
			if(file_exists($fn = "$d/$tpl_name"))
			{
				$tpl_source = ec(file_get_contents($fn));
				$mtime = filemtime($fn);
				return;
			}
		}

		foreach(bors_dirs(true) as $dir)
		{
			if(file_exists($fn = $dir.'/templates/'.$tpl_name))
			{
				$tpl_source = ec(file_get_contents($fn));
				$mtime = filemtime($fn);
				return;
			}

			if(file_exists($fn = $dir.'/'.$tpl_name))
			{
				$tpl_source = ec(file_get_contents($fn));
				$mtime = filemtime($fn);
				return;
			}
		}

		$tpl_source = NULL;
		$mtime = NULL;
		return;
	}
643154
public function display($tpl = null)
	{
		$this->frameUrl = JFactory::getApplication()->input->get('url', array(), 'raw');

		$this->addToolbar();
		JHtml::_('jquery.framework');

		return parent::display($tpl);
	}
197229
protected function processTableName(Node $tpl) {
    $mapper = self::getMapper($tpl->getType());
    $mapperTableName = $mapper->getRealTableName();

    $tableName = $tpl->getProperty(self::PROPERTY_TABLE_NAME);
    if ($tableName == null) {
      $tableName = $mapperTableName;

      // if the template is the child of another node of the same type,
      // we must use a table alias
      $parents = $tpl->getParentsEx(null, null, $tpl->getType());
      foreach ($parents as $curParent) {
        $curParentTableName = $curParent->getProperty(self::PROPERTY_TABLE_NAME);
        if ($curParentTableName == $tableName) {
          $tableName .= '_'.($this->aliasCounter++);
        }
      }
      // set the table name for later reference
      $tpl->setProperty(self::PROPERTY_TABLE_NAME, $tableName);
    }

    return ['name' => $mapperTableName, 'alias' => $tableName];
  }
1287730
protected function _setTpl($tpl)
    {
        $this->_tpl = $tpl;

        if ($tpl === true) {
            $this->_tpl = self::TPL_WRAP;
        }

        if ($tpl === false) {
            $this->_tpl = self::TPL_DEFAULT;
        }
    }
561561
public static function getQueryTemplateArray($tpl, array $arguments)
    {
        $argNum = count($arguments);
        for ($i = $argNum; $i > 0; $i--) {
            $tpl = str_replace('%' . $i, $arguments[$i - 1], $tpl);
        }

        return $tpl;
    }
328585
public static function getCreateFunction($tbl): string
    {
        $sql = self::getInstance()->sql_query("SHOW CREATE FUNCTION `$tbl`");

        $q = $sql->fetch(PDO::FETCH_ASSOC);

        return strtr($q['Create Function'], ["\r" => '', "\n" => '', "\t" => '']);
    }
84277
public function renderTemplate($tpl, array $render) {
    $registry = new \Drutiny\Registry();
    $loader = new \Twig_Loader_Filesystem($registry->templateDirs());
    $twig = new \Twig_Environment($loader, array(
      'cache' => sys_get_temp_dir() . '/drutiny/cache',
      'auto_reload' => TRUE,
      // 'debug' => true,
    ));
    // $twig->addExtension(new \Twig_Extension_Debug());

    // Filter to sort arrays by a property.
    $twig->addFilter(new \Twig_SimpleFilter('psort', function (array $array, array $args = []) {
        $property = reset($args);

        usort($array, function ($a, $b) use ($property) {
          if ($a[$property] == $b[$property]) {
            return 0;
          }
          $index = [$a[$property], $b[$property]];
          sort($index);
          return $index[0] == $a[$property] ? 1 : -1;
        });

        return $array;
    },
    ['is_variadic' => true]));

    $template = $twig->load($tpl . '.' . $this->getFormat() . '.twig');
    $contents = $template->render($render);
    return $contents;
  }
53955
public function dump($tpl, array $vars = array())
    {
        $vars['__user__'] = Security::getInstance()->getUser();
        $vars['__admin__'] = Security::getInstance()->getAdmin();
        $vars['__profiles__'] = Security::getCleanProfiles();
        $vars['__flash__'] = Security::getInstance()->getFlashes();
        $vars['__get__'] = Request::getInstance()->getQueryParams();
        $vars['__post__'] = Request::getInstance()->getData();
        $dump = '';
        try {
            $dump = $this->tpl->render($tpl, $vars);
        } catch (\Exception $e) {
            Logger::log($e->getMessage(), LOG_ERR);
        }
        return $dump;
    }
727842
protected function render($tpl = null, array $data = []) {
        if ($this instanceof Controller) {
            if (is_array($tpl)) {
                $data = $tpl;
                $tpl  = null;
            }
            $layout = '~' . $this->layout;
            $data   = $this->onInitLayoutData($data);
            if ($tpl && $tpl{0} == '~') {
                $tpl = substr($tpl, 1);
                $tpl = $this->realPath($tpl . '.tpl');
            } else if ($tpl) {
                $path = str_replace(['\\', 'controllers'], [DS, 'views'], $this->reflectionObj->getNamespaceName());
                $tpl  = $this->realPath($path . DS . $tpl . '.tpl');
            } else {
                $path = str_replace(['\\', 'controllers'], [DS, 'views'], $this->reflectionObj->getNamespaceName());
                $tpl  = $this->realPath($path . DS . $this->ctrName . DS . $this->action . '.tpl');
            }
            $data['workspaceView'] = $tpl;
            $view                  = view($layout, $data);

            return $view;
        }

        return null;
    }
376795
private function realPath($path) {
        $tpls    = explode('/', $path);
        $tpls[0] = App::id2dir($tpls[0]);
        $tpl     = implode('/', $tpls);

        return $tpl;
    }
50533
private function tpl(): string
    {
        if (interface_exists($this->type)) {
            return self::$testing
                ? 'Argument %s passed to x must be an array of objects implementing interface %s, %s given for key %s'
                : 'Argument %s passed to %s must be an array of objects implementing interface %s, %s given for key %s, called in %s on line %s';
        }

        if (class_exists($this->type)) {
            return self::$testing
                ? 'Argument %s passed to x must be an array of %s instances, %s given for key %s'
                : 'Argument %s passed to %s must be an array of %s instances, %s given for key %s, called in %s on line %s';
        }

        return self::$testing
            ? 'Argument %s passed to x must be an array of %s values, %s given for key %s'
            : 'Argument %s passed to %s must be an array of %s values, %s given for key %s, called in %s on line %s';
    }
536515
private function getTplContent($tplFile, $type)
    {
        if ($type === 0 && !is_null($this->layout)) {//主模板且存在模板布局
            $layoutCon = file_get_contents($this->layout);
            $tplCon = file_get_contents($tplFile);

            //获取子模板内容
            $presult = preg_match_all(
                '#' . $this->options['leftDelimiter'] . 'to\s+([a_zA-Z]+?)' . $this->options['rightDelimiter'] . '(.*?)' . $this->options['leftDelimiter'] . '\/to' . $this->options['rightDelimiter'] . '#is',
                $tplCon,
                $tmpl
            );
            $tplCon = null;
            if ($presult > 0) {
                array_shift($tmpl);
            }
            //保存子模板提取完的区块内容
            for ($i = 0; $i < $presult; $i++) {
                $this->layoutBlockData[$tmpl[0][$i]] = $tmpl[1][$i];
            }
            $presult = null;

            //将子模板内容替换到布局文件返回
            $layoutBlockData = &$this->layoutBlockData;
            $layoutCon = preg_replace_callback(
                '#' . $this->options['leftDelimiter'] . 'block\s+([a_zA-Z]+?)' . $this->options['rightDelimiter'] . '(.*?)' . $this->options['leftDelimiter'] . '\/block' . $this->options['rightDelimiter'] . '#is',
                function ($matches) use ($layoutBlockData) {
                    array_shift($matches);
                    if (isset($layoutBlockData[$matches[0]])) {
                        //替换{parent}标签并返回
                        return str_replace(
                            $this->options['rightDelimiter'] . 'parent' . $this->options['rightDelimiter'],
                            $matches[1],
                            $layoutBlockData[$matches[0]]
                        );
                    } else {
                        return '';
                    }
                },
                $layoutCon
            );
            unset($layoutBlockData);
            $this->layoutBlockData = [];
            return $layoutCon;//返回替换完的布局文件内容
        } else {
            return file_get_contents($tplFile);
        }
    }