コード例 #1
0
ファイル: Route.php プロジェクト: piratevn/cms-gio
 /**
  * @return Gio_Core_Route
  */
 public static function getInstance()
 {
     if (null == self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
コード例 #2
0
ファイル: Widget.php プロジェクト: piratevn/cms-gio
 protected function showAction()
 {
     $request = $this->getRequest();
     $this->view->zoneId = $this->getParam('zone_id');
     $this->view->containerId = uniqid('adZone_');
     $route = Gio_Core_Route::getInstance()->getCurrentRoute();
     $this->view->route = $route['name'];
     $this->view->url = $request->getRedirectUrl();
 }
コード例 #3
0
ファイル: AdminAuth.php プロジェクト: piratevn/cms-gio
 public function run()
 {
     $request = Gio_Core_Request::getInstance();
     $configs = Gio_Core_Config_Xml::getConfig('web');
     $adminPrefixUrl = $configs->admin->url_prefix;
     $adminTemplate = $configs->admin->template;
     $adminSkin = isset($configs->admin->skin) ? $configs->admin->skin : 'default';
     $baseUrl = $request->getBaseUrl();
     $uri = $request->getRequestUri();
     $serverName = $request->getServerName();
     $serverPort = $request->getServerPort();
     $serverPort = $serverPort == 80 ? '' : ':' . $serverPort;
     $uri = 'http://' . $serverName . $serverPort . $uri;
     $currentUrl = str_replace($baseUrl, '', $uri);
     $currentUrl = '/' . rtrim(ltrim($currentUrl, '/'), '/') . '/';
     /**
      * 7 is length of /admin/
      */
     $length = strlen($adminPrefixUrl) + 2;
     if (!$adminPrefixUrl || substr($currentUrl, 0, $length) != "/{$adminPrefixUrl}/") {
         return;
     }
     $controllerFront = Gio_Core_Controller::getIntance();
     $controllerFront->setTemplate($adminTemplate);
     $view = Gio_Core_View::getInstance();
     $view->APP_TEMPLATE = $adminTemplate;
     $view->APP_SKIN = $adminSkin;
     $view->setAdminSection(true);
     /**
      * Check admin login
      */
     $phpSessionId = $request->getPost('PHPSESSID');
     $session = Gio_Core_Session::getSessionById($phpSessionId);
     $json = new Services_JSON();
     $user = null == $session || null == $session['data'] ? null : $json->decode($session['data']);
     $view->userLogin = $user;
     //return;
     $route = Gio_Core_Route::getCurrentRoute(true);
     if ((null == $user || !isset($user->username) || null == $user->username) && (null == $route || $route['name'] != 'core_auth_login')) {
         $return = $_SERVER['REQUEST_URI'];
         $return = $return ? rawurlencode(base64_encode($return)) : null;
         $link = $view->url('core_auth_login');
         if (strpos($link, '?') !== false) {
             $return = $return != null ? '&return=' . $return : null;
         } else {
             $return = $return != null ? '?return=' . $return : null;
         }
         header('Location: ' . $link . $return);
         exit;
     }
 }
コード例 #4
0
ファイル: Widget.php プロジェクト: piratevn/cms-gio
 protected function showAction()
 {
     $currRoute = Gio_Core_Route::getCurrentRoute();
     $routeName = $currRoute['name'];
     $defaults = $currRoute;
     $request = $this->getRequest();
     $this->view->lang = $request->getParam('lang');
     $links = array();
     if (isset($defaults['localization']['enable']) && 'true' == $defaults['localization']['enable'] && isset($defaults['localization']['identifier']['class'])) {
         $class = $defaults['localization']['identifier']['class'];
         $name = $defaults['localization']['identifier']['param'];
         /**
          * The DAO method used to get the model instance
          */
         $method = isset($defaults['localization']['identifier']['method']) ? $defaults['localization']['identifier']['method'] : 'getById';
         $id = Gio_Core_Request::getInstance()->getParam($name);
         $conn = Gio_Db_Connection::getConnection();
         $translationDao = new Modules_Core_Models_Mysql_Translation();
         $translationDao->setConnection($conn);
         $items = $translationDao->getItems($id, $class);
         $array = explode('_', $class);
         $array[] = $array[count($array) - 1];
         $array[count($array) - 2] = 'Mysql';
         $daoClass = implode('_', $array);
         $daoInstance = new $daoClass();
         $daoInstance->setConnection($conn);
         if ($items != null) {
             $config = Gio_Core_Config_Xml::getConfig('localization');
             $languages = $config->languages->details;
             foreach ($items as $item) {
                 if ($item['item_id'] == $id) {
                     continue;
                 }
                 $object = $daoInstance->{$method}($item['item_id']);
                 if ($object != null) {
                     $language = $item['language'];
                     if (isset($languages[$item['language']])) {
                         $info = explode('|', $languages[$item['language']]);
                         $language = $info[1];
                     }
                     $links[] = array('url' => $this->view->url($routeName, $object), 'label' => $language);
                 }
             }
         }
     }
     $this->view->assign('links', $links);
 }
コード例 #5
0
ファイル: Csrf.php プロジェクト: piratevn/cms-gio
 public function __construct($routeName)
 {
     if (isset($config['salt'])) {
         $this->_salt = $config['salt'];
     }
     if (isset($config['name'])) {
         $this->_name = $config['name'];
     }
     if (isset($config['timeout'])) {
         $this->_timeout = $config['timeout'];
     }
     $routes = Gio_Core_Route::getInstance()->getRoutes();
     if ($routeName && isset($routes[$routeName])) {
         $defaults = $routes[$routeName];
         if (isset($defaults['csrf']) && 'true' == (string) $defaults['csrf']['enable']) {
             $this->_csrfEnable = true;
             $this->_csrfRequestMethod = strtoupper($defaults['csrf']['request']);
             $this->_csrfRetriveMethod = strtoupper($defaults['csrf']['retrive']);
         }
     }
 }
コード例 #6
0
ファイル: Permalink.php プロジェクト: piratevn/cms-gio
 public function run()
 {
     $request = Gio_Core_Request::getInstance();
     $configs = Gio_Core_Config_Xml::getConfig('web');
     /**
      * Do nothing if we are in page of managing permalink
      */
     $uri = $request->getRequestUri();
     $uri = strtolower($uri);
     $uri = rtrim($uri, '/') . '/';
     $adminPrefix = $configs->admin->url_prefix;
     $adminPrefix = rtrim(ltrim($adminPrefix, '/'), '/');
     if (is_int(strpos($uri, '/' . $adminPrefix . '/core/permalink'))) {
         return;
     }
     $defaultFile = ROOT_DIR . DS . 'configs' . DS . 'permalink.xml';
     $host = $request->getServerName();
     $host = substr($host, 0, 3) == 'www' ? substr($host, 4) : $host;
     $file = ROOT_DIR . DS . 'configs' . DS . $host . '.' . 'permalink.xml';
     $file = file_exists($file) ? $file : $defaultFile;
     if (!file_exists($file)) {
         return;
     }
     $route = Gio_Core_Route::getInstance();
     $config = @simplexml_load_file($file);
     if (!isset($config->item) || empty($config->item)) {
         return;
     }
     $categoryConfig = Gio_Core_Module::getConfig('category');
     $param = isset($categoryConfig['url']['param']) ? $categoryConfig['url']['param'] : 'category_id';
     foreach ($config->item as $index => $item) {
         $item = (array) $item;
         if (!in_array($item['name'], $this->_inArray)) {
             $route->setRoute($item['name'], $item);
         } elseif ($param == 'category_path' && in_array($item['name'], $this->_inArray)) {
             $route->setRoute($item['name'], $item);
         }
     }
 }
コード例 #7
0
ファイル: LinkProvider.php プロジェクト: piratevn/cms-gio
 public static function getLinks($lang = null)
 {
     if (null == $lang) {
         $lang = Gio_Core_Config_Xml::getConfig('web')->language;
     }
     $view = Gio_Core_View::getInstance();
     $router = Gio_Core_Route::getInstance();
     $results = array();
     $links = array();
     /**
      * Add the homepage link
      */
     $links['core_index_index'][] = array('href' => $view->url('core_index_index', array('language' => $lang)));
     $links = Gio_Core_Hook_Registry::getInstance()->executeFilter('Core_LinkProvider', $links, array($lang));
     foreach ($links as $routeName => $value) {
         /**
          * Get route description
          */
         $defaults = $router->getRoute($routeName);
         $description = isset($defaults['langKey']) ? $view->TRANSLATOR->translator($defaults['langKey'], $defaults['module'], $lang) : $routeName;
         $results[$routeName] = array('description' => $description, 'links' => $value);
     }
     return $results;
 }
コード例 #8
0
ファイル: Page.php プロジェクト: piratevn/cms-gio
 public function editAction()
 {
     $request = $this->getRequest();
     $template = $request->getParam('template_id');
     $this->view->template = $template;
     $pageId = $request->getParam('page_id');
     $page = Modules_Core_Services_Page::getById($pageId);
     if (null == $page) {
         return;
     }
     $page['template_id'] = $template;
     $this->view->pageData = $page;
     $dbRoutesPage = Modules_Core_Services_Page::dbPages('route');
     $routes = array();
     if ($dbRoutesPage) {
         foreach ($dbRoutesPage as $index => $route) {
             $routes[] = $route['route'];
         }
     }
     $this->view->dbRoutesPage = $routes;
     $routesFrontend = Gio_Core_Route::getInstance()->getRoutes(true);
     $this->view->routesFrontend = $routesFrontend;
     if ($request->isPost()) {
         $pageData = $request->getPost('page');
         $pageData = Modules_Core_Services_Page::validate($pageData);
         if (isset($pageData['messages_error']) && $pageData['messages_error']) {
             $this->view->errorMessages = $pageData['messages'];
             $pageData['page_id'] = $pageId;
             $pageData['template_id'] = $template;
             $this->view->pageData = $pageData;
             return;
         }
         if (in_array($pageData['route'], $routes) && $page['route'] != $pageData['route']) {
             Gio_Core_Messenger::getInstance()->addMessage($this->view->TRANSLATOR->translator('page_actions_edit_exist'));
             $this->redirect($this->view->url('core_page_edit', $page));
             return;
         }
         Modules_Core_Services_Page::update($pageData);
         Gio_Core_Messenger::getInstance()->addMessage($this->view->TRANSLATOR->translator('page_actions_edit_success'));
         $this->redirect($this->view->url('core_page_edit', $page));
     }
 }
コード例 #9
0
ファイル: Translator.php プロジェクト: piratevn/cms-gio
 private static function _getLang()
 {
     $route = Gio_Core_Route::getCurrentRoute(true);
     $configs = Gio_Core_Config_Xml::getConfig('web');
     $lang = $configs->language;
     if (isset($route['localization']['enable']) && $route['localization']['enable'] == true) {
         $request = Gio_Core_Request::getInstance();
         $lang = $request->getParam('lang');
     }
     return $lang;
 }
コード例 #10
0
ファイル: Application.php プロジェクト: piratevn/cms-gio
 public function run()
 {
     /**
      * Run Permalink Plugin 
      */
     $permalink = new Modules_Core_Controllers_Plugins_Permalink();
     call_user_func(array($permalink, 'run'));
     /**
      * Run LocalizationRoute Plugin 
      */
     $localizationRoute = new Gio_Core_Plugins_LocalizationRoute();
     call_user_func(array($localizationRoute, 'run'));
     /**
      * Run Install Checker
      */
     $currentRoute = Gio_Core_Route::getCurrentRoute();
     self::$_route = $currentRoute;
     $controllerFront = Gio_Core_Controller::getIntance();
     if ($currentRoute && $currentRoute['name'] != 'core_install_step1' && self::_initInstallChecker() === false) {
         $controllerFront->redirect($this->_view->url('core_install_step1'));
         return;
     }
     if (isset($currentRoute['module']) && isset($currentRoute['controller']) && isset($currentRoute['action'])) {
         if (self::_initInstallChecker() == true) {
             $csrf = new Gio_Core_Csrf($currentRoute['name']);
             if (!$csrf->authentication()) {
                 return;
             }
             $csrf->appendElement();
         }
         $controllerFront->setModuleName($currentRoute['module'])->setControllerName($currentRoute['controller'])->setActionName($currentRoute['action']);
         /**
          * Run Plugins First
          */
         if (self::_initInstallChecker() == true) {
             $this->_runPlugin();
         }
         $this->_view->CURRENT_ROUTE = $currentRoute['name'];
         $content = $controllerFront->dispatch();
         $this->_view->setLayoutContent($content);
         if (!Gio_Core_Controller::getIntance()->getDisableLayout()) {
             $layout = isset($this->_view->APP_LAYOUT) && $this->_view->APP_LAYOUT ? $this->_view->APP_LAYOUT : $controllerFront->getLayout();
             $layoutFile = TEMPLATE_DIR . DS . $this->_view->APP_TEMPLATE . DS . 'layouts' . DS . $layout . '.phtml';
             $this->_view->fetch($layoutFile);
         } else {
             $this->_view->content($content);
         }
     }
 }
コード例 #11
0
ファイル: View.php プロジェクト: piratevn/cms-gio
 public function url($name, $params = array())
 {
     return Gio_Core_Route::getInstance()->get($name, $params);
 }