Esempio n. 1
0
 public function indexAction()
 {
     // To do before anything else
     $this->initPage();
     // Get, check and setup the 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 stories
     $storiesTable = new Stories();
     $stories = $storiesTable->getStories($count, $page * $count, $this->_admin);
     // Update stories with few gimicks and assign to view
     foreach ($stories as &$story) {
         $story['permalink'] = Stuffpress_Permalink::story($story['id'], $story['title']);
         $story['is_geo'] = $storiesTable->isGeo($story['id']);
     }
     $this->view->stories = $stories;
     // Navigation options
     $this->view->page = $page;
     $this->view->hasprevious = $page > 0 ? true : false;
     $this->view->hasnext = isset($items) && 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();
     // Add page specific elements
     $this->view->headScript()->appendFile('js/controllers/stories.js');
 }
Esempio n. 2
0
 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
         $host = $this->_config->web->host;
         // 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='http://{$username}.{$host}/story/{$item['permalink']}'>";
                 if ($item['thumbnail']) {
                     $item_content .= "<img src='" . $this->getUrl($username, "/thumbnail/{$item['thumbnail']}") . "'>";
                 } else {
                     $item_content .= "<img src='" . $this->getUrl($username, "/images/book50.jpg") . "'>";
                 }
                 $item_content .= "</a></td>";
                 $item_content .= "<td class='overview'>";
                 $item_content .= "<div class='title'><a href='" . $this->getUrl($username, "/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='http://{$host}/style/embed_stories.css' media='screen, projection' rel='stylesheet' type='text/css' />\");\r\n" . "document.write('<script src=\\'http://{$host}/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='http://{$host}'><img src='http://{$host}/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;
 }
 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");
 }
Esempio n. 4
0
        // We should also delete the associated comments
        $comments = new Comments();
        $comments->deleteComments($source['id']);
    }
}
// Delete all user files
$fdb = new Files();
$files = $fdb->getFiles();
if ($files && count($files) > 0) {
    foreach ($files as $file) {
        $fdb->deleteFile($file->key);
    }
}
// Delete all stories
$stdb = new Stories();
$stories = $stdb->getStories();
if ($stories && count($stories) > 0) {
    foreach ($stories as $story) {
        $stdb->deleteStory($story['id']);
    }
}
// Delete all widgets
$wdb = new Widgets();
$widgets = $wdb->getWidgets();
if ($widgets && count($widgets) > 0) {
    foreach ($widgets as $widget) {
        $wdb->deleteWidget($widget['id']);
    }
}
// Delete all properties
$up = new Properties(array(Properties::KEY => $user->id));