本文整理汇总了PHP中Posts类的典型用法代码示例。如果您正苦于以下问题:PHP Posts类的具体用法?PHP Posts怎么用?PHP Posts使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Posts类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: viewAction
public function viewAction()
{
$categories = new Categories();
$feeds = new Feeds();
$this->view->category = $categories->getBySlug($this->getRequest()->getParam('id'));
$this->view->category->feeds = $feeds->getByCategory($this->view->category->id);
$posts = new Posts();
$limit = 10;
$page = $this->getRequest()->getParam('page') ? $this->getRequest()->getParam('page') : 1;
$this->view->posts = $posts->getByCategory($this->view->category->id, $page, $limit);
$total = $posts->getByCategory($this->view->category->id, 1, 0, true)->total;
$this->view->paginator = Zend_Paginator::factory($total);
$this->view->paginator->setCurrentPageNumber($page);
$this->view->paginator->setItemCountPerPage($limit);
}
开发者ID:akeemphilbert,项目名称:ifphp,代码行数:15,代码来源:CategoryController.php
示例17: action_block_content_draft_posts
/**
* Produce the content for the latest drafts block
* @param Block $block The block object
* @param Theme $theme The theme that the block will be output with
*/
public function action_block_content_draft_posts($block, $theme)
{
$block->recent_posts = Posts::get(array('status' => 'draft', 'limit' => 8, 'user_id' => User::identify()->id));
if (User::identify()->can('manage_entries')) {
$block->link = URL::get('admin', array('page' => 'posts', 'status' => Post::status('draft'), 'user_id' => User::identify()->id));
}
}
开发者ID:habari-extras,项目名称:draftdashmodule,代码行数:12,代码来源:draftdashmodule.plugin.php
示例18: blogSitemap
/**
* 文章
*/
private function blogSitemap()
{
$criteria = new CDbCriteria();
$criteria->condition = 'classify=' . $this->classify . ' AND status=' . Posts::STATUS_PASSED;
$criteria->select = 'id, cTime';
$criteria->order = 'id ASC';
$criteria->limit = $this->limitPerPage;
$criteria->offset = $this->pageStart;
$model = Posts::model()->findAll($criteria);
foreach ($model as $k => $v) {
$this->blogItems[] = array('url' => $this->webSiteTitle . '/post/' . $v->id . '.html', 'date' => date(DATE_W3C, $v->cTime));
//$tagArr = preg_split('#,|,#i', $v->tag);
if (!empty($tagArr)) {
foreach ($tagArr as $k => $v) {
if (!in_array($v, $this->tagItems)) {
$this->tagItems[] = $v;
}
}
}
}
//创建临时函数数组
$tmp = array();
$tmp = $this->tagItems;
$this->tagItems = array();
foreach ($tmp as $k => $v) {
$this->tagItems[] = array('url' => $this->webSiteTitle . '/posts/tag-' . $v->id . '.html', 'date' => date(DATE_W3C, time()));
}
unset($tmp);
}
开发者ID:ph7pal,项目名称:momo,代码行数:32,代码来源:Sitemap.php
示例19: getWishListForWeb
public function getWishListForWeb($user_id)
{
$criteria = new CDbCriteria();
$criteria->condition = "user_id = {$user_id}";
$wishlists = Wishlist::model()->findAll($criteria);
$wishlist_arr = array();
foreach ($wishlists as $wishlist) {
$wishlist_arr[] = $wishlist->post_id;
}
//var_dump($wishlist_arr); die;
$returnArr = array();
$criteria_post = new CDbCriteria();
$criteria_post->addInCondition('t.post_id', $wishlist_arr);
$count = Posts::model()->count($criteria_post);
$pages = new CPagination($count);
$pages->validateCurrentPage = FALSE;
$pages->pageSize = Yii::app()->params['RESULT_PER_PAGE'];
$pages->applyLimit($criteria_post);
$posts = Posts::model()->findAll($criteria_post);
$is_followed = User::model()->isFollowedByUser(Yii::app()->session['user_id'], $user_id, 'USER');
$profile = User::model()->findByPk($user_id);
foreach ($posts as $post) {
$itemArr = Posts::model()->getPostById($post->post_id, Yii::app()->session['user_id']);
$returnArr[] = $itemArr;
}
return array('data' => $returnArr, 'pages' => $pages, 'profile' => $profile, 'is_followed' => $is_followed);
// return FALSE;
}
开发者ID:huynt57,项目名称:fashion,代码行数:28,代码来源:Wishlist.php
示例20: begin
public function begin()
{
$termId = $this->getParams('term_id');
$ordering = $this->getParams('ordering');
$fetchChild = $this->getParams('fetch_child', false);
$q = Posts::read()->where('`status`=:status AND `is_draft` = 0')->setParameter(':status', 'PUBLISH', \PDO::PARAM_STR);
$term = Terms::retrieveById($termId);
if (!$term) {
return;
}
if ($fetchChild) {
$child = $term->getDescendants();
$ids = array($term->getId());
foreach ($child as $_c) {
$ids[] = $_c->getId();
}
$q->andWhere('`term_id` IN (' . implode(',', $ids) . ')');
} else {
$q->andWhere('`term_id`=:term_id')->setParameter(':term_id', $term->getId(), \PDO::PARAM_INT);
}
//limit
$limit = $this->getParams('limit');
if ($limit) {
$q->setMaxResults((int) $limit);
}
if ($ordering) {
foreach ($ordering as $_ordering) {
$q->addOrderBy($_ordering['field'], $_ordering['order']);
}
} else {
$q->addOrderBy('modified_time', 'DESC');
}
$this->list = $q->execute()->fetchAll(\PDO::FETCH_CLASS, 'Posts', array(null, false));
}
开发者ID:hosivan90,项目名称:toxotes,代码行数:34,代码来源:LatestNews.php
注:本文中的Posts类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论