当前位置: 首页>>代码示例>>PHP>>正文


PHP Smarty::getTemplateDir方法代码示例

本文整理汇总了PHP中Smarty::getTemplateDir方法的典型用法代码示例。如果您正苦于以下问题:PHP Smarty::getTemplateDir方法的具体用法?PHP Smarty::getTemplateDir怎么用?PHP Smarty::getTemplateDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Smarty的用法示例。


在下文中一共展示了Smarty::getTemplateDir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: buildUniqueResourceName

 /**
  * modify resource_name according to resource handlers specifications
  *
  * @param  Smarty  $smarty        Smarty instance
  * @param  string  $resource_name resource_name to make unique
  * @param  boolean $isConfig      flag for config resource
  *
  * @return string unique resource name
  */
 public function buildUniqueResourceName(Smarty $smarty, $resource_name, $isConfig = false)
 {
     if ($isConfig) {
         if (!isset($smarty->_joined_config_dir)) {
             $smarty->getTemplateDir(null, true);
         }
         return get_class($this) . '#' . $smarty->_joined_config_dir . '#' . $resource_name;
     } else {
         if (!isset($smarty->_joined_template_dir)) {
             $smarty->getTemplateDir();
         }
         return get_class($this) . '#' . $smarty->_joined_template_dir . '#' . $resource_name;
     }
 }
开发者ID:vanderlee,项目名称:smarty,代码行数:23,代码来源:smarty_resource.php

示例2: loadPage

 /**
  * Loads page.
  */
 private function loadPage()
 {
     $this->lang = new Language("SF Global");
     $this->langPages = new Language("Pages lang");
     $currLang = $this->url->getCurrentLanguage();
     $this->lang->loadLang($this->config->get('main_lang_dir') . $currLang . "/{$currLang}.php");
     $this->langPages->loadLang($this->config->get('main_lang_dir') . $currLang . "/{$currLang}_pages.php");
     $currPageName = $this->url->getCurrentPageName();
     $actualPageName = $this->langPages->getIndex($currPageName);
     if ($actualPageName === null) {
         $actualPageName = $currPageName;
     }
     $tplDir = $this->tplEngine->getTemplateDir(0);
     $this->loadClassCheckInterface('component_loader', 'Framework\\Core\\FrameworkClasses\\Components\\IComponentLoader');
     $this->loadClassCheckInterface('page_loader', 'Framework\\Core\\FrameworkClasses\\Routing\\IPageLoader');
     $componentLoader = new SFComponentLoader($this->config->get('app_dir') . 'components/output/', $tplDir . 'out_components/', $this->config->get('output_components'), $this->config->get('out_comp_ns'), $this->config->get('logic_components'), $this->config->get('logic_comp_ns'), $this->tplEngine, $this->config->get('config_type'), $this->url->getCurrentLanguage(), $this->config->get('wrap_components'), $this->config->get('logic_components_dir'), $this->config->get('output_components_options'), $this->dbFactory, $this->config->get('common_output_components'), $this->config->get('current_page'), $this->logger, $this);
     $ajaxLevel = $this->getAjaxLevel();
     $loadSpecificComponent = false;
     if (!is_numeric($ajaxLevel)) {
         $loadSpecificComponent = $ajaxLevel;
     }
     $pageLoader = new PageLoader($this->config->get('pages'), $this->config->get('pages_out_components'), $this->config->get('pages_templates'), $this->config->get('empty_page_index'), $this->config->get('maintenance_mode'), $this->tplEngine, $tplDir . 'pages/', $componentLoader, $this->logger, $this->url, $this->config->get('output_components_url'), $this->config->get('pages_url'), $loadSpecificComponent);
     $pageLoader->pageNotFoundPage = $this->config->get('page_not_found_page');
     $pageLoader->pageMaintenance = $this->config->get('page_maintenance');
     $header = "";
     $content = $pageLoader->getCurrentPageContent($actualPageName, $header);
     if ($loadSpecificComponent !== false || $ajaxLevel == 2) {
         $ajaxData = array('content' => $content, 'header' => $header);
         $this->outputJsonEncoded($ajaxData);
     }
     $header = $this->genHeaderIndex() . $header;
     $this->tplEngine->assign('header', $header);
     // assign to the main tpl
     $this->tplEngine->assign('mainContent', $content);
 }
开发者ID:Miljankg,项目名称:simplef,代码行数:38,代码来源:SF.class.php

示例3: _tplTemplateExists

 /**
  * @param string $sTemplate
  * @param bool $bException
  *
  * @return bool|void
  * @throws Exception
  */
 protected function _tplTemplateExists($sTemplate, $bException = false)
 {
     if (!$this->oSmarty) {
         $this->_tplInit();
     }
     $bResult = $this->oSmarty->templateExists($sTemplate);
     $sSkin = $this->GetConfigSkin();
     if (!$bResult && $bException) {
         $sMessage = 'Can not find the template "' . $sTemplate . '" in skin "' . $sSkin . '"';
         if ($aTpls = $this->GetSmartyObject()->template_objects) {
             if (is_array($aTpls)) {
                 $sMessage .= ' (from: ';
                 foreach ($aTpls as $oTpl) {
                     $sMessage .= $oTpl->template_resource . '; ';
                 }
                 $sMessage .= ')';
             }
         }
         $sMessage .= '. ';
         $oSkin = E::ModuleSkin()->GetSkin($sSkin);
         if ((!$oSkin || $oSkin->GetCompatible() != 'alto') && !E::ActivePlugin('ls')) {
             $sMessage .= 'Probably you need to activate plugin "Ls".';
         }
         // записываем доп. информацию - пути к шаблонам Smarty
         $sErrorInfo = 'Template Dirs: ' . implode('; ', $this->oSmarty->getTemplateDir());
         $this->_error($sMessage, $sErrorInfo);
         return false;
     }
     if ($bResult && ($sResult = $this->_getTemplatePath($sSkin, $sTemplate))) {
         $sTemplate = $sResult;
     }
     return $bResult ? $sTemplate : $bResult;
 }
开发者ID:anp135,项目名称:altocms,代码行数:40,代码来源:Viewer.class.php

示例4: compileAll

 /**
  * Compile all template or config files
  *
  * @param \Smarty $smarty
  * @param  string $extension     template file name extension
  * @param  bool   $force_compile force all to recompile
  * @param  int    $time_limit    set maximum execution time
  * @param  int    $max_errors    set maximum allowed errors
  * @param bool    $isConfig      flag true if called for config files
  *
  * @return int number of template files compiled
  */
 protected function compileAll(Smarty $smarty, $extension, $force_compile, $time_limit, $max_errors, $isConfig = false)
 {
     // switch off time limit
     if (function_exists('set_time_limit')) {
         @set_time_limit($time_limit);
     }
     $_count = 0;
     $_error_count = 0;
     $sourceDir = $isConfig ? $smarty->getConfigDir() : $smarty->getTemplateDir();
     // loop over array of source directories
     foreach ($sourceDir as $_dir) {
         $_dir_1 = new RecursiveDirectoryIterator($_dir);
         $_dir_2 = new RecursiveIteratorIterator($_dir_1);
         foreach ($_dir_2 as $_fileinfo) {
             $_file = $_fileinfo->getFilename();
             if (substr(basename($_fileinfo->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
                 continue;
             }
             if (!substr_compare($_file, $extension, -strlen($extension)) == 0) {
                 continue;
             }
             if ($_fileinfo->getPath() !== substr($_dir, 0, -1)) {
                 $_file = substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file;
             }
             echo "\n<br>", $_dir, '---', $_file;
             flush();
             $_start_time = microtime(true);
             $_smarty = clone $smarty;
             $_smarty->force_compile = $force_compile;
             try {
                 /* @var Smarty_Internal_Template $_tpl */
                 $_tpl = new $smarty->template_class($_file, $_smarty);
                 $_tpl->caching = Smarty::CACHING_OFF;
                 $_tpl->source = $isConfig ? Smarty_Template_Config::load($_tpl) : Smarty_Template_Source::load($_tpl);
                 if ($_tpl->mustCompile()) {
                     $_tpl->compileTemplateSource();
                     $_count++;
                     echo ' compiled in  ', microtime(true) - $_start_time, ' seconds';
                     flush();
                 } else {
                     echo ' is up to date';
                     flush();
                 }
             } catch (Exception $e) {
                 echo "\n<br>        ------>Error: ", $e->getMessage(), "<br><br>\n";
                 $_error_count++;
             }
             // free memory
             unset($_tpl);
             $_smarty->_clearTemplateCache();
             if ($max_errors !== null && $_error_count == $max_errors) {
                 echo "\n<br><br>too many errors\n";
                 exit;
             }
         }
     }
     echo "\n<br>";
     return $_count;
 }
开发者ID:yanlyan,项目名称:si_ibuhamil,代码行数:71,代码来源:smarty_internal_method_compilealltemplates.php

示例5: smartyNodePorts

 public function smartyNodePorts(Smarty $hook_data)
 {
     $template_dirs = $hook_data->getTemplateDir();
     $plugin_templates = PLUGINS_DIR . DIRECTORY_SEPARATOR . LMSNodePortsPlugin::PLUGIN_DIRECTORY_NAME . DIRECTORY_SEPARATOR . 'templates';
     array_unshift($template_dirs, $plugin_templates);
     $hook_data->setTemplateDir($template_dirs);
     return $hook_data;
 }
开发者ID:kyob,项目名称:lms-plugins,代码行数:8,代码来源:NodePortsHandler.php

示例6: insertDefaultTemplateDir

 /**
  * Inserts plugin templates dir at beginning of smarty template dir list
  */
 public static function insertDefaultTemplateDir(Smarty $smarty)
 {
     $template_dirs = $smarty->getTemplateDir();
     $reflector = new ReflectionClass(get_called_class());
     $plugin_templates = dirname($reflector->getFileName()) . DIRECTORY_SEPARATOR . 'templates';
     array_unshift($template_dirs, $plugin_templates);
     $smarty->setTemplateDir($template_dirs);
 }
开发者ID:vargburzum,项目名称:lms,代码行数:11,代码来源:LMSPlugin.php

示例7: compileAllTemplates

 /**
  * Compile all template files
  *
  * @param  string $extension     template file name extension
  * @param  bool   $force_compile force all to recompile
  * @param  int    $time_limit    set maximum execution time
  * @param  int    $max_errors    set maximum allowed errors
  * @param  Smarty $smarty        Smarty instance
  *
  * @return integer number of template files compiled
  */
 public static function compileAllTemplates($extension, $force_compile, $time_limit, $max_errors, Smarty $smarty)
 {
     // switch off time limit
     if (function_exists('set_time_limit')) {
         @set_time_limit($time_limit);
     }
     $smarty->force_compile = $force_compile;
     $_count = 0;
     $_error_count = 0;
     // loop over array of template directories
     foreach ($smarty->getTemplateDir() as $_dir) {
         $_compileDirs = new RecursiveDirectoryIterator($_dir);
         $_compile = new RecursiveIteratorIterator($_compileDirs);
         foreach ($_compile as $_fileinfo) {
             $_file = $_fileinfo->getFilename();
             if (substr(basename($_fileinfo->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
                 continue;
             }
             if (!substr_compare($_file, $extension, -strlen($extension)) == 0) {
                 continue;
             }
             if ($_fileinfo->getPath() == substr($_dir, 0, -1)) {
                 $_template_file = $_file;
             } else {
                 $_template_file = substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file;
             }
             echo '<br>', $_dir, '---', $_template_file;
             flush();
             $_start_time = microtime(true);
             try {
                 $_tpl = $smarty->createTemplate($_template_file, null, null, null, false);
                 if ($_tpl->mustCompile()) {
                     $_tpl->compileTemplateSource();
                     $_count++;
                     echo ' compiled in  ', microtime(true) - $_start_time, ' seconds';
                     flush();
                 } else {
                     echo ' is up to date';
                     flush();
                 }
             } catch (Exception $e) {
                 echo 'Error: ', $e->getMessage(), "<br><br>";
                 $_error_count++;
             }
             // free memory
             $smarty->template_objects = array();
             $_tpl->smarty->template_objects = array();
             $_tpl = null;
             if ($max_errors !== null && $_error_count == $max_errors) {
                 echo '<br><br>too many errors';
                 exit;
             }
         }
     }
     return $_count;
 }
开发者ID:chaoyanjie,项目名称:HiBlog,代码行数:67,代码来源:smarty_internal_utility.php

示例8: smartyCashImportOKBS

 public function smartyCashImportOKBS(Smarty $hook_data)
 {
     $template_dirs = $hook_data->getTemplateDir();
     $plugin_templates = PLUGINS_DIR . DIRECTORY_SEPARATOR . LMSCustomersAgePlugin::PLUGIN_DIRECTORY_NAME . DIRECTORY_SEPARATOR . 'templates';
     $custom_templates_dir = ConfigHelper::getConfig('phpui.custom_templates_dir');
     if (!empty($custom_templates_dir) && file_exists($plugin_templates . DIRECTORY_SEPARATOR . $custom_templates_dir) && !is_file($plugin_tempaltes . DIRECTORY_SEPARATOR . $custom_templates_dir)) {
         $plugin_templates = PLUGINS_DIR . DIRECTORY_SEPARATOR . LMSCustomersAgePlugin::PLUGIN_DIRECTORY_NAME . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $custom_templates_dir;
     }
     array_unshift($template_dirs, $plugin_templates);
     $hook_data->setTemplateDir($template_dirs);
     return $hook_data;
 }
开发者ID:kyob,项目名称:lms-plugins,代码行数:12,代码来源:CashImportOKBSHandler.php

示例9: smarty_function_include_file

/**
 * Includes a file in template. Handy for adding html files to tpl files
 *
 * @param array $Params The parameters passed into the function.
 * The parameters that can be passed to this function are as follows.
 * - <b>name</b>: The name of the file.
 * @param Smarty $Smarty The smarty object rendering the template.
 * @return string The rendered asset.
 */
function smarty_function_include_file($Params, &$Smarty)
{
    $Name = ltrim(val('name', $Params), '/');
    if (strpos($Name, '..') !== false) {
        return '<!-- Error, moving up directory path not allowed -->';
    }
    if (isUrl($Name)) {
        return '<!-- Error, urls are not allowed -->';
    }
    $filename = rtrim($Smarty->getTemplateDir(), '/') . '/' . $Name;
    if (!file_exists($filename)) {
        return '<!-- Error, file does not exist -->';
    }
    return file_get_contents($filename);
}
开发者ID:vanilla,项目名称:vanilla,代码行数:24,代码来源:function.include_file.php

示例10: smarty_function_route

/**
 * Wrapper for @see Router::reverse(). Additional params are _fullurl and _https, for links with https-protocol and
 * absolute urls. Define the route name with _name and everything else is used as arguments, you may also specify all
 * arguments at once using the 'arguments' param.
 *
 * @package FeM\sPof\template\smartyPlugins
 * @author dangerground
 * @since 1.0
 *
 * @api
 *
 * @throws FeM\sPof\exception\SmartyTemplateException
 *
 * @param array $params
 * @param Smarty $smarty
 *
 * @return string
 */
function smarty_function_route($params, &$smarty)
{
    // get array elements as single params
    if (isset($params['arguments']) && is_array($params['arguments'])) {
        $params = array_merge($params['arguments'], $params);
        unset($params['arguments']);
    }
    $arguments = $params;
    unset($arguments['_name']);
    $fullurl = isset($arguments['_fullurl']) ? $arguments['_fullurl'] : false;
    unset($arguments['_fullurl']);
    $https = isset($arguments['_https']) || isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'on' ? $arguments['_https'] : true;
    unset($arguments['_https']);
    try {
        $server = FeM\sPof\Config::get('server');
        $basedir = 'https://' . $_SERVER['SERVER_NAME'] . $server['path'];
        return ($fullurl ? $https ? $basedir : preg_replace('#^https#', 'http', $basedir) : '') . \FeM\sPof\Router::reverse($params['_name'], $arguments);
    } catch (\InvalidArgumentException $e) {
        throw new \FeM\sPof\exception\SmartyTemplateException(__FUNCTION__ . ': ' . $e->getMessage(), $smarty->getTemplateDir()[0] . $smarty->template_resource, $e);
    }
}
开发者ID:fem,项目名称:spof,代码行数:39,代码来源:function.route.php

示例11: __get

 /**
  * get Smarty property in template context
  *
  * @param string $property_name property name
  */
 public function __get($property_name)
 {
     switch ($property_name) {
         case 'source':
             if (empty($this->template_resource)) {
                 throw new SmartyException("Unable to parse resource name \"{$this->template_resource}\"");
             }
             $this->source = Smarty_Resource::source($this);
             // cache template object under a unique ID
             // do not cache eval resources
             if ($this->source->type != 'eval') {
                 $this->smarty->template_objects[sha1(join(DIRECTORY_SEPARATOR, $this->smarty->getTemplateDir()) . $this->template_resource . $this->cache_id . $this->compile_id)] = $this;
             }
             return $this->source;
         case 'compiled':
             $this->compiled = $this->source->getCompiled($this);
             return $this->compiled;
         case 'cached':
             if (!class_exists('Smarty_Template_Cached')) {
                 include SMARTY_SYSPLUGINS_DIR . 'smarty_cacheresource.php';
             }
             $this->cached = new Smarty_Template_Cached($this);
             return $this->cached;
         case 'compiler':
             $this->smarty->loadPlugin($this->source->compiler_class);
             $this->compiler = new $this->source->compiler_class($this->source->template_lexer_class, $this->source->template_parser_class, $this->smarty);
             return $this->compiler;
             // FIXME: routing of template -> smarty attributes
         // FIXME: routing of template -> smarty attributes
         default:
             if (property_exists($this->smarty, $property_name)) {
                 return $this->smarty->{$property_name};
             }
     }
     throw new SmartyException("template property '{$property_name}' does not exist.");
 }
开发者ID:harmofwk,项目名称:harmofwk,代码行数:41,代码来源:smarty_internal_template.php

示例12: getScriptPaths

 /**
  * Retrieve the current template directory
  *
  * @return array
  */
 public function getScriptPaths()
 {
     return $this->_smarty->getTemplateDir();
 }
开发者ID:bjtenao,项目名称:tudu-web,代码行数:9,代码来源:Smarty3.php

示例13: getTemplateUid

 /**
  * Get template's unique ID
  *
  * @param Smarty $smarty        Smarty object
  * @param string $resource_name template name
  * @param string $cache_id      cache id
  * @param string $compile_id    compile id
  * @return string filepath of cache file
  */
 protected function getTemplateUid(Smarty $smarty, $resource_name, $cache_id, $compile_id)
 {
     $uid = '';
     if (isset($resource_name)) {
         $tpl = new $smarty->template_class($resource_name, $smarty);
         if ($tpl->source->exists) {
             $uid = $tpl->source->uid;
         }
         // remove from template cache
         unset($smarty->template_objects[sha1(join(DIRECTORY_SEPARATOR, $smarty->getTemplateDir()) . $tpl->template_resource . $tpl->cache_id . $tpl->compile_id)]);
     }
     return $uid;
 }
开发者ID:harmofwk,项目名称:harmofwk,代码行数:22,代码来源:smarty_cacheresource_keyvaluestore.php

示例14:

 /**
  * Gets the template root directory for this Template object.
  *
  * @return string
  */
 function get_template_dir()
 {
     return $this->smarty->getTemplateDir();
 }
开发者ID:squidjam,项目名称:Piwigo,代码行数:9,代码来源:template.class.php

示例15: fn_addon_template_overrides

/**
 * Get list of templates that should be overridden by addons
 *
 * @param  string $resource_name    Base template name
 * @param  Smarty $view             Templater object
 *
 * @return string Overridden template name
 */
function fn_addon_template_overrides($resource_name, &$view)
{
    static $init = array();
    $o_name = 'template_overrides_' . AREA;
    $template_dir = rtrim($view->getTemplateDir(0), '/') . '/';
    if (!isset($init[$o_name])) {
        Registry::registerCache($o_name, array('addons'), Registry::cacheLevel('static'));
        if (!Registry::isExist($o_name)) {
            $template_overrides = array();
            foreach (Registry::get('addons') as $a => $_settings) {
                $odir = $template_dir . 'addons/' . $a . '/overrides';
                if ($_settings['status'] == 'A' && is_dir($odir)) {
                    $tpls = fn_get_dir_contents($odir, false, true, '', '', true);
                    foreach ($tpls as $k => $t) {
                        $tpl_hash = md5($t);
                        if (empty($template_overrides[$tpl_hash])) {
                            $template_overrides[$tpl_hash] = $template_dir . 'addons/' . $a . '/overrides/' . $t;
                        }
                    }
                }
            }
            if (empty($template_overrides)) {
                $template_overrides['plug'] = true;
            }
            Registry::set($o_name, $template_overrides);
        }
        $init[$o_name] = true;
    }
    return Registry::ifGet($o_name . '.' . md5($resource_name), $resource_name);
}
开发者ID:heg-arc-ne,项目名称:cscart,代码行数:38,代码来源:fn.control.php


注:本文中的Smarty::getTemplateDir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。