本文整理汇总了PHP中Zikula_View::getTopLevelModule方法的典型用法代码示例。如果您正苦于以下问题:PHP Zikula_View::getTopLevelModule方法的具体用法?PHP Zikula_View::getTopLevelModule怎么用?PHP Zikula_View::getTopLevelModule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zikula_View
的用法示例。
在下文中一共展示了Zikula_View::getTopLevelModule方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_sortlink
/**
* Zikula_View function to the module lists header links
*
* This function returns the sort link for one of the columns of a list.
*
*
* Available parameters:
* - linktext: Text of the link
* - currentsort: Current column being sorted on the list
* - sort: Column to sort with this link
* - sortdir: Sort direction of the link (default: ASC)
* - assign: If set, the results are assigned to the corresponding
* variable instead of printed out
* - modname: Module name for the link
* - type: Function type for the link (default: user)
* - func: Function name for the link (default: main)
* - route: the routename
*
* Additional parameters will be passed to ModUtil::url directly.
*
* Example
* {sortlink __linktext='Column name' sort='colname' currentsort=$sort sortdir=$sortdir modname='ModName' type='admin' func='view'}
*
* @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 link output.
*/
function smarty_function_sortlink($params, Zikula_View $view)
{
if (!isset($params['currentsort'])) {
trigger_error(__f('Error! "%1$s" must be set in %2$s', array('currentsort', 'sortlink')));
}
if (!isset($params['sort'])) {
trigger_error(__f('Error! "%1$s" must be set in %2$s', array('sort', 'sortlink')));
}
$modname = isset($params['modname']) ? $params['modname'] : $view->getTopLevelModule();
$type = isset($params['type']) ? $params['type'] : 'user';
$func = isset($params['func']) ? $params['func'] : 'index';
$route = isset($params['route']) ? $params['route'] : null;
$text = isset($params['linktext']) ? $params['linktext'] : ' ';
$sortdir = isset($params['sortdir']) ? strtoupper($params['sortdir']) : 'ASC';
$assign = isset($params['assign']) ? $params['assign'] : null;
// defines the CSS class and revert the order for current field
if ($params['currentsort'] == $params['sort']) {
$cssclass = 'z-order-' . strtolower($sortdir);
// reverse the direction
$params['sortdir'] = $sortdir == 'ASC' ? 'DESC' : 'ASC';
} else {
$cssclass = 'z-order-unsorted';
// defaults the direction to ASC
$params['sortdir'] = 'ASC';
}
// unset non link parameters
$unsets = array('linktext', 'currentsort', 'assign', 'modname', 'type', 'func', 'route');
foreach ($unsets as $unset) {
unset($params[$unset]);
}
// build the link output
if (!empty($route)) {
$link = $view->getContainer()->get('router')->generate($route, $params);
} else {
$link = ModUtil::url($modname, $type, $func, $params);
}
$output = '<a class="' . DataUtil::formatForDisplay($cssclass) . '" href="' . DataUtil::formatForDisplay($link) . '">' . DataUtil::formatForDisplay($text) . '</a>';
if ($assign) {
$view->assign($assign, $output);
} else {
return $output;
}
}