Esempio n. 1
0
 public function bootstrap($app)
 {
     Hook::on(\hass\menu\Module::EVENT_MENU_MODULE_LINKS, [$this, "onMenuConfig"]);
     Hook::on(new MenuCreateHook());
     Hook::on(new \hass\taxonomy\hooks\EntityUrlPrefix());
     Hook::on(\hass\system\Module::EVENT_SYSTEM_GROUPNAV, [$this, "onSetGroupNav"]);
 }
Esempio n. 2
0
 public function bootstrap($app)
 {
     Hook::on(\hass\system\Module::EVENT_SYSTEM_GROUPNAV, [$this, "onSetGroupNav"]);
     Hook::on(\hass\backend\Module::EVENT_ADMIN_THEME, function ($event) {
         $event->parameters->set(\hass\backend\Module::EVENT_ADMIN_THEME, \Yii::$app->get('config')->get("app.backendTheme"));
     });
 }
Esempio n. 3
0
 public function getTheme()
 {
     /**
      *
      * @var $parameters \hass\base\classes\Parameters
      */
     $parameters = Hook::trigger(static::EVENT_ADMIN_THEME)->parameters;
     return $parameters->get(static::EVENT_ADMIN_THEME, $this->theme);
 }
Esempio n. 4
0
 public function init()
 {
     parent::init();
     /** @var \hass\base\classes\Parameters $parameters */
     $parameters = Hook::trigger(Module::EVENT_SEARCH_CONFIG)->parameters;
     $this->indexs = [];
     foreach ($parameters as $index => $parameter) {
         $this->indexs[$index] = \Yii::getAlias($parameter["xunsearch"]);
     }
 }
Esempio n. 5
0
 public function initCoreHooks()
 {
     Hook::on(new \hass\menu\hooks\MenuCreateHook());
     Hook::on(new \hass\page\hooks\MenuCreateHook());
     Hook::on(new \hass\taxonomy\hooks\MenuCreateHook());
     Hook::on(new \hass\taxonomy\hooks\EntityUrlPrefix());
     Hook::on(new \hass\user\hooks\EntityUrlPrefix());
     Hook::on(new \hass\post\hooks\SearchModel());
     Hook::on(new \hass\page\hooks\SearchModel());
 }
Esempio n. 6
0
 public function bootstrap($app)
 {
     /**
      *
      * @var $boot \dektrium\user\Bootstrap
      */
     $boot = \Yii::createObject('\\dektrium\\user\\Bootstrap');
     $boot->bootstrap(\Yii::$app);
     Hook::on(\hass\system\Module::EVENT_SYSTEM_GROUPNAV, [$this, "onSetGroupNav"]);
     Hook::on(new \hass\user\hooks\EntityUrlPrefix());
 }
Esempio n. 7
0
 public function bootstrap($app)
 {
     Hook::on(\hass\system\Module::EVENT_SYSTEM_GROUPNAV, [$this, "onSetGroupNav"]);
     //         Util::setComponent("search", [
     //             "class"=>"\\hass\\search\\components\\Search"
     //         ]);
     //            Util::setComponent("sphinx", [
     //                'class' => 'yii\sphinx\Connection',
     //                'dsn' => 'mysql:host=127.0.0.1;port=9306;',
     //                'username' => '',
     //                'password' => '',
     //            ]);
 }
Esempio n. 8
0
 protected function getHookPermissions()
 {
     if ($this->_hookPermissions != null) {
         return $this->_hookPermissions;
     }
     $parameters = Hook::trigger(\hass\rbac\Module::EVENT_RBAC_PERMISSION)->parameters;
     foreach ($parameters as $config) {
         foreach ($config['permissions'] as $name => $item) {
             $class = $item['type'] == Item::TYPE_PERMISSION ? Permission::className() : Role::className();
             $this->_hookPermissions[$name] = new $class(['name' => $name, 'description' => isset($item['description']) ? $item['description'] : null, 'ruleName' => isset($item['ruleName']) ? $item['ruleName'] : null, 'data' => isset($item['data']) ? $item['data'] : null, 'createdAt' => null, 'updatedAt' => null]);
         }
     }
     return $this->_hookPermissions;
 }
 public function init()
 {
     parent::init();
     if ($this->slug == null) {
         throw new InvalidConfigException("slug不能为空");
     }
     $this->currentAbsoluteUrl = \Yii::$app->getRequest()->getAbsoluteUrl();
     $collection = Menu::findBySlug($this->slug);
     $createCallbacks = Hook::trigger(\hass\menu\Module::EVENT_MENU_LINK_CREATE)->parameters;
     $this->items = NestedSetsTree::generateTree($collection, function ($item) use($createCallbacks) {
         list($item['label'], $item["url"]) = call_user_func($createCallbacks[$item['module']], $item['name'], $item['original']);
         $item["options"] = Serializer::unserializeToArray($item["options"]);
         return $item;
     }, 'items');
 }
Esempio n. 10
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)]);
 }
Esempio n. 11
0
 /**
  *
  * @param \yii\base\ActionEvent $event            
  */
 public function onSetLeftNav($event)
 {
     $group = \Yii::$app->getRequest()->get("menu-group", null);
     if ($group == null) {
         return \Yii::$app->getResponse()->redirect(Url::to(["/{$this->id}/default/controlpanel", "menu-group" => ModuleGroupEnmu::SYSTEM]));
     } else {
         $parameters = Hook::trigger(static::EVENT_SYSTEM_GROUPNAV)->parameters;
         $navs = $parameters->get($group, []);
         $groupParams = ["menu-group" => $group];
         // 根据控制器重定向导航第一个页面
         if (\Yii::$app->controller->getRoute() == ltrim(\Yii::$app->defaultRoute, "/")) {
             $nav = Util::getFirstNav($navs);
             if ($nav) {
                 return \Yii::$app->getResponse()->redirect(Url::to(array_merge($nav["url"], $groupParams)));
             }
         }
         Hook::on(\hass\backend\Module::EVENT_ADMIN_LEFTNAV, function ($event) use($navs) {
             $event->parameters->fromArray($navs);
         });
     }
 }
Esempio n. 12
0
 public function bootstrap($app)
 {
     Hook::on(\hass\system\Module::EVENT_SYSTEM_GROUPNAV, [$this, "onSetGroupNav"]);
     Hook::on(\hass\area\Module::EVENT_BLOCK_TYPE, [$this, "onBlockModule"]);
 }
Esempio n. 13
0
 public function bootstrap($app)
 {
     Hook::on(\hass\system\Module::EVENT_SYSTEM_GROUPNAV, [$this, "onSetGroupNav"]);
     Util::setComponent("authManager", ["class" => "\\hass\\rbac\\components\\DbManager"]);
     Hook::on(new \hass\rbac\hooks\Permission());
 }
Esempio n. 14
0
 public function bootstrap($app)
 {
     Hook::on(new \hass\post\hooks\EntityUrlPrefix());
     Hook::on(\hass\system\Module::EVENT_SYSTEM_GROUPNAV, [$this, "onSetGroupNav"]);
 }
Esempio n. 15
0
 /**
  *
  * @param unknown $item
  * @param unknown $module
  */
 protected function ensureNode($item, $module)
 {
     $createCallbacks = Hook::trigger(\hass\menu\Module::EVENT_MENU_LINK_CREATE)->parameters;
     list($name, $url) = call_user_func($createCallbacks[$module], $item['name'], $item['original']);
     $parameters = Hook::trigger(\hass\menu\Module::EVENT_MENU_MODULE_LINKS)->parameters;
     $item["name"] = $name;
     $item['originalName'] = $item["name"];
     $item['title'] = "";
     $item["module"] = $module;
     $item["children"] = [];
     $item["url"] = $this->createUrl($url);
     $item["moduleName"] = $parameters[$module]["name"];
     return $item;
 }
Esempio n. 16
0
 public static function getBlockHook($type)
 {
     $parameters = Hook::trigger(\hass\area\Module::EVENT_BLOCK_TYPE)->parameters;
     $hook = $parameters[$type];
     return [$hook["nav"]["label"], $hook["model"], $hook["view"], $hook["widget"]];
 }
 public function bootstrap($app)
 {
     Hook::on(\hass\system\Module::EVENT_SYSTEM_GROUPNAV, [$this, "onSetGroupNav"]);
 }
Esempio n. 18
0
 public static function getEntityPrefix($model)
 {
     $parameters = Hook::trigger(\hass\urlrule\Module::EVENT_URLRULE_PREFIX_ENTITY)->parameters;
     $alias = null;
     foreach ($parameters as $class => $prefix) {
         if ($model instanceof $class) {
             $alias = $prefix;
             break;
         }
     }
     if ($alias == null) {
         $alias = strtolower(StringHelper::basename(get_class($model)));
     }
     return $alias;
 }
Esempio n. 19
0
 public function bootstrap($app)
 {
     Hook::on(\hass\system\Module::EVENT_SYSTEM_GROUPNAV, [$this, "onSetGroupNav"]);
     \Yii::$app->controllerMap = ArrayHelper::merge(\Yii::$app->controllerMap, ["revolutionslider" => 'hass\\revolutionslider\\controllers\\RevolutionsliderController']);
 }