本文整理汇总了PHP中LogUtil::log方法的典型用法代码示例。如果您正苦于以下问题:PHP LogUtil::log方法的具体用法?PHP LogUtil::log怎么用?PHP LogUtil::log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LogUtil
的用法示例。
在下文中一共展示了LogUtil::log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
}
示例2: smarty_block_secauthaction_block
/**
* Implement permissions checks in a template.
*
* Available attributes:
* - component (string) The component to be tested, e.g., 'ModuleName::'
* - instance (string) The instance to be tested, e.g., 'name::1'
* - level (int) The level of access required, e.g., ACCESS_READ
*
* Example:
* <pre>
* {secauthaction_block component='News::' instance='1::' level=ACCESS_COMMENT}
* do some stuff now that we have permission
* {/secauthaction_block}
* </pre>.
*
* @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.
*
* @return mixed The content of the block, if the user has the specified
* access level for the component and instance, otherwise null;
* false on an error.
*
* @deprecated See {@link smarty_block_securityutil_checkpermission_block}.
*/
function smarty_block_secauthaction_block($params, $content, &$smarty)
{
LogUtil::log(__f('Warning! Template block {%1$s} is deprecated, please use {%2$s} instead.', array('secauthaction_block', 'checkpermissionblock')), E_USER_DEPRECATED);
if (is_null($content)) {
return;
}
// check our input
if (!isset($params['component'])) {
$smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('smarty_block_secauthaction_block', 'component')));
return false;
}
if (!isset($params['instance'])) {
$smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('smarty_block_secauthaction_block', 'instance')));
return false;
}
if (!isset($params['level'])) {
$smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('smarty_block_secauthaction_block', 'level')));
return false;
}
if (!SecurityUtil::checkPermission($params['component'], $params['instance'], constant($params['level']))) {
return;
}
return $content;
}
示例3: smarty_function_securityutil_checkpermission
/**
* Example:
* {securityutil_checkpermission component='Users::' instance='.*' level='ACCESS_ADMIN' assign='auth'}
*
* true/false will be returned.
*
* This file is a plugin for Zikula_View, the Zikula implementation of Smarty
* @param array $params All attributes passed to this function from the template
* @param object $smarty Reference to the Smarty object
* @return boolean authorized?
*/
function smarty_function_securityutil_checkpermission($params, $smarty)
{
LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('securityutil_checkpermission', 'checkpermission')), E_USER_DEPRECATED);
if (!isset($params['component'])) {
$smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('securityutil_checkpermission', 'component')));
return false;
}
if (!isset($params['instance'])) {
$smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('securityutil_checkpermission', 'instance')));
return false;
}
if (!isset($params['level'])) {
$smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('securityutil_checkpermission', 'level')));
return false;
}
$result = SecurityUtil::checkPermission($params['component'], $params['instance'], constant($params['level']));
if (isset($params['assign'])) {
$smarty->assign($params['assign'], $result);
} else {
return $result;
}
}
示例4: 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;
}
}
示例5: smarty_function_configgetvar
/**
* Obtain and display a configuration variable from the Zikula system.
*
* Available attributes:
* - name (string) The name of the configuration variable to obtain
* - html (bool) If set, the output is prepared for display by
* DataUtil::formatForDisplayHTML instead of
* DataUtil::formatForDisplay
* - assign (string) the name of a template variable to assign the
* output to, instead of returning it to the template. (optional)
*
* <i>Note that if the the result is assigned to a template variable, it is not
* prepared for display by either DataUtil::formatForDisplayHTML or
* DataUtil::formatForDisplay. If it is to be displayed, the safetext
* modifier should be used.</i>
*
* Examples:
*
* <samp><p>Welcome to {configgetvar name='sitename'}!</p></samp>
*
* <samp>{configgetvar name='sitename' assign='thename'}</samp><br>
* <samp><p>Welcome to {$thename|safetext}!</p></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 mixed The value of the configuration variable.
*/
function smarty_function_configgetvar($params, $view)
{
LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated.', array('configgetvar')), E_USER_DEPRECATED);
$name = isset($params['name']) ? $params['name'] : null;
$default = isset($params['default']) ? $params['default'] : null;
$html = isset($params['html']) ? $params['html'] : null;
$assign = isset($params['assign']) ? $params['assign'] : null;
if (!$name) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('configgetvar', 'name')));
return false;
}
$result = System::getVar($name, $default);
if ($assign) {
$view->assign($assign, $result);
} else {
if (is_bool($html) && $html) {
return DataUtil::formatForDisplayHTML($result);
} else {
return DataUtil::formatForDisplay($result);
}
}
}
示例6: getVersionMeta
/**
* Get version metadata for a module.
*
* @param string $moduleName Module Name.
* @param string $rootdir Root directory of the module (default: modules).
*
* @return Zikula_AbstractVersion|array
*/
public static function getVersionMeta($moduleName, $rootdir = 'modules')
{
$modversion = array();
$class = "{$moduleName}_Version";
if (class_exists($class)) {
try {
$modversion = new $class();
} catch (Exception $e) {
LogUtil::log(__f('%1$s threw an exception reporting: "%2$s"', array($class, $e->getMessage())), Zikula_AbstractErrorHandler::CRIT);
throw new InvalidArgumentException(__f('%1$s threw an exception reporting: "%2$s"', array($class, $e->getMessage())), 0, $e);
}
if (!$modversion instanceof Zikula_AbstractVersion) {
LogUtil::registerError(__f('%s is not an instance of Zikula_AbstractVersion', get_class($modversion)));
}
} elseif (is_dir("{$rootdir}/{$moduleName}/lib")) {
LogUtil::registerError(__f('Could not find %1$s for module %2$s', array("{$moduleName}_Version", $moduleName)));
} else {
// pre 1.3 modules
$legacyVersionPath = "{$rootdir}/{$moduleName}/pnversion.php";
if (!file_exists($legacyVersionPath)) {
if (!System::isUpgrading()) {
LogUtil::log(__f("Error! Could not load the file '%s'.", $legacyVersionPath), Zikula_AbstractErrorHandler::CRIT);
LogUtil::registerError(__f("Error! Could not load the file '%s'.", $legacyVersionPath));
}
$modversion = array('name' => $moduleName, 'description' => '', 'version' => 0);
} else {
include $legacyVersionPath;
}
}
return $modversion;
}
示例7: smarty_function_manuallink
/**
* Zikula_View function to create manual link.
*
* This function creates a manual link from some parameters.
*
* Available parameters:
* - manual: name of manual file, manual.html if not set
* - chapter: an anchor in the manual file to jump to
* - newwindow: opens the manual in a new window using javascript
* - width: width of the window if newwindow is set, default 600
* - height: height of the window if newwindow is set, default 400
* - title: name of the new window if newwindow is set, default is modulename
* - class: class for use in the <a> tag
* - assign: if set, the results ( array('url', 'link') are assigned to the corresponding variable instead of printed out
*
* Example
* {manuallink newwindow=1 width=400 height=300 title=rtfm }
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return string|void
*/
function smarty_function_manuallink($params, Zikula_View $view)
{
LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated.', array('manuallink')), E_USER_DEPRECATED);
$userlang = ZLanguage::transformFS(ZLanguage::getLanguageCode());
$stdlang = System::getVar('language_i18n');
$title = isset($params['title']) ? $params['title'] : 'Manual';
$manual = isset($params['manual']) ? $params['manual'] : 'manual.html';
$chapter = isset($params['chapter']) ? '#' . $params['chapter'] : '';
$class = isset($params['class']) ? 'class="' . $params['class'] . '"' : '';
$width = isset($params['width']) ? $params['width'] : 600;
$height = isset($params['height']) ? $params['height'] : 400;
$modname = ModUtil::getName();
$possibleplaces = array("modules/{$modname}/docs/{$userlang}/manual/{$manual}", "modules/{$modname}/docs/{$stdlang}/manual/{$manual}", "modules/{$modname}/docs/en/manual/{$manual}", "modules/{$modname}/docs/{$userlang}/{$manual}", "modules/{$modname}/docs/{$stdlang}/{$manual}", "modules/{$modname}/docs/lang/en/{$manual}");
foreach ($possibleplaces as $possibleplace) {
if (file_exists($possibleplace)) {
$url = $possibleplace . $chapter;
break;
}
}
if (isset($params['newwindow'])) {
$link = "<a {$class} href='#' onclick=\"window.open( '" . DataUtil::formatForDisplay($url) . "' , '" . DataUtil::formatForDisplay($modname) . "', 'status=yes,scrollbars=yes,resizable=yes,width={$width},height={$height}'); picwin.focus();\">" . DataUtil::formatForDisplayHTML($title) . "</a>";
} else {
$link = "<a {$class} href=\"" . DataUtil::formatForDisplay($url) . "\">" . DataUtil::formatForDisplayHTML($title) . "</a>";
}
if (isset($params['assign'])) {
$ret = array('url' => $url, 'link' => $link);
$view->assign($params['assign'], $ret);
return;
} else {
return $link;
}
}
示例8: smarty_function_secauthaction
/**
* Example:
* {secauthaction comp="Stories::" inst=".*" level="ACCESS_ADMIN" assign="auth"}
*
* true/false will be returned.
*
* This file is a plugin for Zikula_View, the Zikula implementation of Smarty
* @param array $params All attributes passed to this function from the template
* @param object &$smarty Reference to the Smarty object
* @return boolean authorized?
*/
function smarty_function_secauthaction($params, &$smarty)
{
LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('secauthaction', 'checkpermission')), E_USER_DEPRECATED);
$assign = isset($params['assign']) ? $params['assign'] : null;
$comp = isset($params['comp']) ? $params['comp'] : null;
$inst = isset($params['inst']) ? $params['inst'] : null;
$level = isset($params['level']) ? $params['level'] : null;
if (!$comp) {
$smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('smarty_function_secauthaction', 'comp')));
return false;
}
if (!$inst) {
$smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('smarty_function_secauthaction', 'inst')));
return false;
}
if (!$level) {
$smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('smarty_function_secauthaction', 'level')));
return false;
}
$result = SecurityUtil::checkPermission($comp, $inst, constant($level));
if ($assign) {
$smarty->assign($assign, $result);
} else {
return $result;
}
}
示例9: 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;
}
}
示例10: smarty_function_languagelist
/**
* Smarty function to display a drop down list of languages.
*
* This plugin as been superceded by html_select_languages.
*
* @deprecated
* @param array $params All attributes passed to this function from the template.
* @param object $smarty Reference to the Smarty object.
*
* @return string The value of the last status message posted, or void if no status message exists.
*/
function smarty_function_languagelist($params, $smarty)
{
LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('languagelist', 'html_select_languages')), E_USER_DEPRECATED);
require_once $smarty->_get_plugin_filepath('function','html_select_languages');
return smarty_function_html_select_languages($params, $smarty);
}
示例11: smarty_function_moduleadminlinks
/**
* Zikula_View function to display admin links for a module.
*
* Example:
* {moduleadminlinks modname=Example start="[" end="]" seperator="|" class="z-menuitem-title"}
*
* Available parameters:
* - modname Module name to display links for.
* - start Start string (optional).
* - end End string (optional).
* - seperator Link seperator (optional).
* - class CSS class (optional).
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return string A formatted string containing navigation for the module admin panel.
*/
function smarty_function_moduleadminlinks($params, $view)
{
LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('moduleadminlinks', 'modulelinks')), E_USER_DEPRECATED);
// set some defaults
$start = isset($params['start']) ? $params['start'] : '[';
$end = isset($params['end']) ? $params['end'] : ']';
$seperator = isset($params['seperator'])? $params['seperator']: '|';
$class = isset($params['class']) ? $params['class'] : 'z-menuitem-title';
$modname = $params['modname'];
unset ($params['modname']);
if (!isset($modname) || !ModUtil::available($modname)) {
$modname = ModUtil::getName();
}
// check our module name
if (!ModUtil::available($modname)) {
$view->trigger_error('moduleadminlinks: '.__f("Error! The '%s' module is not available.", DataUtil::formatForDisplay($modname)));
return false;
}
// get the links from the module API
$links = ModUtil::apiFunc($modname, 'admin', 'getlinks', $params);
// establish some useful count vars
$linkcount = count($links);
$adminlinks = "<span class=\"$class\">$start ";
foreach ($links as $key => $link) {
$id = '';
if (isset($link['id'])) {
$id = 'id="' . $link['id'] . '"';
}
if (!isset($link['title'])) {
$link['title'] = $link['text'];
}
if (isset($link['disabled']) && $link['disabled'] == true) {
$adminlinks .= "<span $id>" . '<a class="z-disabledadminlink" title="' . DataUtil::formatForDisplay($link['title']) . '">' . DataUtil::formatForDisplay($link['text']) . '</a> ';
} else {
$adminlinks .= "<span $id><a href=\"" . DataUtil::formatForDisplay($link['url']) . '" title="' . DataUtil::formatForDisplay($link['title']) . '">' . DataUtil::formatForDisplay($link['text']) . '</a> ';
}
if ($key == $linkcount-1) {
$adminlinks .= '</span>';
continue;
}
// linebreak
if (isset($link['linebreak']) && $link['linebreak'] == true) {
$adminlinks .= "</span>\n ";
$adminlinks .= "$end</span><br /><span class=\"$class\">$start ";
} else {
$adminlinks .= "$seperator</span>\n ";
}
}
$adminlinks .= "$end</span>\n";
return $adminlinks;
}
示例12: smarty_function_themeinfo
/**
* Smarty function to display the theme info
*
* Example
* {themeinfo}
*
* @see function.themeinfo.php::smarty_function_themeinfo()
* @param array $params All attributes passed to this function from the template
* @param object $smarty Reference to the Smarty object
* @return string the themeinfo
*/
function smarty_function_themeinfo($params, $smarty)
{
LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('themeinfo', '$themeinfo')), E_USER_DEPRECATED);
$thistheme = UserUtil::getTheme();
$themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName($thistheme));
$themecredits = '<!-- ' . __f('Theme: %1$s by %2$s - %3$s', array(DataUtil::formatForDisplay($themeinfo['display']), DataUtil::formatForDisplay($themeinfo['author']), DataUtil::formatForDisplay($themeinfo['contact']))) . ' -->';
return $themecredits;
}
示例13: smarty_function_assign_arrayval
/**
* Assign a template variable with the value found in an array element at the specified key.
*
* Available attributes:
* - array (array) The array template variable in which to retrieve the value
* - key (string|int) The key into the specified array where the value is to be retrieved from
* - assign (string) The name of the template variable to assign the value to (required)
*
* Examples:
*
* Assign the template variable $myVar with the value found in the template
* variable $myArray['myKey']:
*
* <samp>{assign_arrayval array=$myArray key='myKey' assign='myVar'}</samp>
*
* Assign the template variable $myVar with the value found in the template
* variable $myArray[3]:
*
* <samp>{assign_arrayval array=$myArray key=3 assign='myVar'}</samp>
*
* In the following example, assume the template variable $myArray[4] is not
* set (isset would return false). In this case $myVar is set to null:
*
* <samp>{assign_arrayval array=$myArray key=4 assign='myVar'}</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_arrayval($params, Zikula_View $view)
{
LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('assign_arrayval key="X" ...', 'array_field field="X" ...')), E_USER_DEPRECATED);
$array = isset($params['array']) ? $params['array'] : array();
$key = isset($params['key']) ? $params['key'] : '';
$assign = isset($params['assign']) ? $params['assign'] : $key;
$val = isset($array[$key]) ? $array[$key] : null;
$view->assign($assign, $val);
}
示例14: 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);
}
}
示例15: smarty_function_title
/**
* Zikula_View function to generate the title for the page
*
* Available parameters:
* - assign if set, the title will be assigned to this variable
*
* Example
* {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.title.php::smarty_function_title()
*
* @return string The title.
*/
function smarty_function_title($params, $view)
{
LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('title', "pagegetvar name='title'")), E_USER_DEPRECATED);
$title = PageUtil::getVar('title');
if (isset($params['assign'])) {
$view->assign($params['assign'], $title);
} else {
return $title;
}
}