Exemple #1
0
 /**
  * Преобразование ассоциативного массива в URL строку
  * 
  **/
 public static function convert_to_get_line($arr)
 {
     if (is_array($arr) && !empty($arr)) {
         $arr = XARRAY::clearEmptyItems($arr);
         foreach ($arr as $key => $val) {
             $val = XARRAY::clearEmptyItems($val);
             if (is_array($val) && count($val) > 0) {
                 foreach ($val as $svk => $svv) {
                     if (is_array($svv)) {
                         $svv = implode('>', $svv);
                     }
                     $sv[] = $svk . ':' . $svv;
                 }
                 $val = implode('&', $sv);
                 unset($sv);
                 $getter_line .= '/' . $key . '/' . $val;
             } elseif (!is_array($val) && $val) {
                 $getter_line .= '/' . $key . '/' . $val;
             }
         }
         return $getter_line;
     }
 }
Exemple #2
0
 function buildPage($pagePath, $innerAccess = false)
 {
     global $_PATH;
     global $REQUEST_VARS, $REQUEST_ASSOC, $_COMMON_SITE_CONF;
     $this->_EVM->fire('agregator:start', $pagePath);
     if (!$innerAccess && ($url = $this->rewrite($pagePath))) {
         return $this->buildPage($url, true);
     }
     $this->modules_out = null;
     $this->globalFields = array();
     $_SESSION['pages']['previous_page_path'] = $_SESSION['pages']['current_page_full_path'];
     $_SESSION['pages']['current_page_full_path'] = $pagePath;
     if ($pos = strpos($pagePath, '@')) {
         $_SESSION['pages']['current_page_no_filter'] = substr($pagePath, 0, $pos - 1);
     }
     if (isset($_SESSION['fronted']['enabled'])) {
         $this->frontEditMode = true;
     }
     //отделяем переменные и action
     if (preg_match("/(\\;|\\)|\\'|\"|\\!|\\<|\\>|union)/", urldecode($pagePath))) {
         return false;
     }
     $pathExploded = explode('~', $pagePath);
     $_SESSION['pages']['current_page_path'] = $pathExploded[0];
     if (!isset($pathExploded[1]) && ($pos = strpos($pathExploded[0], '@'))) {
         $pathExploded[1] = substr($pathExploded[0], $pos - 1);
         $pathExploded[0] = substr($pathExploded[0], 0, $pos);
     }
     if (isset($pathExploded[1])) {
         $this->pageParams = $pathExploded[1];
         //разбор переменных GET оформление ассоциативных массивов arrayname/key=value&key1=value
         $this->requestVarsDetect($this->pageParams);
         $_SESSION['pages']['current_get_params'] = substr($this->pageParams, 1 + strpos($this->pageParams, '/'));
     }
     if (isset($pathExploded[0])) {
         if (preg_match('/[0-9a-z_\\-\\/]/', $pathExploded[0])) {
             $treePath = XARRAY::clearEmptyItems(explode('/', $pathExploded[0]), true);
         } else {
             return false;
         }
     }
     /*
      *   action всегда  $REQUEST_VARS[0];
      *  приоритет action из $REQUEST_VARS[0] всегда выше чем у модуля по умолчанию если данное дествие разрешено
      */
     //вызов модуля страниц
     $pages = xCore::moduleFactory('pages.front');
     //    $pages->createTest();
     if (!$pages->getPageIdByPath($pathExploded[0])) {
         return false;
     }
     //кросспост
     if ($_SESSION['POST']) {
         $_POST = $_SESSION['POST'];
         unset($_SESSION['POST']);
     }
     xCore::callCommonInstance('templates');
     $templates = templatesCommon::getInstance();
     if (!$pages->page['params']['Template']) {
         return;
     }
     $templates->refreshMainTpls();
     $this->mainTemplate = $templates->getTpl($pages->page['params']['Template'], HTTP_HOST);
     $slotzCrotch = $pages->getSlotzCrotch($this->mainTemplate['slotz']);
     //добываем модули слотов ветвления
     if (!empty($pages->modulesOrder)) {
         foreach ($pages->modulesOrder as $moduleId => $priority) {
             if ($module = $pages->execModules[$moduleId]) {
                 //всегда 1 экземпляр на уровне factory
                 if (is_object($moduleObject = xCore::moduleFactory($module['params']['Type'] . '.front'))) {
                     $moduleObject->requestActionSet($this->request_action);
                     $moduleTimeStart = Common::getmicrotime();
                     $modulesOut[$moduleId] = $moduleObject->execute($module['params']);
                     $modules_crotch[$mk]['params']['__moduleExecutionTime'] = Common::getmicrotime() - $moduleTimeStart;
                 }
             }
         }
     }
     global $time;
     $y = Common::getmicrotime();
     echo $y - $time . ' modules ready ';
     while (list($slot, $modules) = each($slotzCrotch)) {
         foreach ($modules as $moduleId) {
             if (!$this->frontEditMode) {
                 $this->slotzOut[$slot] .= $modulesOut[$moduleId];
             } else {
                 /*                        while (list($module_id, $mout) = each($out))
                                         {
                                             $out[$module_id] = '<map etime="' . $modules_crotch[$module_id]['_etime'] . '" template="' . $modules_crotch[$module_id]['Template'] . '" alias="' . $modules_crotch[$module_id]['Alias'] . '" mtype="' . $modules_crotch[$module_id]['type'] . '" class="__module" id="_m' . $module_id . '">' . $mout . '</map>';
                                         }
                                         $this->modules_out[$slot] = '<form  alias="' . $tpl_slotz_all[$slot]['SlotAlias'] . '" class="__slot" id="_s' . $tpl_slotz_id[$slot] . '">' . implode('', $out) . '</form>';    
                 */
             }
         }
     }
     /*  if (($this->frontEditMode) && ($tpl_slotz_all))
         {
             //добавляем пустые слоты для FED
             foreach ($tpl_slotz_all as $slot => $source)
             {
                 $this->modules_out[$slot] = '<form alias="' . $tpl_slotz_all[$slot]['SlotAlias'] . '" class="__slot" id="_s' . $tpl_slotz_id[$slot] . '"> </form>';
             }
         }*/
     return true;
 }
Exemple #3
0
 public function getPageIdByPath($path)
 {
     global $REQUEST_VARS;
     $treePath = XARRAY::clearEmptyItems(explode('/', $path), true);
     $this->root = $this->_tree->getNodeInfo(1);
     $this->domain = $this->_tree->selectStruct('*')->selectParams('*')->where(array('@basic', '=', HTTP_HOST), array('@ancestor', '=', 1))->run();
     $this->domain = $this->domain[0];
     $langVersions = $this->getLangVersions($this->domain['id']);
     $langVersionsStack = XARRAY::arr_to_keyarr($langVersions, 'id', 'basic');
     if (!$treePath) {
         if (!$this->domain['params']['StartPage']) {
             return;
         }
         //здесь заглушка - по умолчанию должен выбирать первую языковую версию если другое не указано
         $this->langVersion = $langVersions[$langVersionsStack[$this->domain['params']['StartPage']]];
         if (!$this->langVersion['params']['StartPage']) {
             return;
         }
         //здесь заглушка - по умолчанию должен выбирать первую страницу
         $this->page = $this->_tree->getNodeInfo($this->langVersion['params']['StartPage']);
         if ($this->pageFinalPoint() === false) {
             return false;
         } else {
             return true;
         }
     } else {
         if (($lang = array_search($treePath[0], $langVersionsStack) !== false) && $langVersions[$treePath[0]]) {
             $this->langVersion = $langVersions[$treePath[0]];
         } else {
             foreach ($langVersions as $lKey => $lVersion) {
                 if ($this->domain['params']['StartPage'] == $lVersion['id']) {
                     $this->langVersion = $langVersions[$lKey];
                 }
             }
             reset($langVersions);
             if (!$this->langVersion) {
                 $this->langVersion = current($langVersions);
             }
             array_unshift($treePath, $this->langVersion['basic']);
             $this->_commonObj->nativeLangVersion = $this->langVersion['basic'];
         }
         array_unshift($treePath, HTTP_HOST);
         if (!($node = $this->_tree->idByBasicPath($treePath, array('_DOMAIN', '_LVERSION', '_PAGE', '_GROUP'), true))) {
             return false;
         }
         $this->page = $this->_tree->getNodeInfo($node['id']);
         if ($this->page['obj_type'] == '_PAGE') {
             if ($this->_tree->readNodeParam($this->page['ancestor'], 'StartPage') == $this->page['id']) {
                 if (xRegistry::get('TPA')->pathParams) {
                     $pathParams = '/~' . xRegistry::get('TPA')->pathParams;
                 }
                 $this->move_301_permanent(CHOST . '/' . $this->_commonObj->createPagePath($this->page['id'], true) . $pathParams);
             }
         }
         if ($this->pageFinalPoint() === false) {
             return false;
         } else {
             $bones = array_slice($this->page['path'], 3);
             $bones[] = $this->page['id'];
             if (!empty($bones)) {
                 $this->bones = $this->_tree->selectStruct('*')->selectParams('*')->getBasicPath('/', true)->where(array('@id', '=', $bones))->format('keyval', 'id')->run();
             }
             array_unshift($this->bones, $this->langVersion);
             return true;
         }
     }
 }