diff --git a/Block/Adminhtml/Login.php b/Block/Adminhtml/Login.php new file mode 100644 index 0000000..cdd89e4 --- /dev/null +++ b/Block/Adminhtml/Login.php @@ -0,0 +1,61 @@ +helper = $helper; + + parent::__construct($context); + } + + /** + * Return helper + * + * @return \Magenizr\AdminBranding\Helper\Data + */ + public function getHelper() + { + return $this->helper; + } + + /** + * Check if additional text is enabled + * + * @return mixed + */ + public function isAdditionalTextEnabled() + { + return $this->getHelper()->isSetFlag('magento_adminlogin_additional_text_enabled'); + } + + /** + * Return additional text + * + * @return mixed + */ + public function getAdditionalText() + { + return $this->getHelper()->getScopeConfig('magento_adminlogin_additional_text'); + } +} diff --git a/Helper/Data.php b/Helper/Data.php new file mode 100755 index 0000000..4a4b398 --- /dev/null +++ b/Helper/Data.php @@ -0,0 +1,138 @@ +fileSystem = $fileSystem; + $this->directoryList = $directoryList; + $this->storeManager = $storeManager; + + parent::__construct($context); + } + + /** + * @param $image + * @param $enabled + * @param $file + * @return bool|string + */ + public function getAdminLogoSrc($image, $enabled, $file) + { + // Return default image if not enabled + if (!$this->isSetFlag($enabled) || !$this->isEnabled()) { + return $image; + } + + // Path to media folder ( e.g /var/www/src/[project]/pub/media ) + $mediaPath = $this->directoryList->getPath('media'); + + // Uploaded image file via system.xml + $file = explode(',', $this->getScopeConfig($file)); + + if (isset($file[0])) { + // Absolute path to image file + $mediaPathAbsolute = implode('/', [ + $mediaPath, // e.g /var/www/src/[project]/pub/media + self::UPLOAD_DIR, // e.g magenizr_adminbranding/default/ + $file[0] // e.g magento_branding.png + ]); + + // Check if image file actually exists on the filesystem + if ($this->fileSystem->isReadable($mediaPathAbsolute)) { + $mediaPathRelative = '../../../../../../media'; + + $image = implode('/', [ + $mediaPathRelative, + self::UPLOAD_DIR, // e.g magenizr_adminbranding/default/ + $file[0] // e.g magento_branding.png + ]); + + return $image; + } + } + + return $image; + } + + /** + * Return status of the module + * + * @return mixed + */ + public function isEnabled() + { + return $this->isSetFlag('enabled'); + } + + /** + * Use isSetFlag to check boolean fields + * + * @param $field + * @return mixed + */ + public function isSetFlag($field) + { + return $this->scopeConfig->isSetFlag( + self::SECTION . '/' . $field, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + } + + /** + * Get module configuration values from core_config_data + * + * @param $field + * @return mixed + */ + public function getScopeConfig($field) + { + return $this->scopeConfig->getValue( + self::SECTION . '/' . $field, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + } +} diff --git a/Model/Config/Backend/Image.php b/Model/Config/Backend/Image.php new file mode 100644 index 0000000..17db728 --- /dev/null +++ b/Model/Config/Backend/Image.php @@ -0,0 +1,53 @@ +_mediaDirectory->getAbsolutePath( + $this->_appendScopeInfo(\Magenizr\AdminBranding\Helper\Data::UPLOAD_DIR) + ); + } + + /** + * Makes a decision about whether to add info about the scope. + * + * @return boolean + */ + protected function _addWhetherScopeInfo() + { + return true; + } + + /** + * Getter for allowed extensions of uploaded files. + * + * @return string[] + */ + protected function _getAllowedExtensions() + { + return ['jpg', 'jpeg', 'gif', 'png', 'svg']; + } + // @codingStandardsIgnoreEnd +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..96d4bf7 --- /dev/null +++ b/README.md @@ -0,0 +1,65 @@ +# Admin Branding +Create a unique Magento admin login by adding your company logo or a custom text ( HTML support ) underneath the login such as `Implemented by Your Company Ltd` or above the Magento navigation within the backend. + +![Magenizr AdminBranding - Backend Login](https://images2.imgbox.com/5f/43/XpwjZvRQ_o.png) + +## System Requirements +- Magento 2.3.x, 2.4.x +- PHP 5.6.x, 7.x + +## Installation (Composer) + +1. Update your composer.json `composer require "magenizr/magento2-adminbranding":"1.0.0" --no-update` +2. Install dependencies and update your composer.lock `composer update --lock` + +``` +./composer.json has been updated +Loading composer repositories with package information +Updating dependencies (including require-dev) +Package operations: 1 install, 0 updates, 0 removals + - Installing magenizr/magento2-adminbranding (1.0.0): Downloading (100%) +Writing lock file +Generating autoload files +``` + +3. Enable the module and clear static content. + +``` +php bin/magento module:enable Magenizr_AdminBranding --clear-static-content +php bin/magento setup:upgrade +``` + +## Installation (Manually) +1. Download the code. +2. Extract the downloaded tar.gz file. Example: `tar -xzf Magenizr_AdminBranding_1.0.0.tar.gz`. +3. Copy the code into `./app/code/Magenizr/AdminBranding/`. +4. Enable the module and clear static content. + +``` +php bin/magento module:enable Magenizr_AdminBranding --clear-static-content +php bin/magento setup:upgrade +``` + +## Features +* Enable / Disable module +* Upload your logo for login form or above the navigation +* Add a custom text ( HTML support ) underneath the login form + +## Usage +Go to `Stores > Configuration > Advanced > Admin > Admin Branding` and enable the module. Upload your company logo for the login form or above the sidebar. An additional text can be added and enabled below the login form. + +## Support +If you experience any issues, don't hesitate to open an issue on [Github](https://github.com/magenizr/Magenizr_AdminBranding/issues). For a custom build, contact us on [Magento Marketplace](https://marketplace.magento.com/partner/magenizr). + +## Purchase +This module is available for free on [GitHub](https://github.com/magenizr). + +## Contact +Follow us on [GitHub](https://github.com/magenizr), [Twitter](https://twitter.com/magenizr) and [Facebook](https://www.facebook.com/magenizr). + +## History +===== 1.0.0 ===== +* Stable version + +## License +[OSL - Open Software Licence 3.0](https://opensource.org/licenses/osl-3.0.php) diff --git a/composer.json b/composer.json new file mode 100755 index 0000000..2b83501 --- /dev/null +++ b/composer.json @@ -0,0 +1,32 @@ +{ + "name": "magenizr/magento2-adminbranding", + "description": "Admin Branding allows you to replace the Magento® logo on the admin login page as well as on the dashboard. In addition to that, you can display a custom text and link your clients directly to your issue tracking plattform like JIRA or Zendesk.", + "type": "magento2-module", + "version": "1.0.0", + "license": [ + "OSL-3.0" + ], + "authors": [ + { + "name": "Magenizr", + "email": "modules@magenizr.com", + "homepage": "https://www.magenizr.com" + } + ], + "keywords": [ + "Magento 2", + "Admin", + "Backend", + "Branding", + "Replace", + "Logo" + ], + "autoload": { + "files": [ + "registration.php" + ], + "psr-4": { + "Magenizr\\AdminBranding\\": "" + } + } +} diff --git a/etc/acl.xml b/etc/acl.xml new file mode 100755 index 0000000..2d78d35 --- /dev/null +++ b/etc/acl.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml new file mode 100755 index 0000000..14c66d1 --- /dev/null +++ b/etc/adminhtml/system.xml @@ -0,0 +1,82 @@ + + + + + +
+ + + + + + Magento\Config\Model\Config\Source\Yesno + + + + + + Magento\Config\Model\Config\Source\Yesno + + 1 + + + + + + + Magenizr\AdminBranding\Model\Config\Backend\Image + magenizr_adminbranding + + 1 + + + + + + + Magento\Config\Model\Config\Source\Yesno + + 1 + + + + + + + Magenizr\AdminBranding\Model\Config\Backend\Image + magenizr_adminbranding + + 1 + + + + + + Sign In button on the admin login page. Default: No]]> + Magento\Config\Model\Config\Source\Yesno + + 1 + + + + + + + + 1 + + + + +
+
+
diff --git a/etc/config.xml b/etc/config.xml new file mode 100644 index 0000000..b483519 --- /dev/null +++ b/etc/config.xml @@ -0,0 +1,25 @@ + + + + + + + + 0 + 0 + 0 + 0 + Your Company Ltd.]]> + + + + diff --git a/etc/module.xml b/etc/module.xml new file mode 100755 index 0000000..ff95378 --- /dev/null +++ b/etc/module.xml @@ -0,0 +1,19 @@ + + + + + + + + + + diff --git a/i18n/de_DE.csv b/i18n/de_DE.csv new file mode 100755 index 0000000..4acc01f --- /dev/null +++ b/i18n/de_DE.csv @@ -0,0 +1,14 @@ +"Enabled","Aktiviert" +"Disable the module temporarily.","Modul vorübergehend deaktivieren." +"Replace Admin Login Logo","Admin Login Logo ersetzen" +"Replace the Magento® logo on the admin login page. Default: No","Das Magento® Logo auf der Administrator Login Seite ersetzen. Standard: Nein" +"Admin Login Logo","Admin Login Logo" +"Upload a SVG, PNG or GIF file. Recommended format 288x100px.","Eine SVG, PNG oder GIF Datei hochladen. Empfohlenes Format 288x100px." +"Replace Admin Menu Logo","Replace Admin Menu Logo" +"Replace the Magento® logo on top of the admin navigation. Default: No","Das Magento® Logo oberhalb der Navigation ersetzen. Standard: Nein" +"Admin Menu Logo","Admin Navigation Logo" +"Upload a SVG, PNG or GIF file. Recommended format 35x41px.","Eine SVG, PNG oder GIF Datei hochladen. Empfohlenes Format 35x41px." +"Enable Additional Text","Zusätzlichen Text aktivieren" +"Add additional text underneath the Sign In button on the admin login page. Default: No","Zusätzlichen Text unterhalb des Sign In Buttons der Administrator Login Seite darstellen. Standard: Nein" +"Additional Text","Zusätzlicher Text" +"HTML supported.","HTML wird unterstützt." diff --git a/i18n/en_US.csv b/i18n/en_US.csv new file mode 100755 index 0000000..46bf812 --- /dev/null +++ b/i18n/en_US.csv @@ -0,0 +1,14 @@ +"Enabled","Enabled" +"Disable the module temporarily.","Disable the module temporarily." +"Replace Admin Login Logo","Replace Admin Login Logo" +"Replace the Magento® logo on the admin login page. Default: No","Replace the Magento® logo on the admin login page. Default: No" +"Admin Login Logo","Admin Login Logo" +"Upload a SVG, PNG or GIF file. Recommended format 288x100px.","Upload a SVG, PNG or GIF file. Recommended format 288x100px." +"Replace Admin Menu Logo","Replace Admin Menu Logo" +"Replace the Magento® logo on top of the admin navigation. Default: No","Replace the Magento® logo on top of the admin navigation. Default: No" +"Admin Menu Logo","Admin Menu Logo" +"Upload a SVG, PNG or GIF file. Recommended format 35x41px.","Upload a SVG, PNG or GIF file. Recommended format 35x41px." +"Enable Additional Text","Enable Additional Text" +"Add additional text underneath the Sign In button on the admin login page. Default: No","Add additional text underneath the Sign In button on the admin login page. Default: No" +"Additional Text","Additional Text" +"HTML supported.","HTML supported." diff --git a/registration.php b/registration.php new file mode 100755 index 0000000..5b5326d --- /dev/null +++ b/registration.php @@ -0,0 +1,15 @@ + + + + + + + + + images/magento-logo.svg + magento_admin_login_logo_file_enabled + magento_admin_login_logo_file + + + + + diff --git a/view/adminhtml/layout/adminhtml_auth_login.xml b/view/adminhtml/layout/adminhtml_auth_login.xml new file mode 100755 index 0000000..9f76c3d --- /dev/null +++ b/view/adminhtml/layout/adminhtml_auth_login.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + diff --git a/view/adminhtml/layout/default.xml b/view/adminhtml/layout/default.xml new file mode 100644 index 0000000..966cafe --- /dev/null +++ b/view/adminhtml/layout/default.xml @@ -0,0 +1,25 @@ + + + + + + + + + images/magento-icon.svg + magento_admin_menu_logo_file_enabled + magento_admin_menu_logo_file + + + + + diff --git a/view/adminhtml/templates/login.phtml b/view/adminhtml/templates/login.phtml new file mode 100644 index 0000000..f8033ca --- /dev/null +++ b/view/adminhtml/templates/login.phtml @@ -0,0 +1,16 @@ + + +isAdditionalTextEnabled() && $block->getHelper()->isEnabled()): ?> +
+

getAdditionalText(); ?>

+
+ diff --git a/view/adminhtml/web/css/style.less b/view/adminhtml/web/css/style.less new file mode 100644 index 0000000..a07bf00 --- /dev/null +++ b/view/adminhtml/web/css/style.less @@ -0,0 +1,24 @@ +/** + * Magenizr AdminBranding + * + * @category Magenizr + * @package Magenizr_AdminBranding + * @copyright Copyright (c) 2021 Magenizr (https://agency.magenizr.com) + * @license https://www.magenizr.com/license Magenizr EULA + */ + +@border-top-color: #adadad; + +#magenizr-adminbranding { + + width: 288px; + + p { + margin: 25px 0 0 0; + } + + p.border-top { + border-top: 1px solid @border-top-color; + padding-top: 15px; + } +}