Esempio n. 1
0
 public function indexAction()
 {
     // Get, check and setup the parameters
     if (!($widget_id = $this->getRequest()->getParam("id"))) {
         throw new Stuffpress_Exception("No widget id provided to the widget controller");
     }
     // Verify if the requested widget exist and get its data
     $widgets = new Widgets();
     if (!($widget = $widgets->getWidget($widget_id))) {
         throw new Stuffpress_Exception("Invalid widget id");
     }
     // Get the widget properties
     $properties = new WidgetsProperties(array(Properties::KEY => $widget_id));
     $title = $properties->getProperty('title');
     $this->view->title = $title ? $title : "Tag cloud";
     // Get the archives
     $db_tags = new Tags(array(Stuffpress_Db_Table::USER => $widget['user_id']));
     if ($tags = $db_tags->getTopTags(20)) {
         $max = $tags[0]['count'];
         $min = $tags[count($tags) - 1]['count'];
         sort($tags);
         $this->view->tags = $tags;
         $this->view->max = $max;
         $this->view->min = $min;
     }
 }
 public function indexAction()
 {
     // Get, check and setup the parameters
     if (!($widget_id = $this->getRequest()->getParam("id"))) {
         throw new Stuffpress_Exception("No widget id provided to the widget controller");
     }
     // Verify if the requested widget exist and get its data
     $widgets = new Widgets();
     if (!($widget = $widgets->getWidget($widget_id))) {
         throw new Stuffpress_Exception("Invalid widget id");
     }
     // Get the last comments
     $comments = new Comments(array(Stuffpress_Db_Table::USER => $widget['user_id']));
     $mycomments = $comments->getLastComments();
     $data = new Data();
     // Prepare the comments for output
     foreach ($mycomments as &$comment) {
         $time = strtotime($comment['timestamp']);
         $item = $data->getItem($comment['source_id'], $comment['item_id']);
         $comment['item'] = $item;
         $comment['when'] = Stuffpress_Date::ago($time, "j M y");
         $comment['comment'] = str_replace("\n", " ", $comment['comment']);
         if (strlen($comment['comment']) > 50) {
             $comment['comment'] = mb_substr($comment['comment'], 0, 47) . "...";
         }
     }
     // Get the widget properties
     $properties = new WidgetsProperties(array(Properties::KEY => $widget_id));
     $title = $properties->getProperty('title');
     $this->view->title = $title ? $title : "Latest comments";
     // Prepare the view for rendering
     $this->view->comments = $mycomments;
 }
Esempio n. 3
0
 public function indexAction()
 {
     // Get, check and setup the parameters
     if (!($widget_id = $this->getRequest()->getParam("id"))) {
         throw new Stuffpress_Exception("No widget id provided to the widget controller");
     }
     // Verify if the requested widget exist and get its data
     $widgets = new Widgets();
     if (!($widget = $widgets->getWidget($widget_id))) {
         throw new Stuffpress_Exception("Invalid widget id");
     }
     // Get the user
     $users = new Users();
     $user = $users->getUser($widget['user_id']);
     // Get all sources configured for that user
     $properties = new Properties(array(Properties::KEY => $user->id));
     // Get the bio data
     // User profile
     $this->view->username = $user->username;
     $this->view->first_name = $properties->getProperty('first_name');
     $this->view->last_name = $properties->getProperty('last_name');
     $this->view->bio = $properties->getProperty('bio');
     $this->view->location = $properties->getProperty('location');
     $this->view->avatar = $properties->getProperty('avatar_image');
     // Get the widget properties
     $properties = new WidgetsProperties(array(Properties::KEY => $widget_id));
     $title = $properties->getProperty('title');
     $this->view->title = $title ? $title : "About {$user->username}";
 }
Esempio n. 4
0
 public function indexAction()
 {
     // Get, check and setup the parameters
     if (!($widget_id = $this->getRequest()->getParam("id"))) {
         throw new Stuffpress_Exception("No widget id provided to the widget controller");
     }
     // Verify if the requested widget exist and get its data
     $widgets = new Widgets();
     if (!($widget = $widgets->getWidget($widget_id))) {
         throw new Stuffpress_Exception("Invalid widget id");
     }
     // Get the widget properties
     $properties = new WidgetsProperties(array(Properties::KEY => $widget_id));
     $title = $properties->getProperty('title');
     $this->view->title = $title ? $title : "Powered by";
 }
Esempio n. 5
0
 public function deleteAction()
 {
     // Get, check and setup the parameters
     $widget_id = $this->getRequest()->getParam("id");
     // Do we own the widget ?
     $widgets = new Widgets();
     if (!($widget = $widgets->getWidget($widget_id))) {
         throw new Stuffpress_Exception("Unknown widget with id {$widget_id}");
     }
     if ($widget['user_id'] != $this->_application->user->id) {
         throw new Stuffpress_AccessDeniedException("Not the owner of widget {$widget_id}");
     }
     $widgets->deleteWidget($widget_id);
     // Delete the widget properties
     $properties = new WidgetsProperties(array(Properties::KEY => $widget_id));
     $properties->deleteAllProperties();
     return $this->_helper->json->sendJson(false);
 }
Esempio n. 6
0
 public function indexAction()
 {
     // Get, check and setup the parameters
     if (!($widget_id = $this->getRequest()->getParam("id"))) {
         throw new Stuffpress_Exception("No widget id provided to the widget controller");
     }
     // Verify if the requested widget exist and get its data
     $widgets = new Widgets();
     if (!($widget = $widgets->getWidget($widget_id))) {
         throw new Stuffpress_Exception("Invalid widget id");
     }
     // Get all sources configured for that user
     $sources = new Sources(array(Stuffpress_Db_Table::USER => $widget['user_id']));
     $mysources = $sources->getSources();
     // If sources are configured, get the links for each source
     $links = array();
     if ($mysources) {
         foreach ($mysources as $source) {
             if (!($source['public'] && $source['enabled'])) {
                 continue;
             }
             if ($source['service'] == 'stuffpress') {
                 continue;
             }
             $model = SourceModel::newInstance($source['service']);
             $model->setSource($source);
             $link['prefix'] = $model->getServicePrefix();
             $link['url'] = $model->getServiceURL();
             $link['name'] = $model->getTitle();
             $links[] = $link;
         }
     }
     // Get the widget properties
     $properties = new WidgetsProperties(array(Properties::KEY => $widget_id));
     $title = $properties->getProperty('title');
     $this->view->title = $title ? $title : "My 2.0 Life";
     // Prepare the view for rendering
     $this->view->links = $links;
 }
Esempio n. 7
0
 public function submitAction()
 {
     if (!$this->getRequest()->isPost()) {
         return $this->_helper->json->sendJson(true);
     }
     $form = $this->getForm();
     if (!$form->isValid($_POST)) {
         return $this->_helper->json->sendJson($form->getErrorArray());
     }
     // Get the values and proceed
     $values = $form->getValues();
     $title = $values['title'];
     $id = $values['id'];
     // Get the user
     $application = Stuffpress_Application::getInstance();
     // Get the widget properties
     $properties = new WidgetsProperties(array(Properties::KEY => $id, Properties::USER => $application->user->id));
     // Save the new properties
     $properties->setProperty('title', $title);
     // Ok send the result
     return $this->_helper->json->sendJson(false);
 }
 public function indexAction()
 {
     // Get, check and setup the parameters
     if (!($widget_id = $this->getRequest()->getParam("id"))) {
         throw new Stuffpress_Exception("No widget id provided to the widget controller");
     }
     // Verify if the requested widget exist and get its data
     $widgets = new Widgets();
     if (!($widget = $widgets->getWidget($widget_id))) {
         throw new Stuffpress_Exception("Invalid widget id");
     }
     // Get the widget properties
     $properties = new WidgetsProperties(array(Properties::KEY => $widget_id));
     $title = $properties->getProperty('title');
     $this->view->title = $title ? $title : "Archives";
     // Get the archives
     $data = new Data(array(Stuffpress_Db_Table::USER => $widget['user_id']));
     $archives = $data->getItemsPerMonth();
     // Prepare the view for rendering
     $this->view->archives = $archives;
     // Add the required javascript
     $this->view->headScript()->appendFile('js/accordion/init.js');
 }
 public function indexAction()
 {
     // Get, check and setup the parameters
     if (!($widget_id = $this->getRequest()->getParam("id"))) {
         throw new Stuffpress_Exception("No widget id provided to the widget controller");
     }
     // Verify if the requested widget exist and get its data
     $widgets = new Widgets();
     if (!($widget = $widgets->getWidget($widget_id))) {
         throw new Stuffpress_Exception("Invalid widget id");
     }
     // Get the user
     $users = new Users();
     $user = $users->getUser($widget['user_id']);
     // Get all sources configured for that user
     $properties = new Properties(array(Properties::KEY => $user->id));
     // Get the friendconnect data
     $this->view->googlefc = $properties->getProperty('googlefc');
     // Get the widget properties
     $properties = new WidgetsProperties(array(Properties::KEY => $widget_id));
     $title = $properties->getProperty('title');
     $this->view->title = $title;
 }
Esempio n. 10
0
 public function indexAction()
 {
     // Get, check and setup the parameters
     if (!($widget_id = $this->getRequest()->getParam("id"))) {
         throw new Stuffpress_Exception("No widget id provided to the widget controller");
     }
     // Verify if the requested widget exist and get its data
     $widgets = new Widgets();
     if (!($widget = $widgets->getWidget($widget_id))) {
         throw new Stuffpress_Exception("Invalid widget id");
     }
     // Get the basename
     $host = trim(Zend_Registry::get("host"), '/');
     // Get the user
     $users = new Users();
     $user = $users->getUser($widget['user_id']);
     $username = $user->username;
     // Get the widget properties
     $properties = new WidgetsProperties(array(Properties::KEY => $widget_id));
     $title = $properties->getProperty('title');
     $this->view->title = $title ? $title : "Subscribe to my lifestream";
     // RSS Link
     $this->view->feed = "http://{$host}/rss/feed.xml";
 }
Esempio n. 11
0
$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));
$up->deleteAllProperties();
$wp = new WidgetsProperties(array(Properties::KEY => $user->id));
$wp->deleteAllProperties();
// Delete the user
$udb->deleteUser($user->id);
// Exit with proper message
die("User {$user->username} has been deleted.\r\n");
Esempio n. 12
0
 public function deleteWidget($id)
 {
     if (!($widget = $this->getWidget($id))) {
         return;
     }
     $where = $this->getAdapter()->quoteInto('id = ?', $id);
     $this->delete($where);
     $properties = new WidgetsProperties(array(Properties::KEY => $id));
     $properties->deleteAllProperties();
     $this->cacheRemove('Widgets_getWidgets_' . $this->_user);
 }