protected function renderContent()
 {
     //import model
     Yii::import('application.modules.article.models.ArticleCategory');
     $criteria = new CDbCriteria();
     if ($this->publish != null) {
         $criteria->condition = 'publish = :publish';
         $criteria->params = array(':publish' => $this->publish);
     }
     $model = ArticleCategory::model()->findAll($criteria);
     $this->render('front_article_category', array('model' => $model));
 }
Exemplo n.º 2
0
 public function deleteApproval($id)
 {
     if (empty($id)) {
         return false;
     }
     $ret = $this->deleteByPk($id);
     if ($ret) {
         ArticleCategory::model()->updateAll(array("aid" => 0), "aid={$id}");
         OfficialdocCategory::model()->updateAll(array("aid" => 0), "aid={$id}");
     }
     return $ret;
 }
 public function handleArticleCategory($event)
 {
     $categorys = array();
     Yii::import("application.modules.article.model.ArticleCategory", true);
     $records = ArticleCategory::model()->findAll(array("order" => "sort ASC"));
     if (!empty($records)) {
         foreach ($records as $record) {
             $cat = $record->attributes;
             $categorys[$cat["catid"]] = $cat;
         }
     }
     Syscache::model()->modify("articlecategory", $categorys);
 }
Exemplo n.º 4
0
 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     $setting = ArticleSetting::model()->findByPk(1, array('select' => 'meta_description, meta_keyword'));
     if (isset($_GET['category']) && $_GET['category'] != '') {
         $title = ArticleCategory::model()->findByPk($_GET['category']);
     }
     $criteria = new CDbCriteria();
     $criteria->condition = 'publish = :publish AND published_date <= curdate()';
     $criteria->params = array(':publish' => 1);
     $criteria->order = 'published_date DESC';
     if (isset($_GET['category']) && $_GET['category'] != '') {
         $criteria->compare('cat_id', $_GET['category']);
     }
     $dataProvider = new CActiveDataProvider('Articles', array('criteria' => $criteria, 'pagination' => array('pageSize' => 10)));
     $this->pageTitle = 'Articles';
     $this->pageDescription = isset($_GET['category']) && $_GET['category'] != '' ? Phrase::trans($title->name, 2) : $setting->meta_description;
     $this->pageMeta = isset($_GET['category']) && $_GET['category'] != '' ? Phrase::trans($title->desc, 2) : $setting->meta_keyword;
     $this->render('front_index', array('dataProvider' => $dataProvider));
 }
Exemplo n.º 5
0
 public static function handleApproval($datas)
 {
     $allApprovals = Approval::model()->fetchAllSortByPk("id");
     $allCategorys = ArticleCategory::model()->fetchAllSortByPk("catid");
     $artApprovals = ArticleApproval::model()->fetchAllGroupByArtId();
     $backArtIds = ArticleBack::model()->fetchAllBackArtId();
     foreach ($datas as &$art) {
         $art["back"] = in_array($art["articleid"], $backArtIds) ? 1 : 0;
         $art["approval"] = $art["approvalStep"] = array();
         $catid = $art["catid"];
         if (!empty($allCategorys[$catid]["aid"])) {
             $aid = $allCategorys[$catid]["aid"];
             if (!empty($allApprovals[$aid])) {
                 $art["approval"] = $allApprovals[$aid];
             }
         }
         if (!empty($art["approval"])) {
             $art["approvalName"] = !empty($art["approval"]) ? $art["approval"]["name"] : "";
             $art["artApproval"] = isset($artApprovals[$art["articleid"]]) ? $artApprovals[$art["articleid"]] : array();
             $art["stepNum"] = count($art["artApproval"]);
             $step = array();
             foreach ($art["artApproval"] as $artApproval) {
                 $step[$artApproval["step"]] = User::model()->fetchRealnameByUid($artApproval["uid"]);
             }
             for ($i = 1; $i <= $art["approval"]["level"]; $i++) {
                 if ($i <= $art["stepNum"]) {
                     $art["approval"][$i]["approvaler"] = isset($step[$i]) ? $step[$i] : "未知";
                 } else {
                     $levelName = Approval::model()->getLevelNameByStep($i);
                     $approvalUids = $art["approval"][$levelName];
                     $art["approval"][$i]["approvaler"] = User::model()->fetchRealnamesByUids($approvalUids, "、");
                 }
             }
         }
     }
     return $datas;
 }
Exemplo n.º 6
0
 public function getList($type = 1, $catid = 0, $search = "")
 {
     $gUid = Ibos::app()->user->uid;
     $childCatIds = "";
     if (!empty($catid)) {
         $this->catid = $catid;
         $childCatIds = ArticleCategory::model()->fetchCatidByPid($this->catid, true);
     }
     if (!empty($search)) {
         $this->condition = "subject like '%{$search}%'";
     }
     $articleidArr = ArticleReader::model()->fetchArticleidsByUid(Ibos::app()->user->uid);
     $this->condition = ArticleUtil::joinListCondition($type, $articleidArr, $childCatIds, $this->condition);
     $datas = Article::model()->fetchAllAndPage($this->condition);
     $listData = $datas["datas"];
     foreach ($listData as $key => $value) {
         $value["content"] = StringUtil::cutStr(strip_tags($value["content"]), 30);
         $listData[$key] = array_filter($value);
         $listData[$key]["readstatus"] = ArticleReader::model()->checkIsRead($value["articleid"], $gUid);
     }
     $return["datas"] = $listData;
     $return["pages"] = array("pageCount" => $datas["pages"]->getPageCount(), "page" => $datas["pages"]->getCurrentPage(), "pageSize" => $datas["pages"]->getPageSize());
     return $return;
 }
    public function actionDelete($id) {
        $model = $this->loadModel($id);

        $desc = $model->descendants()->findAll(array('order'=>'title'));
        if(!$desc){
                
        } else {
            $error = "Рубрика имеет подрубрики:\n ";
            foreach ($desc as $rub) {
                $error .= $rub->title."\n";
            }
            $error .= 'Сначала перенесите или удалите подрубрики.';
            echo CJSON::encode(array('success'=>false, 'message'=>$error, 'errortype'=>1));
            Yii::app()->end();
        }
        $count = ArticleCategory::model()->countByAttributes(array('category'=>$model->id));
        if($count > 0){
            $error = 'В рубрике имеются '.$count.' статей. Перенесите сначала статьи в другую рубрику.';
            echo CJSON::encode(array('success'=>false, 'message'=>$error, 'errortype'=>2));
            Yii::app()->end();
        }


        //Delete if not root node
        $model->tree->delete();
        echo CJSON::encode(array('success'=>true));

        Yii::app()->end();

    } 
Exemplo n.º 8
0
 /**
  * Set organization categories 
  * @param array $categories ids.
  */
 public function setCategories(array $categories, $add = false)
 {
     $dontDelete = array();
     if (!empty($categories)) {
         foreach ($categories as $c) {
             if (empty($c)) {
                 continue;
             }
             $found = ArticleCategory::model()->findByAttributes(array('category' => $c, 'article' => $this->id));
             // если не было категории - делаем
             if (!$found) {
                 $record = new ArticleCategory();
                 $record->category = (int) $c;
                 $record->article = $this->id;
                 $record->save(false);
             }
             $dontDelete[] = $c;
         }
     }
     if ($add === false) {
         // Удаляем все категории, которых не было в массиве
         if (sizeof($dontDelete) > 0) {
             $cr = new CDbCriteria();
             $cr->addNotInCondition('category', $dontDelete);
             ArticleCategory::model()->deleteAllByAttributes(array('article' => $this->id), $cr);
         } else {
             // удаляем все категории, т.к. пустой массив
             // Delete all relations
             ArticleCategory::model()->deleteAllByAttributes(array('article' => $this->id));
         }
     }
 }
 /**
  * Manages all models.
  */
 public function actionManage()
 {
     $model = new Articles('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['Articles'])) {
         $model->attributes = $_GET['Articles'];
     }
     $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['category'])) {
         $category = ArticleCategory::model()->findByPk($_GET['category']);
         $title = ': ' . Phrase::trans($category->name, 2);
     } else {
         $title = '';
     }
     $this->pageTitle = Yii::t('phrase', 'View Articles') . $title;
     $this->pageDescription = Yii::t('phrase', 'Use this page to search for and manage article entries. To Approve or Feature an article, just click on the icon, it will automate turn on and off per that setting. To edit, delete, or manage an article, please login as that user, and perform your actions.');
     $this->pageMeta = '';
     $this->render('admin_manage', array('model' => $model, 'columns' => $columns));
 }
Exemplo n.º 10
0
 public function getData($condition = "")
 {
     $categoryData = ArticleCategory::model()->fetchAll($condition);
     return $categoryData;
 }
Exemplo n.º 11
0
 private function back()
 {
     $uid = Ibos::app()->user->uid;
     $artIds = trim(EnvUtil::getRequest("articleids"), ",");
     $reason = StringUtil::filterCleanHtml(EnvUtil::getRequest("reason"));
     $ids = explode(",", $artIds);
     if (empty($ids)) {
         $this->ajaxReturn(array("isSuccess" => false, "msg" => Ibos::lang("Parameters error", "error")));
     }
     $sender = User::model()->fetchRealnameByUid($uid);
     foreach ($ids as $artId) {
         $art = Article::model()->fetchByPk($artId);
         $categoryName = ArticleCategory::model()->fetchCateNameByCatid($art["catid"]);
         if (!$this->checkIsApprovaler($art, $uid)) {
             $this->ajaxReturn(array("isSuccess" => false, "msg" => Ibos::lang("You do not have permission to verify the article")));
         }
         $config = array("{sender}" => $sender, "{subject}" => $art["subject"], "{category}" => $categoryName, "{content}" => $reason, "{url}" => Ibos::app()->urlManager->createUrl("article/default/index", array("type" => "notallow")));
         Notify::model()->sendNotify($art["author"], "article_back_message", $config, $uid);
         ArticleBack::model()->addBack($artId, $uid, $reason, TIMESTAMP);
     }
     $this->ajaxReturn(array("isSuccess" => true, "msg" => Ibos::lang("Operation succeed", "message")));
 }
 /**
  * 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 = ArticleCategory::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('phrase', 'The requested page does not exist.'));
     }
     return $model;
 }
Exemplo n.º 13
0
 public function actionDelete($id)
 {
     $model = $this->loadModel($id);
     $error = '';
     $desc = $model->descendants()->findAll(array('order' => 'title'));
     if (!$desc) {
     } else {
         $error .= "Тег имеет вложенные теги:\n ";
         foreach ($desc as $rub) {
             $error .= $rub->title . "\n";
         }
         $error .= 'Сначала перенесите или удалите вложенные теги.';
     }
     $count = ArticleCategory::model()->countByAttributes(array('category' => $model->id));
     if ($count > 0) {
         $error .= 'Имеются ' . $count . ' привязки. Перенесите сначала привязанные в другой тег.';
     }
     if (!empty($error)) {
         echo CJSON::encode(array('success' => false, 'message' => $error));
         Yii::app()->end();
     }
     //Delete if not root node
     $model->tree->delete();
     echo CJSON::encode(array('success' => true));
     Yii::app()->end();
 }
Exemplo n.º 14
0
 public function fetchUnApprovalArtIds($catid, $uid)
 {
     $backArtIds = ArticleBack::model()->fetchAllBackArtId();
     $backArtIdStr = implode(",", $backArtIds);
     $backCondition = empty($backArtIdStr) ? "" : "AND `articleid` NOT IN({$backArtIdStr})";
     if (empty($catid)) {
         $catids = ArticleCategory::model()->fetchAllApprovalCatidByUid($uid);
         $catidStr = implode(",", $catids);
         $condition = "((FIND_IN_SET( `catid`, '{$catidStr}') {$backCondition} ) OR `author` = {$uid})";
     } else {
         $isApproval = ArticleCategory::model()->checkIsApproval($catid, $uid);
         $condition = $isApproval ? "(`catid` = {$catid} {$backCondition} )" : " (`catid` = {$catid} AND `author` = {$uid})";
     }
     $record = $this->fetchAll(array("select" => array("articleid"), "condition" => "`status` = 2 AND " . $condition));
     $artIds = ConvertUtil::getSubByKey($record, "articleid");
     return $artIds;
 }
Exemplo n.º 15
0
 protected function getCurApproval()
 {
     $catid = EnvUtil::getRequest("catid");
     $category = ArticleCategory::model()->fetchByPk($catid);
     $approval = Approval::model()->fetchByPk($category["aid"]);
     $this->ajaxReturn(array("approval" => $approval));
 }
Exemplo n.º 16
0
 /**
  * Set default columns to display
  */
 protected function afterConstruct()
 {
     $controller = strtolower(Yii::app()->controller->id);
     if (count($this->defaultColumns) == 0) {
         /*
         $this->defaultColumns[] = array(
         	'class' => 'CCheckBoxColumn',
         	'name' => 'id',
         	'selectableRows' => 2,
         	'checkBoxHtmlOptions' => array('name' => 'trash_id[]')
         );
         */
         $this->defaultColumns[] = array('header' => 'No', 'value' => '$this->grid->dataProvider->pagination->currentPage*$this->grid->dataProvider->pagination->pageSize + $row+1');
         $this->defaultColumns[] = array('name' => 'title', 'value' => '$data->title."<br/><span>".Utility::shortText(Utility::hardDecode($data->body),200)."</span>"', 'htmlOptions' => array('class' => 'bold'), 'type' => 'raw');
         $category = ArticleCategory::model()->findByPk($_GET['category']);
         if (!isset($_GET['category']) || isset($_GET['category']) && $category->dependency == 0) {
             if ($category->dependency == 0) {
                 $parent = $_GET['category'];
             } else {
                 $parent = null;
             }
             $this->defaultColumns[] = array('name' => 'cat_id', 'value' => 'Phrase::trans($data->cat->name, 2)', 'filter' => ArticleCategory::getCategory(null, $parent), 'type' => 'raw');
         }
         $this->defaultColumns[] = array('name' => 'creation_search', 'value' => '$data->creation_relation->displayname');
         $this->defaultColumns[] = array('name' => 'creation_date', 'value' => 'Utility::dateFormat($data->creation_date)', 'htmlOptions' => array('class' => 'center'), 'filter' => Yii::app()->controller->widget('zii.widgets.jui.CJuiDatePicker', array('model' => $this, 'attribute' => 'creation_date', 'language' => 'ja', 'i18nScriptFile' => 'jquery.ui.datepicker-en.js', 'htmlOptions' => array('id' => 'creation_date_filter'), 'options' => array('showOn' => 'focus', 'dateFormat' => 'dd-mm-yy', 'showOtherMonths' => true, 'selectOtherMonths' => true, 'changeMonth' => true, 'changeYear' => true, 'showButtonPanel' => true)), true));
         if (in_array($controller, array('o/admin'))) {
             $this->defaultColumns[] = array('name' => 'published_date', 'value' => 'Utility::dateFormat($data->published_date)', 'htmlOptions' => array('class' => 'center'), 'filter' => Yii::app()->controller->widget('zii.widgets.jui.CJuiDatePicker', array('model' => $this, 'attribute' => 'published_date', 'language' => 'ja', 'i18nScriptFile' => 'jquery.ui.datepicker-en.js', 'htmlOptions' => array('id' => 'published_date_filter'), 'options' => array('showOn' => 'focus', 'dateFormat' => 'dd-mm-yy', 'showOtherMonths' => true, 'selectOtherMonths' => true, 'changeMonth' => true, 'changeYear' => true, 'showButtonPanel' => true)), true));
         }
         if (!isset($_GET['type'])) {
             if (OmmuSettings::getInfo('site_headline') == 1) {
                 $this->defaultColumns[] = array('name' => 'headline', 'value' => '$data->headline == 1 ? Chtml::image(Yii::app()->theme->baseUrl.\'/images/icons/publish.png\') : Utility::getPublish(Yii::app()->controller->createUrl("headline",array("id"=>$data->article_id)), $data->headline, 9)', 'htmlOptions' => array('class' => 'center'), 'filter' => array(1 => Yii::t('phrase', 'Yes'), 0 => Yii::t('phrase', 'No')), 'type' => 'raw');
             }
             $this->defaultColumns[] = array('name' => 'publish', 'value' => 'Utility::getPublish(Yii::app()->controller->createUrl("publish",array("id"=>$data->article_id)), $data->publish, 1)', 'htmlOptions' => array('class' => 'center'), 'filter' => array(1 => Yii::t('phrase', 'Yes'), 0 => Yii::t('phrase', 'No')), 'type' => 'raw');
         }
     }
     parent::afterConstruct();
 }