Example #1
0
 protected function actionSubmit($params)
 {
     $model = \GO\Site\Model\Site::model()->createOrFindByParams($params);
     $model->setAttributes($params);
     $model->save();
     echo $this->renderSubmit($model);
 }
Example #2
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 #3
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 #4
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 #5
0
 /**
  * Find a content item by it's slug (and siteId)
  * 
  * @param string $slug
  * @param int $siteId
  * @return Content
  * @throws \GO\Base\Exception\NotFound
  */
 public static function findBySlug($slug, $siteId = false)
 {
     if (!$siteId) {
         $siteId = \Site::model()->id;
     }
     //		 if(!$siteId)
     //			$model = self::model()->findSingleByAttribute('slug', $slug);
     //		 else
     $model = self::model()->findSingleByAttributes(array('slug' => $slug, 'site_id' => $siteId));
     if (!$model) {
         return false;
     }
     //Throw new \GO\Base\Exception\NotFound('There is no page found with the slug: '.$slug);
     return $model;
 }
Example #6
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();
 }