commit 6462260d5a7d9b60ddbafd44f265975e98321ae1 Author: Dennis Eichhorn Date: Fri Dec 18 17:43:42 2015 +0100 Split diff --git a/Admin/Install/Navigation.php b/Admin/Install/Navigation.php new file mode 100644 index 0000000..1b22469 --- /dev/null +++ b/Admin/Install/Navigation.php @@ -0,0 +1,38 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Draw\Admin\Install; + +/** + * Navigation class. + * + * @category Modules + * @package Modules\Admin + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Navigation +{ + public static function install($dbPool) + { + $navData = json_decode(file_get_contents(__DIR__ . '/nav.install.json'), true); + + $class = '\\Modules\\Navigation\\Admin\\Installer'; + $class::installExternal($dbPool, $navData); + } +} diff --git a/Admin/Install/nav.install.json b/Admin/Install/nav.install.json new file mode 100644 index 0000000..f6f9ab9 --- /dev/null +++ b/Admin/Install/nav.install.json @@ -0,0 +1,48 @@ +[ + { + "id": 1005201001, + "pid": "754a08ddf8bcb1cf22f310f09206dd783d42f7dd", + "type": 2, + "subtype": 1, + "name": "Draw", + "uri": "/{/lang}/backend/draw/list", + "target": "self", + "icon": null, + "order": 70, + "from": "Draw", + "permission": null, + "parent": 1003301001, + "children": [ + { + "id": 1005202001, + "pid": "e19f4e17662b65bae885bc55cbb55797677ecc40", + "type": 3, + "subtype": 1, + "name": "List", + "uri": "/{/lang}/backend/draw/list", + "target": "self", + "icon": null, + "order": 1, + "from": "Draw", + "permission": null, + "parent": 1005201001, + "children": [] + }, + { + "id": 1005202101, + "pid": "e19f4e17662b65bae885bc55cbb55797677ecc40", + "type": 3, + "subtype": 5, + "name": "Create", + "uri": "/{/lang}/backend/draw/create", + "target": "self", + "icon": null, + "order": 15, + "from": "Draw", + "permission": null, + "parent": 1005201001, + "children": [] + } + ] + } +] diff --git a/Admin/Installer.php b/Admin/Installer.php new file mode 100644 index 0000000..6153a83 --- /dev/null +++ b/Admin/Installer.php @@ -0,0 +1,48 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Draw\Admin; + +use phpOMS\DataStorage\Database\DatabaseType; +use phpOMS\DataStorage\Database\Pool; +use phpOMS\Module\InstallerAbstract; + +/** + * Calendar install class. + * + * @category Modules + * @package Modules\Calendar + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Installer extends InstallerAbstract +{ + + /** + * {@inheritdoc} + */ + public static function install(Pool $dbPool, array $info) + { + parent::install($dbPool, $info); + + switch ($dbPool->get('core')->getType()) { + case DatabaseType::MYSQL: + break; + } + } +} diff --git a/Controller.js b/Controller.js new file mode 100644 index 0000000..4f4cecd --- /dev/null +++ b/Controller.js @@ -0,0 +1,42 @@ +(function (jsOMS, undefined) { + jsOMS.Modules.Draw = function (app) { + this.app = app; + this.editors = []; + }; + + jsOMS.Modules.Draw.prototype.bind = function (id) { + var temp = null; + + if (typeof id !== 'undefined') { + temp = new jsOMS.Modules.Draw.Editor(document.getElementById(id)); + temp.bind(); + + this.editors.push(temp); + } else { + var canvas = document.getElementsByClassName('m-draw'); + + this.editors = []; + + /* Handle media forms */ + for (var c = 0; c < canvas.length; c++) { + temp = new jsOMS.Modules.Draw.Editor(canvas[c]); + temp.bind(); + + this.editors.push(temp); + } + } + } + + jsOMS.Modules.Draw.prototype.getElements = function() { + return this.editors; + } + + jsOMS.Modules.Draw.prototype.count = function() { + return this.editors.length; + } +}(window.jsOMS = window.jsOMS || {})); + +jsOMS.ready(function () { + window.omsApp.moduleManager.initModule('Draw'); + window.omsApp.moduleManager.get('Draw').bind(); +}); diff --git a/Controller.php b/Controller.php new file mode 100644 index 0000000..124632f --- /dev/null +++ b/Controller.php @@ -0,0 +1,170 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Draw; + +use Modules\Navigation\Models\Navigation; +use Modules\Navigation\Views\NavigationView; +use phpOMS\Asset\AssetType; +use phpOMS\Contract\RenderableInterface; +use phpOMS\Message\RequestAbstract; +use phpOMS\Message\RequestDestination; +use phpOMS\Message\ResponseAbstract; +use phpOMS\Module\ModuleAbstract; +use phpOMS\Module\WebInterface; +use phpOMS\Views\View; +use phpOMS\Views\ViewLayout; + +/** + * Calendar controller class. + * + * @category Modules + * @package Draw + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Controller extends ModuleAbstract implements WebInterface +{ + + /** + * Module name. + * + * @var \string + * @since 1.0.0 + */ + protected static $module = 'Draw'; + + /** + * Localization files. + * + * @var \string + * @since 1.0.0 + */ + protected static $localization = [ + RequestDestination::BACKEND => ['backend'], + ]; + + /** + * Providing. + * + * @var \string + * @since 1.0.0 + */ + protected static $providing = [ + 'Content', + ]; + + /** + * Dependencies. + * + * @var \string + * @since 1.0.0 + */ + protected static $dependencies = [ + ]; + + /** + * Routing elements. + * + * @var array + * @since 1.0.0 + */ + protected static $routes = [ + '^.*/backend/draw/create.*$' => [ + ['dest' => '\Modules\Draw\Controller:setUpDrawEditor', 'method' => 'GET', 'type' => ViewLayout::NULL], + ['dest' => '\Modules\Draw\Controller:viewDrawCreate', 'method' => 'GET', 'type' => ViewLayout::MAIN], + ], + '^.*/backend/draw/list.*$' => [['dest' => '\Modules\Draw\Controller:viewDrawList', 'method' => 'GET', 'type' => ViewLayout::MAIN],], + ]; + + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setUpDrawEditor(RequestAbstract $request, ResponseAbstract $response, $data = null) + { + $head = $response->getHead(); + $head->addAsset(AssetType::JS, $request->getUri()->getBase() . 'Modules/Draw/ModuleDraw.js'); + } + + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return RenderableInterface + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function viewDrawCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Draw/Theme/backend/draw-create'); + $view->addData('nav', $this->createNavigation(1005201001, $request, $response)); + + return $view; + } + + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return RenderableInterface + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function viewDrawList(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Draw/Theme/backend/draw-list'); + $view->addData('nav', $this->createNavigation(1005201001, $request, $response)); + + return $view; + } + + /** + * @param int $pageId Page/parent Id for navigation + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * + * @return RenderableInterface + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + private function createNavigation(\int $pageId, RequestAbstract $request, ResponseAbstract $response) + { + $nav = Navigation::getInstance($request, $this->app->dbPool); + $navView = new NavigationView($this->app, $request, $response); + $navView->setTemplate('/Modules/Navigation/Theme/backend/mid'); + $navView->setNav($nav->getNav()); + $navView->setLanguage($request->getL11n()->language); + $navView->setParent($pageId); + + return $navView; + } +} diff --git a/Models/DrawType.enum.js b/Models/DrawType.enum.js new file mode 100644 index 0000000..469bb7b --- /dev/null +++ b/Models/DrawType.enum.js @@ -0,0 +1,18 @@ +/** + * DrawType. + * + * @author OMS Development Team + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 * @since 1.0.0 + */ +(function (jsOMS, undefined) +{ + jsOMS.Modules.Draw.DrawTypeEnum = Object.freeze({ + DRAW: 0, + LINE: 1, + RECTANGLE: 2, + CIRCLE: 3, + }); +}(window.jsOMS = window.jsOMS || {})); diff --git a/Models/Editor.js b/Models/Editor.js new file mode 100644 index 0000000..fbc8112 --- /dev/null +++ b/Models/Editor.js @@ -0,0 +1,199 @@ +(function (jsOMS, undefined) +{ + jsOMS.Modules.Draw.Editor = function (editor) + { + this.editor = editor; + this.canvas = document.getElementsByTagName('canvas')[0]; + this.canvasContainer = this.canvas.parentElement; + this.ctx = this.canvas.getContext("2d"); + + var canvasStyle = window.getComputedStyle(this.canvas, null); + var canvasContainerStyle = window.getComputedStyle(this.canvasContainer, null); + + this.resize({ + width: parseFloat(canvasContainerStyle.width) - parseFloat(canvasContainerStyle.paddingLeft) - parseFloat(canvasContainerStyle.paddingRight) - parseFloat(canvasContainerStyle.borderLeftWidth) - parseFloat(canvasStyle.borderLeftWidth), + height: parseFloat(canvasContainerStyle.height) - parseFloat(canvasContainerStyle.paddingTop) - parseFloat(canvasContainerStyle.paddingBottom) - parseFloat(canvasContainerStyle.borderRightWidth) - parseFloat(canvasStyle.borderRightWidth) + }); + + // Backup for undo. + this.canvasBackup = document.createElement('canvas'); + this.ctxBackup = this.canvasBackup.getContext("2d"); + + this.size = 1; + this.type = jsOMS.Modules.Draw.DrawTypeEnum.DRAW; + this.color = '#000000'; + this.drawFlag = false; + this.oldPos = {x: 0, y: 0}; + this.newPos = {x: 0, y: 0}; + + // All backup steps need to be stored here (draw, resize etc.) + // Undo means the whole canvas will be redrawn on the canvasBackup without the last step + this.undoHistory = []; + this.redoHistory = []; + }; + + jsOMS.Modules.Draw.Editor.prototype.bind = function () + { + var self = this; + + // Handle draw and resize + this.canvas.addEventListener('mousemove', function (evt) + { + if (!self.drawFlag || self.type === jsOMS.Modules.Draw.DrawTypeEnum.DRAW) { + self.oldPos = self.newPos; + self.newPos = self.mousePosition(evt); + + if (self.newPos.x < self.canvas.width - 1 && self.newPos.x > self.canvas.width - 5 && self.newPos.y < self.canvas.height - 1 && self.newPos.y > self.canvas.height - 5) { + document.body.style.cursor = 'nwse-resize'; + } else if (self.newPos.x > 1 && self.newPos.x < 5 && self.newPos.y > 1 && self.newPos.y < 5) { + document.body.style.cursor = 'nwse-resize'; + } else if (self.newPos.x > 1 && self.newPos.x < 5 && self.newPos.y < self.canvas.height - 1 && self.newPos.y > self.canvas.height - 5) { + document.body.style.cursor = 'nesw-resize'; + } else if (self.newPos.x < self.canvas.width - 1 && self.newPos.x > self.canvas.width - 5 && self.newPos.y > 1 && self.newPos.y < 5) { + document.body.style.cursor = 'nesw-resize'; + } else if (self.newPos.x < self.canvas.width - 1 && self.newPos.x > self.canvas.width - 5 && self.newPos.y > 5 && self.newPos.y < self.canvas.height - 5) { + document.body.style.cursor = 'ew-resize'; + } else if (self.newPos.x > 1 && self.newPos.x < 5 && self.newPos.y > 5 && self.newPos.y < self.canvas.height - 5) { + document.body.style.cursor = 'ew-resize'; + } else if (self.newPos.x > 5 && self.newPos.x < self.canvas.width - 5 && self.newPos.y < self.canvas.height - 1 && self.newPos.y > self.canvas.height - 5) { + document.body.style.cursor = 'ns-resize'; + } else if (self.newPos.x > 5 && self.newPos.x < self.canvas.width - 5 && self.newPos.y > 1 && self.newPos.y < 5) { + document.body.style.cursor = 'ns-resize'; + } else { + document.body.style.cursor = 'default'; + } + + if (self.type === jsOMS.Modules.Draw.DrawTypeEnum.DRAW) { + self.draw(self.oldPos, self.newPos); + } + } + }, false); + + this.canvas.addEventListener("mousedown", function (evt) + { + self.drawFlag = true; + self.oldPos = self.newPos; + self.newPos = self.mousePosition(evt); + + if (self.drawFlag && self.type === jsOMS.Modules.Draw.DrawTypeEnum.DRAW) { + self.draw(self.newPos, self.newPos); + } else if (self.drawFlag && self.type === jsOMS.Modules.Draw.DrawTypeEnum.RECTANGLE || self.type === jsOMS.Modules.Draw.DrawTypeEnum.LINE || self.type === jsOMS.Modules.Draw.DrawTypeEnum.CIRCLE) { + self.oldPos = self.newPos; + self.newPos = self.mousePosition(evt); + } + }, false); + + this.canvas.addEventListener("mouseup", function (evt) + { + self.oldPos = self.newPos; + self.newPos = self.mousePosition(evt); + + if (self.drawFlag && self.type === jsOMS.Modules.Draw.DrawTypeEnum.RECTANGLE || self.type === jsOMS.Modules.Draw.DrawTypeEnum.LINE || self.type === jsOMS.Modules.Draw.DrawTypeEnum.CIRCLE) { + self.draw(self.oldPos, self.newPos); + } + + self.drawFlag = false; + }, false); + + this.canvas.addEventListener("mouseout", function (evt) + { + self.oldPos = self.newPos; + self.newPos = self.mousePosition(evt); + + self.draw(self.oldPos, self.newPos); + self.drawFlag = false; + document.body.style.cursor = 'default'; + }, false); + }; + + jsOMS.Modules.Draw.Editor.prototype.draw = function (start, end) + { + if (this.drawFlag) { + this.ctx.beginPath(); + this.ctx.strokeStyle = this.color; + this.ctx.lineWidth = this.size; + + if (this.type === jsOMS.Modules.Draw.DrawTypeEnum.DRAW) { + this.ctx.moveTo(start.x, start.y); + this.ctx.lineTo(end.x, end.y); + } else if (this.type === jsOMS.Modules.Draw.DrawTypeEnum.RECTANGLE) { + this.ctx.rect(start.x, start.y, end.x - start.x, end.y - start.y); + } else if (this.type === jsOMS.Modules.Draw.DrawTypeEnum.CIRCLE) { + this.ctx.arc(start.x, start.y, Math.sqrt((end.x - start.x) * (end.x - start.x) + (end.y - start.y) * (end.y - start.y)), 0, 2 * Math.PI); + } else if (this.type === jsOMS.Modules.Draw.DrawTypeEnum.LINE) { + this.ctx.moveTo(start.x, start.y); + this.ctx.lineTo(end.x, end.y); + } + + this.ctx.stroke(); + // this.ctx.closePath(); + + // check if undo has space + // create backup to backup canvas + // remove x first undos from history + // add this step to undo + } + } + + jsOMS.Modules.Draw.Editor.prototype.setSize = function (size) + { + this.size = size; + } + + jsOMS.Modules.Draw.Editor.prototype.setType = function (type) + { + this.type = type; + } + + jsOMS.Modules.Draw.Editor.prototype.setColor = function (color) + { + this.color = color; + } + + jsOMS.Modules.Draw.Editor.prototype.toImage = function (callback) + { + var image = new Image(); + image.onload = function () + { + callback(image); + } + + image.src = this.canvas.toDataURL('image/png'); + + // return image; + } + + jsOMS.Modules.Draw.Editor.prototype.mousePosition = function (evt) + { + var rect = this.canvas.getBoundingClientRect(); + return { + x: evt.clientX - rect.left - 0.5, + y: evt.clientY - rect.top - 0.5 + }; + } + + jsOMS.Modules.Draw.Editor.prototype.resize = function (size) + { + var tmpCanvas = document.createElement('canvas'); + tmpCanvas.width = this.canvas.width; + tmpCanvas.height = this.canvas.height; + + tmpCanvas.getContext('2d').drawImage(this.canvas, 0, 0); + + this.canvas.width = size.width; + this.canvas.height = size.height; + + this.canvas.getContext('2d').drawImage(tmpCanvas, 0, 0, tmpCanvas.width, tmpCanvas.height, 0, 0, this.canvas.width, this.canvas.height); + } + + jsOMS.Modules.Draw.Editor.prototype.scale = function (scale) + { + var tmpCanvas = document.createElement('canvas'); + tmpCanvas.width = this.canvas.width; + tmpCanvas.height = this.canvas.height; + + tmpCanvas.getContext('2d').drawImage(this.canvas, 0, 0); + + this.canvas.getContext('2d').drawImage(tmpCanvas, 0, 0, tmpCanvas.width, tmpCanvas.height, 0, 0, scale.width, scale.height); + } +}(window.jsOMS = window.jsOMS || {})); diff --git a/ModuleDraw.js b/ModuleDraw.js new file mode 100644 index 0000000..ebb5ebd --- /dev/null +++ b/ModuleDraw.js @@ -0,0 +1,254 @@ +(function (jsOMS, undefined) +{ + jsOMS.Modules.Draw = function (app) + { + this.app = app; + this.editors = []; + }; + + jsOMS.Modules.Draw.prototype.bind = function (id) + { + var temp = null; + + if (typeof id !== 'undefined') { + temp = new jsOMS.Modules.Draw.Editor(document.getElementById(id)); + temp.bind(); + + this.editors.push(temp); + } else { + var canvas = document.getElementsByClassName('m-draw'); + + this.editors = []; + + /* Handle media forms */ + for (var c = 0; c < canvas.length; c++) { + temp = new jsOMS.Modules.Draw.Editor(canvas[c]); + temp.bind(); + + this.editors.push(temp); + } + } + } + + jsOMS.Modules.Draw.prototype.getElements = function () + { + return this.editors; + } + + jsOMS.Modules.Draw.prototype.count = function () + { + return this.editors.length; + } +}(window.jsOMS = window.jsOMS || {})); + +jsOMS.ready(function () +{ + window.omsApp.moduleManager.initModule('Draw'); + window.omsApp.moduleManager.get('Draw').bind(); +}); + +/** + * DrawType. + * + * @author OMS Development Team + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 * @since 1.0.0 + */ +(function (jsOMS, undefined) +{ + jsOMS.Modules.Draw.DrawTypeEnum = Object.freeze({ + DRAW: 0, + LINE: 1, + RECTANGLE: 2, + CIRCLE: 3, + }); +}(window.jsOMS = window.jsOMS || {})); + +(function (jsOMS, undefined) +{ + jsOMS.Modules.Draw.Editor = function (editor) + { + this.editor = editor; + this.canvas = document.getElementsByTagName('canvas')[0]; + this.canvasContainer = this.canvas.parentElement; + this.ctx = this.canvas.getContext("2d"); + + var canvasStyle = window.getComputedStyle(this.canvas, null); + var canvasContainerStyle = window.getComputedStyle(this.canvasContainer, null); + + this.resize({ + width: parseFloat(canvasContainerStyle.width) - parseFloat(canvasContainerStyle.paddingLeft) - parseFloat(canvasContainerStyle.paddingRight) - parseFloat(canvasContainerStyle.borderLeftWidth) - parseFloat(canvasStyle.borderLeftWidth), + height: parseFloat(canvasContainerStyle.height) - parseFloat(canvasContainerStyle.paddingTop) - parseFloat(canvasContainerStyle.paddingBottom) - parseFloat(canvasContainerStyle.borderRightWidth) - parseFloat(canvasStyle.borderRightWidth) + }); + + // Backup for undo. + this.canvasBackup = document.createElement('canvas'); + this.ctxBackup = this.canvasBackup.getContext("2d"); + + this.size = 1; + this.type = jsOMS.Modules.Draw.DrawTypeEnum.RECTANGLE; + this.color = '#000000'; + this.drawFlag = false; + this.oldPos = {x: 0, y: 0}; + this.newPos = {x: 0, y: 0}; + + // All backup steps need to be stored here (draw, resize etc.) + // Undo means the whole canvas will be redrawn on the canvasBackup without the last step + this.undoHistory = []; + this.redoHistory = []; + }; + + jsOMS.Modules.Draw.Editor.prototype.bind = function () + { + var self = this; + + // Handle draw and resize + this.canvas.addEventListener('mousemove', function (evt) + { + if (!self.drawFlag || self.type === jsOMS.Modules.Draw.DrawTypeEnum.DRAW) { + self.oldPos = self.newPos; + self.newPos = self.mousePosition(evt); + + if (self.newPos.x < self.canvas.width - 1 && self.newPos.x > self.canvas.width - 5 && self.newPos.y < self.canvas.height - 1 && self.newPos.y > self.canvas.height - 5) { + document.body.style.cursor = 'nwse-resize'; + } else if (self.newPos.x > 1 && self.newPos.x < 5 && self.newPos.y > 1 && self.newPos.y < 5) { + document.body.style.cursor = 'nwse-resize'; + } else if (self.newPos.x > 1 && self.newPos.x < 5 && self.newPos.y < self.canvas.height - 1 && self.newPos.y > self.canvas.height - 5) { + document.body.style.cursor = 'nesw-resize'; + } else if (self.newPos.x < self.canvas.width - 1 && self.newPos.x > self.canvas.width - 5 && self.newPos.y > 1 && self.newPos.y < 5) { + document.body.style.cursor = 'nesw-resize'; + } else if (self.newPos.x < self.canvas.width - 1 && self.newPos.x > self.canvas.width - 5 && self.newPos.y > 5 && self.newPos.y < self.canvas.height - 5) { + document.body.style.cursor = 'ew-resize'; + } else if (self.newPos.x > 1 && self.newPos.x < 5 && self.newPos.y > 5 && self.newPos.y < self.canvas.height - 5) { + document.body.style.cursor = 'ew-resize'; + } else if (self.newPos.x > 5 && self.newPos.x < self.canvas.width - 5 && self.newPos.y < self.canvas.height - 1 && self.newPos.y > self.canvas.height - 5) { + document.body.style.cursor = 'ns-resize'; + } else if (self.newPos.x > 5 && self.newPos.x < self.canvas.width - 5 && self.newPos.y > 1 && self.newPos.y < 5) { + document.body.style.cursor = 'ns-resize'; + } else { + document.body.style.cursor = 'default'; + } + + if (self.type === jsOMS.Modules.Draw.DrawTypeEnum.DRAW) { + self.draw(self.oldPos, self.newPos); + } + } + }, false); + + this.canvas.addEventListener("mousedown", function (evt) + { + self.drawFlag = true; + self.oldPos = self.newPos; + self.newPos = self.mousePosition(evt); + + if (self.drawFlag && self.type === jsOMS.Modules.Draw.DrawTypeEnum.DRAW) { + self.draw(self.newPos, self.newPos); + } else if (self.drawFlag && self.type === jsOMS.Modules.Draw.DrawTypeEnum.RECTANGLE || self.type === jsOMS.Modules.Draw.DrawTypeEnum.LINE || self.type === jsOMS.Modules.Draw.DrawTypeEnum.CIRCLE) { + self.oldPos = self.newPos; + self.newPos = self.mousePosition(evt); + } + }, false); + + this.canvas.addEventListener("mouseup", function (evt) + { + self.oldPos = self.newPos; + self.newPos = self.mousePosition(evt); + + if (self.drawFlag && self.type === jsOMS.Modules.Draw.DrawTypeEnum.RECTANGLE || self.type === jsOMS.Modules.Draw.DrawTypeEnum.LINE || self.type === jsOMS.Modules.Draw.DrawTypeEnum.CIRCLE) { + self.draw(self.oldPos, self.newPos); + } + + self.drawFlag = false; + }, false); + + this.canvas.addEventListener("mouseout", function (evt) + { + self.oldPos = self.newPos; + self.newPos = self.mousePosition(evt); + + self.draw(self.oldPos, self.newPos); + self.drawFlag = false; + document.body.style.cursor = 'default'; + }, false); + }; + + jsOMS.Modules.Draw.Editor.prototype.draw = function (start, end) + { + if (this.drawFlag) { + this.ctx.beginPath(); + this.ctx.strokeStyle = this.color; + this.ctx.lineWidth = this.size; + + if (this.type === jsOMS.Modules.Draw.DrawTypeEnum.DRAW) { + this.ctx.moveTo(start.x, start.y); + this.ctx.lineTo(end.x, end.y); + } else if (this.type === jsOMS.Modules.Draw.DrawTypeEnum.RECTANGLE) { + this.ctx.rect(start.x, start.y, end.x - start.x, end.y - start.y); + } else if (this.type === jsOMS.Modules.Draw.DrawTypeEnum.CIRCLE) { + this.ctx.arc(start.x, start.y, Math.sqrt((end.x - start.x) * (end.x - start.x) + (end.y - start.y) * (end.y - start.y)), 0, 2 * Math.PI); + } else if (this.type === jsOMS.Modules.Draw.DrawTypeEnum.LINE) { + this.ctx.moveTo(start.x, start.y); + this.ctx.lineTo(end.x, end.y); + } + + this.ctx.stroke(); + // this.ctx.closePath(); + + // check if undo has space + // create backup to backup canvas + // remove x first undos from history + // add this step to undo + } + } + + jsOMS.Modules.Draw.Editor.prototype.setSize = function (size) + { + this.size = size; + } + + jsOMS.Modules.Draw.Editor.prototype.setType = function (type) + { + this.type = type; + } + + jsOMS.Modules.Draw.Editor.prototype.setColor = function (color) + { + this.color = color; + } + + jsOMS.Modules.Draw.Editor.prototype.mousePosition = function (evt) + { + var rect = this.canvas.getBoundingClientRect(); + return { + x: evt.clientX - rect.left - 0.5, + y: evt.clientY - rect.top - 0.5 + }; + } + + jsOMS.Modules.Draw.Editor.prototype.resize = function (size) + { + var tmpCanvas = document.createElement('canvas'); + tmpCanvas.width = this.canvas.width; + tmpCanvas.height = this.canvas.height; + + tmpCanvas.getContext('2d').drawImage(this.canvas, 0, 0); + + this.canvas.width = size.width; + this.canvas.height = size.height; + + this.canvas.getContext('2d').drawImage(tmpCanvas, 0, 0, tmpCanvas.width, tmpCanvas.height, 0, 0, this.canvas.width, this.canvas.height); + } + + jsOMS.Modules.Draw.Editor.prototype.scale = function (scale) + { + var tmpCanvas = document.createElement('canvas'); + tmpCanvas.width = this.canvas.width; + tmpCanvas.height = this.canvas.height; + + tmpCanvas.getContext('2d').drawImage(this.canvas, 0, 0); + + this.canvas.getContext('2d').drawImage(tmpCanvas, 0, 0, tmpCanvas.width, tmpCanvas.height, 0, 0, scale.width, scale.height); + } +}(window.jsOMS = window.jsOMS || {})); diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/Theme/backend/draw-create.tpl.php b/Theme/backend/draw-create.tpl.php new file mode 100644 index 0000000..4e07b2e --- /dev/null +++ b/Theme/backend/draw-create.tpl.php @@ -0,0 +1,84 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * @var \phpOMS\Views\View $this + */ + +echo $this->getData('nav')->render(); ?> + +
+
+
+ +
+
+
+ +
+
+ +
+ +
+
    +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
+
+ +
+
+
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
diff --git a/Theme/backend/draw-list.tpl.php b/Theme/backend/draw-list.tpl.php new file mode 100644 index 0000000..e91e39c --- /dev/null +++ b/Theme/backend/draw-list.tpl.php @@ -0,0 +1,44 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * @var \phpOMS\Views\View $this + */ + +$footerView = new \Web\Views\Lists\PaginationView($this->app, $this->request, $this->response); +$footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig'); +$footerView->setPages(20); +$footerView->setPage(1); + +echo $this->getData('nav')->render(); ?> +
+ + + + + + + + $value) : $count++; ?> + + +
l11n->lang['Draw']['Images']; ?>
l11n->lang['Draw']['Name']; ?> + l11n->lang['Draw']['Creator']; ?> + l11n->lang['Draw']['Created']; ?> +
render(); ?> +
l11n->lang[0]['Empty']; ?> + +
+
diff --git a/Theme/lang/api.en.lang.php b/Theme/lang/api.en.lang.php new file mode 100644 index 0000000..a2fa112 --- /dev/null +++ b/Theme/lang/api.en.lang.php @@ -0,0 +1,17 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +$MODLANG['Navigation'] = [ +]; diff --git a/Theme/lang/backend.en.lang.php b/Theme/lang/backend.en.lang.php new file mode 100644 index 0000000..d66270d --- /dev/null +++ b/Theme/lang/backend.en.lang.php @@ -0,0 +1,26 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +$MODLANG['Draw'] = [ + 'Created' => 'Created', + 'Creator' => 'Creator', + 'Draw' => 'Draw', + 'GroupUser' => 'Group/User', + 'Images' => 'Images', + 'Layout' => 'Layout', + 'Name' => 'Name', + 'Permission' => 'Permission', + 'Start' => 'Start', +]; diff --git a/Theme/lang/nav.backend.en.lang.php b/Theme/lang/nav.backend.en.lang.php new file mode 100644 index 0000000..dac6410 --- /dev/null +++ b/Theme/lang/nav.backend.en.lang.php @@ -0,0 +1,20 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +$MODLANG['Navigation'] = [ + 'Create' => 'Create', + 'Draw' => 'Draw', + 'List' => 'List', +]; diff --git a/info.json b/info.json new file mode 100644 index 0000000..f01c80a --- /dev/null +++ b/info.json @@ -0,0 +1,51 @@ +{ + "name": { + "id": 1005200000, + "internal": "Draw", + "external": "OMS Draw" + }, + "version": "1.0.0", + "requirements": { + "phpOMS": "1.0.0", + "phpOMS-db": "1.0.0" + }, + "creator": { + "name": "Orange Management", + "website": "www.spl1nes.com" + }, + "description": "The administration module.", + "directory": "Draw", + "dependencies": {}, + "providing": { + "Navigation": "*" + }, + "load": [ + { + "pid": [ + "e19f4e17662b65bae885bc55cbb55797677ecc40" + ], + "type": 4, + "for": "Content", + "file": "Draw", + "from": "Draw" + }, + { + "pid": [ + "e19f4e17662b65bae885bc55cbb55797677ecc40" + ], + "type": 5, + "for": "Content", + "file": "backend", + "from": "Draw" + }, + { + "pid": [ + "754a08ddf8bcb1cf22f310f09206dd783d42f7dd" + ], + "type": 5, + "from": "Draw", + "for": "Navigation", + "file": "nav.backend" + } + ] +}