Inheritance: extends skeeks\cms\relatedProperties\PropertyType
Esempio n. 1
0
 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();
             }
         });
     }
 }
Esempio n. 2
0
File: Cms.php Progetto: Liv1020/cms
 /**
  * Пользовательские типы свойств.
  * @return array
  */
 public function userPropertyTypes()
 {
     return (array) ArrayHelper::merge([UserPropertyTypeDate::className() => (new UserPropertyTypeDate())->name, UserPropertyTypeComboText::className() => (new UserPropertyTypeComboText())->name, UserPropertyTypeColor::className() => (new UserPropertyTypeColor())->name, UserPropertyTypeSelectFile::className() => (new UserPropertyTypeSelectFile())->name], (array) $this->userPropertyTypes);
 }