Example #1
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;
 }
Example #2
0
 public function install()
 {
     if (GO::modules()->isInstalled('site')) {
         $alreadyExists = Site::model()->findSingleByAttribute('module', 'adminmanual');
         if (!$alreadyExists) {
             $siteProperties = array('name' => "Manual", 'user_id' => 1, 'domain' => '*', 'module' => 'manualsite', 'ssl' => '0', 'mod_rewrite' => '0', 'mod_rewrite_base_path' => '/', 'base_path' => '', 'language' => 'en');
             $defaultSite = new Site();
             $defaultSite->setAttributes($siteProperties);
             $defaultSite->save();
             $home = new GO\Site\Model\Content();
             $home->site_id = $defaultSite->id;
             $home->title = "Home";
             $home->slug = "";
             $home->template = "/manualsite/home";
             $home->save();
             $chapter = new GO\Site\Model\Content();
             $chapter->parent_id = $home->id;
             $chapter->site_id = $home->id;
             $chapter->title = "Example chapter";
             $chapter->content = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
             $chapter->slug = "example-chapter";
             $chapter->template = "/manualsite/content";
             $chapter->save();
             $sub = new GO\Site\Model\Content();
             $sub->parent_id = $chapter->id;
             $sub->site_id = $defaultSite->id;
             $sub->title = "Sub 1";
             $sub->content = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
             $sub->slug = "example-chapter";
             $sub->template = "/manualsite/content";
             $sub->save();
             $sub = new GO\Site\Model\Content();
             $sub->parent_id = $chapter->id;
             $sub->site_id = $defaultSite->id;
             $sub->title = "Sub 2";
             $sub->content = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
             $sub->slug = "example-chapter";
             $sub->template = "/manualsite/content";
             $sub->save();
         }
         $category = \GO\Customfields\Model\Category::model()->createIfNotExists("GO\\Site\\Model\\Site", "Extra");
         \GO\Customfields\Model\Field::model()->createIfNotExists($category->id, "Google tracking code");
     }
     return parent::install();
 }
Example #3
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;
 }
Example #4
0
 /**
  * Will select all content item from a website and pass them to the sitemap template
  * @param array $params [empty]
  */
 protected function actionSitemap($params)
 {
     $sitemap = \GO\Site\Model\Content::getTreeNodes(2);
     echo $this->render('sitemap', array('sitemap' => $sitemap));
 }
Example #5
0
 /**
  * Rearrange the tree based on the given sorting
  * 
  * @param array $params
  * @return array
  */
 protected function actionTreeSort($sortOrder, $parent)
 {
     //		EXAMPLE INPUT
     //		parent:1_menu_11
     //		sortOrder:["1_menuitem_30","1_menuitem_31","1_menuitem_33","1_menuitem_8"]
     $sortOrder = json_decode($sortOrder, true);
     $extractedParentNode = \GO\Site\SiteModule::extractTreeNode($parent);
     switch ($extractedParentNode['type']) {
         case 'content':
             $allowedTypes = array('content');
             return \GO\Site\Model\Content::setTreeSort($extractedParentNode, $sortOrder, $allowedTypes);
             break;
             //				case 'site':
             //					$allowedTypes = array('content');
             //					return \GO\Site\Model\Site::setTreeSort($extractedParentNode, $sortOrder, $allowedTypes);
             //					break;
         //				case 'site':
         //					$allowedTypes = array('content');
         //					return \GO\Site\Model\Site::setTreeSort($extractedParentNode, $sortOrder, $allowedTypes);
         //					break;
         case 'menu':
             $allowedTypes = array('menuitem');
             return \GO\Site\Model\Menu::setTreeSort($extractedParentNode, $sortOrder, $allowedTypes);
             break;
         case 'menuitem':
             $allowedTypes = array('menuitem');
             return \GO\Site\Model\MenuItem::setTreeSort($extractedParentNode, $sortOrder, $allowedTypes);
             break;
     }
 }
Example #6
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);
 }
Example #7
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;
 }