Example #1
0
 public function __construct(\GO\Site\Model\Site $siteModel)
 {
     $file = new \GO\Base\Fs\File($siteModel->getSiteModule()->moduleManager->path() . 'siteconfig.php');
     if ($file->exists()) {
         require $file->path();
     }
     if (isset($siteconfig)) {
         $this->_configOptions = $siteconfig;
     }
 }
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
 /**
  * # Backend Functionality
  * 
  * Get the tree array for the children of the current item
  * 
  * @return array
  */
 public function getMenuChildrenTree()
 {
     $tree = array();
     $children = $this->children;
     foreach ($children as $child) {
         $hasChildren = $child->hasChildren();
         $childNode = array('id' => $this->site_id . '_menuitem_' . $child->id, 'menu_id' => $this->id, 'menu_item_id' => $child->id, 'cls' => 'site-node-menuitem', 'site_id' => $this->site_id, 'iconCls' => 'go-model-icon-Menuitem', 'text' => $child->label, 'hasChildren' => $hasChildren, 'expanded' => !$hasChildren || \GO\Site\Model\Site::isExpandedNode($this->site_id . '_menu_' . $child->id), 'children' => $hasChildren ? null : $child->getChildrenTree());
         $tree[] = $childNode;
     }
     return $tree;
 }
Example #4
0
 public function install()
 {
     if (\GO::modules()->isInstalled('site')) {
         $alreadyExists = \GO\Site\Model\Site::model()->findSingleByAttribute('module', 'defaultsite');
         if (!$alreadyExists) {
             $siteProperties = array('name' => \GO::t('name', 'defaultsite'), 'user_id' => 1, 'domain' => '*', 'module' => 'defaultsite', 'ssl' => '0', 'mod_rewrite' => '0', 'mod_rewrite_base_path' => '/', 'base_path' => '', 'language' => '');
             $defaultSite = new \GO\Site\Model\Site();
             $defaultSite->setAttributes($siteProperties);
             $defaultSite->save();
         }
     }
     return parent::install();
 }
Example #5
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);
 }
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 processImage($imageAttr)
 {
     //		if(key_exists('width', $imageAttr)){}
     //		if(key_exists('height', $imageAttr)){}
     //		if(key_exists('zoom', $imageAttr)){}
     //		if(key_exists('crop', $imageAttr)){}
     //		if(key_exists('alt', $imageAttr)){}
     //		if(key_exists('a', $imageAttr)){}
     //		if(key_exists('path', $imageAttr)){}
     //		if(key_exists('align', $imageAttr)){}
     $html = '';
     if (key_exists('path', $imageAttr)) {
         if (key_exists('width', $imageAttr) && key_exists('height', $imageAttr)) {
             if (key_exists('crop', $imageAttr)) {
                 $thumb = \Site::thumb($imageAttr['path'], array("lw" => $imageAttr['width'], "ph" => $imageAttr['height'], "zc" => 1));
             } else {
                 $thumb = \Site::thumb($imageAttr['path'], array("lw" => $imageAttr['width'], "ph" => $imageAttr['height'], "zc" => 0));
             }
             if (isset($imageAttr['link_to_original'])) {
                 $imageAttr['href'] = \Site::file($imageAttr['path'], false);
                 // Create an url to the original image
                 $imageAttr['data-lightbox'] = $imageAttr['path'];
             }
         } else {
             $thumb = \Site::file($imageAttr['path']);
         }
         $html .= '<img src="' . $thumb . '"';
         if (key_exists('alt', $imageAttr)) {
             $html .= ' alt="' . $imageAttr['alt'] . '"';
         }
         if (key_exists('align', $imageAttr)) {
             $html .= ' style="' . $imageAttr['align'] . '"';
         } else {
             $html .= ' style="display:inline-block;"';
         }
         $html .= ' />';
         if (key_exists('href', $imageAttr)) {
             $target = '';
             if (isset($imageAttr['target'])) {
                 $target = ' target="' . $imageAttr['target'] . '"';
             }
             $a = '<a ';
             if (isset($imageAttr['data-lightbox'])) {
                 $a .= 'data-lightbox="' . $imageAttr['data-lightbox'] . '"';
             }
             $a .= 'href="%s"' . $target . '>%s</a>';
             $html = sprintf($a, $imageAttr['href'], $html);
         }
     }
     return $html;
 }
Example #8
0
 public function getTreeNodeAttributes()
 {
     $hasChildren = $this->hasChildren();
     return array('id' => $this->site_id . '_content_' . $this->id, 'site_id' => $this->site_id, 'content_id' => $this->id, 'slug' => $this->slug, 'cls' => 'site-node-content', 'iconCls' => 'go-model-icon-GO_Site_Model_Content', 'expanded' => !$hasChildren || \GO\Site\Model\Site::isExpandedNode($this->site_id . '_content_' . $this->id), 'hasChildren' => $hasChildren, 'children' => $hasChildren ? $this->getChildrenTree() : array(), 'text' => $this->title, 'qtip' => 'Drag me to the editor to create a link.');
 }
Example #9
0
 /**
  * Find's the site model by server name or GET param site_id and runs the site.
  * 
  * @throws \GO\Base\Exception\NotFound
  */
 public static function launch($site_id = null)
 {
     if (isset($site_id)) {
         self::$_site = \GO\Site\Model\Site::model()->findByPk($site_id, false, true);
         // Find the website model from its id
     } else {
         if (isset($_GET['site_id'])) {
             GO::session()->values['site_id'] = $_GET['site_id'];
         }
         if (isset(GO::session()->values['site_id'])) {
             self::$_site = \GO\Site\Model\Site::model()->findByPk(GO::session()->values['site_id'], false, true);
         } else {
             self::$_site = \GO\Site\Model\Site::model()->findSingleByAttribute('domain', $_SERVER["SERVER_NAME"]);
         }
         // Find the website model from its domainname
     }
     if (!self::$_site) {
         self::$_site = \GO\Site\Model\Site::model()->findSingleByAttribute('domain', '*');
     }
     // Find the website model from its domainname
     if (!self::$_site) {
         throw new \GO\Base\Exception\NotFound('Website for domain ' . $_SERVER["SERVER_NAME"] . ' not found in database');
     }
     \GO::session()->loginWithCookies();
     if (!empty(self::model()->language)) {
         \GO::language()->setLanguage(self::model()->language);
     }
     self::router()->runController();
 }