From: fomichev Date: Fri, 14 Feb 2025 10:00:28 +0000 (+0300) Subject: Добавление функционала адресов ресурсов X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=9b0b7299ad5eb773522d7acc7f08fca4886ee232;p=erp24_rep%2Fyii-erp24%2F.git Добавление функционала адресов ресурсов --- diff --git a/erp24/controllers/WikiController.php b/erp24/controllers/WikiController.php index 50d7d5ac..e38e3bba 100644 --- a/erp24/controllers/WikiController.php +++ b/erp24/controllers/WikiController.php @@ -72,6 +72,23 @@ class WikiController extends Controller return $tree; } + public function actionShowDoc() + { + $returnUrl = Yii::$app->request->get('returnUrl'); + + if (!empty($returnUrl)) { + $resourceLink = explode('/', $returnUrl); + $resourceLink = $resourceLink[1]; + $wikiArticle = WikiArticle::findOne(['resource_link' => $resourceLink]); + if($wikiArticle) { + $category = WikiCategory::findOne(['id' => $wikiArticle->category_id]); + return $this->redirect('/wiki/'. $category->slug . '/' . $wikiArticle->slug); + } + } + + return $this->redirect('/wiki'); + } + /** * Displays a single WikiArticle model. * @param int $id ID статьи diff --git a/erp24/records/WikiArticle.php b/erp24/records/WikiArticle.php index e4004294..35dfd078 100644 --- a/erp24/records/WikiArticle.php +++ b/erp24/records/WikiArticle.php @@ -20,7 +20,7 @@ use yii\helpers\Inflector; * @property int $created_by Кем создано * @property string|null $updated_at Дата обновления * @property int|null $updated_by Кем обновлено - * + * @property string $resource_link Ссылка на ресурс * @property WikiCategory $category */ class WikiArticle extends \yii\db\ActiveRecord @@ -63,9 +63,9 @@ class WikiArticle extends \yii\db\ActiveRecord [[ 'title', 'category_id', 'content' ], 'required'], [['category_id', 'created_by', 'updated_by'], 'default', 'value' => null], [['category_id', 'created_by', 'updated_by'], 'integer'], - [['slug', 'created_at', 'created_by'], 'safe'], + [['slug', 'created_at', 'created_by', 'resource_link'], 'safe'], [['description', 'content'], 'string'], - [['slug', 'title', 'created_at', 'updated_at'], 'string', 'max' => 255], + [['slug', 'title', 'created_at', 'updated_at', 'resource_link'], 'string', 'max' => 255], [['slug'], 'unique'], [['category_id'], 'exist', 'skipOnError' => true, 'targetClass' => WikiCategory::class, 'targetAttribute' => ['category_id' => 'id']], ]; @@ -87,6 +87,7 @@ class WikiArticle extends \yii\db\ActiveRecord 'created_by' => 'Кем создано', 'updated_at' => 'Дата обновления', 'updated_by' => 'Кем обновлено', + 'resource_link' => 'Ссылка на ресурс' ]; } diff --git a/erp24/views/store-city-list/index.php b/erp24/views/store-city-list/index.php index 100a8292..0dc141d0 100644 --- a/erp24/views/store-city-list/index.php +++ b/erp24/views/store-city-list/index.php @@ -22,7 +22,7 @@ $this->params['breadcrumbs'][] = $this->title; Yii::$app->request->url] ), ['class' => 'ms-3', 'target' => '_blank', 'title' => 'Открыть документацию'] ) ?> diff --git a/erp24/views/wiki/_form.php b/erp24/views/wiki/_form.php index 303306a6..b5469ee7 100644 --- a/erp24/views/wiki/_form.php +++ b/erp24/views/wiki/_form.php @@ -44,6 +44,11 @@ $categoryList = getCategoriesWithHierarchy($categories); ['prompt' => 'Выберите родительскую категорию'] ) ?> + field($model, 'resource_link')->textInput(['maxlength' => true]) + ->label('Ссылка на ресурс') + ->hint('Основная часть адреса целевого ресурса для документации, + например - store-city-list из /store-city-list без index') ?> + field($model, 'description')->textarea(['rows' => 3]) ?> field($model, 'content')->hiddenInput()->label('Содержание') ?>