public function actionJump($id) { $item = SiteModuleItem::findOne(['id' => $id, 'site_id' => $this->module->siteId, 'status' => SiteModuleItem::STATUS_ENABLED]); if (!$item || $item->superior->status != SiteModule::STATUS_ENABLED) { throw new NotFoundHttpException(\Yii::t($this->module->messageCategory, 'no matched data')); } return $this->redirect($item->accessed($this->module->statisticsEnable)->link); }
public function actionJump($id) { $item = SiteModuleItem::findOne(['id' => $id, 'site_id' => $this->module->siteId]); if (!$item) { throw new NotFoundHttpException(\Yii::t($this->module->messageCategory, 'no matched data')); } return $this->redirect($item->getLink($this->module->frontendUrl)); }
public function actionItemDelete() { $item = SiteModuleItem::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(); }
public function actionItems($mid, $type = 'all', $stype = null, $sword = null) { if (\Yii::$app->request->isPost) { $scenario = \Yii::$app->request->post('scenario'); $items = \Yii::$app->request->post('items'); if ($scenario && $items) { foreach ($items as $id => $attributes) { if (($item = SiteModuleItem::findOne($id)) && $attributes) { $item->scenario = $scenario; foreach ($attributes as $attribute => $value) { $item->{$attribute} = $value; } $item->commonHandler(); } } } return $this->refresh(); } $superior = SiteModule::findOne(['id' => $mid, 'site_id' => $this->module->siteId, 'type' => SiteModule::TYPE_MENU]); if (!$superior) { throw new NotFoundHttpException(\Yii::t($this->module->messageCategory, 'no matched data')); } if ($type !== 'all') { $query->andWhere(['type' => $type]); } $query = SiteModuleItem::find()->where(['site_id' => $this->module->siteId, 'module_id' => $mid])->orderby('list_order desc, created_at'); if ($sword !== null) { $query->andWhere(['like', "{$stype}", $sword]); } $pagination = new Pagination(['totalCount' => $query->count()]); $items = $query->offset($pagination->offset)->limit($pagination->limit)->all(); $typeItems = ArrayHelper::merge(['all' => \Yii::t($this->module->messageCategory, '{attribute} {action}', ['attribute' => \Yii::t($this->module->messageCategory, 'type'), 'action' => \Yii::t($this->module->messageCategory, 'filtering')])], SiteModuleItem::defaultAttributeItems('type')); return $this->render($this->action->id, ['type' => $type, 'stype' => $stype, 'sword' => $sword, 'superior' => $superior, 'items' => $items, 'pagination' => $pagination, 'typeItems' => $typeItems]); }
/** * Get items belongs it * * @since 0.0.1 * @return {array} */ public function getItems() { return $this->hasMany(SiteModuleItem::classname(), ['module_id' => 'id']); }