From 67e98f280d8c4d98a10e29aeb12635f891565277 Mon Sep 17 00:00:00 2001 From: DaRock Date: Sun, 19 Jan 2020 17:40:30 +0200 Subject: [PATCH 1/3] Support for OpenCart 3.x added --- app/Http/Middleware/AdminMiddleware.php | 4 +- .../{2.3 => 2.x}/opencore.ocmod.zip | Bin .../controller/extension/module/opencore.php | 0 .../admin/controller/startup/opencore.php | 0 .../en-gb/extension/module/opencore.php | 0 .../ro-ro/extension/module/opencore.php | 0 .../template/extension/module/opencore.tpl | 0 .../catalog/controller/startup/opencore.php | 0 .../upload/system/library/db/corepdo.php | 0 opencart-module/3.x/opencore.ocmod.zip | Bin 0 -> 11279 bytes .../controller/extension/module/opencore.php | 132 +++++++++ .../admin/controller/startup/opencore.php | 86 ++++++ .../en-gb/extension/module/opencore.php | 15 + .../ro-ro/extension/module/opencore.php | 15 + .../template/extension/module/opencore.twig | 33 +++ .../catalog/controller/startup/opencore.php | 56 ++++ .../3.x/upload/system/library/db/corepdo.php | 269 ++++++++++++++++++ support/Opencart/Installer.php | 2 +- 18 files changed, 610 insertions(+), 2 deletions(-) rename opencart-module/{2.3 => 2.x}/opencore.ocmod.zip (100%) rename opencart-module/{2.3 => 2.x}/upload/admin/controller/extension/module/opencore.php (100%) rename opencart-module/{2.3 => 2.x}/upload/admin/controller/startup/opencore.php (100%) rename opencart-module/{2.3 => 2.x}/upload/admin/language/en-gb/extension/module/opencore.php (100%) rename opencart-module/{2.3 => 2.x}/upload/admin/language/ro-ro/extension/module/opencore.php (100%) rename opencart-module/{2.3 => 2.x}/upload/admin/view/template/extension/module/opencore.tpl (100%) rename opencart-module/{2.3 => 2.x}/upload/catalog/controller/startup/opencore.php (100%) rename opencart-module/{2.3 => 2.x}/upload/system/library/db/corepdo.php (100%) create mode 100644 opencart-module/3.x/opencore.ocmod.zip create mode 100644 opencart-module/3.x/upload/admin/controller/extension/module/opencore.php create mode 100644 opencart-module/3.x/upload/admin/controller/startup/opencore.php create mode 100644 opencart-module/3.x/upload/admin/language/en-gb/extension/module/opencore.php create mode 100644 opencart-module/3.x/upload/admin/language/ro-ro/extension/module/opencore.php create mode 100644 opencart-module/3.x/upload/admin/view/template/extension/module/opencore.twig create mode 100644 opencart-module/3.x/upload/catalog/controller/startup/opencore.php create mode 100644 opencart-module/3.x/upload/system/library/db/corepdo.php diff --git a/app/Http/Middleware/AdminMiddleware.php b/app/Http/Middleware/AdminMiddleware.php index deb0ff2..071d1f3 100644 --- a/app/Http/Middleware/AdminMiddleware.php +++ b/app/Http/Middleware/AdminMiddleware.php @@ -29,8 +29,10 @@ public function handle(Request $request, Closure $next) $session = Startup::getRegistry('session'); + $tokenKey = getTokenKey(); + /** check if OpenCart admin token is present and if is valid */ - if(empty($session->data['token']) || empty($request->get('token')) || $session->data['token'] != $request->get('token')) { + if(empty($session->data[$tokenKey]) || empty($request->get($tokenKey)) || $session->data[$tokenKey] != $request->get($tokenKey)) { return redirect(basename(DIR_APPLICATION) . '/login'); } diff --git a/opencart-module/2.3/opencore.ocmod.zip b/opencart-module/2.x/opencore.ocmod.zip similarity index 100% rename from opencart-module/2.3/opencore.ocmod.zip rename to opencart-module/2.x/opencore.ocmod.zip diff --git a/opencart-module/2.3/upload/admin/controller/extension/module/opencore.php b/opencart-module/2.x/upload/admin/controller/extension/module/opencore.php similarity index 100% rename from opencart-module/2.3/upload/admin/controller/extension/module/opencore.php rename to opencart-module/2.x/upload/admin/controller/extension/module/opencore.php diff --git a/opencart-module/2.3/upload/admin/controller/startup/opencore.php b/opencart-module/2.x/upload/admin/controller/startup/opencore.php similarity index 100% rename from opencart-module/2.3/upload/admin/controller/startup/opencore.php rename to opencart-module/2.x/upload/admin/controller/startup/opencore.php diff --git a/opencart-module/2.3/upload/admin/language/en-gb/extension/module/opencore.php b/opencart-module/2.x/upload/admin/language/en-gb/extension/module/opencore.php similarity index 100% rename from opencart-module/2.3/upload/admin/language/en-gb/extension/module/opencore.php rename to opencart-module/2.x/upload/admin/language/en-gb/extension/module/opencore.php diff --git a/opencart-module/2.3/upload/admin/language/ro-ro/extension/module/opencore.php b/opencart-module/2.x/upload/admin/language/ro-ro/extension/module/opencore.php similarity index 100% rename from opencart-module/2.3/upload/admin/language/ro-ro/extension/module/opencore.php rename to opencart-module/2.x/upload/admin/language/ro-ro/extension/module/opencore.php diff --git a/opencart-module/2.3/upload/admin/view/template/extension/module/opencore.tpl b/opencart-module/2.x/upload/admin/view/template/extension/module/opencore.tpl similarity index 100% rename from opencart-module/2.3/upload/admin/view/template/extension/module/opencore.tpl rename to opencart-module/2.x/upload/admin/view/template/extension/module/opencore.tpl diff --git a/opencart-module/2.3/upload/catalog/controller/startup/opencore.php b/opencart-module/2.x/upload/catalog/controller/startup/opencore.php similarity index 100% rename from opencart-module/2.3/upload/catalog/controller/startup/opencore.php rename to opencart-module/2.x/upload/catalog/controller/startup/opencore.php diff --git a/opencart-module/2.3/upload/system/library/db/corepdo.php b/opencart-module/2.x/upload/system/library/db/corepdo.php similarity index 100% rename from opencart-module/2.3/upload/system/library/db/corepdo.php rename to opencart-module/2.x/upload/system/library/db/corepdo.php diff --git a/opencart-module/3.x/opencore.ocmod.zip b/opencart-module/3.x/opencore.ocmod.zip new file mode 100644 index 0000000000000000000000000000000000000000..fc0cf6897208e90d49986d486dbb88fce704d1b7 GIT binary patch literal 11279 zcmbuF1yq&I)4*wv5Rh)9K}tYCrCX5h?v6``Qi327(ks7o{z?ToZ`(lSAnKTcY{hzOBDr!#aNHo+2h?ACgFF7*Z zF=vKWF}CPoz4?gzY`>o43}(zVzoLL{aP(fqf?M~od${)Jg6QSWfVTKfq%GeaR}t8F z^j^v~7E(8(&`J+V-p@^zM*>F*+xe5|GEhz&7Ko(dT2)(av@LNQ1VP9_S{hna_N@nTYJofJY6rKc0=ahH7tB6#s~AxmNhEOVsMpr&vW$MvVoS5ovgHbg z5RFsBM_gDA;C*&7+p(n)t?DN@+JZuuRSw?(dy*e>2e^xtx;Za-071YK71%ZM8txTe zwU}=%HS8CTyB1#CmDEcZOUFB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6c zABMcl48YafpB;Ul6i6O?-2VQ2oqF6W>d7zaGynMMQa#ve3Qi)L-utc@B>#p)c7>#R z4e8&U0i3DBcF6?EzhTl|VaEOy^PfBg9Nimoi3Ul~5Wu75*P8_JXqoyiXz=|8d>AUd z8h+p2Ly!aw=Q{tAUaU&`^c|IH!1VprWiaxSYD;Iw+) zgYPtue82g>X;fEe@&AMN`}Zdy=#mSPApUjMWVphe{A=!S-k~k%OXGqhXc#|-($yLY zcqq|bEX!Ad_lGktjr{Ml|H1z$uHLp^#uaENAbFi7uKIf#>rX?uJY0kOySeRh;vfl% zw(DqD{Y`LDNc;W7e?H2CbBi%AcLR_F@vq}v^|$t4bARLS7`;n8NP>p(v%jy_EWrJp z`(N>Y@^{(BrN5#4t`6xsOWe8=`9>F)+E+aA{b&kq?RoLz?{76og7)C+7z9@sQNLyU zI7oxT>fT+#KoSJK4n}ze)_Xnd-&YA7i;H^leU2ar!h>UfEf0WP`Yq4Ab@A23U+wr~ zj{jnR6Hr>z;u+s|KlD@BtZx!Dic9)s%JyqX0Yv|nvT6KB`j2?}R$u@(#PeB|v~NQI z$!CDeXK+LOoN%LFu|M5K$>twJfDW$U020#E@0JEh)4of~UkAXy0#N=H@P}Nk+47PF zk|5@FtgE?P@U^Vpload->language('extension/module/opencore'); + + $this->document->setTitle($this->language->get('heading_title')); + + $data['heading_title'] = $this->language->get('heading_title'); + + $data['breadcrumbs'] = array(); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_home'), + 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) + ); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_extension'), + 'href' => $this->url->link('extension/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true) + ); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('heading_title'), + 'href' => $this->url->link('extension/module/opencore', 'user_token=' . $this->session->data['user_token'], true) + ); + + $this->checkInstalation(); + if (empty($this->errors)) { + $data['success_message'] = $this->language->get('text_success'); + } else { + $data['error_instalation_failure'] = $this->language->get('error_instalation_failure'); + $data['errors'] = $this->errors; + } + + $data['header'] = $this->load->controller('common/header'); + $data['column_left'] = $this->load->controller('common/column_left'); + $data['footer'] = $this->load->controller('common/footer'); + + $this->response->setOutput($this->load->view('extension/module/opencore', $data)); + } + + public function install() + { + $this->installHtaccess(); + + $this->installOcmod('opencore'); + $this->refreshOcmod(); + + $this->installEvent('opencore_admin_menu', 'startup/opencore/before_view', 'admin/view/*/before'); + $this->installEvent('opencore_admin_before_c', 'startup/opencore/before_controller', 'admin/controller/*/before'); + $this->installEvent('opencore_catalog_before_c', 'startup/opencore/before_controller', 'catalog/controller/*/before'); + + $this->addPermissions('extension/module/opencore', ['access', 'modify']); + $this->addPermissions('core/*', ['access', 'modify']); + + $this->session->data['success'] = $this->language->get('text_success'); + } + + public function uninstall() + { + $this->removeHtaccess(); + + $this->removeOcmod('opencore'); + $this->refreshOcmod(); + + $this->removeEvent('opencore_admin_menu'); + $this->removeEvent('opencore_admin_before_c'); + $this->removeEvent('opencore_catalog_before_c'); + + $this->removePermissions('extension/module/opencore', ['access', 'modify']); + $this->removePermissions('core/*', ['access', 'modify']); + + $this->session->data['success'] = $this->language->get('text_success'); + + if (isOc3()) { + $route = 'marketplace/extension'; + } else { + $route = 'extension/extension'; + } + + $location = "index.php?route={$route}&" . $this->getTokenStr() . '&type=module'; + die(""); + } + + private function checkInstalation() + { + /* + * Server Requirements + * PHP >= 5.6.4 + * OpenSSL PHP Extension + * PDO PHP Extension + * Mbstring PHP Extension + */ + + //will fail if the before_controller will not be triggered + if (!class_exists('ControllerStartupOpencore')) { + $this->errors[] = $this->language->get('error_router'); + } + + //TODO: need to check event entry/status for opencore_catalog_before_controll & opencore_admin_menu + + $this->load->model('setting/modification'); + $modification = $this->model_setting_modification->getModificationByCode('opencore'); + + if (empty($modification)) { + $this->errors[] = $this->language->get('error_modification_entry'); + } elseif (empty($modification['status'])) { + $this->errors[] = $this->language->get('error_modification_status'); + } elseif (empty($modification['xml'])) { + $this->errors[] = $this->language->get('error_modification_empty_xml'); + } + + //TODO: check if opencore menu event is installed! + if (!file_exists(DIR_APPLICATION . '.htaccess')) { + $this->errors[] = $this->language->get('error_htaccess_not_found'); + } + } +} diff --git a/opencart-module/3.x/upload/admin/controller/startup/opencore.php b/opencart-module/3.x/upload/admin/controller/startup/opencore.php new file mode 100644 index 0000000..b01d755 --- /dev/null +++ b/opencart-module/3.x/upload/admin/controller/startup/opencore.php @@ -0,0 +1,86 @@ +executeIfRouteExists($route, $data, $output); + + /** + * in case the view\/*\/before event is not activated by default we can call + * $this->event->register('view/\*\/before', new Action('startup/opencore/before_view')); + */ + } + + /** + * Adds admin menu entries + * + * @param string $route + * @param array $data + */ + public function before_view($route, &$data) + { + if (isset($this->booted[$route])) { + return; + } + + switch ($route) { + case 'common/column_left': + //adding entries into admin menu for OpenCore panel + $data['menus'][] = [ + 'id' => 'opencore-menu', + 'icon' => 'fa-cube', + 'name' => 'OpenCore', + 'href' => $this->url->link('core/home', $this->getTokenStr()), + 'children' => [] + ]; + break; + case 'user/user_group_form': + //adding permissions into admin user/permissions page for OpenCore panel + $data['permissions'][] = 'core/*'; + + //get modules + $modules = app('modules')->all(); + foreach ($modules as $module) { + if ($module->enabled()) { + $data['permissions'][] = strtolower($module->getName()) . '/*'; + } + } + break; + } + + $this->booted($route); + } + + private function booted($route) + { + $this->booted[$route] = true; + } +} diff --git a/opencart-module/3.x/upload/admin/language/en-gb/extension/module/opencore.php b/opencart-module/3.x/upload/admin/language/en-gb/extension/module/opencore.php new file mode 100644 index 0000000..c198dba --- /dev/null +++ b/opencart-module/3.x/upload/admin/language/en-gb/extension/module/opencore.php @@ -0,0 +1,15 @@ + + +
+ {% if success_message %} +
{{ success_message }} + +
+ {% endif %} + {% if error is defined %} +
{{ error_instalation_failure }} + +
+ {% endif %} + {% if error is defined %} + {% for error in errors %} +
{{ error }} + +
+ {% endfor %} + {% endif %} +
+ +{{ footer }} diff --git a/opencart-module/3.x/upload/catalog/controller/startup/opencore.php b/opencart-module/3.x/upload/catalog/controller/startup/opencore.php new file mode 100644 index 0000000..6f82042 --- /dev/null +++ b/opencart-module/3.x/upload/catalog/controller/startup/opencore.php @@ -0,0 +1,56 @@ +executeIfRouteExists($route, $data, $output); + + /** + * in case the view\/*\/before event is not activated by default we can call + * $this->event->register('view/\*\/before', new Action('startup/opencore/before_view')); + */ + } + + /** + * Before loading views event + * + * @param string $route + * @param array $data + */ + /* public function before_view($route, &$data) + { + return null; + } */ +} diff --git a/opencart-module/3.x/upload/system/library/db/corepdo.php b/opencart-module/3.x/upload/system/library/db/corepdo.php new file mode 100644 index 0000000..3d9a1bc --- /dev/null +++ b/opencart-module/3.x/upload/system/library/db/corepdo.php @@ -0,0 +1,269 @@ + PDO::CASE_NATURAL, + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL, + PDO::ATTR_STRINGIFY_FETCHES => false, + PDO::ATTR_EMULATE_PREPARES => false, + //PDO::ATTR_PERSISTENT => false, + //PDO::MYSQL_ATTR_SSL_CA => false + ]; + + private $charset = 'utf8mb4'; //original was: utf8 + private $collation = 'utf8mb4_unicode_ci';//original was: utf8_general_ci + + public function __construct($hostname, $username, $password, $database, $port = '3306') + { + try { + $this->connection = new PDO($this->getDsn($hostname, $database, $port), $username, $password, $this->options); + } catch (PDOException $e) { + throw new Exception('Failed to connect to database. Reason: \'' . $e->getMessage() . '\''); + } + + $this->configureEncoding(); + + + // Next, we will check to see if a timezone has been specified in this config + // and if it has we will issue a statement to modify the timezone with the + // database. Setting this DB timezone is an optional configuration item. + $this->configureTimezone(); + + if (defined('DB_MODES')) { + $this->setCustomModes(); + } elseif (defined('DB_STRICT')) { + $this->connection->prepare($this->strictMode())->execute(); + } else { + $this->connection->prepare("set session sql_mode='NO_ENGINE_SUBSTITUTION'")->execute(); + } + } + + /** + * Create a DSN string from a configuration. + * + * Chooses socket or host/port based on the 'unix_socket' config value. + * + * @param array $config + * @return string + */ + protected function getDsn($hostname, $database, $port) + { + return $this->hasSocket() + ? $this->getSocketDsn($database) + : $this->getHostDsn($hostname, $database, $port); + } + + /** + * Determine if the given configuration array has a UNIX socket value. + * + * @param array $config + * @return bool + */ + protected function hasSocket() + { + return defined('DB_UNIX_SOCKET') && ! empty(DB_UNIX_SOCKET); + } + + /** + * Get the DSN string for a socket configuration. + * + * @param array $config + * @return string + */ + protected function getSocketDsn($database) + { + return "mysql:unix_socket=" . DB_UNIX_SOCKET . ";dbname={$database}"; + } + + /** + * Get the DSN string for a host / port configuration. + * + * @param array $config + * @return string + */ + protected function getHostDsn($hostname, $database, $port) + { + return isset($port) + ? "mysql:host={$hostname};port={$port};dbname={$database}" + : "mysql:host={$hostname};dbname={$database}"; + } + + /** + * Set the connection character set and collation. + * + * @return void + */ + protected function configureEncoding() + { + $this->charset = defined('DB_CHARSET') ? DB_CHARSET : $this->charset; + $this->collation = defined('DB_COLLATION') ? DB_COLLATION : $this->collation; + + $this->connection->prepare("set names '{$this->charset}' collate '{$this->collation}'")->execute(); + } + + /** + * Set the timezone on the connection. + * + * @return void + */ + protected function configureTimezone() + { + if (defined('DB_TIMEZONE')) { + $this->connection->prepare('set time_zone="' . DB_TIMEZONE . '"')->execute(); + } + } + + /** + * Get the query to enable strict mode. + * + * @return string + */ + protected function strictMode() + { + if (version_compare($this->connection->getAttribute(PDO::ATTR_SERVER_VERSION), '8.0.11') >= 0) { + return "set session sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'"; + } + + return "set session sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'"; + } + + /** + * Set the custom modes on the connection. + * + * @param array $config + * @return void + */ + protected function setCustomModes() + { + $this->connection->prepare("set session sql_mode='" . DB_MODES . "'")->execute(); + } + + public function getConnection() + { + return $this->connection; + } + + public function prepare($sql) + { + $this->statement = $this->connection->prepare($sql); + } + + public function bindParam($parameter, $variable, $data_type = \PDO::PARAM_STR, $length = 0) + { + if ($length) { + $this->statement->bindParam($parameter, $variable, $data_type, $length); + } else { + $this->statement->bindParam($parameter, $variable, $data_type); + } + } + + public function execute() + { + try { + if ($this->statement && $this->statement->execute()) { + $data = array(); + + while ($row = $this->statement->fetch(\PDO::FETCH_ASSOC)) { + $data[] = $row; + } + + $result = new \stdClass(); + $result->row = (isset($data[0])) ? $data[0] : array(); + $result->rows = $data; + $result->num_rows = $this->statement->rowCount(); + } + } catch (PDOException $e) { + throw new Exception('Error: ' . $e->getMessage() . ' Error Code : ' . $e->getCode()); + } + } + + public function query($sql, $params = array()) + { + $this->statement = $this->connection->prepare($sql); + + $result = false; + + try { + if ($this->statement && $this->statement->execute($params)) { + $data = array(); + + while ($row = $this->statement->fetch(PDO::FETCH_ASSOC)) { + $data[] = $row; + } + + $result = new \stdClass(); + $result->row = (isset($data[0]) ? $data[0] : array()); + $result->rows = $data; + $result->num_rows = $this->statement->rowCount(); + } + } catch (PDOException $e) { + throw new Exception('Error: ' . $e->getMessage() . ' Error Code : ' . $e->getCode() . '
' . $sql); + } + + if ($result) { + return $result; + } else { + $result = new \stdClass(); + $result->row = array(); + $result->rows = array(); + $result->num_rows = 0; + return $result; + } + } + + public function escape($value) + { + return str_replace(array("\\", "\0", "\n", "\r", "\x1a", "'", '"'), array("\\\\", "\\0", "\\n", "\\r", "\Z", "\'", '\"'), $value); + } + + public function countAffected() + { + if ($this->statement) { + return $this->statement->rowCount(); + } else { + return 0; + } + } + + public function getLastId() + { + return $this->connection->lastInsertId(); + } + + public function isConnected() + { + if ($this->connection) { + return true; + } else { + return false; + } + } + + public function __destruct() + { + $this->connection = null; + } +} diff --git a/support/Opencart/Installer.php b/support/Opencart/Installer.php index fc6f560..7fa092b 100644 --- a/support/Opencart/Installer.php +++ b/support/Opencart/Installer.php @@ -32,7 +32,7 @@ public function installOcmod($code) ); if (isOc3()) { - $query = $this->db->query('SELECT * FROM `' . DB_PREFIX . 'extension` WHERE ode = "' . $this->db->escape($code) . '"'); + $query = $this->db->query('SELECT * FROM `' . DB_PREFIX . 'extension` WHERE code = "' . $this->db->escape($code) . '"'); $modification_data['extension_install_id'] = $query->num_rows ? (int) $query->row['extension_id'] : 0; From 3e20f47645095c31396c96507356a79c043e287f Mon Sep 17 00:00:00 2001 From: darock Date: Mon, 20 Jan 2020 10:47:31 +0200 Subject: [PATCH 2/3] 3.x css fix & Readme update --- README.md | 15 +++++++++++---- public/css/admin.css | 11 ++++++++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9d59242..a48369c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -

OpenCore

+

OpenCore

**An application build on Laravel which can run as a subsystem for OpenCart system.** @@ -51,7 +51,7 @@ admin / setting / server / Use SEO URLs: Yes 6. php artisan key:generate 7. php artisan migrate:install 8. php artisan migrate -9. copy OpenCart extension files from core/opencart-module/2.3/upload to you OpenCart root folder +9. copy OpenCart extension files from core/opencart-module/(2.x|3.x)/upload to you OpenCart root folder 10. go to OpenCart admin panel / extensions / extensions / modules, find OpenCore module and install it 11. click on the OpenCore icon from admin / left column / section "System Requirements" and make sure there's nothing marked with red 12. Optional: in order to enable Developer & Example modules you need to access admin / user / user groups section and add permission for them @@ -117,5 +117,12 @@ MIT license. Please see the [license file](LICENSE) for more information. ## Screenshots - - +OpenCore home OpenCart 2x +OpenCore home OpenCart 3x +System Requirements +OpenCore Modules management +Developer Module +Logs Dashboard +Tasks +Add Task +Example Module diff --git a/public/css/admin.css b/public/css/admin.css index a183737..3cbb242 100644 --- a/public/css/admin.css +++ b/public/css/admin.css @@ -3,7 +3,8 @@ background: -webkit-linear-gradient(left,#a0328c 30%,#7040a4 50%,#4359c7 65%,#0082e6 85%); background: linear-gradient(to right,#a0328c 30%,#7040a4 50%,#4359c7 65%,#0082e6 85%); will-change: transform; - z-index:1 + z-index:1; + min-height: 50px; } .navbar-color .icon-bar { background-color: #fff; @@ -11,6 +12,14 @@ .navbar-color, .navbar-color ul:not(.dropdown-menu) > li > a, .navbar-colorul:not(.dropdown-menu) > li > a:visited, .navbar-color .navbar-header a { color:#fff; } +.navbar-color .navbar-header a { + padding: 16.5px 15px; + line-height: 17px; + height: 50px; +} +.navbar-color .navbar-nav > li > a { + line-height: 20px; +} .navbar-color .nav > li.active, .navbar-color .nav > li:hover { background: rgba(255, 255, 255, 0.1); } From 8ef628016a15aafe96d49b4201727bb873e2d4ae Mon Sep 17 00:00:00 2001 From: darock Date: Mon, 20 Jan 2020 10:51:07 +0200 Subject: [PATCH 3/3] Version update --- support/Opencart/Startup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support/Opencart/Startup.php b/support/Opencart/Startup.php index 208bdfc..cf00dc3 100644 --- a/support/Opencart/Startup.php +++ b/support/Opencart/Startup.php @@ -14,7 +14,7 @@ } if (!defined('OPENCORE_VERSION')) { - define('OPENCORE_VERSION', '1.1.0'); + define('OPENCORE_VERSION', '1.2.0'); } require_once __DIR__ . '/../../vendor/autoload.php';