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


PHP Posts类代码示例

本文整理汇总了PHP中Posts的典型用法代码示例。如果您正苦于以下问题:PHP Posts类的具体用法?PHP Posts怎么用?PHP Posts使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: listPostsAction

 public function listPostsAction($page, $json = false)
 {
     $admin = new Posts();
     $this->authCheck();
     $result = $admin->listAllEventPosts(true);
     // Выводит список всех постов
     /*
     
     		if ($json) {
     			echo "<pre> asdad";
     
     			foreach ($result as $key => $value) {
     				foreach ($value as $k => $v) {
     				 	$result[$value][$value[$k]] = htmlspecialchars($v)
     				 	echo $result[$value][$value[$k]];
     				 } 
     			}
     
     			//$result = htmlspecialchars($result[']);
     
     			//print_r(json_encode($result[0]),JSON_HEX_APOS);
     
     			//return ;
     			json_encode($result, JSON_HEX_APOS);
     
     			return false;
     		}
     */
     $page = 'templates/front/listPosts.php';
     // Показывает список определенных постов вычесленных в зависимости от параметра $page
     require_once ROOT_PATH . DIRECTORY_SEPARATOR . 'templates/front/header.php';
     require_once ROOT_PATH . DIRECTORY_SEPARATOR . $page;
     require_once ROOT_PATH . DIRECTORY_SEPARATOR . 'templates/front/footer.php';
 }
开发者ID:devM4x,项目名称:board_php,代码行数:34,代码来源:frontController.php

示例2: updateFeed

 /**
  * Add feed to system
  * 
  * @param Feed $feed
  */
 private function updateFeed(Feed $feed)
 {
     require_once 'Ifphp/models/Posts.php';
     $feedSource = Zend_Feed_Reader::import($feed->url);
     $posts = new Posts();
     $tdate = $feedSource->current()->getDateModified();
     $tdate = new Zend_Date($tdate);
     while ($feedSource->valid() && $tdate->toValue() > $feed->lastPing && !$posts->getByLink($feedSource->current()->getPermaLink())) {
         $tdate = $feedSource->current()->getDateModified();
         $tdate = new Zend_Date($tdate);
         $defaultFilterChain = new Zend_Filter();
         $defaultFilterChain->addFilter(new Ifphp_Filter_XSSClean());
         $defaultFilterChain->addFilter(new Zend_Filter_StringTrim());
         $defaultFilterChain->addFilter(new Zend_Filter_StripTags());
         $post = $posts->createRow();
         $post->title = $defaultFilterChain->filter($feedSource->current()->getTitle());
         $post->description = $defaultFilterChain->filter($feedSource->current()->getDescription());
         $post->feedId = $defaultFilterChain->filter($feed->id);
         $post->link = $defaultFilterChain->filter($feedSource->current()->getPermaLink());
         $post->publishDate = $tdate->toValue();
         $post->save();
         Ifphp_Controller_Front::getInstance()->getPluginBroker()->addPost($post, $feed);
         $feedSource->next();
     }
     $feed->lastPing = time();
     $feed->save();
 }
开发者ID:aprondak,项目名称:ifphp,代码行数:32,代码来源:FeedProvider.php

示例3: addFeed

 /**
  *
  * @param Feed $feed 
  */
 public function addFeed(Feed $feed)
 {
     $posts = new Posts();
     $posts->clear();
     $feeds = new Feeds();
     $feeds->clear();
 }
开发者ID:akeemphilbert,项目名称:ifphp,代码行数:11,代码来源:Cache.php

示例4: post_init

/**
 * Starts up the post class on init
 */
function post_init()
{
    $posts = new Posts();
    if (!$posts->capture()) {
        return false;
    }
}
开发者ID:troubletribbles,项目名称:dr_bootstrap,代码行数:10,代码来源:posts.php

示例5: buildPostSearch

 /**
  * Build the post search index
  * 
  * @param boolean $isCount
  * @return boolean
  */
 protected function buildPostSearch($isCount = false)
 {
     $index = Zend_Search_Lucene::create(Zend_Registry::getInstance()->config->search->post);
     require_once 'Ifphp/models/Posts.php';
     require_once 'Ifphp/models/Feeds.php';
     require_once 'Ifphp/models/Categories.php';
     $posts = new Posts();
     $allPosts = $posts->getRecent(1, 0);
     if ($isCount) {
         echo $allPosts->count() . ' posts would have been added to the post index';
         exit;
     }
     foreach ($allPosts as $post) {
         $feed = $post->findParentFeeds();
         $doc = new Zend_Search_Lucene_Document();
         $doc->addField(Zend_Search_Lucene_Field::Text('pid', $post->id));
         $doc->addField(Zend_Search_Lucene_Field::Text('title', $post->title));
         $doc->addField(Zend_Search_Lucene_Field::Text('siteUrl', $post->siteUrl));
         $doc->addField(Zend_Search_Lucene_Field::Text('link', $post->link));
         $doc->addField(Zend_Search_Lucene_Field::Text('feedTitle', $feed->title));
         $doc->addField(Zend_Search_Lucene_Field::Text('feedSlug', $feed->slug));
         $doc->addField(Zend_Search_Lucene_Field::Text('feedDescription', $feed->description));
         $doc->addField(Zend_Search_Lucene_Field::keyword('category', $feed->findParentCategories()->title));
         $doc->addField(Zend_Search_Lucene_Field::Text('description', $post->description));
         $doc->addField(Zend_Search_Lucene_Field::unIndexed('publishDate', $post->publishDate));
         $doc->addField(Zend_Search_Lucene_Field::Keyword('type', 'post'));
         $index->addDocument($doc);
     }
     chown(Zend_Registry::getInstance()->search['post'], 'www-data');
     return true;
 }
开发者ID:aprondak,项目名称:ifphp,代码行数:37,代码来源:SearchProvider.php

示例6: show

 public function show()
 {
     $appel = new Posts();
     $posts = $appel->findbyid($_GET['id']);
     $this->variable('post', $posts);
     $this->render('show', 'Posts');
 }
开发者ID:ThibaultRoger,项目名称:myFramBlog,代码行数:7,代码来源:CategoriesController.php

示例7: actionIndex

 public function actionIndex($id)
 {
     Yii::app()->clientScript->registerScript('global_user_id', 'var glUserId = ' . Yii::app()->user->id . ';', CClientScript::POS_HEAD);
     if (Yii::app()->user->id == $id) {
         $user = $this->myProfile;
     } else {
         $user = UserProfile::model()->getUserProfile($id);
     }
     // Получаем инфу о текущем пользователе
     if (empty($user)) {
         if (Yii::app()->user->id !== $id) {
             throw new CException('Not Found', 404);
         } else {
             $this->redirect($this->createUrl('/profile/profile/edit', array('id' => $id)));
         }
     }
     $wall = new Posts();
     // Получаем последние 10 постов
     $wall->_owner_id = $id;
     // С чьей стены получаем
     $wall->_limit = Yii::app()->params->maxPostPerRequest;
     // Количество получаемых постов
     Yii::app()->clientScript->registerPackage('profile-index');
     $this->render('index', array('myProfile' => $this->myProfile, 'profile' => $user, 'wall' => $wall->getLast()));
 }
开发者ID:BGCX067,项目名称:facecom-svn-to-git,代码行数:25,代码来源:ProfileController.php

示例8: __construct

 public function __construct()
 {
     try {
         // split the url
         $url = isset($_GET['url']) ? explode('/', rtrim($_GET['url'], '/')) : null;
         if (empty($url[0])) {
             $url[0] = 'posts';
         }
         // prepare the file containing the controller
         $file = 'lib/controllers/' . $url[0] . '.controller.php';
         if (file_exists($file)) {
             // controller found, run with it.
             // include the controller file
             require $file;
             // load the controller
             $controller = new $url[0]();
             // load the controllers model
             $controller->load_model($url[0]);
             // check for a method
             if (isset($url[1])) {
                 // does the method exist?
                 if (!method_exists($controller, $url[1])) {
                     throw new Exception("Invalid Method.", 404);
                 }
                 // splice params into array
                 $params = array_slice($url, 2);
                 // call the controller class method with the params. site.com/controller/method/p1/p2/p3/p4
                 call_user_func_array(array($controller, $url[1]), $params);
             } else {
                 // call default method
                 $controller->index();
             }
         } else {
             // no controller can be found, so load posts
             require 'lib/controllers/posts.controller.php';
             $controller = new Posts();
             $controller->load_model('posts');
             if (is_numeric($url[0])) {
                 // call archive
                 call_user_func_array(array($controller, 'archive'), $url);
             } else {
                 // check for method.
                 if (method_exists($controller, $url[0])) {
                     // splice params into array
                     $params = array_slice($url, 1);
                     // call the controller class method with the params.
                     call_user_func_array(array($controller, $url[0]), $params);
                 } else {
                     throw new Exception("Invalid URI string.", 404);
                 }
             }
         }
     } catch (Exception $e) {
         $this->error($e);
     }
 }
开发者ID:rlemon,项目名称:blog.rlemon.com,代码行数:56,代码来源:bootstrap.class.php

示例9: recentAction

 public function recentAction()
 {
     $page = $this->getRequest()->getParam('page') ? $this->getRequest()->getParam('page') : 1;
     $limit = 5;
     $posts = new Posts();
     $this->view->posts = $posts->getRecent($page, $limit);
     $total = $posts->getRecent($page, 0, true)->total;
     $this->view->paginator = Zend_Paginator::factory($total);
     $this->view->paginator->setCurrentPageNumber($page);
     $this->view->paginator->setItemCountPerPage($limit);
 }
开发者ID:akeemphilbert,项目名称:ifphp,代码行数:11,代码来源:PostController.php

示例10: testStore

 public function testStore()
 {
     $post = new Posts();
     $post->id = 123;
     $post->title = 'GGC Test Post!';
     $post->temp_username = 'Joe';
     $post->message = 'This is a fake data blah blah blah';
     $post->topic_id = 1651;
     $post->save();
     Posts::findOrFail($post->id);
 }
开发者ID:Abenaman,项目名称:ggc-talk,代码行数:11,代码来源:PostTest.php

示例11: indexAction

 /**
  * Site landing page
  */
 public function indexAction()
 {
     $limit = 5;
     $page = $this->getRequest()->getParam('page') ? $this->getRequest()->getParam('page') : 1;
     $posts = new Posts();
     $this->view->posts = $posts->getRecent($page, $limit);
     $total = $posts->getRecent($page, 0, true)->total;
     $this->view->paginator = Zend_Paginator::factory($total);
     $this->view->paginator->setCurrentPageNumber($page);
     $this->view->paginator->setItemCountPerPage($limit);
     $this->view->keywords = implode('', array('ifphp', 'news aggragator', 'support,' . $this->view->term));
 }
开发者ID:aprondak,项目名称:ifphp,代码行数:15,代码来源:IndexController.php

示例12: __construct

 function __construct($max_pp = null, $count = null)
 {
     $posts = new Posts();
     $this->current_page = $posts->getCurrentPageNumber();
     $this->per_page = $posts->getMaxPostPerPage();
     $this->total_count = $posts->getPostsCount();
     if (isset($count)) {
         $this->total_count = $count;
     }
     if (isset($max_pp)) {
         $this->per_page = $max_pp;
     }
 }
开发者ID:VSG24,项目名称:ccms,代码行数:13,代码来源:Pagination.php

示例13: getGabById

 public function getGabById($idGab, $bdd)
 {
     $liste = array();
     $i = 0;
     $listePosts = $bdd->query('SELECT * FROM posts WHERE (id=' . $idGab . ') ORDER BY id DESC');
     while ($item = $listePosts->fetch()) {
         $post = new Posts();
         $post->hydrate($item['id'], $item['id_user'], $item['text'], $item['id_post_origin'], $item['likes'], $bdd);
         $liste[$i] = $post;
         $i++;
     }
     $this->setListePosts($liste);
 }
开发者ID:sewelseb,项目名称:gabbler,代码行数:13,代码来源:ListePosts.class.php

示例14: createAction

 public function createAction()
 {
     $post = new Posts();
     $success = $post->save($this->request->getPost(), array('id_posta', 'poruka', 'created_at'));
     if ($success) {
         echo "Your message has been posted !";
     } else {
         echo "Sorry, the following problems were generated: ";
         foreach ($post->getMessages() as $message) {
             echo $message->getMessage(), "<br/>";
         }
     }
     $this->view->disable();
 }
开发者ID:bblazina,项目名称:twitterclone,代码行数:14,代码来源:PostsController.php

示例15: actionShare

 public function actionShare()
 {
     $user_id = Yii::app()->user->id;
     $res = false;
     if (Yii::app()->request->isAjaxRequest && !empty($user_id)) {
         $item_id = Yii::app()->getRequest()->getPost('item_id');
         $sharedEntry = Posts::model()->findByPk($item_id);
         $newEntry = new Posts();
         $newEntryHash = md5($sharedEntry->author_type . $sharedEntry->author_id . $user_id . $sharedEntry->creation_date);
         if ($sharedEntry->owner_id == $user_id || $sharedEntry->author_id == $user_id || $sharedEntry->status != 1) {
             // если запись уже есть на стене или если запись заблочена то не добавляем
             echo json_encode(array('status' => 'error', 'data' => 'Ошибка при копировании записи'));
             exit;
         }
         $newEntry->parent_id = $sharedEntry->id;
         // поле parent_id устанавливаем отличное от нуля (id расшариваемого поста)
         $newEntry->post_type = 'userwall';
         // Все основные поля копируем как есть
         $newEntry->author_type = $sharedEntry->author_type;
         $newEntry->owner_type = 'user';
         $newEntry->content = $sharedEntry->content;
         $newEntry->multimedia = $sharedEntry->multimedia;
         $newEntry->status = $sharedEntry->status;
         $newEntry->creation_date = time();
         $newEntry->author_id = $sharedEntry->author_id;
         $newEntry->owner_id = $user_id;
         $newEntry->hash = $newEntryHash;
         // сохраняем новую и старую записи
         $transaction = $sharedEntry->dbConnection->beginTransaction();
         try {
             $newEntry->save();
             $sharedEntry->shares = intval($sharedEntry->shares) + 1;
             // увеличиваем счетчик share у копируемой записи
             $sharedEntry->save();
             $transaction->commit();
             $res = true;
         } catch (Exception $e) {
             $transaction->rollback();
             $res = false;
         }
         if ($res == true) {
             echo json_encode(array('status' => 'ok', 'data' => 'shared'));
         } else {
             echo json_encode(array('status' => 'error', 'data' => 'Ошибка подключения к БД'));
         }
     } else {
         throw new CException('Not Found', 404);
     }
 }
开发者ID:BGCX067,项目名称:facecom-svn-to-git,代码行数:49,代码来源:ShareController.php


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