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


PHP Smarty::addTemplateDir方法代码示例

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


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

示例1: get_template

 /**
  * @param null $template
  * @param null $cache_id
  * @param null $compiled_id
  * @param null $parent
  * @return string
  *
  * @throws \SmartyException
  */
 public function get_template($template = null, $cache_id = null, $compiled_id = null, $parent = null)
 {
     $this->init_engine();
     $this->template_engine->setCompileDir($this->compile_dir);
     foreach ($this->template_dirs as $i => $dir) {
         $i == 0 && $this->template_engine->setTemplateDir($dir);
         $i > 0 && $this->template_engine->addTemplateDir($dir);
     }
     $this->load_lang_vars($this->get_lang_file());
     return $this->template_engine->getTemplate($template, $cache_id, $compiled_id, $parent);
 }
开发者ID:one-more,项目名称:peach_framework,代码行数:20,代码来源:baseview.php

示例2: realpath

 /**
  * Adds template directory for this Template object.
  * Also set compile id if not exists.
  *
  * @param string $dir
  */
 function set_template_dir($dir)
 {
     $this->smarty->addTemplateDir($dir);
     if (!isset($this->smarty->compile_id)) {
         $compile_id = "1";
         $compile_id .= ($real_dir = realpath($dir)) === false ? $dir : $real_dir;
         $this->smarty->compile_id = base_convert(crc32($compile_id), 10, 36);
     }
 }
开发者ID:squidjam,项目名称:Piwigo,代码行数:15,代码来源:template.class.php

示例3: getThemeSmarty

 /**
  * 取得一个和 Theme 初始化一样的 Smarty 对象,只有这样才能正确处理缓存清理工作
  */
 private function getThemeSmarty()
 {
     $themeSmarty = new \Smarty();
     //设置 smarty 工作目录
     $themeSmarty->setCompileDir(RUNTIME_PATH . '/Smarty/Mobile/Compile');
     $themeSmarty->setCacheDir(RUNTIME_PATH . '/Smarty/Mobile/Cache');
     // 获取当前插件的根地址
     $currentThemeBasePath = realpath(dirname(__FILE__) . '/../../../');
     // 增加 smarty 模板搜索路径
     $themeSmarty->addTemplateDir($currentThemeBasePath . '/mobile/Tpl/');
     return $themeSmarty;
 }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:15,代码来源:MobileClear.php

示例4: render

 /**
  * Processes a view script and returns the output.
  *
  * @param  string|ModelInterface $nameOrModel The script/resource process, or a view model
  * @param  array|\ArrayAccess $values Values to use during rendering
  * @throws \Zend\View\Exception\DomainException
  * @return string The script output.
  */
 public function render($nameOrModel, $values = array())
 {
     $model = null;
     if ($nameOrModel instanceof ModelInterface) {
         $model = $nameOrModel;
         $nameOrModel = $model->getTemplate();
         if (empty($nameOrModel)) {
             throw new Exception\DomainException(sprintf('%s: received View Model, but template is empty', __METHOD__));
         }
         $options = $model->getOptions();
         foreach ($options as $setting => $value) {
             $method = 'set' . $setting;
             if (method_exists($this, $method)) {
                 $this->{$method}($value);
             }
             unset($method, $setting, $value);
         }
         unset($options);
         $values = (array) $model->getVariables();
     }
     // check if we can render the template
     if (!$this->canRender($nameOrModel)) {
         return null;
     }
     // handle tree rendering
     if ($model && $this->canRenderTrees() && $model->hasChildren()) {
         if (!isset($values['content'])) {
             $values['content'] = '';
         }
         foreach ($model as $child) {
             /** @var \Zend\View\Model\ViewModel $child */
             if ($this->canRender($child->getTemplate())) {
                 $file = $this->resolver->resolve($child->getTemplate(), $this);
                 $this->smarty->addTemplateDir(dirname($file));
                 $childVariables = (array) $child->getVariables();
                 $childVariables['this'] = $this;
                 $this->smarty->assign($childVariables);
                 return $this->smarty->fetch($file);
             }
             $child->setOption('has_parent', true);
             $values['content'] .= $this->view->render($child);
         }
     }
     // give the template awareness of the Renderer
     $values['this'] = $this;
     // assign the variables
     $this->smarty->assign($values);
     // resolve the template
     $file = $this->resolver->resolve($nameOrModel);
     $this->smarty->addTemplateDir(dirname($file));
     // render
     return $this->smarty->fetch($file);
 }
开发者ID:gkralik,项目名称:gk-smarty,代码行数:61,代码来源:SmartyRenderer.php

示例5: getSmarty

 /**
  * Singleton instance
  * @return Smarty
  * @throws SmartyException
  */
 private function getSmarty()
 {
     if (!isset($this->smarty)) {
         $smarty = new Smarty();
         $smarty->addTemplateDir(VIEWS_DIR);
         $smarty->setCompileDir(BASE_DIR . '/cache/templates');
         $smarty->registerPlugin('modifier', 'lang', array('View', 'translate'));
         // translations
         $smarty->registerPlugin('function', 'profiler', array('Profiler', 'show'));
         // profiler
         $smarty->force_compile = true;
         $this->smarty = $smarty;
     }
     return $this->smarty;
 }
开发者ID:tiger154,项目名称:prototype,代码行数:20,代码来源:Mail.php

示例6: registerServices

 /**
  * Register the services here to make them general or register in the ModuleDefinition to make them module-specific
  */
 public function registerServices(DiInterface $di)
 {
     // Registering a dispatcher
     $di->set('dispatcher', function () {
         $dispatcher = new Dispatcher();
         $dispatcher->setDefaultNamespace("App\\Frontend\\Controllers\\");
         return $dispatcher;
     });
     //Registering a dispatcher
     /*$di->set('dispatcher', function(){
                 //Create an EventsManager
                 $eventsManager = new EventsManager();
                 //Attach a listener
                 $eventsManager->attach("dispatch", function($event, $dispatcher, $exception) {
                     //Handle controller or action doesn't exist
                     if ($event->getType() == 'beforeException') {
                         switch ($exception->getCode()) {
                             case Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
                             case Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
                                 $dispatcher->forward([
                                     'controller' => 'error',
                                     'action'     => 'index',
                                     'params'     => ['message' => $exception->getMessage()],
                                 ]);
                                 return false;
                         }
                     }
                 });
     
                 $dispatcher = new MvcDispatcher();
                 //$dispatcher->setDefaultNamespace('App\Controllers\\');
                 $dispatcher->setEventsManager($eventsManager);
                 return $dispatcher;
             });*/
     // Registering a smarty component
     $di->set('smarty', function () {
         $smarty = new \Smarty();
         $options = ['left_delimiter' => '<{', 'right_delimiter' => '}>', 'template_dir' => ROOT_DIR . '/app/Frontend/Views', 'compile_dir' => ROOT_DIR . '/runtime/Smarty/compile', 'cache_dir' => ROOT_DIR . '/runtime/Smarty/cache', 'error_reporting' => error_reporting() ^ E_NOTICE, 'escape_html' => true, 'force_compile' => false, 'compile_check' => true, 'caching' => false, 'debugging' => false];
         foreach ($options as $k => $v) {
             $smarty->{$k} = $v;
         }
         $config = (include ROOT_DIR . "/config/main.php");
         if (!empty($config['theme'])) {
             $smarty->addTemplateDir(ROOT_DIR . '/app/Frontend/Themes/' . $config['theme']);
         }
         return $smarty;
     });
 }
开发者ID:fenghuilee,项目名称:writepress,代码行数:51,代码来源:Module.php

示例7: Smarty

    //CRAWLER
    $GLOBALS['crawl_cycle'] = Config::getConfigValueByName('crawl_cycle_length_in_minutes');
    //TEMPLATE
    $GLOBALS['template'] = Config::getConfigValueByName('template');
    //WEBSERVER
    $GLOBALS['url_to_netmon'] = Config::getConfigValueByName('url_to_netmon');
}
//load smarty template engine
require_once ROOT_DIR . '/lib/extern/smarty/Smarty.class.php';
$smarty = new Smarty();
$smarty->compile_check = true;
$smarty->debugging = false;
// base template directory
// this is used as a fallback if nothing is found in the custom template folder
// lookup ordered by param2
$smarty->addTemplateDir(ROOT_DIR . '/templates/base/html', 10);
// custom template folder - smarty will try here first ( order 0 )
$smarty->addTemplateDir(ROOT_DIR . '/templates/' . $GLOBALS['template'] . '/html', 0);
$smarty->compile_dir = ROOT_DIR . '/templates_c';
$smarty->assign('template', $GLOBALS['template']);
$smarty->assign('installed', $GLOBALS['installed']);
$smarty->assign('community_name', $GLOBALS['community_name']);
$smarty->assign('community_slogan', $GLOBALS['community_slogan']);
/**
 * Auto Login
 */
if ($GLOBALS['installed']) {
    //if the user is not logged in and the remember me cookie is set
    if (!isset($_SESSION['user_id']) and !empty($_COOKIE["remember_me"])) {
        require_once ROOT_DIR . '/lib/core/user_old.class.php';
        require_once ROOT_DIR . '/lib/core/UserRememberMeList.class.php';
开发者ID:wAmpIre,项目名称:netmon,代码行数:31,代码来源:runtime.php

示例8: addTemplateDir

 /**
  * Adds another Smarty template_dir to scan for templates
  *
  * @param string $dir
  * @return Ext_View_Smarty
  */
 public function addTemplateDir($dir)
 {
     $this->_smarty->addTemplateDir($dir);
     return $this;
 }
开发者ID:iLoiLohas,项目名称:pinchshopper,代码行数:11,代码来源:Smarty.php

示例9: getSmarty

 public static function getSmarty()
 {
     $smarty = new Smarty();
     //$smarty->left_delimiter = '<!--{';
     //$smarty->right_delimiter = '}-->';
     $smarty->template_dir = "global/smarty/";
     $smarty->addTemplateDir(Import::$uber_src_path . "/global/smarty/");
     $smarty->compile_dir = Import::$uber_src_path . "/server/Smarty-3.1.8/tmp";
     return $smarty;
 }
开发者ID:awwthentic1234,项目名称:hey,代码行数:10,代码来源:Smarty.class.php

示例10: sqlsec

<?php

/**
 * Code for the most sites for the beginning...
 */
require_once 'config.php';
date_default_timezone_set($GLOBALS["timezone"]);
require_once 'class/role.php';
require_once 'class/user.php';
require_once 'class/plugin.php';
require_once 'class/smarty/Smarty.class.php';
$messages = array();
$allcss = array();
$template = new Smarty();
$template->addTemplateDir("plugins/");
$jsscripts = array();
$dojorequire = array();
session_start();
//SECURE SQL-INJECTION
function sqlsec($value)
{
    $search = array("\\", "", "\n", "\r", "'", '"', "");
    $replace = array("\\\\", "\\0", "\\n", "\\r", "\\'", '\\"', "\\Z");
    return str_replace($search, $replace, $value);
}
//This stops SQL Injection in POST vars
foreach ($_POST as $key => $value) {
    $_POST[$key] = sqlsec($value);
}
//This stops SQL Injection in GET vars
foreach ($_GET as $key => $value) {
开发者ID:hersche,项目名称:Peta,代码行数:31,代码来源:default.php

示例11: Smarty

<?php

/**
 * Example Application
 *
 * @package Example-application
 */
$smarty = new Smarty();
$smarty->setCacheDir(sys_get_temp_dir());
$smarty->setCompileDir(sys_get_temp_dir());
$smarty->addTemplateDir(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'templates');
$smarty->setConfigDir(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'configs');
$smarty->addPluginsDir(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'plugins');
$smarty->debugging = true;
//Note: That "debug.tpl" inside phar is not accessible))
$smarty->debug_tpl = SMARTY_DEBUG_TPL;
$smarty->caching = false;
$smarty->cache_lifetime = 1;
$smarty->assign("Name", "Fred Irving Johnathan Bradley Peppergill", true);
$smarty->assign("FirstName", array("John", "Mary", "James", "Henry"));
$smarty->assign("LastName", array("Doe", "Smith", "Johnson", "Case"));
$smarty->assign("Class", array(array("A", "B", "C", "D"), array("E", "F", "G", "H"), array("I", "J", "K", "L"), array("M", "N", "O", "P")));
$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"), array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));
$smarty->assign("option_values", array("NY", "NE", "KS", "IA", "OK", "TX"));
$smarty->assign("option_output", array("New York", "Nebraska", "Kansas", "Iowa", "Oklahoma", "Texas"));
$smarty->assign("option_selected", "NE");
$smarty->display('index.tpl', time(), time());
开发者ID:inri13666,项目名称:smarty-phar,代码行数:27,代码来源:common.php

示例12: add_template_directory

 /**
  * Set Template dir
  *
  * @access public
  * @param string $directory
  */
 public function add_template_directory($directory)
 {
     $this->smarty->addTemplateDir($directory);
 }
开发者ID:tigron,项目名称:skeleton-template-smarty,代码行数:10,代码来源:Smarty.php

示例13: Smarty

<?php

require_once 'vendor/autoload.php';
/* PHP requires setting a timezone. This will be fine,
   since the app doesn't require a time */
date_default_timezone_set('America/New_York');
/* If sendmail is available, send emails immediately.
   If not, place in hold_email table for later release */
$on_line = false;
$email_direct = false;
$smarty = new Smarty();
$smarty->addTemplateDir(__DIR__ . '/templates');
$smarty->addPluginsDir(__DIR__ . '/plugins');
session_start();
if (isset($_SESSION['user_id'])) {
    $user_id = $_SESSION['user_id'];
    $smarty->assign('user_id', $user_id);
    $smarty->assign('HelloName', $_SESSION['HelloName']);
} else {
    $user_id = 0;
    if (!isset($login)) {
        header("Location: login.php");
    }
}
/* Set permissions.
   Viewer can see everyone's information, and suggest changes
   Editor can see info, and release suggested changes to live db
   Everyone can suggest changes to their own info -
     user_id == contact_id in people.tpl & edit_contact.tpl
*/
$rbac = new PhpRbac\Rbac();
开发者ID:cottonwoodgulch,项目名称:alumni,代码行数:31,代码来源:libe.php

示例14: Ldap

session_start();
//Objeto da classe LDAP
$ldap = new Ldap();
//Se a variável login não existir na sessão, não deixar passar do index
if (!array_key_exists('login', $_SESSION)) {
    header('Location: index.php');
    exit;
    //Se o usuário for um solicitante, ele não poderá alterar seus dados
} else {
    if ($ldap->userExists($_SESSION['login'], "ou=solicitacoes")) {
        header('Location: home.php');
    }
}
$s = new Smarty();
//Diretório de templates
$s->addTemplateDir("../view/templates");
//Diretório de templates compilados
$s->setCompileDir("../view/com_templates");
$usuario = $ldap->getUsuario($_SESSION['login']);
//Verifica se o usuário possui foto
if ($usuario->jpegPhoto) {
    //Se existir, baixar a foto para a pasta do site e associar valor verdadeiro à variável foto, usada no html da "home"
    file_put_contents("imagens/" . $usuario->uid . ".jpg", $usuario->jpegPhoto);
    //Este valor é utilizado num if. Se o usuário tiver foto, carregar a foto dele. Se não, carregar a imagem padrão
    $s->assign('foto', true);
} else {
    $s->assign('foto', false);
}
//Associa à variável usuário, um objeto recheado de valores para serem utilizados no html da home
$s->assign('usuario', $usuario);
if ($ldap->isAdmin($_SESSION['login'], "ou=usuarios")) {
开发者ID:noc-ufvjm,项目名称:valid,代码行数:31,代码来源:alterar-dados.php

示例15: array

<?php

//------------------------------------------------------------------------
//------------------------------------------------------------------------
//php imports
//------------------------------------------------------------------------
//------------------------------------------------------------------------
require_once Import::$uber_src_path . "/server/Smarty-3.1.8/libs/Smarty.class.php";
//------------------------------------------------------------------------
//------------------------------------------------------------------------
//init var
//------------------------------------------------------------------------
//------------------------------------------------------------------------
$obj = array();
//------------------------------------------------------------------------
//------------------------------------------------------------------------
//init
//------------------------------------------------------------------------
//------------------------------------------------------------------------
$smarty = new Smarty();
$smarty->left_delimiter = '<!--{';
$smarty->right_delimiter = '}-->';
$smarty->template_dir = "global/smarty";
$smarty->addTemplateDir(Import::$uber_src_path . "/server/werm/smarty");
$smarty->compile_dir = Import::$uber_src_path . "/server/Smarty-3.1.8/tmp";
开发者ID:awwthentic1234,项目名称:hey,代码行数:25,代码来源:header.php


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