当前位置: 首页>>代码示例>>PHP>>正文


PHP PKPApplication::getDispatcher方法代码示例

本文整理汇总了PHP中PKPApplication::getDispatcher方法的典型用法代码示例。如果您正苦于以下问题:PHP PKPApplication::getDispatcher方法的具体用法?PHP PKPApplication::getDispatcher怎么用?PHP PKPApplication::getDispatcher使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PKPApplication的用法示例。


在下文中一共展示了PKPApplication::getDispatcher方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: smartyUrl

 /**
  * Generate a URL into a PKPApp. (This is a wrapper around Dispatcher::url() to make it available to Smarty templates.)
  * {url} 標籤
  */
 function smartyUrl($params, &$smarty)
 {
     if (!isset($params['context'])) {
         // Extract the variables named in $paramList, and remove them
         // from the params array. Variables remaining in params will be
         // passed along to Request::url as extra parameters.
         $context = array();
         $contextList = Application::getContextList();
         foreach ($contextList as $contextName) {
             if (isset($params[$contextName])) {
                 $context[$contextName] = $params[$contextName];
                 unset($params[$contextName]);
             } else {
                 $context[$contextName] = null;
             }
         }
         $params['context'] = $context;
     }
     // Extract the variables named in $paramList, and remove them
     // from the params array. Variables remaining in params will be
     // passed along to Request::url as extra parameters.
     $paramList = array('router', 'context', 'page', 'component', 'op', 'path', 'anchor', 'escape', 'source');
     foreach ($paramList as $param) {
         if (isset($params[$param])) {
             ${$param} = $params[$param];
             unset($params[$param]);
         } else {
             ${$param} = null;
         }
     }
     if (isset($source)) {
         $params['source'] = Request::getRequestUri();
     }
     // Set the default router
     $request =& PKPApplication::getRequest();
     if (is_null($router)) {
         if (is_a($request->getRouter(), 'PKPComponentRouter')) {
             $router = ROUTE_COMPONENT;
         } else {
             $router = ROUTE_PAGE;
         }
     }
     // Check the router
     $dispatcher =& PKPApplication::getDispatcher();
     $routerShortcuts = array_keys($dispatcher->getRouterNames());
     assert(in_array($router, $routerShortcuts));
     // Identify the handler
     switch ($router) {
         case ROUTE_PAGE:
             $handler = $page;
             break;
         case ROUTE_COMPONENT:
             $handler = $component;
             break;
         default:
             // Unknown router type
             assert(false);
     }
     // Let the dispatcher create the url
     return $dispatcher->url($request, $router, $context, $handler, $op, $path, $params, $anchor, !isset($escape) || $escape);
 }
开发者ID:pulipulichen,项目名称:ocs,代码行数:65,代码来源:PKPTemplateManager.inc.php

示例2: smartyUrl

 /**
  * Generate a URL into a PKPApp.
  * @param $params array
  * @param $smarty object
  * Available parameters:
  * - router: which router to use
  * - context
  * - page
  * - component
  * - op
  * - path (array)
  * - anchor
  * - escape (default to true unless otherwise specified)
  * - params: parameters to include in the URL if available as an array
  */
 function smartyUrl($parameters, &$smarty)
 {
     if (!isset($parameters['context'])) {
         // Extract the variables named in $paramList, and remove them
         // from the parameters array. Variables remaining in params will be
         // passed along to Request::url as extra parameters.
         $context = array();
         $contextList = Application::getContextList();
         foreach ($contextList as $contextName) {
             if (isset($parameters[$contextName])) {
                 $context[$contextName] = $parameters[$contextName];
                 unset($parameters[$contextName]);
             } else {
                 $context[$contextName] = null;
             }
         }
         $parameters['context'] = $context;
     }
     // Extract the reserved variables named in $paramList, and remove them
     // from the parameters array. Variables remaining in parameters will be passed
     // along to Request::url as extra parameters.
     $paramList = array('params', 'router', 'context', 'page', 'component', 'op', 'path', 'anchor', 'escape');
     foreach ($paramList as $parameter) {
         if (isset($parameters[$parameter])) {
             ${$parameter} = $parameters[$parameter];
             unset($parameters[$parameter]);
         } else {
             ${$parameter} = null;
         }
     }
     // Merge parameters specified in the {url paramName=paramValue} format with
     // those optionally supplied in {url params=$someAssociativeArray} format
     $parameters = array_merge($parameters, (array) $params);
     // Set the default router
     $request =& PKPApplication::getRequest();
     if (is_null($router)) {
         if (is_a($request->getRouter(), 'PKPComponentRouter')) {
             $router = ROUTE_COMPONENT;
         } else {
             $router = ROUTE_PAGE;
         }
     }
     // Check the router
     $dispatcher =& PKPApplication::getDispatcher();
     $routerShortcuts = array_keys($dispatcher->getRouterNames());
     assert(in_array($router, $routerShortcuts));
     // Identify the handler
     switch ($router) {
         case ROUTE_PAGE:
             $handler = $page;
             break;
         case ROUTE_COMPONENT:
             $handler = $component;
             break;
         default:
             // Unknown router type
             assert(false);
     }
     // Let the dispatcher create the url
     return $dispatcher->url($request, $router, $context, $handler, $op, $path, $parameters, $anchor, !isset($escape) || $escape);
 }
开发者ID:ramonsodoma,项目名称:pkp-lib,代码行数:76,代码来源:PKPTemplateManager.inc.php

示例3: initialize

 /**
  * @copydoc GridRow::initialize()
  */
 function initialize($request, $template = null)
 {
     parent::initialize($request, $template);
     // Is this a new row or an existing row?
     $plugin =& $this->getData();
     /* @var $plugin Plugin */
     assert(is_a($plugin, 'Plugin'));
     $rowId = $this->getId();
     // Only add row actions if this is an existing row
     if (!is_null($rowId)) {
         $router = $request->getRouter();
         /* @var $router PKPRouter */
         $actionArgs = array_merge(array('plugin' => $plugin->getName()), $this->getRequestArgs());
         if ($this->_canEdit($plugin)) {
             $managementVerbs = $plugin->getManagementVerbs();
             // If plugin has not management verbs, we receive
             // null. Check for it before foreach.
             if (!is_null($managementVerbs)) {
                 foreach ($managementVerbs as $verb) {
                     list($verbName, $verbLocaleKey) = $verb;
                     $linkAction = null;
                     $actionRequest = null;
                     $image = null;
                     switch ($verbName) {
                         case 'enable':
                         case 'disable':
                             // Do nothing. User interact with those verbs via enabled grid column.
                             break;
                         default:
                             // Check if verb has a link action defined.
                             $verbLinkAction = $plugin->getManagementVerbLinkAction($request, $verb);
                             if (is_a($verbLinkAction, 'LinkAction')) {
                                 $linkAction = $verbLinkAction;
                             } else {
                                 // Legacy plugin behavior. Define a default redirect request.
                                 import('lib.pkp.classes.linkAction.request.AjaxAction');
                                 $dispatcher = PKPApplication::getDispatcher();
                                 $context = $request->getContext();
                                 $actionRequest = new AjaxAction($router->url($request, null, null, 'plugin', null, array('category' => $plugin->getCategory(), 'plugin' => $plugin->getName(), 'verb' => $verbName)));
                             }
                             break;
                     }
                     // Build link action for those verbs who don't define one.
                     if (!$linkAction && $actionRequest) {
                         $linkAction = new LinkAction($verbName, $actionRequest, $verbLocaleKey, $image);
                     }
                     if ($linkAction) {
                         // Insert row link action.
                         $this->addAction($linkAction);
                         unset($linkAction);
                         unset($actionRequest);
                     }
                 }
             }
         }
         // Administrative functions.
         if (in_array(ROLE_ID_SITE_ADMIN, $this->_userRoles)) {
             import('lib.pkp.classes.linkAction.request.RemoteActionConfirmationModal');
             $this->addAction(new LinkAction('delete', new RemoteActionConfirmationModal(__('manager.plugins.deleteConfirm'), __('common.delete'), $router->url($request, null, null, 'deletePlugin', null, $actionArgs), 'modal_delete'), __('common.delete'), 'delete'));
             $this->addAction(new LinkAction('upgrade', new AjaxModal($router->url($request, null, null, 'upgradePlugin', null, $actionArgs), __('manager.plugins.upgrade'), 'modal_upgrade'), __('grid.action.upgrade'), 'upgrade'));
         }
     }
 }
开发者ID:relaciones-internacionales-journal,项目名称:pkp-lib,代码行数:66,代码来源:PKPPluginGridRow.inc.php


注:本文中的PKPApplication::getDispatcher方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。