Skip to content

Commit

Permalink
Provide icons for plugins in admin menu
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 86183b66c5b53b47e5ddb1e0d1c155c06c331d35
Merge: ebfb1ab 4a8f428
Author: Andreas Gohr <andi@splitbrain.org>
Date:   Sat Jan 21 11:20:32 2017 +0100

    Merge branch 'master' of git://github.com/ThisNameIsNotAllowed/dokuwiki into pull-request-1767

    * 'master' of git://github.com/ThisNameIsNotAllowed/dokuwiki:
      Update admin.php
      Update admin.php
      Update _admin.css
      Update admin.php
      Update html.php
      Update _admin.css
      Update html.php
      Update html.php
      Update html.php
      Update.html
      Update html.php
      Update admin.php

commit 4a8f428
Author: ThisNameIsNotAllowed <ThisNameIsNotAllowed@users.noreply.github.com>
Date:   Fri Jan 20 09:25:52 2017 +0100

    Update admin.php

    Changed the code to check for icons being SVG files.
    This should fix php5.3 errors for using method returns straight on.

commit e43b6ca
Author: ThisNameIsNotAllowed <ThisNameIsNotAllowed@users.noreply.github.com>
Date:   Fri Jan 20 08:22:41 2017 +0100

    Update admin.php

    Removed elements that could lead to behaviors that shouldn't occure.

commit 9af82fb
Merge: b99c677 0b8d187
Author: ThisNameIsNotAllowed <ThisNameIsNotAllowed@users.noreply.github.com>
Date:   Thu Jan 19 16:22:02 2017 +0100

    Merge pull request #1 from ThisNameIsNotAllowed/add-c

    Added css, forced the author to use ".svg"-files for plugin icons.

commit 0b8d187
Author: ThisNameIsNotAllowed <ThisNameIsNotAllowed@users.noreply.github.com>
Date:   Thu Jan 19 16:17:34 2017 +0100

    Update _admin.css

    fixed some aligning for plugin names.

commit 9158649
Author: ThisNameIsNotAllowed <ThisNameIsNotAllowed@users.noreply.github.com>
Date:   Thu Jan 19 15:49:20 2017 +0100

    Update admin.php

    Added method to return menu icons only in case their mime type matches svg files.

    Added warning to getMenuIcon comments telling the user to provide svg only.

commit 6df4e0f
Author: ThisNameIsNotAllowed <ThisNameIsNotAllowed@users.noreply.github.com>
Date:   Thu Jan 19 15:46:17 2017 +0100

    Update html.php

    Added code to accept svg files only.
    Also changed names of css classes to suit dokuwiki style.

commit 3435abc
Author: ThisNameIsNotAllowed <ThisNameIsNotAllowed@users.noreply.github.com>
Date:   Thu Jan 19 15:41:06 2017 +0100

    Update _admin.css

    Added css for displaying plugin icons.

commit b99c677
Author: ThisNameIsNotAllowed <ThisNameIsNotAllowed@users.noreply.github.com>
Date:   Thu Nov 24 14:16:23 2016 +0100

    Update html.php

    Changed the list of admin plugins.

    The icons and plugin names appearance can now be influenced by css.

commit 479c651
Author: ThisNameIsNotAllowed <ThisNameIsNotAllowed@users.noreply.github.com>
Date:   Thu Nov 24 13:45:08 2016 +0100

    Update html.php

    Cleaned, due to too much duplicated code.

commit e621fd9
Author: ThisNameIsNotAllowed <ThisNameIsNotAllowed@users.noreply.github.com>
Date:   Wed Nov 23 16:26:14 2016 +0100

    Update html.php

    Changed class name for images shown before plugin names.

commit 9099dac
Author: ThisNameIsNotAllowed <ThisNameIsNotAllowed@users.noreply.github.com>
Date:   Wed Nov 23 16:24:01 2016 +0100

    Update.html

    Added icon to plugin array

commit faea3ce
Author: ThisNameIsNotAllowed <ThisNameIsNotAllowed@users.noreply.github.com>
Date:   Wed Nov 23 15:56:40 2016 +0100

    Update html.php

    Added support to display plugin icons in admin menu.

commit 539e60b
Author: ThisNameIsNotAllowed <ThisNameIsNotAllowed@users.noreply.github.com>
Date:   Wed Nov 23 15:51:39 2016 +0100

    Update admin.php

    Add support for icons in admin menu.
  • Loading branch information
ThisNameIsNotAllowed authored and splitbrain committed Jan 21, 2017
1 parent ebfb1ab commit 3b93167
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 3 deletions.
17 changes: 14 additions & 3 deletions inc/html.php
Expand Up @@ -2073,7 +2073,8 @@ function html_admin(){

$menu[$p] = array('plugin' => $p,
'prompt' => $obj->getMenuText($conf['lang']),
'sort' => $obj->getMenuSort()
'icon' => $obj->getMenuIconSvgOnly(),
'sort' => $obj->getMenuSort(),
);
}

Expand Down Expand Up @@ -2171,10 +2172,20 @@ function ($a, $b) {
// output the menu
ptln('<div class="clearer"></div>');
print p_locale_xhtml('adminplugins');
ptln('<ul>');
ptln('<ul class="admin_plugins icon">');
foreach ($menu as $item) {
if (!$item['prompt']) continue;
ptln(' <li><div class="li"><a href="'.wl($ID, 'do=admin&amp;page='.$item['plugin']).'">'.$item['prompt'].'</a></div></li>');
ptln('<li><div class="li admin_plugin_container">');
ptln('<div class="admin_plugin_icon">');
//add icon to the item, in case of being specified
if(strlen($item['icon']) > 0){
ptln('<img src="'.$item['icon'].'" alt="admin_icon_'.hsc($item['prompt']).'"></img>');
}
ptln('</div>');
ptln('<div class="admin_plugin_name"><a href="'.wl($ID, 'do=admin&amp;page='.$item['plugin']).'">');
ptln($item['prompt']);
ptln('</a></div>');
ptln('</div></li>');
}
ptln('</ul>');
}
Expand Down
30 changes: 30 additions & 0 deletions lib/plugins/admin.php
Expand Up @@ -30,6 +30,36 @@ public function getMenuText($language) {
return $menutext;
}

/**
* Return the path to the icon being displayed in the main admin menu.
* Default means, there won't be any icon.
* (Override this function for setting another image)
*
* CAUTION:
* Only svg-files are allowed
*
*/
public function getMenuIcon(){
return '';
}

/**
* Return the path to the icon being displayed in the main admin menu.
* In case of file mime-type not being SVG, an empty string will be returned.
* @return string menu icon url or empty
*/
public function getMenuIconSvgOnly(){
$returnValue = '';

if(strlen($this->getMenuIcon()) != '' && is_file(DOKU_INC.substr($this->getMenuIcon(), strlen(DOKU_BASE)))){
$calculated = mimetype(DOKU_INC.substr($this->getMenuIcon(), strlen(DOKU_BASE)), false);
if(is_array($calculated) && $calculated[0] == 'svg') {
$returnValue = $this->getMenuIcon();
}
}
return $returnValue;
}

/**
* Determine position in list in admin window
* Lower values are sorted up
Expand Down
49 changes: 49 additions & 0 deletions lib/tpl/dokuwiki/css/_admin.css
Expand Up @@ -49,6 +49,55 @@
background-image: url(../../images/admin/popularity.png);
}

/* DokuWiki additional plugins below */
.dokuwiki ul.admin_plugins {
float: left;
width: 40%;
}

.dokuwiki ul.admin_plugins.no_icon{
float: left;
width: 40%;
}

.dokuwiki ul.admin_plugins.icon{
list-style-type: none;
}

.dokuwiki ul.admin_plugins li {
pading-left: 35px;
margin: 0 0 0.4em 0;
color: inherit;
background: transparent none no-repeat scroll 0 0;
}

.dokuwiki ul.admin_plugins li .admin_plugin_container {
display: block;
height: 20px;
vertical-align: middle;
}

.dokuwiki ul.admin_plugins li .admin_plugin_container div.admin_plugin_icon {
width: 20px;
height: 20px;
display: inline-block;
vertical-align: middle;
}

.dokuwiki ul.admin_plugins li .admin_plugin_container div.admin_plugin_icon img {
height: 20px;
width: 20px;
}

.dokuwiki ul.admin_plugins li .admin_plugin_container div.admin_plugin_name {
padding-left: 0.5em;
vertical-align: middle;
display: inline-block;
text-align: center;
margin: 0 auto;
}


/* DokuWiki version below */
.dokuwiki #admin__version {
clear: left;
Expand Down

0 comments on commit 3b93167

Please sign in to comment.