]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Добавление функционала адресов ресурсов
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Fri, 14 Feb 2025 10:00:28 +0000 (13:00 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Fri, 14 Feb 2025 10:00:28 +0000 (13:00 +0300)
erp24/controllers/WikiController.php
erp24/records/WikiArticle.php
erp24/views/store-city-list/index.php
erp24/views/wiki/_form.php

index 50d7d5ac185d0d1c5f2ca4a4aa9d7a38f169da16..e38e3bba2a8e7299b65ed302523a7614391c4d8d 100644 (file)
@@ -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 статьи
index e400429436932f442edd850a66b1b6e82cb75d9b..35dfd0780ff665b6f905eda141e7ab2ead6353a6 100644 (file)
@@ -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' => 'Ссылка на ресурс'
         ];
     }
 
index 100a82927acc4a8c1d2c6d937616109dff3866c6..0dc141d098b5cc4a85af81210160eecdd6f1be0f 100644 (file)
@@ -22,7 +22,7 @@ $this->params['breadcrumbs'][] = $this->title;
             <?= Html::a(
                 '📖 Документация',
                 Url::to(
-                    '/wiki/magaziny/spravocnik-po-gorodam-i-rajonam'
+                    ['wiki/show-doc', 'returnUrl' => Yii::$app->request->url]
                 ),
                 ['class' => 'ms-3', 'target' => '_blank', 'title' => 'Открыть документацию']
             ) ?>
index 303306a66af93369743ccb9ec71db5f3169bdb14..b5469ee7891211f20c5f912e63053386fb4474da 100644 (file)
@@ -44,6 +44,11 @@ $categoryList = getCategoriesWithHierarchy($categories);
         ['prompt' => 'Выберите родительскую категорию']
     ) ?>
 
+    <?= $form->field($model, 'resource_link')->textInput(['maxlength' => true])
+        ->label('Ссылка на ресурс')
+        ->hint('Основная часть адреса целевого ресурса для документации,
+         например - store-city-list из /store-city-list без index') ?>
+
     <?= $form->field($model, 'description')->textarea(['rows' => 3]) ?>
 
     <?= $form->field($model, 'content')->hiddenInput()->label('Содержание') ?>