Beispiel #1
0
 protected function actionContent($params)
 {
     if (!isset($params['slug'])) {
         $params['slug'] = '';
     }
     $content = \GO\Site\Model\Content::model()->findBySlug($params['slug']);
     if (!$content) {
         header("HTTP/1.0 404 Not Found");
         header("Status: 404 Not Found");
         echo $this->render('/site/404');
     } else {
         $this->setPageTitle($content->metaTitle);
         if (!empty($content->meta_description)) {
             \Site::scripts()->registerMetaTag($content->meta_description, 'description');
         }
         if (!empty($content->meta_keywords)) {
             \Site::scripts()->registerMetaTag($content->meta_keywords, 'keywords');
         }
         // Check if the template is not empty
         if (empty($content->template)) {
             $defaultTemplate = \Site::config()->getDefaultTemplate();
             if (!empty($defaultTemplate)) {
                 $content->template = $defaultTemplate;
             }
         }
         echo $this->render($content->template, array('content' => $content));
     }
 }
Beispiel #2
0
 static function render($params, $tag, \GO\Site\Model\Content $content)
 {
     $html = '<a';
     if (empty($params['slug']) && empty($params['path'])) {
         return "Error: slug or path must be set in link tag!";
     }
     if (isset($params['slug'])) {
         $params['slug'] = explode('#', $params['slug']);
         $model = Content::model()->findBySlug($params['slug'][0], $content->site_id);
         if (!$model) {
             return "Broken link to slug: '" . $params['slug'][0] . "'";
         }
         $params['href'] = $model->getUrl();
         if (isset($params['slug'][1])) {
             $params['href'] .= '#' . $params['slug'][1];
         }
     } else {
         $params['href'] = \Site::file($params['path'], false);
     }
     unset($params['anchor'], $params['slug'], $params['path']);
     foreach ($params as $key => $value) {
         $html .= ' ' . $key . '="' . $value . '"';
     }
     $html .= '>' . $tag['innerText'] . '</a>';
     return $html;
 }
Beispiel #3
0
 /**
  * Build the tree for the backend
  * 
  * @param array $params
  * @return array
  */
 protected function actionTree($params)
 {
     $response = array();
     if (!isset($params['node'])) {
         return $response;
     }
     $extractedNode = \GO\Site\SiteModule::extractTreeNode($params['node']);
     // 1_menuitem_6 = array('siteId' => '1','type' =>'menuitem','modelId' => '6');
     // 1_root = array('siteId' => '1','type' =>'root','modelId' => false);
     // 1_content = array('siteId' => '1','type' =>'content','modelId' => false);
     // 1_menu = array('siteId' => '1','type' =>'menu','modelId' => false);
     // 1_menu_1 = array('siteId' => '1','type' =>'menu','modelId' => '1');
     switch ($extractedNode['type']) {
         case 'root':
             $response = \GO\Site\Model\Site::getTreeNodes();
             break;
         case 'content':
             if (empty($extractedNode['modelId'])) {
                 $response = \GO\Site\Model\Site::getTreeNodes();
             } else {
                 $content = \GO\Site\Model\Content::model()->findByPk($extractedNode['modelId']);
                 if ($content) {
                     $response = $content->getChildrenTree();
                 }
             }
             break;
         case 'menu':
             $menu = \GO\Site\Model\Menu::model()->findByPk($extractedNode['modelId']);
             if ($menu) {
                 $response = $menu->getChildrenTree();
             }
             break;
         case 'menuitem':
             $menuitem = \GO\Site\Model\MenuItem::model()->findByPk($extractedNode['modelId']);
             if ($menuitem) {
                 $response = $menuitem->getChildrenTree();
             }
             break;
     }
     echo $this->renderJson($response);
 }
Beispiel #4
0
 private function _renderContentChildren($parent, $level = 0)
 {
     $itemHtml = '';
     $target = !empty($parent->target) ? ' target="' . $parent->target . '"' : '';
     $parentContentItem = \GO\Site\Model\Content::model()->findByPk($parent->content_id);
     foreach ($parentContentItem->children as $child) {
         $itemHtml .= strtr($this->itemTemplate, array('{item}' => $child->title, '{url}' => $child->getUrl(), '{target}' => $target, '{items}' => ''));
     }
     $html = '';
     if (!empty($itemHtml)) {
         $tpl = $this->template;
         // If this is the root UL
         if ($parent instanceof \GO\Site\Model\Menu) {
             $options = $this->htmlOptions;
             array_walk($options, create_function('&$i,$k', '$i=" $k=\\"$i\\"";'));
             $options = implode($options, "");
             $tpl = preg_replace('/>/', $options . '>', $tpl, 1);
         }
         $html = strtr($tpl, array('{items}' => $itemHtml));
     }
     return $html;
 }
Beispiel #5
0
 public function actionContentTree($params)
 {
     $response = array();
     if (empty($params['site_id'])) {
         throw new \Exception('No Site ID given!');
     }
     if (!isset($params['node'])) {
         return $response;
     }
     $site = Site::model()->findByPk($params['site_id']);
     $args = explode('_', $params['node']);
     $siteId = $args[0];
     if (!isset($args[1])) {
         $type = 'root';
     } else {
         $type = $args[1];
     }
     if (isset($args[2])) {
         $parentId = $args[2];
     } else {
         $parentId = null;
     }
     switch ($type) {
         case 'content':
             if ($parentId === null) {
                 $response = $site->loadContentNodes();
             } else {
                 $parentNode = \GO\Site\Model\Content::model()->findByPk($parentId);
                 if ($parentNode) {
                     $response = $parentNode->getChildrenTree();
                 }
             }
             break;
             //			case 'news':
             //				$response = \GO\Site\Model\News::getTreeNodes($site);
             //				break;
     }
     echo $this->renderJson($response);
 }
Beispiel #6
0
 public static function processLink($linkAttr, $completeXml)
 {
     $html = '<a';
     switch ($linkAttr['linktype']) {
         case 'content':
             // $linkAttr['contentid'] = '1';
             if (empty($linkAttr['contentid'])) {
                 $linkAttr['contentid'] = '0';
             }
             $content = Content::model()->findByPk((int) $linkAttr['contentid']);
             if ($content) {
                 $url = $content->url;
             } else {
                 $url = '#';
             }
             $html .= ' href="' . $url . '"';
             break;
         case 'file':
             // $linkAttr['path'] = 'public/site/1/files/1/contract.png';
             if (empty($linkAttr['path'])) {
                 $linkAttr['path'] = '#';
             }
             $html .= ' href="' . \Site::file($linkAttr['path'], false) . '"';
             break;
         case 'manual':
             // $linkAttr['url'] = 'www.google.nl';
             if (empty($linkAttr['url'])) {
                 $linkAttr['url'] = '#';
             }
             $html .= ' href="' . $linkAttr['url'] . '"';
             break;
     }
     if (isset($linkAttr['target'])) {
         $html .= ' target="_blank"';
     }
     if (!empty($linkAttr['title'])) {
         $html .= ' title="' . $linkAttr['title'] . '"';
     }
     $html .= '>';
     preg_match('/(<a[^>]*>)(.*?)(<\\/a>)/i', $completeXml, $matches);
     if (isset($matches[2])) {
         $html .= $matches[2];
     } else {
         $html .= 'LINK';
     }
     $html .= '</a>';
     return $html;
 }