public function storiesAction()
 {
     $count = $this->getRequest()->getParam("count");
     $count = $count ? $count : 5;
     // Hit the cache
     $cache_id = "embed_stories_{$this->_user->id}_{$count}";
     if (!$this->_cache || !($script = $this->_cache->load($cache_id))) {
         // A few variable needed
         $base = "http://" . Stuffpress_Application::getDomain($this->_user);
         // Get the user properties
         $username = $this->_user->username;
         // Get all the items; if we are an admin, we also get the hidden one
         $stories = new Stories();
         $items = $stories->getStories($count, 0, false);
         $content = "<div id='storytlr_widget' class='storytlr_widget'>";
         if (count($items) == 0) {
             $content .= "<p>{$username} has not created any story yet.</p>";
         } else {
             foreach ($items as $item) {
                 $item['permalink'] = Stuffpress_Permalink::story($item['id'], $item['title']);
                 $date_from = date("F j, Y", $item['date_from']);
                 $date_to = date("F j, Y", $item['date_to']);
                 $item_content = "<table><tr>";
                 $item_content .= "<td class='thumbnail'><a href='{$base}/story/{$item['permalink']}'>";
                 if ($item['thumbnail']) {
                     $item_content .= "<img src='{$base}/thumbnail/{$item['thumbnail']}'>";
                 } else {
                     $item_content .= "<img src='{$base}/images/book50.jpg'>";
                 }
                 $item_content .= "</a></td>";
                 $item_content .= "<td class='overview'>";
                 $item_content .= "<div class='title'><a href='{$base}/story/{$item['permalink']}'>" . $this->escape($item['title']) . "</a></div>";
                 $item_content .= "<div class='subtitle'>" . $this->escape($item['subtitle']) . "</div>";
                 $item_content .= "<div class='date'>{$date_from} to {$date_to}</div>";
                 $item_content .= "</td>";
                 $item_content .= "</tr></table>";
                 $content .= $item_content;
             }
         }
         $content .= "</div>";
         $script = "document.write(\"<link href='{$base}/style/embed_stories.css' media='screen, projection' rel='stylesheet' type='text/css' />\");\r\n" . "document.write('<script src=\\'{$base}/js/controllers/embed_story.js\\' type=\\'text/javascript\\' /></script>');\r\n" . "document.write(\"<div id='storytlr'>\");\r\n" . "document.write(\"<h1>" . ucfirst($username) . "'s Stories</h1>\");\r\n" . "document.write(\"" . $content . "\");\r\n" . "document.write(\"<div class='bar'><a href='{$base}'><img src='{$base}/images/powered2.png'></a></div>\");\r\n" . "document.write(\"</div>\");";
         if ($this->_cache) {
             $this->_cache->save($script, $cache_id, array("stories_{$this->_user->id}"), 300);
         }
     }
     header("Content-Disposition: attachment; filename=\"stories.js\"");
     header("Content-type: text/javascript; charset=UTF-8");
     echo $script;
     ob_end_flush();
     die;
 }
Beispiel #2
0
 public function expand($token)
 {
     if (!($url = $this->getUrl($token))) {
         return false;
     }
     if ($url['internal']) {
         $users = new Users();
         if (!($user = $users->getUser($url['user_id']))) {
             return false;
         }
         $domain = Stuffpress_Application::getDomain($user);
         return "http://" . $domain . "/entry/" . $url['url'];
     } else {
         return $url['url'];
     }
 }
 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 init()
 {
     // Set the user shard
     if (Zend_Registry::isRegistered("user")) {
         $this->_user = Zend_Registry::get("user");
     }
     if (!Zend_Registry::isRegistered('shard')) {
         Zend_Registry::set("shard", $this->_user->id);
     }
     // Get the config
     if (Zend_Registry::isRegistered("configuration")) {
         $this->_config = Zend_Registry::get("configuration");
     }
     // Set the domain
     $this->_domain = Stuffpress_Application::getDomain($this->_user, true);
     // Get the user properties
     $this->_properties = new Properties(array(Stuffpress_Db_Properties::KEY => $this->_user->id));
     // Prevent the layout to be rendered
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->layout->disableLayout();
 }
Beispiel #5
0
 public function __construct($user = false, $domain = false)
 {
     $this->_user = $user ? $user : Zend_Registry::get("user");
     $this->_domain = $domain ? $domain : Stuffpress_Application::getDomain($this->_user, true);
     $this->_config = Zend_Registry::get("configuration");
 }
Beispiel #6
0
    public function getPublicDomain($cname=true) {
		return Stuffpress_Application::getDomain($this->user, $cname);
    }