/** * test max position * feeds has wrong positions by setUp */ public function testSort() { $categoryModel = new application_models_categories(); $this->model->sort($categoryModel->find('2')->current(), array('2', '1')); $this->assertEquals(1, $this->model->find('1')->count()); $this->assertEquals(1, $this->model->find('2')->count()); $this->assertEquals(1, $this->model->find('3')->count()); $this->assertEquals('0', $this->model->find('2')->current()->position); // correct position $this->assertEquals('2', $this->model->find('2')->current()->category); // corrent category $this->assertEquals('1', $this->model->find('1')->current()->position); // correct position $this->assertEquals('2', $this->model->find('1')->current()->category); // corrent category $this->assertEquals('0', $this->model->find('3')->current()->position); // correct position $this->assertEquals('1', $this->model->find('3')->current()->category); // corrent category }
/** * save new order of feeds (sortable) * * @return void */ public function sortAction() { // get new category $category = $this->getRequest()->getParam('cat'); if (strlen($category) > 4) { $category = substr($category, 4); } // load category $categoriesModel = new application_models_categories(); $category = $categoriesModel->find($category); // no category found: abort if ($category->count() == 0) { return; } // get feeds in new order $feeds = $this->getRequest()->getParam('feed'); // save new order $feedsModel = new application_models_feeds(); $categories = $feedsModel->sort($category->current(), $feeds); // send new unread items $unread = Zend_Controller_Action_HelperBroker::getStaticHelper('itemcounter')->unreadItemsCategories(); $this->_helper->json($unread); }