public function attachTo(Model_Article $article) { $this->article = $article->getId(); }
public function actionReorder($params) { $view = $this->ajaxView('article'); $view->state = 'failed'; if ($params['id'] && $params['targid']) { $oarticle = new Model_Article($this->getStorage(), $params['id']); $tarticle = new Model_Article($this->getStorage(), $params['targid']); $view->id = $oarticle->getId(); $view->target_id = $tarticle->getId(); if ($oarticle->isLoaded() && $tarticle->isLoaded()) { $this->canPerform($oarticle, 'edit'); $view->state = 'reordered'; $view->place = $params['place']; switch ($params['place']) { case 'before': $method = 'insertBefore'; break; case 'after': $method = 'insertAfter'; break; default: if ($oarticle->isBefore($tarticle)) { $method = 'insertAfter'; $view->place = 'after'; } else { $method = 'insertBefore'; $view->place = 'before'; } } try { $oarticle->{$method}($tarticle); } catch (Exception $e) { $view->state = 'failed'; $view->error = $e->getMessage(); } } else { $view->error = 'Article(s) not found.'; } } else { $view->error = 'Article IDs are not set.'; } return $view; }