diff --git a/composer.json b/composer.json index c4a4b2f..00bbe7e 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,8 @@ "ext-zip": "*", "josantonius/session": "^2.0", "firebase/php-jwt": "^6.10", - "k-adam/env-editor": "^2.0" + "k-adam/env-editor": "^2.0", + "guzzlehttp/guzzle": "^7.9" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index c36242c..da515a7 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "da3890f2b5b477bf758306141b8c8583", + "content-hash": "9b8653e1a4f451d6e125cb1732ffdeef", "packages": [ { "name": "brick/math", @@ -398,6 +398,331 @@ ], "time": "2024-07-20T21:45:45+00:00" }, + { + "name": "guzzlehttp/guzzle", + "version": "7.9.2", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "d281ed313b989f213357e3be1a179f02196ac99b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/d281ed313b989f213357e3be1a179f02196ac99b", + "reference": "d281ed313b989f213357e3be1a179f02196ac99b", + "shasum": "" + }, + "require": { + "ext-json": "*", + "guzzlehttp/promises": "^1.5.3 || ^2.0.3", + "guzzlehttp/psr7": "^2.7.0", + "php": "^7.2.5 || ^8.0", + "psr/http-client": "^1.0", + "symfony/deprecation-contracts": "^2.2 || ^3.0" + }, + "provide": { + "psr/http-client-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "ext-curl": "*", + "guzzle/client-integration-tests": "3.0.2", + "php-http/message-factory": "^1.1", + "phpunit/phpunit": "^8.5.39 || ^9.6.20", + "psr/log": "^1.1 || ^2.0 || ^3.0" + }, + "suggest": { + "ext-curl": "Required for CURL handler support", + "ext-intl": "Required for Internationalized Domain Name (IDN) support", + "psr/log": "Required for using the Log middleware" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Jeremy Lindblom", + "email": "jeremeamia@gmail.com", + "homepage": "https://github.com/jeremeamia" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "psr-18", + "psr-7", + "rest", + "web service" + ], + "support": { + "issues": "https://github.com/guzzle/guzzle/issues", + "source": "https://github.com/guzzle/guzzle/tree/7.9.2" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle", + "type": "tidelift" + } + ], + "time": "2024-07-24T11:22:20+00:00" + }, + { + "name": "guzzlehttp/promises", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/f9c436286ab2892c7db7be8c8da4ef61ccf7b455", + "reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "phpunit/phpunit": "^8.5.39 || ^9.6.20" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "support": { + "issues": "https://github.com/guzzle/promises/issues", + "source": "https://github.com/guzzle/promises/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises", + "type": "tidelift" + } + ], + "time": "2024-10-17T10:06:22+00:00" + }, + { + "name": "guzzlehttp/psr7", + "version": "2.7.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "a70f5c95fb43bc83f07c9c948baa0dc1829bf201" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/a70f5c95fb43bc83f07c9c948baa0dc1829bf201", + "reference": "a70f5c95fb43bc83f07c9c948baa0dc1829bf201", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.1 || ^2.0", + "ralouphie/getallheaders": "^3.0" + }, + "provide": { + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "http-interop/http-factory-tests": "0.9.0", + "phpunit/phpunit": "^8.5.39 || ^9.6.20" + }, + "suggest": { + "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "support": { + "issues": "https://github.com/guzzle/psr7/issues", + "source": "https://github.com/guzzle/psr7/tree/2.7.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", + "type": "tidelift" + } + ], + "time": "2024-07-18T11:15:46+00:00" + }, { "name": "illuminate/collections", "version": "v11.28.1", @@ -1458,6 +1783,166 @@ }, "time": "2021-11-05T16:47:00+00:00" }, + { + "name": "psr/http-client", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "support": { + "source": "https://github.com/php-fig/http-client" + }, + "time": "2023-09-23T14:17:50+00:00" + }, + { + "name": "psr/http-factory", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "shasum": "" + }, + "require": { + "php": ">=7.1", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "PSR-17: Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-factory" + }, + "time": "2024-04-15T12:06:14+00:00" + }, + { + "name": "psr/http-message", + "version": "2.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/2.0" + }, + "time": "2023-04-04T09:54:51+00:00" + }, { "name": "psr/simple-cache", "version": "3.0.0", @@ -1555,6 +2040,50 @@ }, "time": "2020-08-27T05:07:01+00:00" }, + { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "support": { + "issues": "https://github.com/ralouphie/getallheaders/issues", + "source": "https://github.com/ralouphie/getallheaders/tree/develop" + }, + "time": "2019-03-08T08:55:37+00:00" + }, { "name": "samejack/php-argv", "version": "dev-master", @@ -2676,5 +3205,5 @@ "ext-zip": "*" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/kernel/IGTabel/action_column/InstallActionColumn.php b/kernel/IGTabel/action_column/InstallActionColumn.php new file mode 100644 index 0000000..4e64b56 --- /dev/null +++ b/kernel/IGTabel/action_column/InstallActionColumn.php @@ -0,0 +1,17 @@ +baseUrl . $this->prefix . $this->id; + return " Установить "; + } +} \ No newline at end of file diff --git a/kernel/controllers/ModuleController.php b/kernel/controllers/ModuleController.php index 323a537..2626620 100644 --- a/kernel/controllers/ModuleController.php +++ b/kernel/controllers/ModuleController.php @@ -7,6 +7,7 @@ use Josantonius\Session\Facades\Session; use kernel\AdminController; use kernel\helpers\Debug; use kernel\models\Option; +use kernel\modules\module_shop_client\services\ModuleShopClientService; use kernel\modules\user\service\UserService; use kernel\Request; use kernel\services\ModuleService; @@ -52,6 +53,11 @@ class ModuleController extends AdminController $i++; } } +// foreach (ModuleShopClientService::getModuleShopClientInfo() as $module) { +// $module->id = $i++; +// $modules_info[] = $module; +// } + $module_count = count($modules_info); $modules_info = array_slice($modules_info, $per_page*($page_number-1), $per_page); $this->cgView->render("index.php", [ @@ -61,6 +67,7 @@ class ModuleController extends AdminController 'module_count' => $module_count, 'per_page' => $per_page, ]); + } public function actionActivate(): void diff --git a/kernel/modules/module_shop_client/ModuleShopClientModule.php b/kernel/modules/module_shop_client/ModuleShopClientModule.php new file mode 100644 index 0000000..2bae379 --- /dev/null +++ b/kernel/modules/module_shop_client/ModuleShopClientModule.php @@ -0,0 +1,32 @@ +menuService = new MenuService(); + } + + /** + * @throws \Exception + */ + public function init(): void + { + $this->menuService->createItem([ + "label" => "Магазин модулей", + "url" => "/admin/module_shop_client", + "slug" => "module_shop_client", + ]); + } + + public function deactivate(): void + { + $this->menuService->removeItemBySlug("module_shop_client"); + } +} \ No newline at end of file diff --git a/kernel/modules/module_shop_client/controllers/ModuleShopClientController.php b/kernel/modules/module_shop_client/controllers/ModuleShopClientController.php new file mode 100644 index 0000000..0162d6e --- /dev/null +++ b/kernel/modules/module_shop_client/controllers/ModuleShopClientController.php @@ -0,0 +1,72 @@ +cgView->viewPath = KERNEL_MODULES_DIR . "/module_shop_client/views/"; + + $this->client = new Client(); + $this->moduleService = new ModuleService(); + } + public function actionIndex(int $page_number = 1): void + { + $per_page = 8; + + $token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.W10.POQZmGB7EZIayINtYhzu5r1rdgZhF9qPJpaQkl_g6pU'; + $modules_info = $this->client->request('GET', 'http://igfs.loc/api/module_shop/gb_slug', [ + 'headers' => [ + 'Authorization' => 'Bearer ' . $token, + ] + ]); + $modules_info = json_decode($modules_info->getBody()->getContents(), true); + $module_count = count($modules_info); + $modules_info = array_slice($modules_info, $per_page*($page_number-1), $per_page); + $this->cgView->render("index.php", [ + 'modules_info' => $modules_info, + 'page_number' => $page_number, + 'module_count' => $module_count, + 'per_page' => $per_page, + ]); + } + + public function actionView(int $id): void + { + $token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.W10.POQZmGB7EZIayINtYhzu5r1rdgZhF9qPJpaQkl_g6pU'; + $module_info = $this->client->request('GET', 'http://igfs.loc/api/module_shop/' . $id, [ + 'headers' => [ + 'Authorization' => 'Bearer ' . $token, + ] + ]); + $module_info = json_decode($module_info->getBody()->getContents(), true); + $this->cgView->render("view.php", ['data' => $module_info]); + } + + public function actionInstall(int $id): void + { + $token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.W10.POQZmGB7EZIayINtYhzu5r1rdgZhF9qPJpaQkl_g6pU'; + $module_info = $this->client->request('GET', 'http://igfs.loc/api/module_shop/' . $id, [ + 'headers' => [ + 'Authorization' => 'Bearer ' . $token, + ] + ]); + $module_info = json_decode($module_info->getBody()->getContents(), true); + Debug::dd($module_info['path_to_archive']); + $this->moduleService->installModule($module_info['path_to_archive']); + + } + +} \ No newline at end of file diff --git a/kernel/modules/module_shop_client/manifest.json b/kernel/modules/module_shop_client/manifest.json new file mode 100644 index 0000000..2b84e36 --- /dev/null +++ b/kernel/modules/module_shop_client/manifest.json @@ -0,0 +1,12 @@ +{ + "name": "Module shop client", + "version": "0.1", + "author": "ITGuild", + "slug": "module_shop_client", + "description": "Module shop client module", + "module_class": "kernel\\modules\\module_shop_client\\ModuleShopClientModule", + "module_class_file": "{KERNEL_MODULES}/module_shop_client/ModuleShopClientModule.php", + "routs": "routs/module_shop_client.php", + "migration_path": "migrations", + "dependence": "menu" +} \ No newline at end of file diff --git a/kernel/modules/module_shop_client/routs/module_shop_client.php b/kernel/modules/module_shop_client/routs/module_shop_client.php new file mode 100644 index 0000000..52e87f1 --- /dev/null +++ b/kernel/modules/module_shop_client/routs/module_shop_client.php @@ -0,0 +1,29 @@ +filter('bearer', [\kernel\modules\secure\middlewares\BearerAuthMiddleware::class, "handler"]); + +App::$collector->group(["prefix" => "admin"], function (RouteCollector $router){ + App::$collector->group(["before" => "auth"], function (RouteCollector $router) { + App::$collector->group(["prefix" => "module_shop_client"], function (RouteCollector $router) { + App::$collector->get('/', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::class, 'actionIndex']); + App::$collector->get('/page/{page_number}', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::class, 'actionIndex']); + App::$collector->get('/install/{id}', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::class, 'actionInstall']); +// App::$collector->get('/create', [\kernel\modules\post\controllers\PostController::class, 'actionCreate']); +// App::$collector->post("/", [\kernel\modules\post\controllers\PostController::class, 'actionAdd']); + App::$collector->get('/{id}', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::class, 'actionView']); +// App::$collector->any('/update/{id}', [\kernel\modules\post\controllers\PostController::class, 'actionUpdate']); +// App::$collector->any("/edit/{id}", [\kernel\modules\post\controllers\PostController::class, 'actionEdit']); +// App::$collector->get('/delete/{id}', [\kernel\modules\post\controllers\PostController::class, 'actionDelete']); + }); + }); +}); + +//App::$collector->group(["prefix" => "api"], function (CgRouteCollector $router){ +// App::$collector->group(['before' => 'bearer'], function (CgRouteCollector $router){ +// $router->rest("post", [\kernel\modules\post\controllers\PostRestController::class]); +// }); +//}); \ No newline at end of file diff --git a/kernel/modules/module_shop_client/services/ModuleShopClientService.php b/kernel/modules/module_shop_client/services/ModuleShopClientService.php new file mode 100644 index 0000000..02517b4 --- /dev/null +++ b/kernel/modules/module_shop_client/services/ModuleShopClientService.php @@ -0,0 +1,57 @@ +request('GET', 'http://igfs.loc/api/module_shop/gb_slug', [ + 'headers' => [ + 'Authorization' => 'Bearer ' . $token, + ] + ]); + + + return json_decode($res->getBody()->getContents()); + } + + /** + * @throws \Exception + */ +// public static function getModuleShopClientTable(): ListJsonTable +// { +// $modules_info = json_decode(ModuleShopClientService::getModuleShopClientInfo()); +// +// $meta = []; +// $meta['columns'] = [ +// "name" => "Название", +// "author" => "Автор", +// "version" => "Версия", +// "description" => "Описание", +// "installations" => 'Установки', +// "views" => 'Просмотры' +// ]; +// $meta['params'] = ["class" => "table table-bordered"]; +// $meta['perPage'] = 3; +// $meta['baseUrl'] = "/admin/module_shop_client"; +// $meta['currentPage'] = 1; +// $meta['total'] = count($modules_info); +// +// $info_to_table['meta'] = $meta; +// $info_to_table['data'] = $modules_info; +// +// $table = new ListJsonTable(json_encode($info_to_table, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); +// +// $table->create(); +// return $table; +// } + +} \ No newline at end of file diff --git a/kernel/modules/module_shop_client/views/index.php b/kernel/modules/module_shop_client/views/index.php new file mode 100644 index 0000000..0dd2fd8 --- /dev/null +++ b/kernel/modules/module_shop_client/views/index.php @@ -0,0 +1,53 @@ + "Название", + "author" => "Автор", + "version" => "Версия", + "description" => "Описание", + "installations" => "Установки", + "views" => "Просмотры" +]; +$meta['params'] = ["class" => "table table-bordered"]; +$meta['perPage'] = $per_page; +$meta['baseUrl'] = "/admin/module_shop_client"; +$meta['currentPage'] = $page_number; +$meta['total'] = $module_count; + +$info_to_table['meta'] = $meta; +$info_to_table['data'] = $modules_info; + +$table = new ListJsonTable(json_encode($info_to_table, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); + + +//$table->addAction(function ($row, $url) use ($moduleService){ +// $slug = $row['slug']; +// if ($moduleService->isActive($slug)){ +// $label = "Деактивировать"; +// $btn_type = "warning"; +// $btn = "$label"; +// +// } +// else { +// $label = "Активировать"; +// $btn_type = "primary"; +// $btn = "$label"; +// } +// +// return $btn; +//}); + +$table->addAction(\kernel\IGTabel\action_column\ViewActionColumn::class); +$table->addAction(\kernel\IGTabel\action_column\InstallActionColumn::class); + +$table->create(); +$table->render(); diff --git a/kernel/modules/module_shop_client/views/view.php b/kernel/modules/module_shop_client/views/view.php new file mode 100644 index 0000000..05bcc51 --- /dev/null +++ b/kernel/modules/module_shop_client/views/view.php @@ -0,0 +1,32 @@ + [ + "rows" => [ + "name" => "Название", + "author" => "Автор", + "version" => "Версия", + "description" => "Описание", + "installations" => "Установки", + "views" => "Просмотры" + ], + "params" => ["class" => "table table-bordered"], + "baseUrl" => "/admin/module_shop_client", + ], + "data" => $data +]; +$table = new \Itguild\Tables\ViewJsonTable(json_encode($table_info, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); + +$table->beforePrint(function () { + $btn = PrimaryBtn::create("Список", "/admin/module_shop_client")->fetch(); + return $btn; +}); +$table->create(); +$table->render(); \ No newline at end of file