public function execute() { $is_admin = $this->getUser()->isAdmin($this->getApp()); $storage = $this->getStorage(); if (waRequest::post('save')) { $this->save(); $save_id = rand(10000, 99999); $storage->write('blog_setttings_save_id', $save_id); $this->redirect(array('module' => 'settings', 'save' => $save_id)); } if ($is_admin) { $e_g = blogHelper::getAvailable(); reset($e_g); $user = $this->getUser(); $this->view->assign('e_g', current($e_g)); $this->view->assign('user_name', $user['name']); // Checking if have saved now $save_id = $storage->read('blog_setttings_save_id'); } // Checking if have saved now $save_id = $storage->read('blog_setttings_save_id'); if ($save_id && $save_id == waRequest::get('save', 0)) { $storage->del('blog_setttings_save_id'); $this->view->assign('saved', 1); } $this->getResponse()->setTitle(_w('Blog settings page')); $this->setLayout(new blogDefaultLayout()); $this->view->assign('user_settings', $res = $this->getUserSettings()); if ($is_admin) { $this->view->assign('backend_settings', $this->getFrontendSettings()); $this->view->assign('routing_settings_url', blogHelper::getRouteSettingsUrl()); } }
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))); }
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'] = '******'; $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'); }
public function execute() { $is_admin = $this->getUser()->isAdmin($this->getApp()); $storage = $this->getStorage(); if (waRequest::post('save')) { $this->save(); $save_id = rand(10000, 99999); $storage->write('blog_setttings_save_id', $save_id); $this->redirect(array('module' => 'settings', 'save' => $save_id)); } if ($is_admin) { $e_g = blogHelper::getAvailable(); reset($e_g); $user = $this->getUser(); $this->view->assign('e_g', current($e_g)); $this->view->assign('user_email', $user->get('email', 'default')); // Checking if have saved now $save_id = $storage->read('blog_setttings_save_id'); } // Checking if have saved now $save_id = $storage->read('blog_setttings_save_id'); if ($save_id && $save_id == waRequest::get('save', 0)) { $storage->del('blog_setttings_save_id'); $this->view->assign('saved', 1); } $this->getResponse()->setTitle(_w('Blog settings page')); $this->setLayout(new blogDefaultLayout()); $this->view->assign('user_settings', $res = $this->getUserSettings()); if ($is_admin) { $this->view->assign('backend_settings', $this->getFrontendSettings()); // to mislead potential foes, apparently... $this->view->assign('routing_settings_url', blogHelper::getRouteSettingsUrl()); $this->view->assign('photos_app_available', blogPhotosBridge::isAvailable()); } $app_settings_model = new waAppSettingsModel(); $this->view->assign('last_reminder_cron_time', $app_settings_model->get('blog', 'last_reminder_cron_time')); $this->view->assign('cron_command', 'php ' . wa()->getConfig()->getRootPath() . '/cli.php blog reminder'); }
public function backendSidebar($params) { $output = array(); $post_model = new blogPostModel(); $blogs = blogHelper::getAvailable(false); $search_options = array('contact_id' => wa()->getUser()->getId(), 'status' => blogPostModel::STATUS_PUBLISHED, 'blog_id' => array_keys($blogs)); $count = $post_model->countByField($search_options); $selected = ''; if (waRequest::get('search') == $this->id) { $selected = ' class="selected"'; } $img_url = wa()->getUser()->getPhoto(20); $title = _wp('Posts by me'); $output['menu'] = <<<HTML <li{$selected}> \t<span class="count my_count">{$count}</span> \t<a href="?search={$this->id}"> \t\t<i class="icon16 userpic20" style="background-image: url('{$img_url}');"></i>{$title} \t</a> </li> HTML; return $output; }
protected function getComments($search_options) { if (empty($search_options['post_id'])) { $search_options['post_id'] = null; } if (!isset($search_options['blog_id'])) { $search_options['blog_id'] = array_keys(blogHelper::getAvailable()); } else { if (is_numeric($search_options['blog_id'])) { $search_options['blog_id'] = array((int) $search_options['blog_id']); } else { if (!is_array($search_options['blog_id'])) { $search_options['blog_id'] = array(); } } } if (is_numeric($search_options['filter'])) { $search_options['filter'] = (int) $search_options['filter']; if (in_array($search_options['filter'], $search_options['blog_id'])) { $search_options['blog_id'] = array($search_options['filter']); } else { $search_options['blog_id'] = array(); } } else { if ($search_options['filter'] == 'myposts') { if (empty($search_options['blog_id'])) { $search_options['post_id'] = array(); } else { $post_model = new blogPostModel(); $search_options['post_id'] = array_keys($post_model->select('id')->where('contact_id=? AND blig_id IN (?)', array($this->getUser()->getId(), $search_options['blog_id']))->fetchAll('id')); } } } $search_options['approved'] = true; $comment_model = new blogCommentModel(); return $comment_model->getList($search_options, array("photo_url_20"), array('datetime' => blogActivity::getUserActivity())); }
public function frontendExecute() { $post_slug = waRequest::param('post_url', false, waRequest::TYPE_STRING_TRIM); $storage = wa()->getStorage(); $post_model = new blogPostModel(); $show_comments = $this->appSettings('show_comments', true); $request_captcha = $show_comments && $this->appSettings('request_captcha', true); $require_authorization = $show_comments && $this->appSettings('require_authorization', false); $available = blogHelper::getAvailable(); // it's preview $hash = waRequest::get('preview'); $post = $post_model->search(array('url' => $post_slug, 'status' => $hash ? false : blogPostModel::STATUS_PUBLISHED), array('comments' => $show_comments ? array(50, 20) : false, 'params' => true, 'escape' => true), array('blog' => $available))->fetchSearchItem(); if (!$post) { throw new waException(_w('Post not found'), 404); } if ($post['status'] != blogPostModel::STATUS_PUBLISHED) { $hash = base64_decode($hash); list($hash, $user_id) = array(substr($hash, 0, 32), substr($hash, 32)); $options = array('contact_id' => $post['contact_id'], 'blog_id' => $post['blog_id'], 'post_id' => $post['id'], 'user_id' => $user_id); $preview_cached_options = $storage->read('preview'); $preview_cached_post_options = isset($preview_cached_options['post_id']) ? $preview_cached_options['post_id'] : null; if ($preview_cached_post_options && $preview_cached_post_options != $options) { $preview_cached_post_options = null; } if (!$preview_cached_post_options) { if ($hash == blogPostModel::getPreviewHash($options, false, false)) { $preview_cached_options['post_id'] = $preview_cached_post_options = $options; $storage->write('preview', $preview_cached_options); } } if (!$preview_cached_post_options) { throw new waException(_w('Post not found'), 404); } if (!$this->checkAuthorRightsToBlog($user_id, $post)) { throw new waException(_w('Post not found'), 404); } } $title = $this->getResponse()->getTitle(); if ($this->getRequest()->param('title_type', 'blog_post') == 'blog_post') { if ($title) { $this->getResponse()->setTitle($title . " » " . $post['title']); } elseif (isset($available[$post['blog_id']]) && ($title = $available[$post['blog_id']]['title'])) { $this->getResponse()->setTitle($title . " » " . $post['title']); } else { $this->getResponse()->setTitle($post['title']); } } else { $this->getResponse()->setTitle($post['title']); } $blog_id = (array) $this->getRequest()->param('blog_id'); if (!in_array($post['blog_id'], $blog_id)) { if ($this->getRequest()->param('blog_url_type') == 0) { if (isset($available[$post['blog_id']])) { $this->redirect($post['link'], 301); } } throw new waException(_w('Post not found'), 404); } $this->getRequest()->setParam('blog_id', $post['blog_id']); if (isset($post['comments']) && !empty($post['comments'])) { $depth = 1000; foreach ($post['comments'] as $key => $comment) { if ($comment['status'] == blogCommentModel::STATUS_DELETED) { if ($comment['depth'] < $depth) { $depth = $comment['depth']; } unset($post['comments'][$key]); continue; } if ($comment['depth'] > $depth) { unset($post['comments'][$key]); } else { $depth = 1000; } } } $errors = array(); $form = array(); if ($storage->read('errors') !== null) { $errors = $storage->read('errors'); $form = $storage->read('form'); $storage->remove('errors'); $storage->remove('form'); } $post['comment_link'] = blogPost::getUrl($post, 'comment'); $post['link'] = blogPost::getUrl($post); /** * Frontend post view page * UI hook allow extends frontend post view page * @event frontend_post * @param array[string]mixed $post * @param array[string]int $post['id'] * @param array[string]int $post['blog_id'] * @return array[string][string]string $return[%plugin_id%] * @return array[string][string]string $return[%plugin_id%]['footer'] */ $this->view->assign('frontend_post', wa()->event('frontend_post', $post)); $this->view->assign('errors', $errors); $this->view->assign('form', $form); $this->view->assign('show_comments', $show_comments); $this->view->assign('request_captcha', $request_captcha); $this->view->assign('require_authorization', $require_authorization); $this->view->assign('theme', waRequest::param('theme', 'default')); $app_url = wa()->getAppStaticUrl(); $root_url = wa()->getRootUrl(); $storage = wa()->getStorage(); $current_auth = $storage->read('auth_user_data'); $current_auth_source = $current_auth ? $current_auth['source'] : null; $this->view->assign('current_auth_source', $current_auth_source); $this->view->assign('current_auth', $current_auth, true); $adapters = wa()->getAuthAdapters(); $this->view->assign('auth_adapters', $adapters); $this->view->getHelper()->globals($this->getRequest()->param()); 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); }
public function onCount() { $full = !func_get_args(); $app = $this->getApplication(); $user = waSystem::getInstance()->getUser(); $user_id = $user->getId(); $type = explode(':', $user->getSettings($app, 'type_items_count')); $type = array_filter(array_map('trim', $type), 'strlen'); if (!$type) { $type = array('posts', 'comments_to_my_post', 'overdue'); } $activity_datetime = blogActivity::getUserActivity($user_id, false); $blogs = array_keys(blogHelper::getAvailable(false)); $counter = array(); $post_model = new blogPostModel(); if (in_array('posts', $type) && $full && $blogs) { $post_new_count = $post_model->getAddedPostCount($activity_datetime, $blogs); $post_new_count = array_sum($post_new_count); $counter['posts'] = $post_new_count; } else { $counter['posts'] = false; } if (in_array('comments', $type) && $full && $blogs) { $comment_model = new blogCommentModel(); $counter['comments'] = $comment_model->getCount($blogs, null, $activity_datetime, 0); } else { $counter['comments'] = false; } if (in_array('comments_to_my_post', $type) && $full && $blogs) { $comment_model = new blogCommentModel(); $counter['comments_to_my_post'] = $comment_model->getCount($blogs, null, $activity_datetime, 0, $user_id); } else { $counter['comments_to_my_post'] = false; } if (in_array('overdue', $type) && $blogs) { if (!isset($post_model)) { $post_model = new blogPostModel(); } $where = "status = '" . blogPostModel::STATUS_DEADLINE . "'"; $where .= " AND blog_id IN (" . implode(', ', $blogs) . ")"; $where .= " AND contact_id = {$user_id}"; $where .= " AND datetime <= '" . waDateTime::date("Y-m-d") . "'"; $count_overdue = $post_model->select("count(id)")->where($where)->fetchField(); $counter['overdue'] = $count_overdue ? $count_overdue : 0; } else { $counter['overdue'] = false; } $count = array_sum($counter); $url = $this->getBackendUrl(true) . $this->application . '/'; if ($count) { switch ($count) { case $counter['comments']: case $counter['comments_to_my_post']: $url .= '?module=comments'; break; case $counter['overdue']: $url .= '?action=calendar'; break; } } //debug //$counter['type'] = $type; //$counter['activity_datetime'] = $activity_datetime; //$counter['current_datetime'] = date("Y-m-d H:i:s",time()); //waLog::log('$counter = '.var_export($counter,true),"blog-counter-{$user_id}.log"); return array('count' => $count == 0 ? null : $count, 'url' => $url); }
public function execute($plugin = null, $module = null, $action = null, $default = false) { if (!$plugin && $module == 'frontend') { try { if (!waRequest::param('page_id')) { $request_url = parse_url($this->system->getRootUrl() . $this->system->getConfig()->getRequestUrl()); if (isset($request_url['path']) && $request_url['path'] && substr($request_url['path'], -1) != '/') { $request_url['path'] .= '/'; $this->system->getResponse()->redirect(implode('', $request_url), 301); } } #parse request URL $params = waRequest::param(); #determine blog ID which are dependent on routing settings $blog_model = new blogBlogModel(); $blogs = array(); $params['blog_url_type'] = waRequest::param('blog_url_type', 0, waRequest::TYPE_INT); if (!($title = waRequest::param('title'))) { $title = wa()->accountName(); } $blog_url = waRequest::param('blog_url', '', waRequest::TYPE_STRING_TRIM); $main_page = false; if ($params['blog_url_type'] > 0) { if ($blog = $blog_model->getByField(array('id' => $params['blog_url_type'], 'status' => blogBlogModel::STATUS_PUBLIC))) { $blogs[] = $blog; $main_page = true; } } elseif (strlen($blog_url)) { if ($blog = $blog_model->getBySlug($blog_url, true, array('id', 'name', 'url'))) { $blogs[] = $blog; } } else { $blogs = blogHelper::getAvailable(); if (!isset($params['post_url'])) { if (count($blogs) > 1 || $params['blog_url_type'] == 0) { $main_page = true; } } } if ($blogs) { if (count($blogs) == 1 && ($params['blog_url_type'] != 0 || strlen($blog_url))) { $blog = reset($blogs); $params['blog_id'] = intval($blog['id']); $params['blog_url'] = $blog['url']; if (!$main_page) { $routing = wa()->getRouting(); if ($params['blog_id'] != $routing->getRouteParam('blog_url_type') || isset($params['post_url'])) { $title = $blog['name']; } elseif (!$title) { $title = $blog['name']; } } } else { $params['blog_id'] = array_map('intval', array_keys($blogs)); } } else { throw new waException(_w('Blog not found'), 404); } wa()->getResponse()->setTitle($title); if ($main_page) { wa()->getResponse()->setMeta('keywords', waRequest::param('meta_keywords')); wa()->getResponse()->setMeta('description', waRequest::param('meta_description')); } waRequest::setParam($params); parent::execute($plugin, $module, $action, $default); } catch (Exception $e) { waRequest::setParam('exception', $e); parent::execute(null, 'frontend', 'error'); } } else { parent::execute($plugin, $module, $action, $default); } }
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); }
public function timeline($blog_ids = array(), $datetime = array()) { $blogs = blogHelper::getAvailable(); if (empty($blog_ids)) { $blog_ids = array_keys($blogs); } $blog_post_model = new blogPostModel(); return $blog_post_model->getTimeline($blog_ids, $blogs, $datetime); }
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); $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)); } }