示例#1
0
 function _initHeader()
 {
     //date_default_timezone_set("PRC");
     header("Content-Type:text/html;charset=utf-8");
     $config = new Zend_Config_Ini(CONFIGS_PATH . '/application.ini', 'production');
     defined("SYS_NAME") || define("SYS_NAME", $config->sys->name);
     defined("SYS_COPYRIGHT") || define("SYS_COPYRIGHT", $config->sys->copyright . date('Y'));
     defined("SYS_EMAIL_SUFFIX") || define("SYS_EMAIL_SUFFIX", $config->sys->email_suffix);
     $page_head = '<title>' . SYS_NAME . '</title>
                   <link type="image/x-icon" rel=icon href="' . HOME_PATH . '/public/images/favicon.ico">
                   <link rel="stylesheet" type="text/css" href="' . HOME_PATH . '/public/css/style.css"/>
                   <link rel="stylesheet" type="text/css" href="' . HOME_PATH . '/public/css/icon.css"/>
                   <link rel="stylesheet" type="text/css" href="' . HOME_PATH . '/library/ext/resources/css/ext-all.css">
                   <link rel="stylesheet" type="text/css" href="' . HOME_PATH . '/public/css/BoxSelect.css">
                   <script type="text/javascript" src="' . HOME_PATH . '/library/ext/ext-all.js"></script>
                   <script type="text/javascript" src="' . HOME_PATH . '/library/ext/locale/ext-lang-zh_CN.js"></script>
                   <script type="text/javascript" src="' . HOME_PATH . '/public/js/BoxSelect.js"></script>
                   <script type="text/javascript" src="' . HOME_PATH . '/public/js/EmployeeCombo.js"></script>
                   <script type="text/javascript">Ext.override(Ext.view.Table, { enableTextSelection: true });var homePath="' . HOME_PATH . '";</script>';
     defined("SYS_HEAD") || define("SYS_HEAD", $page_head);
     $router = new Zend_Controller_Router_Rewrite();
     $request = new Zend_Controller_Request_Http();
     $router->route($request);
     $controller = $request->getControllerName();
     $action = $request->getActionName();
     // 已登录验证过滤
     if ($controller != 'home' && $controller != 'index' && $controller != 'login' && $controller != 'hra' && $controller != 'admin' && $controller != 'dcc' || $controller == 'hra' && $action != 'news' || $controller == 'admin' && $action != 'cron' || $controller == 'dcc' && $action != 'upload') {
         $user_session = new Zend_Session_Namespace('user');
         if (!isset($user_session->user_info)) {
             exit("<script>window.location.href='" . HOME_PATH . "/public/home/login';</script>");
         }
     }
 }
示例#2
0
文件: Router.php 项目: nhp/shopware-4
    /**
     * Retrieve router object
     *
     * @return Zend_Controller_Router_Rewrite
     */
    public function getRouter()
    {
        if (null === $this->_router) {
            $bootstrap = $this->getBootstrap();
            $bootstrap->bootstrap('FrontController');
            $this->_router = $bootstrap->getContainer()->frontcontroller->getRouter();

            $options = $this->getOptions();
            if (!isset($options['routes'])) {
                $options['routes'] = array();
            }

            if (isset($options['chainNameSeparator'])) {
                $this->_router->setChainNameSeparator($options['chainNameSeparator']);
            }

            if (isset($options['useRequestParametersAsGlobal'])) {
                $this->_router->useRequestParametersAsGlobal($options['useRequestParametersAsGlobal']);
            }

            $this->_router->addConfig(new Zend_Config($options['routes']));
        }

        return $this->_router;
    }
示例#3
0
 protected function _initRouter()
 {
     $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/routes.ini');
     $router = new Zend_Controller_Router_Rewrite();
     $router->addConfig($config);
     Zend_Controller_Front::getInstance()->setRouter($router);
 }
示例#4
0
 protected function setUp()
 {
     parent::setUp();
     foreach (array_keys($_POST) as $key) {
         unset($_POST[$key]);
     }
     Zend_Auth::getInstance()->setStorage(new Zend_Auth_Storage_NonPersistent());
     $this->clean();
     $front = Zend_Controller_Front::getInstance();
     $router = new Zend_Controller_Router_Rewrite();
     $routes_config = new USVN_Config_Ini(USVN_ROUTES_CONFIG_FILE, USVN_CONFIG_SECTION);
     $router->addConfig($routes_config, 'routes');
     $front->setRouter($router);
     $table = new USVN_Db_Table_Users();
     $this->user = $table->fetchNew();
     $this->user->setFromArray(array('users_login' => 'john', 'users_password' => 'pinocchio'));
     $this->user->save();
     $this->admin_user = $table->fetchNew();
     $this->admin_user->setFromArray(array('users_login' => 'god', 'users_password' => 'ingodwetrust', 'users_is_admin' => true));
     $this->admin_user->save();
     $authAdapter = new USVN_Auth_Adapter_Database('john', 'pinocchio');
     Zend_Auth::getInstance()->authenticate($authAdapter);
     $front->setControllerDirectory(USVN_CONTROLLERS_DIR);
     $this->request = new USVN_Controller_Request_Http();
     $front->setRequest($this->request);
     $this->response = new Zend_Controller_Response_Cli();
     $front->setResponse($this->response);
     $router->addRoute('default', new Zend_Controller_Router_Route_Module(array(), $front->getDispatcher(), $front->getRequest()));
 }
示例#5
0
 /**
  *
  * Initialize router
  */
 protected function _initRewrite()
 {
     $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/routes.ini', 'production');
     $objRouter = new Zend_Controller_Router_Rewrite();
     $router = $objRouter->addConfig($config, 'routes');
     $front = Zend_Controller_Front::getInstance();
     $front->setRouter($router);
 }
示例#6
0
 /**
  * Initialize the routes
  *
  * @return void
  */
 protected function _initRouter()
 {
     $routes = new Zend_Config_Xml(APPLICATION_PATH . '/configs/frontend_routes.xml');
     $router = new Zend_Controller_Router_Rewrite();
     $router->addConfig($routes);
     $front = Zend_Controller_Front::getInstance();
     $front->setRouter($router);
 }
示例#7
0
 protected function _initLoadRouter()
 {
     $config = new Zend_Config_Ini(CONFIG_PATH . '/routers.ini', 'setup-router');
     $objRouter = new Zend_Controller_Router_Rewrite();
     //new Zend_Controller_Router_Route_Regex()
     $router = $objRouter->addConfig($config, 'routers');
     $front = Zend_Controller_Front::getInstance();
     $front->setRouter($router);
 }
示例#8
0
 /**
  * Initialize router
  *
  * @return \Zend_Controller_Router_Rewrite
  */
 protected function _initRoutes()
 {
     $config = new Zend_Config_Json(APPLICATION_PATH . '/configs/routes/en.json', 'routes', array('ignore_constants' => true, 'skip_extends' => true));
     $router = new Zend_Controller_Router_Rewrite();
     $router->addConfig($config);
     $front = Zend_Controller_Front::getInstance();
     $front->setRouter($router);
     return $router;
 }
示例#9
0
 protected function _getRouterInstance()
 {
     $routes = array('default' => $this->_getRoute('*', self::CONTROLLER_INDEX), self::ROUTE_INDEX => $this->_getRoute('form-to-mail', self::CONTROLLER_INDEX), self::ROUTE_CONFIRM => $this->_getRoute('form-to-mail/confirm', self::CONTROLLER_INDEX), self::ROUTE_LOGIN => $this->_getRoute('form-to-mail/login', self::CONTROLLER_LOGIN));
     require_once 'Zend/Controller/Router/Rewrite.php';
     $router = new Zend_Controller_Router_Rewrite();
     $router->removeDefaultRoutes();
     $router->addRoutes($routes);
     return $router;
 }
示例#10
0
 protected function _initRouter()
 {
     // Loads routes from specific config file
     $front = $this->bootstrap('FrontController')->getResource('FrontController');
     $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/routes.ini', 'production');
     $routing = new Zend_Controller_Router_Rewrite();
     $routing->addConfig($config, 'routes');
     $front->setRouter($routing);
 }
示例#11
0
 protected function _getRouterInstance()
 {
     $path = $this->getServicePath();
     $routes = array('default' => $this->_getRoute('*', self::CONTROLLER_CAMPAIGNS), self::ROUTE_CAMPAIGNS => $this->_getRoute("{$path}/campaigns", self::CONTROLLER_CAMPAIGNS), self::ROUTE_CAMPAIGNS_SHARP => $this->_getRoute("{$path}/campaigns/:id", self::CONTROLLER_CAMPAIGNS), self::ROUTE_SUBSCRIPTIONS_SUBSCRIBE => $this->_getRoute("{$path}/subscriptions", self::CONTROLLER_SUBSCRIPTIONS), self::ROUTE_SUBSCRIPTIONS_UNSUBSCRIBE => $this->_getRoute("{$path}/subscriptions/unsubscribe", self::CONTROLLER_SUBSCRIPTIONS), self::ROUTE_SUBSCRIPTIONS_CONFIRM_OPTIN => $this->_getRoute("{$path}/subscriptions/confirm/optin", self::CONTROLLER_SUBSCRIPTIONS), self::ROUTE_SUBSCRIPTIONS_CONFIRM_FINAL => $this->_getRoute("{$path}/subscriptions/confirm/final", self::CONTROLLER_SUBSCRIPTIONS), self::ROUTE_SUBSCRIPTIONS_CONFIRM_UNSUBSCRIBE => $this->_getRoute("{$path}/subscriptions/confirm/unsubscribe", self::CONTROLLER_SUBSCRIPTIONS));
     require_once 'Zend/Controller/Router/Rewrite.php';
     $router = new Zend_Controller_Router_Rewrite();
     $router->removeDefaultRoutes();
     $router->addRoutes($routes);
     return $router;
 }
示例#12
0
 protected function _getRouterInstance()
 {
     $path = $this->getServicePath();
     $routes = array('default' => $this->_getRoute('*', self::CONTROLLER_CAMPAIGNS), self::ROUTE_LOGIN => $this->_getRoute("{$path}/login", self::CONTROLLER_LOGIN), self::ROUTE_CAMPAIGNS => $this->_getRoute("{$path}/campaigns", self::CONTROLLER_CAMPAIGNS), self::ROUTE_CAMPAIGNS_SHARP => $this->_getRoute("{$path}/campaigns/:id", self::CONTROLLER_CAMPAIGNS), self::ROUTE_CAMPAIGNS_NEW => $this->_getRoute("{$path}/campaigns/new", self::CONTROLLER_CAMPAIGNS), self::ROUTE_CAMPAIGNS_BATCH => $this->_getRoute("{$path}/campaigns/batch", self::CONTROLLER_CAMPAIGNS), self::ROUTE_CAMPAIGNS_ATTACHMENTS => $this->_getRoute("{$path}/campaigns/:aid/attachments", self::CONTROLLER_CAMPAIGNS_ATTACHMENTS), self::ROUTE_CAMPAIGNS_ATTACHMENTS_SHARP => $this->_getRoute("{$path}/campaigns/:aid/attachments/:id", self::CONTROLLER_CAMPAIGNS_ATTACHMENTS), self::ROUTE_CAMPAIGNS_ATTACHMENTS_NEW => $this->_getRoute("{$path}/campaigns/:aid/attachments/new", self::CONTROLLER_CAMPAIGNS_ATTACHMENTS), self::ROUTE_CAMPAIGNS_ATTACHMENTS_BATCH => $this->_getRoute("{$path}/campaigns/:aid/attachments/batch", self::CONTROLLER_CAMPAIGNS_ATTACHMENTS), self::ROUTE_CAMPAIGNS_ATTACHMENTS_UPLOAD => $this->_getRoute("{$path}/campaigns/:aid/attachments/upload", self::CONTROLLER_CAMPAIGNS_ATTACHMENTS), self::ROUTE_CAMPAIGNS_ATTACHMENTS_ASSIGN => $this->_getRoute("{$path}/campaigns/:aid/attachments/assign", self::CONTROLLER_CAMPAIGNS_ATTACHMENTS), self::ROUTE_CAMPAIGNS_ATTACHMENTS_JSURLS => $this->_getRoute("{$path}/campaigns/:aid/attachments/jsurls", self::CONTROLLER_CAMPAIGNS_ATTACHMENTS));
     require_once 'Zend/Controller/Router/Rewrite.php';
     $router = new Zend_Controller_Router_Rewrite();
     $router->removeDefaultRoutes();
     $router->addRoutes($routes);
     return $router;
 }
示例#13
0
 protected function _getRouterInstance()
 {
     require_once 'Zend/Controller/Router/Route.php';
     $routes = array('default' => new Zend_Controller_Router_Route('*', array(Sitengine_Env::PARAM_CONTROLLER => $this->getController(self::CONTROLLER_INDEX), Sitengine_Env::PARAM_ACTION => 'index')), self::ROUTE_INDEX => new Zend_Controller_Router_Route('backend/sitemap/:' . Sitengine_Env::PARAM_ACTION . '/*', array(Sitengine_Env::PARAM_CONTROLLER => $this->getController(self::CONTROLLER_INDEX), Sitengine_Env::PARAM_ACTION => 'index')), self::ROUTE_LOGIN => new Zend_Controller_Router_Route('backend/sitemap/login', array(Sitengine_Env::PARAM_CONTROLLER => $this->getController(self::CONTROLLER_LOGIN), Sitengine_Env::PARAM_ACTION => 'index')));
     require_once 'Zend/Controller/Router/Rewrite.php';
     $router = new Zend_Controller_Router_Rewrite();
     $router->removeDefaultRoutes();
     $router->addRoutes($routes);
     return $router;
 }
示例#14
0
 protected function _getRouterInstance()
 {
     $path = $this->getServicePath();
     $routes = array('default' => $this->_getRoute('*', self::CONTROLLER_USER), self::ROUTE_USER => $this->_getRoute("{$path}/user", self::CONTROLLER_USER), self::ROUTE_USER_NEW => $this->_getRoute("{$path}/join", self::CONTROLLER_USER), self::ROUTE_LOGIN => $this->_getRoute("{$path}/login", self::CONTROLLER_LOGIN));
     require_once 'Zend/Controller/Router/Rewrite.php';
     $router = new Zend_Controller_Router_Rewrite();
     $router->removeDefaultRoutes();
     $router->addRoutes($routes);
     return $router;
 }
示例#15
0
 public static function getRouter()
 {
     /* @var $router Zend_Controller_Router_Rewrite */
     $router = new \Zend_Controller_Router_Rewrite();
     $routes = array();
     $routes['watch'] = new \Zend_Controller_Router_Route('watch/:id/:name', array('controller' => 'watch', 'action' => 'index', 'id' => "0", 'name' => ''));
     $routes['category'] = new \Zend_Controller_Router_Route('category/:categoryId/:page', array('controller' => 'category', 'action' => 'index', 'categoryId' => "0", 'page' => '1'));
     $routes['latest-update'] = new \Zend_Controller_Router_Route('latest-update/:page', array('controller' => 'index', 'action' => 'index', 'page' => "1"));
     $router->addRoutes($routes);
     return $router;
 }
示例#16
0
 public function recentAction()
 {
     //@todo route: do it the right way!
     $router = new Zend_Controller_Router_Rewrite();
     $routeConfig = new Zend_Config_Ini(APPLICATION_PATH . '/configs/defaultRoutes.ini');
     $router->addConfig($routeConfig, 'routes');
     $registry = Zend_Registry::getInstance();
     $config = $registry->get("config");
     $this->_helper->verifyIdentity();
     $recent = new Ml_Model_Recent();
     if (!$registry->isRegistered("authedUserInfo")) {
         throw new Exception("Not authenticated.");
     }
     $userInfo = $registry->get("authedUserInfo");
     $uploads = $recent->contactsUploads($userInfo['id']);
     //send response
     $doc = new Ml_Model_Dom();
     $doc->formatOutput = true;
     $rootElement = $doc->createElement("items");
     $doc->appendChild($rootElement);
     foreach ($uploads as $share) {
         $shareElement = $doc->createElement("item");
         $avatarInfo = unserialize($share['people.avatarInfo']);
         if (isset($avatarInfo['secret'])) {
             $iconSecret = $avatarInfo['secret'];
         } else {
             $iconSecret = '';
         }
         $shareData = array("type" => "file", "id" => $share['id']);
         foreach ($shareData as $name => $field) {
             $shareElement->appendChild($doc->newTextAttribute($name, $field));
         }
         $shareData = array("title" => $share['share.title'], "short" => $share['share.short'], "url" => "http://" . $config['webhost'] . $router->assemble(array("username" => $share['people.alias'], "share_id" => $share['id']), "sharepage_1stpage"));
         foreach ($shareData as $name => $field) {
             $shareElement->appendChild($doc->newTextElement($name, $field));
         }
         $filesizeElement = $doc->createElement("filesize");
         $filesizeElement->appendChild($doc->newTextAttribute("bits", $share['share.fileSize']));
         $filesizeElement->appendChild($doc->newTextAttribute("kbytes", ceil($share['share.fileSize'] / (1024 * 8))));
         $shareElement->appendChild($filesizeElement);
         $ownerElement = $doc->createElement("owner");
         $shareData = array("id" => $share['people.id'], "alias" => $share['people.alias'], "realname" => $share['people.name'], "iconsecret" => $iconSecret);
         foreach ($shareData as $name => $field) {
             $ownerElement->appendChild($doc->newTextAttribute($name, $field));
         }
         $shareElement->appendChild($ownerElement);
         $rootElement->appendChild($shareElement);
     }
     $this->_helper->printResponse($doc);
 }
示例#17
0
 /**
  * Routes initialization
  *
  * @return Zend_Controller_Router
  */
 protected function _initRoutes()
 {
     $this->bootstrapOptions();
     $router = new \Zend_Controller_Router_Rewrite();
     foreach (\NS\Service\AbstractService::getConfig() as $module => $config) {
         if ($config->routes) {
             foreach ($config->routes as $r => $routeConfig) {
                 $router->addRoute($module . '_' . $r, \Zend_Controller_Router_Route::getInstance($routeConfig));
             }
         }
     }
     \Zend_Controller_Front::getInstance()->setRouter($router);
     return $router;
 }
示例#18
0
 /**
  * Retrieve router object
  *
  * @return Zend_Controller_Router_Rewrite
  */
 public function getRouter()
 {
     if (null === $this->_router) {
         $bootstrap = $this->getBootstrap();
         $bootstrap->bootstrap('FrontController');
         $front = $bootstrap->getContainer()->frontcontroller;
         $options = $this->getOptions();
         if (!isset($options['routes'])) {
             $options['routes'] = array();
         }
         $this->_router = $front->getRouter();
         $this->_router->addConfig(new Zend_Config($options['routes']));
     }
     return $this->_router;
 }
示例#19
0
文件: Router.php 项目: neilgarb/yadda
 public function __construct()
 {
     parent::__construct();
     $this->removeDefaultRoutes();
     $this->addRoute('deal-listing', new Zend_Controller_Router_Route('deal/:id/listing.jpg', array('controller' => 'deal', 'action' => 'thumb', 'width' => 75, 'height' => 75, 'crop' => false, 'filename' => 'listing.jpg'), array('id' => '\\d+')));
     $this->addRoute('deal-detail', new Zend_Controller_Router_Route('deal/:id/detail.jpg', array('controller' => 'deal', 'action' => 'thumb', 'width' => 250, 'height' => 250, 'crop' => false, 'filename' => 'detail.jpg'), array('id' => '\\d+')));
 }
示例#20
0
 public function __construct($prefix)
 {
     parent::__construct();
     $this->AddRoute('admin', new Zend_Controller_Router_Route($prefix . '/:module/:controller/:action', array('module' => 'index', 'controller' => 'index', 'action' => 'index')));
     $this->AddRoute('kwf_welcome', new Zend_Controller_Router_Route('/kwf/welcome/:controller/:action', array('module' => 'kwf_controller_action_welcome', 'controller' => 'index', 'action' => 'index')));
     $this->AddRoute('kwf_user', new Zend_Controller_Router_Route('/kwf/user/:controller/:action', array('module' => 'kwf_controller_action_user', 'action' => 'index')));
     $this->AddRoute('kwf_error', new Zend_Controller_Router_Route('/kwf/error/:controller/:action', array('module' => 'kwf_controller_action_error')));
     $this->AddRoute('kwf_start', new Zend_Controller_Router_Route('/kwf/start', array('module' => 'kwf_controller_action_welcome', 'controller' => 'start', 'action' => 'index')));
     $this->AddRoute('kwf_pool', new Zend_Controller_Router_Route('/kwf/pool/:controller/:action', array('module' => 'kwf_controller_action_pool', 'controller' => 'pools', 'action' => 'index')));
     $this->AddRoute('kwf_debug', new Zend_Controller_Router_Route('/kwf/debug/:controller/:action', array('module' => 'kwf_controller_action_debug', 'controller' => 'index', 'action' => 'index')));
     $this->AddRoute('kwf_media', new Zend_Controller_Router_Route('/kwf/media/:controller/:action', array('module' => 'kwf_controller_action_media', 'controller' => 'index', 'action' => 'index')));
     $this->AddRoute('kwf_spam', new Zend_Controller_Router_Route('/kwf/spam/:controller/:action', array('module' => 'kwf_controller_action_spam', 'action' => 'index')));
     $this->AddRoute('kwf_enquiries', new Zend_Controller_Router_Route('/kwf/enquiries/:controller/:action', array('module' => 'kwf_controller_action_enquiries', 'action' => 'index')));
     $this->AddRoute('kwf_redirects', new Zend_Controller_Router_Route('/kwf/redirects/:controller/:action', array('module' => 'kwf_controller_action_redirects', 'action' => 'index')));
     $this->AddRoute('kwf_maintenance', new Zend_Controller_Router_Route('/kwf/maintenance/:controller/:action', array('module' => 'kwf_controller_action_maintenance', 'action' => 'index')));
     $this->AddRoute('kwf_component', new Zend_Controller_Router_Route('/kwf/component/:controller/:action', array('module' => 'kwf_controller_action_component', 'action' => 'index')));
     $apiRoute = new Zend_Controller_Router_Route('api');
     $restRoute = new Kwf_Rest_Route($this->getFrontController(), array('module' => 'api'), array('api'));
     $chainedRoute = new Kwf_Controller_Router_Route_Chain();
     $chainedRoute->chain($apiRoute)->chain($restRoute);
     $this->addRoute('api', $chainedRoute);
     //Komponenten routes
     if ($prefix) {
         $prefix = '/' . $prefix;
         $this->AddRoute('welcome', new Zend_Controller_Router_Route($prefix . '', array('module' => 'kwf_controller_action_welcome', 'controller' => 'welcome', 'action' => 'index')));
     }
     $this->AddRoute('component', new Zend_Controller_Router_Route($prefix . '/component/:controller/:action', array('module' => 'kwf_controller_action_component', 'action' => 'index')));
     $this->AddRoute('components', new Zend_Controller_Router_Route($prefix . '/components/:action', array('module' => 'kwf_controller_action_component', 'controller' => 'components', 'action' => 'index')));
     $this->AddRoute('componentshow', new Zend_Controller_Router_Route($prefix . '/component/show/:class/:componentId', array('componentId' => null, 'module' => 'kwf_controller_action_component', 'controller' => 'components', 'action' => 'show')));
     $this->AddRoute('componentedit', new Zend_Controller_Router_Route($prefix . '/component/edit/:class/:componentController/:action', array('module' => 'component', 'controller' => 'component', 'action' => 'index')));
 }
示例#21
0
文件: Router.php 项目: neilgarb/yadda
 public function __construct()
 {
     parent::__construct();
     $this->removeDefaultRoutes();
     $this->addRoute('home', new Zend_Controller_Router_Route('', array('controller' => 'index', 'action' => 'index')));
     $this->addRoute('search', new Zend_Controller_Router_Route('search', array('controller' => 'deal', 'action' => 'search')));
     $this->addRoute('deal', new Zend_Controller_Router_Route('deal/:id', array('controller' => 'deal', 'action' => 'view'), array('id' => '\\d+')));
     $this->addRoute('contact', new Zend_Controller_Router_Route('contact', array('controller' => 'index', 'action' => 'contact')));
 }
示例#22
0
 protected function _getRouterInstance()
 {
     $path = $this->getServicePath();
     $routes = array('default' => $this->_getRoute('*', self::CONTROLLER_USERS), self::ROUTE_LOGIN => $this->_getRoute("{$path}/login", self::CONTROLLER_LOGIN), self::ROUTE_USERS => $this->_getRoute("{$path}/users", self::CONTROLLER_USERS), self::ROUTE_USERS_SHARP => $this->_getRoute("{$path}/users/:id", self::CONTROLLER_USERS), self::ROUTE_USERS_NEW => $this->_getRoute("{$path}/users/new", self::CONTROLLER_USERS), self::ROUTE_USERS_BATCH => $this->_getRoute("{$path}/users/batch", self::CONTROLLER_USERS), self::ROUTE_USERS_MEMBERSHIPS => $this->_getRoute("{$path}/users/:aid/memberships", self::CONTROLLER_USERS_MEMBERSHIPS), self::ROUTE_USERS_MEMBERSHIPS_SHARP => $this->_getRoute("{$path}/users/:aid/memberships/:id", self::CONTROLLER_USERS_MEMBERSHIPS), self::ROUTE_USERS_MEMBERSHIPS_NEW => $this->_getRoute("{$path}/users/:aid/memberships/new", self::CONTROLLER_USERS_MEMBERSHIPS), self::ROUTE_USERS_MEMBERSHIPS_BATCH => $this->_getRoute("{$path}/users/:aid/memberships/batch", self::CONTROLLER_USERS_MEMBERSHIPS), self::ROUTE_GROUPS => $this->_getRoute("{$path}/groups", self::CONTROLLER_GROUPS), self::ROUTE_GROUPS_SHARP => $this->_getRoute("{$path}/groups/:id", self::CONTROLLER_GROUPS), self::ROUTE_GROUPS_NEW => $this->_getRoute("{$path}/groups/new", self::CONTROLLER_GROUPS), self::ROUTE_GROUPS_BATCH => $this->_getRoute("{$path}/groups/batch", self::CONTROLLER_GROUPS), self::ROUTE_GROUPS_MEMBERS => $this->_getRoute("{$path}/groups/:aid/members", self::CONTROLLER_GROUPS_MEMBERS), self::ROUTE_GROUPS_MEMBERS_SHARP => $this->_getRoute("{$path}/groups/:aid/members/:id", self::CONTROLLER_GROUPS_MEMBERS), self::ROUTE_GROUPS_MEMBERS_NEW => $this->_getRoute("{$path}/groups/:aid/members/new", self::CONTROLLER_GROUPS_MEMBERS), self::ROUTE_GROUPS_MEMBERS_BATCH => $this->_getRoute("{$path}/groups/:aid/members/batch", self::CONTROLLER_GROUPS_MEMBERS));
     require_once 'Zend/Controller/Router/Rewrite.php';
     $router = new Zend_Controller_Router_Rewrite();
     $router->removeDefaultRoutes();
     $router->addRoutes($routes);
     return $router;
 }
示例#23
0
 /**
  * Adds a redirect route for the homepage.
  *
  * A redirect is required to make a "homepage" that is an external URL, an
  * admin URL, or a URL with a query string.
  *
  * @param string $uri The absolute uri to redirect to the default route to
  * @param Zend_Controller_Router_Rewrite $router The router
  * @return boolean True if the route was successfully added, else false.
  */
 protected function _addHomepageRedirect($uri, $router)
 {
     // Handle possible internal links by stripping the base URL
     $uri = $this->_leftTrim($uri, PUBLIC_BASE_URL);
     if ($uri == '' || $uri == '/' || strpos($uri, '?') === 0 || strpos($uri, '/?') === 0) {
         return false;
     }
     $router->addRoute(self::HOMEPAGE_ROUTE_NAME, new Zend_Controller_Router_Route('/', array('controller' => 'redirector', 'action' => 'index', 'redirect_uri' => $uri)));
     return true;
 }
示例#24
0
 /**
  * Same route function in Zend_Controller_Front::dispatch().
  * It updates the request with routes and sends a message to
  * Zend_Controller_Front. This is processed in dispatch().
  * 
  * @param Zend_Controller_Request_Abstract $request
  */
 private function _route(Zend_Controller_Request_Abstract $request)
 {
     try {
         $this->_router->route($request);
     } catch (Exception $e) {
         if ($this->_front->throwExceptions()) {
             throw $e;
         }
     }
 }
 /**
  * Test own route
  */
 public function testInstall()
 {
     // set request and start routing
     $this->_request->setRequestUri('install.php');
     $request = $this->_router->route($this->_request);
     // check result
     $this->assertEquals('install', $this->_router->getCurrentRouteName());
     $this->assertEquals('default', $request->getModuleName());
     $this->assertEquals('index', $request->getControllerName());
     $this->assertEquals('index', $request->getActionName());
 }
示例#26
0
 /**
  * Router rewrite Front
  * 
  * @return string url
  */
 protected function _initFrontController()
 {
     $url = $_SERVER['REQUEST_URI'];
     $arr = explode('/', $url);
     $total_arr = sizeof($arr);
     $urlCheck = 3;
     //localhost = 3 server = 2, $arr[1]
     $detail = $total_arr == $urlCheck && preg_match('/^\\d+-\\d+-.*+$/', $arr[2], $matches) ? true : false;
     if ($total_arr == $urlCheck && !empty($arr[2]) && !$detail) {
         $front = Zend_Controller_Front::getInstance();
         $front->setControllerDirectory(array('default' => APPLICATION_PATH . "/modules/front/controllers", 'admin' => APPLICATION_PATH . "/modules/admin/controllers"));
         $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/routers.ini', 'estore');
         $router = new Zend_Controller_Router_Rewrite();
         return $front->setRouter($router->addConfig($config, 'routes'));
     } else {
         $front = Zend_Controller_Front::getInstance();
         $front->setControllerDirectory(array('default' => APPLICATION_PATH . "/modules/front/controllers", 'admin' => APPLICATION_PATH . "/modules/admin/controllers"));
         $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/routers.ini', 'rewriteshopname');
         $router = new Zend_Controller_Router_Rewrite();
         return $front->setRouter($router->addConfig($config, 'routes'));
     }
 }
示例#27
0
 public function test_getInstance_fromINIConfig()
 {
     $config = new \Zend\Config\Ini(dirname(__FILE__) . '/../Controller/_files/routes.ini', 'testing');
     $router = new \Zend_Controller_Router_Rewrite();
     $router->addConfig($config, 'routes');
     $route = $router->getRoute('rest');
     $this->assertType('Zend\\REST\\Route', $route);
     $this->assertEquals('object', $route->getDefault('controller'));
     $request = $this->_buildRequest('GET', '/mod/project');
     $values = $this->_invokeRouteMatch($request, array(), $route);
     $this->assertEquals('mod', $values['module']);
     $this->assertEquals('project', $values['controller']);
     $this->assertEquals('index', $values['action']);
     $request = $this->_buildRequest('POST', '/mod/user');
     $values = $this->_invokeRouteMatch($request, array(), $route);
     $this->assertEquals('mod', $values['module']);
     $this->assertEquals('user', $values['controller']);
     $this->assertEquals('post', $values['action']);
     $request = $this->_buildRequest('GET', '/other');
     $values = $this->_invokeRouteMatch($request, array(), $route);
     $this->assertFalse($values);
 }
示例#28
0
 public function __construct()
 {
     parent::__construct();
     $this->addRoute('register', new Zend_Controller_Router_Route('register', array('controller' => 'user', 'action' => 'register')));
     $this->addRoute('login', new Zend_Controller_Router_Route('login', array('controller' => 'user', 'action' => 'login')));
     $this->addRoute('logout', new Zend_Controller_Router_Route('logout', array('controller' => 'user', 'action' => 'logout')));
     $this->addRoute('user', new Zend_Controller_Router_Route('users/:id', array('controller' => 'user', 'action' => 'view'), array('id' => '\\d+')));
     $this->addRoute('applications', new Zend_Controller_Router_Route('applications', array('controller' => 'application', 'action' => 'index')));
     $this->addRoute('application-new', new Zend_Controller_Router_Route('applications/new', array('controller' => 'application', 'action' => 'new')));
     $this->addRoute('application', new Zend_Controller_Router_Route('applications/:id', array('controller' => 'application', 'action' => 'view'), array('id' => '\\d+')));
     $this->addRoute('template-new', new Zend_Controller_Router_Route('templates/new', array('controller' => 'template', 'action' => 'new')));
     $this->addRoute('template', new Zend_Controller_Router_Route('templates/:id', array('controller' => 'template', 'action' => 'view'), array('id' => '\\d+')));
     $this->addRoute('api-template-register', new Zend_Controller_Router_Route('api/template.register', array('module' => 'api', 'controller' => 'template', 'action' => 'register')));
     $this->addRoute('api-event-submit', new Zend_Controller_Router_Route('api/event.submit', array('module' => 'api', 'controller' => 'event', 'action' => 'submit')));
 }
示例#29
0
 /**
  * set router
  */
 protected function _setRouter()
 {
     if (null === self::$_router) {
         self::$_router = new Zend_Controller_Router_Rewrite();
         $route_project = new Zend_Controller_Router_Route_Regex('index.php/project/(\\d+)', array('controller' => 'project', 'action' => 'view'), array(1 => 'id'));
         $route_project_list = new Zend_Controller_Router_Route_Regex('project/list/(\\d+)', array('controller' => 'Index', 'action' => 'list', 'module' => 'project'), array(1 => 'page'), 'project/list/%d');
         $route_user_login = new Zend_Controller_Router_Route_Regex('user/login', array('module' => 'user', 'controller' => 'index', 'action' => 'login'));
         $route_user_logout = new Zend_Controller_Router_Route_Regex('user/logout', array('module' => 'user', 'controller' => 'index', 'action' => 'logout'));
         $route_user_list = new Zend_Controller_Router_Route_Regex('user/list/(\\d+)', array('module' => 'user', 'controller' => 'Index', 'action' => 'list'), array(1 => 'page'), 'user/list/%d');
         $route_user_edit = new Zend_Controller_Router_Route_Regex('user/edit', array('module' => 'user', 'controller' => 'index', 'action' => 'edit'));
         $route_user_edit_id = new Zend_Controller_Router_Route_Regex('user/edit/(\\d+)', array('module' => 'user', 'controller' => 'index', 'action' => 'edit'), array(1 => 'id'));
         $route_user_save = new Zend_Controller_Router_Route_Regex('user/save', array('module' => 'user', 'controller' => 'index', 'action' => 'save'));
         self::$_router->addRoutes(array($route_project, $route_user_login, $route_user_logout, $route_user_list, $route_user_edit, $route_user_edit_id, $route_user_save));
     }
 }
示例#30
0
 public function route(Zend_Controller_Request_Abstract $request)
 {
     // Let the Rewrite router route the request first
     $request = parent::route($request);
     if ($request->getParam('page') == '') {
         // If the page param isn't set, route to default page and controller
         $defaultPage = Brightfame_Page_Manager::getInstance()->getDefaultPage();
         //$request->setControllerName($defaultPage->pageType->controller);
         //$request->setParam('page',$defaultPage->page);
     } else {
         // Route to current page's controller
         $page = Brightfame_Page_Manager::getInstance()->getPage($request->getParam('page'));
         //$request->setControllerName($page->pageType->controller);
     }
     return $request;
 }