From 524db91d4797856e3395e4c4fcd7f6c2391a799c Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 9 Oct 2016 20:07:30 +0200 Subject: [PATCH 1/9] Fix install --- Admin/Install/Navigation.php | 2 +- Admin/Installer.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Admin/Install/Navigation.php b/Admin/Install/Navigation.php index aa1aef1..597b937 100644 --- a/Admin/Install/Navigation.php +++ b/Admin/Install/Navigation.php @@ -29,7 +29,7 @@ use phpOMS\DataStorage\Database\Pool; */ class Navigation { - public static function install(Pool $dbPool) + public static function install(string $path, Pool $dbPool) { $navData = json_decode(file_get_contents(__DIR__ . '/Navigation.install.json'), true); diff --git a/Admin/Installer.php b/Admin/Installer.php index 51c1884..7ce9811 100644 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -37,9 +37,9 @@ class Installer extends InstallerAbstract /** * {@inheritdoc} */ - public static function install(Pool $dbPool, InfoManager $info) + public static function install(string $path, Pool $dbPool, InfoManager $info) { - parent::install($dbPool, $info); + parent::install($path, $dbPool, $info); switch ($dbPool->get('core')->getType()) { case DatabaseType::MYSQL: From 3f6672eb42c4a22f414633b1b5429b1cd2d6727e Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 29 Oct 2016 20:44:52 +0200 Subject: [PATCH 2/9] Adjust database pool name --- Admin/Activate.php | 4 ++-- Admin/Deactivate.php | 4 ++-- Admin/Install/Navigation.php | 4 ++-- Admin/Installer.php | 4 ++-- Admin/Uninstall.php | 4 ++-- Admin/Update.php | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Admin/Activate.php b/Admin/Activate.php index 7cad9a2..c9e45cf 100644 --- a/Admin/Activate.php +++ b/Admin/Activate.php @@ -16,7 +16,7 @@ namespace Modules\Draw\Admin; -use phpOMS\DataStorage\Database\Pool; +use phpOMS\DataStorage\Database\DatabasePool; use phpOMS\Module\ActivateAbstract; use phpOMS\Module\InfoManager; @@ -37,7 +37,7 @@ class Activate extends ActivateAbstract /** * {@inheritdoc} */ - public static function activate(Pool $dbPool, InfoManager $info) + public static function activate(DatabasePool $dbPool, InfoManager $info) { parent::activate($dbPool, $info); } diff --git a/Admin/Deactivate.php b/Admin/Deactivate.php index 7859f29..dbd55e5 100644 --- a/Admin/Deactivate.php +++ b/Admin/Deactivate.php @@ -16,7 +16,7 @@ namespace Modules\Draw\Admin; -use phpOMS\DataStorage\Database\Pool; +use phpOMS\DataStorage\Database\DatabasePool; use phpOMS\Module\DeactivateAbstract; use phpOMS\Module\InfoManager; @@ -37,7 +37,7 @@ class Deactivate extends DeactivateAbstract /** * {@inheritdoc} */ - public static function deactivate(Pool $dbPool, InfoManager $info) + public static function deactivate(DatabasePool $dbPool, InfoManager $info) { parent::deactivate($dbPool, $info); } diff --git a/Admin/Install/Navigation.php b/Admin/Install/Navigation.php index 597b937..c24b762 100644 --- a/Admin/Install/Navigation.php +++ b/Admin/Install/Navigation.php @@ -14,7 +14,7 @@ * @link http://orange-management.com */ namespace Modules\Draw\Admin\Install; -use phpOMS\DataStorage\Database\Pool; +use phpOMS\DataStorage\Database\DatabasePool; /** * Navigation class. @@ -29,7 +29,7 @@ use phpOMS\DataStorage\Database\Pool; */ class Navigation { - public static function install(string $path, Pool $dbPool) + public static function install(string $path, DatabasePool $dbPool) { $navData = json_decode(file_get_contents(__DIR__ . '/Navigation.install.json'), true); diff --git a/Admin/Installer.php b/Admin/Installer.php index 7ce9811..fbe6380 100644 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -16,7 +16,7 @@ namespace Modules\Draw\Admin; use phpOMS\DataStorage\Database\DatabaseType; -use phpOMS\DataStorage\Database\Pool; +use phpOMS\DataStorage\Database\DatabasePool; use phpOMS\Module\InfoManager; use phpOMS\Module\InstallerAbstract; @@ -37,7 +37,7 @@ class Installer extends InstallerAbstract /** * {@inheritdoc} */ - public static function install(string $path, Pool $dbPool, InfoManager $info) + public static function install(string $path, DatabasePool $dbPool, InfoManager $info) { parent::install($path, $dbPool, $info); diff --git a/Admin/Uninstall.php b/Admin/Uninstall.php index 82639f6..817a401 100644 --- a/Admin/Uninstall.php +++ b/Admin/Uninstall.php @@ -16,7 +16,7 @@ namespace Modules\Draw\Admin; -use phpOMS\DataStorage\Database\Pool; +use phpOMS\DataStorage\Database\DatabasePool; use phpOMS\Module\UninstallAbstract; /** @@ -36,7 +36,7 @@ class Uninstall extends UninstallAbstract /** * {@inheritdoc} */ - public static function uninstall(Pool $dbPool, InfoManager $info) + public static function uninstall(DatabasePool $dbPool, InfoManager $info) { parent::uninstall($dbPool, $info); } diff --git a/Admin/Update.php b/Admin/Update.php index 56498b9..77894f8 100644 --- a/Admin/Update.php +++ b/Admin/Update.php @@ -16,7 +16,7 @@ namespace Modules\Draw\Admin; -use phpOMS\DataStorage\Database\Pool; +use phpOMS\DataStorage\Database\DatabasePool; use phpOMS\Module\UpdateAbstract; use phpOMS\System\File\Directory; @@ -37,7 +37,7 @@ class Update extends UpdateAbstract /** * {@inheritdoc} */ - public static function update(Pool $dbPool, array $info) + public static function update(DatabasePool $dbPool, array $info) { Directory::deletePath(__DIR__ . '/Update'); mkdir('Update'); From 6bdc90c65e3352c202fdcc1a409349447d7941a6 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 9 Nov 2016 21:14:16 +0100 Subject: [PATCH 3/9] Fixing draw and drafting create --- Admin/Routes/Web/Api.php | 12 +++++ Controller.js | 3 ++ Controller.php | 77 ++++++++++++++++++++++++++++++- Models/DrawType.enum.js | 3 ++ Models/Editor.js | 3 ++ Theme/Backend/draw-create.tpl.php | 6 +-- Theme/backend/draw-create.tpl.php | 6 +-- 7 files changed, 103 insertions(+), 7 deletions(-) create mode 100644 Admin/Routes/Web/Api.php diff --git a/Admin/Routes/Web/Api.php b/Admin/Routes/Web/Api.php new file mode 100644 index 0000000..ca73176 --- /dev/null +++ b/Admin/Routes/Web/Api.php @@ -0,0 +1,12 @@ + [ + [ + 'dest' => '\Modules\Draw\Controller:apiDrawCreate', + 'verb' => RouteVerb::SET, + ], + ], +]; diff --git a/Controller.js b/Controller.js index 0c85129..9b750ea 100644 --- a/Controller.js +++ b/Controller.js @@ -1,5 +1,8 @@ (function (jsOMS) { "use strict"; + + /** @namespace jsOMS.Uri.UriFactory */ + jsOMS.Autoloader.defineNamespace('jsOMS.Modules.Draw'); jsOMS.Modules.Draw = function (app) { this.app = app; diff --git a/Controller.php b/Controller.php index e0e8678..515fe54 100644 --- a/Controller.php +++ b/Controller.php @@ -92,7 +92,9 @@ class Controller extends ModuleAbstract implements WebInterface { /** @var Head $head */ $head = $response->get('Content')->getData('head'); - $head->addAsset(AssetType::JS, $request->getUri()->getBase() . 'Modules/Draw/ModuleDraw.js'); + $head->addAsset(AssetType::JSLATE, $request->getUri()->getBase() . 'Modules/Draw/Controller.js'); + $head->addAsset(AssetType::JSLATE, $request->getUri()->getBase() . 'Modules/Draw/Models/DrawType.enum.js'); + $head->addAsset(AssetType::JSLATE, $request->getUri()->getBase() . 'Modules/Draw/Models/Editor.js'); } /** @@ -133,4 +135,77 @@ class Controller extends ModuleAbstract implements WebInterface return $view; } + private function validateDrawCreate(RequestAbstract $request) : array + { + $val = []; + if ( + ($val['title'] = empty($request->getData('title'))) + || ($val['image'] = empty($request->getData('plain'))) + || ($val['status'] = ( + $request->getData('status') === null + || !NewsStatus::isValidValue((int) $request->getData('status')) + )) + ) { + return $val; + } + + return []; + } + + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function apiDrawCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) + { + if (!empty($val = $this->validateDrawCreate($request))) { + $response->set('draw_create', new FormValidation($val)); + + return; + } + + $path = MediaController::createMediaPath(); + $extension = 'png'; + $filename = ''; + $rnd = ''; + + // todo: implement limit since this could get exploited + do { + $filename = sha1($request->getData('image') . $rnd); + $filename .= '.' . $extension; + + $rnd = mt_rand(); + } while (file_exists($path . '/' . $filename)); + + $fullPath = $path . '/' . $filename; + + $this->createLocalFile($fullPath, $request->getData('image')); + + $status = [ + 'path' => $path, + 'filename' => $filename, + 'size' => File::size($fullPath), + 'extension' => $extension, + ]; + + $media = MediaController::createDbEntries($status, $request->getAccount()); + $draw = Draw::fromMedia(end($media)); + + DrawMapper::create($draw); + + $response->set('image', $draw->jsonSerialize()); + } + + private function createLocalFile(string $outputPath, string $raw) : bool + { + $imageData = ImageUtils::decodeBase64Image($raw); + File::put($outputPath, $imageData); + + return true; + } + } diff --git a/Models/DrawType.enum.js b/Models/DrawType.enum.js index 5b3b4e4..976d28d 100644 --- a/Models/DrawType.enum.js +++ b/Models/DrawType.enum.js @@ -10,6 +10,9 @@ (function (jsOMS) { "use strict"; + + /** @namespace jsOMS.Uri.UriFactory */ + jsOMS.Autoloader.defineNamespace('jsOMS.Modules.Draw'); jsOMS.Modules.Draw.DrawTypeEnum = Object.freeze({ DRAW: 0, diff --git a/Models/Editor.js b/Models/Editor.js index fb5e8f9..ef555a2 100644 --- a/Models/Editor.js +++ b/Models/Editor.js @@ -1,6 +1,9 @@ (function (jsOMS) { "use strict"; + + /** @namespace jsOMS.Uri.UriFactory */ + jsOMS.Autoloader.defineNamespace('jsOMS.Modules.Draw'); jsOMS.Modules.Draw.Editor = function (editor) { diff --git a/Theme/Backend/draw-create.tpl.php b/Theme/Backend/draw-create.tpl.php index 86ae76f..49fc5c8 100644 --- a/Theme/Backend/draw-create.tpl.php +++ b/Theme/Backend/draw-create.tpl.php @@ -21,8 +21,8 @@ echo $this->getData('nav')->render(); ?>
-
- + +
@@ -63,7 +63,7 @@ echo $this->getData('nav')->render(); ?>
- +
diff --git a/Theme/backend/draw-create.tpl.php b/Theme/backend/draw-create.tpl.php index 86ae76f..49fc5c8 100644 --- a/Theme/backend/draw-create.tpl.php +++ b/Theme/backend/draw-create.tpl.php @@ -21,8 +21,8 @@ echo $this->getData('nav')->render(); ?>
-
- + +
@@ -63,7 +63,7 @@ echo $this->getData('nav')->render(); ?>
- +
From baf4c5dd17951ba8f36116154534980c4ac8bbf0 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 23 Nov 2016 23:48:27 +0100 Subject: [PATCH 4/9] [Draw] working mini draft --- Admin/Installer.php | 29 ++++++ Admin/Routes/Web/Api.php | 2 +- Admin/Routes/Web/Backend.php | 6 ++ Controller.php | 28 ++++-- Models/DrawImage.php | 154 ++++++++++++++++++++++++++++++ Models/DrawImageMapper.php | 126 ++++++++++++++++++++++++ Models/DrawType.enum.js | 2 +- Theme/backend/draw-create.tpl.php | 2 +- Theme/backend/draw-list.tpl.php | 9 +- info.json | 3 +- 10 files changed, 346 insertions(+), 15 deletions(-) create mode 100644 Models/DrawImage.php create mode 100644 Models/DrawImageMapper.php diff --git a/Admin/Installer.php b/Admin/Installer.php index fbe6380..cdb9354 100644 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -43,6 +43,35 @@ class Installer extends InstallerAbstract switch ($dbPool->get('core')->getType()) { case DatabaseType::MYSQL: + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'draw_image` ( + `draw_image_id` int(11) NOT NULL AUTO_INCREMENT, + `draw_image_media` int(11) NOT NULL, + `draw_image_path` varchar(255) NOT NULL, + PRIMARY KEY (`draw_image_id`), + KEY `draw_image_media` (`draw_image_media`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'draw_image` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'draw_image_ibfk_1` FOREIGN KEY (`draw_image_media`) REFERENCES `' . $dbPool->get('core')->prefix . 'media` (`media_id`);' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'editor_tag` ( + `editor_tag_id` int(11) NOT NULL AUTO_INCREMENT, + `editor_tag_doc` int(11) NOT NULL, + `editor_tag_tag` varchar(20) NOT NULL, + PRIMARY KEY (`editor_tag_id`), + KEY `editor_tag_doc` (`editor_tag_doc`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'editor_tag` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'editor_tag_ibfk_1` FOREIGN KEY (`editor_tag_doc`) REFERENCES `' . $dbPool->get('core')->prefix . 'draw_image` (`draw_image_id`);' + )->execute(); break; } } diff --git a/Admin/Routes/Web/Api.php b/Admin/Routes/Web/Api.php index ca73176..19c303e 100644 --- a/Admin/Routes/Web/Api.php +++ b/Admin/Routes/Web/Api.php @@ -3,7 +3,7 @@ use phpOMS\Router\RouteVerb; return [ - '^.*/backend/draw.*$' => [ + '^.*/api/draw.*$' => [ [ 'dest' => '\Modules\Draw\Controller:apiDrawCreate', 'verb' => RouteVerb::SET, diff --git a/Admin/Routes/Web/Backend.php b/Admin/Routes/Web/Backend.php index c48aa85..f5f14b2 100644 --- a/Admin/Routes/Web/Backend.php +++ b/Admin/Routes/Web/Backend.php @@ -19,4 +19,10 @@ return [ 'verb' => RouteVerb::GET, ], ], + '^.*/backend/draw/single.*$' => [ + [ + 'dest' => '\Modules\Draw\Controller:viewDrawSingle', + 'verb' => RouteVerb::GET, + ], + ], ]; diff --git a/Controller.php b/Controller.php index 515fe54..592b4f9 100644 --- a/Controller.php +++ b/Controller.php @@ -15,12 +15,19 @@ */ namespace Modules\Draw; +use Model\Message\FormValidation; +use Modules\Draw\Models\DrawImage; +use Modules\Draw\Models\DrawImageMapper; +use Modules\Media\Models\UploadStatus; use phpOMS\Asset\AssetType; use phpOMS\Message\RequestAbstract; use phpOMS\Message\ResponseAbstract; use phpOMS\Model\Html\Head; use phpOMS\Module\ModuleAbstract; use phpOMS\Module\WebInterface; +use Modules\Media\Controller as MediaController; +use phpOMS\System\File\Local\File; +use phpOMS\Utils\ImageUtils; use phpOMS\Views\View; /** @@ -132,6 +139,9 @@ class Controller extends ModuleAbstract implements WebInterface $view->setTemplate('/Modules/Draw/Theme/Backend/draw-list'); $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005201001, $request, $response)); + $images = DrawImageMapper::getNewest(25); + $view->addData('images', $images); + return $view; } @@ -140,11 +150,7 @@ class Controller extends ModuleAbstract implements WebInterface $val = []; if ( ($val['title'] = empty($request->getData('title'))) - || ($val['image'] = empty($request->getData('plain'))) - || ($val['status'] = ( - $request->getData('status') === null - || !NewsStatus::isValidValue((int) $request->getData('status')) - )) + || ($val['image'] = empty($request->getData('image'))) ) { return $val; } @@ -181,21 +187,23 @@ class Controller extends ModuleAbstract implements WebInterface $rnd = mt_rand(); } while (file_exists($path . '/' . $filename)); - $fullPath = $path . '/' . $filename; + $fullPath = __DIR__ . '/../../' . $path . '/' . $filename; $this->createLocalFile($fullPath, $request->getData('image')); $status = [ 'path' => $path, 'filename' => $filename, + 'name' => $request->getData('title'), 'size' => File::size($fullPath), 'extension' => $extension, + 'status' => UploadStatus::OK, ]; - $media = MediaController::createDbEntries($status, $request->getAccount()); - $draw = Draw::fromMedia(end($media)); - - DrawMapper::create($draw); + $media = MediaController::createDbEntry($status, $request->getAccount()); + $draw = DrawImage::fromMedia($media); + + DrawImageMapper::create($draw); $response->set('image', $draw->jsonSerialize()); } diff --git a/Models/DrawImage.php b/Models/DrawImage.php new file mode 100644 index 0000000..e5d9bcc --- /dev/null +++ b/Models/DrawImage.php @@ -0,0 +1,154 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Draw\Models; + +use Modules\Media\Models\Media; +use phpOMS\Contract\ArrayableInterface; + +/** + * News article class. + * + * @category Module + * @package Framework + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class DrawImage implements ArrayableInterface, \JsonSerializable +{ + + /** + * Article ID. + * + * @var int + * @since 1.0.0 + */ + private $id = 0; + + /** + * Doc path for organizing. + * + * @var string + * @since 1.0.0 + */ + private $path = ''; + + /** + * Media object. + * + * @var Media + * @since 1.0.0 + */ + private $media = null; + + /** + * Constructor. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function __construct() + { + } + + /** + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getId() : int + { + return $this->id; + } + + /** + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getPath() : string + { + return $this->path; + } + + /** + * @param string $path + * + * @return mixed + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setPath(string $path) + { + $this->path = $path; + } + + /** + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getMedia() + { + return $this->media; + } + + /** + * @param string $media + * + * @return mixed + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setMedia($media) + { + $this->media = $media; + } + + public function toArray() : array + { + return [ + 'id' => $this->id, + 'path' => $this->path, + 'media' => $this->media->toArray(), + ]; + } + + public function __toString() + { + return $this->jsonSerialize(); + } + + public function jsonSerialize() + { + return json_encode($this->toArray()); + } + + public static function fromMedia(Media $media) + { + $image = new self(); + $image->setMedia($media); + + return $image; + } +} diff --git a/Models/DrawImageMapper.php b/Models/DrawImageMapper.php new file mode 100644 index 0000000..85f3adc --- /dev/null +++ b/Models/DrawImageMapper.php @@ -0,0 +1,126 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Draw\Models; + +use Modules\Admin\Models\AccountMapper; +use phpOMS\DataStorage\Database\DataMapperAbstract; +use phpOMS\DataStorage\Database\Query\Builder; +use phpOMS\DataStorage\Database\Query\Column; +use phpOMS\DataStorage\Database\RelationType; + +class DrawImageMapper extends DataMapperAbstract +{ + + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + static protected $columns = [ + 'draw_image_id' => ['name' => 'draw_image_id', 'type' => 'int', 'internal' => 'id'], + 'draw_image_media' => ['name' => 'draw_image_media', 'type' => 'int', 'internal' => 'media'], + 'draw_image_path' => ['name' => 'draw_image_path', 'type' => 'string', 'internal' => 'path'], + ]; + + /** + * Has one relation. + * + * @var array + * @since 1.0.0 + */ + protected static $ownsOne = [ + 'media' => [ + 'mapper' => \Modules\Media\Models\MediaMapper::class, + 'src' => 'draw_image_media', + ], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static $table = 'draw_image'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static $primaryField = 'draw_image_id'; + + /** + * Create object. + * + * @param mixed $obj Object + * @param int $relations Behavior for relations creation + * + * @return mixed + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function create($obj, int $relations = RelationType::ALL) + { + try { + $objId = parent::create($obj, $relations); + $query = new Builder(self::$db); + $query->prefix(self::$db->getPrefix()) + ->insert( + 'account_permission_account', + 'account_permission_from', + 'account_permission_for', + 'account_permission_id1', + 'account_permission_id2', + 'account_permission_r', + 'account_permission_w', + 'account_permission_m', + 'account_permission_d', + 'account_permission_p' + ) + ->into('account_permission') + ->values($obj->getMedia()->getCreatedBy(), 'draw', 'draw', 1, $objId, 1, 1, 1, 1, 1); + + self::$db->con->prepare($query->toSql())->execute(); + } catch (\Exception $e) { + return false; + } + + return $objId; + } + + /** + * Find. + * + * @param array $columns Columns to select + * + * @return Builder + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function find(...$columns) : Builder + { + return parent::find(...$columns)->from('account_permission') + ->where('account_permission.account_permission_for', '=', 'editor') + ->where('account_permission.account_permission_id1', '=', 1) + ->where('news.news_id', '=', new Column('account_permission.account_permission_id2')) + ->where('account_permission.account_permission_r', '=', 1); + } +} diff --git a/Models/DrawType.enum.js b/Models/DrawType.enum.js index 976d28d..b5c810a 100644 --- a/Models/DrawType.enum.js +++ b/Models/DrawType.enum.js @@ -18,6 +18,6 @@ DRAW: 0, LINE: 1, RECTANGLE: 2, - CIRCLE: 3, + CIRCLE: 3 }); }(window.jsOMS = window.jsOMS || {})); diff --git a/Theme/backend/draw-create.tpl.php b/Theme/backend/draw-create.tpl.php index 49fc5c8..0bb01f3 100644 --- a/Theme/backend/draw-create.tpl.php +++ b/Theme/backend/draw-create.tpl.php @@ -22,7 +22,7 @@ echo $this->getData('nav')->render(); ?>
- +
diff --git a/Theme/backend/draw-list.tpl.php b/Theme/backend/draw-list.tpl.php index c655ce2..96151c6 100644 --- a/Theme/backend/draw-list.tpl.php +++ b/Theme/backend/draw-list.tpl.php @@ -22,6 +22,8 @@ $footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig'); $footerView->setPages(20); $footerView->setPage(1); +$images = $this->getData('images'); + echo $this->getData('nav')->render(); ?>
@@ -35,7 +37,12 @@ echo $this->getData('nav')->render(); ?> - $value) : $count++; ?> + $value) : $count++; + $url = \phpOMS\Uri\UriFactory::build('/{/lang}/backend/draw/single?id=' . $value->getId()); ?> + +
render(); ?>
getMedia()->getName(); ?> + getMedia()->getCreatedBy(); ?> + getMedia()->getCreatedAt()->format('Y-m-d'); ?>
getText('Empty', 0, 0); ?> diff --git a/info.json b/info.json index 39a23c2..ccf9c08 100644 --- a/info.json +++ b/info.json @@ -16,7 +16,8 @@ "description": "The administration module.", "directory": "Draw", "dependencies": { - "Admin" : "1.0.0" + "Admin" : "1.0.0", + "Media" : "1.0.0" }, "providing": { "Navigation": "*" From fc8a61e1b7873a82ed518d4a45bfc53ea01708df Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 23 Nov 2016 23:48:34 +0100 Subject: [PATCH 5/9] Fix paths --- Theme/Backend/draw-create.tpl.php | 2 +- Theme/Backend/draw-list.tpl.php | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Theme/Backend/draw-create.tpl.php b/Theme/Backend/draw-create.tpl.php index 49fc5c8..0bb01f3 100644 --- a/Theme/Backend/draw-create.tpl.php +++ b/Theme/Backend/draw-create.tpl.php @@ -22,7 +22,7 @@ echo $this->getData('nav')->render(); ?>
- +
diff --git a/Theme/Backend/draw-list.tpl.php b/Theme/Backend/draw-list.tpl.php index c655ce2..96151c6 100644 --- a/Theme/Backend/draw-list.tpl.php +++ b/Theme/Backend/draw-list.tpl.php @@ -22,6 +22,8 @@ $footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig'); $footerView->setPages(20); $footerView->setPage(1); +$images = $this->getData('images'); + echo $this->getData('nav')->render(); ?>
@@ -35,7 +37,12 @@ echo $this->getData('nav')->render(); ?> - $value) : $count++; ?> + $value) : $count++; + $url = \phpOMS\Uri\UriFactory::build('/{/lang}/backend/draw/single?id=' . $value->getId()); ?> + +
render(); ?>
getMedia()->getName(); ?> + getMedia()->getCreatedBy(); ?> + getMedia()->getCreatedAt()->format('Y-m-d'); ?>
getText('Empty', 0, 0); ?> From 1bef41c52264ed5b0d28e8ec4a665d2877a4c957 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 7 Dec 2016 18:59:40 +0100 Subject: [PATCH 6/9] Fixing templates --- Controller.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Controller.php b/Controller.php index 592b4f9..18fc9a0 100644 --- a/Controller.php +++ b/Controller.php @@ -123,6 +123,25 @@ class Controller extends ModuleAbstract implements WebInterface return $view; } + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return \Serializable + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function viewDrawImage(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Draw/Theme/Backend/draw-create'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005201001, $request, $response)); + + return $view; + } + /** * @param RequestAbstract $request Request * @param ResponseAbstract $response Response From 91f6d3e1c81062c7e9cc11c2623bdc43e32aa82d Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 7 Dec 2016 20:23:04 +0100 Subject: [PATCH 7/9] Prepare const visibility --- Controller.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Controller.php b/Controller.php index 18fc9a0..9ae710a 100644 --- a/Controller.php +++ b/Controller.php @@ -50,7 +50,7 @@ class Controller extends ModuleAbstract implements WebInterface * @var string * @since 1.0.0 */ - const MODULE_PATH = __DIR__; + /* public */ const MODULE_PATH = __DIR__; /** * Module version. @@ -58,7 +58,7 @@ class Controller extends ModuleAbstract implements WebInterface * @var string * @since 1.0.0 */ - const MODULE_VERSION = '1.0.0'; + /* public */ const MODULE_VERSION = '1.0.0'; /** * Module name. @@ -66,7 +66,7 @@ class Controller extends ModuleAbstract implements WebInterface * @var string * @since 1.0.0 */ - const MODULE_NAME = 'Draw'; + /* public */ const MODULE_NAME = 'Draw'; /** * Providing. From 1d8f4fe292912e9e0df04b11cad8085d13a250b2 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 7 Dec 2016 20:56:15 +0100 Subject: [PATCH 8/9] Increase php version requirement --- Admin/Activate.php | 2 +- Admin/Deactivate.php | 2 +- Admin/Install/Navigation.php | 2 +- Admin/Installer.php | 2 +- Admin/Uninstall.php | 2 +- Admin/Update.php | 2 +- Controller.php | 2 +- Models/DrawImage.php | 2 +- Models/DrawImageMapper.php | 2 +- Theme/Backend/Lang/Navigation.en.lang.php | 2 +- Theme/Backend/Lang/api.en.lang.php | 2 +- Theme/Backend/Lang/en.lang.php | 2 +- Theme/Backend/draw-create.tpl.php | 2 +- Theme/Backend/draw-list.tpl.php | 2 +- Theme/backend/Lang/Navigation.en.lang.php | 2 +- Theme/backend/Lang/api.en.lang.php | 2 +- Theme/backend/Lang/en.lang.php | 2 +- Theme/backend/draw-create.tpl.php | 2 +- Theme/backend/draw-list.tpl.php | 2 +- 19 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Admin/Activate.php b/Admin/Activate.php index c9e45cf..5aac385 100644 --- a/Admin/Activate.php +++ b/Admin/Activate.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Admin/Deactivate.php b/Admin/Deactivate.php index dbd55e5..8d34d89 100644 --- a/Admin/Deactivate.php +++ b/Admin/Deactivate.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Admin/Install/Navigation.php b/Admin/Install/Navigation.php index c24b762..a3964fd 100644 --- a/Admin/Install/Navigation.php +++ b/Admin/Install/Navigation.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Admin/Installer.php b/Admin/Installer.php index cdb9354..13cc3d5 100644 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Admin/Uninstall.php b/Admin/Uninstall.php index 817a401..7da0928 100644 --- a/Admin/Uninstall.php +++ b/Admin/Uninstall.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Admin/Update.php b/Admin/Update.php index 77894f8..6c188d9 100644 --- a/Admin/Update.php +++ b/Admin/Update.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Controller.php b/Controller.php index 9ae710a..af576a1 100644 --- a/Controller.php +++ b/Controller.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Models/DrawImage.php b/Models/DrawImage.php index e5d9bcc..eb2b6b4 100644 --- a/Models/DrawImage.php +++ b/Models/DrawImage.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Models/DrawImageMapper.php b/Models/DrawImageMapper.php index 85f3adc..5338320 100644 --- a/Models/DrawImageMapper.php +++ b/Models/DrawImageMapper.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Theme/Backend/Lang/Navigation.en.lang.php b/Theme/Backend/Lang/Navigation.en.lang.php index 77f067e..f282723 100644 --- a/Theme/Backend/Lang/Navigation.en.lang.php +++ b/Theme/Backend/Lang/Navigation.en.lang.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Theme/Backend/Lang/api.en.lang.php b/Theme/Backend/Lang/api.en.lang.php index 754d136..228fc42 100644 --- a/Theme/Backend/Lang/api.en.lang.php +++ b/Theme/Backend/Lang/api.en.lang.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php index 81c780f..3a0fc13 100644 --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Theme/Backend/draw-create.tpl.php b/Theme/Backend/draw-create.tpl.php index 0bb01f3..481df6c 100644 --- a/Theme/Backend/draw-create.tpl.php +++ b/Theme/Backend/draw-create.tpl.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Theme/Backend/draw-list.tpl.php b/Theme/Backend/draw-list.tpl.php index 96151c6..ed0166a 100644 --- a/Theme/Backend/draw-list.tpl.php +++ b/Theme/Backend/draw-list.tpl.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Theme/backend/Lang/Navigation.en.lang.php b/Theme/backend/Lang/Navigation.en.lang.php index 77f067e..f282723 100644 --- a/Theme/backend/Lang/Navigation.en.lang.php +++ b/Theme/backend/Lang/Navigation.en.lang.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Theme/backend/Lang/api.en.lang.php b/Theme/backend/Lang/api.en.lang.php index 754d136..228fc42 100644 --- a/Theme/backend/Lang/api.en.lang.php +++ b/Theme/backend/Lang/api.en.lang.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Theme/backend/Lang/en.lang.php b/Theme/backend/Lang/en.lang.php index 81c780f..3a0fc13 100644 --- a/Theme/backend/Lang/en.lang.php +++ b/Theme/backend/Lang/en.lang.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Theme/backend/draw-create.tpl.php b/Theme/backend/draw-create.tpl.php index 0bb01f3..481df6c 100644 --- a/Theme/backend/draw-create.tpl.php +++ b/Theme/backend/draw-create.tpl.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Theme/backend/draw-list.tpl.php b/Theme/backend/draw-list.tpl.php index 96151c6..ed0166a 100644 --- a/Theme/backend/draw-list.tpl.php +++ b/Theme/backend/draw-list.tpl.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD From 1823c98f30576fa6edebc406c51482dab96e3c6a Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 22 Jan 2017 21:08:46 +0100 Subject: [PATCH 9/9] Fixing json serialization and reporter --- Models/DrawImage.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Models/DrawImage.php b/Models/DrawImage.php index eb2b6b4..1527409 100644 --- a/Models/DrawImage.php +++ b/Models/DrawImage.php @@ -136,12 +136,12 @@ class DrawImage implements ArrayableInterface, \JsonSerializable public function __toString() { - return $this->jsonSerialize(); + return json_encode($this->toArray()); } public function jsonSerialize() { - return json_encode($this->toArray()); + return $this->toArray(); } public static function fromMedia(Media $media)