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'); }
public function invokeHandler(RequestData $data) { $uid = $data->get("uid"); $stories = new Stories(); if ($uid != NULL && is_numeric($uid)) { return $stories->byUser($uid); } else { return null; } }
public function invokeHandler(RequestData $data, $search = "") { $order_by = $data->get("order_by", "updated"); $search_by = $data->get("search_by", "title"); $categories = $data->get("categories", array()); $language = $data->get("language", ""); $type = $data->get("type", ""); $stories = new Stories(); $stories->RELEVANCE = empty($search) ? 0 : 0.1; $stories->setCategories($categories); $stories->setClasses($type, $language); if ($search_by == 'title') { $stories_results = $stories->searchByTitle($search, 0, $order_by); } else { if ($search_by == 'text') { $stories_results = $stories->searchByText($search, 0, $order_by); } else { $stories_results = $stories->searchByAll($search, 0, $order_by); } } if (count($stories_results)) { // echo "REPLACE INTO search_cache(search_text) values(".$search.")"; $RDb = DBService::getDB(); $res = $RDb->update("REPLACE INTO search_cache(search_text) values('" . $search . "')"); } // print_r($stories->get(0)); return $stories_results; }
public function testGetContent() { $params = $this->getParams(); $_SERVER['HTTP_USER_AGENT'] = "google"; $obj = new Stories($params); $res = $obj->getContent(); $script_line = '<script> $BV.ui("su", "show_stories", { productId: "test" }); </script>'; $this->assertContains($script_line, $res); $params['include_display_integration_code'] = FALSE; $obj = new Stories($params); $res = $obj->getContent(); $script_line = '<script> $BV.ui("su", "show_stories", { productId: "test" }); </script>'; $this->assertNotContains($script_line, $res); }
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"); }
<?php require_once "inc/models/stories.php"; $storyArray = Stories::selectAll(); if (!isset($msgObject["msg"])) { $msgObject["msg"] = ''; } $again = false; $view = 'stories-show'; $_SESSION['activeTrail'] = 'objects';
public function viewAction() { // Get another layout $this->_helper->layout->setlayout('story'); // Get, check and setup the parameters $story_id = $this->getRequest()->getParam("id"); $page = $this->getRequest()->getParam("page"); $page = $page == '' ? 'cover' : $page; $mode = $this->getRequest()->getParam("mode"); $embed = $this->getRequest()->getParam("embed"); $length = 8; //Verify if the requested user exist $stories = new Stories(); $story = $stories->getStory($story_id); // If not, then return to the home page with an error if (!$story) { throw new Stuffpress_NotFoundException("Story {$story_id} does not exist"); } //Get the story owner data for user properties $users = new Users(); $user = $users->getUser($story->user_id); // Load the user properties $properties = new Properties(array(Stuffpress_Db_Properties::KEY => $user->id)); // Are we the owner ? if (!$embed && $this->_application->user && $this->_application->user->id == $story->user_id) { $owner = true; } else { $owner = false; } // If the page is private, go back with an error if (!$owner && $properties->getProperty('is_private')) { throw new Stuffpress_AccessDeniedException("This page has been set as private."); } // If the story is draft, go back with an error if (!$owner && $story->is_hidden) { throw new Stuffpress_AccessDeniedException("This story has not been published yet."); } // Are we in edit mode ? if ($owner && $mode == 'edit') { $edit = true; } else { $edit = false; } $data = new StoryItems(); $count = $data->getItemsCount($story_id, $edit); $pages = ceil($count / $length); // Now we can check if the page number is valid if ($page != 'cover') { if ($page < 0) { $page = 0; } else { if ($page >= $pages) { $page = $pages - 1; } } } // If page is not a cover, get the items if ($page != 'cover') { $this->view->items = $data->getItems($story_id, $length, $page * $length, $edit); } // Add the data required by the view $this->view->embed = $embed; $this->view->username = $user->username; $this->view->edit = $edit; $this->view->owner = $owner; $this->view->image = $story->thumbnail; $this->view->user_id = $user->id; $this->view->story_id = $story->id; $this->view->story_title = $story->title; $this->view->story_subtitle = $story->subtitle; $this->view->is_private = $story->is_hidden; $this->view->is_geo = $stories->isGeo($story_id); // Navigation options $this->view->page = $page; $this->view->pages = $pages; // Add a previous button $e = $embed ? "embed/{$embed}/" : ""; if ($page == 'cover') { unset($this->view->previous); } else { if ($page == 0) { $action = $edit ? "edit" : "view"; $this->view->previous = "story/{$action}/id/{$story_id}/page/cover/{$e}"; } else { if ($page != 'cover' && $page > 0) { $action = $edit ? "edit" : "view"; $this->view->previous = "story/{$action}/id/{$story_id}/page/" . ($page - 1) . "/{$e}"; } } } // Add a next button if ($page == 'cover') { $action = $edit ? "edit" : "view"; $this->view->next = "story/{$action}/id/{$story_id}/page/0/{$e}"; } else { if ($page + 1 < $pages) { $action = $edit ? "edit" : "view"; $this->view->next = "story/{$action}/id/{$story_id}/page/" . ($page + 1) . "/{$e}"; } } // Prepare the generic view // Set the timezone to the user timezone $timezone = $story->timezone ? $story->timezone : $properties->getProperty('timezone'); date_default_timezone_set($timezone); // User provided footer (e.g. tracker) $user_footer = $properties->getProperty('footer'); $this->view->user_footer = $user_footer; // Javascript $this->view->headScript()->appendFile('js/prototype/prototype.js'); $this->view->headScript()->appendFile('js/scriptaculous/scriptaculous.js'); $this->view->headScript()->appendFile('js/storytlr/validateForm.js'); $this->view->headScript()->appendFile('js/controllers/story.js'); // Page title $this->view->headTitle($story->title . " | " . $story->subtitle); // Change layout if embedding if ($embed) { $this->_helper->layout->setlayout('embed_story'); } // Page layout $this->view->title = $properties->getProperty('title'); $this->view->subtitle = $properties->getProperty('subtitle'); $this->view->footer = $properties->getProperty('footer'); $this->view->section = "story"; }
private function setKeyImage($story_id, $url) { $stories = new Stories(); $files = new Files(); $file_id = $files->downloadFile($url, ""); $files->fitSquare($file_id, 50, 'thumbnails'); $file = $files->getFile($file_id); $stories->setThumbnail($story_id, $file->key); }
require_once "inc/models/stories.php"; $action = 'story-edit-prepare'; $again = true; $path = ''; if (isset($_POST['abort'])) { $action = 'stories-show-prepare'; } else { if (isset($_POST['name']) && $_POST['name'] != '' && count($_POST['sequence']) > 0) { $id = $_POST['id']; $name = $_POST['name']; $description = $_POST['description']; $non_ordered_sequence = $_POST['sequence']; $new_sequence_object = array(); foreach ($non_ordered_sequence as $sequence) { $value_scanned = $sequence["scanned"]; // "0", "3", ... unset($sequence["scanned"]); if (array_key_exists($value_scanned, $new_sequence_object)) { array_push($new_sequence_object[$value_scanned], $sequence); } else { $new_sequence_object[$value_scanned] = array($sequence); } } $storyObject = new Stories($name, json_encode($new_sequence_object), $description); $storyObject->updateById($id); $action = 'stories-show-prepare'; } else { $action = 'stories-show-prepare'; } }
$sdb->deleteSource($source['id']); // 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
<?php require_once "inc/models/stories.php"; $action = 'stories-show-prepare'; $again = true; if (isset($_GET['id'])) { if ($_POST['yes']) { $id = $_GET['id']; Stories::deleteById($id); } }
public function storyAction() { $story_id = $this->getRequest()->getParam("id"); // Hit the cache $cache_id = "embed_story_{$story_id}"; if (!$this->_cache || !($script = $this->_cache->load($cache_id))) { //Verify if the requested user exist $stories = new Stories(); $story = $stories->getStory($story_id); // If not, then return to the home page with an error if (!$story) { throw new Stuffpress_NotFoundException("Story {$story_id} does not exist"); } // If the story is draft, go back with an error if ($story->is_hidden) { throw new Stuffpress_AccessDeniedException("This story has not been published yet."); } // Get the user properties $username = $this->_user->username; $host = $this->_config->web->host; // Get the data we need $id = $story->id; $uid = rand(0, 100) . $id; $title = $story->title; $sub = $story->subtitle; $image = $story->thumbnail; $script = "document.write('<link href=\\'http://{$host}/style/embed_story.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_embed\\' onclick=\\'showStory({$uid});\\' title=\\'Click to view story\\'>');\r\n" . "document.write('<div class=\\'logo\\'><img src=\\'http://{$host}/images/coverlogo.png\\' /></div>');\r\n" . "document.write('<div class=\\'cover\\'>');\r\n"; if ($image) { $script .= "document.write('<img src=\\'" . $this->getUrl($username, "/file/view/key/{$image}") . "\\' class=\\'cover\\'>');\r\n"; } $script .= "document.write('</div>');\r\n" . "document.write('<div class=\\'titles\\'>');\r\n" . "document.write('<span class=\\'title\\' id=\\'story_title\\'>" . $this->escape($title) . "</span>');\r\n" . "document.write('<span class=\\'subtitle\\' id=\\'story_subtitle\\'>" . $this->escape($sub) . "</span>');\r\n" . "document.write('</div>');\r\n" . "document.write('</div>');\r\n" . "document.write('<div class=\\'popoutwrapper\\'><div class=\\'popout\\'><a href=\\'" . $this->getUrl($username, "/story/view/id/{$id}") . "\\' target=\\'_blank\\' >View in new window <img src=\\'http://{$host}/images/popout.gif\\' /></a></div></div>');\r\n" . "document.write('<div class=\\'storytlr_mask\\' id=\\'storytlr_mask_{$uid}\\'>');\r\n" . "document.write('</div>');\r\n" . "document.write('<div class=\\'storytlr_container\\' id=\\'storytlr_container_{$uid}\\'>');\r\n" . "document.write('<div id=\\'storytlr_page\\'>');\r\n" . "document.write('<div id=\\'storytlr_control\\'>');\r\n" . "document.write('<a href=\\'javascript:hideStory({$uid});\\' title=\\'Close story\\'><img src=\\'http://{$host}/images/close.gif\\'/></a>');\r\n" . "document.write('</div>');\r\n" . "document.write('<iframe id=\\'storytlr_frame\\' src=\\'" . $this->getUrl($username, "/story/view/id/{$id}?embed=page") . "\\' width=\\'1050px\\' height=\\'620px\\' scrolling=\\'no\\' frameborder=\\'0\\'>Your browser doe snot support this. Check the lifestream here.</iframe>');\r\n" . "document.write('</div>');\r\n" . "document.write('</div>');\r\n"; if ($this->_cache) { $this->_cache->save($script, $cache_id, array("story_{$story_id}"), 300); } } header("Content-type: text/javascript"); header("Content-Disposition: attachment; filename=\"widget.js\""); echo $script; ob_end_flush(); die; }
<?php require_once "inc/models/stories.php"; if (isset($_GET['id'])) { $id = $_GET['id']; $story = Stories::selectById($id); } $again = false; $view = 'story-delete';
$my_user_id = $_SESSION['my_id']; $db = Database::obtain(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE); $db->connect(); $s = new Stories('member', BASE_DOMAIN, ''); $sl = $s->getStoryCreator($story_id); foreach ($sl as $s) { $to_email = $s['email']; $first_name = $s['first_name']; $creator_id = $s['master_id']; } if ($mode == 'share') { $to_email = $_REQUEST['email']; // echo "Share ".$to_email . "<br />"; } //send to db $se = new Stories('member', BASE_DOMAIN, ''); $se->sendEmail($to_email, $from, $message, $story_id, $sender_id, $creator_id, $from); if ($mode != 'share') { $se->updateClaim($story_id, '1', $sender_id); } //register as claimer in interest $mail = new PHPMailer(); // defaults to using php "mail()" $mail->IsSendmail(); // telling the class to use SendMail transport $body = "<body style=\"margin: 10px;\">\n<div style=\"width: 640px; font-family: Arial, Helvetica, sans-serif; font-size: 11px;\">\n<div align=\"center\"><img src=\"http://www.getpublicized.com/pg/img/p-story.png\" style=\"height: 90px; width: 90px\"></div><br>\n<br>\n" . $first_name . " Interest Email<br>\n<br>\n\n<br>\nthis person is interested in this story: \n<a href=\"" . $url . "\" >client story</a>\n<br />\nMessage:<br />\n<blockquote>" . $message . "</blockquote>\n</div>\n</body>\n"; $body = eregi_replace("[\\]", '', $body); $mail->AddReplyTo($from, ""); $mail->SetFrom($from, 'Get-P User'); $address = $to_email; $mail->AddAddress($address, "");
require_once "../models/games.php"; require_once "../models/game_sounds.php"; require_once "../models/stories.php"; require_once "../models/sounds.php"; $_POST['gameid'] = 1; if (isset($_GET['gameobjectid']) && $_GET['gameobjectid'] != '') { $gameObjectId = $_GET['gameobjectid']; $gameId = $_POST['gameid']; } else { $gameObjectId = 0; } $gameArray = Games::selectById($gameId); $currentPlayerId = $gameArray['current_player']; $currentStoryId = $gameArray['story_id']; $playersArray = Players::selectByGameId($gameId); $storyArray = Stories::selectById($currentStoryId); $storySequenceArray = json_decode($storyArray['sequence'], true); $soundArray = Sounds::selectAllOrderedById(); $modifyPlayerSituation = false; foreach ($playersArray as $key => $value) { $playersSituationArray[$key] = json_decode($value[situation], true); } echo "Current GameObjectId: {$gameObjectId}<br>"; echo "Current GameId: {$gameId}<br>"; echo "Current StoryId: {$currentStoryId}<br>"; echo "Current PlayerId: {$currentPlayerId}<br><br>"; echo "Dump PlayersArray:<br><br>"; var_dump($playersArray); echo "<br><br>Dump CurrentPlayerSituationArray:<br><br>"; var_dump($playersSituationArray[$currentPlayerId]); echo "<br><br>Dump CurrentPlayerSituationArray for GameObjectId:<br><br>";
public function index() { $stories = Stories::all(); return view('stories', ['stories' => $stories]); }
require_once "inc/models/stories.php"; $action = 'story-create-prepare'; $again = true; $path = ''; if (isset($_POST['abort'])) { $action = 'stories-show-prepare'; } else { if (isset($_POST['name']) && $_POST['name'] != '' && count($_POST['sequence']) > 0) { $name = $_POST['name']; $description = $_POST['description']; $non_ordered_sequence = $_POST['sequence']; $new_sequence_object = array(); foreach ($non_ordered_sequence as $sequence) { $value_scanned = $sequence["scanned"]; // "0", "3", ... unset($sequence["scanned"]); if (array_key_exists($value_scanned, $new_sequence_object)) { array_push($new_sequence_object[$value_scanned], $sequence); } else { $new_sequence_object[$value_scanned] = array($sequence); } } $storyObject = new Stories($name, json_encode($new_sequence_object), $description); $storyObject->insert(); $action = 'stories-show-prepare'; } else { $action = 'stories-show-prepare'; $msgObject = array("type" => "danger", "msg" => "Story konnte nicht angelegt werden."); } }