protected function renderContent()
 {
     $module = strtolower(Yii::app()->controller->module->id);
     $controller = strtolower(Yii::app()->controller->id);
     $action = strtolower(Yii::app()->controller->action->id);
     $currentAction = strtolower(Yii::app()->controller->id . '/' . Yii::app()->controller->action->id);
     //import model
     Yii::import('application.modules.article.models.ArticleCategory');
     Yii::import('application.modules.article.models.ArticleMedia');
     Yii::import('application.modules.article.models.Articles');
     Yii::import('application.modules.article.models.ArticleTag');
     $criteria = new CDbCriteria();
     if ($this->hastag != null) {
         $criteria->with = array('tag_ONE' => array('alias' => 'a'), 'tag_ONE.tag_TO' => array('alias' => 'b'));
         $criteria->condition = 't.publish = :publish AND t.published_date <= curdate() AND b.body = :body';
         $criteria->params = array(':publish' => 1, ':body' => $this->hastag);
     } else {
         $criteria->condition = 'publish = :publish AND published_date <= curdate()';
         $criteria->params = array(':publish' => 1);
     }
     $criteria->order = 't.published_date DESC';
     if ($this->category != null) {
         $criteria->compare('cat_id', $this->category);
     }
     $criteria->limit = 3;
     $model = Articles::model()->findAll($criteria);
     $this->render('article_main_news_recent', array('model' => $model));
 }
Example #2
0
 public function run()
 {
     $criteria = new CDbCriteria();
     $criteria->limit = 4;
     $criteria->order = 'RAND()';
     $model = Articles::model()->findAll($criteria);
     $this->render('popularProducts', array('model' => $model));
 }
Example #3
0
 public function run()
 {
     $article = Articles::model()->onSite()->byType($this->type)->find();
     if (empty($article)) {
         return;
     }
     $this->render('article', array('article' => $article));
 }
Example #4
0
 public function loadModelByAlias($alias_url)
 {
     $model = Articles::model()->findByAttributes(array('alias_url' => $alias_url));
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #5
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 = Articles::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndexing()
 {
     ini_set('max_execution_time', 0);
     ob_start();
     $index = new Zend_Search_Lucene(Yii::getPathOfAlias($this->_indexFilesPath), true);
     $criteria = new CDbCriteria();
     $now = new CDbExpression("NOW()");
     $criteria->compare('t.publish', 1);
     $criteria->compare('date(published_date) <', $now);
     $criteria->order = 'article_id DESC';
     //$criteria->limit = 10;
     $model = Articles::model()->findAll($criteria);
     foreach ($model as $key => $item) {
         if ($item->media_id != 0) {
             $images = Yii::app()->request->baseUrl . '/public/article/' . $item->article_id . '/' . $item->cover->media;
         } else {
             $images = '';
         }
         if (in_array($item->cat_id, array(2, 3, 5, 6, 7, 18))) {
             $url = Yii::app()->createUrl('article/news/site/view', array('id' => $item->article_id, 't' => Utility::getUrlTitle($item->title)));
         } else {
             if (in_array($item->cat_id, array(9))) {
                 $url = Yii::app()->createUrl('article/site/view', array('id' => $item->article_id, 't' => Utility::getUrlTitle($item->title)));
             } else {
                 if (in_array($item->cat_id, array(10, 15, 16))) {
                     $url = Yii::app()->createUrl('article/archive/site/view', array('id' => $item->article_id, 't' => Utility::getUrlTitle($item->title)));
                 } else {
                     if (in_array($item->cat_id, array(23, 24, 25))) {
                         $url = Yii::app()->createUrl('article/newspaper/site/view', array('id' => $item->article_id, 't' => Utility::getUrlTitle($item->title)));
                     } else {
                         if (in_array($item->cat_id, array(13, 14, 20, 21))) {
                             $url = Yii::app()->createUrl('article/regulation/site/download', array('id' => $item->article_id, 't' => Utility::getUrlTitle($item->title)));
                         } else {
                             if (in_array($item->cat_id, array(19))) {
                                 $url = Yii::app()->createUrl('article/announcement/site/download', array('id' => $item->article_id, 't' => Utility::getUrlTitle($item->title)));
                             }
                         }
                     }
                 }
             }
         }
         $doc = new Zend_Search_Lucene_Document();
         $doc->addField(Zend_Search_Lucene_Field::UnIndexed('id', CHtml::encode($item->article_id), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::Keyword('category', CHtml::encode(Phrase::trans($item->cat->name, 2)), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::Text('media', CHtml::encode($images), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::Text('title', CHtml::encode($item->title), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::Text('body', CHtml::encode(Utility::hardDecode(Utility::softDecode($item->body))), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::Text('url', CHtml::encode(Utility::getProtocol() . '://' . Yii::app()->request->serverName . $url), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::UnIndexed('date', CHtml::encode(Utility::dateFormat($item->published_date, true) . ' WIB'), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::UnIndexed('creation', CHtml::encode($item->user->displayname), 'utf-8'));
         $index->addDocument($doc);
     }
     echo 'Artkel Lucene index created';
     $index->commit();
     $this->redirect(Yii::app()->createUrl('video/search/indexing'));
     ob_end_flush();
 }
 public function actionDelBloger($id)
 {
     if(Yii::app()->user->role == 'admin') {
         $user = User::model()->findByPk($id);
         Articles::model()->deleteAll('author_id = :id', array(':id'=>$user->id));
         User::model()->deleteByPk($id);
         $this->redirect('/site/index');
     }
 }
 /**
  * Deletes a particular model.
  * If deletion is successful, the browser will be redirected to the 'admin' page.
  * @param integer $id the ID of the model to be deleted
  */
 public function actionDelete($id)
 {
     $user = $this->loadModel($id);
     Articles::model()->deleteAll('author_id = :id', array(':id' => $user->id));
     $user->delete();
     // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
     if (!isset($_GET['ajax'])) {
         $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
     }
 }
 public function actionDelete($id)
 {
     $model = Articles::model()->findByPk($id);
     if ($model->delete()) {
         Yii::app()->end();
     }
     // if AJAX request (triggered by deletion via index grid view), we should not redirect the browser
     if (!isset($_GET['ajax'])) {
         $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('index'));
     }
 }
 public function init()
 {
     $criteria = new CDbCriteria();
     $criteria->condition = 'date > :date_start';
     $criteria->order = 'views DESC';
     $criteria->with = 'author';
     $criteria->limit = 5;
     $criteria->select = 'id, date, title';
     $criteria->params = array(':date_start' => date('Y-m-d H:m:s', time() - 60 * 60 * 24 * 7));
     $this->week = Articles::model()->findAll($criteria);
     $criteria->params = array(':date_start' => date('Y-m-d H:m:s', time() - 60 * 60 * 24 * 30));
     $this->month = Articles::model()->findAll($criteria);
 }
 protected function renderContent()
 {
     $module = strtolower(Yii::app()->controller->module->id);
     $controller = strtolower(Yii::app()->controller->id);
     $action = strtolower(Yii::app()->controller->action->id);
     $currentAction = strtolower(Yii::app()->controller->id . '/' . Yii::app()->controller->action->id);
     //import model
     Yii::import('application.modules.article.models.Articles');
     Yii::import('application.modules.article.models.ArticleMedia');
     Yii::import('application.modules.article.models.ArticleSetting');
     //$cat = ($controller == 'site') ? 1 : 2;
     $model = Articles::model()->findAll(array('condition' => 'publish = :publish AND headline = :headline AND published_date <= curdate()', 'params' => array(':publish' => 1, ':headline' => 1), 'order' => 'article_id DESC', 'limit' => 1));
     $this->render('front_article_headline', array('model' => $model));
 }
Example #12
0
 public static function getArticlesToSlider()
 {
     $sliderArray = array();
     $articleArray = array();
     if ($slider = self::model()->findAll()) {
         foreach ($slider as $item) {
             $sliderArray[$item->id] = $item->id;
         }
     }
     if ($articles = Articles::model()->findAll()) {
         foreach ($articles as $itemArticle) {
             $articleArray[$itemArticle->id] = $itemArticle->name_uk;
         }
     }
     return array_diff_key($articleArray, $sliderArray);
 }
 protected function renderContent()
 {
     $module = strtolower(Yii::app()->controller->module->id);
     $controller = strtolower(Yii::app()->controller->id);
     $action = strtolower(Yii::app()->controller->action->id);
     $currentAction = strtolower(Yii::app()->controller->id . '/' . Yii::app()->controller->action->id);
     $currentModule = strtolower(Yii::app()->controller->module->id . '/' . Yii::app()->controller->id);
     $currentModuleAction = strtolower(Yii::app()->controller->module->id . '/' . Yii::app()->controller->id . '/' . Yii::app()->controller->action->id);
     //import model
     Yii::import('application.modules.article.models.Articles');
     Yii::import('application.modules.article.models.ArticleCategory');
     Yii::import('application.modules.article.models.ArticleMedia');
     $criteria = new CDbCriteria();
     $criteria->condition = 'publish = :publish AND published_date <= curdate()';
     $criteria->params = array(':publish' => 1);
     $criteria->order = 'view DESC';
     $criteria->limit = 3;
     $model = Articles::model()->findAll($criteria);
     $this->render('article_popular', array('module' => $module, 'controller' => $controller, 'action' => $action, 'currentAction' => $currentAction, 'currentModule' => $currentModule, 'currentModuleAction' => $currentModuleAction, 'model' => $model));
 }
 protected function renderContent()
 {
     $module = strtolower(Yii::app()->controller->module->id);
     $controller = strtolower(Yii::app()->controller->id);
     $action = strtolower(Yii::app()->controller->action->id);
     $currentAction = strtolower(Yii::app()->controller->id . '/' . Yii::app()->controller->action->id);
     //import model
     Yii::import('application.modules.article.models.Articles');
     Yii::import('application.modules.article.models.ArticleCategory');
     Yii::import('application.modules.article.models.ArticleMedia');
     $criteria = new CDbCriteria();
     $criteria->condition = 'publish = :publish AND published_date <= curdate()';
     $criteria->params = array(':publish' => 1);
     $criteria->order = 'published_date DESC';
     //$criteria->addInCondition('cat_id',array(18));
     //$criteria->compare('cat_id',18);
     //$criteria->limit = 3;
     $criteria->limit = $module == null && $currentAction == 'site/index' ? 4 : 5;
     $model = Articles::model()->findAll($criteria);
     $this->render('front_article_recent', array('model' => $model));
 }
 /**
  * Кабинет пользователя
  */
 public function actionUser_cabinet()
 {
     if (Yii::app()->request->isAjaxRequest) {
         if (isset($_POST['Users'])) {
             $model = Users::model()->findByPk($_POST['Users']['idUser']);
             $oldFile = null;
             $fileName = null;
             // Генерим имя фото
             if ('' != $_FILES['Users']['name']['image']) {
                 $fileName = AuxiliaryFunctions::getUniquNamePhoto($_FILES['Users']['name']['image']);
                 $_POST['Users']['photo'] = $fileName;
                 $oldFile = $model->photo;
             }
             $model->attributes = $_POST['Users'];
             if ($model->save(false)) {
                 if ($fileName) {
                     AuxiliaryFunctions::savePhoto($model, $fileName, $oldFile);
                 }
                 if (Yii::app()->request->isAjaxRequest) {
                     echo CJSON::encode(array('result' => 'ok'));
                     exit;
                 }
             } else {
                 if (Yii::app()->request->isAjaxRequest) {
                     echo CJSON::encode(array('error' => 'save'));
                     exit;
                 }
             }
         }
     }
     if (Yii::app()->user->isGuest || 'Admins' == Yii::app()->session->get("typeAuthorize") || !isset($_GET['idUser']) || $_GET['idUser'] != Yii::app()->user->id) {
         $this->redirect(Yii::app()->homeUrl);
     } else {
         $model = Users::model()->findByPk($_GET['idUser']);
     }
     $artWaitingModeration = Articles::model()->count('idUser = :idUser AND moderationAppruv = 0', array(":idUser" => $_GET['idUser']));
     $artPublication = Articles::model()->count('idUser = :idUser AND public = 1', array(":idUser" => $_GET['idUser']));
     $menuInBookmarks = Bookmarks::model()->getUserBookmarks(Yii::app()->user->id);
     $this->render('user_cabinet', array('model' => $model, 'tabArticles' => array('artWaitingModeration' => $artWaitingModeration, 'artPublication' => $artPublication, 'menuInBookmarks' => $menuInBookmarks)));
 }
Example #16
0
	/**
	 * Displays a particular model.
	 * @param integer $id the ID of the model to be displayed
	 */
	public function actionView($id)
	{
        $menu = Menus::model()->findByPk($id);
        if (isset($menu)) {
            if ($menu->parent_id != 0) {
                $menu = Menus::model()->findByPk($menu->parent_id);
            }
            $sub_menus = Menus::model()->findAll('parent_id=:parent_id',array(':parent_id' => $menu->id));
            //$articles = Articles::model()->findAll('menu_id=:menu_id',array(':menu_id' => $id));
            $articles = Articles::model()->findAll(array(
                'condition' => 'menu_id='.$id,
                'order' => 'id desc'
            ));
            $this->render('view',array(
                'articles'=>$articles,
                'sub_menus' => $sub_menus,
                'menu' => $menu,
                'active_id' => $id
            ));
        } else {
            $this->redirect('/');
        }

	}
 /**
  * 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 = Articles::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Phrase::trans(193, 0));
     }
     return $model;
 }
 public function actionSave_article()
 {
     $idArticle = null;
     // Проверки на доступ к странице
     if (Yii::app()->user->isGuest) {
         $this->redirect($this->createAbsoluteUrl('default/index'));
     }
     if (isset($_POST['cancel'])) {
         $this->redirect($this->createAbsoluteUrl('default/list_articles', $_GET));
     }
     if (isset($_POST['delete'])) {
         $this->actionDelete_article();
         $this->redirect($this->createAbsoluteUrl('default/list_articles', $_GET));
     }
     // Автокомплитер тегов
     if (isset($_GET['q'])) {
         $lastTag = end(explode(",", $_GET['q']));
         $criteria = new CDbCriteria();
         $criteria->condition = 'textTag LIKE :tag';
         $criteria->params = array(':tag' => '%' . trim(htmlspecialchars($lastTag)) . '%');
         if (isset($_GET['limit']) && is_numeric($_GET['limit'])) {
             $criteria->limit = $_GET['limit'];
         }
         $tags = Tags::model()->findAll($criteria);
         if ($tags) {
             $resStr = '';
             foreach ($tags as $tag) {
                 $resStr .= $tag->textTag . "\n";
             }
             echo $resStr;
         }
         exit;
     }
     // Редактирование или добавление новой
     if (isset($_GET['idArticle'])) {
         $idArticle = $_GET['idArticle'];
         $model = Articles::model()->findByPk($_GET['idArticle']);
         $model['tagArray'] = AuxiliaryFunctions::getTagsList($model->tagstoarticles, false);
     } else {
         $model = new Articles('create');
     }
     // Нажата кнопка "Редактировать" или "Добавить"
     if (isset($_POST['Articles'])) {
         $oldFile = null;
         $oldFile = $model->photo;
         $fileName = null;
         // Генерим имя фото
         if ('' != $_FILES['Articles']['name']['image']) {
             $fileName = AuxiliaryFunctions::getUniquNamePhoto($_FILES['Articles']['name']['image']);
             $_POST['Articles']['photo'] = $fileName;
             $oldFile = $model->photo;
         }
         $model->attributes = $_POST['Articles'];
         if (empty($model->idUser)) {
             $model->idUser = Users::getIdUserForAdmin();
         }
         if ($model->validate()) {
             if ($model->save()) {
                 $idArticle = $model->idArticle;
                 if ($fileName) {
                     AuxiliaryFunctions::savePhoto($model, $fileName, $oldFile);
                 }
                 // Теги для статьи
                 if (isset($_POST['textTag'])) {
                     $tagsArray = explode(",", $_POST['textTag']);
                     $idArray = array();
                     foreach ($tagsArray as $item) {
                         $tagId = null;
                         if (!empty($item)) {
                             $item = trim(htmlspecialchars($item));
                         } else {
                             continue;
                         }
                         $tagResult = Tags::model()->findByAttributes(array('textTag' => $item));
                         if (null === $tagResult) {
                             $newTag = new Tags();
                             $newTag->textTag = $item;
                             if ($newTag->save()) {
                                 $tagId = $newTag->idTag;
                             }
                         } else {
                             $tagId = $tagResult->idTag;
                         }
                         $idArray[] = $tagId;
                     }
                     if ($idArray) {
                         foreach ($idArray as $item) {
                             $item = (int) $item;
                             $idArticle = (int) $idArticle;
                             if (!TagsToArticles::model()->exists('idArticle = :idArticle AND idTag = :idTag', array(':idArticle' => $idArticle, ':idTag' => $item))) {
                                 $newTags2Art = new TagsToArticles();
                                 $newTags2Art->idArticle = $idArticle;
                                 $newTags2Art->idTag = (int) $item;
                                 $newTags2Art->save();
                             }
                         }
                     }
                 }
                 $this->redirect($this->createAbsoluteUrl('default/list_articles', $_GET));
             }
         }
     }
     $menus = Mainmenu::model()->getDropDownMenu();
     $idMenu = !empty($model->idMenu) ? $model->idMenu : key($menus);
     $category1 = array('' => 'Без категории');
     $category2 = Categorys::getAllCategories($idMenu);
     $category = $category1 + $category2;
     $tags = new Tags();
     $this->render('//articles/save_article', array('model' => $model, 'menus' => $menus, 'category' => $category, 'tags' => $tags));
 }
 /**
  * Просмотр статьи с комментами
  */
 public function actionView_article()
 {
     if (isset($_GET['idArticle']) || isset($_POST['idArticle'])) {
         $idArticle = isset($_GET['idArticle']) ? $_GET['idArticle'] : $_POST['idArticle'];
         $criteria = new CDbCriteria();
         // Комментарии к статье
         $criteria->with = array('idUser0');
         $criteria->condition = 'idArticle = :idArticle AND deleted = 0 AND public = 1';
         $criteria->params = array(':idArticle' => $idArticle);
         $comments = Comments::model()->findAll($criteria);
         $commentsDataProvider = new CArrayDataProvider($comments, array('keyField' => 'idComment', 'pagination' => array('pageSize' => 50)));
         // Статья
         $criteria->with = array('idCategory0', 'idMenu0', 'idUser0', 'commentsCount', 'tagstoarticles');
         $criteria->condition = 't.idArticle = :idArticle AND moderationAppruv = 1 AND public = 1 AND deleted = 0';
         if (Yii::app()->request->isAjaxRequest) {
             if (isset($_POST['type'])) {
                 if ('appruve' == $_POST['type']) {
                     $criteria->condition = 't.idArticle = :idArticle AND moderationAppruv = 0 AND deleted = 0';
                 }
             }
         }
         $criteria->params = array(':idArticle' => $idArticle);
         $model = Articles::model()->find($criteria);
         // Теги
         $model['tagArray'] = AuxiliaryFunctions::getTagsList($model->tagstoarticles);
         // Счетчик просмотров статьи
         if ($model->idUser != Yii::app()->user->id && 'Admins' != Yii::app()->session->get("typeAuthorize")) {
             $model->saveCounters(array('numberOfViews' => 1));
         }
         if (isset($_GET['idMenu'])) {
             // Категории раздела
             $this->_listCategory = Categorys::getAllCategories($_GET['idMenu'], true, true);
         }
         $bookmarks = Bookmarks::model()->find(array('select' => 'idBookmarks', 'condition' => 'idUser = :idUser AND idArticle = :idArticle AND idMenu = :idMenu AND idCategory = :idCategory', 'params' => array(':idUser' => Yii::app()->user->id, ':idArticle' => $model->idArticle, ':idMenu' => $model->idMenu, ':idCategory' => $model->idCategory)));
         if (Yii::app()->request->isAjaxRequest) {
             $articlePopup = $this->renderPartial('view_article', array('model' => $model, 'commentsDataProvider' => $commentsDataProvider, 'modelComment' => new Comments(), 'idBookmarks' => null === $bookmarks ? null : $bookmarks->idBookmarks), true);
             echo CJSON::encode(array('popup' => $articlePopup));
             exit;
         }
         $this->breadcrumbs = AuxiliaryFunctions::fillingBreadcrumbs($idArticle, 'article');
         $this->render('view_article', array('model' => $model, 'commentsDataProvider' => $commentsDataProvider, 'modelComment' => new Comments(), 'idBookmarks' => null === $bookmarks ? null : $bookmarks->idBookmarks));
     }
 }
Example #20
0
                    </div>
                    <div class="blogersPageAll">
                        <hr>
                        <h1><?= Yii::t('main', 'Всі блогери'); ?></h1>
                        <div class="containerBloger">
                            <?php foreach($allBlogers as $bloger): ?>
                                <?php $article = Articles::model()->find(array('condition'=>'author_id = :id', 'params'=>array(':id'=>$bloger->id), 'limit'=>1, 'order'=>'date DESC')); ?>
                                <?php if(!empty($article)):?>
                                <div class="items wow">
                                    <?= CHtml::image(Yii::app()->baseUrl.'/uploads/users/avatars/'.$bloger->avatar, $bloger->name); ?>
                                    <div class="rating">
                                        <p><i class="fa fa-bookmark hoverIco"></i> &nbsp;&nbsp;
                                            <?= CHtml::link($bloger->name, array('/blog/default/bloger', 'id'=>$bloger->id)); ?>
                                            <br>
                                    <span>
                                        <?php $article = Articles::model()->find(array('condition'=>'author_id = :id', 'params'=>array(':id'=>$bloger->id), 'limit'=>1, 'order'=>'date DESC')); ?>
                                        <b><?= Yii::t('main', 'Останній пост'); ?>:</b> &nbsp; <?= !empty($article) ? date('d-m-Y', strtotime($article->date)) : Yii::t('main', 'У автора немає постів'); ?> &nbsp; <br>
                                       <i class="fa fa-eye"></i> <?= !empty($article) ? (int)$article->views : Yii::t('main', 'У автора немає постів'); ?></span>
                                        </p>
                                    </div>
                                </div>
                                <?php endif; ?>
                            <?php endforeach; ?>
                        </div>

                    </div>

                </div>
            </div>
            <div class="allmini pageWithoutTop">
                <?php $this->widget('application.components.widgets.AllNewsWidget', array('limit'=>50, 'showPictures'=>false)); ?>
Example #21
0
 public function safeDown()
 {
     $article = Articles::model()->byType(Articles::TYPE_UNDER_CONSTRUCTION)->delete();
     $this->dropTable('Articles_lang');
     $this->dropTable('Articles');
 }
Example #22
0
 public function actionGetTreePages()
 {
     $result = array();
     if (isset($_REQUEST['model']) && isset($_REQUEST['page'])) {
         $limit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : 30;
         $model = $_REQUEST['model'];
         $id = $_REQUEST['id'];
         $bid = $_REQUEST['bid'];
         $p = isset($_REQUEST['page']) ? $_REQUEST['page'] - 1 : 0;
         $items = array();
         $isParent = false;
         $count = 0;
         $criteria = new CDbCriteria();
         switch ($model) {
             case 'news':
                 $criteria->addCondition("is_active = 1");
                 $criteria->limit = $limit;
                 $criteria->offset = $p * $limit;
                 $items = News::model()->findAll($criteria);
                 if (is_array($items) && count($items)) {
                     foreach ($items as $item) {
                         $checked = BannersPagesRelation::model()->findByAttributes(array("banner_id" => $bid, "object_id" => $item->id, "model" => $model)) ? true : false;
                         $result[] = array('name' => $item->name, 'model' => $model, 'id' => $item->id, 'oid' => $item->id, 'isParent' => $isParent, "checked" => $checked);
                     }
                 }
                 break;
             case 'articles_categories':
                 $criteria->addCondition("is_active = 1");
                 $criteria->limit = $limit;
                 $criteria->offset = $p * $limit;
                 $items = ArticlesCategories::model()->findAll($criteria);
                 if ($id == 0) {
                     $isParent = true;
                     $model = 'articles';
                 }
                 if (is_array($items) && count($items)) {
                     foreach ($items as $item) {
                         $criteria = new CDbCriteria();
                         $criteria->addCondition("category_id = :cid AND is_active = 1");
                         $criteria->params = array(":cid" => $item->id);
                         $count = Articles::model()->count($criteria);
                         $checked = BannersPagesRelation::model()->findByAttributes(array("banner_id" => $bid, "object_id" => $item->id, "model" => $model)) ? true : false;
                         $result[] = array('name' => $item->name, 'model' => $model, 'id' => $item->id, 'oid' => $item->id, 'count' => $count, 'page' => $p, 'pageSize' => 30, 'isParent' => $isParent, "checked" => $checked);
                     }
                 }
                 break;
             case 'articles':
                 $criteria->addCondition("category_id = :cid AND is_active = 1");
                 $criteria->limit = $limit;
                 $criteria->offset = $p * $limit;
                 $criteria->params = array(":cid" => $id);
                 $items = Articles::model()->findAll($criteria);
                 if (is_array($items) && count($items)) {
                     foreach ($items as $item) {
                         $checked = BannersPagesRelation::model()->findByAttributes(array("banner_id" => $bid, "object_id" => $item->id, "model" => $model)) ? true : false;
                         $result[] = array('name' => $item->name, 'model' => $model, 'id' => $item->id, 'oid' => $item->id, 'isParent' => $isParent, "checked" => $checked);
                     }
                 }
                 break;
             case 'clinics':
                 $criteria->addCondition("is_active = 1");
                 $criteria->limit = $limit;
                 $criteria->offset = $p * $limit;
                 $items = Clinics::model()->findAll($criteria);
                 if (is_array($items) && count($items)) {
                     foreach ($items as $item) {
                         $checked = BannersPagesRelation::model()->findByAttributes(array("banner_id" => $bid, "object_id" => $item->id, "model" => $model)) ? true : false;
                         $result[] = array('name' => $item->name, 'model' => $model, 'id' => $item->id, 'oid' => $item->id, 'isParent' => $isParent, "checked" => $checked);
                     }
                 }
                 break;
             case 'experts':
                 $criteria->addCondition("is_active = 1");
                 $criteria->limit = $limit;
                 $criteria->offset = $p * $limit;
                 $items = Experts::model()->findAll($criteria);
                 if (is_array($items) && count($items)) {
                     foreach ($items as $item) {
                         $checked = BannersPagesRelation::model()->findByAttributes(array("banner_id" => $bid, "object_id" => $item->id, "model" => $model)) ? true : false;
                         $result[] = array('name' => $item->name, 'model' => $model, 'id' => $item->id, 'oid' => $item->id, 'isParent' => $isParent, "checked" => $checked);
                     }
                 }
                 break;
             case 'book_categories':
                 $criteria->addCondition("is_active = 1");
                 $criteria->limit = $limit;
                 $criteria->offset = $p * $limit;
                 $items = BookCategories::model()->findAll($criteria);
                 if ($id == 0) {
                     $isParent = true;
                     $model = 'book';
                 }
                 if (is_array($items) && count($items)) {
                     foreach ($items as $item) {
                         $criteria = new CDbCriteria();
                         $criteria->addCondition("category_id = :cid AND is_active = 1");
                         $criteria->params = array(":cid" => $item->id);
                         $count = BookPages::model()->count($criteria);
                         $checked = BannersPagesRelation::model()->findByAttributes(array("banner_id" => $bid, "object_id" => $item->id, "model" => $model)) ? true : false;
                         $result[] = array('name' => $item->name, 'model' => $model, 'id' => $item->id, 'oid' => $item->id, 'count' => $count, 'page' => $p, 'pageSize' => 30, 'isParent' => $isParent, "checked" => $checked);
                     }
                 }
                 break;
             case 'book':
                 $criteria->addCondition("category_id = :cid AND is_active = 1");
                 $criteria->limit = $limit;
                 $criteria->offset = $p * $limit;
                 $criteria->params = array(":cid" => $id);
                 $items = BookPages::model()->findAll($criteria);
                 if (is_array($items) && count($items)) {
                     foreach ($items as $item) {
                         $checked = BannersPagesRelation::model()->findByAttributes(array("banner_id" => $bid, "object_id" => $item->id, "model" => $model)) ? true : false;
                         $result[] = array('name' => $item->name, 'model' => $model, 'id' => $item->id, 'oid' => $item->id, 'isParent' => $isParent, "checked" => $checked);
                     }
                 }
                 break;
         }
     }
     echo json_encode($result);
 }
Example #23
0
                        </div>
                        <hr noshade>
                        <p><?= Yii::t('main', 'Використовуйте електронну пошту'); ?></p>
                        <div class="input-group round">
                            <?php $this->widget('application.components.widgets.AuthWidget'); ?>
                        </div>
                    </li>
                    <?php else: ?>
					<?php $user = User::model()->findByPk(Yii::app()->user->id); ?>
                    <li class="logINCabinet">
                        <hr noshade>
                        <p><?= Yii::t('main', 'Особистий кабінет користувача'); ?></p>
                        <img src="<?= Yii::app()->baseUrl.'/uploads/users/avatars/'.$user->avatar; ?>" alt="">
                        <h3><?= $user->name; ?></h3>
                        <span><?= Yii::t('main', 'Кількість постів'); ?>: <span><?= Articles::model()->count(array('condition'=>'author_id = '.Yii::app()->user->id)); ?></span></span>
                        <?php $article = Articles::model()->find(array('order'=>'date DESC', 'condition'=>'author_id = '.Yii::app()->user->id)); ?>
                        <span><?= Yii::t('main', 'Останній пост'); ?>: <span><?= !empty($article) ? date('d-m-Y', strtotime($article->date)) : Yii::t('main', 'Немає постів'); ?></span></span>
                        <?= Chtml::link(Yii::t('main', 'Особистий кабінет'), array('/blog/cabinet/index'), array('class'=>'button')); ?>
                        <?= Chtml::link(Yii::t('main', 'Вийти'), array('/site/logout')); ?>
                    </li>
                    <?php endif; ?>
                </ul>
            </li>
        </ul>
    </nav>
</header>
<div class="topBlockInfo">
    <div class="titleGarmata">
        <p><?= Yii::t('main', 'Перше міське інтернет телебачення Чернігова'); ?></p> &nbsp; &mdash; &nbsp; <p><i class="fa fa-calendar"></i> <?= $this->getCurrentDate(); ?></p>
    </div>
    <div class="forTopButton">
 /**
  * After save attributes
  */
 protected function afterSave()
 {
     parent::afterSave();
     $article_path = "public/article/" . $this->article_id;
     if ($this->isNewRecord && in_array($this->article_type, array(1, 3))) {
         // Add article directory
         if (!file_exists($article_path)) {
             @mkdir($article_path, 0777, true);
             // Add file in article directory (index.php)
             $newFile = $article_path . '/index.php';
             $FileHandle = fopen($newFile, 'w');
         }
     }
     if ($this->article_type == 1) {
         if ($this->isNewRecord || !$this->isNewRecord && ArticleSetting::getInfo('media_limit') == 1) {
             $this->media = CUploadedFile::getInstance($this, 'media');
             if ($this->media instanceof CUploadedFile) {
                 $fileName = time() . '_' . $this->article_id . '_' . Utility::getUrlTitle($this->title) . '.' . strtolower($this->media->extensionName);
                 if ($this->media->saveAs($article_path . '/' . $fileName)) {
                     if ($this->isNewRecord || !$this->isNewRecord && $this->media_id == 0) {
                         $images = new ArticleMedia();
                         $images->article_id = $this->article_id;
                         $images->cover = 1;
                         $images->media = $fileName;
                         $images->save();
                     } else {
                         if ($this->old_media != '' && file_exists($article_path . '/' . $this->old_media)) {
                             rename($article_path . '/' . $this->old_media, 'public/article/verwijderen/' . $this->article_id . '_' . $this->old_media);
                         }
                         $images = ArticleMedia::model()->findByPk($this->media_id);
                         $images->media = $fileName;
                         $images->update();
                     }
                 }
             }
         }
     } else {
         if ($this->article_type == 2) {
             if ($this->isNewRecord) {
                 $video = new ArticleMedia();
                 $video->article_id = $this->article_id;
                 $video->cover = 1;
                 $video->media = $this->video;
                 $video->save();
             } else {
                 if ($this->media_id == 0) {
                     $video = new ArticleMedia();
                     $video->article_id = $this->article_id;
                     $video->cover = 1;
                     $video->media = $this->video;
                     if ($video->save()) {
                         $data = Articles::model()->findByPk($this->article_id);
                         $data->media_id = $video->media_id;
                         $data->update();
                     }
                 } else {
                     $video = ArticleMedia::model()->findByPk($this->media_id);
                     $video->media = $this->video;
                     $video->update();
                 }
             }
         }
     }
     $this->file = CUploadedFile::getInstance($this, 'file');
     if ($this->file instanceof CUploadedFile) {
         $fileName = time() . '_' . $this->article_id . '_' . Utility::getUrlTitle($this->title) . '.' . strtolower($this->file->extensionName);
         if ($this->file->saveAs($article_path . '/' . $fileName)) {
             if (!$this->isNewRecord && $this->media_file != '' && file_exists($article_path . '/' . $this->old_file)) {
                 rename($article_path . '/' . $this->old_file, 'public/article/verwijderen/' . $this->article_id . '_' . $this->old_file);
             }
             $article = Articles::model()->findByPk($this->article_id);
             $article->media_file = $fileName;
             $article->update();
         }
     }
     // Add Keyword
     if (!$this->isNewRecord) {
         if ($this->keyword != '') {
             $model = OmmuTags::model()->find(array('select' => 'tag_id, body', 'condition' => 'publish = 1 AND body = :body', 'params' => array(':body' => $this->keyword)));
             $tag = new ArticleTag();
             $tag->article_id = $this->article_id;
             if ($model != null) {
                 $tag->tag_id = $model->tag_id;
             } else {
                 $data = new OmmuTags();
                 $data->body = $this->keyword;
                 if ($data->save()) {
                     $tag->tag_id = $data->tag_id;
                 }
             }
             $tag->save();
         }
     }
     // Reset headline
     if (ArticleSetting::getInfo('headline') == 1) {
         if ($this->headline == 1) {
             self::model()->updateAll(array('headline' => 0), array('condition' => 'article_id != :id AND cat_id = :cat', 'params' => array(':id' => $this->article_id, ':cat' => $this->cat_id)));
         }
     } else {
     }
 }
Example #25
0
 /**
  * Карта сайта
  */
 public function actionSite_map()
 {
     // ITEMS MENUS
     $menus = Mainmenu::model()->findAll(array('condition' => 'type = "middle" AND partSite = "site" AND visible = 1'));
     $itemsArray = array();
     foreach ($menus as $oneMenu) {
         $itemMenu = array('label' => $oneMenu->title, 'url' => array($oneMenu->link, 'listType' => 'razdel', 'idMenu' => $oneMenu->idMenu), 'itemOptions' => array('class' => 'itemMenu'), 'linkOptions' => array('class' => 'linkMenu'));
         // ITEMS CATEGORYS
         $categorys = Categorys::model()->findAll(array('condition' => 'idMenu = :idMenu AND active = 1', 'params' => array(':idMenu' => $oneMenu->idMenu)));
         // ITEMS ARTICLES (MENU)
         $articlesMenu = Articles::model()->findAll(array('condition' => 'moderationAppruv = 1 AND public = 1 AND deleted = 0 AND idMenu = :idMenu AND idCategory = 0', 'params' => array(':idMenu' => $oneMenu->idMenu)));
         $categoryItems = array();
         if (!empty($categorys)) {
             foreach ($categorys as $oneCategory) {
                 $itemCategory = array('label' => $oneCategory->title, 'url' => array('articles/list_articles', 'listType' => 'category', 'idMenu' => $oneCategory->idMenu, 'idCategory' => $oneCategory->idCategory), 'itemOptions' => array('class' => 'itemCategory'), 'linkOptions' => array('class' => 'linkCategory'));
                 // ITEMS ARTICLES (MENU - CATEGORY)
                 $articles = Articles::model()->findAll(array('condition' => 'moderationAppruv = 1 AND public = 1 AND deleted = 0 AND idMenu = :idMenu AND idCategory = :idCategory', 'params' => array(':idMenu' => $oneMenu->idMenu, ':idCategory' => $oneCategory->idCategory)));
                 if (!empty($articles)) {
                     $catMenuArtItem = array();
                     foreach ($articles as $oneArticle) {
                         $catMenuArtItem['items'][] = array('label' => $oneArticle->title, 'url' => array('articles/view_article', 'idArticle' => $oneArticle->idArticle, 'idMenu' => $oneArticle->idMenu), 'itemOptions' => array('class' => 'itemArticle'), 'linkOptions' => array('class' => 'linkArticle'));
                     }
                     $categoryItems['items'][] = $itemCategory + $catMenuArtItem;
                 } else {
                     $categoryItems['items'][] = $itemCategory;
                 }
             }
         }
         if (!empty($articlesMenu)) {
             foreach ($articlesMenu as $oneArticleMenu) {
                 $categoryItems['items'][] = array('label' => $oneArticleMenu->title, 'url' => array('articles/view_article', 'idArticle' => $oneArticleMenu->idArticle, 'idMenu' => $oneArticleMenu->idMenu), 'itemOptions' => array('class' => 'itemArticle'), 'linkOptions' => array('class' => 'linkArticle'));
             }
         }
         if (!empty($categoryItems['items'])) {
             $itemsArray['items'][] = $itemMenu + $categoryItems;
         } else {
             $itemsArray['items'][] = $itemMenu;
         }
     }
     $this->render('site_map', array('itemsArray' => $itemsArray));
 }
Example #26
0
 public function renderContent()
 {
     $articles = Articles::model()->findAll(array('condition' => 'menu_id=1'));
     $this->render('bottomSlider',array('articles' => $articles));
 }
 /**
  * Get Article
  */
 public static function getArticle($id, $type = null)
 {
     $criteria = new CDbCriteria();
     $criteria->compare('cat_id', $id);
     if ($type == null) {
         //$criteria->select = '';
         $model = Articles::model()->findAll($criteria);
     } else {
         $model = Articles::model()->count($criteria);
     }
     return $model;
 }
 /**
  * Manages all models.
  */
 public function actionManage()
 {
     $model = new ArticleLikes('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['ArticleLikes'])) {
         $model->attributes = $_GET['ArticleLikes'];
     }
     $columnTemp = array();
     if (isset($_GET['GridColumn'])) {
         foreach ($_GET['GridColumn'] as $key => $val) {
             if ($_GET['GridColumn'][$key] == 1) {
                 $columnTemp[] = $key;
             }
         }
     }
     $columns = $model->getGridColumn($columnTemp);
     if (isset($_GET['article'])) {
         $article = Articles::model()->findByPk($_GET['article']);
         $title = ': ' . $article->title . ' ' . Phrase::trans(26062, 1) . ' ' . $article->user->displayname;
     } else {
         $title = '';
     }
     $this->pageTitle = Phrase::trans(26065, 1) . $title;
     $this->pageDescription = '';
     $this->pageMeta = '';
     $this->render('admin_manage', array('model' => $model, 'columns' => $columns));
 }
 /**
  * Заполняет ХЛЕБНЫЕ КРОШКИ
  * @param $id
  * @param $type (mainMenu, category, article)
  * @return array
  */
 public static function fillingBreadcrumbs($id, $type)
 {
     $breadcrumbs = array();
     switch ($type) {
         case 'mainMenu':
             $modelMenu = Mainmenu::model()->findByPk($id);
             $breadcrumbs = array($modelMenu->title => array('articles/list_articles', 'listType' => 'razdel', 'idMenu' => $modelMenu->idMenu));
             break;
         case 'category':
             $modelCategory = Categorys::model()->findByPk($id);
             $modelMenu = Mainmenu::model()->findByPk($modelCategory->idMenu);
             $breadcrumbs = array($modelMenu->title => array('articles/list_articles', 'listType' => 'razdel', 'idMenu' => $modelMenu->idMenu));
             $breadcrumbs = $breadcrumbs + array($modelCategory->title => array('articles/list_articles', 'listType' => 'category', 'idMenu' => $modelMenu->idMenu, 'idCategory' => $modelCategory->idCategory));
             break;
         case 'article':
             $modelArticle = Articles::model()->findByPk($id);
             $modelMenu = Mainmenu::model()->findByPk($modelArticle->idMenu);
             $breadcrumbs = array($modelMenu->title => array('articles/list_articles', 'listType' => 'razdel', 'idMenu' => $modelMenu->idMenu));
             if (!empty($modelArticle->idCategory)) {
                 $modelCategory = Categorys::model()->findByPk($modelArticle->idCategory);
                 $breadcrumbs = $breadcrumbs + array($modelCategory->title => array('articles/list_articles', 'listType' => 'category', 'idMenu' => $modelMenu->idMenu, 'idCategory' => $modelCategory->idCategory));
             }
             $breadcrumbs = $breadcrumbs + array($modelArticle->title);
             break;
     }
     return $breadcrumbs;
 }
 /**
  * After delete attributes
  */
 protected function afterDelete()
 {
     parent::afterDelete();
     //delete article image
     $article_path = "public/article/" . $this->article_id;
     if (in_array($this->article->article_type, array(1, 3)) && $this->media != '' && file_exists($article_path . '/' . $this->media)) {
         rename($article_path . '/' . $this->media, 'public/article/verwijderen/' . $this->article_id . '_' . $this->media);
     }
     //reset cover in article
     $data = self::getPhoto($this->article_id);
     if ($data != null) {
         if ($this->cover == 1) {
             $photo = self::model()->findByPk($data[0]->media_id);
             $photo->cover = 1;
             if ($photo->update()) {
                 $cover = Articles::model()->findByPk($this->article_id);
                 $cover->media_id = $photo->media_id;
                 $cover->update();
             }
         }
     }
 }