From 42ab26a3db1cef8319985fc3a0f5d23d2dff4e3b Mon Sep 17 00:00:00 2001 From: Kavalar Date: Mon, 27 May 2024 12:59:44 +0300 Subject: [PATCH] to composer --- .gitignore | 2 ++ composer.json | 18 ++++++++++++++ examples/simple.json | 15 ++++++++++++ examples/simple.php | 11 +++++++++ index.php | 11 +++++++++ simple.json | 14 +++++++++++ ListJsonTable.php => src/ListJsonTable.php | 15 ++++++------ Pagination.php => src/Pagination.php | 3 +-- ViewJsonTable.php => src/ViewJsonTable.php | 5 ++-- {actionBtn => src/actionBtn}/ActionBtn.php | 2 +- {actionBtn => src/actionBtn}/ToDeleteBtn.php | 2 +- {actionBtn => src/actionBtn}/ToEditBtn.php | 2 +- {actionBtn => src/actionBtn}/ToListBtn.php | 2 +- .../actionColumn}/ActionColumn.php | 2 +- .../actionColumn}/DeleteActionColumn.php | 2 +- .../actionColumn}/EditActionColumn.php | 2 +- .../actionColumn}/ViewActionColumn.php | 2 +- src/traits/CreateOption.php | 21 ++++++++++++++++ src/traits/CreateParams.php | 24 +++++++++++++++++++ 19 files changed, 134 insertions(+), 21 deletions(-) create mode 100644 .gitignore create mode 100644 composer.json create mode 100644 examples/simple.json create mode 100644 examples/simple.php create mode 100644 index.php create mode 100644 simple.json rename ListJsonTable.php => src/ListJsonTable.php (92%) rename Pagination.php => src/Pagination.php (96%) rename ViewJsonTable.php => src/ViewJsonTable.php (95%) rename {actionBtn => src/actionBtn}/ActionBtn.php (88%) rename {actionBtn => src/actionBtn}/ToDeleteBtn.php (86%) rename {actionBtn => src/actionBtn}/ToEditBtn.php (86%) rename {actionBtn => src/actionBtn}/ToListBtn.php (86%) rename {ActionColumn => src/actionColumn}/ActionColumn.php (86%) rename {ActionColumn => src/actionColumn}/DeleteActionColumn.php (86%) rename {ActionColumn => src/actionColumn}/EditActionColumn.php (87%) rename {ActionColumn => src/actionColumn}/ViewActionColumn.php (86%) create mode 100755 src/traits/CreateOption.php create mode 100755 src/traits/CreateParams.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0dca145 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/vendor/ +.idea diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..0cf08ef --- /dev/null +++ b/composer.json @@ -0,0 +1,18 @@ +{ + "name": "itguild/tables", + "type": "library", + "license": "MIT", + "autoload": { + "psr-4": { + "Itguild\\Tables\\": "src/" + } + }, + "authors": [ + { + "name": "Kavalar", + "email": "apuc06@mail.ru" + } + ], + "minimum-stability": "dev", + "require": {} +} diff --git a/examples/simple.json b/examples/simple.json new file mode 100644 index 0000000..824a44f --- /dev/null +++ b/examples/simple.json @@ -0,0 +1,15 @@ +{ + "meta": { + "title": "forma 1", + "columns": { + "email": "Email", + "description": "Описание 1", + "description2": "Описание 2" + }, + "params": {"class": "table table-bordered", "border": "1"} + }, + "data": [ + {"email":"fas@mail.ru","description":"fafdgdfs","description2":"ffdghdas"}, + + ] +} \ No newline at end of file diff --git a/examples/simple.php b/examples/simple.php new file mode 100644 index 0000000..c52961d --- /dev/null +++ b/examples/simple.php @@ -0,0 +1,11 @@ +create(); +$table->render(); \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..b09e7b2 --- /dev/null +++ b/index.php @@ -0,0 +1,11 @@ +create(); +$table->render(); \ No newline at end of file diff --git a/simple.json b/simple.json new file mode 100644 index 0000000..5567772 --- /dev/null +++ b/simple.json @@ -0,0 +1,14 @@ +{ + "meta": { + "title": "forma 1", + "columns": { + "email": "Email", + "description": "Описание 1", + "description2": "Описание 2" + }, + "params": {"class": "table table-bordered", "border": "1"} + }, + "data": [ + {"id":1, "email":"fas@mail.ru","description":"fafdgdfs","description2":"ffdghdas"} + ] +} \ No newline at end of file diff --git a/ListJsonTable.php b/src/ListJsonTable.php similarity index 92% rename from ListJsonTable.php rename to src/ListJsonTable.php index db9312f..2f448cd 100644 --- a/ListJsonTable.php +++ b/src/ListJsonTable.php @@ -1,13 +1,11 @@ beforePrintCell = false; + $this->beforePrint = function (){}; $this->json = $json; $this->data = json_decode($this->json, true); - $this->baseUrl = $this->data['meta']['baseUrl'] ?? null; + $this->baseUrl = $this->data['meta']['baseUrl'] ?? ''; $this->setActions(); } diff --git a/Pagination.php b/src/Pagination.php similarity index 96% rename from Pagination.php rename to src/Pagination.php index c6d51a4..84fe770 100644 --- a/Pagination.php +++ b/src/Pagination.php @@ -1,8 +1,7 @@ $title){ + $selected = (int)$value === $val ? "selected" : ""; + $optionsString .= ""; + } + return $optionsString; + } +} \ No newline at end of file diff --git a/src/traits/CreateParams.php b/src/traits/CreateParams.php new file mode 100755 index 0000000..6bccd4a --- /dev/null +++ b/src/traits/CreateParams.php @@ -0,0 +1,24 @@ + $param){ + if(is_string($param)){ + $paramsString .= $key . "='" . $param . "'"; + } + } + + return $paramsString; + } + +} \ No newline at end of file