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


PHP blogPostModel::search方法代码示例

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


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

示例1: execute

 public function execute()
 {
     $routes = $this->getRoutes();
     $app_id = wa()->getApp();
     $blog_model = new blogBlogModel();
     $post_model = new blogPostModel();
     $blogs = $blog_model->getAvailable(false, array('id', 'name', 'url'));
     foreach ($routes as $route) {
         $lastmod = null;
         $this->routing->setRoute($route);
         $default_blog_id = isset($route['blog_url_type']) ? (int) $route['blog_url_type'] : 0;
         $default_blog_id = max(0, $default_blog_id);
         $extend_options = array('datetime' => true);
         $extend_data = array('blog' => $blogs);
         foreach ($blogs as $blog_id => $blog) {
             if (!$default_blog_id || $blog_id == $default_blog_id) {
                 $search_options = array('blog_id' => $blog_id);
                 $posts = $post_model->search($search_options, $extend_options, $extend_data)->fetchSearchAll('id,title,url,datetime,blog_id');
                 foreach ($posts as $post) {
                     $post['blog_url'] = $blog['url'];
                     $post_lastmod = strtotime($post['datetime']);
                     $lastmod = max($lastmod, $post_lastmod);
                     if (!empty($post['comment_datetime'])) {
                         $post_lastmod = max($post_lastmod, strtotime($post['comment_datetime']));
                     }
                     $this->addUrl($post['link'], $post_lastmod);
                 }
             }
         }
         $this->addUrl(wa()->getRouteUrl($app_id . "/frontend", array(), true), $lastmod);
     }
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:32,代码来源:blogSitemapConfig.class.php

示例2: defaultAction

 public function defaultAction()
 {
     // When viewed from a public dashboard, pretend we're logged in
     $old_user = $user = $this->getUser();
     if (wa()->getUser()->getId() != $user->getId()) {
         $old_user = wa()->getUser();
         wa()->setUser($user);
     }
     $filter = $this->getSettings('filter', 'all');
     $blogs = blogHelper::getAvailable();
     $blog_ids = array_keys($blogs);
     $comments = $this->getComments(array('blog_id' => $blog_ids, 'filter' => $filter, 'offset' => 0, 'limit' => 6));
     wa()->setUser($old_user);
     // get related posts info
     $post_ids = array();
     foreach ($comments as $comment) {
         $post_ids[$comment['post_id']] = true;
     }
     $post_model = new blogPostModel();
     $extend_data = array('blog' => $blogs);
     $search_options = array('id' => array_keys($post_ids));
     $extend_options = array('user' => false, 'link' => true, 'rights' => true, 'plugin' => false, 'comments' => false);
     $posts = $post_model->search($search_options, $extend_options, $extend_data)->fetchSearchAll(false);
     $comments = blogCommentModel::extendRights($comments, $posts);
     $this->display(array('blogs' => $blogs, 'posts' => $posts, 'comments' => $comments, 'filter' => $filter));
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:26,代码来源:blogComments.widget.php

示例3: defaultAction

 public function defaultAction()
 {
     // When viewed from a public dashboard, pretend we're logged in
     $old_user = $user = $this->getUser();
     if (wa()->getUser()->getId() != $user->getId()) {
         $old_user = wa()->getUser();
         wa()->setUser($user);
     }
     $blog_model = new blogBlogModel();
     $blogs = $blog_model->getAvailable(wa()->getUser());
     $blog_id = $this->getSettings('blog_id');
     if ($blog_id && !empty($blogs[$blog_id])) {
         $blog_ids = array($blog_id);
     } else {
         $blog_ids = array_keys($blogs);
     }
     $post_model = new blogPostModel();
     $posts = $post_model->search(array('blog_id' => $blog_ids), array('status' => 'view', 'author_link' => false, 'rights' => true, 'text' => 'cut'), array('blog' => $blogs))->fetchSearchPage(1, 1);
     wa()->setUser($old_user);
     $post = reset($posts);
     $blog = false;
     if ($post && !empty($blogs[$post['blog_id']])) {
         $blog = $blogs[$post['blog_id']];
     }
     $this->display(array('blog' => $blog, 'post' => $post));
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:26,代码来源:blogPosts.widget.php

示例4: execute

 public function execute()
 {
     $post_id = max(0, waRequest::get('id', 0, waRequest::TYPE_INT));
     if (!$post_id) {
         throw new waException(_w('Post not found'), 404);
     }
     $post_model = new blogPostModel();
     $search_options = array('id' => $post_id);
     $extend_options = array('comments' => array(20), 'user' => array('photo_url_50'), 'status' => 'view');
     $post = $post_model->search($search_options, $extend_options)->fetchSearchItem();
     if (!$post) {
         throw new waException(_w('Post not found'), 404);
     }
     $post['rights'] = $this->getRights("blog.{$post['blog_id']}");
     $posts = array(&$post);
     blogHelper::extendRights($posts, array(), $this->getUser()->getId());
     blogPhotosBridge::loadAlbums($posts);
     if (isset($post['comments']) && $post['comments']) {
         $post['comments'] = blogCommentModel::extendRights($post['comments'], array($post_id => $post));
     }
     $blog_model = new blogBlogModel();
     $blog = $blog_model->getById($post['blog_id']);
     if ($blog['status'] != blogBlogModel::STATUS_PUBLIC || $post['status'] != blogPostModel::STATUS_PUBLISHED) {
         blogHelper::checkRights($post['blog_id'], true, blogRightConfig::RIGHT_READ);
     }
     $items = $blog_model->prepareView(array($blog));
     $blog = array_shift($items);
     $this->setLayout(new blogDefaultLayout());
     $this->getResponse()->setTitle($post['title']);
     /**
      * Backend post view page
      * UI hook allow extends post view page
      * @event backend_post
      * @param array[string]mixed $post Current page post item data
      * @param array[string]int $post['id'] Post ID
      * @param array[string]int $post['blog_id'] Post blog ID
      * @return array[string][string]string $backend_post['%plugin_id%']['footer'] Plugin %plugin_id% footer html
      */
     $this->view->assign('backend_post', wa()->event('backend_post', $post, array('footer')));
     $user = $this->getUser();
     $this->view->assign('current_contact', array('id' => $user->getId(), 'name' => $user->getName(), 'photo20' => $user->getPhoto(20)));
     $this->view->assign('blog_id', $blog['id']);
     $this->view->assign('blog', $blog);
     $this->view->assign('contact_rights', $this->getUser()->getRights('contacts', 'backend'));
     if ($this->getConfig()->getOption('can_use_smarty')) {
         try {
             $post['text'] = $this->view->fetch("string:{$post['text']}", $this->cache_id);
         } catch (SmartyException $ex) {
             $post['text'] = blogPost::handleTemplateException($ex, $post);
         }
     }
     $this->view->assign('post', $post);
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:53,代码来源:blogPost.action.php

示例5: execute

 public function execute()
 {
     $contact_photo_size = 20;
     $comments_per_page = max(1, intval($this->getConfig()->getOption('comments_per_page')));
     $page = max(1, waRequest::get('page', 1, waRequest::TYPE_INT));
     $blog_models = new blogBlogModel();
     $user = $this->getUser();
     $blogs = blogHelper::getAvailable();
     $comment_model = new blogCommentModel();
     $offset = $comments_per_page * ($page - 1);
     $prepare_options = array('datetime' => blogActivity::getUserActivity());
     $fields = array("photo_url_{$contact_photo_size}");
     $blog_ids = array_keys($blogs);
     $comments = $comment_model->getList($offset, $comments_per_page, $blog_ids, $fields, $prepare_options);
     $comments_all_count = $comment_model->getCount($blog_ids, null, null, null, null, null);
     $post_ids = array();
     foreach ($comments as $comment) {
         $post_ids[$comment['post_id']] = true;
     }
     //get related posts info
     $post_model = new blogPostModel();
     $search_options = array('id' => array_keys($post_ids));
     $extend_options = array('user' => false, 'link' => true, 'rights' => true, 'plugin' => false, 'comments' => false);
     $extend_data = array('blog' => $blogs);
     $posts = $post_model->search($search_options, $extend_options, $extend_data)->fetchSearchAll(false);
     $comments = blogCommentModel::extendRights($comments, $posts);
     $comments_count = ($page - 1) * $comments_per_page + count($comments);
     if ($page == 1) {
         $this->setLayout(new blogDefaultLayout());
         $this->getResponse()->setTitle(_w('Comments'));
     }
     /**
      * Backend comments view page
      * UI hook allow extends backend comments view page
      * @event backend_comments
      * @param array[int][string]mixed $comments
      * @param array[int][string]int $comments[%id%][id] comment id
      * @return array[string][string]string $return[%plugin_id%]['toolbar'] Comment's toolbar html
      */
     $this->view->assign('backend_comments', wa()->event('backend_comments', $comments));
     $this->view->assign('comments', $comments);
     $this->view->assign('comments_count', $comments_count);
     $this->view->assign('comments_total_count', $comments_all_count);
     $this->view->assign('comments_per_page', $comments_per_page);
     $this->view->assign('pages', ceil($comments_all_count / $comments_per_page));
     $this->view->assign('page', $page);
     $this->view->assign('contact_rights', $this->getUser()->getRights('contacts', 'backend'));
     $this->view->assign('current_contact_id', $user->getId());
     $this->view->assign('current_contact', array('id' => $user->getId(), 'name' => $user->getName(), 'photo20' => $user->getPhoto($contact_photo_size)));
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:50,代码来源:blogComments.action.php

示例6: execute

 public function execute()
 {
     $rss_author_tag = null;
     if ($blog_id = $this->getRequest()->param('blog_id')) {
         $rss_posts_number = max(1, $this->appSettings('rss_posts_number', 10));
         $rss_author_tag = $this->appSettings('rss_author_tag');
         $options = array();
         $data = array();
         switch ($rss_author_tag) {
             case 'blog':
                 $blog_model = new blogBlogModel();
                 $data['blog'] = $blog_model->getByField(array('id' => $blog_id), 'id');
                 break;
             default:
                 $data['blog'] = blogHelper::getAvailable();
                 break;
         }
         $options['params'] = true;
         $options['user'] = 'id,photo_url_20,email';
         $post_model = new blogPostModel();
         $posts = $post_model->search(array('blog_id' => $blog_id), $options, $data)->fetchSearchPage(1, $rss_posts_number);
         blogPhotosBridge::loadAlbums($posts);
     } else {
         $posts = array();
     }
     $link = wa()->getRouteUrl('blog/frontend', array(), true);
     $rss_link = wa()->getRouteUrl('blog/frontend/rss', array(), true);
     $title = waRequest::param('rss_title') ? waRequest::param('rss_title') : wa()->accountName();
     $this->view->assign('info', array('title' => $title, 'link' => $link, 'description' => '', 'language' => 'ru', 'pubDate' => date(DATE_RSS), 'lastBuildDate' => date(DATE_RSS), 'self' => $rss_link));
     $this->view->assign('blog_name', $this->getResponse()->getTitle());
     $this->view->assign('rss_author_tag', $rss_author_tag);
     if ($this->getConfig()->getOption('can_use_smarty')) {
         foreach ($posts as &$post) {
             try {
                 $post['text'] = $this->view->fetch("string:{$post['text']}", $this->cache_id);
             } catch (SmartyException $ex) {
                 $post['text'] = blogPost::handleTemplateException($ex, $post);
             }
         }
         unset($post);
     }
     foreach ($posts as &$post) {
         if (is_array($post['user']['email'])) {
             $post['user']['email'] = reset($post['user']['email']);
         }
     }
     unset($post);
     $this->view->assign('posts', $posts);
     $this->getResponse()->addHeader('Content-Type', 'application/rss+xml; charset=utf-8');
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:50,代码来源:blogFrontendRss.action.php

示例7: execute

 public function execute()
 {
     $id = $this->get('id', true);
     $post_model = new blogPostModel();
     $post = $post_model->search(array('id' => $id))->fetchSearchItem();
     if ($post) {
         $blog_model = new blogBlogModel();
         $blog = $blog_model->getById($post['blog_id']);
         if ($blog['status'] != blogBlogModel::STATUS_PUBLIC || $post['status'] != blogPostModel::STATUS_PUBLISHED) {
             blogHelper::checkRights($post['blog_id'], true, blogRightConfig::RIGHT_READ);
         }
         $this->response = $post;
     } else {
         throw new waAPIException('invalid_param', 'Post not found', 404);
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:16,代码来源:blog.post.getInfo.method.php

示例8: execute

 public function execute()
 {
     $hash = $this->get('hash');
     $offset = waRequest::get('offset', 0, 'int');
     if ($offset < 0) {
         throw new waAPIException('invalid_param', 'Param offset must be greater than or equal to zero');
     }
     $limit = waRequest::get('limit', 100, 'int');
     if ($limit < 0) {
         throw new waAPIException('invalid_param', 'Param limit must be greater than or equal to zero');
     }
     if ($limit > 1000) {
         throw new waAPIException('invalid_param', 'Param limit must be less or equal 1000');
     }
     $options = array();
     $hash = explode('/', trim($hash, '/'));
     $hash[1] = isset($hash[1]) ? $hash[1] : '';
     switch ($hash[0]) {
         case 'blog':
             $options['blog_id'] = (int) $hash[1];
             break;
         case 'contact':
         case 'author':
             $options['contact_id'] = (int) $hash[1];
             break;
         case 'search':
             $options['text'] = $hash[1];
             break;
         case 'tag':
             // use plugin
             $options['plugin'] = array('tag' => $hash[1]);
             break;
     }
     if ($options) {
         $post_model = new blogPostModel();
         $posts = $post_model->search($options)->fetchSearch($offset, $limit);
     } else {
         $posts = array();
     }
     $this->response['count'] = count($posts);
     $this->response['offset'] = $offset;
     $this->response['limit'] = $limit;
     $this->response['posts'] = array_values($posts);
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:44,代码来源:blog.post.search.method.php

示例9: execute

 public function execute()
 {
     $routes = $this->getRoutes();
     $app_id = wa()->getApp();
     $blog_model = new blogBlogModel();
     $post_model = new blogPostModel();
     $page_model = new blogPageModel();
     $blogs = $blog_model->getAvailable(false, array('id', 'name', 'url'));
     $real_domain = $this->routing->getDomain(null, true, false);
     foreach ($routes as $route) {
         $lastmod = null;
         $this->routing->setRoute($route);
         $default_blog_id = isset($route['blog_url_type']) ? (int) $route['blog_url_type'] : 0;
         $default_blog_id = max(0, $default_blog_id);
         $extend_options = array('datetime' => true);
         $extend_data = array('blog' => $blogs);
         foreach ($blogs as $blog_id => $blog) {
             if (!$default_blog_id || $blog_id == $default_blog_id) {
                 $search_options = array('blog_id' => $blog_id);
                 $posts = $post_model->search($search_options, $extend_options, $extend_data)->fetchSearchAll('id,title,url,datetime,blog_id');
                 foreach ($posts as $post) {
                     $post['blog_url'] = $blog['url'];
                     $post_lastmod = strtotime($post['datetime']);
                     $lastmod = max($lastmod, $post_lastmod);
                     if (!empty($post['comment_datetime'])) {
                         $post_lastmod = max($post_lastmod, strtotime($post['comment_datetime']));
                     }
                     $this->addUrl($post['link'], $post_lastmod);
                 }
             }
         }
         // pages
         $main_url = wa()->getRouteUrl($app_id . "/frontend", array(), true, $real_domain);
         $domain = $this->routing->getDomain(null, true);
         $sql = "SELECT full_url, url, create_datetime, update_datetime FROM " . $page_model->getTableName() . '
                 WHERE status = 1 AND domain = s:domain AND route = s:route';
         $pages = $page_model->query($sql, array('domain' => $domain, 'route' => $route['url']))->fetchAll();
         foreach ($pages as $p) {
             $this->addUrl($main_url . $p['full_url'], $p['update_datetime'] ? $p['update_datetime'] : $p['create_datetime'], self::CHANGE_MONTHLY, 0.6);
         }
         $this->addUrl(wa()->getRouteUrl($app_id . "/frontend", array(), true, $real_domain), $lastmod, self::CHANGE_DAILY, 1.0);
     }
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:43,代码来源:blogSitemapConfig.class.php

示例10: defaultAction

 public function defaultAction()
 {
     $blog_model = new blogBlogModel();
     $blogs = $blog_model->getAvailable(wa()->getUser());
     $blog_id = $this->getSettings('blog_id');
     if ($blog_id && !empty($blogs[$blog_id])) {
         $blog_ids = array($blog_id);
     } else {
         $blog_ids = array_keys($blogs);
     }
     $search_options = array('blog_id' => $blog_ids);
     $extend_options = array('status' => 'view', 'author_link' => false, 'rights' => true, 'text' => 'cut');
     $post_model = new blogPostModel();
     $posts = $post_model->search($search_options, $extend_options, array('blog' => $blogs))->fetchSearchPage(1, 1);
     $post = reset($posts);
     $blog = false;
     if ($post && !empty($blogs[$post['blog_id']])) {
         $blog = $blogs[$post['blog_id']];
     }
     $this->display(array('blog' => $blog, 'post' => $post));
 }
开发者ID:niva79,项目名称:webasyst-framework,代码行数:21,代码来源:blogPosts.widget.php

示例11: backendExecute

 /**
  * protected backend preview
  * @throws waException
  * @return void
  */
 public function backendExecute()
 {
     $post_id = waRequest::param('post_id', false, waRequest::TYPE_INT);
     if ($post_id) {
         $post_model = new blogPostModel();
         $show_comments = $this->appSettings('show_comments', true);
         $photo_sizes = array(50, 20);
         $search_options = array('id' => $post_id, 'status' => false);
         if (!$this->getUser()->isAdmin($this->getApp())) {
             $search_options['contact_id'] = $this->getUser()->getId();
         }
         $post = $post_model->search($search_options, array('comments' => false))->fetchSearchItem();
     }
     if (!isset($post)) {
         throw new waException(_w('Post not found'), 404);
     }
     $this->view->assign('post', $post);
 }
开发者ID:nowaym,项目名称:webasyst-framework,代码行数:23,代码来源:blogFrontendPost.action.php

示例12: execute

 public function execute()
 {
     if ($this->getRequest()->param('blog_id') === false) {
         throw new waException(_w('Blog not found'), 404);
     }
     $this->view->getHelper()->globals($this->getRequest()->param());
     $posts_per_page = max(1, intval($this->getConfig()->getOption('posts_per_page')));
     $post_model = new blogPostModel();
     $options = array();
     if (!$this->appSettings('show_comments', true)) {
         $options['comments'] = false;
     }
     $options['params'] = true;
     $options['text'] = 'cut';
     $options['escape'] = true;
     $is_search = false;
     if (isset($this->search_params["search"])) {
         $plugin = $this->search_params["search"];
         if (!isset($this->search_params["plugin"])) {
             $this->search_params["plugin"] = array();
         }
         if (isset($this->search_params[$plugin])) {
             $this->search_params["plugin"][$plugin] = $this->search_params[$plugin];
             $is_search = true;
         }
     }
     $query = $this->getRequest()->get('query', '', waRequest::TYPE_STRING_TRIM);
     if ($query) {
         $this->search_params['text'] = urldecode($query);
         $options['highlighted'] = true;
     }
     $blogs = blogHelper::getAvailable();
     $posts = $post_model->search($this->search_params, $options, array('blog' => $blogs))->fetchSearchPage($this->page, $posts_per_page);
     $stream_title = false;
     if (isset($this->search_params['contact_id'])) {
         if (count($posts)) {
             reset($posts);
             $post = current($posts);
             $name = $post['user']['name'];
             $is_search = true;
         } else {
             if ($contact = blogHelper::getContactInfo($this->search_params['contact_id'])) {
                 $name = htmlentities($contact['name'], ENT_QUOTES, 'utf-8');
                 $is_search = true;
             } else {
                 throw new waException(_w('Blog not found'), 404);
             }
         }
         $stream_title = sprintf(_w('Posts by %s'), $name);
         $this->getResponse()->setTitle($stream_title);
     } elseif ($is_search) {
         $stream_title = $this->getResponse()->getTitle();
     } elseif (isset($this->search_params['year'])) {
         $stream_title = '';
         if (isset($this->search_params['day'])) {
             $stream_title .= intval($this->search_params['day']) . ' ';
         }
         if (isset($this->search_params['month'])) {
             $stream_title .= _ws(date("F", gmmktime(0, 0, 0, intval($this->search_params['month']), 1))) . ' ';
         }
         $stream_title .= $this->search_params['year'] . ' — ' . $this->getResponse()->getTitle();
         $this->getResponse()->setTitle($stream_title);
     } else {
         if (!empty($this->search_params['text'])) {
             $stream_title = urldecode($this->search_params['text']);
             $this->getResponse()->setTitle($stream_title);
             $is_search = true;
         }
     }
     $this->view->assign('stream_title', $stream_title);
     $pages = $post_model->pageCount();
     $url = wa()->getRouteUrl('blog/frontend', $this->search_params, true);
     if ($pages && $pages < $this->page) {
         $page = min($pages, $this->page);
         $redirect = $url . ($page > 1 ? "?page={$page}" : '');
         $this->getResponse()->redirect($redirect, 302);
     }
     if ($layout = $this->getLayout()) {
         $links = array();
         if ($pages > $this->page) {
             $page = $this->page + 1;
             $links['next'] = "{$url}?page={$page}";
         }
         if ($this->page > 1) {
             $page = $this->page - 1;
             $links['prev'] = $url . ($page > 1 ? "?page={$page}" : '');
         }
         $layout->assign('links', $links);
         if (!$is_search) {
             /*
              * @deprecated fix assigning sidebar_timeline for next version of blog
              * */
             $layout->assign('sidebar_timeline', $post_model->getTimeline($this->search_params['blog_id'], $blogs, $this->search_params));
         }
         if (isset($this->search_params['contact_id'])) {
             $layout->assign('action_info', array('search' => array('contact_id' => $this->search_params['contact_id'])));
         }
         $layout->assign('is_search', $is_search);
     }
     $this->view->assign('is_search', $is_search);
//.........这里部分代码省略.........
开发者ID:Favorskij,项目名称:webasyst-framework,代码行数:101,代码来源:blogFrontend.action.php

示例13: execute

 public function execute()
 {
     $user = $this->getUser();
     $filter = waRequest::get('filter');
     $contact_settings = new waContactSettingsModel();
     if (!$filter) {
         $filter = $contact_settings->getOne($user->getId(), $this->getAppId(), 'comments_filter');
         if (!$filter) {
             $filter = 'myposts';
         }
     } else {
         $contact_settings->set($user->getId(), $this->getAppId(), 'comments_filter', $filter);
     }
     $contact_photo_size = 20;
     $comments_per_page = max(1, intval($this->getConfig()->getOption('comments_per_page')));
     $page = max(1, waRequest::get('page', 1, waRequest::TYPE_INT));
     $blogs = blogHelper::getAvailable();
     $offset = $comments_per_page * ($page - 1);
     $prepare_options = array('datetime' => blogActivity::getUserActivity());
     $fields = array("photo_url_{$contact_photo_size}");
     $blog_ids = array_keys($blogs);
     $data = $this->getComments(array('offset' => $offset, 'limit' => $comments_per_page, 'blog_id' => $blog_ids, 'filter' => $filter), $fields, $prepare_options);
     $comments = $data['comments'];
     $comments_all_count = $data['comments_all_count'];
     $post_ids = array();
     foreach ($comments as $comment) {
         $post_ids[$comment['post_id']] = true;
     }
     //get related posts info
     $post_model = new blogPostModel();
     $search_options = array('id' => array_keys($post_ids));
     $extend_options = array('user' => false, 'link' => true, 'rights' => true, 'plugin' => false, 'comments' => false);
     $extend_data = array('blog' => $blogs);
     $posts = $post_model->search($search_options, $extend_options, $extend_data)->fetchSearchAll(false);
     $comments = blogCommentModel::extendRights($comments, $posts);
     $comments_count = ($page - 1) * $comments_per_page + count($comments);
     if ($page == 1) {
         $this->setLayout(new blogDefaultLayout());
         $this->getResponse()->setTitle(_w('Comments'));
     }
     /**
      * Backend comments view page
      * UI hook allow extends backend comments view page
      * @event backend_comments
      * @param array[int][string]mixed $comments
      * @param array[int][string]int $comments[%id%][id] comment id
      * @return array[string][string]string $return[%plugin_id%]['toolbar'] Comment's toolbar html
      */
     $this->view->assign('backend_comments', wa()->event('backend_comments', $comments, array('toolbar')));
     $this->view->assign('comments', $comments);
     $this->view->assign('comments_count', $comments_count);
     $this->view->assign('comments_total_count', $comments_all_count);
     $this->view->assign('comments_per_page', $comments_per_page);
     $this->view->assign('pages', ceil($comments_all_count / $comments_per_page));
     $this->view->assign('page', $page);
     $this->view->assign('contact_rights', $this->getUser()->getRights('contacts', 'backend'));
     $this->view->assign('current_contact_id', $user->getId());
     $this->view->assign('current_contact', array('id' => $user->getId(), 'name' => $user->getName(), 'photo20' => $user->getPhoto($contact_photo_size)));
     $this->view->assign('filter', $filter);
     $yet_authors_exist = false;
     if ($blogs) {
         $yet_authors_exist = !!$post_model->select('contact_id')->where('blog_id IN (' . implode(',', $blog_ids) . ') AND contact_id != ' . $user->getId())->limit(1)->fetchField();
     }
     $this->view->assign('blogs', $blogs);
     $this->view->assign('yet_authors_exist', $yet_authors_exist);
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:66,代码来源:blogComments.action.php

示例14: execute

 public function execute()
 {
     $this->user = $this->getUser();
     $blog_id = waRequest::get('blog', null, 'int');
     $post_id = waRequest::get('id', null, 'int');
     $request = waRequest::get();
     $module = waRequest::get('module');
     $action = waRequest::get('action');
     if (!$action) {
         $action = waRequest::get('module');
     }
     $view_all_posts = waRequest::get('all', null) !== null || empty($request);
     $blog_model = new blogBlogModel();
     $blogs = $blog_model->getAvailable($this->user, array(), null, array('new' => true, 'expire' => 1, 'link' => false));
     $blog_ids = array_keys($blogs);
     $comment_model = new blogCommentModel();
     $comment_count = $comment_model->getCount($blog_ids);
     $activity_datetime = blogActivity::getUserActivity();
     $comment_new_count = $comment_model->getCount($blog_ids, null, $activity_datetime, 1);
     $post_count = 0;
     $new_post_count = 0;
     $writable_blogs = false;
     foreach ($blogs as $blog) {
         $post_count += $blog['qty'];
         if ($blog['rights'] >= blogRightConfig::RIGHT_READ_WRITE) {
             $writable_blogs = true;
         }
         if (isset($blog['new_post']) && $blog['new_post'] > 0) {
             $new_post_count += $blog['new_post'];
         }
     }
     if ($writable_blogs) {
         $post_model = new blogPostModel();
         $search_options = array('status' => array(blogPostModel::STATUS_DRAFT, blogPostModel::STATUS_DEADLINE, blogPostModel::STATUS_SCHEDULED));
         if (!$this->user->isAdmin($this->getApp())) {
             $search_options['contact_id'] = $this->user->getId();
         }
         $search_options['sort'] = 'overdue';
         $drafts = $post_model->search($search_options, array('status' => true, 'link' => false, 'plugin' => false, 'comments' => false), array('blog' => $blogs))->fetchSearchAll(false);
         $where = "status = '" . blogPostModel::STATUS_DEADLINE . "' AND datetime <= '" . waDateTime::date("Y-m-d") . "'";
         if (!$this->getUser()->isAdmin($this->getApp())) {
             $where .= " AND contact_id = {$this->getUser()->getId()}";
             $where .= " AND blog_id IN (" . implode(', ', array_keys($blogs)) . ")";
         }
         $count_overdue = $post_model->select("count(id)")->where($where)->fetchField();
         $count_overdue = $count_overdue ? $count_overdue : 0;
     } else {
         $drafts = false;
         $count_overdue = false;
     }
     /**
      * Extend backend sidebar
      * Add extra sidebar items (menu items, additional sections, system output)
      * @event backend_sidebar
      * @example #event handler example
      * public function sidebarAction()
      * {
      *     $output = array();
      *
      *     #add external link into sidebar menu
      *     $output['menu']='<li>
      *         <a href="http://www.webasyst.com">
      *             http://www.webasyst.com
      *         </a>
      *     </li>';
      *
      *     #add section into sidebar menu
      *     $output['section']='';
      *
      *     #add system link into sidebar menu
      *     $output['system']='';
      *
      *     return $output;
      * }
      * @return array[string][string]string $return[%plugin_id%]['menu'] Single menu items
      * @return array[string][string]string $return[%plugin_id%]['section'] Sections menu items
      * @return array[string][string]string $return[%plugin_id%]['system'] Extra menu items
      */
     $this->view->assign('backend_sidebar', wa()->event('backend_sidebar'));
     $this->view->assign('blog_id', $blog_id);
     $this->view->assign('blogs', $blogs);
     $this->view->assign('view_all_posts', $view_all_posts);
     $this->view->assign('action', $action);
     $this->view->assign('module', $module);
     $this->view->assign('post_id', $post_id);
     $this->view->assign('new_post', waRequest::get('action') == 'edit' && waRequest::get('id') == '');
     $this->view->assign('drafts', $drafts);
     $this->view->assign('comment_count', $comment_count);
     $this->view->assign('comment_new_count', $comment_new_count);
     $this->view->assign('post_count', $post_count);
     $this->view->assign('new_post_count', $new_post_count);
     $this->view->assign('count_draft_overdue', $count_overdue);
     $this->view->assign('writable_blogs', $writable_blogs);
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:94,代码来源:blogBackendSidebar.action.php

示例15: execute

 public function execute()
 {
     $blog_model = new blogBlogModel();
     $blogs = $blog_model->getAvailable($this->getUser());
     $stream = array('all_posts' => false);
     $title_suffix = '';
     $search_options = array();
     // native search
     if ($text = waRequest::get('text', '')) {
         $text = urldecode($text);
         $search_options['text'] = $text;
         $title_suffix = " / {$text}";
     }
     // plugins' search
     if ($plugin = waRequest::get('search', false)) {
         $search_options["plugin"] = array();
         if (is_array($plugin)) {
             foreach ($plugin as $plugin_id => $plugin_params) {
                 $search_options["plugin"][$plugin_id] = $plugin_params;
             }
         } else {
             $search_options["plugin"][$plugin] = waRequest::get($plugin, true);
         }
     }
     if ($blog_id = max(0, waRequest::get('blog', null, waRequest::TYPE_INT))) {
         if (!isset($blogs[$blog_id])) {
             throw new waException(_w('Blog not found'), 404);
         }
         wa()->getStorage()->write('blog_last_id', $blog_id);
         $blog =& $blogs[$blog_id];
         $stream['title'] = $blog['name'];
         $stream['link'] = $this->getUrl($blog);
         $stream['blog'] = $blog;
         $search_options['blog_id'] = $blog_id;
     } else {
         if (empty($search_options["plugin"])) {
             $stream['title'] = _w('All posts');
             $stream['link'] = $this->getUrl();
             $stream['all_posts'] = true;
         } else {
             $stream['title'] = '';
             $stream['link'] = '';
         }
         $stream['blog'] = null;
         $search_options['blog_id'] = array_keys($blogs);
     }
     $this->getResponse()->setTitle($stream['title'] . $title_suffix);
     $search = false;
     $page = max(1, waRequest::get('page', 1, waRequest::TYPE_INT));
     $posts_per_page = max(1, intval($this->getConfig()->getOption('posts_per_page')));
     $extend_options = array();
     $extend_options['status'] = 'view';
     $extend_options['author_link'] = false;
     $extend_options['rights'] = true;
     if (!$this->getRequest()->isMobile()) {
         $extend_options['text'] = 'cut';
     }
     $post_model = new blogPostModel();
     $posts = $post_model->search($search_options, $extend_options, array('blog' => $blogs))->fetchSearchPage($page, $posts_per_page);
     // Add photo albums to posts
     blogPhotosBridge::loadAlbums($posts);
     if ($page == 1) {
         $stream['title'] = $this->getResponse()->getTitle();
         $this->chooseLayout();
         $this->view->assign('search', $plugin ? urldecode(http_build_query(array('search' => $plugin))) : null);
         /**
          * Backend posts stream view page
          * UI hook allow extends backend posts view page
          * @event backend_stream
          * @param array[string]mixed $stream Array of stream properties
          * @param array[string]array $stream['blog'] Related blog data array or null
          * @param array[string]string $stream['title'] Stream title
          * @param array[string]string $stream['link'] Stream link
          * @return array[string][string]string $return['%plugin_id%']['menu'] Stream context menu html
          */
         $this->view->assign('backend_stream', wa()->event('backend_stream', $stream, array('menu')));
     }
     $posts_count = ($page - 1) * $posts_per_page + count($posts);
     $import_link = null;
     if ($posts_count <= 0 && !empty($stream['all_posts'])) {
         // When import plugin is installed, show its link on the welcome page
         $plugins = wa()->getConfig()->getPlugins();
         if (!empty($plugins['import'])) {
             $import_link = wa()->getUrl() . '?module=plugins#/settings/custom/import/';
         }
     }
     $this->view->assign('blogs', $blogs);
     $this->view->assign('blog_id', $blog_id);
     $this->view->assign('text', $text);
     $this->view->assign('stream', $stream);
     $this->view->assign('page', $page);
     $this->view->assign('pages', $post_model->pageCount());
     $this->view->assign('posts_total_count', $post_model->searchCount());
     $this->view->assign('posts_count', $posts_count);
     $this->view->assign('import_link', $import_link);
     $this->view->assign('posts_per_page', $posts_per_page);
     $this->view->assign('contact_rights', $this->getUser()->getRights('contacts', 'backend'));
     if ($this->getConfig()->getOption('can_use_smarty')) {
         foreach ($posts as &$post) {
             try {
//.........这里部分代码省略.........
开发者ID:Lazary,项目名称:webasyst,代码行数:101,代码来源:blogBackend.action.php


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