public function execute()
 {
     $domain_id = $this->get('domain_id', true);
     $route = $this->get('route');
     if ($route) {
         $route = urldecode($route);
     }
     $content = $this->get('content');
     $page_model = new sitePageModel();
     $pages = $page_model->getByDomain($domain_id, $route, $content);
     if ($this->get('params') && $pages) {
         $params_model = new sitePageParamsModel();
         $rows = $params_model->getByField('page_id', array_keys($pages), true);
         foreach ($rows as $row) {
             $pages[$row['page_id']]['params'][$row['name']] = $row['value'];
         }
     }
     $tree = $this->get('tree');
     if ($tree == null || $tree) {
         foreach ($pages as $page_id => $page) {
             if ($page['parent_id'] && isset($pages[$page['parent_id']])) {
                 $pages[$page['parent_id']]['childs'][] =& $pages[$page_id];
             }
         }
         foreach ($pages as $page_id => $page) {
             if ($page['parent_id']) {
                 unset($pages[$page_id]);
             }
         }
     }
     $this->response['pages'] = array_values($pages);
 }
Ejemplo n.º 2
0
 public function page($id)
 {
     $page_model = new sitePageModel();
     $page = $page_model->getById($id);
     $page['content'] = $this->wa->getView()->fetch('string:' . $page['content']);
     $page_params_model = new sitePageParamsModel();
     $page += $page_params_model->getById($id);
     return $page;
 }
Ejemplo n.º 3
0
 public function getPage($url = null)
 {
     if ($url === null) {
         $url = wa()->getRouting()->getCurrentUrl();
     }
     $route = wa()->getRouting()->getRoute('url');
     $page_model = new sitePageModel();
     if (substr($url, -1) !== '/' && strpos(substr($url, -5), '.') === false) {
         if ($page = $page_model->getByUrl($this->getDomainId(), $route, $url . '/')) {
             $url = waSystem::getInstance()->getConfig()->getRequestUrl(false);
             if (($i = strpos($url, '?')) === false) {
                 wa()->getResponse()->redirect($url . '/');
             } else {
                 wa()->getResponse()->redirect(substr($url, 0, $i) . '/' . substr($url, $i));
             }
         }
     }
     $page = $page_model->getByUrl($this->getDomainId(), $route, $url);
     if (!$page) {
         return array();
     }
     if (!$page['status']) {
         $app_settings_model = new waAppSettingsModel();
         $hash = $app_settings_model->get('site', 'preview_hash');
         if (!$hash || md5($hash) != waRequest::get('preview')) {
             return array();
         }
     }
     $params_model = new sitePageParamsModel();
     if ($params = $params_model->getById($page['id'])) {
         $page += $params;
     }
     if (!$page['title']) {
         $page['title'] = $page['name'];
     }
     //$page['url'] = wa()->getAppUrl().$page['url'];
     foreach ($page as $k => $v) {
         if ($k != 'content') {
             $page[$k] = htmlspecialchars($v);
         }
     }
     return $page;
 }