public function actionIndex() { $model = new News(); $model->unsetAttributes(); $model->attributes = $this->aRequest('News'); $this->render('index', array('model' => $model)); }
public function actionNews($slug = null) { if ($slug === null) { $model = new News('search'); $model->unsetAttributes(); $model->isList = true; $model->category_id = Yii::app()->request->getParam('category_id'); $this->render('news', array('model' => $model)); } else { $model = $this->loadNews($slug); $model->saveCounters(array('countViews' => 1)); // to memcache mb $comment = new NewsComment(); if (isset($_POST['ajax']) && $_POST['ajax'] === 'newsComment-form') { echo CActiveForm::validate($comment); Yii::app()->end(); } if (isset($_POST['NewsComment'])) { $comment->attributes = $_POST['NewsComment']; $comment->news_id = $model->id; $comment->user_id = Yii::app()->user->id; if ($comment->validate() && $comment->preSave()) { $comment->unsetAttributes(); Yii::app()->user->setFlash('comment_success', true); $this->redirect(array('/site/news', 'slug' => $model->slug, '#' => 'comments')); } } $criteria = new CDbCriteria(); $criteria->compare('news_id', $model->id); $criteria->order = '`id` ASC'; $comments = NewsComment::model()->findAll($criteria); $this->render('news_inner', array('model' => $model, 'comment' => $comment, 'comments' => $comments)); } }
public function actionIndex() { $model = new News('search'); $model->unsetAttributes(); if (isset($_GET['News'])) { $model->attributes = $_GET['News']; } $this->render('index', array('model' => $model)); }
public function actionList() { $model = new News('search'); $model->unsetAttributes(); if(isset($_GET['News'])) $model->attributes=$_GET['News']; Yii::app()->session['myurl'] = $this->createUrl('list'); $this->render('list',array('model'=>$model)); }
public function actionManage() { $model = new News('search'); $model->unsetAttributes(); if (isset($_GET['News'])) { $model->setAttributes($_GET['News']); } $this->render('manage', array('model' => $model)); }
public function actionIndex() { $model = new News('search'); $model->unsetAttributes(); if (isset($_GET['News'])) { $model->setAttributes($_GET['News']); } $dataProvider = $model->search(); $this->render('//news/index', array('dataProvider' => $dataProvider, 'model' => $model)); }
/** * Manages all models. */ public function actionAdmin() { $model = new News('search'); $model->unsetAttributes(); // clear any default values if (isset($_GET['News'])) { $model->attributes = $_GET['News']; } $this->render('admin', array('model' => $model)); }
/** * Lists all models. */ public function actionIndex() { $model=new News('search'); $model->unsetAttributes(); // clear any default values if(isset($_GET['News'])) $model->attributes=$_GET['News']; $this->render('index',array( 'model'=>$model, )); }
public function actionIndex() { $this->pageName = Yii::t('NewsModule.default', 'MODULE_NAME'); $this->breadcrumbs = array($this->pageName); $model = new News('search'); $model->unsetAttributes(); if (!empty($_GET['News'])) { $model->attributes = $_GET['News']; } $this->render('index', array('model' => $model)); }
public function actionIndex() { $this->layout = '//layouts/admin'; $this->pageTitle = 'Новости'; $this->breadcrumbs = array('Новости'); $model = new News('search'); $model->unsetAttributes(); if (isset($_GET['News'])) { $model->attributes = $_GET['News']; } $this->render('index', array('model' => $model)); }
public function actionIndex() { $model = new News('search'); $model->unsetAttributes(); // clear any default values if (isset($_GET['News'])) { $model->attributes = $_GET['News']; $model->parent_id = $model->category_news_id; $model->category_news_id = null; dump($model->attributes, false); } $this->render('index', array('model' => $model)); }
public function actionIndex($id) { $catelog = CategoriesNews::model()->findByPk($id); if ($catelog == null) { throw new CHttpException('404', 'Không tìm thấy trang.'); } $model = new News('search'); $model->unsetAttributes(); // clear any default values if (isset($_GET['News'])) { $model->attributes = $_GET['News']; } $this->render('index', array('model' => $model, 'catalog' => $catelog)); }
/** * Manages all models. */ public function actionIndex($idTree = null, $organization = null) { if ($idTree != null && $organization != null) { $allIfns = false; if (!Tree::model()->exists('id=:id AND module=:module and organization=:organization', array(':id' => $idTree, ':module' => 'news', ':organization' => $organization))) { throw new CHttpException(404, 'Страница не найдена.'); } } else { $allIfns = true; } $model = new News('search'); $model->unsetAttributes(); // clear any default values if (isset($_GET['News'])) { $model->attributes = $_GET['News']; } $this->render('index', array('model' => $model, 'idTree' => $allIfns ? CHtml::listData(Organization::model()->findAll('code<>:code', array(':code' => '8600')), 'code', 'code') : $idTree, 'organization' => $organization, 'allIfns' => $allIfns)); }
/** * Manages all models. */ public function actionAdmin() { if ($this->menu_use[3]) { $model = new News('searchInSide'); $news_type_list = array(); $criteria = new CDbCriteria(); $criteria->condition = 'status=:status AND news_type_id=5'; $criteria->params = array(':status' => 1); $criteria->order = 'sort_order'; $news_type = NewsGroup::model()->findAll($criteria); foreach ($news_type as $type) { $news_type_list[$type->news_group_id] = $type->name_th; } $model->unsetAttributes(); // clear any default values if (isset($_GET['News'])) { $model->attributes = $_GET['News']; } $this->render('admin', array('model' => $model, 'news_type_list' => $news_type_list)); } else { $this->redirect(array('site/index')); } }
/** * Manages all models. */ public function actionAdmin() { if(Yii::app()->user->checkAccess('admin')){ $model=new News('search'); $model->unsetAttributes(); // clear any default values if(isset($_GET['News'])) $model->attributes=$_GET['News']; $this->render('admin',array( 'model'=>$model, )); } else { $this->redirect('/admin/user/login'); } }
/** * Manages all models. */ public function actionAdmin() { Yii::app()->bootstrap->registerJS(); Yii::app()->bootstrap->registerJSBackend(); $model = new News('search'); $model->unsetAttributes(); // clear any default values if (isset($_GET['News'])) { $model->attributes = $_GET['News']; } //phan trang dang dropdown if (isset($_GET['pageSize'])) { Yii::app()->user->setState('pageSize', (int) $_GET['pageSize']); unset($_GET['pageSize']); } $this->render('admin', array('model' => $model)); }
/** * Manages all models. * * @return void */ public function actionIndex() { $model = new News('search'); $model->unsetAttributes(); // clear any default values $model->setAttributes(Yii::app()->getRequest()->getParam('News', array())); $this->render('index', array('model' => $model)); }
/** * Manages all models. */ public function actionAdmin() { if ($this->menu_use[2]) { $model = new News('searchStudent'); $model->unsetAttributes(); // clear any default values if (isset($_GET['News'])) { $model->attributes = $_GET['News']; } $this->render('admin', array('model' => $model)); } else { $this->redirect(array('site/index')); } }
/** * Manages all models. */ public function actionIndex() { $model = new News('search'); $model->attachBehavior('dateComparator', array('class' => 'DateComparator')); $model->unsetAttributes(); // clear any default values // set attributes from get if (isset($_GET['News'])) { $model->attributes = $_GET['News']; } $this->render('list', array('model' => $model)); }
/** * Lists all models. */ public function actionIndex() { //$dataProvider = new CActiveDataProvider('News'); $model = new News('search'); $model->unsetAttributes(); // clear any default values $criteria = new CDbCriteria(); if (isset($_GET['News'])) { $model->attributes = $_GET['News']; if (isset($_GET['beginDate']) && isset($_GET['endDate'])) { $criteria->addBetweenCondition('date', $_GET['beginDate'], $_GET['endDate']); } } $this->render('index', array('model' => $model, 'titleListNews' => $this->config->title, 'criteria' => $criteria)); }
/** * @test */ public function search() { $model = new News('search'); $model->unsetAttributes(); // recherche par date $model->unsetAttributes(); $model->event_date = "01/06/2013"; $data = $model->search()->data; $this->assertEquals(1, count($data)); $this->assertEquals($this->news('n1')->id, $data[0]->id); // recherche par statut $model->unsetAttributes(); $model->enabled = 0; $data = $model->search()->data; $this->assertEquals(1, count($data)); // recherche par catégorie $model->unsetAttributes(); $categoryId = 1; // la plupart des news sont de cette catégorie $model->category_id = $categoryId; $count = Yii::app()->db->createCommand("SELECT count(*) as cpt FROM news WHERE category_id = {$categoryId}")->queryScalar(); $this->assertEquals($count, count($model->search()->data)); $model->unsetAttributes(); $categoryId = 2; // il y a quelques news de cette catégorie $model->category_id = $categoryId; $count = Yii::app()->db->createCommand("SELECT count(*) as cpt FROM news WHERE category_id = {$categoryId}")->queryScalar(); $this->assertEquals($count, count($model->search()->data)); $model->unsetAttributes(); $categoryId = 99; // aucune news de cette catégorie $model->category_id = $categoryId; $count = Yii::app()->db->createCommand("SELECT count(*) as cpt FROM news WHERE category_id = {$categoryId}")->queryScalar(); $this->assertEquals($count, count($model->search()->data)); }
/** * Manages all models. */ public function actionAdmin() { $this->pageTitle = Yii::t('titles', 'NEWS_ADMIN'); $this->layout = '//layouts/header_user'; $model = new News('search'); $model->unsetAttributes(); // clear any default values if (isset($_GET['News'])) { $model->attributes = $_GET['News']; } $this->render('admin', array('model' => $model)); }
/** * Manages all models. */ public function actionAdmin($idTree) { if (!Tree::model()->exists('id=:id AND module=:module', array(':id' => $idTree, 'module' => 'page'))) { throw new CHttpException(404, 'Страница не найдена.'); } if (!(Yii::app()->user->admin || Access::model()->checkAccessUserForTree($idTree))) { throw new CHttpException(403, 'Доступ запрещен.'); } $model = new News('search'); $model->unsetAttributes(); // clear any default values if (isset($_GET['News'])) { $model->attributes = $_GET['News']; } $this->render('admin', array('model' => $model, 'idTree' => $idTree)); }