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