本文整理汇总了PHP中blogPostModel::searchCount方法的典型用法代码示例。如果您正苦于以下问题:PHP blogPostModel::searchCount方法的具体用法?PHP blogPostModel::searchCount怎么用?PHP blogPostModel::searchCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blogPostModel
的用法示例。
在下文中一共展示了blogPostModel::searchCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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 {
//.........这里部分代码省略.........
示例2: execute
//.........这里部分代码省略.........
$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);
$this->view->assign('page', $this->page);
$this->view->assign('is_lazyloading', $this->is_lazyloading);
$this->view->assign('pages', $pages);
$this->view->assign('post_count', $post_model->searchCount());
$this->view->assign('show_comments', !isset($options['comments']) || $options['comments']);
$this->view->assign('posts_per_page', $posts_per_page);
$this->view->assign('blog_query', $query);
/**
* Backward compatibility with older themes
* @deprecated
*/
$this->view->assign('is_concrete_blog', waRequest::param('blog_url') ? true : false);
$this->view->assign('layout_type', $this->is_lazyloading ? 'lazyloading' : ($this->page > 1 ? 'page' : 'default'));
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);
}
$this->view->assign('posts', $posts);
if ($this->cache_time && false) {
$this->cache->set(array_keys($posts));
}
}