Beispiel #1
0
 public function init()
 {
     parent::init();
     if ($this->_superior = SiteModule::findOne(['site_id' => $this->siteId, 'type' => SiteModule::TYPE_MENU, 'position' => $this->position, 'status' => SiteModule::STATUS_ENABLED])) {
         $this->items = $this->_superior->getItems()->where(['site_id' => $this->siteId, 'status' => SiteModuleItem::STATUS_ENABLED])->orderby('list_order desc, created_at')->all();
     }
 }
Beispiel #2
0
 public function init()
 {
     parent::init();
     if ($this->_superior = SiteModule::findOne(['site_id' => $this->siteId, 'type' => SiteModule::TYPE_BANNER, 'position' => $this->position, 'status' => SiteModule::STATUS_ENABLED])) {
         $this->items = $this->_superior->getItems()->where(['site_id' => $this->siteId, 'status' => SiteModuleItem::STATUS_ENABLED])->orderby('list_order desc, created_at')->all();
     }
     if ($this->items && $this->carousel) {
         $this->options['id'] = $this->randomId;
         $this->view->registerJs("\$('#{$this->randomId}').carousel();", 3);
     }
 }
 public function actionDelete()
 {
     $item = SiteModule::findOne(['id' => \Yii::$app->request->post('id', 0), 'site_id' => $this->module->siteId]);
     $done = $item && $item->delete();
     return \Yii::$app->request->isAjax ? $this->respond(['error' => !$done, 'message' => \Yii::t($this->module->messageCategory, 'operation ' . ($done ? 'succeeded' : 'failed')) . ($done ? '' : ', ' . \Yii::t($this->module->messageCategory, 'please try again'))]) : $this->goBack();
 }
Beispiel #4
0
 public function actionEdit($id = 0)
 {
     if (!$id) {
         $item = new SiteModule();
         $item->scenario = 'add';
         $item->site_id = $this->module->siteId;
         $item->type = SiteModule::TYPE_MENU;
     } else {
         $item = SiteModule::findOne(['id' => $id, 'site_id' => $this->module->siteId, 'type' => SiteModule::TYPE_MENU]);
         if (!$item) {
             throw new NotFoundHttpException(\Yii::t($this->module->messageCategory, 'no matched data'));
         }
         $item->scenario = 'edit';
     }
     if (\Yii::$app->request->isPost && $item->load(\Yii::$app->request->post())) {
         if ($item->commonHandler()) {
             \Yii::$app->session->setFlash('item', '0|' . \Yii::t($this->module->messageCategory, 'operation succeeded'));
             return $this->redirect(['menu/list']);
         }
         \Yii::$app->session->setFlash('item', '1|' . $item->firstErrorInfirstErrors);
     }
     return $this->render($this->action->id, ['item' => $item]);
 }