Ejemplo n.º 1
0
 protected function launch()
 {
     if ($cache = $this->ensureCache()) {
         if ((list($items, $prevModel, $nextModel) = $cache->get([__CLASS__, $this->rootPage->id, $this->page->id])) === false) {
             list($items, $prevModel, $nextModel) = $this->getViewData();
             $cache->set([__CLASS__, $this->rootPage->id, $this->page->id], [$items, $prevModel, $nextModel], $this->cacheDuration, $this->cacheDependency ? $this->cacheDependency : DbState::dependency(Page::tableName()));
         }
     } else {
         list($items, $prevModel, $nextModel) = $this->getViewData();
     }
     echo $this->render($this->layout, ['model' => $this->page, 'rootModel' => $this->rootPage, 'items' => $items, 'prevModel' => $prevModel, 'nextModel' => $nextModel]);
 }
 /**
  * @return Response
  */
 public function actionOrdering()
 {
     $data = Yii::$app->request->getBodyParam('data', []);
     foreach ($data as $id => $order) {
         if ($target = Page::findOne($id)) {
             $target->updateAttributes(['ordering' => intval($order)]);
         }
     }
     Page::find()->roots()->one()->reorderNode('ordering');
     DbState::updateState(Page::tableName());
     return $this->redirect(ArrayHelper::getValue(Yii::$app->request, 'referrer', ['index']));
 }