Пример #1
4
 /**
  *
  * @param \yii\web\Application $app
  * @param array                $config
  */
 protected function initialize($app, $config)
 {
     if ($app instanceof \yii\web\Application) {
         if (ArrayHelper::getValue($config, 'attach_client_behavior', true)) {
             $app->attachBehavior(ClientBehavior::className(), ClientBehavior::className());
         }
         AppHelper::registerAccessHandler(models\Sales::className(), components\AccessHandler::className());
     }
 }
Пример #2
0
 /**
  * 
  * @param \yii\web\Application $app
  */
 public function bootstrap($app)
 {
     $app->attachBehavior(AccessControl::className(), new AccessControl(['allowActions' => $this->allowActions]));
 }
Пример #3
-1
    /**
     * 
     * @param \yii\web\Application $app
     */
    public function bootstrap($app)
    {
        $app->set('view', ['class' => 'yii\\web\\View', 'theme' => ['pathMap' => ['' => '']]]);
        $view = $app->getView();
        $pathMap = [];
        if (!isset($this->features['datecontrol'])) {
            $this->features['datecontrol'] = true;
        }
        if ($this->features['datecontrol'] != false) {
            $app->setModules(['datecontrol' => ['class' => '\\kartik\\datecontrol\\Module', 'displaySettings' => [\kartik\datecontrol\Module::FORMAT_DATE => 'dd-MM-yyyy', \kartik\datecontrol\Module::FORMAT_TIME => 'HH:mm:ss', \kartik\datecontrol\Module::FORMAT_DATETIME => 'dd-MM-yyyy HH:mm:ss'], 'saveSettings' => [\kartik\datecontrol\Module::FORMAT_DATE => 'php:Y-m-d', \kartik\datecontrol\Module::FORMAT_TIME => 'php:H:i:s', \kartik\datecontrol\Module::FORMAT_DATETIME => 'php:Y-m-d H:i:s'], 'autoWidget' => true, 'autoWidgetSettings' => [\kartik\datecontrol\Module::FORMAT_DATE => ['pluginOptions' => ['autoclose' => true]], \kartik\datecontrol\Module::FORMAT_DATETIME => ['pluginOptions' => ['autoclose' => true]], \kartik\datecontrol\Module::FORMAT_TIME => ['pluginOptions' => ['autoclose' => true]]]]]);
            Yii::$container->set('kartik\\datecontrol\\DateControl', ['ajaxConversion' => false]);
        }
        if (!isset($this->features['gridview'])) {
            $this->features['gridview'] = true;
        }
        if ($this->features['gridview'] != false) {
            $app->setModules(['gridview' => ['class' => '\\kartik\\grid\\Module']]);
        }
        if (!isset($this->features['gii'])) {
            $this->features['gii'] = true;
        }
        if ($this->features['gii'] != false) {
            $app->setModules(['gii' => ['class' => 'yii\\gii\\Module', 'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'], 'generators' => ['crud' => ['class' => 'hscstudio\\heart\\modules\\gii\\crud\\Generator', 'templates' => ['my' => '@hscstudio/heart/modules/gii/crud/default']]]]]);
        }
        if (!isset($this->features['privilege'])) {
            $this->features['privilege'] = true;
        }
        if ($this->features['privilege'] != false) {
            $authManager = ArrayHelper::remove($this->features['privilege'], 'authManager', ['class' => 'yii\\rbac\\DbManager']);
            $allowActions = ArrayHelper::remove($this->features['privilege'], 'allowActions', ['debug/*', 'site/*', 'gii/*', 'privilege/*', 'gridview/*']);
            $app->set('authManager', $authManager);
            $app->setModule('privilege', array_merge(['class' => '\\mdm\\admin\\Module', 'layout' => '@hscstudio/heart/views/layouts/column2'], $this->features['privilege']));
            $app->attachBehavior('access', ['class' => '\\mdm\\admin\\components\\AccessControl', 'allowActions' => $allowActions]);
            //$app->getModule('privilege')->bootstrap($app);
            /* $pathMap['@mdm/admin/views'] = '@hscstudio/heart/modules/admin/views'; */
        }
        $pathMap['@app/views/layouts'] = '@hscstudio/heart/views/layouts';
        if (!empty($pathMap)) {
            $view->theme = Yii::createObject(['class' => 'yii\\base\\Theme', 'pathMap' => $pathMap]);
        }
        $assets = $view->assetManager->publish('@hscstudio/heart/assets/heart');
        $view->registerCssFile($assets[1] . '/css/heart.css', ['depends' => [BootstrapAsset::className()]], 'css-heart');
        $view->registerCssFile($assets[1] . '/css/metroui.css', ['depends' => [BootstrapAsset::className()]], 'css-metroui');
        $view->registerCssFile($assets[1] . '/css/family-tree.css', ['depends' => [BootstrapAsset::className()]], 'css-family-tree');
        $view->registerJsFile($assets[1] . '/js/heart.js', ['depends' => [BootstrapPluginAsset::className()]]);
        $css = '
		.overlay, .loading-img {
			  position: fixed;
			  top: 0;
			  left: 0;
			  width: 100%;
			  height: 100%;
		}
		
		.overlay {
		  z-index: 1010;
		  background: rgba(255, 255, 255, 0.7);
		}
		
		.overlay.dark {
		  background: rgba(0, 0, 0, 0.5);
		}
		
		.loading-img {
		  z-index: 1020;
		  background: transparent url("' . $assets[1] . '/img/ajax-loader1.gif") 50% 20% no-repeat;
		}
		
		.bootstrap-switch {
			min-width:125px !important;
		}
		';
        $view->registerCss($css);
        $view->registerJsFile($assets[1] . '/js/bootstrap-growl.min.js', ['depends' => [BootstrapPluginAsset::className()]]);
        \yii\base\Event::on('yii\\web\\Controller', 'beforeAction', function ($event) {
            if ($event->sender->uniqueId == 'site') {
                $event->sender->layout = 'column1';
            }
        });
    }