当前位置: 首页>>代码示例>>PHP>>正文


PHP Property::getForGroupId方法代码示例

本文整理汇总了PHP中app\models\Property::getForGroupId方法的典型用法代码示例。如果您正苦于以下问题:PHP Property::getForGroupId方法的具体用法?PHP Property::getForGroupId怎么用?PHP Property::getForGroupId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Property的用法示例。


在下文中一共展示了Property::getForGroupId方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例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: 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

示例4: foreach

\yii\bootstrap\Modal::begin(['id' => 'custom-fields-modal', 'header' => Yii::t('app', 'Edit order properties')]);
$form = \kartik\widgets\ActiveForm::begin(['action' => ['update-order-properties', 'id' => $model->id]]);
foreach (\app\models\PropertyGroup::getForModel($model->object->id, $model->id) as $group) {
    ?>
    <?php 
    if ($group->hidden_group_title == 0) {
        ?>
        <h4><?php 
        echo $group->name;
        ?>
</h4>
    <?php 
    }
    ?>
    <?php 
    $properties = \app\models\Property::getForGroupId($group->id);
    ?>
    <?php 
    foreach ($properties as $property) {
        ?>
        <?php 
        echo $property->handler($form, $model->abstractModel, [], 'frontend_edit_view');
        ?>
    <?php 
    }
}
echo Html::submitButton(Yii::t('app', 'Send'), ['class' => 'btn btn-primary']);
\kartik\widgets\ActiveForm::end();
\yii\bootstrap\Modal::end();
?>
开发者ID:Razzwan,项目名称:dotplant2,代码行数:30,代码来源:view.php

示例5: foreach

            </article>
            <article class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                <div class="jarviswidget">
                    <header>
                        <h2><i class="fa fa-cubes"></i> <?php 
echo Yii::t('app', 'Properties');
?>
</h2>
                    </header>
                    <div class="widget-body">
                    <?php 
foreach ($groups as $group) {
    ?>
                            <?php 
    $properties = Property::getForGroupId($group->id);
    ?>
                            <?php 
    foreach ($properties as $property) {
        ?>
                                <?php 
        if ($propertyValues = $review->submission->getPropertyValuesByPropertyId($property->id)) {
            ?>
                                    <?php 
            echo Html::beginTag('div', ['class' => 'col-md-8']);
            ?>
                                    <?php 
            echo $property->handler('form', $review->submission->abstractModel, $propertyValues, 'backend_render_view');
            ?>
                                    <?php 
            echo Html::endTag('div');
开发者ID:heartshare,项目名称:dotplant2,代码行数:30,代码来源:submission-view.php

示例6: actionClone

 /**
  * Clone product action.
  * @param integer $id
  * @throws \yii\web\NotFoundHttpException
  */
 public function actionClone($id, $returnUrl = ['index'])
 {
     /** @var Product|HasProperties $model */
     $model = Product::findOne($id);
     if ($model === null) {
         throw new NotFoundHttpException();
     }
     /** @var Product|HasProperties $newModel */
     $newModel = new Product();
     $newModel->setAttributes($model->attributes, false);
     $time = time();
     $newModel->name .= ' (copy ' . date('Y-m-d h:i:s', $time) . ')';
     $newModel->slug .= '-copy-' . date('Ymdhis', $time);
     $newModel->id = null;
     if ($newModel->validate() === false) {
         $newModel->slug = substr(uniqid() . "-" . $model->slug, 0, 80);
     }
     if ($newModel->save()) {
         $object = Object::getForClass(get_class($newModel));
         // save categories
         $categoriesTableName = Object::getForClass(Product::className())->categories_table_name;
         $query = new Query();
         $params = $query->select(['category_id', 'sort_order'])->from($categoriesTableName)->where(['object_model_id' => $model->id])->all();
         if (!empty($params)) {
             $rows = [];
             foreach ($params as $param) {
                 $rows[] = [$param['category_id'], $newModel->id, $param['sort_order']];
             }
             Yii::$app->db->createCommand()->batchInsert($categoriesTableName, ['category_id', 'object_model_id', 'sort_order'], $rows)->execute();
         }
         // save images bindings
         $params = $query->select(['object_id', 'filename', 'image_title', 'image_alt', 'sort_order'])->from(Image::tableName())->where(['object_id' => $object->id, 'object_model_id' => $model->id])->all();
         if (!empty($params)) {
             $rows = [];
             foreach ($params as $param) {
                 $rows[] = [$param['object_id'], $newModel->id, $param['filename'], $param['image_title'], $param['image_alt'], $param['sort_order']];
             }
             Yii::$app->db->createCommand()->batchInsert(Image::tableName(), ['object_id', 'object_model_id', 'filename', 'image_title', 'image_alt', 'sort_order'], $rows)->execute();
         }
         $newModelProps = [];
         foreach (array_keys($model->propertyGroups) as $key) {
             $opg = new ObjectPropertyGroup();
             $opg->attributes = ['object_id' => $object->id, 'object_model_id' => $newModel->id, 'property_group_id' => $key];
             $opg->save();
             $props = Property::getForGroupId($key);
             foreach ($props as $prop) {
                 $propValues = $model->getPropertyValuesByPropertyId($prop->id);
                 if ($propValues !== null) {
                     foreach ($propValues->values as $val) {
                         $valueToSave = ArrayHelper::getValue($val, 'psv_id', $val['value']);
                         $newModelProps[$prop->key][] = $valueToSave;
                     }
                 }
             }
         }
         $newModel->saveProperties(['Properties_Product_' . $newModel->id => $newModelProps]);
         Yii::$app->session->setFlash('success', Yii::t('app', 'Product has been cloned successfully.'));
         $this->redirect(['edit', 'id' => $newModel->id, 'returnUrl' => $returnUrl]);
     }
 }
开发者ID:pramana08,项目名称:dotplant2,代码行数:65,代码来源:BackendProductController.php

示例7: getPropertyGroups

 public function getPropertyGroups($force = false, $getByObjectId = false, $createAbstractModel = false)
 {
     $message = "getPropertyGroups " . $this->owner->className() . ':' . $this->owner->id . " force:" . ($force ? 'true' : 'false') . " getByObjectId:" . ($getByObjectId ? 'true' : 'false') . " createAbstractModel:" . ($createAbstractModel ? 'true' : 'false');
     Yii::trace($message, 'properties');
     $cacheKey = $message;
     if ($this->properties === null && $force === false) {
         // try to get from cache
         $data = Yii::$app->cache->get($message);
         if ($data !== false) {
             Yii::trace("Properties from cache", 'properties');
             $this->abstract_model = isset($data['abstract_model']) ? $data['abstract_model'] : [];
             $this->properties = $data['properties'];
             $this->property_key_to_id = $data['property_key_to_id'];
             $this->property_id_to_group_id = $data['property_id_to_group_id'];
         }
     }
     if ($createAbstractModel === true && is_null($this->abstract_model)) {
         // force creating abstract model if it is null and needed
         $force = true;
     }
     if ($this->properties === null || $force === true) {
         $tags = [ActiveRecordHelper::getObjectTag($this->owner->className(), $this->owner->id)];
         $this->properties = [];
         if ($getByObjectId === true) {
             $groups = PropertyGroup::getForObjectId($this->getObject()->id);
         } else {
             $groups = PropertyGroup::getForModel($this->getObject()->id, $this->owner->id);
         }
         $values_for_abstract = [];
         $properties_models = [];
         $rules = [];
         /** @var PropertyGroup $group */
         foreach ($groups as $group) {
             $tags[] = ActiveRecordHelper::getObjectTag(PropertyGroup::className(), $group->id);
             $this->properties[$group->id] = [];
             $props = Property::getForGroupId($group->id);
             foreach ($props as $p) {
                 $values = $this->getPropertyValues($p);
                 $this->properties[$group->id][$p->key] = $values;
                 if ($createAbstractModel === true) {
                     $values_for_abstract[$p->key] = $values;
                 }
                 $properties_models[$p->key] = $p;
                 $this->property_key_to_id[$p->key] = $p->id;
                 if (!isset($this->property_id_to_group_id[$group->id])) {
                     $this->property_id_to_group_id[$group->id] = [$p->key];
                 } else {
                     $this->property_id_to_group_id[$group->id][] = $p->key;
                 }
                 if ($createAbstractModel === true) {
                     $handlerAdditionalParams = Json::decode($p->handler_additional_params);
                     if (isset($handlerAdditionalParams['rules']) && is_array($handlerAdditionalParams['rules'])) {
                         foreach ($handlerAdditionalParams['rules'] as $rule) {
                             if (is_array($rule)) {
                                 $rules[] = ArrayHelper::merge([$p->key], $rule);
                             } else {
                                 $rules[] = [$p->key, $rule];
                             }
                         }
                     }
                 }
             }
         }
         if ($createAbstractModel === true) {
             $this->abstract_model = new AbstractModel([], $this->owner);
             $this->abstract_model->setPropertiesModels($properties_models);
             $this->abstract_model->setAttributes($values_for_abstract);
             $this->abstract_model->setFormName('Properties_' . $this->owner->formName() . '_' . $this->owner->id);
             $this->abstract_model->addRules($rules);
         }
         $res = Yii::$app->cache->set($cacheKey, ['properties' => $this->properties, 'abstract_model' => $this->abstract_model, 'property_id_to_group_id' => $this->property_id_to_group_id, 'property_key_to_id' => $this->property_key_to_id], 86400, new TagDependency(['tags' => $tags]));
         Yii::trace('putting props to cache: ' . ($res ? 'true' : 'false') . ' key:' . $cacheKey, 'properties');
     }
     return $this->properties;
 }
开发者ID:lzpfmh,项目名称:dotplant2,代码行数:75,代码来源:HasProperties.php

示例8: getPossibleSelections

 public function getPossibleSelections()
 {
     $data = ['propertyIds' => [], 'propertyStaticValueIds' => []];
     if ($this->onlyAvailableFilters) {
         Yii::beginProfile("onlyAvailableFilters");
         $object = Object::findById($this->objectId);
         if (!is_null($object) && isset($this->currentSelections['last_category_id'])) {
             $cacheKey = 'FilterWidget: ' . $object->id . ':' . $this->currentSelections['last_category_id'] . ':' . Json::encode($this->currentSelections['properties']);
             $data = Yii::$app->cache->get($cacheKey);
             if ($data === false) {
                 $data = [];
                 Yii::beginProfile("ObjectIds for this category");
                 $query = new Query();
                 $query = $query->select($object->categories_table_name . '.object_model_id')->distinct()->from($object->categories_table_name)->join("JOIN", Product::tableName(), sprintf("%s.`id` = %s.`object_model_id`", Product::tableName(), $object->categories_table_name))->andWhere([Product::tableName() . ".`active`" => 1])->andWhere(['category_id' => $this->currentSelections['last_category_id']]);
                 if (count($this->currentSelections['properties']) > 0) {
                     Yii::beginProfile("Apply currency selections(properties)");
                     foreach ($this->currentSelections['properties'] as $property_id => $values) {
                         $joinTableName = 'OSVJoinTable' . $property_id;
                         $query->join('JOIN', ObjectStaticValues::tableName() . ' ' . $joinTableName, $joinTableName . '.object_id = :objectId AND ' . $joinTableName . '.object_model_id = ' . $object->categories_table_name . '.object_model_id  ', [':objectId' => $object->id]);
                         $query->andWhere(['in', '`' . $joinTableName . '`.`property_static_value_id`', $values]);
                     }
                     Yii::endProfile("Apply currency selections(properties)");
                 }
                 Yii::endProfile("ObjectIds for this category");
                 $ids = array_map('intval', $query->column());
                 $query = null;
                 Yii::beginProfile("all PSV ids");
                 $data['propertyStaticValueIds'] = [];
                 if (count($ids) !== 0) {
                     $q4psv = (new Query())->select('property_static_value_id')->from(ObjectStaticValues::tableName())->distinct()->where(['object_id' => $object->id])->andWhere('object_model_id in (' . implode(',', $ids) . ')');
                     $data['propertyStaticValueIds'] = array_map('intval', $q4psv->column());
                 }
                 Yii::endProfile("all PSV ids");
                 $ids = null;
                 Yii::beginProfile("Property ids from PSV ids");
                 $data['propertyIds'] = [];
                 if (count($data['propertyStaticValueIds']) !== 0) {
                     $data['propertyIds'] = PropertyStaticValues::find()->select('property_id')->distinct()->where(['dont_filter' => 0])->andWhere('id IN (' . implode(',', $data['propertyStaticValueIds']) . ')')->asArray()->column();
                 }
                 Yii::endProfile("Property ids from PSV ids");
                 Yii::$app->cache->set($cacheKey, $data, 86400, new TagDependency(['tags' => [\devgroup\TagDependencyHelper\ActiveRecordHelper::getCommonTag($object->object_class)]]));
                 $object = null;
             }
         }
         Yii::endProfile("onlyAvailableFilters");
     }
     $this->possibleSelections = [];
     $groups = PropertyGroup::getForObjectId($this->objectId);
     foreach ($groups as $group) {
         if ($this->onlyGroupsIds !== null) {
             if (in_array($group->id, $this->onlyGroupsIds) === false) {
                 // skip this group
                 continue;
             }
         }
         if ($group->is_internal) {
             continue;
         }
         $this->possibleSelections[$group->id] = ['group' => $group, 'selections' => [], 'static_selections' => [], 'dynamic_selections' => []];
         $props = Property::getForGroupId($group->id);
         foreach ($props as $p) {
             if ($this->onlyAvailableFilters && !in_array($p->id, $data['propertyIds'])) {
                 if ($this->disableInsteadOfHide === false) {
                     continue;
                 }
             }
             if ($p->dont_filter) {
                 continue;
             }
             if ($p->has_static_values) {
                 $propertyStaticValues = PropertyStaticValues::getValuesForPropertyId($p->id);
                 foreach ($propertyStaticValues as $key => $propertyStaticValue) {
                     if ($propertyStaticValue['dont_filter']) {
                         unset($propertyStaticValues[$key]);
                     }
                 }
                 if ($this->onlyAvailableFilters) {
                     foreach ($propertyStaticValues as $key => $propertyStaticValue) {
                         if (!in_array($propertyStaticValue['id'], $data['propertyStaticValueIds'])) {
                             if ($this->disableInsteadOfHide === true) {
                                 $this->disabled_ids[] = $propertyStaticValue['id'];
                             } else {
                                 unset($propertyStaticValues[$key]);
                             }
                         }
                     }
                 }
                 $this->possibleSelections[$group->id]['static_selections'][$p->id] = $propertyStaticValues;
             } elseif ($p->is_column_type_stored && $p->value_type == 'NUMBER') {
                 $this->possibleSelections[$group->id]['dynamic_selections'][] = $p->id;
             }
         }
         if (count($this->possibleSelections[$group->id]) === 0) {
             unset($this->possibleSelections[$group->id]);
         }
     }
 }
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:97,代码来源:FilterWidget.php

示例9: run

 /**
  * @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 = [];
     $spamResult = [];
     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]);
         $spamResult = $model->check();
     }
     $haveSpam = false;
     if (is_array($spamResult) === true) {
         foreach ($spamResult as $result) {
             if (ArrayHelper::getValue($result, 'ok', false) === true) {
                 $haveSpam = $haveSpam || ArrayHelper::getValue($result, 'is_spam', false);
             }
         }
     }
     $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);
     }
     if ($haveSpam === false) {
         if (!empty($form->email_notification_addresses)) {
             try {
                 $emailView = !empty($form->email_notification_view) ? $form->email_notification_view : '@app/widgets/form/views/email-template.php';
                 Yii::$app->mail->compose($emailView, ['form' => $form, 'submission' => $submission])->setTo(explode(',', $form->email_notification_addresses))->setFrom(Yii::$app->mail->getMailFrom())->setSubject($form->name . ' #' . $submission->id)->send();
             } catch (\Exception $e) {
                 // do nothing
             }
         }
     }
     return $submission->id;
 }
开发者ID:keyeMyria,项目名称:dotplant2,代码行数:76,代码来源:SubmitFormAction.php

示例10: getProperties

 /**
  * @param $objectId
  * @return array
  */
 protected static function getProperties($objectId)
 {
     $properties = [];
     $groups = PropertyGroup::getForObjectId($objectId);
     foreach ($groups as $group) {
         $props = Property::getForGroupId($group->id);
         foreach ($props as $prop) {
             $properties[] = $prop;
         }
     }
     return $properties;
 }
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:16,代码来源:Import.php

示例11: array_reduce

echo $form->field($review, 'status')->dropDownList(Review::getStatuses());
?>
            <?php 
BackendWidget::end();
?>
        </article>

        <article class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
            <?php 
if (null !== $submission) {
    BackendWidget::begin(['title' => Yii::t('app', 'Properties'), 'icon' => 'cubes']);
    ?>
            <?php 
    echo array_reduce($groups, function ($result, $item) use($submission) {
        /** @var PropertyGroup $item */
        $result .= array_reduce(\app\models\Property::getForGroupId($item->id), function ($res, $prop) use($submission) {
            /** @var \app\models\Property $prop */
            if (null !== ($val = $submission->getPropertyValuesByPropertyId($prop->id))) {
                $html = Html::tag('div', $prop->handler('form', $submission->abstractModel, $val, 'backend_render_view'), ['class' => 'col-md-8']);
                $res .= Html::tag('div', $html, ['class' => 'form-group']);
            }
            return $res;
        }, '');
        return $result;
    }, '');
    ?>

                <?php 
    echo $form->field($submission, 'date_received');
    ?>
                <?php 
开发者ID:yii2ApplicationCollect,项目名称:dotplant2,代码行数:31,代码来源:edit.php


注:本文中的app\models\Property::getForGroupId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。