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($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); } }