本文整理汇总了PHP中Zikula_View::trigger_error方法的典型用法代码示例。如果您正苦于以下问题:PHP Zikula_View::trigger_error方法的具体用法?PHP Zikula_View::trigger_error怎么用?PHP Zikula_View::trigger_error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zikula_View
的用法示例。
在下文中一共展示了Zikula_View::trigger_error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_blockshow
/**
* Renders and displays a single Zikula block by blockinfo array or block id.
*
* Available attributes:
* - module (string) The internal name of the module that defines the block.
* - blockname (string) The internal name of the block.
* - block (int|array) Either the integer block id (bid) of the block, or
* an array containing the blockinfo for the block.
* - position (string) The position of the block.
* - assign (string) If set, the results are assigned to the corresponding
* template variable instead of being returned to the template (optional)
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the {@link Zikula_View} object.
*
* @return string The rendered output of the specified block.
*/
function smarty_function_blockshow($params, Zikula_View $view)
{
$module = isset($params['module']) ? $params['module'] : null;
$blockname = isset($params['blockname']) ? $params['blockname'] : null;
$block = isset($params['block']) ? $params['block'] : null;
$position = isset($params['position']) ? $params['position'] : null;
$assign = isset($params['assign']) ? $params['assign'] : null;
if (!$module) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('blockshow', 'module')));
return;
}
if (!$blockname) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('blockshow', 'blockname')));
return;
}
if (!$block) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('blockshow', 'id/info')));
return;
}
if (!$position) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('blockshow', 'position')));
return;
}
if (!is_array($block)) {
$block = BlockUtil::getBlockInfo($block);
}
$block['position'] = $position;
$output = BlockUtil::show($module, $blockname, $block);
if ($assign) {
$view->assign($assign, $output);
} else {
return $output;
}
}
示例2: smarty_function_modgetvar
/**
* Zikula_View function to get module variable
*
* This function obtains a module-specific variable from the Zikula system.
*
* Note that the results should be handled by the safetext or the safehtml
* modifier before being displayed.
*
*
* Available parameters:
* - module: The well-known name of a module from which to obtain the variable
* - name: The name of the module variable to obtain
* - assign: If set, the results are assigned to the corresponding variable instead of printed out
* - html: If true then result will be treated as html content
* - default: The default value to return if the config variable is not set
*
* Example
* {modgetvar module='Example' name='foobar' assign='foobarOfExample'}
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return string The module variable.
*/
function smarty_function_modgetvar($params, Zikula_View $view)
{
$assign = isset($params['assign']) ? $params['assign'] : null;
$default = isset($params['default']) ? $params['default'] : null;
$module = isset($params['module']) ? $params['module'] : null;
$html = isset($params['html']) ? (bool) $params['html'] : false;
$name = isset($params['name']) ? $params['name'] : null;
if (!$module) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modgetvar', 'module')));
return false;
}
if (!$name && !$assign) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modgetvar', 'name')));
return false;
}
if (!$name) {
$result = ModUtil::getVar($module);
} else {
$result = ModUtil::getVar($module, $name, $default);
}
if ($assign) {
$view->assign($assign, $result);
} else {
if ($html) {
return DataUtil::formatForDisplayHTML($result);
} else {
return DataUtil::formatForDisplay($result);
}
}
}
示例3: smarty_function_modishooked
/**
* Zikula_View function to check for the availability of a module
*
* This function calls ModUtil::isHooked to determine if two Zikula modules are
* hooked together. True is returned if the modules are hooked, false otherwise.
* The result can also be assigned to a template variable.
*
* Available parameters:
* - tmodname: The well-known name of the hook module
* - smodname: The well-known name of the calling module
* - assign: The name of a variable to which the results are assigned
*
* Examples
* {modishooked tmodname='Ratings' smodname='News'}
*
* {modishooked tmodname='bar' smodname='foo' assign='barishookedtofoo'}
* {if $barishookedtofoo}.....{/if}
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @see function.modishooked.php::smarty_function_modishooked()
*
* @return boolean True if the module is available; false otherwise.
*/
function smarty_function_modishooked($params, $view)
{
LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated.', array('modishooked')), E_USER_DEPRECATED);
$assign = isset($params['assign']) ? $params['assign'] : null;
$smodname = isset($params['smodname']) ? $params['smodname'] : null;
$tmodname = isset($params['tmodname']) ? $params['tmodname'] : null;
if (!$tmodname) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modishooked', 'tmodname')));
return false;
}
if (!$smodname) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modishooked', 'smodname')));
return false;
}
$result = ModUtil::isHooked($tmodname, $smodname);
if ($assign) {
$view->assign($params['assign'], $result);
} else {
return $result;
}
}
示例4: smarty_function_blockgetinfo
/**
* Obtain the value of one block variable or all block variables for a specified block.
*
* Note: If the name of the block variable is not set, then the assign parameter
* must be set since an array of block variables will be returned.
*
* Available attributes:
* - bid (numeric) The block id
* - name (string) The name of the block variable to get, otherwise the
* entire block array is assigned is returned.
* (required, if the assign attribute is not specified,
* otherwise, optional)
* - assign (string) The name of the template variable to which the value
* is assigned, instead of being output to the template.
* (optional if the name attribute is set, otherwise
* required)
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the {@link Zikula_View} object.
*
* @return mixed the value of the block variable specified by the name attribute,
* or an array containing the full block information.
*/
function smarty_function_blockgetinfo($params, Zikula_View $view)
{
$bid = isset($params['bid']) ? (int) $params['bid'] : 0;
$name = isset($params['name']) ? $params['name'] : null;
$assign = isset($params['assign']) ? $params['assign'] : null;
if (!$bid) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('blockgetinfo', 'bid')));
}
// get the block info array
$blockinfo = BlockUtil::getBlockInfo($bid);
if ($name) {
if ($assign) {
$view->assign($assign, $blockinfo[$name]);
} else {
return $blockinfo[$name];
}
} else {
// handle the full blockinfo array
if ($assign) {
$view->assign($assign, $blockinfo);
} else {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified to get the full block information.', array('pnblockgetinfo', 'assign')));
}
}
return;
}
示例5: smarty_function_array_field_isset
/**
* Check if an array element (subscript) is set.
*
* Available attributes:
* - array (array) an array template variable
* - field (string) the value of a key in the array specified above
* - returnValue (bool|int) if set, then the contents of the array element
* $array[$field] is returned if it is set, otherwise false is returned
* - assign (string) (optional) if provided, a template variable with
* the specified name is set with the return value,
* instead of returning the value to the template
*
* Examples:
*
* Return true to the template if the template variable $myarray['arraykey']
* is set, otherwise return false to the template:
*
* <samp>{array_field_isset array=$myarray field='arraykey'}</samp>
*
* Return the value of the template variable $myarray['arraykey'] to the
* template if it is set, otherwise return false to the template:
*
* <samp>{array_field_isset array=$myarray field='arraykey' returnValue=1}</samp>
*
* Assign true to the template variable $myValue if the template variable
* $myarray['arraykey'] is set, otherwise set $myValue to false:
*
* <samp>{array_field_isset array=$myarray field='arraykey' assign='myValue'}</samp>
*
* Assign the value of the template variable $myarray['arraykey'] to the
* template variable $myValue if it is set, otherwise assign false to $myValue:
*
* <samp>{array_field_isset array=$myarray field='arraykey' returnValue=1 assign='myValue'}</samp>
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the {@link Zikula_View} object.
*
* @return boolean|mixed if returnValue is not set, then returns true if the array
* element is set, otherwise false; if returnValue is set,
* then returns the value of the array element if it is set,
* otherwise false.
*/
function smarty_function_array_field_isset($params, Zikula_View $view)
{
LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('array_field_isset returnValue=1 ...', 'array_field ...')), E_USER_DEPRECATED);
$array = isset($params['array']) ? $params['array'] : null;
$field = isset($params['field']) ? $params['field'] : null;
$returnValue = isset($params['returnValue']) ? $params['returnValue'] : null;
$assign = isset($params['assign']) ? $params['assign'] : null;
if ($array === null) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('array_field_isset', 'array')));
return false;
}
if ($field === null) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('array_field_isset', 'field')));
return false;
}
$result = isset($array[$field]);
if ($result && $returnValue) {
$result = $array[$field];
}
if ($assign) {
$view->assign($assign, $result);
} else {
return $result;
}
}
示例6: smarty_function_array_pop
/**
* Pop a field of an array and assign its value to a template variable.
*
* Available attributes:
* - array (string) Name of the template array variable to process
* - field (string) Name of the array field to assign then unset
* - unset (bool) Flag to specify if the field must be unset or not (default: true)
* - assign (string) Name of the assign variable to setup (optional)
*
* Example:
*
* Having an $objarray in our template, we want to process its fields in different
* sections of the template, so we get the needed fields separately on the desired positions,
* clearing the array in the process.
*
* For instance, the $hooks array resulted of notify the 'display_view' hooks, can be
* processed individually using this plugin:
*
* <samp>{array_pop array='hooks' field='EZComments'}</samp>
* <samp>{array_pop array='hooks' field='EZComments' assign='comments'}</samp>
*
* And display later the remaining ones with a foreach.
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the {@link Zikula_View} object.
*
* @return mixed False on failure, void if the value is assigned, or the value extracted itself.
*/
function smarty_function_array_pop($params, Zikula_View $view)
{
if (!isset($params['array']) || !$params['array']) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('assign_cache', 'var')));
return false;
}
if (!isset($params['field']) || !$params['field']) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('assign_cache', 'value')));
return false;
}
$unset = isset($params['unset']) ? (bool) $params['unset'] : true;
$value = null;
$array = $view->getTplVar($params['array']);
if ($array && isset($array[$params['field']])) {
$value = $array[$params['field']];
if ($unset) {
unset($array[$params['field']]);
}
$view->assign($params['array'], $array);
}
if (isset($params['assign']) && $params['assign']) {
$view->assign($params['assign'], $value);
} else {
return $value;
}
}
示例7: smarty_function_array_field_pop
/**
* Zikula_View function return and unset an array field if set.
*
* Available attributes:
* - array (string) The name of an array template variable
* - field (string) The name of an array key in the array template variable above
* - unset (bool|int) If true, the array element will be unset, if false the
* \ array element will remain unchanged
* - assign (string) The name of a template variable that the value of
* $array['field'] will be assigned to
*
* Examples:
*
* Assign the value of the template variable $myarray['arraykey'] to the
* template variable $myValue if it is set, otherwise assign false to $myValue.
* The template variable $myarray['arraykey'] is NOT unset:
*
* <samp>{array_field_pop array='myarray' field='arraykey' assign='myValue'}</samp>
*
* Assign the value of the template variable $myarray['arraykey'] to the
* template variable $myValue if it is set, otherwise assign false to $myValue.
* The template variable $myarray['arraykey'] IS unset:
*
* <samp>{array_field_pop array='myarray' field='arraykey' unset=1 assign='myValue'}</samp>
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the {@link Zikula_View} object.
*
* @return null The value of the specified array element is return
* in the specified template variable if it is set,
* otherwise the template variable is set to false; no output to the template.
*/
function smarty_function_array_field_pop($params, Zikula_View $view)
{
LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('array_field_pop', 'array_pop')), E_USER_DEPRECATED);
$array = isset($view->_tpl_vars[$params['array']]);
$field = isset($params['field']) ? $params['field'] : null;
$unset = isset($params['unset']) ? $params['unset'] : false;
$assign = isset($params['assign']) ? $params['assign'] : null;
if (!$array) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('array_field_pop', 'array')));
return false;
}
if (!is_array($view->_tpl_vars[$params['array']])) {
$view->trigger_error(__f('Non-array passed to %s.', 'array_field_pop'));
return false;
}
if ($field === null) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('array_field_pop', 'field')));
return false;
}
$result = false;
if (isset($view->_tpl_vars[$params['array']][$field])) {
$result = $view->_tpl_vars[$params['array']][$field];
if ($unset) {
unset($view->_tpl_vars[$params['array']][$field]);
}
}
if ($assign) {
$view->assign($assign, $result);
} else {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified to get the required field.', array('array_field_pop', 'assign')));
return false;
}
}
示例8: smarty_function_modulejavascript
/**
* Zikula_View function to include module specific javascripts
*
* Available parameters:
* - modname module name (if not set, the current module is assumed)
* if modname="" than we will look into the main javascript folder
* - script name of the external javascript file (mandatory)
* - modonly javascript will only be included when the the current module is $modname
* - onload function to be called with onLoad handler in body tag, makes sense with assign set only, see example #2
* - assign if set, the tag and the script filename are returned
*
* Example: {modulejavascript modname=foobar script=module_admin_config.js modonly=1 }
* Output: <script type="text/javascript" src="modules/foobar/javascript/module_admin_config.js">
*
* Example: {modulejavascript modname=foobar script=module_admin_config.js modonly=1 onload="dosomething()" assign=myjs }
* Output: nothing, but assigns a variable containing several values:
* $myjs.scriptfile = "modules/foobar/javascript/module_admin_config.js"
* $myjs.tag = "<script type=\"text/javascript\" src=\"modules/foobar/javascript/module_admin_config.js\"></script>"
* $myjs.onload = "onLoad=\"dosomething()\"";
* Possible code in master.tpl would be:
*
* ...
* { $myjs.tag }
* </head>
* <body { $myjs.onload } >
* ...
*
* which results in
*
* ...
* <script type="text/javascript" src="modules/foobar/javascript/module_admin_config.js"></script>
* </head>
* <body onLoad="dosomething()" >
* ...
*
* if foobar is the current module.
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return string The tag.
*/
function smarty_function_modulejavascript($params, Zikula_View $view)
{
// check if script is set (mandatory)
if (!isset($params['script'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modulejavascript', 'script')));
return false;
}
// check if modname is set and if not, if $modonly is set
if (!isset($params['modname'])) {
if (isset($params['modonly'])) {
// error - we want $modonly only with $modname
$view->trigger_error(__f('Error! in %1$s: parameter \'%2$s\' only supported together with \'%3$s\' set.', array('modulejavascript', 'modonly', 'modname')));
return;
}
// we use the current module name
$params['modname'] = ModUtil::getName();
}
if (isset($params['modonly']) && $params['modname'] != ModUtil::getName()) {
// current module is not $modname - do nothing and return silently
return;
}
// if modname is empty, we will search the main javascript folder
if ($params['modname'] == '') {
$searchpaths = array('javascript', 'javascript/ajax');
} else {
// theme directory
$theme = DataUtil::formatForOS(UserUtil::getTheme());
$osmodname = DataUtil::formatForOS($params['modname']);
$themepath = "themes/{$theme}/Resources/public/js/{$osmodname}";
// module directory
$modinfo = ModUtil::getInfoFromName($params['modname']);
$osmoddir = DataUtil::formatForOS($modinfo['directory']);
$modpath = "modules/{$osmoddir}/Resources/public/js";
$syspath = "system/{$osmoddir}/Resources/public/js";
$searchpaths = array($themepath, $modpath, $syspath);
}
$osscript = DataUtil::formatForOS($params['script']);
// search for the javascript
$scriptsrc = '';
foreach ($searchpaths as $path) {
if (is_readable("{$path}/{$osscript}")) {
$scriptsrc = "{$path}/{$osscript}";
break;
}
}
// if no module javascript has been found then return no content
$tag = empty($scriptsrc) ? '' : '<script type="text/javascript" src="' . $scriptsrc . '"></script>';
// onLoad event handler used?
$onload = isset($params['onload']) ? 'onLoad="' . $params['onload'] . '"' : '';
if (isset($params['assign'])) {
$return = array();
$return['scriptfile'] = $scriptsrc;
$return['tag'] = $tag;
$return['onload'] = $onload;
$view->assign($params['assign'], $return);
} else {
return $tag;
}
//.........这里部分代码省略.........
示例9: smarty_function_modurl
/**
* Zikula_View function to create a zikula.orgpatible URL for a specific module function.
*
* This function returns a module URL string if successful. Unlike the API
* function ModURL, this is already sanitized to display, so it should not be
* passed to the safetext modifier.
*
* Available parameters:
* - modname: The well-known name of a module for which to create the URL (required)
* - type: The type of function for which to create the URL; currently one of 'user' or 'admin' (default is 'user')
* - func: The actual module function for which to create the URL (default is 'main')
* - fragment: The fragement to target within the URL
* - ssl: See below
* - fqurl: Make a fully qualified URL
* - forcelongurl: Do not create a short URL (forced)
* - forcelang (boolean|string) Force the inclusion of the $forcelang or default system language in the generated url
* - append: (optional) A string to be appended to the URL
* - assign: If set, the results are assigned to the corresponding variable instead of printed out
* - all remaining parameters are passed to the module function
*
* Example
* Create a URL to the News 'view' function with parameters 'sid' set to 3
* <a href="{modurl modname='News' type='user' func='display' sid='3'}">Link</a>
*
* Example SSL
* Create a secure https:// URL to the News 'view' function with parameters 'sid' set to 3
* ssl - set to constant null,true,false NOTE: $ssl = true not $ssl = 'true' null - leave the current status untouched, true - create a ssl url, false - create a non-ssl url
* <a href="{modurl modname='News' type='user' func='display' sid='3' ssl=true}">Link</a>
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return string The URL.
*/
function smarty_function_modurl($params, Zikula_View $view)
{
$assign = isset($params['assign']) ? $params['assign'] : null;
$append = isset($params['append']) ? $params['append'] : '';
$fragment = isset($params['fragment']) ? $params['fragment'] : null;
$fqurl = isset($params['fqurl']) ? $params['fqurl'] : null;
$forcelongurl = isset($params['forcelongurl']) ? (bool) $params['forcelongurl'] : false;
if (isset($params['func']) && $params['func']) {
$func = $params['func'];
} else {
if (System::isLegacyMode()) {
$func = 'main';
LogUtil::log(__f('{modurl} - %1$s is a required argument, you must specify it explicitly in %2$s', array('func', $view->template)), E_USER_DEPRECATED);
} else {
$view->trigger_error(__f('{modurl} - %1$s is a required argument, you must specify it explicitly in %2$s', array('func', $view->template)));
return false;
}
}
if (isset($params['type']) && $params['type']) {
$type = $params['type'];
} else {
if (System::isLegacyMode()) {
$type = 'user';
LogUtil::log(__f('{modurl} - %1$s is a required argument, you must specify it explicitly in %2$s', array('type', $view->template)), E_USER_DEPRECATED);
} else {
$view->trigger_error(__f('{modurl} - %1$s is a required argument, you must specify it explicitly in %2$s', array('type', $view->template)));
return false;
}
}
$modname = isset($params['modname']) ? $params['modname'] : null;
$ssl = isset($params['ssl']) ? (bool) $params['ssl'] : null;
$forcelang = isset($params['forcelang']) && $params['forcelang'] ? $params['forcelang'] : false;
// avoid passing these to ModUtil::url
unset($params['modname']);
unset($params['type']);
unset($params['func']);
unset($params['fragment']);
unset($params['ssl']);
unset($params['fqurl']);
unset($params['assign']);
unset($params['append']);
unset($params['forcelang']);
unset($params['forcelongurl']);
if (!$modname) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modurl', 'modname')));
return false;
}
$result = ModUtil::url($modname, $type, $func, $params, $ssl, $fragment, $fqurl, $forcelongurl, $forcelang);
if ($append && is_string($append)) {
$result .= $append;
}
if ($assign) {
$view->assign($assign, $result);
} else {
return DataUtil::formatForDisplay($result);
}
}
示例10: smarty_function_assignedcategorieslist
/**
* Retrieve an HTML unordered list of the categories assigned to a specified item.
*
* The assigned categories are retrieved from $item['__CATEGORIES__'] (DBUtil) or $item['Categories'] (Doctrine).
* However, if we are using Doctrine 2, the categories are passed as param.
*
* Available attributes:
* - item (array) The item from which to retrieve the assigned categories.
* or
* - categories (object) The item's categories.
* - doctrine2 (boolean) true or false if using doctrine2 or not.
*
* Example:
*
* <samp>{assignedcategorieslist item=$myVar}</samp>
* <samp>{assignedcategorieslist categories=$myCategories doctrine2=true}</samp>
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the {@link Zikula_View} object.
*
* @return string The HTML code for an unordered list containing the item's
* assigned categories. If no categories are assigned to the
* item, then the list will contain a single list-item (<li>)
* with a message to that effect.
*/
function smarty_function_assignedcategorieslist($params, Zikula_View $view)
{
if (isset($params['doctrine2']) && (bool) $params['doctrine2'] == true) {
if (!isset($params['categories'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('assignedcategorieslist', 'categories')));
return false;
}
} elseif (!isset($params['item'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('assignedcategorieslist', 'item')));
return false;
}
$lang = ZLanguage::getLanguageCode();
$result = "<ul>\n";
if (isset($params['doctrine2']) && (bool) $params['doctrine2'] == true) {
if (count($params['categories']) > 0) {
foreach ($params['categories'] as $category) {
$name = $category->getCategory()->getName();
$display_name = $category->getCategory()->getDisplayName();
$result .= "<li>\n";
if (isset($display_name[$lang]) && !empty($display_name[$lang])) {
$result .= $display_name[$lang];
} elseif (isset($name) && !empty($name)) {
$result .= $name;
}
$result .= "</li>\n";
}
} else {
$result .= '<li>' . DataUtil::formatForDisplay(__('No assigned categories.')) . '</li>';
}
} else {
if (isset($params['item']['Categories']) && !empty($params['item']['Categories'])) {
$categories = $params['item']['Categories'];
} elseif (isset($params['item']['__CATEGORIES__']) && !empty($params['item']['__CATEGORIES__'])) {
$categories = $params['item']['__CATEGORIES__'];
} else {
$categories = array();
}
if (!empty($categories)) {
foreach ($categories as $property => $category) {
if (isset($category['Category'])) {
$category = $category['Category'];
}
$result .= "<li>\n";
if (isset($category['display_name'][$lang])) {
$result .= $category['display_name'][$lang];
} elseif (isset($category['name'])) {
$result .= $category['name'];
}
$result .= "</li>\n";
}
} else {
$result .= '<li>' . DataUtil::formatForDisplay(__('No assigned categories.')) . '</li>';
}
}
$result .= "</ul>\n";
return $result;
}
示例11: smarty_function_assign_cache
/**
* Assign a value caching its parameters if cache is enabled.
*
* Available attributes:
* - var (string) The template variable to assign
* - value (mixed) The value to assign
*
* Example:
*
* Having an $obj loaded from the DB, use assign_cache to cache some of its values,
* and use it later safely, even inside a cached template:
*
* <samp>{assign_cache var='author' value=$obj.cr_uid}</samp>
*
* And use that cached value later in another plugin:
*
* <samp>{useravatar uid=$author}</samp>
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the {@link Zikula_View} object.
*
* @return void
*/
function smarty_function_assign_cache($params, Zikula_View $view)
{
if (!isset($params['var'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('assign_cache', 'var')));
return false;
}
if (!isset($params['value'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('assign_cache', 'value')));
return false;
}
$view->assign($params['var'], $params['value']);
return;
}
示例12: smarty_function_gt
/**
* Zikula_View function to use the _dgettext() function
*
* This function takes a identifier and returns the corresponding language constant.
*
* Available parameters:
* - text: (required) string to translate
* - plural: (optional) plural version of the string
* - count: (optional) if we have plural we need to specify the count
* - tagN: (optional) replace for sprintf() e.g. %s or %1$s
* - domain: (optional) textdomain to be used (not required, the system will fill this out automatically
* - comment: (optional) comment to the translator (this is not processed by this code)
* - assign: If set, the results are assigned to the corresponding variable instead of printed out
*
* Examples
* {gt text="Hello world"}
* {gt text="Hello %s" tag1=$name}
* {gt text="You want one cup" plural="You want two cups" count=2}
* {gt text='Hello %1$s, welcome to %2$s' tag1=$city tag2=$country comment="%1 is a name %2 is the place"}
* ## WARNING! When using %1$s in a template, smarty compiles this to PHP so the string must be in single quotes or
* ## the $s will be evaluated as variable $s
*
*
* String replacement follows the rules at http://php.net/sprintf but please note Smarty seems to pass
* all variables as strings so %s and %n$s are mostly used.
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return string Translation if it was available.
*/
function smarty_function_gt($params, Zikula_View $view)
{
// the check order here is important because:
// if we are calling from a theme both $view->themeDomain and $view->renderDomain are set.
// if the call was from a template only $view->renderDomain is set.
if (isset($params['domain'])) {
$domain = (strtolower($params['domain']) == 'zikula' ? null : $params['domain']);
} else {
$domain = $view->getDomain(); // default domain
}
if (!isset($params['text'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('smarty_function_gt', 'text')));
return false;
}
$text = $params['text'];
// validate plural settings if applicable
if ((!isset($params['count']) && isset($params['plural'])) || (isset($params['count']) && !isset($params['plural']))) {
$view->trigger_error(__('Error! If you use a plural or count in gettext, you must use both parameters together.'));
return false;
}
$count = (isset($params['count']) ? (int)$params['count'] : 0);
$plural = (isset($params['plural']) ? $params['plural'] : false);
// build array for tags (for %s, %1$s etc) if applicable
ksort($params);
$tags = array();
foreach ($params as $key => $value) {
if (preg_match('#^tag([0-9]{1,2})$#', $key)) {
$tags[] = $value;
}
}
$tags = (count($tags) == 0 ? null : $tags);
// perform gettext
if ($plural) {
$result = (isset($tags) ? _fn($text, $plural, $count, $tags, $domain) : _n($text, $plural, $count, $domain));
} else {
$result = (isset($tags) ? __f($text, $tags, $domain) : __($text, $domain));
}
// assign or return
if (isset($params['assign'])) {
$view->assign($params['assign'], $result);
} else {
return $result;
}
}
示例13: smarty_function_modcallhooks
/**
* Zikula_View function call hooks
*
* This function calls a specific module function. It returns whatever the return
* value of the resultant function is if it succeeds.
* Note that in contrast to the API function modcallhooks you need not to load the
* module with ModUtil::load.
*
*
* Available parameters:
* - 'hookobject' the object the hook is called for - either 'item' or 'category'
* - 'hookaction' the action the hook is called for - one of 'create', 'delete', 'transform', or 'display'
* - 'hookid' the id of the object the hook is called for (module-specific)
* - 'implode' Implode collapses all display hooks into a single string.
* - 'assign' If set, the results are assigned to the corresponding variable instead of printed out
* - all remaining parameters are passed to the ModUtil::callHooks API via the extrainfo array
*
* Example
* {modcallhooks hookobject='item' hookaction='modify' hookid=$tid $modname='ThisModule' $objectid=$tid}
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @see function.modcallhooks.php::smarty_function_modcallhooks()
*
* @return string The results of the module function.
*/
function smarty_function_modcallhooks($params, $view)
{
LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('modcallhooks', 'notifydisplayhooks')), E_USER_DEPRECATED);
$assign = isset($params['assign']) ? $params['assign'] : null;
$hookid = isset($params['hookid']) ? $params['hookid'] : '';
$hookaction = isset($params['hookaction']) ? $params['hookaction'] : null;
$hookobject = isset($params['hookobject']) ? $params['hookobject'] : null;
$implode = isset($params['implode']) ? (bool)$params['implode'] : true;
// avoid sending these to ModUtil::callHooks
unset($params['hookobject']);
unset($params['hookaction']);
unset($params['hookid']);
unset($params['assign']);
unset($params['implode']);
if (!$hookobject) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modcallhooks', 'hookobject')));
return false;
}
if (!$hookaction) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modcallhooks', 'hookaction')));
return false;
}
if (!$hookid) {
$hookid = '';
}
// create returnurl if not supplied (= this page)
if (!isset($params['returnurl']) || empty($params['returnurl'])) {
$params['returnurl'] = str_replace('&', '&', 'http://' . System::getHost() . System::getCurrentUri());
}
// if the implode flag is true then we must always assign the result to a template variable
// outputing the erray is no use....
if (!$implode) {
$assign = 'hooks';
}
$result = ModUtil::callHooks($hookobject, $hookaction, $hookid, $params, $implode);
if ($assign) {
$view->assign($assign, $result);
} else {
return $result;
}
}
示例14: smarty_function_modapifunc
/**
* Zikula_View function to to execute a module API function
*
* This function calls a calls a specific module API function. It returns whatever the return
* value of the resultant function is if it succeeds.
* Note that in contrast to the API function ModUtil::apiFunc you need not to load the
* module API with ModUtil::loadApi.
*
*
* Available parameters:
* - modname: The well-known name of a module to execute a function from (required)
* - type: The type of function to execute; currently one of 'user' or 'admin' (default is 'user')
* - func: The name of the module function to execute (default is 'main')
* - assign: The name of a variable to which the results are assigned
* - all remaining parameters are passed to the module API function
*
* Examples
* {modapifunc modname='News' type='user' func='get' sid='3'}
*
* {modapifunc modname='foobar' type='user' func='getfoo' id='1' assign='myfoo'}
* {$myfoo.title}
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @see function.modfunc.php::smarty_function_modfunc()
*
* @return string The results of the module API function.
*/
function smarty_function_modapifunc($params, Zikula_View $view)
{
$assign = isset($params['assign']) ? $params['assign'] : null;
$func = isset($params['func']) && $params['func'] ? $params['func'] : 'main';
$modname = isset($params['modname']) ? $params['modname'] : null;
$type = isset($params['type']) && $params['type'] ? $params['type'] : 'user';
// avoid passing these to ModUtil::apiFunc
unset($params['modname']);
unset($params['type']);
unset($params['func']);
unset($params['assign']);
if (!$modname) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modapifunc', 'modname')));
return false;
}
if (isset($params['modnamefunc'])) {
$params['modname'] = $params['modnamefunc'];
unset($params['modnamefunc']);
}
$result = ModUtil::apiFunc($modname, $type, $func, $params);
if ($assign) {
$view->assign($assign, $result);
} else {
return $result;
}
}
示例15: smarty_function_thumb
/**
* Available params:
* - image (string) Path to source image (required)
* - width (int) Thumbnail width in pixels (optional, default value based on 'default' preset)
* - height (int) Thumbnail width in pixels (optional, default value based on 'default' preset)
* - mode (string) Thumbnail mode; 'inset' or 'outset' (optional, default 'inset')
* - extension (string) File extension for thumbnails: jpg, png, gif; null for original file type
* (optional, default value based on 'default' preset)
* - objectid (string) Unique signature for object, which owns this thumbnail (optional)
* - preset (string|object) Name of preset defined in Imagine or custom preset passed as instance of
* SystemPlugin_Imagine_Preset; if given inline options ('width', 'heigth', 'mode'
* and 'extension') are ignored (optional)
* - manager (object) Instance of SystemPlugin_Imagine_Manager; if given inline options ('width',
* 'heigth', 'mode' and 'extension') are ignored (optional)
* - fqurl (boolean) If set the thumb path is absolute, if not relative
* - tag (boolean) If set to true - full <img> tag will be generated. Tag attributes should be
* passed with "img_" prefix (for example: "img_class"). Getttext prefix may be
* used for translations (for example: "__img_alt")
*
* Examples
*
* Basic usage with inline options:
* {thumb image='path/to/image.png' width=100 height=100 mode='inset' extension='jpg'}
*
* Using preset define in Imagine plugin
* {thumb image='path/to/image.png' objectid='123' preset='my_preset'}
*
* Using custom preset, defined in module and passed to template
* {thumb image='path/to/image.png' objectid='123' preset=$preset}
*
* Using custom SystemPlugin_Imagine_Manager instance, defined in module and passed to template
* {thumb image='path/to/image.png' objectid='123' manager=$manager}
*
* Generating full img tag
* {thumb image='path/to/image.png' objectid='123' preset=$preset tag=true __img_alt='Alt text, gettext prefix may be used' img_class='image-class'}
* This will generate:
* <img src="thumb/path" widht="100" height="100" alt="Alt text, gettext prefix may be used" class="image-class" />
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the {@link Zikula_View} object.
*
* @return string thumb path
*/
function smarty_function_thumb($params, Zikula_View $view)
{
if (!isset($params['image']) || empty($params['image'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('smarty_function_thumb', 'image')));
return false;
}
$image = $params['image'];
$objectId = isset($params['objectid']) ? $params['objectid'] : null;
if (isset($params['manager']) && $params['manager'] instanceof SystemPlugin_Imagine_Manager) {
$manager = $params['manager'];
} else {
$manager = $view->getServiceManager()->getService('systemplugin.imagine.manager');
}
if (isset($params['preset']) && $params['preset'] instanceof SystemPlugin_Imagine_Preset) {
$preset = $params['preset'];
} elseif (isset($params['preset']) && $manager->getPlugin()->hasPreset($params['preset'])) {
$preset = $manager->getPlugin()->getPreset($params['preset']);
} else {
$preset = array();
$preset['width'] = isset($params['width']) ? $params['width'] : null;
$preset['height'] = isset($params['height']) ? $params['height'] : null;
$preset['mode'] = isset($params['mode']) ? $params['mode'] : null;
$preset['extension'] = isset($params['extension']) ? $params['extension'] : null;
$preset = array_filter($preset);
}
$manager->setPreset($preset);
$thumb = $manager->getThumb($image, $objectId);
$basePath = (isset($params['fqurl']) && $params['fqurl']) ? System::getBaseUrl() : System::getBaseUri();
$result = "{$basePath}/{$thumb}";
if (isset($params['tag']) && $params['tag']) {
$thumbSize = @getimagesize($thumb);
$attributes = array();
$attributes[] = "src=\"{$basePath}/{$thumb}\"";
$attributes[] = $thumbSize[3]; // width and height
// get tag params
foreach ($params as $key => $value) {
if (strpos($key, 'img_') === 0) {
$key = str_replace('img_', '', $key);
$attributes[$key] = "{$key}=\"{$value}\"";
}
}
if (!isset($attributes['alt'])) {
$attributes[] = 'alt=""';
}
$attributes = implode(' ', $attributes);
$result = "<img {$attributes} />";
}
if (isset($params['assign'])) {
$view->assign($params['assign'], $result);
} else {
//.........这里部分代码省略.........