コード例 #1
0
 /**
  * test counting feeds
  */
 public function testCount()
 {
     $this->assertEquals(3, $this->model->count(1, 2));
     $this->assertEquals(2, $this->model->count(1, 2, 'multimedia'));
     $this->assertEquals(1, $this->model->count(1, 2, 'messages'));
     $this->assertEquals(1, $this->model->count(1, 1));
     $this->assertEquals(2, $this->model->count(2, 2));
 }
コード例 #2
0
 /**
  * shows a list of items
  * will be called on every change of settings and
  * returns the messages and images
  *
  * @return void
  */
 public function listAction()
 {
     $isJson = $this->getRequest()->getParam('json', false);
     // load current settings
     $settingsModel = new application_models_settings();
     $currentSettings = array();
     foreach ($settingsModel->fetchAll() as $setting) {
         $currentSettings[$setting->name] = $setting->value;
     }
     // read settings
     $settings = $this->getRequest()->getPost();
     $settings = array_merge($currentSettings, $settings);
     // get list template vars
     $listHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('list');
     try {
         $listHelper->readItems($settings);
         $listHelper->setTemplateVars($this->view);
     } catch (Exception $e) {
         $this->_helper->json(array('error' => $e->getMessage()));
     }
     // save settings
     if (Zend_Registry::get('config')->demomode != "1" && Zend_Registry::get('session')->authenticated === true) {
         $settingsModel->save(array('currentPriorityStart' => $settings['currentPriorityStart'], 'currentPriorityEnd' => $settings['currentPriorityEnd'], 'view' => $settings['view'], 'selected' => $settings['selected'], 'unread' => $settings['unread'], 'starred' => $settings['starred'], 'sort' => $settings['sort']));
     }
     // get unread items
     $itemCounter = Zend_Controller_Action_HelperBroker::getStaticHelper('itemcounter');
     // return items
     $feedModel = new application_models_feeds();
     $result = array('html' => utf8_encode(utf8_decode($this->view->render('item/list.' . Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->getViewSuffix()))), 'categories' => $itemCounter->unreadItemsCategories($settings), 'feeds' => $itemCounter->unreadItemsFeeds($settings), 'starred' => $itemCounter->starredItems($settings), 'all' => $itemCounter->allItems($settings), 'countfeeds' => $feedModel->count(Zend_Registry::get('session')->currentPriorityStart, Zend_Registry::get('session')->currentPriorityEnd, Zend_Registry::get('session')->view));
     if ($isJson == true) {
         unset($result['html']);
         $result['messages'] = $listHelper->getMessages();
         $result['moremessages'] = $listHelper->hasMoreMessages();
         $result['multimedia'] = $listHelper->getMultimedia();
         $result['moremultimedia'] = $listHelper->hasMoreMultimedia();
     }
     $this->_helper->json($result);
 }
コード例 #3
0
 /**
  * set feedlist data for the current view
  *
  * @return void
  */
 protected function feedlistData()
 {
     // check whether uncategorized exists or not (add it if not)
     $categoriesModel = new application_models_categories();
     $categoriesModel->checkUncategorized();
     // categories and feeds (target template param)
     $this->view->categories = array();
     // load unread items
     $itemCounter = Zend_Controller_Action_HelperBroker::getStaticHelper('itemcounter');
     $unreadCategory = $itemCounter->unreadItemsCategories();
     $unreadFeed = $itemCounter->unreadItemsFeeds();
     // get open categories
     if (Zend_Registry::get('session')->saveOpenCategories == 1) {
         $open = explode(',', Zend_Registry::get('session')->openCategories);
     } else {
         $open = array();
     }
     // load categories
     $categoriesDb = $categoriesModel->fetchAll($categoriesModel->select()->order('position ASC'));
     $feedPositions = Zend_Controller_Action_HelperBroker::getStaticHelper('icon')->getFeedsIconPosition();
     // read feeds and count items of the loaded categories
     $feedsModel = new application_models_feeds();
     foreach ($categoriesDb as $cat) {
         $newcat = $cat->toArray();
         // get feeds of cat
         $feedRowset = $cat->findDependentRowset('application_models_feeds', null, $feedsModel->select()->order('position ASC'));
         $newcat['feeds'] = array();
         foreach ($feedRowset as $feed) {
             $newfeed = $feed->toArray();
             $newfeed['unread'] = isset($unreadFeed[$feed->id]) ? $unreadFeed[$feed->id] : 0;
             $newfeed['iconposition'] = $feedPositions[$feed->id];
             $newcat['feeds'][] = $newfeed;
         }
         // get unread items of cat
         $newcat['unread'] = isset($unreadCategory[$cat->id]) ? $unreadCategory[$cat->id] : 0;
         // set open (feeds visible) or not
         if (in_array($cat->id, $open)) {
             $newcat['open'] = true;
         } else {
             $newcat['open'] = false;
         }
         // append category
         $this->view->categories[] = $newcat;
     }
     // count starred items
     $this->view->starred = $itemCounter->starredItems();
     // count unread items
     $this->view->unread = $unreadCategory[0];
     // count all items
     $this->view->all = $itemCounter->allItems();
     // count read items
     $this->view->read = $this->view->all - $this->view->unread;
     // count feeds
     $this->view->amountfeeds = $feedsModel->count(Zend_Registry::get('session')->currentPriorityStart, Zend_Registry::get('session')->currentPriorityEnd, Zend_Registry::get('session')->view);
 }
コード例 #4
0
 /**
  * delete feed
  *
  * @return void
  */
 public function deleteAction()
 {
     // get id
     $id = $this->getRequest()->getParam('id');
     // delete feed
     $feedModel = new application_models_feeds();
     $result = $feedModel->remove($id);
     // return unread items or error
     $return = array();
     if ($result === true) {
         // renew iconcache
         Zend_Controller_Action_HelperBroker::getStaticHelper('icon')->resetIconImage();
         // count unread items per category
         $return['categories'] = Zend_Controller_Action_HelperBroker::getStaticHelper('itemcounter')->unreadItemsCategories();
         // count all feeds
         $return['feeds'] = $feedModel->count(Zend_Registry::get('session')->currentPriorityStart, Zend_Registry::get('session')->currentPriorityEnd, Zend_Registry::get('session')->view);
         // count all items
         $return['all'] = Zend_Controller_Action_HelperBroker::getStaticHelper('itemcounter')->allItems();
         // new settings (priority)
         $return['settings'] = $this->resetPriorities();
     } else {
         $return['error'] = $result;
     }
     // send result
     $this->_helper->json($return);
 }