コード例 #1
0
ファイル: frontController.php プロジェクト: devM4x/board_php
 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';
 }
コード例 #2
0
ファイル: FeedProvider.php プロジェクト: aprondak/ifphp
 /**
  * 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();
 }
コード例 #3
0
ファイル: Cache.php プロジェクト: akeemphilbert/ifphp
 /**
  *
  * @param Feed $feed 
  */
 public function addFeed(Feed $feed)
 {
     $posts = new Posts();
     $posts->clear();
     $feeds = new Feeds();
     $feeds->clear();
 }
コード例 #4
0
/**
 * Starts up the post class on init
 */
function post_init()
{
    $posts = new Posts();
    if (!$posts->capture()) {
        return false;
    }
}
コード例 #5
0
ファイル: SearchProvider.php プロジェクト: aprondak/ifphp
 /**
  * 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;
 }
コード例 #6
0
 public function show()
 {
     $appel = new Posts();
     $posts = $appel->findbyid($_GET['id']);
     $this->variable('post', $posts);
     $this->render('show', 'Posts');
 }
コード例 #7
0
 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()));
 }
コード例 #8
0
 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);
     }
 }
コード例 #9
0
 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);
 }
コード例 #10
0
ファイル: PostTest.php プロジェクト: Abenaman/ggc-talk
 public function testStore()
 {
     $post = new Posts();
     $post->id = 123;
     $post->title = 'GGC Test Post!';
     $post->temp_username = '******';
     $post->message = 'This is a fake data blah blah blah';
     $post->topic_id = 1651;
     $post->save();
     Posts::findOrFail($post->id);
 }
コード例 #11
0
ファイル: IndexController.php プロジェクト: aprondak/ifphp
 /**
  * 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));
 }
コード例 #12
0
ファイル: Pagination.php プロジェクト: VSG24/ccms
 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;
     }
 }
コード例 #13
0
ファイル: ListePosts.class.php プロジェクト: sewelseb/gabbler
 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);
 }
コード例 #14
0
 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();
 }
コード例 #15
0
 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);
     }
 }
コード例 #16
0
 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);
 }
コード例 #17
0
 /**
  * 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));
     }
 }
コード例 #18
0
ファイル: Sitemap.php プロジェクト: ph7pal/momo
 /**
  * 文章
  */
 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);
 }
コード例 #19
0
ファイル: Wishlist.php プロジェクト: huynt57/fashion
 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;
 }
コード例 #20
0
ファイル: LatestNews.php プロジェクト: hosivan90/toxotes
 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));
 }
コード例 #21
0
ファイル: theme.php プロジェクト: habari-extras/hmallow2
 /**
  * Add additional template variables to the template output.
  *
  *  You can assign additional output values in the template here, instead of
  *  having the PHP execute directly in the template.  The advantage is that
  *  you would easily be able to switch between template types (RawPHP/Smarty)
  *  without having to port code from one to the other.
  *
  *  You could use this area to provide "recent comments" data to the template,
  *  for instance.
  *
  *  Note that the variables added here should possibly *always* be added,
  *  especially 'user'.
  *
  *  Also, this function gets executed *after* regular data is assigned to the
  *  template.  So the values here, unless checked, will overwrite any existing
  *  values.
  */
 public function add_template_vars()
 {
     //Theme Options
     $this->assign('home_tab', 'Home');
     //Set to whatever you want your first tab text to be.
     $this->assign('show_author', false);
     //Display author in posts
     if (!$this->template_engine->assigned('pages')) {
         $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
     }
     if (!$this->template_engine->assigned('page')) {
         $page = Controller::get_var('page');
         $this->assign('page', isset($page) ? $page : 1);
     }
     parent::add_template_vars();
     //from mzingi
     //visiting page/2, /3 will offset to the next page of posts in the sidebar
     $page = Controller::get_var('page');
     $pagination = Options::get('pagination');
     if ($page == '') {
         $page = 1;
     }
     $this->assign('more_posts', Posts::get(array('status' => 'published', 'content_type' => 'entry', 'offset' => $pagination * $page, 'limit' => 5)));
     //from mzingi
     //for recent comments loop in sidebar.php
     $this->assign('recent_comments', Comments::get(array('limit' => 5, 'status' => Comment::STATUS_APPROVED, 'orderby' => 'date DESC')));
 }
コード例 #22
0
ファイル: theme.php プロジェクト: habari-extras/redarry
 /**
  * Add additional template variables to the template output.
  * 	 
  *  You can assign additional output values in the template here, instead of 
  *  having the PHP execute directly in the template.  The advantage is that 
  *  you would easily be able to switch between template types (RawPHP/Smarty)
  *  without having to port code from one to the other.
  *  
  *  You could use this area to provide "recent comments" data to the template,
  *  for instance.	  	 	 
  *  
  *  Note that the variables added here should possibly *always* be added, 
  *  especially 'user'.
  * 	 
  *  Also, this function gets executed *after* regular data is assigned to the
  *  template.  So the values here, unless checked, will overwrite any existing 
  *  values.	 	 	 
  */
 public function add_template_vars()
 {
     $this->add_template('formcontrol_text', dirname(__FILE__) . '/forms/formcontrol_text.php', true);
     $this->add_template('formcontrol_textarea', dirname(__FILE__) . '/forms/formcontrol_textarea.php', true);
     if (!$this->template_engine->assigned('pages')) {
         $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
     }
     if (!$this->template_engine->assigned('user')) {
         $this->assign('user', User::identify());
     }
     if (!$this->template_engine->assigned('page')) {
         $this->assign('page', isset($page) ? $page : 1);
     }
     if (!$this->template_engine->assigned('feed_alternate')) {
         $matched_rule = URL::get_matched_rule();
         switch ($matched_rule->name) {
             case 'display_entry':
             case 'display_page':
                 $feed_alternate = URL::get('entry', array('slug' => Controller::get_var('slug')));
                 break;
             case 'display_entries_by_tag':
                 $feed_alternate = URL::get('tag_collection', array('tag' => Controller::get_var('tag')));
                 break;
             case 'index_page':
             default:
                 $feed_alternate = URL::get('collection', array('index' => '1'));
         }
         $this->assign('feed_alternate', $feed_alternate);
     }
     parent::add_template_vars();
 }
コード例 #23
0
ファイル: theme.php プロジェクト: habari-extras/phoenixblue
 /**
  * Add additional template variables to the template output.
  *
  *  You can assign additional output values in the template here, instead of
  *  having the PHP execute directly in the template.  The advantage is that
  *  you would easily be able to switch between template types (RawPHP/Smarty)
  *  without having to port code from one to the other.
  *
  *  You could use this area to provide "recent comments" data to the template,
  *  for instance.
  *
  *  Note that the variables added here should possibly *always* be added,
  *  especially 'user'.
  *
  *  Also, this function gets executed *after* regular data is assigned to the
  *  template.  So the values here, unless checked, will overwrite any existing
  *  values.
  */
 public function add_template_vars()
 {
     if (!$this->template_engine->assigned('pages')) {
         $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
     }
     if (!$this->template_engine->assigned('user')) {
         $this->assign('user', User::identify());
     }
     if (!$this->template_engine->assigned('tags')) {
         $this->assign('tags', Tags::get());
     }
     if (!$this->template_engine->assigned('page')) {
         $this->assign('page', isset($page) ? $page : 1);
     }
     if (!$this->template_engine->assigned('feed_alternate')) {
         $matched_rule = URL::get_matched_rule();
         switch ($matched_rule->name) {
             case 'display_entry':
             case 'display_page':
                 $feed_alternate = URL::get('atom_entry', array('slug' => Controller::get_var('slug')));
                 break;
             case 'display_entries_by_tag':
                 $feed_alternate = URL::get('atom_feed_tag', array('tag' => Controller::get_var('tag')));
                 break;
             case 'display_home':
             default:
                 $feed_alternate = URL::get('atom_feed', array('index' => '1'));
         }
         $this->assign('feed_alternate', $feed_alternate);
     }
     // Specify pages you want in your navigation here
     $this->assign('nav_pages', Posts::get(array('content_type' => 'page', 'status' => 'published', 'nolimit' => 1)));
     parent::add_template_vars();
 }
コード例 #24
0
 public function actionInsertPostCeleb()
 {
     $this->pageTitile = 'Thêm bài viết người nổi tiếng';
     $request = Yii::app()->request;
     try {
         $post_content = StringHelper::filterString($request->getPost('post_content'));
         $celeb_id = StringHelper::filterString($request->getPost('celeb_id'));
         $location = StringHelper::filterString($request->getPost('location'));
         $cats = $request->getPost('cats');
         if (count($_FILES['images']['tmp_name']) > 1) {
             $url_arr = UploadHelper::getUrlUploadMultiImages($_FILES['images'], $celeb_id . 'celeb');
         } else {
             $url_arr = UploadHelper::getUrlUploadMultiImages($_FILES['images'], $celeb_id . 'celeb');
         }
         // $album = StringHelper::filterString($request->getPost('album'));
         $album = NULL;
         $res = Posts::model()->addPostCeleb($celeb_id, $post_content, $location, $url_arr, $album, $cats);
         if ($res != FALSE) {
             Yii::app()->user->setFlash('success', 'Thêm bài viết thành công');
         } else {
             Yii::app()->user->setFlash('error', 'Có lỗi xảy ra');
         }
         $this->redirect(Yii::app()->createUrl('celebrity/addPost'));
     } catch (Exception $ex) {
         var_dump($ex->getMessage());
     }
 }
コード例 #25
0
ファイル: posts.php プロジェクト: gkovats/thekovats
 /**
  * Fetch instance of this class
  */
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new Posts();
     }
     return self::$instance;
 }
コード例 #26
0
 public function actionShowPosts($id, $mid, $sid)
 {
     $posts = Posts::model()->findByPk($sid);
     $multimedia = json_decode($posts->multimedia);
     $count = count($multimedia);
     foreach ($multimedia as $ind => $file) {
         if ($file->nomber == $mid) {
             $num = $ind + 1;
             if ($ind == 0) {
                 $prev = $multimedia[$count - 1]->nomber . '/' . $sid;
             } else {
                 $prev = $multimedia[$ind - 1]->nomber . '/' . $sid;
             }
             if ($ind == $count - 1) {
                 $next = $multimedia[0]->nomber . '/' . $sid;
             } else {
                 $next = $multimedia[$ind + 1]->nomber . '/' . $sid;
             }
             $current_photo = $file;
         }
     }
     $myPage = $id == Yii::app()->user->id;
     $myProfile = UserProfile::model()->getUserProfile(Yii::app()->user->id);
     $ext = Files::model()->findByPk($current_photo->id)->extension;
     $aroundInfo = array('num' => $num, 'count' => $count, 'prev' => $prev, 'next' => $next);
     $comments = Comments::model()->getLast('posts_' . $sid, $mid, 10);
     $comments = array_reverse($comments);
     $file = array('id' => $current_photo->id, 'file' => $current_photo->id, 'image' => array('extension' => $ext), 'description' => '', 'upload_date' => $current_photo->upload_date);
     $this->renderPartial('show_photo', array('photo' => $file, 'nav_link' => 'showposts', 'user_id' => $id, 'aroundInfo' => $aroundInfo, 'myProfile' => $myProfile, 'myPage' => $myPage, 'comments' => $comments, 'comments_tbl' => 'posts_' . $sid, 'comments_item_id' => $mid));
 }
コード例 #27
0
 /**
  * Populate a block with the popular entries
  **/
 public function action_block_content_popular_posts($block, $theme)
 {
     if (!($limit = $block->quantity)) {
         $limit = 5;
     }
     $block->popular_posts = Posts::get(array('content_type' => 'entry', 'has:info' => 'views', 'orderby' => 'CAST(hipi1.value as UNSIGNED) DESC', 'limit' => $limit));
 }
コード例 #28
0
ファイル: articles.php プロジェクト: nathggns/anchor-cms
function article_html()
{
    if ($itm = IoC::resolve('article')) {
        return Posts::parse($itm->html);
    }
    return '';
}
コード例 #29
0
 /**
  * Handles get requests for the dashboard
  * @todo update check should probably be cron'd and cached, not re-checked every load
  */
 public function get_dashboard()
 {
     // Not sure how best to determine this yet, maybe set an option on install, maybe do this:
     $firstpostdate = DB::get_value('SELECT min(pubdate) FROM {posts} WHERE status = ?', array(Post::status('published')));
     $this->theme->active_time = HabariDateTime::date_create($firstpostdate);
     // get the active theme, so we can check it
     // @todo this should be worked into the main Update::check() code for registering beacons
     $active_theme = Themes::get_active();
     $active_theme = $active_theme->name . ':' . $active_theme->version;
     // check to see if we have updates to display
     $this->theme->updates = Options::get('updates_available', array());
     // collect all the stats we display on the dashboard
     $this->theme->stats = array('author_count' => Users::get(array('count' => 1)), 'page_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('page'), 'status' => Post::status('published'))), 'entry_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('entry'), 'status' => Post::status('published'))), 'comment_count' => Comments::count_total(Comment::STATUS_APPROVED, false), 'tag_count' => Tags::vocabulary()->count_total(), 'page_draft_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('page'), 'status' => Post::status('draft'), 'user_id' => User::identify()->id)), 'entry_draft_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('entry'), 'status' => Post::status('draft'), 'user_id' => User::identify()->id)), 'unapproved_comment_count' => User::identify()->can('manage_all_comments') ? Comments::count_total(Comment::STATUS_UNAPPROVED, false) : Comments::count_by_author(User::identify()->id, Comment::STATUS_UNAPPROVED), 'spam_comment_count' => User::identify()->can('manage_all_comments') ? Comments::count_total(Comment::STATUS_SPAM, false) : Comments::count_by_author(User::identify()->id, Comment::STATUS_SPAM), 'user_entry_scheduled_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('any'), 'status' => Post::status('scheduled'), 'user_id' => User::identify()->id)));
     $this->fetch_dashboard_modules();
     // check for first run
     $u = User::identify();
     if (!isset($u->info->experience_level)) {
         $this->theme->first_run = true;
         $u->info->experience_level = 'user';
         $u->info->commit();
     } else {
         $this->theme->first_run = false;
     }
     $this->display('dashboard');
 }
コード例 #30
0
ファイル: theme.php プロジェクト: anupom/my-blog
 /**
  * Add some variables to the template output
  */
 public function add_template_vars()
 {
     if (!$this->template_engine->assigned('pages')) {
         $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
     }
     $page = Controller::get_var('page');
     $page = isset($page) ? $page : 1;
     if (!$this->template_engine->assigned('page')) {
         $this->assign('page', $page);
     }
     $this->assign('show_previously', false);
     $this->assign('show_latest', false);
     $action = Controller::get_action();
     if ($action == 'display_home' || $action == 'display_entries') {
         $offset = (int) (($page + 1 - 1) * Options::get('pagination'));
         $this->assign('previously', Posts::get(array('status' => 'published', 'content_type' => 'entry', 'offset' => $offset, 'limit' => self::PREVIOUSLY_ITEMS)));
         $this->assign('show_previously', true);
     }
     if ($action != 'display_home') {
         $this->assign('latest', Posts::get(array('status' => 'published', 'content_type' => 'entry', 'offset' => 0, 'limit' => self::LATEST_ITEMS)));
         $this->assign('show_latest', true);
     }
     $this->assign('controller_action', $action);
     parent::add_template_vars();
 }