本文整理汇总了PHP中Zikula_View::getContainer方法的典型用法代码示例。如果您正苦于以下问题:PHP Zikula_View::getContainer方法的具体用法?PHP Zikula_View::getContainer怎么用?PHP Zikula_View::getContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zikula_View
的用法示例。
在下文中一共展示了Zikula_View::getContainer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_adminfooter
/**
* Smarty function to close the admin container.
*
* Admin
* {adminfooter}
*
* @see function.adminfooter.php::smarty_function_adminfooter()
* @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_adminfooter($params, \Zikula_View $view)
{
// check to make sure adminmodule is available and route is available
$router = $view->getContainer()->get('router');
try {
$router->generate('zikulaadminmodule_admin_adminfooter');
} catch (\Symfony\Component\Routing\Exception\RouteNotFoundException $e) {
return '';
}
$path = array('_controller' => 'ZikulaAdminModule:Admin:adminfooter');
$subRequest = $view->getRequest()->duplicate(array(), null, $path);
return $view->getContainer()->get('http_kernel')->handle($subRequest, \Symfony\Component\HttpKernel\HttpKernelInterface::SUB_REQUEST)->getContent();
}
示例2: smarty_function_adminfooter
/**
* Smarty function to close the admin container.
*
* Admin
* {adminfooter}
*
* @see function.adminfooter.php::smarty_function_adminfooter()
* @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_adminfooter($params, \Zikula_View $view)
{
// check to make sure adminmodule is available and route is available
$router = $view->getContainer()->get('router');
$routeCollection = $router instanceof \JMS\I18nRoutingBundle\Router\I18nRouter ? $router->getOriginalRouteCollection() : $router->getRouteCollection();
$route = $routeCollection->get('zikulaadminmodule_admin_adminfooter');
if (isset($route)) {
$path = array('_controller' => 'ZikulaAdminModule:Admin:adminfooter');
$subRequest = $view->getRequest()->duplicate(array(), null, $path);
return $view->getContainer()->get('http_kernel')->handle($subRequest, \Symfony\Component\HttpKernel\HttpKernelInterface::SUB_REQUEST)->getContent();
}
return '';
}
示例3: smarty_function_adminheader
/**
* Smarty function to open the admin container.
*
* Admin
* {adminheader}
*
* @see function.adminheader.php::smarty_function_adminheader()
* @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_adminheader($params, $view)
{
// check to make sure adminmodule is available and route is available
$router = $view->getContainer()->get('router');
try {
$router->generate('zikulaadminmodule_admin_adminheader');
} catch (\Symfony\Component\Routing\Exception\RouteNotFoundException $e) {
$url = $view->getContainer()->get('router')->generate('zikularoutesmodule_route_reload', array('lct' => 'admin', 'confirm' => 1));
return '<div class="alert alert-danger"><i class="fa fa-exclamation-triangle fa-2x"></i> ' . __f('Routes must be reloaded. Click %s to reload all routes.', "<a href='{$url}'>" . __('here') . '</a>') . '</div>';
}
$path = array('_controller' => 'ZikulaAdminModule:Admin:adminheader');
$subRequest = $view->getRequest()->duplicate(array(), null, $path);
return $view->getContainer()->get('http_kernel')->handle($subRequest, \Symfony\Component\HttpKernel\HttpKernelInterface::SUB_REQUEST)->getContent();
}
示例4: 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 string|void if the results are 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\Core\UrlInterface) {
return trigger_error(__f('Error! "%1$s" must be an instance of %2$s', array('urlobject', '\\Zikula\\Core\\UrlInterface')));
}
$assign = isset($params['assign']) ? $params['assign'] : false;
// create event and notify
$hook = new Zikula_DisplayHook($eventname, $id, $urlObject);
// @todo Zikula_DisplayHook maintains BC. IN 1.5.0 change to \Zikula\Core\Hook\DisplayHook($id, $urlObject);
$view->getContainer()->get('hook_dispatcher')->dispatch($eventname, $hook);
$responses = $hook->getResponses();
// assign results, this plugin does not return any display
if ($assign) {
$view->assign($assign, $responses);
return null;
}
$output = '';
foreach ($responses as $result) {
$output .= "<div class=\"z-displayhook\">{$result}</div>\n";
}
return $output;
}
示例5: smarty_function_pagerendertime
/**
* Zikula_View function to get the site's page render time
*
* Available parameters:
* - assign if set, the message will be assigned to this variable
* - round if the, the time will be rounded to this number of decimal places
* (optional: default 2)
*
* Example
* {pagerendertime} outputs 'Page created in 0.18122792243958 seconds.'
*
* {pagerendertime round=2} outputs 'Page created in 0.18 seconds.'
*
* @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 page render time in seconds.
*/
function smarty_function_pagerendertime($params, Zikula_View $view)
{
// show time to render
if ($view->getContainer()->getParameter('debug.display_pagerendertime')) {
// calcultate time to render
$dbg_totaltime = $view->getContainer()->get('zikula')->getUptime();
$round = isset($params['round']) ? $params['round'] : 7;
$dbg_totaltime = round($dbg_totaltime, $round);
if (isset($params['assign'])) {
$view->assign('rendertime', $dbg_totaltime);
} else {
// load language files
$message = '<div class="z-pagerendertime" style="text-align:center;">' . __f('Page generated in %s seconds.', $dbg_totaltime) . '</div>';
return $message;
}
}
}
示例6: smarty_function_admincategorymenu
/**
* Smarty function to display the category menu for admin links. This also adds the
* navtabs.css to the page vars array for stylesheets.
*
* Admin
* {admincategorymenu}
*
* @see function.admincategorymenu.php::smarty_function_admincategorymenu()
* @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_admincategorymenu($params, \Zikula_View $view)
{
PageUtil::addVar('stylesheet', ThemeUtil::getModuleStylesheet('ZikulaAdminModule'));
$modinfo = ModUtil::getInfoFromName($view->getTplVar('toplevelmodule'));
$acid = ModUtil::apiFunc('ZikulaAdminModule', 'admin', 'getmodcategory', array('mid' => $modinfo['id']));
$path = array('_controller' => 'ZikulaAdminModule:Admin:categorymenu', 'acid' => $acid);
$subRequest = $view->getRequest()->duplicate(array(), null, $path);
return $view->getContainer()->get('http_kernel')->handle($subRequest, \Symfony\Component\HttpKernel\HttpKernelInterface::SUB_REQUEST)->getContent();
}
示例7: smarty_function_thumb
/**
* Available params:
* - image (string) Path to source image (required)
* - width (int) Thumbnail width in pixels or 'auto' (optional, default value based on 'default' preset)
* - height (int) Thumbnail width in pixels or 'auto' (optional, default value based on 'default' preset)
* - mode (string) Thumbnail mode; 'inset' or 'outbound' (optional, default 'inset')
* In outbound mode auto width or height gives the same effect as inset
* - extension (string) File extension for thumbnails: jpg, png, gif; null for original file type
* (optional, default value based on 'default' preset)
* - options (array) Options array given to the thumbnail Imagine method call.
* - options[jpeg_quality]
* (int) Thumbnail jpeg quality in % [0-100], where 100% is best quality (optional, default value based on 'default' preset)
* - options[png_compression_level]
* (int) Thumbnail png compression level [0-9], where 0 is no compression (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'}
* {thumb image='path/to/image.png' width='150' height='auto' mode='inset' extension='png'}
* {thumb image='path/to/image.jpg' width='150' 'jpeg_quality'=50}
*
* 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->getContainer()->get('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'] : 'auto';
$preset['height'] = isset($params['height']) ? $params['height'] : 'auto';
$preset['mode'] = isset($params['mode']) ? $params['mode'] : null;
$preset['extension'] = isset($params['extension']) ? $params['extension'] : null;
$preset['options'] = isset($params['options']) ? $params['options'] : array();
$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} />";
}
//.........这里部分代码省略.........
示例8: smarty_function_setmetatag
/**
* Set key in $metatags array.
*
* Available attributes:
* - name (string) The name of the configuration variable to obtain
* - value (string) Value.
*
* Examples:
*
* <samp><p>Welcome to {setmetatag name='description' value='Description goes here}!</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 void
*/
function smarty_function_setmetatag($params, Zikula_View $view)
{
$name = isset($params['name']) ? $params['name'] : null;
$value = isset($params['value']) ? $params['value'] : null;
if (!$name) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('setmetatag', 'name')));
return false;
}
$sm = $view->getContainer();
$sm['zikula_view.metatags'][$name] = DataUtil::formatForDisplay($value);
}
示例9: 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;
}
}
示例10: smarty_function_route
/**
* Zikula_View function to create a compatible route for a specific module function.
*
* NOTE: This function only works for modules using the Core 1.4.0+ routing specification
*
* This function returns a module route string if successful. This is already sanitized to display,
* so it should not be passed to the safetext modifier.
*
* Available parameters:
* - name: the route name e.g. `acmewidgetmakermodule_user_construct`
* - absolute: whether to generate an absolute URL
* - assign: If set, the results are assigned to the corresponding variable instead of printed out
* - all remaining parameters are passed to the generator as route parameters
*
* Example
* Create a route to the News 'view' function with parameters 'sid' set to 3
* <a href="{route name='zikulanewsmodule_user_display' sid='3'}">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 route or empty.
*/
function smarty_function_route($params, Zikula_View $view)
{
$assign = isset($params['assign']) ? $params['assign'] : null;
unset($params['assign']);
$name = isset($params['name']) ? $params['name'] : false;
unset($params['name']);
$absolute = isset($params['absolute']) ? $params['absolute'] : false;
unset($params['absolute']);
/** @var $router \JMS\I18nRoutingBundle\Router\I18nRouter */
$router = $view->getContainer()->get('router');
try {
$route = $router->generate($name, $params, $absolute);
} catch (Symfony\Component\Routing\Exception\RouteNotFoundException $e) {
$route = '';
// route does not exist
}
if ($assign) {
$view->assign($assign, $route);
} else {
return DataUtil::formatForDisplay($route);
}
}
示例11: smarty_function_route
/**
* Zikula_View function to create a compatible route for a specific module function.
*
* NOTE: This function only works for modules using the Core 1.4.0+ routing specification
*
* This function returns a module route string if successful. This is already sanitized to display,
* so it should not be passed to the safetext modifier.
*
* Available parameters:
* - name: the route name e.g. `acmewidgetmakermodule_user_construct`
* - absolute: whether to generate an absolute URL
* - assign: If set, the results are assigned to the corresponding variable instead of printed out
* - all remaining parameters are passed to the generator as route parameters
*
* Example
* Create a route to the News 'view' function with parameters 'sid' set to 3
* <a href="{route name='zikulanewsmodule_user_display' sid='3'}">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 route or empty.
*/
function smarty_function_route($params, Zikula_View $view)
{
$assign = isset($params['assign']) ? $params['assign'] : null;
unset($params['assign']);
$name = isset($params['name']) ? $params['name'] : false;
unset($params['name']);
$absolute = isset($params['absolute']) ? $params['absolute'] : false;
unset($params['absolute']);
/** @var $router \JMS\I18nRoutingBundle\Router\I18nRouter */
$router = $view->getContainer()->get('router');
$originalRouteCollection = $router->getOriginalRouteCollection()->all();
if (array_key_exists($name, $originalRouteCollection)) {
$route = $router->generate($name, $params, $absolute);
} else {
$route = '';
// route does not exist
}
if ($assign) {
$view->assign($assign, $route);
} else {
return DataUtil::formatForDisplay($route);
}
}
示例12: smarty_insert_getstatusmsg
/**
* Zikula_View insert function to dynamically get current status/error message
*
* This function obtains the last status message posted for this session.
* The status message exists in one of two session variables: '_ZStatusMsg' for a
* status message, or '_ZErrorMsg' for an error message. If both a status and an
* error message exists then the error message is returned.
*
* This is is a destructive function - it deletes the two session variables
* '_ZStatusMsg' and 'erorrmsg' during its operation.
*
* Available parameters:
* - assign: If set, the status message is assigned to the corresponding variable instead of printed out
* - style, class: If set, the status message is being put in a div tag with the respective attributes
* - tag: You can specify if you would like a span or a div tag
*
* Example
* {insert name='getstatusmsg'}
* {insert name="getstatusmsg" style="color:red;"}
* {insert name="getstatusmsg" class="statusmessage" tag="span"}
*
* @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_insert_getstatusmsg($params, $view)
{
// NOTE: assign parameter is handled by the smarty_core_run_insert_handler(...) function in lib/vendor/Smarty/internals/core.run_insert_handler.php
$class = isset($params['class']) ? $params['class'] : null;
$style = isset($params['style']) ? $params['style'] : null;
$tag = isset($params['tag']) ? $params['tag'] : null;
//prepare output var
$output = '';
// $msgStatus = LogUtil::getStatusMessages();
// we do not use LogUtil::getStatusMessages() because we need to know if we have to
// show a status or an error
$session = $view->getContainer()->get('session');
$msgStatus = $session->getFlashBag()->get(Zikula_Session::MESSAGE_STATUS);
$msgtype = $class ? $class : 'z-statusmsg';
$msgError = $session->getFlashBag()->get(Zikula_Session::MESSAGE_ERROR);
// Error message overrides status message
if (!empty($msgError)) {
$msgStatus = $msgError;
$msgtype = $class ? $class : 'z-errormsg';
}
if (empty($msgStatus) || count($msgStatus) == 0) {
return $output;
}
// some parameters have been set, so we build the complete tag
if (!$tag || $tag != 'span') {
$tag = 'div';
}
// need to build a proper error message from message array
$output = '<' . $tag . ' class="' . $msgtype . '"';
if ($style) {
$output .= ' style="' . $style . '"';
}
$output .= '>';
$output .= implode('<hr />', $msgStatus);
$output .= '</' . $tag . '>';
return $output;
}
示例13: smarty_function_pager
//.........这里部分代码省略.........
if (is_array($vvv)) {
foreach ($vvv as $kkkk => $vvvv) {
if (strlen($vvvv)) {
$tkey = $k . '[' . $kk . '][' . $kkk . '][' . $kkkk . ']';
$pager['args'][$tkey] = $vvvv;
}
}
} elseif (strlen($vvv)) {
$tkey = $k . '[' . $kk . '][' . $kkk . ']';
$pager['args'][$tkey] = $vvv;
}
}
} elseif (strlen($vv)) {
$tkey = $k . '[' . $kk . ']';
$pager['args'][$tkey] = $vv;
}
}
} else {
if (strlen($v)) {
$pager['args'][$k] = $v;
}
}
}
}
}
unset($params['modname']);
unset($params['type']);
unset($params['func']);
unset($params['route']);
$pagerUrl = function ($pager) use($view) {
if (!$pager['route']) {
return ModUtil::url($pager['module'], $pager['type'], $pager['func'], $pager['args']);
}
return $view->getContainer()->get('router')->generate($pager['route'], $pager['args']);
};
// build links to items / pages
// entries are marked as current or displayed / hidden
$pager['pages'] = array();
if ($pager['maxPages'] > 0) {
$pageInterval = floor($pager['maxPages'] / 2);
$leftMargin = $pager['currentPage'] - $pageInterval;
$rightMargin = $pager['currentPage'] + $pageInterval;
if ($leftMargin < 1) {
$rightMargin += abs($leftMargin) + 1;
$leftMargin = 1;
}
if ($rightMargin > $pager['countPages']) {
$leftMargin -= $rightMargin - $pager['countPages'];
$rightMargin = $pager['countPages'];
}
}
$params['processUrls'] = isset($params['processUrls']) ? (bool) $params['processUrls'] : true;
$params['processDetailLinks'] = isset($params['processDetailLinks']) ? (bool) $params['processDetailLinks'] : $template != 'pagerimage.tpl';
if ($params['processDetailLinks']) {
for ($currItem = 1; $currItem <= $pager['countPages']; $currItem++) {
$currItemVisible = true;
if ($pager['maxPages'] > 0 && ($currItem < $leftMargin || $currItem > $rightMargin)) {
if ($pager['optimize']) {
continue;
} else {
$currItemVisible = false;
}
}
if ($params['display'] == 'page') {
$pager['args'][$pager['posvar']] = $currItem;
} else {
示例14: smarty_function_modulelinks
/**
* Zikula_View function to display menulinks in an unordered list
*
* Example
* {modulelinks data=$links id='listid' class='navbar navbar-default' itemclass='z-ml-item' first='z-ml-first' last='z-ml-last'}
*
* Available parameters:
* links Array with menulinks (text, url, title, id, class, disabled) (optional)
* modname Module name to display links for (optional)
* type Function type where the getLinks-function is located (optional)
* menuid ID for the unordered list (optional)
* menuclass Class for the unordered list (optional)
* itemclass Array with menulinks (text, url, title, class, disabled) (optional)
* first Class for the first element (optional)
* last Class for the last element (optional)
* seperator Link seperator (optional)
* class CSS class (optional).
* returnAsArray return results as array, not as formatted html - MUST set assign
*
* @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_modulelinks($params, Zikula_View $view)
{
$menuLinks = isset($params['links']) ? $params['links'] : '';
$menuId = isset($params['menuid']) ? $params['menuid'] : '';
$menuClass = isset($params['menuclass']) ? $params['menuclass'] : 'navbar navbar-default navbar-modulelinks navbar-modulelinks-main';
$menuItemClass = isset($params['itemclass']) ? $params['itemclass'] : '';
$menuItemFirst = isset($params['first']) ? $params['first'] : '';
$menuItemLast = isset($params['last']) ? $params['last'] : '';
$returnAsArray = isset($params['returnAsArray']) ? (bool) $params['returnAsArray'] : false;
if (empty($menuLinks)) {
if (!isset($params['modname']) || !ModUtil::available($params['modname'])) {
$params['modname'] = ModUtil::getName();
}
// check our module name
if (!ModUtil::available($params['modname'])) {
$view->trigger_error('modulelinks: ' . __f("Error! The '%s' module is not available.", DataUtil::formatForDisplay($params['modname'])));
return false;
}
$params['type'] = isset($params['type']) ? $params['type'] : 'admin';
// get the menu links
// try the Core-2.0 way first, then try the legacy way.
$menuLinks = $view->getContainer()->get('zikula.link_container_collector')->getLinks($params['modname'], $params['type']);
if (empty($menuLinks)) {
$menuLinks = ModUtil::apiFunc($params['modname'], $params['type'], 'getLinks', $params);
}
}
// return if there are no links to print or template has requested to returnAsArray
if (!$menuLinks || $returnAsArray && isset($params['assign'])) {
if (isset($params['assign'])) {
$view->assign($params['assign'], $menuLinks);
}
return '';
}
$html = '';
if (!empty($menuLinks)) {
$html = '<ul';
$html .= !empty($menuId) ? ' id="' . $menuId . '"' : '';
$html .= !empty($menuClass) ? ' class="' . $menuClass . '"' : '';
$html .= '>';
$i = 1;
$size = count($menuLinks);
foreach ($menuLinks as $menuitem) {
$class = array();
$class[] = $size == 1 ? 'z-ml-single' : '';
$class[] = $i == 1 && $size > 1 ? $menuItemFirst : '';
$class[] = $i == $size && $size > 1 ? $menuItemLast : '';
$class[] = !empty($menuItemClass) ? $menuItemClass : '';
$class[] = isset($menuitem['disabled']) && $menuitem['disabled'] == true ? 'z-ml-disabled' : '';
$class = trim(implode(' ', $class));
$i++;
if (System::isLegacyMode() && !empty($class) && isset($menuitem['class'])) {
if ($menuitem['class'] == 'z-icon-es-add') {
$menuitem['class'] = null;
$menuitem['icon'] = 'plus';
} elseif ($menuitem['class'] == 'z-icon-es-back') {
$menuitem['class'] = null;
$menuitem['icon'] = 'arrow-left';
} elseif ($menuitem['class'] == 'z-icon-es-cancel') {
$menuitem['class'] = null;
$menuitem['icon'] = 'times';
} elseif ($menuitem['class'] == 'z-icon-es-config') {
$menuitem['class'] = null;
$menuitem['icon'] = 'wrench';
} elseif ($menuitem['class'] == 'z-icon-es-copy') {
$menuitem['class'] = null;
$menuitem['icon'] = 'files-o';
} elseif ($menuitem['class'] == 'z-icon-es-cubes') {
$menuitem['class'] = null;
$menuitem['icon'] = 'th';
} elseif ($menuitem['class'] == 'z-icon-es-cut') {
$menuitem['class'] = null;
$menuitem['icon'] = 'scissors';
} elseif ($menuitem['class'] == 'z-icon-es-delete') {
$menuitem['class'] = null;
$menuitem['icon'] = 'trash-o';
} elseif ($menuitem['class'] == 'z-icon-es-display') {
//.........这里部分代码省略.........
示例15: smarty_insert_csrftoken
/**
* Insert a CSRF protection nonce.
*
* Available parameters:
* - assign: Assign rather the output.
*
* Example:
* <input type="hidden" name="csrftoken" value="{insert name='csrftoken'}" />
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return string
*/
function smarty_insert_csrftoken($params, $view)
{
// NOTE: assign parameter is handled by the smarty_core_run_insert_handler(...) function in lib/vendor/Smarty/internals/core.run_insert_handler.php
return SecurityUtil::generateCsrfToken($view->getContainer());
}