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(); } }); } }
<?php /** * @author Semenov Alexander <*****@*****.**> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 09.06.2015 */ use skeeks\cms\modules\admin\widgets\form\ActiveFormUseTab as ActiveForm; $form = ActiveForm::begin(); ?> <?php echo $form->fieldSelect($model, 'fieldElement', \skeeks\cms\relatedProperties\propertyTypes\PropertyTypeText::fieldElements()); ?> <?php echo $form->fieldInputInt($model, 'rows'); ?> <?php echo $form->buttonsStandart($model); ActiveForm::end();
/** * Базовые типы свойств * @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]; }
/** * * TODO:: is depricated * * Настройка и инициализация параметров покупателя * Команда создает недостающией свойства покупателя */ public function actionUpdatePersonType() { if (!\Yii::$app->v3toysSettings->shopPersonType) { $this->stdout("Для начала выберите профиль в настройках компонента v3toys (через админку)\n", Console::FG_RED); return; } $personType = \Yii::$app->v3toysSettings->shopPersonType; $this->stdout("Person: " . $personType->name . "\n"); /** * @var $property ShopPersonTypeProperty */ $property = $personType->getShopPersonTypeProperties()->andWhere(['code' => 'name'])->one(); if ($property) { $this->stdout("\t name — exist \n", Console::FG_YELLOW); } else { $property = new ShopPersonTypeProperty(); $property->name = 'Имя'; $property->code = 'name'; $property->is_buyer_name = 'Y'; $property->is_user_name = 'Y'; $property->shop_person_type_id = $personType->id; $property->component = PropertyTypeText::className(); if ($property->save()) { $this->stdout("\t name — added \n", Console::FG_GREEN); } else { $errors = Json::encode($property->getFirstErrors()); $this->stdout("\t name — not added {$errors}\n", Console::FG_RED); } } /** * @var $property ShopPersonTypeProperty */ $property = $personType->getShopPersonTypeProperties()->andWhere(['code' => 'phone'])->one(); if ($property) { $this->stdout("\t phone — exist \n", Console::FG_YELLOW); } else { $property = new ShopPersonTypeProperty(); $property->name = 'Телефон'; $property->code = 'phone'; $property->is_user_phone = 'Y'; $property->shop_person_type_id = $personType->id; $property->component = PropertyTypeText::className(); if ($property->save()) { $this->stdout("\t phone — added \n", Console::FG_GREEN); } else { $errors = Json::encode($property->getFirstErrors()); $this->stdout("\t phone — not added {$errors}\n", Console::FG_RED); } } /** * @var $property ShopPersonTypeProperty */ $property = $personType->getShopPersonTypeProperties()->andWhere(['code' => 'email'])->one(); if ($property) { $this->stdout("\t email — exist \n", Console::FG_YELLOW); } else { $property = new ShopPersonTypeProperty(); $property->name = 'Email'; $property->code = 'email'; $property->is_user_email = 'Y'; $property->shop_person_type_id = $personType->id; $property->component = PropertyTypeText::className(); if ($property->save()) { $this->stdout("\t email — added \n", Console::FG_GREEN); } else { $errors = Json::encode($property->getFirstErrors()); $this->stdout("\t email — not added {$errors}\n", Console::FG_RED); } } /** * @var $property ShopPersonTypeProperty */ $property = $personType->getShopPersonTypeProperties()->andWhere(['code' => 'shipping_method'])->one(); if ($property) { $this->stdout("\t shipping_method — exist \n", Console::FG_YELLOW); } else { $property = new ShopPersonTypeProperty(); $property->name = 'Доставка'; $property->code = 'shipping_method'; $property->shop_person_type_id = $personType->id; $property->component = PropertyTypeText::className(); if ($property->save()) { $this->stdout("\t shipping_method — added \n", Console::FG_GREEN); } else { $errors = Json::encode($property->getFirstErrors()); $this->stdout("\t shipping_method — not added {$errors}\n", Console::FG_RED); } } /** * @var $property ShopPersonTypeProperty */ $property = $personType->getShopPersonTypeProperties()->andWhere(['code' => 'comment'])->one(); if ($property) { $this->stdout("\t comment — exist \n", Console::FG_YELLOW); } else { $property = new ShopPersonTypeProperty(); $property->name = 'Комментарий'; $property->code = 'comment'; $property->shop_person_type_id = $personType->id; $property->component = PropertyTypeText::className(); if ($property->save()) { $this->stdout("\t comment — added \n", Console::FG_GREEN); } else { $errors = Json::encode($property->getFirstErrors()); $this->stdout("\t comment — not added {$errors}\n", Console::FG_RED); } } /** * @var $property ShopPersonTypeProperty */ $property = $personType->getShopPersonTypeProperties()->andWhere(['code' => 'courier_city'])->one(); if ($property) { $this->stdout("\t courier_city — exist \n", Console::FG_YELLOW); } else { $property = new ShopPersonTypeProperty(); $property->name = 'Город (курьерская доставка)'; $property->code = 'courier_city'; $property->shop_person_type_id = $personType->id; $property->component = PropertyTypeText::className(); if ($property->save()) { $this->stdout("\t courier_city — added \n", Console::FG_GREEN); } else { $errors = Json::encode($property->getFirstErrors()); $this->stdout("\t courier_city — not added {$errors}\n", Console::FG_RED); } } /** * @var $property ShopPersonTypeProperty */ $property = $personType->getShopPersonTypeProperties()->andWhere(['code' => 'courier_address'])->one(); if ($property) { $this->stdout("\t courier_address — exist \n", Console::FG_YELLOW); } else { $property = new ShopPersonTypeProperty(); $property->name = 'Адрес (курьерская доставка)'; $property->code = 'courier_address'; $property->shop_person_type_id = $personType->id; $property->component = PropertyTypeText::className(); if ($property->save()) { $this->stdout("\t courier_address — added \n", Console::FG_GREEN); } else { $errors = Json::encode($property->getFirstErrors()); $this->stdout("\t courier_address — not added {$errors}\n", Console::FG_RED); } } /** * @var $property ShopPersonTypeProperty */ $property = $personType->getShopPersonTypeProperties()->andWhere(['code' => 'pickup_city'])->one(); if ($property) { $this->stdout("\t pickup_city — exist \n", Console::FG_YELLOW); } else { $property = new ShopPersonTypeProperty(); $property->name = 'Город (самовывоз)'; $property->code = 'pickup_city'; $property->shop_person_type_id = $personType->id; $property->component = PropertyTypeText::className(); if ($property->save()) { $this->stdout("\t pickup_city — added \n", Console::FG_GREEN); } else { $errors = Json::encode($property->getFirstErrors()); $this->stdout("\t pickup_city — not added {$errors}\n", Console::FG_RED); } } /** * @var $property ShopPersonTypeProperty */ $property = $personType->getShopPersonTypeProperties()->andWhere(['code' => 'pickup_point_id'])->one(); if ($property) { $this->stdout("\t pickup_point_id — exist \n", Console::FG_YELLOW); } else { $property = new ShopPersonTypeProperty(); $property->name = 'Пункт самовывоза (самовывоз)'; $property->code = 'pickup_point_id'; $property->shop_person_type_id = $personType->id; $property->component = PropertyTypeText::className(); if ($property->save()) { $this->stdout("\t pickup_point_id — added \n", Console::FG_GREEN); } else { $errors = Json::encode($property->getFirstErrors()); $this->stdout("\t pickup_point_id — not added {$errors}\n", Console::FG_RED); } } /** * @var $property ShopPersonTypeProperty */ $property = $personType->getShopPersonTypeProperties()->andWhere(['code' => 'post_index'])->one(); if ($property) { $this->stdout("\t post_index — exist \n", Console::FG_YELLOW); } else { $property = new ShopPersonTypeProperty(); $property->name = 'Индекс (почта)'; $property->code = 'post_index'; $property->shop_person_type_id = $personType->id; $property->component = PropertyTypeText::className(); if ($property->save()) { $this->stdout("\t post_index — added \n", Console::FG_GREEN); } else { $errors = Json::encode($property->getFirstErrors()); $this->stdout("\t post_index — not added {$errors}\n", Console::FG_RED); } } /** * @var $property ShopPersonTypeProperty */ $property = $personType->getShopPersonTypeProperties()->andWhere(['code' => 'post_region'])->one(); if ($property) { $this->stdout("\t post_region — exist \n", Console::FG_YELLOW); } else { $property = new ShopPersonTypeProperty(); $property->name = 'Регион (почта)'; $property->code = 'post_region'; $property->shop_person_type_id = $personType->id; $property->component = PropertyTypeText::className(); if ($property->save()) { $this->stdout("\t post_region — added \n", Console::FG_GREEN); } else { $errors = Json::encode($property->getFirstErrors()); $this->stdout("\t post_region — not added {$errors}\n", Console::FG_RED); } } /** * @var $property ShopPersonTypeProperty */ $property = $personType->getShopPersonTypeProperties()->andWhere(['code' => 'post_area'])->one(); if ($property) { $this->stdout("\t post_area — exist \n", Console::FG_YELLOW); } else { $property = new ShopPersonTypeProperty(); $property->name = 'Область (почта)'; $property->code = 'post_area'; $property->shop_person_type_id = $personType->id; $property->component = PropertyTypeText::className(); if ($property->save()) { $this->stdout("\t post_area — added \n", Console::FG_GREEN); } else { $errors = Json::encode($property->getFirstErrors()); $this->stdout("\t post_area — not added {$errors}\n", Console::FG_RED); } } /** * @var $property ShopPersonTypeProperty */ $property = $personType->getShopPersonTypeProperties()->andWhere(['code' => 'post_city'])->one(); if ($property) { $this->stdout("\t post_city — exist \n", Console::FG_YELLOW); } else { $property = new ShopPersonTypeProperty(); $property->name = 'Город (почта)'; $property->code = 'post_city'; $property->shop_person_type_id = $personType->id; $property->component = PropertyTypeText::className(); if ($property->save()) { $this->stdout("\t post_city — added \n", Console::FG_GREEN); } else { $errors = Json::encode($property->getFirstErrors()); $this->stdout("\t post_city — not added {$errors}\n", Console::FG_RED); } } /** * @var $property ShopPersonTypeProperty */ $property = $personType->getShopPersonTypeProperties()->andWhere(['code' => 'post_address'])->one(); if ($property) { $this->stdout("\t post_address — exist \n", Console::FG_YELLOW); } else { $property = new ShopPersonTypeProperty(); $property->name = 'Адрес (почта)'; $property->code = 'post_address'; $property->shop_person_type_id = $personType->id; $property->component = PropertyTypeText::className(); if ($property->save()) { $this->stdout("\t post_address — added \n", Console::FG_GREEN); } else { $errors = Json::encode($property->getFirstErrors()); $this->stdout("\t post_address — not added {$errors}\n", Console::FG_RED); } } /** * @var $property ShopPersonTypeProperty */ $property = $personType->getShopPersonTypeProperties()->andWhere(['code' => 'post_recipient'])->one(); if ($property) { $this->stdout("\t post_recipient — exist \n", Console::FG_YELLOW); } else { $property = new ShopPersonTypeProperty(); $property->name = 'полное ФИО получателя (почта)'; $property->code = 'post_recipient'; $property->shop_person_type_id = $personType->id; $property->component = PropertyTypeText::className(); if ($property->save()) { $this->stdout("\t post_recipient — added \n", Console::FG_GREEN); } else { $errors = Json::encode($property->getFirstErrors()); $this->stdout("\t post_recipient — not added {$errors}\n", Console::FG_RED); } } }
/** * @return string */ public function renderConfigForm(ActiveForm $activeForm) { echo $activeForm->fieldSelect($this, 'fieldElement', \skeeks\cms\relatedProperties\propertyTypes\PropertyTypeText::fieldElements()); echo $activeForm->fieldInputInt($this, 'rows'); echo $activeForm->field($this, 'default_value'); }