本文整理汇总了PHP中Smarty::trigger_error方法的典型用法代码示例。如果您正苦于以下问题:PHP Smarty::trigger_error方法的具体用法?PHP Smarty::trigger_error怎么用?PHP Smarty::trigger_error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Smarty
的用法示例。
在下文中一共展示了Smarty::trigger_error方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_oxscript
/**
* Smarty plugin
* -------------------------------------------------------------
* File: function.oxscript.php
* Type: string, html
* Name: oxscript
* Purpose: Collect given javascript includes/calls, but include/call them at the bottom of the page.
*
* Add [{oxscript add="oxid.popup.load();"}] to add script call.
* Add [{oxscript include="oxid.js"}] to include local javascript file.
* Add [{oxscript include="oxid.js?20120413"}] to include local javascript file with query string part.
* Add [{oxscript include="http://www.oxid-esales.com/oxid.js"}] to include external javascript file.
*
* IMPORTANT!
* Do not forget to add plain [{oxscript}] tag before closing body tag, to output all collected script includes and calls.
* -------------------------------------------------------------
*
* @param array $params Params
* @param Smarty $smarty Clever simulation of a method
*
* @return string
*/
function smarty_function_oxscript($params, &$smarty)
{
$isDynamic = isset($smarty->_tpl_vars["__oxid_include_dynamic"]) ? (bool) $smarty->_tpl_vars["__oxid_include_dynamic"] : false;
$priority = !empty($params['priority']) ? $params['priority'] : 3;
$widget = !empty($params['widget']) ? $params['widget'] : '';
$isInWidget = !empty($params['inWidget']) ? $params['inWidget'] : false;
$output = '';
if (isset($params['add'])) {
if (empty($params['add'])) {
$smarty->trigger_error("{oxscript} parameter 'add' can not be empty!");
return '';
}
$register = oxNew('OxidEsales\\EshopCommunity\\Core\\ViewHelper\\JavaScriptRegistrator');
$register->addSnippet($params['add'], $isDynamic);
} elseif (isset($params['include'])) {
if (empty($params['include'])) {
$smarty->trigger_error("{oxscript} parameter 'include' can not be empty!");
return '';
}
$register = oxNew('OxidEsales\\EshopCommunity\\Core\\ViewHelper\\JavaScriptRegistrator');
$register->addFile($params['include'], $priority, $isDynamic);
} else {
$renderer = oxNew('OxidEsales\\EshopCommunity\\Core\\ViewHelper\\JavaScriptRenderer');
$output = $renderer->render($widget, $isInWidget, $isDynamic);
}
return $output;
}
示例2: smarty_function_router
/**
* Плагин для смарти
* Позволяет получать данные о роутах
*
* @param array $aParams
* @param Smarty $oSmarty
* @return string
*/
function smarty_function_router($aParams, &$oSmarty)
{
if (empty($aParams['page'])) {
$oSmarty->trigger_error("Router: missing 'page' parametr");
return;
}
require_once Config::Get('path.root.engine') . '/classes/Router.class.php';
if (!($sPath = Router::GetPath($aParams['page']))) {
$oSmarty->trigger_error("Router: unknown 'page' given");
return;
}
/**
* Возвращаем полный адрес к указаному Action
*/
return isset($aParams['extend']) ? $sPath . $aParams['extend'] . "/" : $sPath;
}
示例3: smarty_function_assign_adv
/**
* Smarty {assign_adv} function plugin
*
* Type: function<br>
* Name: assign_adv<br>
* Purpose: Advanced assign variable to template
*
* @param $params
* @param \Smarty $smarty
*/
function smarty_function_assign_adv($params, &$smarty)
{
extract($params);
if (empty($var)) {
$smarty->trigger_error(gt("assign_adv: missing 'var' parameter"));
return;
}
if (!in_array('value', array_keys($params))) {
$smarty->trigger_error(gt("assign_adv: missing 'value' parameter"));
return;
}
$value = isset($params['value']) ? $params['value'] : null;
if (preg_match('/^\\s*array\\s*\\(\\s*(.*)\\s*\\)\\s*$/s', $value, $match)) {
eval('$value=array(' . str_replace("\n", "", $match[1]) . ');');
} else {
if (preg_match('/^\\s*range\\s*\\(\\s*(.*)\\s*\\)\\s*$/s', $value, $match)) {
eval('$value=range(' . str_replace("\n", "", $match[1]) . ');');
}
}
$smarty->assign($var, $value);
}
示例4: smarty_function_hook
/**
* Плагин для смарти
* Запускает хуки из шаблона на выполнение
*
* @param array $aParams
* @param Smarty $oSmarty
* @return string
*/
function smarty_function_hook($aParams, &$oSmarty)
{
if (empty($aParams['run'])) {
$oSmarty->trigger_error("Hook: missing 'run' parametr");
return;
}
$sHookName = 'template_' . strtolower($aParams['run']);
unset($aParams['run']);
$aResultHook = Engine::getInstance()->Hook_Run($sHookName, $aParams);
if (array_key_exists('template_result', $aResultHook)) {
return join('', $aResultHook['template_result']);
}
return '';
}
示例5: smarty_function_cfg
/**
* Плагин для смарти
* Позволяет получать данные из конфига
*
* @param array $aParams
* @param Smarty $oSmarty
* @return string
*/
function smarty_function_cfg($aParams, &$oSmarty)
{
if (empty($aParams['name'])) {
$oSmarty->trigger_error("Config: missing 'name' parametr");
return;
}
require_once Config::Get('path.root.engine') . '/lib/internal/ConfigSimple/Config.class.php';
if (!isset($aParams['instance'])) {
$aParams['instance'] = Config::DEFAULT_CONFIG_INSTANCE;
}
/**
* Возвращаем значение из конфигурации
*/
return Config::Get($aParams['name'], $aParams['instance']);
}
示例6: 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'])) {
require_once Config::Get('path.root.server') . '/engine/classes/ActionPlugin.class.php';
$sBlockTemplate = Plugin::GetTemplatePath($aParams['params']['plugin']) . '/block.' . $aParams['block'] . '.tpl';
$sBlockClass = Config::Get('path.root.server') . '/plugins/' . $aParams['params']['plugin'] . '/classes/blocks/Block' . $sBlock . '.class.php';
$sCmd = '$oBlock=new Plugin' . ucfirst($aParams['params']['plugin']) . '_Block' . $sBlock . '($aParamsBlock);';
} else {
$sBlockTemplate = Engine::getInstance()->Plugin_GetDelegate('template', 'block.' . $aParams['block'] . '.tpl');
$sBlockClass = Config::Get('path.root.server') . '/classes/blocks/Block' . $sBlock . '.class.php';
$sCmd = '$oBlock=new Block' . $sBlock . '($aParamsBlock);';
}
if (!isset($aParams['block']) or !$oSmarty->template_exists($sBlockTemplate)) {
$oSmarty->trigger_error("Not found template for block: " . $sBlockTemplate);
return;
}
/**
* параметры
*/
$aParamsBlock = array();
if (isset($aParams['params'])) {
$aParamsBlock = $aParams['params'];
}
/**
* Подключаем необходимый обработчик
*/
require_once $sBlockClass;
eval($sCmd);
/**
* Запускаем обработчик
*/
$oBlock->Exec();
/**
* Возвращаем результат в виде обработанного шаблона блока
*/
return $oSmarty->fetch($sBlockTemplate);
}
示例7: smarty_block_hookb
/**
* Плагин для смарти
* Запускает блочные хуки из шаблона на выполнение
*
* @param array $aParams
* @param string $sContent
* @param Smarty $oSmarty
* @param bool $bRepeat
* @return string
*/
function smarty_block_hookb($aParams, $sContent, &$oSmarty, &$bRepeat)
{
if (empty($aParams['run'])) {
$oSmarty->trigger_error("Hook: missing 'run' parametr");
return;
}
if ($sContent) {
$sHookName = 'template_block_' . strtolower($aParams['run']);
unset($aParams['run']);
$aParams['content'] = $sContent;
$aResultHook = Engine::getInstance()->Hook_Run($sHookName, $aParams);
if (array_key_exists('template_result', $aResultHook)) {
echo join('', $aResultHook['template_result']);
return;
}
echo $sContent;
}
}
示例8: smarty_function_html_select_locales
/**
* Zikula_View function to display a drop down list of languages
*
* Available parameters:
* - assign: If set, the results are assigned to the corresponding variable instead of printed out
* - name: Name for the control
* - id: ID for the control
* - selected: Selected value
* - installed: if set only show languages existing in languages folder
* - all: show dummy entry '_ALL' on top of the list with empty value
*
* Example
* {html_select_locales name=locale selected=en}
*
* @param array $params All attributes passed to this function from the template.
* @param Smarty $view Reference to the Zikula_View object.
*
* @return string The value of the last status message posted, or void if no status message exists.
*/
function smarty_function_html_select_locales($params, Smarty $view)
{
if (!isset($params['name']) || empty($params['name'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('html_select_locales', 'name')));
return false;
}
require_once $view->_get_plugin_filepath('function', 'html_options');
$values = $output = array();
if (isset($params['all']) && $params['all']) {
$values[] = '';
$output[] = DataUtil::formatForDisplay(__('All'));
}
$installed = ZLanguage::getInstalledLanguageNames();
$output = array_merge($output, DataUtil::formatForDisplay(array_values($installed)));
$values = array_merge($values, DataUtil::formatForDisplay(array_keys($installed)));
$html_result = smarty_function_html_options(array('output' => $output, 'values' => $values, 'selected' => isset($params['selected']) ? $params['selected'] : null, 'id' => isset($params['id']) ? $params['id'] : null, 'name' => $params['name']), $view);
if (isset($params['assign']) && !empty($params['assign'])) {
$view->assign($params['assign'], $html_result);
} else {
return $html_result;
}
}
示例9: smarty_function_pagenavigator
/**
* 处理分页导航模板
*
* 输出的模板变量
* $pagenav {array}
* {{$pagenav.~}}
*
* nums: {array} 页码列表
* currpage: {int} 当前页面
* recordcount: {int} 记录数
* pagecount: {int} 总页数
* query: {array} 页面传递参数
* next: {int} 下一页的页码
* prev: {int} 前一页页码
*
* @param array $params
* currpage:当前分页
* recordcount: 记录总数
* pagecount: 分页总数
* template: 模板文件
* numcount: 分页数字的个数
* url: 跳转url
* query: 页面跳转传递的参数
* @param Smarty $smarty
* @return void
*/
function smarty_function_pagenavigator($params, &$smarty)
{
if (empty($params['template'])) {
$smarty->trigger_error('Undefined pagenavigator template file');
}
if (!isset($params['recordcount'])) {
//$smarty->trigger_error('Undefined recordcount');
return;
}
if (!isset($params['pagecount'])) {
//$smarty->trigger_error('Undefined pagecount');
return;
}
$currpage = max(1, (int) @$params['currpage']);
$pagecount = (int) $params['pagecount'];
$recordcount = (int) $params['recordcount'];
$numcount = (int) @$params['numcount'];
// 模板变量
$tplvar = array('pagecount' => $pagecount, 'recordcount' => $recordcount, 'currpage' => $currpage, 'next' => $currpage < $pagecount ? $currpage + 1 : null, 'prev' => $currpage > 1 ? $currpage - 1 : null, 'url' => empty($params['url']) ? $_SERVER['SCRIPT_NAME'] : $params['url'], 'jsfunc' => @$params['jsfunc']);
// 输出页码
if ($numcount > 0) {
$lbound = $currpage > intval($numcount / 2) ? $currpage - intval($numcount / 2) : 1;
$ubound = $lbound + $numcount - 1 > $pagecount ? $pagecount : $lbound + $numcount - 1;
$nums = array();
for ($i = $lbound; $i <= $ubound; $i++) {
$nums[] = $i;
}
$tplvar['nums'] = $nums;
}
if (!empty($params['query']) && is_array($params['query'])) {
$tplvar['query'] = $params['query'];
}
$array = array('smarty_include_vars' => array('pagenav' => $tplvar), 'smarty_include_tpl_file' => $params['template']);
$smarty->register_function('page_url', 'smarty_function_pagenavigator_buildurl');
$smarty->register_function('page_jsfunc', 'smarty_function_pagenavigator_buildjsfunc');
$smarty->_smarty_include($array);
}
示例10: smarty_block_menu
/**
* Smarty menu block to parse recursive menu
*
*
* @param array $params All attributes passed to this function from the template.
* @param string $content The content between the block tags.
* @param Smarty $smarty Reference to the {@link Zikula_View} object.
* @param boolean $repeat Controls block repetition. See {@link http://www.smarty.net/manual/en/plugins.block.functions.php Smarty - Block Functions}.
*
* @return void|string The content of the matching case.
*/
function smarty_block_menu($params, $content, $smarty, &$repeat)
{
if (!isset($params['from'])) {
$smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('smarty_block_menu', 'from')));
return false;
}
if (!isset($params['item'])) {
$smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('smarty_block_menu', 'item')));
return false;
}
// find this block in smarty tag stack
foreach ($smarty->_tag_stack as $key => $tag_stack) {
if ($tag_stack[0] == 'menu') {
$menuTagStackKey = $key;
}
}
if (is_null($content)) {
$smarty->_tag_stack[$menuTagStackKey][1]['_content'] = array();
}
$from = $params['from'];
$item = $params['item'];
$key = isset($params['key']) ? $params['key'] : null;
$index = isset($params['_index']) ? $params['_index'] : 0;
$total = count($from);
$repeat = $index < $total;
$iterator = new ArrayIterator($from);
try {
$iterator->seek($index);
$currentKey = $iterator->key();
} catch (Exception $e) {
$currentKey = null;
}
try {
$iterator->seek($index - 1);
$lastKey = $iterator->key();
} catch (Exception $e) {
$lastKey = null;
}
if (isset($params['name'])) {
$menuProps = array('index' => $index, 'iteration' => $index + 1, 'total' => $total, 'first' => (bool) is_null($content), 'last' => $index + 1 >= $total);
}
if ($repeat || empty($from) && is_null($content)) {
$smarty->assign($item, isset($from[$currentKey]) ? $from[$currentKey] : null);
$smarty->assign('index', $index);
$smarty->assign('total', $total);
if (isset($menuProps)) {
$smarty->assign($params['name'], $menuProps);
}
if (isset($key)) {
$smarty->assign($key, $currentKey);
}
$smarty->_tag_stack[$menuTagStackKey][1]['_index'] = $index + 1;
if (!is_null($content)) {
$smarty->_tag_stack[$menuTagStackKey][1]['_content'][$lastKey] = $content;
}
if (empty($from) && is_null($content)) {
$repeat = true;
}
} else {
if (empty($from)) {
$params['_content'] = $content;
$result = _smarty_block_menu_parseheader($params);
} else {
$params['_content'][$lastKey] = $content;
$result = _smarty_block_menu_parsemenu($params);
}
if (isset($params['assign'])) {
$smarty->assign($params['assign'], $result);
} else {
return $result;
}
}
return;
}
示例11: wrapper
/**
* Smarty wrapper for Helpers
*
* @param mixed $params params from Smarty template call
* @param Smarty $smarty Smarty object
* @return mixed
*/
public function wrapper($params, &$smarty)
{
App::uses('Inflector', 'Utility');
$helperName = 'Smarty' . Inflector::camelize($this->name);
$className = Inflector::camelize($this->name);
// sanity check for php version
if (!class_exists('ReflectionClass')) {
$smarty->trigger_error($helperName . ": Error - requires php 5.0 or above", E_USER_NOTICE);
return;
}
$functionName = $params['func'];
$assign = array_key_exists('assign', $params) ? $params['assign'] : null;
$showCall = array_key_exists('__show_call', $params) ? $params['__show_call'] : false;
unset($params['func']);
unset($params['assign']);
unset($params['__show_call']);
$parameters = array();
// our final array of function parameters
if (empty($functionName)) {
$smarty->trigger_error($helperName . ": missing 'func' parameter", E_USER_NOTICE);
return;
}
// process our params array to look for array representations
// based on key names separated by underscores
$processedParams = $this->_processParams($params);
$arrayParams = array();
$classReflector = new ReflectionClass($this->{$className});
if ($classReflector->hasMethod($functionName)) {
// quick sanity check
$funcReflector = $classReflector->getMethod($functionName);
$funcParams = $funcReflector->getParameters();
// returns an array of parameter names
foreach ($funcParams as $param) {
$paramName = $param->getName();
if (isset($processedParams[$paramName])) {
$parameters[$paramName] = $processedParams[$paramName];
unset($processedParams[$paramName]);
} else {
if ($param->isDefaultValueAvailable()) {
$parameters[$paramName] = $param->getDefaultValue();
// mark the index of array parameters for potential later population
if (is_array($parameters[$paramName])) {
$arrayParams[] = $paramName;
}
} else {
if (!$param->isOptional()) {
$smarty->trigger_error($helperName . ": Error " . $paramName . " parameter is required for method " . $functionName, E_USER_NOTICE);
} else {
$parameters[$paramName] = null;
}
}
}
}
// check for unfilled array parameters and populate the first with remaining $params
if (count($arrayParams)) {
$parameters[$arrayParams[0]] = $processedParams;
}
} else {
$smarty->trigger_error($helperName . ": Error " . $classReflector->name . "::" . $functionName . " is not defined", E_USER_NOTICE);
return;
}
if ($showCall) {
echo '<pre>' . $helperName . ' calling $this->' . $className . '->' . $functionName . ' with these parameters: <br />';
var_dump($parameters);
echo '</pre>';
}
$result = call_user_func_array(array($this->{$className}, $functionName), $parameters);
if (!empty($assign)) {
$smarty->assign($assign, $result);
} else {
return $result;
}
}