Browse Source

Refactor for new Plugin system using Strategy Pattern.

Giancarlo Voci 8 years ago
parent
commit
55cc55623c

+ 1 - 0
.gitignore

@@ -42,6 +42,7 @@ composer.phar
 *.odp
 
 # FOLDER TOOLS
+cache
 vendor
 node_modules
 tmp

+ 3 - 4
config.ini

@@ -1,8 +1,6 @@
 [globals]
-;AUTOLOAD="src/"
-;CACHE = "folder=cache/"
-CACHE = false
-CACHE_TTL=1
+AUTOLOAD="src/"
+CACHE = "folder=cache/"
 UI=ui/
 DEBUG=3
 ENCODING="UTF-8"
@@ -13,6 +11,7 @@ dbuser=root
 dbpass=giancarlo
 BASEURL=/lamborghini
 SITENAME=OM-Link Lamborghini
+LOGO_CUSTOMER={{@BASEURL}}/ui/images/logo_text.png
 
 [CORE.fb]
 host=192.168.1.140

+ 8 - 30
index.php

@@ -7,37 +7,15 @@
 
 //error_reporting(E_ALL);
 
+// Init Framework
 require_once 'lib/f3/base.php';
 
-$f3 = \Base::instance();
-$f3->set("AUTOLOAD", 'src/');
+// Load Utility Class
+require_once "src\OpenMind\System\OMUtils.php";
 
-$config = new \OpenMind\Utils\Configuration();
+$frameworkUtils = new \OpenMind\System\OMUtils();
+$frameworkUtils->DieByOldPhpVersion();
+$frameworkUtils->LoadEncryptedConfig('config.bin');
+$frameworkUtils->PluginLoader('src/');
 
-\OpenMind\Utils\OMUtils::getInstance()->LoadEncryptedConfig('config.bin');
-
-$f3->config('labels.ini', true);
-
-$f3->set('DB',
-  new \DB\SQL(
-    $f3->get('DBSETTINGS'),
-    $f3->get('dbuser'),
-    $f3->get('dbpass'),
-    array(\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, \PDO::ATTR_PERSISTENT => TRUE))
-);
-
-$d = new \Customers\Lamborghini\Distinta($f3);
-
-// Pages
-$f3->route('GET /', "Customers\Lamborghini\Pages->Login", $f3->get('CACHE_TTL'));
-$f3->route('GET /homemenu', "Customers\Lamborghini\Pages->HomeMenu", $f3->get('CACHE_TTL'));
-$f3->route('GET|POST /pick2light/@step', "Customers\Lamborghini\Pages->Pick2Light", $f3->get('CACHE_TTL'));
-$f3->route("GET|POST /bind/@step", 'Customers\Lamborghini\Pages->Bind', $f3->get('CACHE_TTL'));
-$f3->route("GET|POST /unbind/@step", 'Customers\Lamborghini\Pages->UnBind', $f3->get('CACHE_TTL'));
-$f3->route('GET /elencodistinta', "Customers\Lamborghini\Pages->ElencoDistinta", $f3->get('CACHE_TTL'));
-
-// Services
-$f3->route("POST /login", 'OpenMind\Web\BaseController\BaseController->Login');
-$f3->route("GET /logout", 'OpenMind\Web\BaseController\BaseController->Logout');
-
-$f3->run();
+\F3::run();

+ 27 - 26
src/Customers/Lamborghini/Distinta.php

@@ -8,16 +8,17 @@
 namespace Customers\Lamborghini;
 
 use OpenMind\Labeling\FindBoxCoreSystem;
+use OpenMind\Labeling\SmartESL;
 
 class Distinta
 {
   private $dbHandle;
   private $userId;
 
-  public function __construct(object $f3)
+  public function __construct()
   {
-    $this->dbHandle = $f3->get('DB');
-    $this->userId = $f3->get('USERID');
+    $this->dbHandle = \F3::get('DB');
+    $this->userId = \F3::get('USERID');
   }
 
   public function CleanDistintaTable()
@@ -45,7 +46,7 @@ EOF;
         "VALUES ({$idutente}, '{$row['consegna']}', '{$row['barcode']}', '{$row['descrizione']}', '{$row['origine']}', '{$row['ubicazione']}', '{$row['sequenza']}', '{$row['qta_prelevare']}', 0)";
       $err = $this->dbHandle->exec($sqlInsert);
       if (!$err)
-        die('CopyDistinta error insert in table distinta_esplosa');
+        die(__FUNCTION__ . ' error insert in table distinta_esplosa');
     }
   }
 
@@ -89,21 +90,29 @@ EOF;
         }
 
         if ($blink) {
-          $label = new \SmartESL($findBoxCore, [$labelId]);
+          $label = new SmartESL($findBoxCore, [$labelId]);
           $label->BlinkSpecial(2, 1, 1000, $iterations, 0);
         }
       }
     }
   }
 
-  public function getDistinte()
+  public function getDistinta(string $maxRows = '3')
   {
-    return $this->dbHandle->exec('SELECT distinct consegna, commessa, ordine_produzione, data_creazione, time_creazione, destinazione_merci FROM `distinte` ORDER BY data_creazione');
+    return $this->dbHandle->exec("SELECT * FROM distinta_esplosa WHERE idutente={$this->userId} AND qta_prelevare>0 and anomalie=0 ORDER BY sequenza LIMIT {$maxRows}");
   }
 
-  public function getDistinta(string $maxRows = '3')
+  public function GetLabelIdFromBarcode(string $barcode): ?string
   {
-    return $this->dbHandle->exec("SELECT * FROM distinta_esplosa WHERE idutente={$this->userId} AND qta_prelevare>0 and anomalie=0 ORDER BY sequenza LIMIT {$maxRows}");
+    $label = $this->dbHandle->exec("SELECT label_id FROM `label_bindings` WHERE barcode='{$barcode}'");
+    if (count($label) > 0)
+      return $label[0]['label_id'];
+    return null;
+  }
+
+  public function getDistinte()
+  {
+    return $this->dbHandle->exec('SELECT distinct consegna, commessa, ordine_produzione, data_creazione, time_creazione, destinazione_merci FROM `distinte` ORDER BY data_creazione');
   }
 
   public function MarkBarcodeAsAnomalia(string $barcode)
@@ -111,7 +120,7 @@ EOF;
     $CORE_SETTINGS = \F3::get('CORE.fb');
     $findBoxCore = new FindBoxCoreSystem(...array_values($CORE_SETTINGS));
     $lblId = $this->GetLabelIdFromBarcode($barcode);
-    $label = new \SmartESL($findBoxCore, [$lblId]);
+    $label = new SmartESL($findBoxCore, [$lblId]);
     $label->BlinkSpecial(3, 1, 1000, 10);
 
     $sql = "UPDATE distinta_esplosa d JOIN label_bindings b ON d.barcode = b.barcode SET anomalie=1 WHERE idutente={$this->userId} AND b.barcode='{$barcode}'";
@@ -140,26 +149,12 @@ EOF;
     return null;
   }
 
-  public function GetLabelIdFromBarcode(string $barcode): ?string
-  {
-    $label = $this->dbHandle->exec("SELECT label_id FROM `label_bindings` WHERE barcode='{$barcode}'");
-    if (count($label) > 0)
-      return $label[0]['label_id'];
-    return null;
-  }
-
-  private function getArticoliByConsegna(string $consegna): array
-  {
-    $sqlCommesse = "SELECT DISTINCT de.barcode, de.descrizione, d.qta_prelevare as qta_nominale, de.qta_prelevare, de.anomalie FROM `distinta_esplosa` AS de JOIN `distinte` AS d ON de.commessa=d.consegna WHERE idutente={$this->userId} AND de.commessa = '{$consegna}' AND de.barcode=d.barcode";
-    return $this->dbHandle->exec($sqlCommesse);
-  }
-
   public function ResetLabelCarrello(string $labelId)
   {
     $CORE_SETTINGS = \F3::get('CORE.fb');
     $findBoxCore = new FindBoxCoreSystem(...array_values($CORE_SETTINGS));
 
-    $label = new \SmartESL($findBoxCore, [$labelId]);
+    $label = new SmartESL($findBoxCore, [$labelId]);
     $label->BlinkSpecial(0, 1, 1000, 8, 0);
 
     $dataFields = array(
@@ -208,11 +203,17 @@ EOF;
 
     $dataFields['end_operations'] = $consegna;
 
-    $label = new \SmartESL($findBoxCore, [$labelId]);
+    $label = new SmartESL($findBoxCore, [$labelId]);
     $findBoxCore->SaveProducts($barcode, $consegna, $dataFields);
     $label->BlinkSpecial(0, 1, 1000, 8, 0);
   }
 
+  private function getArticoliByConsegna(string $consegna): array
+  {
+    $sqlCommesse = "SELECT DISTINCT de.barcode, de.descrizione, d.qta_prelevare as qta_nominale, de.qta_prelevare, de.anomalie FROM `distinta_esplosa` AS de JOIN `distinte` AS d ON de.commessa=d.consegna WHERE idutente={$this->userId} AND de.commessa = '{$consegna}' AND de.barcode=d.barcode";
+    return $this->dbHandle->exec($sqlCommesse);
+  }
+
   /**
    * Esegue il reset delle etichette associate alla distinta
    * @param string $commessa

+ 18 - 0
src/Customers/Lamborghini/LabelingSystem.php

@@ -0,0 +1,18 @@
+<?php
+/**
+ * @author Open Mind
+ * @date 18/06/2018
+ * @time 09:13
+ */
+
+namespace Customers\Lamborghini;
+
+use OpenMind\Labeling\FindBoxCoreSystem as FBCS;
+
+class LabelingSystem extends FBCS
+{
+  public function __construct(string $host, int $port, string $APIKey, string $Password)
+  {
+    parent::__construct(...array_values(\F3::get('CORE.fb')));
+  }
+}

+ 9 - 12
src/Customers/Lamborghini/Lamborghini.php

@@ -7,20 +7,17 @@
 
 namespace Customers\Lamborghini;
 
-use OpenMind\Labeling\FindBoxCoreSystem as FBCS;
+use OpenMind\System\PluginStrategy;
 
-class FindBoxCoreSystem extends FBCS
+class Lamborghini extends PluginStrategy
 {
-  public function __construct()
+  public static function Init()
   {
-    parent::__construct(...array_values(\F3::get('CORE.fb')));
+    \F3::route('GET /', __NAMESPACE__ . '\Pages->Login');
+    \F3::route('GET /homemenu', __NAMESPACE__ . '\Pages->HomeMenu');
+    \F3::route('GET|POST /pick2light/@step', __NAMESPACE__ . '\Pages->Pick2Light');
+    \F3::route("GET|POST /bind/@step", __NAMESPACE__ . '\Pages->Bind');
+    \F3::route("GET|POST /unbind/@step", __NAMESPACE__ . '\Pages->UnBind');
+    \F3::route('GET /elencodistinta', __NAMESPACE__ . '\Pages->ElencoDistinta');
   }
 }
-
-class Lamborghini
-{
-  public function __construct()
-  {
-  }
-}
-

+ 11 - 10
src/Customers/Lamborghini/Pages.php

@@ -8,6 +8,7 @@
 namespace Customers\Lamborghini;
 
 use OpenMind\Labeling\FindBoxCoreSystem;
+use OpenMind\Labeling\SmartESL;
 
 class Pages extends \OpenMind\Web\BaseController
 {
@@ -53,11 +54,11 @@ class Pages extends \OpenMind\Web\BaseController
 
     switch ($args['step']) {
       case 3:
-        $distinta = new Distinta($f3);
+        $distinta = new Distinta();
         $distinta->CleanDistintaTable();
         $distinta->CopyDistinta($stepValues['consegna']);
 
-        $label = new \SmartESL($this->findBoxCore, [$stepValues['labelid']]);
+        $label = new SmartESL($this->findBoxCore, [$stepValues['labelid']]);
         $label->BlinkSpecial(0, 1, 1000, 8, 0);
 
         $distinta->SaveProductsToFindBox('3', true, 50); // prende soltanto i primi 3 dalla tabella copia delle distinte
@@ -69,13 +70,13 @@ class Pages extends \OpenMind\Web\BaseController
         return;
         break;
       case 4:
-        $distinta = new Distinta($f3);
+        $distinta = new Distinta();
         $distinta->SaveProductsToFindBox('3, 2000', false); // LIMIT 3,1000 perchè i primi 3 sono stati fatti nel case 3
         break;
       case 5:
         $datiCommessa['consegna'] = $f3->get('COOKIE.consegna');
         $datiCommessa['labelid'] = $f3->get('COOKIE.labelid');
-        $distinta = new Distinta($f3);
+        $distinta = new Distinta();
         $pickedBarcode = $f3->get('POST.pickedlabelid');
         // Decrease quantity and blink label
         if ($pickedBarcode != null) {
@@ -97,7 +98,7 @@ class Pages extends \OpenMind\Web\BaseController
             $pickedBarcode = $codeFromLabelId ?? $pickedBarcode;
             if ($distinta->RemoveQuantity($pickedBarcode)) {
               // SPEGNE LED ETICHETTA DOPO PICKING
-              $label = new \SmartESL($this->findBoxCore, [$distinta->GetLabelIdFromBarcode($pickedBarcode)]);
+              $label = new SmartESL($this->findBoxCore, [$distinta->GetLabelIdFromBarcode($pickedBarcode)]);
               $label->BlinkOff();
             } else {
               $f3->set('INFOTEXT', 'Barcode non riconosciuto o non associato ad alcuna etichetta elettronica');
@@ -114,7 +115,7 @@ class Pages extends \OpenMind\Web\BaseController
           $anomalie = $distinta->getAnomalieFromConsegne($datiCommessa['consegna']);
           $f3->set('LISTANOMALIE', $anomalie);
 
-          $label = new \SmartESL($this->findBoxCore, [$datiCommessa['labelid']]);
+          //$label = new SmartESL($this->findBoxCore, [$datiCommessa['labelid']]);
           $distinta->SaveLabelCarrello($datiCommessa['labelid'], $datiCommessa['labelid'], $datiCommessa['consegna']);
 
           // Se non ci sono anomalie torna alla homepage
@@ -127,7 +128,7 @@ class Pages extends \OpenMind\Web\BaseController
           foreach($rowsDistinta as $rowDist) {
             $labelId = $distinta->GetLabelIdFromBarcode($rowDist['barcode']);
             if ($labelId != null) {
-              $label = new \SmartESL($this->findBoxCore, [$labelId]);
+              $label = new SmartESL($this->findBoxCore, [$labelId]);
               // Se è lo stesso barcode di quello appena pickato dall'operatore, non lo blinka di nuovo
               if ($distinta->GetArticleCount($rowDist['barcode']) > 0) {
                 $label->BlinkSpecial(2, 1, 1000, 20);
@@ -163,7 +164,7 @@ class Pages extends \OpenMind\Web\BaseController
 
     if ($args['step'] == 3) {
       $this->findBoxCore->Bind($stepValues['labelid'], $stepValues['barcode']);
-      $label = new \SmartESL($this->findBoxCore, [$stepValues['labelid']]);
+      $label = new SmartESL($this->findBoxCore, [$stepValues['labelid']]);
 
       if ($stepValues['labelid'] == $stepValues['barcode'])
         $devType = 79;
@@ -176,7 +177,7 @@ class Pages extends \OpenMind\Web\BaseController
 
       // Reset label carrello if barcode = label id
       if ($stepValues['labelid'] == $stepValues['barcode']) {
-        $d = new Distinta($f3);
+        $d = new Distinta();
         $d->ResetLabelCarrello($stepValues['labelid']);
       } else {
         $articles = new \DB\SQL\Mapper($this->dbHandle, 'articles');
@@ -227,7 +228,7 @@ class Pages extends \OpenMind\Web\BaseController
 
   public function ElencoDistinta($f3)
   {
-    $distinta = new Distinta($f3);
+    $distinta = new Distinta();
     $f3->set('PRODUCTS', $distinta->getDistinte());
     $f3->set('CONTENT', 'distinta.tpl');
     echo \Template::instance()->render('masterpage.tpl');

+ 21 - 21
src/OpenMind/Labeling/FindBoxCoreSystem.php

@@ -50,27 +50,6 @@ class FindBoxCoreSystem
     }
   }
 
-  /**
-   * Helper for make JSON return code
-   *
-   * @param int $errorCode
-   * @param string $value
-   * @return array
-   */
-  private function returnCode(int $errorCode, string $value): array
-  {
-    $val = json_decode($value, true) ?? $value;
-    return array(
-      "err" => $errorCode,
-      "value" => $val);
-  }
-
-  public function BlinkUnassigned()
-  {
-    $URI = "/1.0.0/index.php/smartesl.blink_unassigned/2.0.0/";
-    $this->CallAPI($URI, "", true);
-  }
-
   /**
    * CallGetAPI make HTTP GET requests
    * @param string $URI full path of api url, for example "/1.0.0/index.php/smartesl.blink_special/1.0.0/"
@@ -101,6 +80,27 @@ class FindBoxCoreSystem
     return $this->returnCode(0, $bodyJSON);
   }
 
+  /**
+   * Helper for make JSON return code
+   *
+   * @param int $errorCode
+   * @param string $value
+   * @return array
+   */
+  private function returnCode(int $errorCode, string $value): array
+  {
+    $val = json_decode($value, true) ?? $value;
+    return array(
+      "err" => $errorCode,
+      "value" => $val);
+  }
+
+  public function BlinkUnassigned()
+  {
+    $URI = "/1.0.0/index.php/smartesl.blink_unassigned/2.0.0/";
+    $this->CallAPI($URI, "", true);
+  }
+
   /**
    * Save products into findbus database
    * @param string $barcode

+ 15 - 15
src/OpenMind/Labeling/SmartESL.php

@@ -20,6 +20,21 @@ class SmartESL
     $this->labelProperties = $this->GetStatus();
   }
 
+  /**
+   * Request to label(s) its properties
+   * @return null|object Details
+   */
+  public function GetStatus()
+  {
+    $labels = json_encode(array($this->labels));
+    $URI = "/1.0.0/index.php/smartesl.getstatus/3.1.0/";
+    $ret = $this->core->CallAPI($URI, $labels);
+    if ($ret['err'] == 0 && $ret['value']['code'] == 0) {
+      return $ret['value']['value'];
+    }
+    return null;
+  }
+
   /**
    * Retrieve cached label properties
    *
@@ -87,21 +102,6 @@ class SmartESL
 //    $this->core->CallAPI($URI, "[[\"{$this->labels[0]}\"],0,1,1,500,1,1]", true);
   }
 
-  /**
-   * Request to label(s) its properties
-   * @return null|object Details
-   */
-  public function GetStatus()
-  {
-    $labels = json_encode(array($this->labels));
-    $URI = "/1.0.0/index.php/smartesl.getstatus/3.1.0/";
-    $ret = $this->core->CallAPI($URI, $labels);
-    if ($ret['err'] == 0 && $ret['value']['code'] == 0) {
-      return $ret['value']['value'];
-    }
-    return null;
-  }
-
   public function Display(string $templateId, string $barcode)
   {
     $URI = "/1.0.0/index.php/smartesl.display/2.3.0/";

+ 1 - 1
src/OpenMind/Utils/Configuration.php → src/OpenMind/System/Configuration.php

@@ -5,7 +5,7 @@
  * @time 12:10
  */
 
-namespace OpenMind\Utils;
+namespace OpenMind\System;
 
 class Configuration
 {

+ 65 - 0
src/OpenMind/System/OMUtils.php

@@ -0,0 +1,65 @@
+<?php
+/**
+ * @author Open Mind
+ * @date 26/04/2018
+ * @time 11:11
+ */
+
+namespace OpenMind\System;
+
+use FilesystemIterator;
+use RecursiveDirectoryIterator;
+use RecursiveIteratorIterator;
+
+class OMUtils
+{
+  public static function getInstance()
+  {
+    static $instance = null;
+    if ($instance === null) {
+      $instance = new static(); // PHP 5+ lazy state building
+    }
+    return $instance;
+  }
+
+  /**
+   * Load all modules in <$path> folder
+   * @param string $path
+   */
+  public function PluginLoader(string $path)
+  {
+    $Directory = new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS);
+    $Iterator = new RecursiveIteratorIterator($Directory, RecursiveIteratorIterator::CHILD_FIRST);
+
+    foreach($Iterator as $item) {
+      if (is_file($item->getPathname()))
+        continue;
+      $moduleInitPath = "{$item->getPathname()}/{$item->getFilename()}.php";
+      $className = str_replace('/', '\\', ltrim("{$item->getPathname()}/{$item->getFilename()}", $path));
+      if (file_exists($moduleInitPath)) {
+        $className::Init();
+      }
+    }
+  }
+
+
+  /**
+   * Load an encrypted file with the method "base64_encode(gzcompress(<path to config.ini>))", save it in a temporary file in temp folder of system and load with F3::config()
+   *
+   * @param string $path
+   */
+  public function LoadEncryptedConfig(string $path)
+  {
+    $tmpFilepath = tempnam(sys_get_temp_dir(), 'om');
+    $config = gzuncompress(base64_decode(file_get_contents($path)));
+    file_put_contents($tmpFilepath, $config);
+    \F3::config($tmpFilepath, true);
+    unlink($tmpFilepath);
+  }
+
+  public function DieByOldPhpVersion()
+  {
+    if (version_compare(PHP_VERSION, '7.2') != 1)
+      die('PHP 7.2+ is need to run the project');
+  }
+}

+ 62 - 0
src/OpenMind/System/PluginStrategy.php

@@ -0,0 +1,62 @@
+<?php
+/**
+ * @author Open Mind
+ * @date 21/06/2018
+ * @time 12:34
+ */
+
+namespace OpenMind\System;
+
+/**
+ * Interface IPluginStrategy
+ * Main interface for plugin system, it use Strategy Pattern.
+ *
+ * @package OpenMind\System
+ */
+interface IPluginStrategy
+{
+  public function getVersion(): string;
+
+  public function getName(): string;
+
+  public static function Init();
+}
+
+/**
+ * Class PluginStrategy
+ * Basically every plugin must extend this class to work
+ *
+ * @package OpenMind\System
+ */
+class PluginStrategy implements IPluginStrategy
+{
+  /**
+   * Return default version for plugins that doesn't have one
+   *
+   * @return string
+   */
+  public function getVersion(): string
+  {
+    return '1.0';
+  }
+
+  /**
+   * Return Class name, usefull when a list of installed plugins is need
+   *
+   * @return string
+   */
+  public function getName(): string
+  {
+    return get_class($this);
+  }
+
+  /**
+   * Main function
+   */
+  public static function Init()
+  {
+    $className = get_called_class();
+    die("Plugin " . $className . ' doesn\'t have an Init() function. Please provide one.');
+  }
+
+}

+ 25 - 0
src/OpenMind/System/System.php

@@ -0,0 +1,25 @@
+<?php
+/**
+ * @author Open Mind
+ * @date 21/06/2018
+ * @time 18:28
+ */
+
+namespace OpenMind\System;
+
+
+class System extends PluginStrategy
+{
+  public static function Init()
+  {
+    \F3::set('DB',
+      new \DB\SQL(
+        \F3::get('DBSETTINGS'),
+        \F3::get('dbuser'),
+        \F3::get('dbpass'),
+        array(\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, \PDO::ATTR_PERSISTENT => TRUE))
+    );
+
+    \F3::config('labels.ini', true);
+  }
+}

+ 0 - 34
src/OpenMind/Utils/OMUtils.php

@@ -1,34 +0,0 @@
-<?php
-/**
- * @author Open Mind
- * @date 26/04/2018
- * @time 11:11
- */
-
-namespace OpenMind\Utils;
-
-class OMUtils
-{
-  public static function getInstance()
-  {
-    static $instance = null;
-    if($instance===null) {
-      $instance = new static(); // PHP 5+ lazy state building
-    }
-    return $instance;
-  }
-
-  /**
-   * Load an encrypted file with the method "base64_encode(gzcompress(<path to config.ini>))", save it in a temporary file in temp folder of system and load with F3::config()
-   *
-   * @param string $path
-   */
-  public function LoadEncryptedConfig(string $path)
-  {
-    $tmpFilepath = tempnam(sys_get_temp_dir(), 'om');
-    $config = gzuncompress(base64_decode(file_get_contents($path)));
-    file_put_contents($tmpFilepath, $config);
-    \F3::config($tmpFilepath, true);
-    unlink($tmpFilepath);
-  }
-}

+ 15 - 8
src/OpenMind/Web/BaseController.php

@@ -13,14 +13,6 @@ class BaseController
   protected $userId;
   private $sanitizedPostRequest;
 
-  /**
-   * @return mixed
-   */
-  public function getSanitizedPostRequest()
-  {
-    return $this->sanitizedPostRequest;
-  }
-
   public function __construct($f3)
   {
     $this->sanitizedPostRequest = $f3->clean($f3->get('POST'));
@@ -60,6 +52,11 @@ class BaseController
     return null;
   }
 
+  /**
+   * Check if username and password are correct and set cookie
+   *
+   * @param $f3
+   */
   public function Login($f3)
   {
     $accountData = $this->getSanitizedPostRequest();
@@ -79,6 +76,16 @@ class BaseController
     $f3->reroute('/homemenu');
   }
 
+  /**
+   * Return the sanitized POST parameters
+   *
+   * @return mixed
+   */
+  public function getSanitizedPostRequest()
+  {
+    return $this->sanitizedPostRequest;
+  }
+
   public function Logout($f3)
   {
     $f3->clear('COOKIE.username');

+ 20 - 0
src/OpenMind/Web/Web.php

@@ -0,0 +1,20 @@
+<?php
+/**
+ * @author Open Mind
+ * @date 21/06/2018
+ * @time 18:23
+ */
+
+namespace OpenMind\Web;
+
+use OpenMind\System\PluginStrategy;
+
+class Web extends PluginStrategy
+{
+  public static function Init()
+  {
+    // Services
+    \F3::route("POST /login", __NAMESPACE__ . '\BaseController->Login');
+    \F3::route("GET /logout", __NAMESPACE__ . '\BaseController->Logout');
+  }
+}

+ 1 - 1
ui/bars.tpl

@@ -1,5 +1,5 @@
 <nav class="navbar fixed-top navbar-expand-lg navbar-dark bg-dark">
-    <a href="{{@BASEURL}}/"><img class="navbar-brand" src="{{@BASEURL}}/ui/images/logo_text.png" height="90"/></a>
+    <a href="{{@BASEURL}}/"><img class="navbar-brand" src="{{@LOGO_CUSTOMER}}" height="90"/></a>
     <div class="collapse navbar-collapse"></div>
     <a class="navbar-brand" href="{{@BASEURL}}/logout">
         <img src="{{@BASEURL}}/ui/images/logout.png" height="90"/>