本文整理汇总了PHP中Articles::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Articles::model方法的具体用法?PHP Articles::model怎么用?PHP Articles::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Articles
的用法示例。
在下文中一共展示了Articles::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderContent
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));
}
示例2: run
public function run()
{
$criteria = new CDbCriteria();
$criteria->limit = 4;
$criteria->order = 'RAND()';
$model = Articles::model()->findAll($criteria);
$this->render('popularProducts', array('model' => $model));
}
示例3: run
public function run()
{
$article = Articles::model()->onSite()->byType($this->type)->find();
if (empty($article)) {
return;
}
$this->render('article', array('article' => $article));
}
示例4: loadModelByAlias
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;
}
示例5: loadModel
/**
* 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;
}
示例6: actionIndexing
/**
* 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();
}
示例7: actionDelBloger
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');
}
}
示例8: actionDelete
/**
* 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'));
}
}
示例9: actionDelete
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'));
}
}
示例10: init
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);
}
示例11: renderContent
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));
}
示例12: getArticlesToSlider
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);
}
示例13: renderContent
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));
}
示例14: renderContent
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));
}
示例15: actionUser_cabinet
/**
* Кабинет пользователя
*/
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)));
}