/** * Регистрирует мета-теги * @param \common\db\ActiveRecord $model */ public function registerMetaTags($model) { if ($model->hasAttribute("metatitle") and !empty($model->metatitle)) { $this->title = $model->metatitle; } elseif ($model->hasAttribute("title")) { $this->title = $model->title; } if ($model->hasAttribute("keywords")) { $this->registerMetaTag(["name" => "keywords", "content" => $model->keywords]); } if ($model->hasAttribute("description")) { $this->registerMetaTag(["name" => "description", "content" => $model->description]); } }
/** * Проверяет попытку изменения запрещенных атрибутов * @param \common\db\ActiveRecord $model * @throws \yii\web\ForbiddenHttpException */ protected function checkForbiddenAttrs($model) { $attrs = Yii::$app->request->post($model->formName(), []); $perm = $model->getPermission(); if ($perm and $perm->hasForbiddenAttrs($attrs)) { throw new ForbiddenHttpException('Forbidden'); } }
/** * @inheritdoc */ public function beforeSave($insert) { if (parent::beforeSave($insert)) { if (empty($this->sort)) { $this->sort = self::DEFAULT_SORT; } return true; } return false; }
/** * @inheritdoc */ public function afterSave($insert, $changedAttributes) { if ($insert and $this->active == true) { $this->recalc(); } if (!$insert and isset($changedAttributes['active'])) { $this->recalc(); } parent::afterSave($insert, $changedAttributes); }
/** * Возвращает строку формы * @param \common\db\ActiveRecord $model модель * @param int $index номер строки * @return string */ protected function renderLine($model, $index) { $html = Html::beginTag('tr'); $meta = $model->getMetaFields(); $fields = $meta->getFields(); foreach ($fields as $field) { if (!$field->showInTableInput) { continue; } $html .= Html::beginTag('td'); $html .= $field->getForm($this->form, [], $index); $html .= Html::endTag('td'); } if ($this->hasRowLinks()) { $html .= Html::beginTag('td'); $html .= $this->renderLinks($index, $model); $html .= Html::endTag('td'); } $html .= Html::endTag('tr'); return $html; }
/** * @inheritdoc * загружаем шаблон письма */ public function afterFind() { parent::afterFind(); Yii::$app->getModule('shop')->orderLetters->loadStatusTpl($this); }
/** * @inheritdoc */ public function behaviors() { $behaviors = parent::behaviors(); $behaviors["nestedSets"] = ["class" => NestedSet::className(), "depthAttribute" => "level"]; return $behaviors; }
/** * @inheritdoc */ public function scenarios() { $parent = parent::scenarios(); $arr = array_diff($parent[self::SCENARIO_CONFIRM], ["allGoods"]); $parent[self::SCENARIO_CONFIRM] = array_merge($arr, ["!allGoods"]); return $parent; }
/** * @inheritdoc */ public function behaviors() { $arr = parent::behaviors(); $arr["manyManySaver"] = ['class' => \common\behaviors\ManyManySaver::className(), 'names' => ['sections']]; return $arr; }
/** * @inheritdoc */ public function beforeSave($insert) { if ($insert) { $this->setClientAttributes(); $this->setModelAttributes(); } if (parent::beforeSave($insert)) { $this->item_key = $this->generateKey(); return true; } else { return false; } }
/** * @inheritdoc */ public function fields() { $arr = parent::fields(); $disabled = ["auth_key", "password_hash", "password_reset_token"]; return array_diff($arr, $disabled); }
/** * @inheritdoc */ public function rules() { $parent = parent::rules(); $parent[] = ['sort', 'default', 'value' => 500]; return $parent; }
/** * @inheritdoc */ public function __get($name) { $val = parent::__get($name); if ($name == "includes" and !empty($val)) { $this->sortIncludes($val, $this->id); } return $val; }
/** * @inheritdoc */ public function rules() { $rules = parent::rules(); return $rules; }