示例#1
0
文件: Cms.php 项目: skeeks-cms/cms
 public function init()
 {
     parent::init();
     //Название проекта.
     if (!$this->appName) {
         $this->appName = \Yii::$app->name;
     } else {
         \Yii::$app->name = $this->appName;
     }
     //Язык
     if ($this->languageCode) {
         \Yii::$app->language = $this->languageCode;
     } else {
         $this->languageCode = \Yii::$app->language;
     }
     if (\Yii::$app instanceof Application) {
     } else {
         $this->relatedHandlers = ArrayHelper::merge([PropertyTypeText::className() => ['class' => PropertyTypeText::className()], PropertyTypeNumber::className() => ['class' => PropertyTypeNumber::className()], PropertyTypeList::className() => ['class' => PropertyTypeList::className()], PropertyTypeFile::className() => ['class' => PropertyTypeFile::className()], PropertyTypeTree::className() => ['class' => PropertyTypeTree::className()], PropertyTypeElement::className() => ['class' => PropertyTypeElement::className()], UserPropertyTypeDate::className() => ['class' => UserPropertyTypeDate::className()], UserPropertyTypeComboText::className() => ['class' => UserPropertyTypeComboText::className()], UserPropertyTypeColor::className() => ['class' => UserPropertyTypeColor::className()], UserPropertyTypeSelectFile::className() => ['class' => UserPropertyTypeSelectFile::className()]], $this->relatedHandlers);
         //web init
         if (!$this->noImageUrl) {
             $this->noImageUrl = CmsAsset::getAssetUrl('img/image-not-found.jpg');
         }
         \Yii::$app->view->on(View::EVENT_BEGIN_PAGE, function (Event $e) {
             if (!\Yii::$app->request->isAjax && !\Yii::$app->request->isPjax) {
                 \Yii::$app->response->getHeaders()->setDefault('X-Powered-CMS', $this->descriptor->name . " {$this->descriptor->homepage}");
                 /**
                  * @var $view View
                  */
                 $view = $e->sender;
                 if (!isset($view->metaTags[self::$_huck])) {
                     $view->registerMetaTag(["name" => base64_decode(self::$_huck), "content" => $this->descriptor->name . " — {$this->descriptor->homepage}"], self::$_huck);
                 }
                 if (!isset($view->metaTags['cmsmagazine'])) {
                     $view->registerMetaTag(["name" => 'cmsmagazine', "content" => "7170fe3a42c6f80cd95fd8bce765333d"], 'cmsmagazine');
                 }
             }
         });
         \Yii::$app->user->on(\yii\web\User::EVENT_AFTER_LOGIN, function (UserEvent $e) {
             $e->identity->logged_at = \Yii::$app->formatter->asTimestamp(time());
             $e->identity->save(false);
             if (\Yii::$app->admin->requestIsAdmin) {
                 \Yii::$app->user->identity->updateLastAdminActivity();
             }
         });
     }
 }
示例#2
0
文件: Cms.php 项目: Liv1020/cms
 /**
  * Базовые типы свойств
  * @return array
  */
 public function basePropertyTypes()
 {
     return [PropertyTypeText::className() => (new PropertyTypeText())->name, PropertyTypeNumber::className() => (new PropertyTypeNumber())->name, PropertyTypeList::className() => (new PropertyTypeList())->name, PropertyTypeFile::className() => (new PropertyTypeFile())->name, PropertyTypeTree::className() => (new PropertyTypeTree())->name, PropertyTypeElement::className() => (new PropertyTypeElement())->name];
 }