Example #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();
     }
 }
Example #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);
     }
 }
Example #3
0
 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();
 }
Example #4
0
 public function actionList($stype = null, $sword = null)
 {
     $query = SiteModule::find()->where(['site_id' => $this->module->siteId, 'type' => SiteModule::TYPE_MENU])->orderby('created_at desc');
     if ($sword !== null) {
         $query->andWhere(['like', "{$stype}", $sword]);
     }
     $pagination = new Pagination(['totalCount' => $query->count()]);
     $items = $query->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render($this->action->id, ['stype' => $stype, 'sword' => $sword, 'items' => $items, 'pagination' => $pagination]);
 }
Example #5
0
 /**
  * Get sub module belongs it
  *
  * @since 0.0.1
  * @return {object}
  */
 public function getSubModule()
 {
     return $this->hasOne(SiteModule::classname(), ['id' => 'sub_module_id']);
 }