Exemplo n.º 1
0
 /**
  * Provides functionality to view a given profile
  * @param  int 	  $id          The ID belonging to the user
  * @param  string $displayName The user's display name. This isn't super necessary, it just is better for SEO
  */
 public function actionIndex($id = NULL, $displayName = NULL)
 {
     // If an ID isn't provided, throw an error
     if ($id === NULL) {
         throw new CHttpException(404, Yii::t('ciims.controllers.Profile', "Oops! That user doesn't exist on our network!"));
     }
     // For SEO, if the display name isn't in the url, reroute it
     if ($id !== NULL && $displayName === NULL) {
         $model = Users::model()->findByPk($id);
         if ($model === NULL || $model->status == 0) {
             throw new CHttpException(404, Yii::t('ciims.controllers.Profile', "Oops! That user doesn't exist on our network!"));
         } else {
             $this->redirect('/profile/' . $model->id . '/' . preg_replace('/[^\\da-z]/i', '', $model->displayName));
         }
     }
     $model = Users::model()->findByPk($id);
     // Don't allow null signings or invalidated users to pollute our site
     if ($model->status == 0) {
         throw new CHttpException(404, Yii::t('ciims.controllers.Profile', "Oops! That user doesn't exist on our network!"));
     }
     $this->pageTitle = $model->displayName . ' | ' . Cii::getConfig('name', Yii::app()->name);
     $postsCriteria = Content::model()->getBaseCriteria()->addCondition('type_id=2')->addCondition('password=""')->addCondition('author_id=:id');
     $postsCriteria->params = array(':id' => $id);
     $contentCount = Content::model()->count($postsCriteria);
     $this->render('index', array('model' => $model, 'contentCount' => $contentCount));
 }
Exemplo n.º 2
0
 /**
  * On given Content Class and id redirect the user to it.
  */
 public function actionContent()
 {
     $content = Content::model()->findByAttributes(array('object_model' => Yii::app()->request->getParam('model'), 'object_id' => Yii::app()->request->getParam('id')));
     if ($content != null) {
         $url = $this->createUrl('WallEntry', array('id' => $content->getFirstWallEntryId()));
         $this->redirect($url);
         return;
     }
     $id = (int) Yii::app()->request->getParam('id', "");
     $model = Yii::app()->request->getParam('model');
     // Check given model
     if (!class_exists($model)) {
         throw new CHttpException(404, Yii::t('WallModule.controllers_PermaController', 'Unknown content class!'));
     }
     // Load Model and check type
     $foo = new $model();
     if (!$foo instanceof HActiveRecordContent && !$foo instanceof HActiveRecordContentAddon) {
         throw new CHttpException(404, Yii::t('WallModule.controllers_PermaController', 'Invalid content class!'));
     }
     $model = call_user_func(array($model, 'model'));
     $object = $model->findByPk($id);
     if ($object == null) {
         throw new CHttpException(404, Yii::t('WallModule.controllers_PermaController', 'Could not find requested content!'));
     }
     $url = $this->createUrl('WallEntry', array('id' => $object->content->getFirstWallEntryId()));
     $this->redirect($url);
 }
Exemplo n.º 3
0
 public function prepareMenu()
 {
     switch ($this->lang) {
         case 19:
             $this->menu = array(0 => array('class' => 'card', 'model' => Content::model()->findByPk(1)), 1 => array('class' => 'product', 'model' => Content::model()->findByPk(2)), 2 => array('class' => 'gift', 'model' => Content::model()->findByPk(3)), 3 => array('class' => 'week l1', 'model' => Content::model()->findByPk(4)));
             $this->innerMenu = array(0 => array('class' => 'bottle_product', 'model' => CatalogCategories::model()->findByPk(1)), 1 => array('class' => 'alcohol_product', 'model' => CatalogCategories::model()->findByPk(2)), 2 => array('class' => 'fizz_product', 'model' => CatalogCategories::model()->findByPk(3)), 3 => array('class' => 'accessories_product', 'model' => CatalogCategories::model()->findByPk(4)), 4 => array('class' => 'read_wine_product', 'model' => NewsCategories::model()->findByPk(15)), 5 => array('class' => 'boutique_product', 'model' => null, 'url' => '/boutiques', 'name' => 'О бутиках'));
             $this->catalogMenu = array(0 => array('class' => 'bottle', 'model' => CatalogCategories::model()->findByPk(1)), 1 => array('class' => 'alcohol', 'model' => CatalogCategories::model()->findByPk(2)), 2 => array('class' => 'fizz', 'model' => CatalogCategories::model()->findByPk(3)), 3 => array('class' => 'accessories', 'model' => CatalogCategories::model()->findByPk(4)), 4 => array('class' => 'read_wine', 'model' => NewsCategories::model()->findByPk(15)), 5 => array('class' => 'boutique', 'model' => null, 'url' => '/boutiques', 'name' => 'О бутиках'));
             break;
         case 20:
             $this->menu = array(0 => array('class' => 'card l1', 'model' => Content::model()->findByPk(10)), 1 => array('class' => 'product l1', 'model' => Content::model()->findByPk(11)), 2 => array('class' => 'gift l1', 'model' => Content::model()->findByPk(12)), 3 => array('class' => 'week l1', 'model' => Content::model()->findByPk(13)));
             $this->innerMenu = array(0 => array('class' => 'bottle_product', 'model' => CatalogCategories::model()->findByPk(5)), 1 => array('class' => 'alcohol_product', 'model' => CatalogCategories::model()->findByPk(6)), 2 => array('class' => 'fizz_product', 'model' => CatalogCategories::model()->findByPk(7)), 3 => array('class' => 'accessories_product', 'model' => CatalogCategories::model()->findByPk(8)), 4 => array('class' => 'read_wine_product', 'model' => NewsCategories::model()->findByPk(9)), 5 => array('class' => 'boutique_product', 'model' => null, 'url' => '/boutiques', 'name' => 'About boutiques'));
             $this->catalogMenu = array(0 => array('class' => 'bottle', 'model' => CatalogCategories::model()->findByPk(5)), 1 => array('class' => 'alcohol', 'model' => CatalogCategories::model()->findByPk(6)), 2 => array('class' => 'fizz', 'model' => CatalogCategories::model()->findByPk(7)), 3 => array('class' => 'accessories', 'model' => CatalogCategories::model()->findByPk(8)), 4 => array('class' => 'read_wine', 'model' => NewsCategories::model()->findByPk(9)), 5 => array('class' => 'boutique', 'model' => null, 'url' => '/boutiques', 'name' => 'About boutiques'));
             break;
         case 21:
             $this->menu = array(0 => array('class' => 'card', 'model' => Content::model()->findByPk(14)), 1 => array('class' => 'product l1', 'model' => Content::model()->findByPk(15)), 2 => array('class' => 'gift', 'model' => Content::model()->findByPk(16)), 3 => array('class' => 'week l1', 'model' => Content::model()->findByPk(17)));
             $this->innerMenu = array(0 => array('class' => 'bottle_product', 'model' => CatalogCategories::model()->findByPk(9)), 1 => array('class' => 'alcohol_product', 'model' => CatalogCategories::model()->findByPk(10)), 2 => array('class' => 'fizz_product', 'model' => CatalogCategories::model()->findByPk(11)), 3 => array('class' => 'accessories_product', 'model' => CatalogCategories::model()->findByPk(12)), 4 => array('class' => 'read_wine_product', 'model' => NewsCategories::model()->findByPk(10)), 5 => array('class' => '', 'model' => null, 'url' => '/boutiques', 'name' => 'Boutiques'));
             $this->catalogMenu = array(0 => array('class' => 'bottle', 'model' => CatalogCategories::model()->findByPk(9)), 1 => array('class' => 'alcohol', 'model' => CatalogCategories::model()->findByPk(10)), 2 => array('class' => 'fizz', 'model' => CatalogCategories::model()->findByPk(11)), 3 => array('class' => 'accessories', 'model' => CatalogCategories::model()->findByPk(12)), 4 => array('class' => 'read_wine', 'model' => NewsCategories::model()->findByPk(10)), 5 => array('class' => 'boutique', 'model' => null, 'url' => '/boutiques', 'name' => 'Boutiques'));
             break;
         default:
             $this->menu = array(0 => array('class' => 'card l1', 'model' => Content::model()->findByPk(1)), 1 => array('class' => 'product l1', 'model' => Content::model()->findByPk(2)), 2 => array('class' => 'gift l1', 'model' => Content::model()->findByPk(3)), 3 => array('class' => 'week l1', 'model' => Content::model()->findByPk(4)));
             $this->innerMenu = array(0 => array('class' => 'bottle_product', 'model' => CatalogCategories::model()->findByPk(1)), 1 => array('class' => 'alcohol_product', 'model' => CatalogCategories::model()->findByPk(2)), 2 => array('class' => 'fizz_product', 'model' => CatalogCategories::model()->findByPk(3)), 3 => array('class' => 'accessories_product', 'model' => CatalogCategories::model()->findByPk(4)), 4 => array('class' => 'read_wine_product', 'model' => NewsCategories::model()->findByPk(15)), 5 => array('class' => 'boutique_product', 'model' => null, 'url' => '/boutiques', 'name' => 'О бутиках'));
             $this->catalogMenu = array(0 => array('class' => 'bottle', 'model' => CatalogCategories::model()->findByPk(1)), 1 => array('class' => 'alcohol', 'model' => CatalogCategories::model()->findByPk(2)), 2 => array('class' => 'fizz', 'model' => CatalogCategories::model()->findByPk(3)), 3 => array('class' => 'accessories', 'model' => CatalogCategories::model()->findByPk(4)), 4 => array('class' => 'read_wine', 'model' => NewsCategories::model()->findByPk(15)), 5 => array('class' => 'boutique', 'model' => null, 'url' => '/boutiques', 'name' => 'О бутиках'));
             break;
     }
 }
Exemplo n.º 4
0
 public function run()
 {
     parent::run();
     $data['cnn'] = Content::model()->findAll(array("condition" => "category_id = 31 and state = 1", "order" => "id desc", "limit" => 6));
     $data['count'] = Content::model()->count(array("condition" => "category_id = 31 and state = 1", "order" => "id desc"));
     $this->render('study_by_cnn', $data);
 }
Exemplo n.º 5
0
 /**
  * On run of integrity check command, validate all wall data
  *
  * @param type $event
  */
 public static function onIntegrityCheck($event)
 {
     $integrityChecker = $event->sender;
     $integrityChecker->showTestHeadline("Validating Wall Module (" . WallEntry::model()->count() . " entries)");
     foreach (WallEntry::model()->with('content')->findAll() as $w) {
         if ($w->content === null) {
             $integrityChecker->showFix("Deleting wall entry id " . $w->id . " without assigned wall entry!");
             if (!$integrityChecker->simulate) {
                 $w->delete();
             }
             continue;
         }
     }
     //TODO: Maybe not the best place for that
     $integrityChecker->showTestHeadline("Validating Content Objects (" . Content::model()->count() . " entries)");
     foreach (Content::model()->findAll() as $content) {
         if ($content->user == null) {
             $integrityChecker->showFix("Deleting content id " . $content->id . " of type " . $content->object_model . " without valid user!");
             if (!$integrityChecker->simulate) {
                 $content->delete();
             }
             continue;
         }
         if ($content->getUnderlyingObject() == null) {
             $integrityChecker->showFix("Deleting content id " . $content->id . " of type " . $content->object_model . " without valid content object!");
             if (!$integrityChecker->simulate) {
                 $content->delete();
             }
             continue;
         }
     }
 }
Exemplo n.º 6
0
 public function run()
 {
     parent::run();
     $data = array();
     $id_listen_cat = Category::model()->findAll("taxonomy_id = " . $this->_id_bai_hoc . " and state = 1");
     $id_listen_cat_array = array();
     foreach ($id_listen_cat as $k) {
         $id_listen_cat_array[] = $k->id;
     }
     $id_news_cat = Category::model()->findAll("taxonomy_id = " . $this->_id__tintuc . " and state = 1");
     $id_news_cat_array = array();
     foreach ($id_news_cat as $k) {
         $id_news_cat_array[] = $k->id;
     }
     $comment = Comment::model()->findAll(array("condition" => "state = 1", "limit" => 5, "order" => "id desc"));
     $options = array();
     $i = 0;
     foreach ($comment as $k) {
         $options[$i]['content'] = Content::model()->findByPk($k->content_id);
         $options[$i]['category'] = Category::model()->findByPk($options[$i]['content']->category_id);
         $options[$i]['parent'] = '';
         if ($options[$i]['category']->parent != 0) {
             $options[$i]['parent'] = Category::model()->findByPk($options[$i]['category']->parent);
         }
         $options[$i]['taxonomy'] = Taxonomy::model()->findByPk($options[$i]['category']->taxonomy_id);
         $i++;
     }
     $data['comments'] = $comment;
     $data['options'] = $options;
     $data['news'] = Content::model()->findAll(array("condition" => "state = 1 and category_id in (" . implode(",", $id_news_cat_array) . ")", "limit" => 10, "order" => "id desc"));
     $data['listen'] = Content::model()->findAll(array("condition" => "state = 1 and category_id in (" . implode(",", $id_listen_cat_array) . ")", "limit" => 10, "order" => "id desc"));
     $this->render('news_lession_comment', $data);
 }
Exemplo n.º 7
0
 public function run()
 {
     parent::run();
     $data['new_music'] = Content::model()->findAll(array("condition" => "category_id = 33 and state = 1", "limit" => 20, "order" => "id desc"));
     $data['hot_music'] = Content::model()->findAll(array("condition" => "category_id = 33 and state = 1", "limit" => 20, "order" => "view desc"));
     $this->render('study_by_music', $data);
 }
Exemplo n.º 8
0
 public function actionView()
 {
     $pid = Yii::app()->request->getParam('pid');
     $cid = Yii::app()->request->getParam('cid');
     $id = Yii::app()->request->getParam('id');
     $category = Category::model()->findByPk($pid);
     if ($category->taxonomy_id == $this->root_id) {
         $data = array();
         $data['item'] = Content::model()->findbyPk($id);
         if ($data['item']->category_id == $cid) {
             $data['cat'] = Category::model()->findbyPk($data['item']->category_id);
             $data['root_cat'] = Taxonomy::model()->findbyPk($data['cat']->taxonomy_id);
             $this->title = $data['item']->title;
             Content::model()->updateByPk($id, array('view' => $data['item']->view + 1));
             $data['comment_model'] = Comment::model()->findAll(array('condition' => 'content_id = :cid and state = 1', 'params' => array(':cid' => $id)));
             if ($data['item']->category_id != $cid) {
                 throw new CHttpException(404, 'PAGE NOT FOUND.');
             }
             $this->render('view', $data);
         } else {
             throw new CHttpException(404, 'PAGE NOT FOUND.');
         }
     } else {
         throw new CHttpException(404, 'PAGE NOT FOUND.');
     }
 }
Exemplo n.º 9
0
 /**
  * Handles all incoming requests for the entire site that are not previous defined in CUrlManager
  * Requests come in, are verified, and then pulled from the database dynamically
  * Shows all blog posts for a particular category_id
  * @param $id	- The content ID that we want to pull from the database
  * @return $this->render() - Render of page that we want to display
  **/
 public function actionIndex($id = NULL)
 {
     // Run a pre check of our data
     $this->beforeCiiAction($id);
     // Retrieve the data
     $category = Categories::model()->findByPk($id);
     $this->breadcrumbs = Categories::model()->getParentCategories($id);
     // Parse Metadata
     $meta = Categories::model()->parseMeta($category->metadata);
     $this->setPageTitle(Yii::t('ciims.controllers.Categories', '{{app_name}} | {{label}}', array('{{app_name}}' => Cii::getConfig('name', Yii::app()->name), '{{label}}' => $category->name)));
     $layout = isset($meta['layout']) ? $meta['layout']['value'] : 'default';
     // Set the layout
     $this->setLayout($layout);
     $data = array();
     $pages = array();
     $itemCount = 0;
     $pageSize = Cii::getConfig('categoryPaginationSize', 10);
     $criteria = Content::model()->getBaseCriteria()->addCondition('type_id >= 2')->addCondition("category_id = " . $id)->addCondition('password = ""');
     $criteria->limit = $pageSize;
     $criteria->order = 'created DESC';
     $itemCount = Content::model()->count($criteria);
     $pages = new CPagination($itemCount);
     $pages->pageSize = $pageSize;
     $criteria->offset = $criteria->limit * $pages->getCurrentPage();
     $data = Content::model()->findAll($criteria);
     $pages->applyLimit($criteria);
     $this->render('index', array('id' => $id, 'category' => $category, 'data' => $data, 'itemCount' => $itemCount, 'pages' => $pages, 'meta' => array('description' => $category->getDescription())));
 }
Exemplo n.º 10
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Content::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Exemplo n.º 11
0
 public function run()
 {
     parent::run();
     $data['trailer'] = Content::model()->findAll(array("condition" => "category_id = 30 and state = 1", "order" => "id desc", "limit" => 5));
     $data['count_tl'] = Content::model()->count(array("condition" => "category_id = 30 and state = 1", "order" => "id desc"));
     $data['voa'] = Content::model()->findAll(array("condition" => "category_id = 27 and state = 1", "order" => "id desc", "limit" => 5));
     $data['count_voa'] = Content::model()->count(array("condition" => "category_id = 27 and state = 1", "order" => "id desc"));
     $this->render('study_by_film', $data);
 }
Exemplo n.º 12
0
 public function testRelatedContentRecord()
 {
     // Create Post
     $post = new Post();
     $post->message = "Test";
     $post->content->container = Yii::app()->user->getModel();
     $this->assertTrue(isset($post->content) && $post->content instanceof Content);
     $this->assertTrue($post->validate());
     $this->assertTrue($post->save());
     $this->assertEquals(1, Content::model()->countByAttributes(array('object_model' => 'Post', 'object_id' => $post->getPrimaryKey())));
 }
Exemplo n.º 13
0
 function page()
 {
     $this->layout = 'layout/page';
     if (!($id = $this->get('id'))) {
         throw new HttpException(404);
     }
     if (!($content = Content::model()->findByPk($id))) {
         throw new HttpException(404);
     }
     $this->render('page', array('content' => $content));
 }
Exemplo n.º 14
0
 public function run()
 {
     parent::run();
     $data['count_gt'] = Content::model()->count(array("condition" => "category_id = 28 and state = 1", "order" => "id desc"));
     $data['giaotiep'] = Content::model()->findAll(array("condition" => "category_id = 28 and state = 1", "order" => "id desc", "limit" => 6));
     $data['count_nt'] = Content::model()->count(array("condition" => "category_id = 29 and state = 1", "order" => "id desc"));
     $data['noitieng'] = Content::model()->findAll(array("condition" => "category_id = 29 and state = 1", "order" => "id desc", "limit" => 6));
     $data['count_ytb'] = Content::model()->count(array("condition" => "category_id = 25 and state = 1", "order" => "id desc"));
     $data['youtube'] = Content::model()->findAll(array("condition" => "category_id = 25 and state = 1", "order" => "id desc", "limit" => 6));
     $this->render('study_by_clip', $data);
 }
 /**
  * On global module disable, delete all created content
  */
 public function disable()
 {
     if (parent::disable()) {
         foreach (Content::model()->findAll(array('condition' => 'object_model=:cat OR object_model=:libraryitem', 'params' => array(':cat' => 'LibraryCategory', ':libraryitem' => 'LibraryItem'))) as $content) {
             $content->delete();
         }
         return true;
     }
     throw new CHttpException(404);
     return false;
 }
 /**
  * Returns all content objects (posts, polls, etc.) from this space
  *
  * @param $spaceId : The id of the space
  * @param bool $forceUpdate : Ignore cache
  * @return Content[]
  */
 public function getContentFromSpace($spaceId, $forceUpdate = false)
 {
     $cacheId = 'posts_created_cache' . '_' . $spaceId;
     $spaceContent = Yii::app()->cache->get($cacheId);
     if ($spaceContent === false || $forceUpdate === true) {
         $criteria = new CDbCriteria();
         $criteria->condition = 'space_id=:spaceId AND object_model!=:activity';
         $criteria->params = array(':spaceId' => $spaceId, ':activity' => 'Activity');
         $spaceContent = Content::model()->findAll($criteria);
         Yii::app()->cache->set($cacheId, $spaceContent, ReputationContent::CACHE_TIME_SECONDS);
     }
     return $spaceContent;
 }
Exemplo n.º 17
0
 function index()
 {
     $this->layout = 'layout/page';
     if (!($id = $this->get('id'))) {
         throw new HttpException(404);
     }
     if (!($content = Content::model()->findByPk($id))) {
         throw new HttpException(404);
     }
     if (!($cate = Cate::model()->findByPk($content->cid))) {
         throw new HttpException(404);
     }
     $this->render('index', array('content' => $content, 'cate' => $cate));
 }
Exemplo n.º 18
0
 function delete()
 {
     if (!($id = $this->get('id', 0))) {
         throw new MHttpException(404);
     }
     if (!($model = Content::model()->findByPk($id))) {
         throw new MHttpException(404);
     }
     if ($model->delete()) {
         $this->renderCode(0, '');
     } else {
         $this->renderCode(1, 'fail to delete');
     }
 }
Exemplo n.º 19
0
 /**
  * Displays the article list
  */
 public function actionList()
 {
     $condition = new CDbCriteria();
     $condition->limit = 8;
     $condition->order = 'postdate DESC';
     $page = 1;
     $variable = $this->getActionParams();
     if (isset($variable['page'])) {
         $page = (int) $variable['page'];
     }
     $condition->offset = ($page - 1) * 8;
     $model = Content::model()->findALL($condition);
     $totalnum = Content::model()->count();
     $this->render('list', array('model' => $model, 'page' => $page, 'totalnum' => $totalnum));
 }
Exemplo n.º 20
0
 public function actionIndex()
 {
     $event = new Events();
     $event->attributes = $_GET;
     if (!isset($_GET['content_id'])) {
         $content = Content::model()->findByAttributes(array('slug' => Cii::get($_GET, 'uri', NULL)));
         if ($content !== NULL) {
             $event->content_id = $content->id;
         }
     }
     if ($event->save()) {
         Yii::app()->end();
     }
     return $this->returnError(400, NULL, $event->getErrors());
 }
Exemplo n.º 21
0
 public function actionEdite()
 {
     $id = Yii::app()->request->getParam('id');
     $model = Content::model()->findByPk($id);
     if (isset($_POST['Content'])) {
         $model->attributes = $_POST['Content'];
         if ($model->updateByPk($id, array("title" => $model->title, "body" => $model->body))) {
             $this->redirect(Yii::app()->createURL("manage/index"));
         } else {
             print_r($model->getErrors());
             exit;
         }
     }
     $this->render('edite', array("model" => $model));
 }
Exemplo n.º 22
0
 public function parseUrl($request)
 {
     $path = '/' . $request->pathInfo;
     if (!empty($path)) {
         $Content = Content::model()->findByAttributes(array('path' => $path));
     }
     if ($Content && $Content->id) {
         $route = 'content/view/id/' . $Content->id;
         $_GET['path'] = $Content->path;
         //So that menu items become active
     } else {
         $route = parent::parseUrl($request);
     }
     return lcfirst(str_replace(' ', '', ucwords(str_replace('-', ' ', $route))));
 }
Exemplo n.º 23
0
 /**
  * Displays either all posts or all posts for a particular category_id if an $id is set in RSS Format
  * So that RSS Readers can access the website
  * @param  int $id
  */
 public function actionRss($id = NULL)
 {
     Yii::app()->log->routes[0]->enabled = false;
     ob_end_clean();
     header('Content-type: text/xml; charset=utf-8');
     $url = 'http://' . Yii::app()->request->serverName . Yii::app()->baseUrl;
     $this->setLayout(null);
     $criteria = Content::model()->getBaseCriteria()->addCondition('type_id >= 2')->addCondition('password = ""');
     if ($id !== NULL) {
         $criteria->addCondition("category_id = " . $id);
     }
     $criteria->order = 'created DESC';
     $data = Content::model()->findAll($criteria);
     $this->renderPartial('application.views.site/rss', array('data' => $data, 'url' => $url));
     return;
 }
Exemplo n.º 24
0
 function aliasList($cateAlias = null, $contentAlias = null, $limit = 10)
 {
     $pagination = new MPagination();
     $pagination->setPageSize($limit);
     $pagination->setCurrentPage(0);
     if (is_null($cateAlias)) {
         return Content::model()->findAll('delete_time is null ', array(), $pagination, ' content_id desc ');
     }
     if (!($cate = Cate::model()->find('alias = ?', array($cateAlias)))) {
         return;
     }
     if (is_null($contentAlias)) {
         return Content::model()->findAll('cid = :cid and delete_time is null ', array(':cid' => $cate->cid), $pagination, ' content_id desc ');
     }
     return Content::model()->findAll('alias = :alias and cid = :cid ', array(':alias' => $contentAlias, ':cid' => $cate->cid), $pagination, ' content_id desc ');
 }
Exemplo n.º 25
0
 /**
  * Provides functionality to make a comment
  */
 public function actionComment()
 {
     if (Yii::app()->request->isAjaxRequest && Cii::get($_POST, 'Comments')) {
         $comment = new Comments();
         $comment->attributes = array('user_id' => Yii::app()->user->id, 'content_id' => $_POST['Comments']['content_id'], 'comment' => $_POST['Comments']['comment'], 'parent_id' => Cii::get($_POST['Comments'], 'parent_id', 0), 'approved' => Cii::getConfig('autoApproveComments', 1) == null ? 1 : Cii::getConfig('autoApproveComments', 1));
         if ($comment->save()) {
             $content = Content::model()->findByPk($comment->content_id);
             // Pass the values as "now" for the comment view"
             $comment->created = $comment->updated = Yii::t('Dashboard.main', 'now');
             // Set the attributed id to make life easier...
             header("X-Attribute-Id: {$comment->id}");
             $this->renderPartial('/content/comments', array('count' => $content->comment_count, 'comment' => $comment, 'depth' => 0, 'md' => new CMarkdownParser()));
         } else {
             throw new CHttpException(400, Yii::t('Dashboard.main', 'There was an error saving your comment.'));
         }
     }
 }
Exemplo n.º 26
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $homeId = SnapUtil::config('general/site.homepage_id');
     $Content = Content::model()->findByPk($homeId);
     //Used by the admin bar
     $this->Content = $Content;
     $this->layout = '//layouts/column1';
     $view = '/content/view';
     if ($this->getLayoutFile('//layouts/content_types/' . $Content->type)) {
         $this->layout = '//layouts/content_types/' . $Content->type;
     }
     if ($this->getViewFile('/content/content_types/' . $Content->type)) {
         $view = '/content/content_types/' . $Content->type;
     }
     $News = Content::model()->findAllByAttributes(array('type' => 'news'), array('limit' => 4, 'order' => 'created DESC', 'condition' => '(publish_on < NOW() OR publish_on is null) AND ' . '(unpublish_on < NOW() OR unpublish_on is null) AND ' . 'published = 1'));
     $this->render($view, array('Content' => $Content, 'News' => $News, 'MenuItem' => false));
 }
Exemplo n.º 27
0
 public function run()
 {
     parent::run();
     $data = Content::model()->findAll(array('condition' => 'state = 1 and category_id = ' . $this->cat_id, 'limit' => 4, 'order' => 'created_date desc'));
     $root = Category::model()->findByPk($this->cat_id);
     if ($this->type == 'news') {
         $this->render('sub/news', array('data' => $data, 'root' => $root));
     }
     if ($this->type == 'collect') {
         $category = Category::model()->findAll("parent = " . $this->cat_id);
         $this->render('sub/collect', array('data' => $data, 'root' => $root, "category" => $category));
     }
     if ($this->type == 'listen') {
         $this->render('sub/listen', array('data' => $data, 'root' => $root));
     }
     if ($this->type == 'play') {
         $cate = Category::model()->findAll(array("condition" => "state = 1 and parent = " . $this->cat_id, 'limit' => 4, 'order' => '"order" desc'));
         $this->render('sub/learn', array('data' => $data, 'root' => $root, 'cate' => $cate));
     }
 }
Exemplo n.º 28
0
 public function actionPage($url)
 {
     $model = Content::model()->findByAttributes(array("lang_id" => $this->lang, "is_active" => 1, "url" => $url));
     if (!empty($model)) {
         $this->pageTitle = $model->title;
         $this->pageDescription = $model->meta_description;
         $this->pageKeywords = $model->meta_keywords;
         if ($url == 'vino-nedeli' || $url == 'wine-of-the-week' || $url == 'vin-de-la-semaine') {
             $this->render("contentVino", array("model" => $model));
         } else {
             if ($url == "notfound") {
                 $this->layout = "//layouts/404";
                 $this->render("404", array("model" => $model));
             } else {
                 $this->render("content", array("model" => $model));
             }
         }
     } else {
         $this->redirect("/notfound");
     }
 }
Exemplo n.º 29
0
 public function actionView($id = '')
 {
     $cid = Yii::app()->request->getParam('tid');
     $category = Category::model()->findByPk($cid);
     if ($category->taxonomy_id == $this->root_id) {
         $data = array();
         $data['item'] = Content::model()->findbyPk($id);
         if ($data['item']->category_id == $cid) {
             $data['cat'] = Category::model()->findbyPk($data['item']->category_id);
             $data['root_cat'] = Taxonomy::model()->findbyPk($data['cat']->taxonomy_id);
             $this->title = $data['item']->title;
             Content::model()->updateByPk($id, array('view' => $data['item']->view + 1));
             if ($data['item']->category_id != $cid) {
                 throw new CHttpException(404, 'PAGE NOT FOUND.');
             }
             $this->render('view', $data);
         } else {
             throw new CHttpException(404, 'PAGE NOT FOUND.');
         }
     } else {
         throw new CHttpException(404, 'PAGE NOT FOUND.');
     }
 }
Exemplo n.º 30
0
 public function run()
 {
     parent::run();
     $data = array();
     $this->r_slug = Taxonomy::model()->findByPk($this->tax_id)->slug;
     $current = Content::model()->findByPk($this->p_id);
     $data['cat'] = Category::model()->findByPk($this->c_id);
     $id = Category::model()->findAll(array('condition' => 'taxonomy_id =  ' . $data['cat']->taxonomy_id));
     $arr_id = array();
     foreach ($id as $k) {
         $arr_id[] = $k->id;
         $data['category_'][$k->id] = $k->slug;
     }
     $this->own = Content::model()->find(array('condition' => 'id < :pid and category_id = :cid ', 'params' => array(':pid' => $this->p_id, ':cid' => $this->c_id)));
     $this->new = Content::model()->find(array('condition' => 'id > :pid and category_id = :cid ', 'params' => array(':pid' => $this->p_id, ':cid' => $this->c_id)));
     $data['same_thread'] = Content::model()->findAll(array('condition' => 'id != :pid and category_id in ( :cid ) and state = 1', 'params' => array(':pid' => $this->p_id, ':cid' => implode(",", $arr_id)), 'order' => 'rand()', 'limit' => 3));
     if (count($this->own) == 0) {
         $this->own = $current;
     }
     if (count($this->new) == 0) {
         $this->new = $current;
     }
     $this->render('more_listen', $data);
 }