本文整理汇总了PHP中Zikula_View::assign方法的典型用法代码示例。如果您正苦于以下问题:PHP Zikula_View::assign方法的具体用法?PHP Zikula_View::assign怎么用?PHP Zikula_View::assign使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zikula_View
的用法示例。
在下文中一共展示了Zikula_View::assign方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_legalinlinelink
/**
* Smarty function to display a single inline user link of a specific policy for the Legal module.
*
* Example
* {legalinlinelink policytype='termsofuse'}
*
* Tag Parameters:
* policyType The unique string identifier of the policy typw whose inline link is to be returned; required.
* target The target for the generated link, such as "_blank" to open the policy in a new window; optional, default is blank (same effect as "_self").
* assign The name of the template variable to which the output is assiged, if provided; optional, if not specified the output is sent to the template.
*
* Templates used:
* legal_function_legalinlinelink_notfound.tpl
* legal_function_legalinlinelink_legalnotice.tpl
* legal_function_legalinlinelink_termsofuse.tpl
* legal_function_legalinlinelink_privacypolicy.tpl
* legal_function_legalinlinelink_tradeconditions.tpl
* legal_function_legalinlinelink_cancellationrightpolicy.tpl
* legal_function_legalinlinelink_accessibilitystatement.tpl
*
* Template Parameters Exported:
* $target The target for the generated link, such as "_blank" to open the policy in a new window; optional, default is blank (same effect as "_self").
* (assign) If an assign tag parameter is specified, then a template variable a name equal to the value of the assign parameter is exported, containing the rendered output; optional, default is to return the output to the template.
*
* @param array $params All parameters passed to this function from the template.
* @param Zikula_View &$view Reference to the Zikula view object, a subclass of Smarty.
*
* @return string The rendered template output for the specified policy type.
*/
function smarty_function_legalinlinelink($params, Zikula_View &$view)
{
if (!isset($params['policyType'])) {
$template = 'plugins/legal_function_legalinlinelink_notfound.tpl';
} else {
$params['policyType'] = strtolower($params['policyType']);
$template = 'plugins/legal_function_legalinlinelink_' . $params['policyType'] . '.tpl';
if (!$view->template_exists($template)) {
$template = 'plugins/legal_function_legalinlinelink_notfound.tpl';
}
}
$templateVars = array(
'target' => isset($params['target']) ? $params['target'] : ''
);
$view->assign($templateVars);
if (isset($params['assign']) && !empty($params['assign'])) {
$view->assign($params['assign'], $view->fetch($template));
} else {
return $view->fetch($template);
}
}
示例2: 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;
}
示例3: 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;
}
}
示例4: smarty_function_tree
/**
* Zikula_View function to load Zikula_tree.
*
* Example:
* {tree $menuArray=$your_content imagesDir='yout/path/to/images/'}
*
* @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 results of the module function
*/
function smarty_function_tree($params, Zikula_View $view)
{
$menuString = isset($params['menustring']) ? $params['menustring'] : null;
$menuArray = isset($params['menuarray']) ? $params['menuarray'] : null;
$treeArray = isset($params['treearray']) ? $params['treearray'] : null;
$config = isset($params['config']) ? $params['config'] : array();
if (!isset($menuString) && !isset($menuArray) && !isset($treeArray)) {
$view->trigger_error(__f('Error! in %1$s: %2$s, %3$s or %4$s parameter must be specified.', array('smarty_function_tree', 'menustring', 'menuarray', 'treearray')));
return false;
}
unset($params['menustring']);
unset($params['menuarray']);
unset($params['treearray']);
unset($params['config']);
$config = array_merge($config, (array) $params);
$tree = new Zikula_Tree($config);
if (isset($treeArray)) {
$tree->setTreeData($treeArray);
} elseif (isset($menuArray)) {
$tree->loadArrayData($menuArray);
} else {
$tree->loadStringData($menuString);
}
if (isset($params['assign'])) {
$view->assign($params['assign'], $tree->getHTML());
} else {
return $tree->getHTML();
}
}
示例5: 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;
}
}
示例6: 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);
}
}
}
示例7: smarty_function_selector_user_category
/**
* User category selector.
*
* Available parameters:
* - btnText: If set, the results are assigned to the corresponding variable instead of printed out
* - cid: category ID
*
* Example
* {selector_user_category cid="1" assign="category"}
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return string HTML code of the selector.
*/
function smarty_function_selector_user_category($params, Zikula_View $view)
{
$field = isset($params['field']) ? $params['field'] : 'id';
$selectedValue = isset($params['selectedValue']) ? $params['selectedValue'] : 0;
$defaultValue = isset($params['defaultValue']) ? $params['defaultValue'] : 0;
$defaultText = isset($params['defaultText']) ? $params['defaultText'] : '';
$lang = isset($params['lang']) ? $params['lang'] : ZLanguage::getLanguageCode();
$name = isset($params['name']) ? $params['name'] : 'defautlselectorname';
$recurse = isset($params['recurse']) ? $params['recurse'] : true;
$relative = isset($params['relative']) ? $params['relative'] : true;
$includeRoot = isset($params['includeRoot']) ? $params['includeRoot'] : false;
$includeLeaf = isset($params['includeLeaf']) ? $params['includeLeaf'] : true;
$all = isset($params['all']) ? $params['all'] : false;
$displayPath = isset($params['displayPath']) ? $params['displayPath'] : false;
$attributes = isset($params['attributes']) ? $params['attributes'] : null;
$assign = isset($params['assign']) ? $params['assign'] : null;
$editLink = isset($params['editLink']) ? $params['editLink'] : true;
$submit = isset($params['submit']) ? $params['submit'] : false;
$multipleSize = isset($params['multipleSize']) ? $params['multipleSize'] : 1;
$doReplaceRootCat = false;
$userCats = ModUtil::apiFunc('ZikulaCategoriesModule', 'user', 'getusercategories', array('returnCategory' => 1, 'relative' => $relative));
$html = CategoryUtil::getSelector_Categories($userCats, $field, $selectedValue, $name, $defaultValue, $defaultText, $submit, $displayPath, $doReplaceRootCat, $multipleSize);
if ($editLink && $allowUserEdit && UserUtil::isLoggedIn() && SecurityUtil::checkPermission('ZikulaCategoriesModule::', "{$category['id']}::", ACCESS_EDIT)) {
$url = ModUtil::url('ZikulaCategoriesModule', 'user', 'edituser');
$html .= " <a href=\"{$url}\">" . __('Edit sub-categories') . '</a>';
}
if ($assign) {
$view->assign($assign, $html);
} else {
return $html;
}
}
示例8: smarty_function_notifydisplayhooks
/**
* Zikula_View function notify display hooks.
*
* This function notify display hooks.
*
* Available parameters:
* - 'eventname' The name of the hook event [required].
* - 'id' The ID if the subject.
* - 'urlobject' Zikula_ModUrl instance or null.
* - 'assign' If set, the results array is assigned to the named variable instead display [optional].
* - all remaining parameters are passed to the hook via the args param in the event.
*
* Example:
* {notifydisplayhooks eventname='news.ui_hooks.item.display_view' id=$id urlobject=$urlObject}
* {notifydisplayhooks eventname='news.ui_hooks.item.display_view' id=$id urlobject=$urlObject assign='displayhooks'}
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @see smarty_function_notifydisplayhooks()
*
* @return void The results must be assigned to variable in assigned.
*/
function smarty_function_notifydisplayhooks($params, Zikula_View $view)
{
if (!isset($params['eventname'])) {
return trigger_error(__f('Error! "%1$s" must be set in %2$s', array('eventname', 'notifydisplayhooks')));
}
$eventname = $params['eventname'];
$id = isset($params['id']) ? $params['id'] : null;
$urlObject = isset($params['urlobject']) ? $params['urlobject'] : null;
if ($urlObject && !$urlObject instanceof Zikula_ModUrl) {
return trigger_error(__f('Error! "%1$s" must be an instance of %2$s', array('urlobject', 'Zikula_ModUrl')));
}
$assign = isset($params['assign']) ? $params['assign'] : false;
// create event and notify
$hook = new Zikula_DisplayHook($eventname, $id, $urlObject);
$view->getServiceManager()->getService('zikula.hookmanager')->notify($hook);
$responses = $hook->getResponses();
// assign results, this plugin does not return any display
if ($assign) {
$view->assign($assign, $responses);
return;
}
$output = '';
foreach ($responses as $result) {
$output .= "$result\n";
}
return $output;
}
示例9: smarty_function_previewimage
/**
* Zikula_View function to display a preview image from a theme
*
* Available parameters:
* - name name of the theme to display the preview image for
* - name if set, the id assigned to the image
* - size if set, the size of the image to use from small, medium, large (optional: default 'medium')
* - assign if set, the title will be assigned to this variable
*
* Example
* {previewimage name=andreas08 size=large}
*
* @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_previewimage()
*
* @return string The markup to display the theme image.
*/
function smarty_function_previewimage($params, Zikula_View $view)
{
if (!isset($params['name'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('previewimage', 'name')));
return false;
}
if (!isset($params['size']) || !in_array($params['size'], array('large', 'medium', 'small'))) {
$params['size'] = 'medium';
}
$idstring = '';
if (isset($params['id'])) {
$idstring = " id=\"{$params['id']}\"";
}
$themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName($params['name']));
$theme = ThemeUtil::getTheme($themeinfo['name']);
$themePath = null === $theme ? "themes/{$themeinfo['directory']}/images" : $theme->getRelativePath() . '/Resources/public/images';
if (file_exists("{$themePath}/preview_{$params['size']}.png")) {
$filesrc = "{$themePath}/preview_{$params['size']}.png";
} else {
$filesrc = "system/ThemeModule/Resources/public/images/preview_{$params['size']}.png";
}
$markup = "<img{$idstring} src=\"{$filesrc}\" alt=\"\" />";
if (isset($params['assign'])) {
$view->assign($params['assign'], $markup);
} else {
return $markup;
}
}
示例10: smarty_function_getImage
/**
* Smarty function to return first image src from given HTML content.
*
* Examples
* {getImage htmlcontent=$item.body}
* {getImage htmlcontent=$item.body putbaseurl=true}
* {getImage htmlcontent=$item.body putbaseurl=true assign='imagesrc'}
*
* @return string
*/
function smarty_function_getImage($params, Zikula_View $view)
{
$result = $params['htmlcontent'];
if (isset($params['htmlcontent']) && $params['htmlcontent']) {
if (strpos($params['htmlcontent'], '<img ') === false) {
// image is not found in content
} else {
// get image src
$posstart = strpos($params['htmlcontent'], ' src="', $posstart) + 6;
$posend = strpos($params['htmlcontent'], '"', $posstart);
$result = substr($params['htmlcontent'], $posstart, $posend - $posstart);
if (isset($params['putbaseurl']) && $params['putbaseurl']) {
// put base url, if not
if (substr($result, 0, 7) != 'http://' || substr($result, 0, 8) != 'https://') {
$result = System::getBaseUrl() . ltrim($result, DIRECTORY_SEPARATOR);
}
}
}
}
if (isset($params['assign'])) {
$view->assign($params['assign'], $result);
} else {
return $result;
}
}
示例11: 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;
}
}
示例12: 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;
}
}
示例13: 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;
}
}
示例14: smarty_function_callfunc
/**
* Zikula_View function to to execute a PHP callable.
*
* This plugin can call any PHP callable using x_class + x_method OR x_function
* with a list of argument/value pairs.
*
*
* Available parameters:
* - x_class: The well-known name of a module to execute a function from (required)
* - x_method: The type of function to execute; currently one of 'user' or 'admin' (default is 'user')
* - x_function: The name of the module function to execute (default is 'main')
* - x_assign: If set, the results are assigned to the corresponding variable instead of printed out
* - all remaining parameters are passed to the callable.
*
* Based on call_user_func_array()
*
* Example
* {callfunc x_class='Foo' x_method='Bar' name='Jane'}
* {callfunc x_method='Something' age=21 name='Jane'}
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return mixed The results of the callable.
*/
function smarty_function_callfunc($params, Zikula_View $view)
{
$assign = (isset($params['x_assign']) && !empty($params['x_assign'])) ? $params['x_assign'] : '';
if (array_key_exists('x_class', $params)) {
$class = $params['x_class'];
$method = $params['x_method'];
} else if (array_key_exists('x_function', $params)) {
$function = $params['x_function'];
} else {
$view->trigger_error(__f('Error! in %1$s: the "class" and "method" parameter must be specified together or just "function" by itself.', array('calluserfunc', 'modname')));
}
$callable = (isset($class)) ? array($class, $method) : $function;
unset($params['x_class']);
unset($params['x_method']);
unset($params['x_function']);
unset($params['x_assign']);
$result = call_user_func_array($callable, $params);
if ($assign) {
$view->assign($assign, $result);
} else {
return $result;
}
}
示例15: 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;
}
}