The followings are the available columns in table 'cms_content':
Inheritance: extends CActiveRecord
Esempio n. 1
0
 private function _list($section, $limit)
 {
     $this->section = new CmsSection($section);
     $model = new CmsContent("published");
     $this->items = $model->filter("cms_section_id", $section)->limit($limit)->all();
     if (!$this->items->count()) {
         $this->items = array();
     }
 }
Esempio n. 2
0
 public function slot($slot, $parentId = 0)
 {
     // Try to load missing content from database
     // (e.g. for alias content that is not directly assigned to page)
     if (!isset($this->contents[$parentId][$slot])) {
         $contents = CmsContent::model()->findAllByAttributes(array('parentId' => $parentId, 'slot' => $slot));
         if (count($contents)) {
             $this->contents[$parentId][$slot] = $contents;
         }
     }
     // Run widget for each content that is assigned to current slot
     // and has current content as a parent
     if (isset($this->contents[$parentId][$slot])) {
         if ($this->adminMode) {
             echo '<div class="cms-slot">';
         }
         foreach ($this->contents[$parentId][$slot] as $content) {
             if ($content->module != '' && $content->action != '') {
                 $this->forward($content->module . '/frontend/' . $content->action);
             } else {
                 echo $this->runWidget($content);
             }
         }
         if ($this->adminMode) {
             echo '</div>';
         }
     }
 }
Esempio n. 3
0
 public function related()
 {
     $this->use_layout = false;
     $this->use_view = "_related_list";
     $this->article_offset = 0;
     if (Request::post('page_number') && Request::post('section')) {
         $page = parse_url(Request::post('page_number'));
         $page = str_replace("page=", "", $page['query']);
         if ($page && Request::post('section')) {
             $this->this_page = $page;
             $section = new CmsSection();
             $content = new CmsContent("published");
             $this->cms_section = $section->filter(array('url' => Request::post('section')))->first();
             if ($this->cms_section->id) {
                 $this->cms_section_id = $this->cms_section->id;
                 $this->cms_content = $content->filter(array('cms_section_id' => $this->cms_section_id))->order('published DESC')->page($this->this_page, $this->per_page);
             }
         }
     }
 }
 /**
  * big conversion function - takes old users & old content records and
  * convert them to the new ones
  */
 public function upgrade()
 {
     /* users */
     echo "converting cms_user...\n";
     $cms_user = new CmsUser();
     $oldusers = $cms_user->find_all();
     if (count($oldusers)) {
         echo "  " . count($oldusers) . " users found... moving to wildfire_user..\n";
         foreach ($oldusers as $olduser) {
             $user = new WildfireUser();
             $data = array('username' => $olduser->username, 'firstname' => $olduser->firstname, 'surname' => $olduser->surname, 'email' => $olduser->email, 'password' => $olduser->password, 'usergroup' => $olduser->usergroup);
             $user->update_attributes($data);
             echo '  converted: ' . $data['username'] . ' (' . $data['usergroup'] . ")\n";
         }
         echo "  all users converted..\n\n";
     } else {
         echo "  no users found\n\n";
     }
     /* convert sections - err, maybe later; tree structures */
     /* convert content*/
     echo "converting cms_content...\n";
     $old = new CmsContent();
     $oldcontents = $old->find_all();
     if (count($oldcontents) > 0) {
         echo "  " . count($oldcontents) . " content found... moving to wildfire_content..\n";
         foreach ($oldcontents as $oldcontent) {
             $content = new WildfireContent();
             $data = array('title' => $oldcontent->title, 'excerpt' => $oldcontent->excerpt, 'content' => $oldcontent->content, 'status' => $oldcontent->status, 'published' => $oldcontent->published, 'expires' => $oldcontent->expires, 'date_modified' => $oldcontent->date_modified, 'date_created' => $oldcontent->date_created, 'sort' => $oldcontent->sort, 'pageviews' => $oldcontent->pageviews, 'url' => $oldcontent->url, 'cms_section_id' => $oldcontent->cms_section_id, 'oldid' => $oldcontent->id);
             //find the author
             $oldauthor = new CmsUser($oldcontent->author_id);
             $author = new WildfireUser();
             $author = $author->filter(array('username' => $oldauthor->username, 'password' => $oldauthor->password))->first();
             $content = $content->update_attributes($data);
             $content->author = $author;
             echo "   converted: " . $data['title'] . '(' . $data['published'] . ")\n";
         }
         echo "  all content converted\n\n";
     } else {
         echo "  no content found..\n\n";
     }
 }
Esempio n. 5
0
 public function published_content()
 {
     $content = new CmsContent();
     return $content->filter(array($this->get_col("content")->join_field => $this->primval, "status" => array(0, 1)))->all();
 }
Esempio n. 6
0
 /**
  * Special conversion function - takes the details in the old cms switches it over the the new cms
  **/
 public function port_content()
 {
     $content = new CmsContent();
     $articles = $content->find_all(array("order" => "id ASC"));
     $new = new WildfireFile();
     foreach ($articles as $article) {
         $oldimgs = $new->sql("SELECT * FROM cms_content_cms_file WHERE cms_content_id = {$article->id}")->all();
         foreach ($oldimgs as $img) {
             $newimg = $new->clear()->filter("oldid=" . $img->cms_file_id)->first();
             $newfile = new WildfireFile($newimg->id);
             if ($newfile->id) {
                 $article->images = $newfile;
             }
         }
     }
 }
Esempio n. 7
0
 public function actionDeleteblock()
 {
     if (Yii::app()->request->isPostRequest) {
         // we only allow deletion via POST request
         $model = $this->loadModel();
         $cms = CmsContent::model()->findByAttributes(array('nodeId' => $model->id));
         $model->delete();
         $cms->delete();
         // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
         if (!isset($_POST['ajax'])) {
             $this->redirect(array('/cms/admin/blocks'));
         }
     } else {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
 }
Esempio n. 8
0
 public function find_most_commented($section = "1", $since = "7", $limit = "10")
 {
     $content = new CmsContent();
     $sections = new CmsSection();
     if ($section && !is_numeric($section)) {
         $section = $sections->filter(array('url' => $section))->first()->id;
     }
     $sql = "SELECT *, count(attached_id) as counter FROM `cms_comment` RIGHT JOIN cms_content ON attached_id=cms_content.id WHERE cms_comment.status=1 AND `time` > date_sub(now(), INTERVAL '{$since}' DAY)";
     if ($section) {
         $sql .= " AND cms_section_id={$section}";
     }
     $sql .= " GROUP BY attached_id ORDER BY counter DESC LIMIT {$limit}";
     return $content->find_by_sql($sql);
 }
 public function create()
 {
     $this->display_action_name = 'Create';
     $model = $this->model;
     $this->model = new Campaign();
     $this->model->ClientID = $this->cm_conf['campaign_monitor_ClientID'];
     Session::unset_var('user_errors');
     //remove old errors;
     if ($this->model->is_posted()) {
         $this->model = $this->model->handle_post();
         $errors = "";
         if (count($this->model->errors)) {
             $errors .= "<br />" . implode("<br />", $this->model->errors);
         }
         if (strlen($errors) > 0) {
             $errors .= ":";
             foreach ($this->model->errors as $k => $val) {
                 $errors .= $val . "<br />";
             }
             Session::add_message('There was an error creating you campaign.' . $errors);
         } else {
             Session::add_message('Your campaign has been created!');
             $this->redirect_to('/admin/email');
         }
     }
     $lists = $model->GetLists();
     $this->mail_lists = array_merge(array('' => array('ListID' => '', 'Name' => 'None')), $lists->rowset);
     $segments = $model->GetSegments();
     $this->segments = array_merge(array('' => array('ListID' => '', 'Name' => 'None')), $segments->rowset);
     $cont = new CmsContent("published");
     $this->contents = $cont->all();
     $this->form = $this->render_partial("form");
 }
Esempio n. 10
0
 /**
  * home page - shows statistical summaries
  **/
 public function index()
 {
     $this->stat_links = $this->pageview_data();
     if (!$this->stat_links) {
         $this->stat_links = array();
     }
     $this->stat_search = $this->searchrefer_data();
     if (!$this->stat_search) {
         $this->stat_search = array();
     }
     unset($this->sub_links["index"]);
     $content = new CmsContent();
     $this->recent_content = $content->limit(10)->filter("status < 3")->order("published DESC")->all();
     $this->can_see_stats = $this->can_see_stats();
 }
Esempio n. 11
0
 /**
  * big monster that finds content
  * - if the url exists (ie not false) then find content in following priority
  *   - content with correct url in the correct section
  *   - content with correct url, discounting the section
  *   - otherwise throw a 404 
  * - if url is false 
  *   - find all the content pages inside the current section
  *
  * NOTE: If your logged in to the admin area - unpublished content items are accessible via the permalink, but will not show in lists
  *
  * @param string $url 
  */
 protected function find_content($url)
 {
     $content = new CmsContent();
     if ($url) {
         if (!($this->cms_content = $content->scope("published")->filter(array('url' => $url, 'cms_section_id' => $this->cms_section->id))->first())) {
             //first look inside the section
             $this->cms_content = $content->clear()->scope("published")->filter(array('url' => $url))->first();
         }
         //then look anywhere for the matched url
         //print_r(Session::get("wildfire_language_id")); exit;
         if (count($this->languages) > 1 && ($lang_id = Session::get("wildfire_language_id")) && $this->languages[$lang_id] && $this->cms_content) {
             //look for another language version
             if ($logged_in) {
                 $access_filter = array("status" => array(5, 6));
             } else {
                 $access_filter = array("status" => 6);
             }
             $lang_content = $content->clear()->scope("published")->filter(array("preview_master_id" => $this->cms_content->primval, "language" => $lang_id))->first();
             if ($lang_content) {
                 $this->cms_content = $lang_content;
             }
         }
         if (Request::get("preview") && $this->is_admin_logged_in()) {
             if ($cms_content) {
                 $this->cms_content = $content->clear()->filter(array("preview_master_id" => $this->cms_content->primval))->first();
             } else {
                 $this->cms_content = $content->clear()->filter(array("status" => array(0, 1, 4), "url" => $url))->order("status DESC")->first();
             }
         }
         if (!$this->cms_content) {
             throw new WXRoutingException('The page you are looking for is not available', "Page not found", '404');
         }
     } else {
         $filter = array('cms_section_id' => $this->cms_section->id);
         if (!$this->this_page) {
             $this->cms_content = $content->scope("published")->filter($filter)->all();
         } else {
             $this->cms_content = $content->scope("published")->filter($filter)->page($this->this_page, $this->per_page);
         }
     }
 }
Esempio n. 12
0
 public function articles()
 {
     $content = new CmsContent("published");
     return $content->filter(array("author_id" => $this->id))->all();
 }
Esempio n. 13
0
 public function run()
 {
     $aliasContent = CmsContent::model()->findByPk($this->content->data);
     Yii::app()->controller->runWidget($aliasContent);
 }
 public function status()
 {
     if ($id = Request::get('id')) {
         $content = new CmsContent($id);
         if (isset($_GET['status'])) {
             $content->status = Request::get('status');
         }
         $this->row = $content->save();
         if (Request::get('ajax')) {
             $this->use_layout = false;
         } else {
             $this->redirect_to(Session::get('list_refer'));
         }
     } else {
         $this->redirect_to("/admin/home");
     }
 }