module shop client

This commit is contained in:
Билай Станислав 2024-10-29 14:53:52 +03:00
parent 8eae977357
commit 9d243b5b35
11 changed files with 844 additions and 3 deletions

View File

@ -17,7 +17,8 @@
"ext-zip": "*", "ext-zip": "*",
"josantonius/session": "^2.0", "josantonius/session": "^2.0",
"firebase/php-jwt": "^6.10", "firebase/php-jwt": "^6.10",
"k-adam/env-editor": "^2.0" "k-adam/env-editor": "^2.0",
"guzzlehttp/guzzle": "^7.9"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

533
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "da3890f2b5b477bf758306141b8c8583", "content-hash": "9b8653e1a4f451d6e125cb1732ffdeef",
"packages": [ "packages": [
{ {
"name": "brick/math", "name": "brick/math",
@ -398,6 +398,331 @@
], ],
"time": "2024-07-20T21:45:45+00:00" "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", "name": "illuminate/collections",
"version": "v11.28.1", "version": "v11.28.1",
@ -1458,6 +1783,166 @@
}, },
"time": "2021-11-05T16:47:00+00:00" "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", "name": "psr/simple-cache",
"version": "3.0.0", "version": "3.0.0",
@ -1555,6 +2040,50 @@
}, },
"time": "2020-08-27T05:07:01+00:00" "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", "name": "samejack/php-argv",
"version": "dev-master", "version": "dev-master",
@ -2676,5 +3205,5 @@
"ext-zip": "*" "ext-zip": "*"
}, },
"platform-dev": [], "platform-dev": [],
"plugin-api-version": "2.3.0" "plugin-api-version": "2.6.0"
} }

View File

@ -0,0 +1,17 @@
<?php
namespace kernel\IGTabel\action_column;
use Itguild\Tables\ActionColumn\ActionColumn;
class InstallActionColumn extends ActionColumn
{
protected string $prefix = '/install/';
public function fetch()
{
$link = $this->baseUrl . $this->prefix . $this->id;
return " <a href='$link' class='btn btn-warning'>Установить</a> ";
}
}

View File

@ -7,6 +7,7 @@ use Josantonius\Session\Facades\Session;
use kernel\AdminController; use kernel\AdminController;
use kernel\helpers\Debug; use kernel\helpers\Debug;
use kernel\models\Option; use kernel\models\Option;
use kernel\modules\module_shop_client\services\ModuleShopClientService;
use kernel\modules\user\service\UserService; use kernel\modules\user\service\UserService;
use kernel\Request; use kernel\Request;
use kernel\services\ModuleService; use kernel\services\ModuleService;
@ -52,6 +53,11 @@ class ModuleController extends AdminController
$i++; $i++;
} }
} }
// foreach (ModuleShopClientService::getModuleShopClientInfo() as $module) {
// $module->id = $i++;
// $modules_info[] = $module;
// }
$module_count = count($modules_info); $module_count = count($modules_info);
$modules_info = array_slice($modules_info, $per_page*($page_number-1), $per_page); $modules_info = array_slice($modules_info, $per_page*($page_number-1), $per_page);
$this->cgView->render("index.php", [ $this->cgView->render("index.php", [
@ -61,6 +67,7 @@ class ModuleController extends AdminController
'module_count' => $module_count, 'module_count' => $module_count,
'per_page' => $per_page, 'per_page' => $per_page,
]); ]);
} }
public function actionActivate(): void public function actionActivate(): void

View File

@ -0,0 +1,32 @@
<?php
namespace kernel\modules\module_shop_client;
use kernel\Module;
use kernel\modules\menu\service\MenuService;
class ModuleShopClientModule extends Module
{
public MenuService $menuService;
public function __construct()
{
$this->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");
}
}

View File

@ -0,0 +1,72 @@
<?php
namespace kernel\modules\module_shop_client\controllers;
use GuzzleHttp\Client;
use kernel\AdminController;
use kernel\helpers\Debug;
use kernel\modules\module_shop_client\services\ModuleShopClientService;
use kernel\services\ModuleService;
class ModuleShopClientController extends AdminController
{
protected Client $client;
protected ModuleService $moduleService;
protected function init(): void
{
parent::init();
$this->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']);
}
}

View File

@ -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"
}

View File

@ -0,0 +1,29 @@
<?php
use kernel\App;
use kernel\CgRouteCollector;
use Phroute\Phroute\RouteCollector;
App::$collector->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]);
// });
//});

View File

@ -0,0 +1,57 @@
<?php
namespace kernel\modules\module_shop_client\services;
use GuzzleHttp\Client;
use Itguild\Tables\ListJsonTable;
use kernel\services\ModuleService;
class ModuleShopClientService extends ModuleService
{
public static function getModuleShopClientInfo()
{
$client = new Client();
$token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.W10.POQZmGB7EZIayINtYhzu5r1rdgZhF9qPJpaQkl_g6pU';
$res = $client->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;
// }
}

View File

@ -0,0 +1,53 @@
<?php
/**
* @var array $modules_info
* @var int $module_count
* @var int $page_number
* @var int $per_page
*/
use Itguild\Tables\ListJsonTable;
$meta = [];
$meta['columns'] = [
"name" => "Название",
"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 = "<a class='btn btn-$btn_type' href='$url/deactivate/?slug=$slug' style='margin: 3px; width: 150px;' >$label</a>";
//
// }
// else {
// $label = "Активировать";
// $btn_type = "primary";
// $btn = "<a class='btn btn-$btn_type' href='$url/activate/?slug=$slug' style='margin: 3px; width: 150px;' >$label</a>";
// }
//
// return $btn;
//});
$table->addAction(\kernel\IGTabel\action_column\ViewActionColumn::class);
$table->addAction(\kernel\IGTabel\action_column\InstallActionColumn::class);
$table->create();
$table->render();

View File

@ -0,0 +1,32 @@
<?php
/**
* @var array $data
*/
use kernel\IGTabel\btn\DangerBtn;
use kernel\IGTabel\btn\PrimaryBtn;
use kernel\IGTabel\btn\SuccessBtn;
$table_info = [
"meta" => [
"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();