本文整理汇总了PHP中app\models\Property类的典型用法代码示例。如果您正苦于以下问题:PHP Property类的具体用法?PHP Property怎么用?PHP Property使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Property类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: up
public function up()
{
$submissionObject = Object::getForClass(\app\models\Submission::className());
/** @var PropertyHandler $propertyHandler */
$propertyHandler = PropertyHandler::findOne(['name' => 'Text']);
$this->addColumn(Review::tableName(), 'submission_id', 'INT UNSIGNED NOT NULL');
$form = new \app\models\Form();
$form->name = 'Review form';
$form->email_notification_addresses = '';
$form->email_notification_view = '@app/modules/review/views/review-email-template.php';
$form->save(false, ['name', 'email_notification_addresses', 'email_notification_view']);
$propertyGroup = new PropertyGroup();
$propertyGroup->attributes = ['object_id' => $form->object->id, 'name' => 'Review form additional properties', 'hidden_group_title' => 1];
$propertyGroup->save(true, ['object_id', 'name', 'hidden_group_title']);
$nameProperty = new Property();
$nameProperty->attributes = ['property_group_id' => $propertyGroup->id, 'name' => 'Name', 'key' => 'name', 'property_handler_id' => $propertyHandler->id, 'handler_additional_params' => '{}', 'is_eav' => 1];
$nameProperty->save(true, ['property_group_id', 'name', 'key', 'property_handler_id', 'is_eav', 'handler_additional_params']);
$phoneProperty = new Property();
$phoneProperty->attributes = ['property_group_id' => $propertyGroup->id, 'name' => 'Phone', 'key' => 'phone', 'property_handler_id' => $propertyHandler->id, 'handler_additional_params' => '{}', 'is_eav' => 1];
$phoneProperty->save(true, ['property_group_id', 'name', 'key', 'property_handler_id', 'is_eav', 'handler_additional_params']);
$objectPropertyGroup = new ObjectPropertyGroup();
$objectPropertyGroup->attributes = ['object_id' => $form->object->id, 'object_model_id' => $form->id, 'property_group_id' => $propertyGroup->id];
$objectPropertyGroup->save(true, ['object_id', 'object_model_id', 'property_group_id']);
$reviews = Review::find()->all();
foreach ($reviews as $review) {
$submission = new \app\models\Submission();
$submission->form_id = $form->id;
$submission->processed_by_user_id = $review->author_user_id;
$submission->date_received = $review->date_submitted;
$submission->save(false, ['form_id', 'processed_by_user_id', 'date_received']);
$review->submission_id = $this->db->lastInsertID;
$review->save(true, ['submission_id']);
$this->insert(ObjectPropertyGroup::tableName(), ['object_id' => $submissionObject->id, 'object_model_id' => $submission->id, 'property_group_id' => $propertyGroup->id]);
$this->insert($submissionObject->eav_table_name, ['object_model_id' => $submission->id, 'property_group_id' => $propertyGroup->id, 'key' => $nameProperty->key, 'value' => $review->author_name]);
$this->insert($submissionObject->eav_table_name, ['object_model_id' => $submission->id, 'property_group_id' => $propertyGroup->id, 'key' => $phoneProperty->key, 'value' => $review->author_phone]);
}
$this->dropColumn(Review::tableName(), 'date_submitted');
$this->dropColumn(Review::tableName(), 'author_user_id');
$this->dropColumn(Review::tableName(), 'author_name');
$this->dropColumn(Review::tableName(), 'author_phone');
$this->dropColumn(Review::tableName(), 'rate');
$this->renameColumn(Review::tableName(), 'text', 'review_text');
$this->alterColumn(Review::tableName(), 'rating_id', 'CHAR(32)');
$this->update(BackendMenu::tableName(), ['route' => 'review/backend-rating/index'], ['route' => 'backend/rating/index']);
$this->update(BackendMenu::tableName(), ['route' => 'review/backend-review/index'], ['name' => 'Reviews']);
$this->delete(BackendMenu::tableName(), ['route' => ['review/backend/products', 'review/backend/pages']]);
$this->alterColumn(RatingValues::tableName(), 'rating_id', 'CHAR(32) NOT NULL');
$this->alterColumn(RatingValues::tableName(), 'object_id', 'INT UNSIGNED NOT NULL');
$this->alterColumn(RatingValues::tableName(), 'object_model_id', 'INT UNSIGNED NOT NULL');
$this->alterColumn(RatingValues::tableName(), 'rating_item_id', 'INT UNSIGNED NOT NULL');
$this->alterColumn(RatingValues::tableName(), 'user_id', 'INT UNSIGNED NOT NULL');
$this->createIndex('ix-rating_values-rating_id', RatingValues::tableName(), 'rating_id');
$this->createIndex('ix-rating_values-object_id-object_model_id', RatingValues::tableName(), ['object_id', 'object_model_id']);
$this->createIndex('ix-rating_item-rating_group', RatingItem::tableName(), 'rating_group');
}
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:55,代码来源:m150514_114054_alterReview.php
示例2: run
public function run()
{
$this->genButton = Html::a(Icon::show('edit') . Yii::t('app', 'Generate'), '#', ['class' => 'btn btn-success', 'id' => 'btn-generate']);
$parent_id = $this->model->main_category_id;
$owner_id = $this->model->id;
$this->addButton = Html::a(Icon::show('plus') . Yii::t('app', 'Add'), Url::toRoute(['/shop/backend-product/edit', 'parent_id' => $parent_id, 'owner_id' => $owner_id, 'returnUrl' => \app\backend\components\Helper::getReturnUrl()]), ['class' => 'btn btn-success', 'id' => 'btn-add']);
if (!empty($this->footer)) {
$this->footer = Html::tag('div', $this->addButton . ' ' . $this->genButton, ['class' => 'widget-footer']);
}
$this->object = Object::getForClass(get_class($this->model));
$rest_pg = (new Query())->select('id, name')->from(PropertyGroup::tableName())->where(['object_id' => $this->object->id])->orderBy('sort_order')->all();
$this->property_groups_to_add = [];
foreach ($rest_pg as $row) {
$this->property_groups_to_add[$row['id']] = $row['name'];
}
$optionGenerate = Json::decode($this->model->option_generate);
if (null === PropertyGroup::findOne($optionGenerate['group'])) {
$this->model->option_generate = $optionGenerate = null;
}
$groupModel = null;
if (isset($optionGenerate['group'])) {
$groupModel = PropertyGroup::findOne($optionGenerate['group']);
$properties = Property::getForGroupId($optionGenerate['group']);
} else {
$group_ids = array_keys($this->property_groups_to_add);
$group_id = array_shift($group_ids);
$groupModel = PropertyGroup::findOne($group_id);
$properties = Property::getForGroupId($group_id);
}
if (is_null($groupModel)) {
$groupModel = new PropertyGroup();
}
return $this->render($this->viewFile, ['model' => $this->model, 'form' => $this->form, 'groups' => $this->property_groups_to_add, 'groupModel' => $groupModel, 'properties' => $properties, 'optionGenerate' => $optionGenerate, 'footer' => $this->footer]);
}
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:34,代码来源:OptionGenerate.php
示例3: getValues
private function getValues($model)
{
/** @var $model Product */
$params = '';
$eav = Yii::$app->getDb()->cache(function ($db) use($model) {
return (new Query())->from($model->object->eav_table_name)->select(Property::tableName() . '.id, ' . $model->object->eav_table_name . '.value')->innerJoin(Property::tableName(), Property::tableName() . '.property_group_id = ' . $model->object->eav_table_name . '.property_group_id' . ' AND ' . Property::tableName() . '.key = ' . $model->object->eav_table_name . '.key')->where(['object_model_id' => $model->id, $model->object->eav_table_name . '.key' => array_column(static::$ymlEavProperties, 'key'), $model->object->eav_table_name . '.property_group_id' => array_column(static::$ymlEavProperties, 'group_id'), Property::tableName() . '.id' => array_keys(static::$ymlEavProperties)])->andWhere(['<>', 'value', ''])->all();
});
foreach ($eav as $prop) {
if (false === isset($prop['id'])) {
continue;
}
$unit = empty(static::$ymlEavProperties[$prop['id']]['unit']) ? '' : ' unit="' . static::$ymlEavProperties[$prop['id']]['unit'] . '"';
$val = htmlspecialchars($prop['value']);
switch (static::$ymlEavProperties[$prop['id']]['handler_id']) {
case 3:
$val = $val == 1 ? Yii::t('yii', 'Yes') : Yii::t('yii', 'No');
break;
}
$params .= '<param name="' . static::$ymlEavProperties[$prop['id']]['name'] . '"' . $unit . '>' . $val . '</param>' . PHP_EOL;
}
$psv = Yii::$app->getDb()->cache(function ($db) use($model) {
return (new Query())->from(PropertyStaticValues::tableName())->innerJoin(ObjectStaticValues::tableName(), ObjectStaticValues::tableName() . '.property_static_value_id = ' . PropertyStaticValues::tableName() . '.id')->where(['object_model_id' => $model->id, 'object_id' => $model->object->id, 'property_id' => array_keys(static::$ymlStaticProperties)])->andWhere(['<>', 'value', ''])->all();
});
foreach ($psv as $prop) {
if (false === isset($prop['property_id'])) {
continue;
}
$unit = empty(static::$ymlStaticProperties[$prop['property_id']]['unit']) ? '' : ' unit="' . static::$ymlStaticProperties[$prop['property_id']]['unit'] . '"';
$params .= '<param name="' . static::$ymlStaticProperties[$prop['property_id']]['name'] . '"' . $unit . '>' . htmlspecialchars($prop['value']) . '</param>' . PHP_EOL;
}
return $params;
}
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:32,代码来源:YmlController.php
示例4: actionEdit
public function actionEdit($id = null)
{
$model = new DynamicContent();
$model->loadDefaultValues();
if ($id !== null) {
$model = DynamicContent::findOne($id);
}
$static_values_properties = [];
if (isset($_GET['DynamicContent'])) {
if (isset($_GET['DynamicContent']['object_id'])) {
$model->object_id = intval($_GET['DynamicContent']['object_id']);
}
}
$property_groups_ids_for_object = (new Query())->select('id')->from(PropertyGroup::tableName())->where([])->column();
$properties = Property::find()->where(['has_static_values' => 1, 'has_slugs_in_values' => 1])->andWhere(['in', 'property_group_id', $property_groups_ids_for_object])->all();
foreach ($properties as $prop) {
$static_values_properties[$prop->id] = ['has_static_values' => true, 'property' => $prop, 'static_values_select' => PropertyStaticValues::getSelectForPropertyId($prop->id)];
}
$post = \Yii::$app->request->post();
if (isset($_GET['DynamicContent'])) {
$post = $_GET;
}
if ($model->load($post) && $model->validate() && !isset($_GET['DynamicContent'])) {
$save_result = $model->save();
if ($save_result) {
return $this->redirectUser($model->id);
} else {
\Yii::$app->session->setFlash('error', Yii::t('app', 'Cannot update data'));
}
}
return $this->render('dynamic-content-form', ['model' => $model, 'static_values_properties' => $static_values_properties]);
}
开发者ID:heartshare,项目名称:dotplant2,代码行数:32,代码来源:DynamicContentController.php
示例5: actionIndex
public function actionIndex($category_id = null)
{
$searchModel = new Category();
$searchModel->active = 1;
$params = Yii::$app->request->get();
$dataProvider = $searchModel->search($params);
$selectedCategory = null;
if ($category_id !== null) {
$selectedCategory = Category::findById($category_id);
}
if ($selectedCategory !== null) {
if (Yii::$app->request->isPost === true) {
$newProperty = isset($_GET['add_property_id']) ? Property::findById($_GET['add_property_id']) : null;
if ($newProperty !== null) {
$filterSet = new FilterSets();
$filterSet->category_id = $selectedCategory->id;
$filterSet->property_id = $newProperty->id;
$filterSet->sort_order = 65535;
$filterSet->save();
}
}
}
$groups = PropertyGroup::getForObjectId(Object::getForClass(Product::className())->id, false);
$propertiesDropdownItems = [];
foreach ($groups as $group) {
$item = ['label' => $group->name, 'url' => '#', 'items' => []];
$properties = Property::getForGroupId($group->id);
foreach ($properties as $prop) {
$item['items'][] = ['label' => $prop->name, 'url' => '?category_id=' . $category_id . '&add_property_id=' . $prop->id, 'linkOptions' => ['class' => 'add-property-to-filter-set', 'data-property-id' => $prop->id, 'data-action' => 'post']];
}
$propertiesDropdownItems[] = $item;
}
return $this->render('index', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel, 'selectedCategory' => $selectedCategory, 'propertiesDropdownItems' => $propertiesDropdownItems]);
}
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:34,代码来源:FilterSetsController.php
示例6: run
/**
* Renders the widget.
*
* @return string
*/
public function run()
{
if ($this->type == 'list') {
$items = [];
foreach ($this->model->options as $option) {
$items[] = $option->name;
}
return $this->render($this->listView, ['items' => $items, 'model' => $this->model]);
} else {
$propertyGroup = Json::decode($this->model->option_generate)['group'];
$items = [];
$optionsJson = [];
foreach ($this->model->options as $option) {
$optionProperties = $option->getPropertyGroups()[$propertyGroup];
$itemsJson = [];
foreach ($optionProperties as $key => $property) {
foreach ($property->values as $name => $propValue) {
if (!isset($items[$key])) {
$items[$key] = ['name' => Property::findById($propValue['property_id'])->name];
}
if (!isset($firstOption)) {
$firstOption[$key] = $propValue['psv_id'];
}
$items[$key]['values'][$propValue['psv_id']] = $propValue['name'];
$itemsJson[$key] = $propValue['psv_id'];
}
}
$optionsJson[] = ['id' => $option->id, 'values' => $itemsJson, 'price' => $option->convertedPrice(), 'old_price' => $option->convertedPrice(null, true)];
}
return $this->render($this->formView, ['model' => $this->model, 'items' => $items, 'optionsJson' => $optionsJson]);
}
}
开发者ID:heartshare,项目名称:dotplant2,代码行数:37,代码来源:ProductOption.php
示例7: getNextPart
/**
* @inheritdoc
*/
public function getNextPart($full_url, $next_part, &$previous_parts)
{
$property = Property::findById($this->property_id);
if (is_null($property)) {
return false;
}
if ($property->has_static_values && $property->has_slugs_in_values) {
$cacheTags = [];
$static_values = PropertyStaticValues::getValuesForPropertyId($this->property_id);
$slugs = explode('/', $next_part);
foreach ($static_values as $value) {
if ($slugs[0] === $value['slug']) {
$this->parameters = ['properties' => [$this->property_id => [$value['id']]]];
if (!empty($value['title_append'])) {
$this->parameters['title_append'] = [$value['title_append']];
}
$cacheTags[] = ActiveRecordHelper::getObjectTag(PropertyStaticValues::className(), $value['id']);
$part = new self(['gathered_part' => $value['slug'], 'rest_part' => mb_substr($next_part, mb_strlen($value['slug'])), 'parameters' => $this->parameters, 'cacheTags' => $cacheTags]);
return $part;
}
}
return false;
} else {
return false;
}
}
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:29,代码来源:PropertyPart.php
示例8: actionEdit
public function actionEdit($id = null)
{
$model = new PrefilteredPages();
$model->loadDefaultValues();
if ($id !== null) {
$model = PrefilteredPages::findOne($id);
}
$static_values_properties = [];
$property_groups_ids_for_object = (new Query())->select('id')->from(PropertyGroup::tableName())->where(['object_id' => Object::getForClass(Product::className())->id])->column();
$properties = Property::find()->andWhere(['in', 'property_group_id', $property_groups_ids_for_object])->all();
foreach ($properties as $prop) {
/** @var Property $prop */
$static_values_properties[$prop->id] = ['property' => $prop, 'static_values_select' => PropertyStaticValues::getSelectForPropertyId($prop->id), 'has_static_values' => $prop->has_static_values === 1];
}
$post = \Yii::$app->request->post();
if ($model->load($post) && $model->validate()) {
$save_result = $model->save();
if ($save_result) {
Yii::$app->session->setFlash('info', Yii::t('app', 'Object saved'));
$returnUrl = Yii::$app->request->get('returnUrl', ['index', 'id' => $model->id]);
switch (Yii::$app->request->post('action', 'save')) {
case 'next':
return $this->redirect(['edit', 'returnUrl' => $returnUrl]);
case 'back':
return $this->redirect($returnUrl);
default:
return $this->redirect(Url::toRoute(['edit', 'id' => $model->id, 'returnUrl' => $returnUrl]));
}
//return $this->redirect(['/backend/prefiltered-pages/edit', 'id' => $model->id]);
} else {
\Yii::$app->session->setFlash('error', Yii::t('app', 'Cannot update data'));
}
}
return $this->render('prefiltered-page-form', ['model' => $model, 'static_values_properties' => $static_values_properties]);
}
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:35,代码来源:BackendPrefilteredPagesController.php
示例9: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Factory::create();
for ($i = 0; $i < 100; $i++) {
\App\Models\Property::create(['user_id' => $faker->randomElement([1, 2, 3, 4]), 'property_url' => $faker->url, 'image' => $faker->imageUrl(242, 162), 'property_title' => $faker->sentence, 'bid_price' => $faker->randomFloat(null, 1000, 100000), 'location' => $faker->address . ', ' . $faker->city . ', ' . $faker->country, 'lat' => $faker->latitude, 'lng' => $faker->longitude, 'city_id' => $faker->randomElement([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), 'bid_start_date_time' => Carbon::now()->addMinutes(($i + 1) * 5), 'bid_close_date_time' => Carbon::now()->addMinutes(($i + 1) * 10)]);
}
}
开发者ID:ashutoshjha88,项目名称:mavrick,代码行数:12,代码来源:PropertyTableSeeder.php
示例10: beforeAction
public function beforeAction($action)
{
$storeName = Property::getPropertyValue('store_name', '');
Yii::$app->view->title = Property::getPropertyValue('store_title', $storeName);
Yii::$app->view->registerMetaTag(['name' => 'description', 'content' => Property::getPropertyValue('store_description', $storeName)], 'description');
Yii::$app->view->registerMetaTag(['name' => 'keywords', 'content' => Property::getPropertyValue('store_keywords', $storeName)], 'keywords');
return parent::beforeAction($action);
}
开发者ID:rcjusto,项目名称:simplestore,代码行数:8,代码来源:BaseSiteController.php
示例11: up
public function up()
{
$this->insert('{{%theme_active_widgets}}', ['part_id' => 5, 'widget_id' => 5, 'variation_id' => 2]);
$propertyId1 = \app\models\Property::find()->where(['key' => 'tip_pamyati'])->select('id')->scalar();
$propertyId2 = \app\models\Property::find()->where(['key' => 'tip_ekrana'])->select('id')->scalar();
$this->insert('{{%filter_sets}}', ['category_id' => 3, 'sort_order' => 2, 'property_id' => $propertyId2]);
$this->insert('{{%filter_sets}}', ['category_id' => 3, 'sort_order' => 1, 'property_id' => $propertyId1]);
}
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:8,代码来源:m150608_131918_filters.php
示例12: getTitle
public function getTitle($lang = null)
{
if (empty($lang)) {
$lang = Property::getDefaultLanguage();
}
$model = $this->getBlockLang($lang);
return !is_null($model) ? $model->title : null;
}
开发者ID:rcjusto,项目名称:simplestore,代码行数:8,代码来源:Block.php
示例13: getPropertyList
public function getPropertyList($user_id, $date)
{
$query = Property::where('user_id', '<>', $user_id);
if (empty($date)) {
$query->where('bid_start_date_time', '>', Carbon::now())->orWhere('bid_close_date_time', '>', Carbon::now());
}
return $query->orderBy('bid_start_date_time', 'asc')->get();
}
开发者ID:ashutoshjha88,项目名称:mavrick,代码行数:8,代码来源:PropertyRepository.php
示例14: actionProperties
public function actionProperties()
{
if (isset($_REQUEST['properties']) && is_array($_REQUEST['properties'])) {
foreach ($_REQUEST['properties'] as $propID => $propValue) {
Property::setPropertyValue($propID, $propValue);
}
}
return $this->render('properties');
}
开发者ID:rcjusto,项目名称:simplestore,代码行数:9,代码来源:DefaultController.php
示例15: __construct
/**
* AuthorizeNetCIM constructor.
*/
public function __construct()
{
$this->loginName = Property::getPropertyValue('authorize_login');
$this->transactionKey = Property::getPropertyValue('authorize_key');
if (Property::getPropertyValue('authorize_live', 'no') == 'yes') {
$this->apiHost = 'api.authorize.net';
$this->apiMode = 'liveMode';
}
}
开发者ID:rcjusto,项目名称:simplestore,代码行数:12,代码来源:AuthorizeNetCIM.php
示例16: getData
public function getData()
{
$query = new Query();
$query->select(Property::tableName() . '.id, ' . Property::tableName() . '.name')->from(Property::tableName());
$query->leftJoin(PropertyGroup::tableName(), PropertyGroup::tableName() . '.id = ' . Property::tableName() . '.property_group_id');
$query->andWhere([PropertyGroup::tableName() . '.object_id' => $this->objectId]);
$command = $query->createCommand();
$this->data = ArrayHelper::map($command->queryAll(), 'id', 'name');
return parent::getData();
}
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:10,代码来源:filterFormProperty.php
示例17: generateEmailForgotPassword
public function generateEmailForgotPassword()
{
if (!empty($emailTo = $this->email)) {
$mail = new Mail();
$mail->to = $emailTo;
$mail->subject = Yii::t('app', 'Information from {store_name}', ['store_name' => Property::getPropertyValue('store_name', '')]);
$mail->body = StoreUtils::renderView('//mail/_destination_forgot_password', ['model' => $this]);
$mail->save();
}
}
开发者ID:rcjusto,项目名称:simplestore,代码行数:10,代码来源:DestinationAccount.php
示例18: show
/**
*
* @return Response
*/
public function show($id)
{
$owner = Owner::findOrFail($id);
$owner->Properties = $owner->Properties;
foreach ($owner->Properties as $property) {
$allTransactions = Property::find($property->id)->allTransactions();
$property->transactions = $allTransactions;
}
return \Response::json(['success' => true, 'message' => 'Owners Loaded.', 'data' => $owner]);
}
开发者ID:bgaeddert,项目名称:PropMan,代码行数:14,代码来源:OwnerController.php
示例19: getProperties
protected function getProperties()
{
$result = [];
$query = new Query();
$query->select(Property::tableName() . '.key, ' . Property::tableName() . '.name')->from(Property::tableName());
$query->innerJoin(PropertyGroup::tableName(), PropertyGroup::tableName() . '.id = ' . Property::tableName() . '.property_group_id');
$query->andWhere([PropertyGroup::tableName() . '.object_id' => $this->object->id]);
$command = $query->createCommand();
return ArrayHelper::map($command->queryAll(), 'key', 'name');
}
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:10,代码来源:DataRelationsWidget.php
示例20: run
/**
* @inheritdoc
* @param int $id
* @return int|mixed
* @throws NotFoundHttpException
*/
public function run($id)
{
/** @var Form|HasProperties $form */
if (null === ($form = Form::findById($id))) {
throw new NotFoundHttpException();
}
$post = Yii::$app->request->post();
$form->abstractModel->setAttrubutesValues($post);
/** @var AbstractModel|SpamCheckerBehavior $model */
$model = $form->getAbstractModel();
if (Yii::$app->request->isAjax && isset($post['ajax'])) {
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($model);
}
/** @var \app\models\Object $object */
$object = Object::getForClass(Form::className());
$propGroups = ObjectPropertyGroup::find()->where(['and', 'object_id = :object', 'object_model_id = :id'], [':object' => $object->id, ':id' => $id])->asArray()->all();
$propIds = ArrayHelper::getColumn($propGroups, 'property_group_id');
// Spam checking
$activeSpamChecker = SpamChecker::getActive();
$data = [];
$haveSpam = false;
if ($activeSpamChecker !== null && !empty($activeSpamChecker->api_key)) {
$data[$activeSpamChecker->name]['class'] = $activeSpamChecker->behavior;
$data[$activeSpamChecker->name]['value']['key'] = $activeSpamChecker->api_key;
$properties = Property::getForGroupId($propIds[0]);
foreach ($properties as $prop) {
if (!isset($activeSpamChecker->{$prop->interpret_as}) || empty($activeSpamChecker->{$prop->interpret_as})) {
continue;
}
$data[$activeSpamChecker->name]['value'][$activeSpamChecker->{$prop->interpret_as}] = is_array($post[$form->abstractModel->formName()][$prop->key]) ? implode(' ', $post[$form->abstractModel->formName()][$prop->key]) : $post[$form->abstractModel->formName()][$prop->key];
}
$model->attachBehavior('spamChecker', ['class' => SpamCheckerBehavior::className(), 'data' => $data]);
$haveSpam = $model->isSpam();
}
$date = new \DateTime();
/** @var Submission|HasProperties $submission */
$submission = new Submission(['form_id' => $form->id, 'date_received' => $date->format('Y-m-d H:i:s'), 'ip' => Yii::$app->request->userIP, 'user_agent' => Yii::$app->request->userAgent, 'spam' => (int) $haveSpam]);
if (false === Yii::$app->user->isGuest) {
$submission->processed_by_user_id = Yii::$app->user->identity->getId();
}
if (!($form->abstractModel->validate() && $submission->save())) {
return "0";
}
if (isset($post[$form->abstractModel->formName()])) {
$data = ['AddPropetryGroup' => [$submission->formName() => array_keys($form->getPropertyGroups())], $submission->abstractModel->formName() => $post[$form->abstractModel->formName()]];
if (isset($_FILES[$form->abstractModel->formName()])) {
$_FILES[$submission->abstractModel->formName()] = $_FILES[$form->abstractModel->formName()];
}
$submission->saveProperties($data);
}
return $submission->id;
}
开发者ID:xuantienvp,项目名称:dotplant2,代码行数:59,代码来源:SubmitFormAction.php
注:本文中的app\models\Property类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论