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


PHP Smarty::templateExists方法代码示例

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


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

示例1: render

 public function render($blockName, $moduleName, $controllerName, $actionName, $dataHolder = null, $defaultDir = null)
 {
     $smartyData = $this->smarty->createData($this->smarty);
     if ($dataHolder != null) {
         foreach ($dataHolder as $key => $value) {
             $smartyData->assign($key, $value);
         }
     }
     \org\equinox\utils\debug\DebugBarFactory::add($smartyData->getTemplateVars(), 'Smarty', $blockName);
     $this->smarty->setTemplateDir(ROOT . '/' . $this->templateDir);
     $template = $moduleName . '/' . $controllerName . '/' . $actionName;
     if (!$this->smarty->templateExists($template . '.tpl')) {
         // check the default template
         if ($defaultDir != null) {
             $this->smarty->setTemplateDir($defaultDir);
             $template = $controllerName . '/' . $actionName;
             if (!$this->smarty->templateExists($template . '.tpl')) {
                 throw new \org\equinox\exception\EquinoxException("Cannot find ({$template}.tpl) template in (" . ROOT . '/' . $this->templateDir . ") nor in default directory ({$defaultDir})");
             }
         } else {
             throw new \org\equinox\Exception\EquinoxException("Cannot find ({$template}.tpl) template in (" . $this->smarty->template_dir . ") and no default directory provided");
         }
     }
     $html = $this->smarty->fetch($template . '.tpl', $smartyData);
     \org\equinox\utils\debug\DebugBarFactory::add($html, 'Smarty', $blockName . '_html');
     return $html;
 }
开发者ID:rousseau-christopher,项目名称:equinox-core,代码行数:27,代码来源:ViewSmarty3.php

示例2: _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

示例3: Smarty_function_help

/**
 * Smarty Help Tag
 * Displays help text of this module.
 *
 * Examples:
 * <pre>
 * {help}
 * </pre>
 *
 * Type:     function<br>
 * Name:     help<br>
 * Purpose:  displays help.tpl for a module, if existing<br>
 *
 * @param array  $params
 * @param Smarty $smarty
 *
 * @return string
 */
function Smarty_function_help($params, $smarty)
{
    $modulename = $smarty->getTemplateVars('template_of_module');
    $tpl = $modulename . '/view/smarty/help.tpl';
    // load the help template from the module path ->  app/modules/modulename/view/help.tpl
    if ($smarty->templateExists($tpl)) {
        return $smarty->fetch($tpl);
    }
    return 'Help Template not found.';
}
开发者ID:ksst,项目名称:kf,代码行数:28,代码来源:function.help.php

示例4: smarty_function_pagination

/**
 * Smarty pagination
 * Displays a pagination Element.
 *
 * Examples:
 * <pre>
 * {pagination}
 * </pre>
 *
 * Type:     function<br>
 * Name:     pagination<br>
 * Purpose:  display pagination if needed<br>
 *
 * @param array  $params
 * @param Smarty $smarty
 *
 * @return string
 */
function smarty_function_pagination($params, $smarty)
{
    // check if a alphabet pagination is requested
    if (isset($params['type']) and $params['type'] === 'alphabet') {
        // check if file exists
        if ($smarty->templateExists('pagination-alphabet.tpl') === false) {
            echo 'Pagination Template for alphabet not found.';
        } else {
            // load the generic pagination template
            return $smarty->fetch('pagination-alphabet.tpl');
        }
    }
    // check if file exists
    if ($smarty->templateExists('pagination-generic.tpl') === false) {
        echo 'Pagination Template not found.';
    } else {
        // load the generic pagination template
        return $smarty->fetch('pagination-generic.tpl');
    }
}
开发者ID:ksst,项目名称:kf,代码行数:38,代码来源:function.pagination.php

示例5: smarty_insert_block

/**
 * Плагин для смарти
 * Подключает обработчик блоков шаблона
 *
 * @param array $aParams
 * @param Smarty $oSmarty
 * @return string
 */
function smarty_insert_block($aParams, &$oSmarty)
{
    /**
     * Устанавливаем шаблон
     */
    $sBlock = ucfirst(basename($aParams['block']));
    /**
     * Проверяем наличие шаблона. Определяем значения параметров работы в зависимости от того,
     * принадлежит ли блок одному из плагинов, или является пользовательским классом движка
     */
    if (isset($aParams['params']) and isset($aParams['params']['plugin'])) {
        $sBlockTemplate = Plugin::GetTemplatePath($aParams['params']['plugin']) . '/blocks/block.' . $aParams['block'] . '.tpl';
        $sBlock = 'Plugin' . ucfirst($aParams['params']['plugin']) . '_Block' . $sBlock;
    } else {
        $sBlockTemplate = Engine::getInstance()->Plugin_GetDelegate('template', 'blocks/block.' . $aParams['block'] . '.tpl');
        $sBlock = 'Block' . $sBlock;
    }
    $sBlock = Engine::getInstance()->Plugin_GetDelegate('block', $sBlock);
    if (!isset($aParams['block']) or !$oSmarty->templateExists($sBlockTemplate)) {
        trigger_error("Not found template for block: " . $sBlockTemplate, E_USER_WARNING);
        return;
    }
    /**
     * параметры
     */
    $aParamsBlock = array();
    if (isset($aParams['params'])) {
        $aParamsBlock = $aParams['params'];
    }
    /**
     * Подключаем необходимый обработчик
     */
    $oBlock = new $sBlock($aParamsBlock);
    /**
     * Запускаем обработчик
     */
    $oBlock->Exec();
    /**
     * Возвращаем результат в виде обработанного шаблона блока
     */
    return $oSmarty->fetch($sBlockTemplate);
}
开发者ID:lunavod,项目名称:bunker_stable,代码行数:50,代码来源:insert.block.php

示例6: templateExists

 /**
  * Checks to see if the named template exists
  *
  * @param string $name The template to look for
  * @return bool
  */
 public function templateExists($name)
 {
     return $this->_smarty->templateExists($this->resolveTemplate($name));
 }
开发者ID:opensolutions,项目名称:oss-framework,代码行数:10,代码来源:Smarty.php

示例7: TemplateExists

 /**
  * Проверяет существование шаблона
  *
  * @param string $sTemplate
  * @return bool
  */
 public function TemplateExists($sTemplate)
 {
     return $this->oSmarty->templateExists($sTemplate);
 }
开发者ID:randomtoy,项目名称:livestreet,代码行数:10,代码来源:Viewer.class.php

示例8: templateExists

 /**
  * Checks to see if the named template exists
  *
  * @param string $name The template to look for
  * @return boolean
  */
 public function templateExists($name)
 {
     return $this->_smarty->templateExists($name);
 }
开发者ID:nereliz,项目名称:ViMbAdmin,代码行数:10,代码来源:Smarty.php

示例9: getContentImpl

 /**
  * Основной метод, выполняющий загрузку содержимого тестовой страницы
  */
 private function getContentImpl(RequestArrayAdapter $params, Smarty $smarty)
 {
     //Силовые упражнения
     $exId = $params->int('ex_id');
     if ($exId) {
         //$ex = GymManager::getInstance()->getExercise($exId);
         $tplPath = "gym/exercises/{$exId}.tpl";
         return $smarty->templateExists($tplPath) ? $smarty->fetch($tplPath) : null;
     }
     //Специальные страницы
     $pageType = $params->str('pagetype');
     if ($pageType) {
         $smParams = array();
         switch ($pageType) {
             case 'smarty':
                 foreach (array('blocks', 'functions', 'modifiers') as $type) {
                     $items = DirManager::smarty('plugins/' . $type)->getDirContentFull(null, PsConst::EXT_PHP);
                     /* @var $item DirItem */
                     foreach ($items as $item) {
                         //Название
                         $name = explode('.', $item->getName());
                         $name = $name[1];
                         //Первый комментарий
                         $tokens = token_get_all($item->getFileContents());
                         $comment = array(T_COMMENT, T_DOC_COMMENT);
                         $fileComment = '';
                         foreach ($tokens as $token) {
                             if (in_array($token[0], $comment)) {
                                 $fileComment = trim($token[1]);
                                 break;
                             }
                         }
                         $smParams[$type][] = array('name' => $name, 'comment' => $fileComment);
                     }
                 }
                 break;
             case 'doubleimg':
                 $images = DirManager::images()->getDirContentFull(null, DirItemFilter::IMAGES);
                 $sorted = array();
                 /* @var $img DirItem */
                 foreach ($images as $img) {
                     $ident = $img->getSize() . 'x' . $img->getImageAdapter()->getWidth() . 'x' . $img->getImageAdapter()->getHeight();
                     $sorted[$ident][] = $img;
                 }
                 $result = array();
                 /* @var $img DirItem */
                 foreach ($sorted as $ident => $imgs) {
                     if (count($imgs) > 1) {
                         $result[$ident] = $imgs;
                     }
                 }
                 $smParams = array('images' => $result);
                 break;
             case 'testmethods':
                 $smParams['methods'] = TestManagerCaller::getMethodsList();
                 break;
             case 'imgbysize':
                 $images = DirManager::images()->getDirContentFull(null, DirItemFilter::IMAGES, array('GymExercises'));
                 DirItemSorter::inst()->sort($images, DirItemSorter::BY_SIZE);
                 $smParams = array('images' => $images);
                 break;
             case 'formules':
                 $formules = TexImager::inst()->getAllFormules();
                 $totalSize = 0;
                 /* @var $formula DirItem */
                 foreach ($formules as $formula) {
                     $totalSize += $formula->getSize();
                     $formula->setData('class', 'TeX');
                 }
                 DirItemSorter::inst()->sort($formules, DirItemSorter::BY_SIZE);
                 $smParams = array('formules' => $formules, 'formules_size' => $totalSize);
                 break;
         }
         $content = $smarty->fetch("test/page_{$pageType}.tpl", $smParams);
         if ($pageType) {
             switch ($pageType) {
                 case 'patterns':
                     $out = array();
                     preg_match_all("/===(.*?)===/", $content, $out, PREG_PATTERN_ORDER);
                     $params = array();
                     for ($i = 0; $i < count($out[0]); $i++) {
                         $full = $out[0][$i];
                         $ctt = $out[1][$i];
                         $params[$full] = "<div class=\"demo-head\">{$ctt}</div>";
                     }
                     $content = PsStrings::replaceMap($content, $params);
             }
         }
         return $content;
     }
     //Тестовая страница
     $num = $params->int('num');
     $num = $num ? $num : 1;
     return $smarty->fetch("test/page{$num}.tpl");
 }
开发者ID:ilivanoff,项目名称:ps-sdk-dev,代码行数:98,代码来源:test.php

示例10: Smarty

<?php

//Подключили библиотеку simple_html_dom_parser.php
require_once "inc/simple_html_dom.php";
//Подключили автолоадер composer`a
require './vendor/autoload.php';
//Подключили наши функции
require_once "inc/functions.inc.php";
//Подключили скрипт парсера
require_once "inc/parser.inc.php";
//Создали объект для шаблонизатора
$smarty = new Smarty();
//Передаем параметры(результаты работы парсера)
$smarty->assign("teams", $teams);
$smarty->assign("links_for_teams_preview", $links_for_teams_preview);
$smarty->assign("last_tour_results", $last_tour_results);
//Проверяем существует ли шаблон
if (!$smarty->templateExists('data.tpl')) {
    exit('Такого шаблона не существует');
} else {
    $smarty->display("data.tpl");
}
开发者ID:HungryJunior,项目名称:Parser_FPL_Ukraine,代码行数:22,代码来源:index.php

示例11: Smarty

<?php

require_once "vendor/autoload.php";
require_once "inc/cURL.inc.php";
require_once "inc/html_Parser.inc.php";
//Создаем экземпляр шаблонизатора.
$smarty = new Smarty();
//Передаем данные из парсера (html_Parser.inc.php) в шаблон
$smarty->assign("data", $total_game_data);
//Проверяем существует ли шаблон
if (!$smarty->templateExists('freerolls.tpl')) {
    exit('Такого шаблона не существует');
} else {
    $smarty->display("freerolls.tpl");
}
开发者ID:HungryJunior,项目名称:Pokerstars-Freroll-Passwords-Parser,代码行数:15,代码来源:index.php


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