当前位置: 首页>>代码示例>>PHP>>正文


PHP Post::model方法代码示例

本文整理汇总了PHP中Post::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::model方法的具体用法?PHP Post::model怎么用?PHP Post::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Post的用法示例。


在下文中一共展示了Post::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run()
 {
     $tags = Tag::model()->findAll();
     if ($tags) {
         foreach ($tags as $tag) {
             $post = Post::model()->findAll("FIND_IN_SET(:tag, tags)", array(':tag' => $tag->tag_name));
             $image = Image::model()->findAll("FIND_IN_SET(:tag, tags)", array(':tag' => $tag->tag_name));
             $soft = Soft::model()->findAll("FIND_IN_SET(:tag, seo_keywords)", array(':tag' => $tag->tag_name));
             $video = Video::model()->findAll("FIND_IN_SET(:tag, seo_keywords)", array(':tag' => $tag->tag_name));
             if (!$post && !$image && !$soft && !$video) {
                 $tag->delete();
             } else {
                 $tag->data_count = count($post) + count($image) + count($soft);
                 $tag->save();
             }
         }
     }
     $tagdatas = TagData::model()->findAll();
     if ($tagdatas) {
         foreach ($tagdatas as $value) {
             $modelType = ModelType::model()->findByPk($value->type);
             $model = $modelType->model;
             $data = $model::model()->findByPk($value->content_id);
             if (!$data) {
                 $value->delete();
             }
         }
     }
     $this->controller->message('success', Yii::t('admin', 'Reset Tags Success'), $this->controller->createUrl('index'));
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:30,代码来源:ResetAction.php

示例2: _opCollection

 /**
  * 处理ajax收藏操作
  * 
  */
 private function _opCollection()
 {
     $uid = Yii::app()->user->id;
     if (!$uid) {
         $ret = array('state' => 'error', 'message' => Yii::t('common', 'You Need Login'));
         return $ret;
     }
     $postid = Yii::app()->request->getParam('id');
     $post = Post::model()->findByPk($postid);
     if (!$post) {
         $ret = array('state' => 'error', 'message' => Yii::t('common', 'Collect Failed'));
         return $ret;
     }
     $collect_mod = new Collect();
     //判断是否已经收藏
     $exist_collect = $collect_mod->find('user_id=:uid AND cid=:cid AND type=:type_id', array(':uid' => $uid, ':cid' => $postid, ':type_id' => $type_id));
     if ($exist_collect) {
         $ret = array('state' => 'error', 'message' => Yii::t('common', 'You Have Collected it'));
     } else {
         //收藏
         $collect_mod->cid = $postid;
         $collect_mod->title = $post->title;
         $collect_mod->user_id = $uid;
         $collect_mod->url = Yii::app()->request->hostinfo . $this->controller->createUrl('post/view', array('id' => $postid));
         $collect_mod->type = $type_id;
         $collect_mod->create_time = time();
         if ($collect_mod->save()) {
             $post->updateCounters(array('favorite_count' => 1), 'id=:id', array('id' => $postid));
             $ret = array('state' => 'success', 'message' => Yii::t('common', 'Collect Success'), 'count' => $post->favorite_count + 1);
         } else {
             $ret = array('state' => 'error', 'message' => Yii::t('common', 'Collect Failed'));
         }
     }
     return $ret;
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:39,代码来源:AjaxAction.php

示例3: actionSitemapxml

 /**
  * Generate sitemap.
  */
 public function actionSitemapxml()
 {
     $posts = Post::model()->findAll(array('order' => 'createTime DESC', 'condition' => 'status=' . Post::STATUS_PUBLISHED));
     $pages = Page::model()->findAll(array('order' => 'createTime DESC', 'condition' => 'status=' . Page::STATUS_PUBLISHED));
     header('Content-Type: application/xml');
     $this->renderPartial('../site/sitemapxml', array('posts' => $posts, 'pages' => $pages));
 }
开发者ID:Greka163,项目名称:Yii-blog-new,代码行数:10,代码来源:SiteController.php

示例4: actionComments

 public function actionComments($id)
 {
     if (null === ($model = Post::model()->findByPk($id))) {
         throw new CHttpException(404);
     }
     $this->sendResponse(200, CJSON::encode($model->comments));
 }
开发者ID:jerrylsxu,项目名称:YiiBackbone,代码行数:7,代码来源:PostController.php

示例5: actionAbout2

 public function actionAbout2()
 {
     Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/post.css');
     Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/xinjia.css');
     $catalog_id = Yii::app()->request->getQuery('id');
     if ($catalog_id == '') {
         $catalog_id = 32;
     }
     //				$post = Post::model()->findByPk($id);
     //        $post->view_count += 1;
     //        $post->save();
     //$catalog_id = $post->catalog_id;
     //			nybanner_mls  nybanner_gflc  nybanner_gfht   nybanner_fcjj
     if ($catalog_id == 32) {
         $banner_name = "nybanner_mls";
     }
     if ($catalog_id == 33) {
         $banner_name = "nybanner_gflc";
     }
     if ($catalog_id == 34) {
         $banner_name = "nybanner_gfht";
     }
     if ($catalog_id == 36) {
         $banner_name = "nybanner_fcjj";
     }
     $prev_post = Post::model()->findAll(array('select' => 'id, title, content, view_count', 'condition' => ' catalog_id = :catalog_id', 'params' => array(':catalog_id' => $catalog_id), 'order' => 'id ASC', 'limit' => 1));
     $this->render('about_2', array('banner_name' => $banner_name, 'post' => $post, 'prev_post' => $prev_post[0]));
 }
开发者ID:zywh,项目名称:maplecity,代码行数:28,代码来源:About2Controller.php

示例6: onSearchRebuild

 /**
  * On rebuild of the search index, rebuild all post records
  *
  * @param type $event
  */
 public static function onSearchRebuild($event)
 {
     foreach (Post::model()->findAll() as $obj) {
         #    HSearch::getInstance()->addModel($obj);
         print "p";
     }
 }
开发者ID:alefernie,项目名称:intranet,代码行数:12,代码来源:PostModule.php

示例7: actionIndex

 public function actionIndex()
 {
     $posts = Post::model()->recently()->findAll();
     // renders the view file 'protected/views/site/index.php'
     // using the default layout 'protected/views/layouts/main.php'
     $this->render('index');
 }
开发者ID:knut,项目名称:hamster,代码行数:7,代码来源:SiteController.php

示例8: actionWrite

 public function actionWrite()
 {
     $post = new Post();
     $post->blog_id = Yii::app()->getRequest()->getParam('blog-id');
     if ($postId = (int) Yii::app()->getRequest()->getQuery('id')) {
         $post = Post::model()->findUserPost($postId, Yii::app()->getUser()->getId());
         if (null === $post) {
             throw new CHttpException(404);
         }
     }
     if (Yii::app()->getRequest()->getIsPostRequest() && !empty($_POST['Post'])) {
         $data = Yii::app()->getRequest()->getPost('Post');
         $data['user_id'] = Yii::app()->getUser()->getId();
         $data['status'] = Yii::app()->getRequest()->getPost('draft', Post::STATUS_PUBLISHED);
         $data['tags'] = Yii::app()->getRequest()->getPost('tags');
         if ($post->createPublicPost($data)) {
             $message = Yii::t('BlogModule.blog', 'Post sent for moderation!');
             $redirect = ['/blog/publisher/my'];
             if ($post->isDraft()) {
                 $message = Yii::t('BlogModule.blog', 'Post saved!');
             }
             if ($post->isPublished()) {
                 $message = Yii::t('BlogModule.blog', 'Post published!');
                 $redirect = ['/blog/post/show', 'slug' => $post->slug];
             }
             Yii::app()->getUser()->setFlash(\yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, $message);
             $this->redirect($redirect);
         }
     }
     $this->render('write', ['post' => $post, 'blogs' => (new Blog())->getListForUser(Yii::app()->getUser()->getId())]);
 }
开发者ID:RonLab1987,项目名称:43berega,代码行数:31,代码来源:PublisherController.php

示例9: testIsDeleted

 function testIsDeleted()
 {
     $post = Post::model()->findByPk(1);
     $this->assertFalse($post->isRemoved());
     $post = Post::model()->findByPk(2);
     $this->assertTrue($post->isRemoved());
 }
开发者ID:moohwaan,项目名称:yii-application-cookbook-2nd-edition-code,代码行数:7,代码来源:SoftDeleteBehaviorTest.php

示例10: actionDelete

 public function actionDelete()
 {
     if (Post::model()->deleteUserPost(Yii::app()->getRequest()->getQuery('id'), Yii::app()->getUser()->getId())) {
         Yii::app()->ajax->success();
     }
     Yii::app()->ajax->failure();
 }
开发者ID:sepaker,项目名称:yupe,代码行数:7,代码来源:PublisherController.php

示例11: loadTerm

 public function loadTerm($limit = 5, $data, $type = array(), $operation = 'OR')
 {
     $labels = unserialize($data);
     $cond = '';
     $cond = "post_image!='' ";
     $criteria = new CDbCriteria();
     if (is_array($type)) {
         $criteria->with = $type;
     }
     foreach ($type as $key) {
         if (!empty($labels)) {
             $first = true;
             foreach ($labels as $label => $val) {
                 if ($first) {
                     $cond .= ' AND ';
                     $first = false;
                 }
                 $cond .= " {$key}.term_id='{$val}' ";
                 if (end($labels) !== $val) {
                     $cond .= $operation;
                 }
             }
         }
     }
     $criteria->condition = $cond;
     $criteria->order = 'ID DESC';
     $criteria->limit = $limit;
     $criteria->together = true;
     $model = Post::model()->is_publish()->findAll($criteria);
     return $model;
 }
开发者ID:beckblurry,项目名称:Yii1-Base-Core-V.Alpha.1,代码行数:31,代码来源:slider.php

示例12: actionPosts

 public function actionPosts($name)
 {
     $tag = urldecode($name);
     $this->setSiteTitle(t('tag_posts', 'main', array('{name}' => $tag)));
     // @todo 关键字的描述没有指定
     $this->setPageKeyWords($tag);
     $this->setPageDescription(t('tag_posts_page_description', 'main', array('{name}' => $tag)));
     cs()->registerMetaTag('all', 'robots');
     $cmd = app()->getDb()->createCommand()->select('p.id')->from(TABLE_TAG . ' t')->where('t.name = :tagname', array(':tagname' => $tag))->join(TABLE_POST_TAG . ' pt', 'pt.tag_id = t.id')->join(TABLE_POST . ' p', 'p.id = pt.post_id');
     $ids = $cmd->queryColumn();
     if (count($ids) > 0) {
         $criteria = new CDbCriteria();
         if (param('post_list_type') == POST_LIST_TYPE_TITLE) {
             $criteria->select = array('t.id', 't.title', 't.visit_nums', 't.comment_nums', 't.create_time');
         }
         $criteria->order = 't.istop, t.create_time desc, t.id desc';
         $criteria->addInCondition('t.id', $ids)->addCondition('t.state = :state');
         $criteria->params += array(':state' => POST_STATE_ENABLED);
         $count = Post::model()->count($criteria);
         $pages = new CPagination($count);
         $pages->setPageSize(param('postCountOfTitleListPage'));
         $pages->applyLimit($criteria);
         $posts = Post::model()->findAll($criteria);
     }
     $listType = param('post_list_type');
     $view = $listType == POST_LIST_TYPE_SUMMARY ? '/post/_summary_list' : '/post/_title_list';
     $blockTitle = t('tag_posts', 'main', array('{name}' => $tag));
     $data = array('blockTitle' => $blockTitle, 'posts' => $posts, 'pages' => $pages);
     $postListHtml = $this->renderPartial($view, $data, true);
     $this->render('posts', array('postListHtml' => $postListHtml));
 }
开发者ID:rainsongsky,项目名称:24beta,代码行数:31,代码来源:TagController.php

示例13: actionAbout1

 public function actionAbout1()
 {
     Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/post.css');
     Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/xinjia.css');
     $catalog_id = Yii::app()->request->getQuery('id');
     if ($catalog_id == '') {
         $catalog_id = 27;
     }
     //				$post = Post::model()->findByPk($id);
     //        $post->view_count += 1;
     //        $post->save();
     //$catalog_id = $post->catalog_id;
     //SUPERIORITY   CONTACT US  È˲ÅÕÐļJOIN US
     if ($catalog_id == 27) {
         $cat_name_en = "MAPLECITY PFOFILE";
     }
     if ($catalog_id == 28) {
         $cat_name_en = "SUPERIORITY";
     }
     if ($catalog_id == 30) {
         $cat_name_en = "CONTACT US";
     }
     if ($catalog_id == 31) {
         $cat_name_en = "JOIN US";
     }
     $prev_post = Post::model()->findAll(array('select' => 'id, title, content, view_count', 'condition' => ' catalog_id = :catalog_id', 'params' => array(':catalog_id' => $catalog_id), 'order' => 'id ASC', 'limit' => 1));
     //$prev_post->view_count += 1;
     //$prev_post->save();
     $next_post = Post::model()->findAll(array('select' => 'id, title', 'condition' => 'id < :id AND catalog_id = :catalog_id', 'params' => array(':id' => $id, ':catalog_id' => $catalog_id), 'order' => 'id DESC', 'limit' => 1));
     $this->render('about', array('cat_name_en' => $cat_name_en, 'post' => $post, 'prev_post' => $prev_post[0], 'next_post' => $next_post[0]));
 }
开发者ID:zywh,项目名称:maplecity,代码行数:31,代码来源:AboutController.php

示例14: run

 public function run()
 {
     $criteria = new CdbCriteria();
     $criteria->limit = $this->data('limit');
     $criteria->offset = $this->data('offset');
     $criteria->condition = "post_status='publish' AND (post_modified <= '" . date('Y-m-d H:i:s') . "' AND post_modified >= '" . $this->data('time') . "')";
     $criteria->order = 'post_hits DESC';
     if ($this->data('autoByTerm')) {
         if (isset($_GET['id'])) {
             $category = Category::model()->findByPK((int) $_GET['id']);
             $label = Label::model()->findByPK((int) $_GET['id']);
             $topic = Topic::model()->findByPK((int) $_GET['id']);
             $tag = Tag::model()->findByPK((int) $_GET['id']);
             if ($category != null) {
                 $criteria = $this->getCriteriaTerm('categories', $criteria);
             } elseif ($label != null) {
                 $criteria = $this->getCriteriaTerm('labels', $criteria);
             } elseif ($topic != null) {
                 $criteria = $this->getCriteriaTerm('topics', $criteria);
             } elseif ($tag != null) {
                 $criteria = $this->getCriteriaTerm('tags', $criteria);
             }
         }
     }
     $model = Post::model()->findAll($criteria);
     if ($model != null) {
         $this->layout($model);
     }
 }
开发者ID:beckblurry,项目名称:Yii1-Base-Core-V.Alpha.1,代码行数:29,代码来源:widget_terpopuler.php

示例15: actionEdit

 public function actionEdit()
 {
     $id = Yii::app()->request->getParam('id');
     $edited = false;
     $model = Post::model()->findByPk($id);
     if ($model->content->canWrite()) {
         if (isset($_POST['Post'])) {
             $_POST['Post'] = Yii::app()->input->stripClean($_POST['Post']);
             $model->attributes = $_POST['Post'];
             if ($model->validate()) {
                 $model->save();
                 // Reload record to get populated updated_at field
                 $model = Post::model()->findByPk($id);
                 // Return the new post
                 $output = $this->widget('application.modules_core.post.widgets.PostWidget', array('post' => $model, 'justEdited' => true), true);
                 Yii::app()->clientScript->render($output);
                 echo $output;
                 return;
             }
         }
         $this->renderPartial('edit', array('post' => $model, 'edited' => $edited), false, true);
     } else {
         throw new CHttpException(403, Yii::t('PostModule.controllers_PostController', 'Access denied!'));
     }
 }
开发者ID:skapl,项目名称:design,代码行数:25,代码来源:PostController.php


注:本文中的Post::model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。