public function loadBootstrapModules($bootstrapType) { $modules = \hass\module\models\Module::findEnabledModules(); $regModules = \Yii::$app->getModules(); /** @var \hass\module\models\Module $model */ foreach ($modules as $model) { $model = (object) $model; $class = null; if (isset($regModules[$model->id])) { //是对象的话,说明绝对引导过了,配置高于程序中定义的 if (is_object($regModules[$model->id])) { continue; } // 如果有模块,而且模块的类存在,配置文件优先 if (isset($regModules[$model->id]['class'])) { $class = $regModules[$model->id]['class']; } } //模块类未设置的话 if ($class == null) { if (empty($model->class)) { continue; } Util::setModule($model->id, ['class' => $model->class]); } $bootstraps = explode("|", $model->bootstrap); if (in_array($bootstrapType, $bootstraps)) { /** @var \hass\module\BaseModule $module */ $module = \Yii::$app->getModule($model->id); if ($module instanceof BootstrapInterface) { $module->bootstrap(\Yii::$app); } } } }
public function loadBootstrapModules($bootstrapType) { $modules = \hass\module\models\Module::findEnabledModules(); /** @var \hass\module\models\Module $model */ foreach ($modules as $model) { $model = (object) $model; if (empty($model->class)) { continue; } // 如果有模块,而且模块的类存在则跳过,配置文件优先 if (\Yii::$app->hasModule($model->id)) { $modules = \Yii::$app->getModules(); if (is_object($modules[$model->id]) || isset($modules[$model->id]['class'])) { continue; } } Util::setModule($model->id, ['class' => $model->class]); $bootstraps = explode("|", $model->bootstrap); if (in_array($bootstrapType, $bootstraps)) { /** @var \hass\module\BaseModule $module */ $module = \Yii::$app->getModule($model->id); if ($module instanceof BootstrapInterface) { $module->bootstrap(\Yii::$app); } } } }
public function createLink($name, $original) { $model = Taxonomy::findOne($original); if (empty($name)) { $name = $model->name; } return [$name, Util::getEntityUrl($model)]; }
/** * @param $view * @param $model * @param array $params * @return string */ public function renderRead($view, $model, $params = []) { $prefix = Util::getEntityPrefix($model); $pathMap = [$prefix . "-" . $model->getPrimaryKey(), $view]; if ($model->hasAttribute("slug")) { array_unshift($pathMap, $prefix . "-" . $model->getAttribute("slug")); } $content = $this->getView()->renderRead($pathMap, $params, $this); return $this->renderContent($content); }
/** * Displays page where user can request new confirmation token. If resending was successful, displays message. * * @return string * @throws \yii\web\HttpException */ public function actionResend() { if ($this->module->enableConfirmation == false) { throw new NotFoundHttpException(); } /** @var ResendForm $model */ $model = Yii::createObject(ResendForm::className()); $event = $this->getFormEvent($model); $this->trigger(self::EVENT_BEFORE_RESEND, $event); $this->performAjaxValidation($model); if ($model->load(Yii::$app->request->post()) && $model->resend()) { $this->trigger(self::EVENT_AFTER_RESEND, $event); return $this->render('/loginEmail', ['title' => Yii::t('user', 'A new confirmation link has been sent'), 'module' => $this->module, "email" => $model->email, "emailFacilitator" => Util::getEmailLoginUrl($model->email)]); } return $this->render('resend', ['model' => $model]); }
/** * Shows page where user can request password recovery. * * @return string * @throws \yii\web\NotFoundHttpException */ public function actionRequest() { if (!$this->module->enablePasswordRecovery) { throw new NotFoundHttpException(); } /** @var RecoveryForm $model */ $model = Yii::createObject(['class' => RecoveryForm::className(), 'scenario' => 'request']); $event = $this->getFormEvent($model); $this->performAjaxValidation($model); $this->trigger(self::EVENT_BEFORE_REQUEST, $event); if ($model->load(Yii::$app->request->post()) && $model->sendRecoveryMessage()) { $this->trigger(self::EVENT_AFTER_REQUEST, $event); return $this->render('/loginEmail', ['title' => Yii::t('user', 'Recovery message sent'), 'module' => $this->module, "email" => $model->email, "emailFacilitator" => Util::getEmailLoginUrl($model->email)]); } return $this->render('request', ['model' => $model]); }
public function createLink($name, $original) { $appDefaultPage = Page::getAppDefaultPage(); if ($original == $appDefaultPage["id"]) { if (empty($name)) { $name = $appDefaultPage["title"]; } $urlManager = HASS_APP_BACKEND == true ? \Yii::$app->get("appUrlManager") : \Yii::$app->getUrlManager(); if ($urlManager->showScriptName) { $url = $urlManager->getScriptUrl(); } else { $url = $urlManager->getBaseUrl() . '/'; } return [$name, $url]; } $model = Page::findOne($original); if (empty($name)) { $name = $model->title; } return [$name, Util::getEntityUrl($model)]; }
/** * * @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); }); } }
<div class="time"> <i></i> <span><?php echo $model->getPublishedDate(); ?> </span> <span><?php echo $model->getPublishedTime(); ?> </span> </div> <a rel="nofollow" href="<?php echo \yii\helpers\Url::to(\hass\base\helpers\Util::getEntityUrl($model)); ?> " target="_blank" class="cmt"><i></i><span><?php echo $model->getCommentTotal(); ?> </span></a> </div> </div> </div> </div> <?php } ?>
public function beforeBootstrap() { parent::beforeBootstrap(); Util::setComponent("appUrlManager", ["class" => '\\yii\\web\\UrlManager', "scriptUrl" => \Yii::$app->getRequest()->getBaseUrl() . '/index.php']); }
public function init() { parent::init(); Util::setComponent('appUrlManager', ['enablePrettyUrl' => true, 'showScriptName' => true, 'rules' => [["class" => UrlRule::className()]]], true); }
public function initUserModule() { $boot = \Yii::createObject('\\dektrium\\user\\Bootstrap'); $boot->bootstrap(\Yii::$app); $definitions = \Yii::$app->getComponents(); $themePath = $definitions["view"]["theme"]["pathMap"][\Yii::$app->getViewPath()][0]; Util::setComponent("view", ['theme' => ['pathMap' => ["@hass/user/views" => [$themePath . "/user", "@app/views/user", "@hass/user/views", "@dektrium/user/views"]]]], true); }
public function bootstrap($app) { Util::setComponent("view", ["defaultExtension" => "twig"]); }
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()); }
public static function breadcrumb($entity) { return Util::getBreadcrumbs($entity); }
public function registerTranslations() { Util::setComponent("i18n", ['translations' => ["hass/install" => ['class' => "\\yii\\i18n\\PhpMessageSource", 'basePath' => '@hass/install/messages']]], true); }