-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
375 additions
and
3,493 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"title": "Admin Theme Boss", | ||
"summary": "A light and clear theme based on Uikit 3", | ||
"summary": "A light and clear theme based on Uikit 3, extending AdminThemeUikit", | ||
"href": "https://github.com/noelboss/AdminThemeBoss", | ||
"version": "0.1.4", | ||
"version": "0.2.0", | ||
"author": "Noël Bossart", | ||
"autoload": "template=admin", | ||
"icon": "diamond", | ||
"requires": "ProcessWire>=3.0.94" | ||
"requires": "ProcessWire>=3.0.94,AdminThemeUikit" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
<?php | ||
|
||
/** | ||
* © ICF Church – <[email protected]> | ||
* | ||
* This source file is subject to the license file that is bundled | ||
* with this source code in the file LICENSE. | ||
* | ||
* File created/changed: 2018-07-11T09:55:17+02:00 | ||
*/ | ||
|
||
namespace ProcessWire; | ||
|
||
/** | ||
* AdminThemeBoss. | ||
* | ||
* @property bool $isSuperuser Is current user a superuser? | ||
* @property bool $isEditor Does current user have page-edit permission? | ||
* @property bool $isLoggedIn Is current user logged in? | ||
* @property bool $useOffset Use offset/margin for all Inputfields? | ||
* @property array $noBorderTypes Inputfield class names that should always use the noBorder option (when 100% width). | ||
* @property array $cardTypes Inputfield class names that should always use the card option. | ||
* @property array $offsetTypes Inputfield class names that should always use the offset option. | ||
* @property string $logoURL URL to custom logo, relative to PW installation root. | ||
* @property string $variant URL to custom CSS file, relative to PW installation root. | ||
* @property string $layout Layout type (blank=default, sidenav=multi-pane, sidenav-tree=left-tree, sidenav-tree-alt=right-tree) | ||
* @property int $logoAction Logo click action (0=admin root page list, 1=offcanvas nav) | ||
* @property string $userLabel Text containing user {vars} to use for user label in masthead (default="{Name}") | ||
* @property int $maxWidth Maximum layout width in pixels, or 0 for no max (default=1600). | ||
* @property bool|int $groupNotices Whether or not notices should be grouped by type | ||
*/ | ||
class AdminThemeBoss extends WireData implements Module, ConfigurableModule | ||
{ | ||
/** | ||
* Development mode, to be used when developing this module’s code. | ||
*/ | ||
const dev = false; | ||
|
||
/** | ||
* Default logo image file (relative to this dir). | ||
*/ | ||
const logo = 'uikit/custom/images/pw-mark.png'; | ||
|
||
private $adminThemeUikit; | ||
|
||
/******************************************************************************************* | ||
* MARKUP RENDERING METHODS | ||
* | ||
*/ | ||
|
||
/** | ||
* Render a list of breadcrumbs (list items), excluding the containing <ul>. | ||
* | ||
* @return string | ||
*/ | ||
public function renderBreadcrumbs(HookEvent $event) | ||
{ | ||
if (!$event->return) { | ||
return; | ||
} | ||
|
||
$process = $this->wire('page')->process; | ||
if ($process == 'ProcessPageList') { | ||
return ''; | ||
} | ||
$breadcrumbs = $this->wire('breadcrumbs'); | ||
$out = ''; | ||
|
||
// don't show breadcrumbs if only one of them (subjective) | ||
if (count($breadcrumbs) < 2 && $process != 'ProcessPageEdit') { | ||
return ''; | ||
} | ||
|
||
if (strpos($this->layout, 'sidenav') === false) { | ||
$out = '<li>'.$event->object->renderQuickTreeLink().'</li>'; | ||
} | ||
|
||
foreach ($breadcrumbs as $breadcrumb) { | ||
$title = $breadcrumb->get('titleMarkup'); | ||
if (!$title) { | ||
$title = $this->wire('sanitizer')->entities1($this->_($breadcrumb->title)); | ||
} | ||
|
||
$edit = ''; | ||
$icon = $event->object->renderIcon('pencil'); | ||
if (strpos($breadcrumb->url, 'open=') > 0) { | ||
$pageid = explode('open=', $breadcrumb->url); | ||
$pageid = end($pageid); | ||
if (wire('pages')->get($pageid)->editable()) { | ||
$edit = " <a href='../edit/?id=$pageid'>$icon</a>"; | ||
} | ||
} elseif (strpos($breadcrumb->url, '../') !== false && wire('process')) { | ||
// make sure we're editing a page and not a user | ||
if (method_exists(wire('process'), 'getPage')) { | ||
$pageid = wire('process')->getPage()->parent->id; | ||
|
||
if (wire('pages')->get($pageid)->editable()) { | ||
$edit = " <a href='../edit/?id=$pageid'>$icon</a>"; | ||
} | ||
// modify open | ||
$breadcrumb->url = "../?open=$pageid"; | ||
} else { | ||
bd(wire('process')); | ||
} | ||
} | ||
$out .= "<li><a href='$breadcrumb->url'>$title</a>$edit</li>"; | ||
} | ||
|
||
if ($out) { | ||
$out = "<ul class='uk-breadcrumb'>$out</ul>"; | ||
} | ||
|
||
$event->return = $out; | ||
} | ||
|
||
/** | ||
* Initialize and attach hooks. | ||
*/ | ||
public function init() | ||
{ | ||
if (!$this->get('enablemodule')) { | ||
return; | ||
} | ||
|
||
if ($this->get('allusers') && $this->user->admin_theme !== 'AdminThemeUikit') { | ||
$this->user->setAndSave('admin_theme', 'AdminThemeUikit'); | ||
} | ||
|
||
if ($this->get('extendedbreadcrumb')) { | ||
$this->addHookAfter('AdminThemeUikit::renderBreadcrumbs', $this, 'renderBreadcrumbs'); | ||
} | ||
|
||
$this->addHookAfter('Page::render', $this, 'replaceUikitCSS'); | ||
|
||
$this->adminThemeUikit = $this->wire('modules')->get('AdminThemeUikit'); | ||
} | ||
|
||
/** | ||
* Get the primary Uikit CSS file to use. | ||
* | ||
* @return string | ||
*/ | ||
public function replaceUikitCSS(HookEvent $event) | ||
{ | ||
$page = $event->object; | ||
|
||
if ($page->template->name !== 'admin') { | ||
return; | ||
} | ||
|
||
$moduleInfo = $this->wire('modules')->getModuleInfo($this); | ||
|
||
$themecss = $this->adminThemeUikit->getUikitCSS(); | ||
|
||
$config = $this->wire('config'); | ||
$variant = $this->get('variant'); | ||
|
||
$version = $moduleInfo['version']; | ||
$url = $config->urls->httpSiteModules.basename(__DIR__); | ||
|
||
switch ($variant) { | ||
case 'pw': | ||
case 'black': | ||
case 'vibrant': | ||
$variant = $url.'/uikit/dist/css/uikit.'.$variant.'.min.css'; | ||
break; | ||
|
||
default: | ||
$variant = $url.'/uikit/dist/css/uikit.pw.min.css'; | ||
break; | ||
} | ||
|
||
// replace CSS and Logo | ||
$event->return = str_replace($themecss, $variant, $event->return); | ||
|
||
if (!$this->get('useuikitlogo')) { | ||
$themelogo = $this->adminThemeUikit->getLogoURL(); | ||
$logoURL = $config->urls($this->className()).self::logo; | ||
$event->return = str_replace($themelogo, $logoURL, $event->return); | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<?php | ||
|
||
/** | ||
* © ICF Church – <[email protected]> | ||
* | ||
* This source file is subject to the license file that is bundled | ||
* with this source code in the file LICENSE. | ||
* | ||
* File created/changed: 2018-07-11T09:56:38+02:00 | ||
*/ | ||
|
||
namespace ProcessWire; | ||
|
||
if (!defined('PROCESSWIRE')) { | ||
die(); | ||
} | ||
|
||
/** | ||
* Implementation for Uikit admin theme getConfigInputfields method. | ||
* | ||
* @param AdminTheme|AdminThemeBoss $adminTheme | ||
* @param InputfieldWrapper $inputfields | ||
*/ | ||
class AdminThemeBossConfig extends ModuleConfig | ||
{ | ||
public function __construct() | ||
{ | ||
$this->add([ | ||
[ | ||
'type' => 'fieldset', | ||
'name' => 'theme-options', | ||
'label' => $this->_('Theme Options'), | ||
'icon' => 'paint-brush', | ||
'children' => [ | ||
[ | ||
'name' => 'variant', | ||
'type' => 'radios', | ||
'icon' => 'adjust', | ||
'label' => $this->_('Color'), | ||
//'description' => $this->_('If "No" is selected, then upgrades will only be checked manually when you click to Setup > Upgrades.'), | ||
//'notes' => $this->_('Automatic upgrade check requires ProcessWire 2.5.20 or newer.'), | ||
//'optionColumns' => 1, | ||
'value' => $this->get('variant'), | ||
'options' => [ | ||
'pw' => $this->_('ProcessWire Blue'), | ||
'vibrant' => $this->_('Vibrant Blue'), | ||
'black' => $this->_('Black'), | ||
], | ||
], | ||
[ | ||
'name' => 'extendedbreadcrumb', | ||
'type' => 'checkbox', | ||
'icon' => 'link', | ||
'label' => $this->_('Extended Breadcrumb'), | ||
'description' => $this->_('If set, the default breadcrumb will be extended with edit links.'), | ||
'value' => $this->get('extendedbreadcrumb'), | ||
], | ||
], | ||
], | ||
[ | ||
'type' => 'fieldset', | ||
'name' => 'advanced-options', | ||
'label' => $this->_('Advanced Options'), | ||
'icon' => 'cog', | ||
'collapsed' => Inputfield::collapsedYes, | ||
'children' => [ | ||
[ | ||
'name' => 'enablemodule', | ||
'type' => 'checkbox', | ||
'icon' => 'check', | ||
'label' => $this->_('Enable Module'), | ||
'description' => $this->_('Enable this theme. You can untoggle this option to disable the theme without uninstalling this module.'), | ||
'value' => $this->get('enablemodule'), | ||
], | ||
[ | ||
'name' => 'allusers', | ||
'type' => 'checkbox', | ||
'icon' => 'lock', | ||
'label' => $this->_('Enable For All Users'), | ||
'description' => $this->_('If enabled, AdminThemeUikit will be set as theme for all users.'), | ||
'value' => $this->get('allusers'), | ||
], | ||
[ | ||
'name' => 'useuikitlogo', | ||
'type' => 'checkbox', | ||
'icon' => 'reply', | ||
'label' => $this->_('Use AdminThemeUikit Logo'), | ||
'description' => $this->_('Instead of a adark logo, use the one specified in the AdminThemeUikit settings.'), | ||
'value' => $this->get('useuikitlogo'), | ||
], | ||
], | ||
], | ||
]); | ||
} | ||
|
||
public function getDefaults() | ||
{ | ||
return [ | ||
'variant' => 'pw', | ||
'extendedbreadcrumb' => true, | ||
'enablemodule' => true, | ||
'allusers' => true, | ||
'useuikitlogo' => false, | ||
]; | ||
} | ||
} |
Oops, something went wrong.