Example #1
0
 /**
  * Overwrite getInstance to use custom front controller
  *
  * @return IfwPsn_Zend_Controller_Front|IfwPsn_Vendor_Zend_Controller_Front|null
  */
 public static function getInstance()
 {
     if (null === self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Example #2
0
 /**
  *
  * @param IfwPsn_Vendor_Zend_Application $application
  */
 public function __construct($application)
 {
     $options = array('IfwPsn_Vendor_Zend_Application_Resource' => IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Application/Resource');
     $this->_pluginLoader = new IfwPsn_Vendor_Zend_Loader_PluginLoader($options);
     parent::__construct($application);
     $this->_pm = $this->getApplication()->getOption('pluginmanager');
     // init the custom front controller instance
     $this->_pm->getLogger()->logPrefixed('Initializing front controller.');
     $front = IfwPsn_Zend_Controller_Front::getInstance();
     IfwPsn_Vendor_Zend_Controller_Front::getInstance()->returnResponse(true);
     // set dispatcher
     require_once $this->_pm->getPathinfo()->getRootLib() . 'IfwPsn/Zend/Controller/Dispatcher/Wp.php';
     $dispatcher = new IfwPsn_Zend_Controller_Dispatcher_Wp($this->_pm);
     IfwPsn_Vendor_Zend_Controller_Front::getInstance()->setDispatcher($dispatcher);
 }
Example #3
0
 /**
  * Matches a user submitted path with a previously defined route.
  * Assigns and returns an array of defaults on a successful match.
  *
  * @param string Path used to match against this routing map
  * @return array|false An array of assigned values or a false on a mismatch
  */
 public function match($path)
 {
     $frontController = IfwPsn_Zend_Controller_Front::getInstance();
     $request = $frontController->getRequest();
     /* @var $request IfwPsn_Vendor_Zend_Controller_Request_Http */
     $baseUrl = $request->getBaseUrl();
     if (strpos($baseUrl, 'index.php') !== false) {
         $url = str_replace('index.php', '', $baseUrl);
         $request->setBaseUrl($url);
     }
     $params = $request->getParams();
     if (array_key_exists('mod', $params) || array_key_exists('controller', $params) || array_key_exists('action', $params) || array_key_exists('page', $params)) {
         $module = $request->getParam('mod', $frontController->getDefaultModule());
         $controller = $request->getParam('controller', $frontController->getDefaultControllerName());
         $action = $request->getParam('action', $frontController->getDefaultAction());
         $result = array('module' => $module, 'controller' => $controller, 'action' => $action);
         $this->_current = $result;
         return $result;
     }
     return false;
 }
Example #4
0
 /**
  * Returns href for this page
  *
  * This method uses {@link IfwPsn_Vendor_Zend_Controller_Action_Helper_Url} to assemble
  * the href based on the page's properties.
  *
  * @return string  page href
  */
 public function getHref()
 {
     if ($this->_hrefCache) {
         return $this->_hrefCache;
     }
     if (null === self::$_urlHelper) {
         self::$_urlHelper = IfwPsn_Vendor_Zend_Controller_Action_HelperBroker::getStaticHelper('Url');
     }
     $params = $this->getParams();
     if ($param = $this->getModule()) {
         $params['module'] = $param;
     }
     if ($param = $this->getController()) {
         $params[IfwPsn_Zend_Controller_Front::getInstance()->getRequest()->getControllerKey()] = $param;
     }
     if ($param = $this->getAction()) {
         $params[IfwPsn_Zend_Controller_Front::getInstance()->getRequest()->getActionKey()] = $param;
     }
     if ($param = $this->getPage()) {
         $params['page'] = $param;
     }
     if ($param = $this->getAdminpage()) {
         $params['adminpage'] = $param;
     }
     if ($param = $this->getEditpage()) {
         $params['editpage'] = $param;
     }
     if ($param = $this->getPosttype()) {
         $params['posttype'] = $param;
     }
     $url = self::$_urlHelper->url($params, $this->getRoute(), $this->getResetParams(), $this->getEncodeUrl());
     // Add the fragment identifier if it is set
     $fragment = $this->getFragment();
     if (null !== $fragment) {
         $url .= '#' . $fragment;
     }
     return $this->_hrefCache = $url;
 }
Example #5
0
 public function load()
 {
     require_once $this->_pm->getPathinfo()->getRootLib() . 'IfwPsn/Vendor/Zend/Navigation/Container.php';
     require_once $this->_pm->getPathinfo()->getRootLib() . 'IfwPsn/Vendor/Zend/Navigation.php';
     require_once $this->_pm->getPathinfo()->getRootLib() . 'IfwPsn/Vendor/Zend/Navigation/Page.php';
     require_once $this->_pm->getPathinfo()->getRootLib() . 'IfwPsn/Zend/Navigation/Page/WpMvc.php';
     $this->_registerLiteNav();
     $this->_navigation = new IfwPsn_Vendor_Zend_Navigation();
     IfwPsn_Zend_Controller_Front::getInstance()->initRouter($this->_pm);
     $page = new IfwPsn_Zend_Navigation_Page_WpMvc(array('label' => __('Overview', 'psn'), 'page' => $this->_pm->getPathinfo()->getDirname(), 'action' => 'index', 'controller' => 'index', 'route' => 'requestVars'));
     $page->set('exactActiveMatch', true);
     $this->_navigation->addPage($page);
     IfwPsn_Wp_Proxy_Action::doPlugin($this->_pm, 'after_admin_navigation_overview', $this->_navigation);
     $page = new IfwPsn_Zend_Navigation_Page_WpMvc(array('label' => __('Rules', 'psn'), 'page' => $this->_pm->getPathinfo()->getDirname(), 'action' => 'index', 'controller' => 'rules', 'route' => 'requestVars'));
     $this->_navigation->addPage($page);
     IfwPsn_Wp_Proxy_Action::doPlugin($this->_pm, 'after_admin_navigation_rules', $this->_navigation);
     $page = new IfwPsn_Zend_Navigation_Page_WpMvc(array('label' => __('Options', 'psn'), 'controller' => 'options', 'action' => 'index', 'page' => $this->_pm->getPathinfo()->getDirname(), 'route' => 'requestVars'));
     $this->_navigation->addPage($page);
     IfwPsn_Wp_Proxy_Action::doPlugin($this->_pm, 'after_admin_navigation_options', $this->_navigation);
     $page = new IfwPsn_Zend_Navigation_Page_WpMvc(array('label' => __('Service', 'psn'), 'controller' => 'service', 'action' => 'index', 'page' => $this->_pm->getPathinfo()->getDirname(), 'route' => 'requestVars'));
     $this->_navigation->addPage($page);
     IfwPsn_Wp_Proxy_Action::doPlugin($this->_pm, 'after_admin_navigation_service', $this->_navigation);
 }
Example #6
0
 /**
  * @param IfwPsn_Wp_Plugin_Manager $pm
  * @param $controller
  * @param string $action
  * @param null $page
  * @param array $extra
  * @return string
  */
 public static function getAdminPageUrl(IfwPsn_Wp_Plugin_Manager $pm, $page, $controller, $action = 'index', $extra = array())
 {
     $urlOptions = array_merge(array($pm->getConfig()->getControllerKey() => $controller, $pm->getConfig()->getActionKey() => $action, 'adminpage' => $page), $extra);
     $router = IfwPsn_Zend_Controller_Front::getInstance()->initRouter($pm)->getRouter();
     return $router->assemble($urlOptions, 'requestVars');
 }
Example #7
0
 /**
  * @return IfwPsn_Vendor_Zend_Controller_Front|null
  */
 public function getFrontController()
 {
     require_once $this->getPathinfo()->getRootLib() . '/IfwPsn/Zend/Controller/Front.php';
     return IfwPsn_Zend_Controller_Front::getInstance();
 }
Example #8
0
 /**
  * Registers the controller path
  */
 public function registerPath()
 {
     if ($this->_pm->getAccess()->isPlugin()) {
         // add controller dir
         if (is_dir($this->_pathinfo->getDirnamePath() . 'controllers')) {
             $front = IfwPsn_Zend_Controller_Front::getInstance();
             if ($front instanceof IfwPsn_Vendor_Zend_Controller_Front) {
                 $front->addControllerDirectory($this->_pathinfo->getDirnamePath() . 'controllers', strtolower($this->_pathinfo->getDirname()));
             }
         }
     }
 }
Example #9
0
 /**
  * @param Exception $e
  */
 protected function _handleException(Exception $e)
 {
     $this->_pm->getLogger()->error($e->getMessage());
     $request = IfwPsn_Zend_Controller_Front::getInstance()->getRequest();
     // Repoint the request to the default error handler
     //        $request->setModuleName('default');
     //        $request->setControllerName('Psn-ewrror');
     //        $request->setActionName('error');
     // Set up the error handler
     $error = new IfwPsn_Vendor_Zend_Controller_Plugin_ErrorHandler(array('controller' => $this->_pm->getAbbrLower() . '-error'));
     $error->type = IfwPsn_Vendor_Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER;
     if (is_object($request)) {
         $error->request = clone $request;
     }
     $error->exception = $e;
     $request->setParam('error_handler', $error);
 }