public function indexAction()
 {
     // To do before anything else
     $this->initPage();
     // Action parameters
     $page = $this->getRequest()->getParam("page");
     $tab = $this->getRequest()->getParam("tab");
     // A bit of filtering
     $page = $page >= 0 ? $page : 0;
     $count = 25;
     // Get the list of sources to filter on
     if ($this->_page_properties && $this->_page_properties->getProperty('sources_filter') > 0) {
         $sources = unserialize($this->_page_properties->getProperty('sources'));
     } else {
         $sources = false;
     }
     // Get all the items; if we are an admin, we also get the hidden one
     $data = new Data();
     $items = $data->getLastItems($count, $page * $count, $this->_admin, $sources, array(SourceItem::IMAGE_TYPE));
     $this->view->items = $items;
     $this->view->models = $this->getModels();
     // Set link to RSS of page
     $rss_link = $this->getRssLink($sources, array('image'));
     $this->view->headLink()->appendAlternate($rss_link, "application/rss+xml", "RSS Stream");
     // Add paging
     $this->view->count = $count;
     $this->view->page = $page;
     $this->view->hasprevious = $page > 0 ? true : false;
     $this->view->hasnext = count($items) >= $count ? true : false;
     $this->view->nextlink = "home?tab={$tab}&page=" . ($page + 1);
     $this->view->previouslink = "home?tab={$tab}&page=" . ($page - 1);
     // Prepare the common elements
     $this->common();
     // Special
     if (!$this->_page) {
         $this->view->page_title = "All pictures";
     }
     // Add description
     if ($description = $this->_page_properties->getProperty('description')) {
         $this->view->description = $description;
     }
     // Add specific styles and javascripts
     $this->view->headScript()->appendFile('js/shadowbox/adapter/shadowbox-prototype.js');
     $this->view->headScript()->appendFile('js/shadowbox/shadowbox.js');
     $this->view->headScript()->appendFile('js/shadowbox/init.js');
 }
 public function indexAction()
 {
     // To do before anything else
     $this->initPage();
     // Action parameters
     $page = $this->getRequest()->getParam("page");
     $tab = $this->getRequest()->getParam("tab");
     // A bit of filtering
     $page = $page >= 0 ? $page : 0;
     $count = 50;
     // Get the list of sources to filter on
     if ($this->_page_properties->getProperty('sources_filter') > 0) {
         $sources = unserialize($this->_page_properties->getProperty('sources'));
         $types = unserialize($this->_page_properties->getProperty('types'));
     } else {
         $sources = false;
         $types = false;
     }
     // Get all the items; if we are an admin, we also get the hidden one
     $data = new Data();
     $items = $data->getLastItems($count, $page * $count, $this->_admin, $sources, $types);
     $this->view->items = $items;
     $this->view->models = $this->getModels();
     // Prepare the common elements
     $this->common();
     // Add description
     if ($description = $this->_page_properties->getProperty('description')) {
         $this->view->description = $description;
     }
     // Add paging
     $this->view->count = $count;
     $this->view->page = $page;
     $this->view->hasprevious = $page > 0 ? true : false;
     $this->view->hasnext = count($items) >= $count ? true : false;
     $this->view->nextlink = "home?tab={$tab}&page=" . ($page + 1);
     $this->view->previouslink = "home?tab={$tab}&page=" . ($page - 1);
     // Add atom link
     $domain = Stuffpress_Application::getDomain($this->_user);
     $this->view->headLink()->appendAlternate("http://{$domain}/updates.atom", "application/atom+xml", "Update stream in Atom");
     // Add specific styles and javascripts
     $this->view->headScript()->appendFile('js/controllers/timeline.js');
     if (!$this->_embed) {
         $this->view->headLink()->appendStylesheet('style/lightbox.css');
     }
 }
 public function viewAction()
 {
     // Action parameters
     $page = $this->getRequest()->getParam("page");
     // A bit of filtering
     $page = $page >= 0 ? $page : 0;
     $count = 50;
     // Get all the items; if we are an admin, we also get the hidden one
     $data = new Data();
     $items = $data->getLastItems($count, $page * $count, $this->_admin, false, false, true);
     $this->view->items = $items;
     $this->view->models = $this->getModels();
     // Prepare the common elements
     $this->common();
     // Add the data required by the view
     $this->view->username = $user->username;
     $this->view->owner = $owner;
     $this->view->user_id = $user->id;
     $this->view->gmap_key = $this->_config->gmap->key;
 }
 public function indexAction()
 {
     // To do before anything else
     $this->initPage();
     // Get the list of sources to filter on
     $types = unserialize($this->_page_properties->getProperty('types'));
     // Get all the items; if we are an admin, we also get the hidden one
     $data = new Data();
     if (!$types || in_array('status', $types)) {
         $this->view->items_status = $data->getLastItems(5, 0, false, false, array('status'));
     }
     if (!$types || in_array('link', $types)) {
         $this->view->items_link = $data->getLastItems(5, 0, false, false, array('link'));
     }
     if (!$types || in_array('blog', $types)) {
         $this->view->items_blog = $data->getLastItems(1, 0, false, false, array('blog'));
     }
     if (!$types || in_array('image', $types)) {
         $this->view->items_image = $data->getLastItems(6, 0, false, false, array('image'));
     }
     if (!$types || in_array('audio', $types)) {
         $this->view->items_audio = $data->getLastItems(10, 0, false, false, array('audio'));
     }
     if (!$types || in_array('video', $types)) {
         $this->view->items_video = $data->getLastItems(6, 0, false, false, array('video'));
     }
     if (!$types || in_array('story', $types)) {
         $storiesTable = new Stories();
         $this->view->items_story = $storiesTable->getStories(1, 0, false);
     }
     // Add the models
     $this->view->models = $this->getModels();
     // Prepare the common elements
     $this->common();
     // Set link to RSS of page
     $host = trim(Zend_Registry::get("host"), '/');
     $rss_link = "http://{$host}/rss";
     $this->view->headLink()->appendAlternate($rss_link, "application/rss+xml", "RSS Stream");
 }
 public function rssAction()
 {
     // Let's get some parameters
     $sources = $this->validateSources($this->getRequest()->getParam("sources"));
     $types = $this->validateTypes($this->getRequest()->getParam("types"));
     $nopre = $this->getRequest()->getParam("nopre");
     $nopre = $nopre ? true : false;
     // We need a title
     $title = $this->_properties->getProperty('title');
     $subtitle = $this->_properties->getProperty('subtitle');
     if (strlen($subtitle) > 0) {
         $title = $title . " | " . $subtitle;
     }
     // Need a RSS key to identify this specific request
     $key = $nopre . "_" . @implode("_", $sources) . "_" . @implode("_", $types);
     // Get the items
     $data = new Data();
     $items = $data->getLastItems(50, 0, false, $sources, $types);
     // Generate the RSS
     $this->generateRss($key, $items, $title, $nopre);
 }
 protected function _getLatestItems($latest)
 {
     $data = new Data();
     return $data->getLastItems($latest);
 }
Example #7
0
 public function widgetAction()
 {
     $count = $this->getRequest()->getParam("count");
     $count = $count ? $count : 5;
     $host = $this->_config->web->host;
     // Hit the cache
     $cache_id = "embed_widget_{$this->_user->id}_{$count}";
     if (!$this->_cache || !($widget = $this->_cache->load($cache_id))) {
         // Get all the items; if we are an admin, we also get the hidden one
         $username = $this->_user->username;
         $data = new Data();
         $items = $data->getLastItems($count, 0, false);
         $content = "<div id='storytlr_widget' class='storytlr_widget'><table>";
         foreach ($items as $item) {
             $title = ereg_replace("([[:alpha:]]+://[^[:space:]]+[[:alnum:]/])", "<a href='\\1'>\\1</a>", $this->escape(strip_tags($item->getTitle())));
             $item_content = "<tr>";
             $item_content .= "<td class='icon'><a href='{$item->getLink()}'><img src='http://{$host}/images/{$item->getPrefix()}.png'></a></td>";
             $item_content .= "<td class='title'>{$title}</td>";
             $item_content .= "</tr>";
             $content .= $item_content;
         }
         $content .= "</table></div>";
         $widget = "document.write(\"<link href='http://{$host}/style/embed_widget.css' media='screen, projection' rel='stylesheet' type='text/css' />\");\r\n" . "document.write(\"<div id='storytlr'>\");\r\n" . "document.write(\"<h1>" . ucfirst($username) . "'s Lifestream</h1>\");\r\n" . "document.write(\"<h2>Latest updates</h2>\");\r\n" . "document.write(\"" . $content . "\");\r\n" . "document.write(\"<a href='" . $this->getUrl($username, "/") . "'>View all</a>\");\r\n" . "document.write(\"<div class='bar'><a href='http://{$host}'><img src='http://{$host}/images/powered2.png'></a></div>\");\r\n" . "document.write(\"</div>\");";
         if ($this->_cache) {
             $this->_cache->save($widget, $cache_id, array("content_{$this->_user->id}"), 300);
         }
     }
     // Output the result
     header("Content-Disposition: attachment; filename=\"widget.js\"");
     header("Content-type: text/javascript; charset=UTF-8");
     echo $widget;
     ob_end_flush();
     die;
 }