예제 #1
0
 public function getMetaData()
 {
     $model = $this->getMetaModel();
     $title = $model->title ?: $this->title;
     $description = $model->description ?: $this->short;
     $keywords = $model->keywords ?: implode(",", (array) ArrayHelper::getColumn($this->tags, "name"));
     return [$title, $description, $keywords];
 }
예제 #2
0
 public function actionRead($id)
 {
     $taxonomy = Taxonomy::findByIdOrSlug($id);
     $children = $taxonomy->children()->all();
     $ids = ArrayHelper::getColumn($children, "taxonomy_id");
     array_unshift($ids, $taxonomy->getPrimaryKey());
     $dataProvider = new ActiveDataProvider(['query' => TaxonomyIndex::find()->select(['entity', 'entity_id'])->distinct()->where(["taxonomy_id" => $ids])->orderBy(['taxonomy_index_id' => SORT_DESC]), 'pagination' => ['pageSize' => 15]]);
     list($title, $desc, $keys) = $taxonomy->getMetaData();
     $this->getView()->setMetaData($title, $desc, $keys);
     return $this->render('view', ['taxonomyIndexs' => $dataProvider->getModels(), "pagination" => $dataProvider->getPagination(), "taxonomy" => $taxonomy]);
 }
예제 #3
0
 /**
  * 1.获取所有模块配置的权限(前台模块...怎么办?)
  */
 public function actionPermissions($id)
 {
     $authManager = \Yii::$app->getAuthManager();
     if (\Yii::$app->getRequest()->getIsPost()) {
         $oldPermissions = ArrayHelper::getColumn($authManager->getChildren($id), "name");
         $postPermissions = array_keys(\Yii::$app->getRequest()->post("permissions", []));
         $newChildren = array_diff($postPermissions, $oldPermissions);
         $delChildren = array_diff($oldPermissions, $postPermissions);
         $parent = $authManager->getRole($id);
         //@hass-todo 这里最好是用sql使用批量删除和添加..但是为了兼容phpmanager
         foreach ($delChildren as $name) {
             $authManager->removeChild($parent, $authManager->createPermission($name));
         }
         foreach ($newChildren as $name) {
             $authManager->addChild($parent, $authManager->createPermission($name));
         }
         return $this->refresh();
     }
     $permissions = Hook::trigger(Module::EVENT_RBAC_PERMISSION)->parameters;
     return $this->render("permissions", ["permissions" => $permissions, "children" => $authManager->getChildren($id)]);
 }
 public function getRelatedIds()
 {
     $attachments = AttachmentIndex::find()->where(['entity' => $this->getEntityClass(), 'entity_id' => $this->getEntityId(), 'attribute' => $this->attribute])->all();
     return \hass\base\helpers\ArrayHelper::getColumn($attachments, 'attachment_id');
 }