浏览代码

Introduced external link icon support (#6) and FIXED unexpected behavior with icon link (#7). Thanks to @atomparticle

Giuseppe Di Terlizzi 9 年之前
父节点
当前提交
fd67e1b467
共有 9 个文件被更改,包括 354 次插入310 次删除
  1. 27 25
      action.php
  2. 1 1
      plugin.info.txt
  3. 8 4
      syntax/fa.php
  4. 18 17
      syntax/flag.php
  5. 20 19
      syntax/fugue.php
  6. 8 4
      syntax/glyphicon.php
  7. 257 227
      syntax/icon.php
  8. 10 9
      syntax/oxygen.php
  9. 5 4
      syntax/silk.php

+ 27 - 25
action.php

@@ -1,7 +1,7 @@
 <?php
 /**
  * Icons Action Plugin
- * 
+ *
  * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
  * @author     Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com>
  * @copyright  (C) 2015, Giuseppe Di Terlizzi
@@ -16,31 +16,33 @@ if(!defined('DOKU_INC')) die();
  * Add external CSS file to DokuWiki
  */
 class action_plugin_icons extends DokuWiki_Action_Plugin {
- 
-    /**
-     * Register events
-     *
-     * @param  Doku_Event_Handler  $controller
-     */
-    public function register(Doku_Event_Handler $controller) {
-        $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this,
-                                   '_hookcss');
-    }
- 
-    /**
-     * Event handler
-     *
-     * @param  Doku_Event  &$event
-     */
-    public function _hookcss(Doku_Event &$event, $param) {
-
-        if ($this->getConf('loadFontAwesome')) {
-            $event->data['link'][] = array(
-              'type'    => 'text/css',
-              'rel'     => 'stylesheet',
-              'href'    => $this->getConf('fontAwesomeURL'));
-        }
 
+  /**
+   * Register events
+   *
+   * @param  Doku_Event_Handler  $controller
+   */
+  public function register(Doku_Event_Handler $controller) {
+
+    if ($this->getConf('loadFontAwesome')) {
+      $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this,
+                                 '_hookcss');
     }
 
+  }
+
+  /**
+   * Event handler
+   *
+   * @param  Doku_Event  &$event
+   */
+  public function _hookcss(Doku_Event &$event, $param) {
+
+    $event->data['link'][] = array(
+      'type'    => 'text/css',
+      'rel'     => 'stylesheet',
+      'href'    => $this->getConf('fontAwesomeURL'));
+
+  }
+
 }

+ 1 - 1
plugin.info.txt

@@ -1,7 +1,7 @@
 base icons
 author Giuseppe Di Terlizzi
 email giuseppe.diterlizzi@gmail.com
-date 2015-09-18
+date 2016-01-11
 name Icons Plugin
 desc Embed icons in Dokuwiki
 url http://www.dokuwiki.org/plugin:icons

+ 8 - 4
syntax/fa.php

@@ -1,18 +1,22 @@
 <?php
 /**
  * Plugin Icons: Font Awesome helper
- * 
+ *
  * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
  * @author     Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com>
  * @copyright  (C) 2015, Giuseppe Di Terlizzi
  */
- 
+
 // must be run within Dokuwiki
 if(!defined('DOKU_INC')) die();
 
 require_once(dirname(__FILE__).'/icon.php');
 
 class syntax_plugin_icons_fa extends syntax_plugin_icons_icon {
-    protected $pattern = '{{fa>.+?}}';
-    const IS_ICON = false;
+
+  const IS_ICON      = false;
+  const IS_FONT_ICON = true;
+
+  protected $pattern = '{{fa>.+?}}';
+
 }

+ 18 - 17
syntax/flag.php

@@ -1,12 +1,12 @@
 <?php
 /**
  * Plugin Icons: Flag helper
- * 
+ *
  * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
  * @author     Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com>
  * @copyright  (C) 2015, Giuseppe Di Terlizzi
  */
- 
+
 // must be run within Dokuwiki
 if(!defined('DOKU_INC')) die();
 
@@ -14,29 +14,30 @@ require_once(dirname(__FILE__).'/icon.php');
 
 class syntax_plugin_icons_flag extends syntax_plugin_icons_icon {
 
-    protected $pattern = '{{flag>.+?}}';
-
-    const IS_ICON = true;
-
-    public static function makePath($icon, $size, $base_url) {
+  const IS_ICON      = true;
+  const IS_FONT_ICON = false;
 
-      if ($translation = plugin_load('helper', 'translation')) {
+  protected $pattern = '{{flag>.+?}}';
 
-        $translation_url  = rtrim(DOKU_BASE, '/')   . '/lib/plugins/translation/flags';
-        $translation_path = rtrim(DOKU_PLUGIN, '/') . '/translation/flags';
+  public static function makePath($icon, $size, $base_url) {
 
-        if (file_exists("$translation_path/$icon.gif")) {
-          return "$translation_url/$icon.gif";
-        }
+    if ($translation = plugin_load('helper', 'translation')) {
 
-        if (file_exists("$translation_path/more/$icon.gif")) {
-          return "$translation_url/more/$icon.gif";
-        }
+      $translation_url  = rtrim(DOKU_BASE, '/')   . '/lib/plugins/translation/flags';
+      $translation_path = rtrim(DOKU_PLUGIN, '/') . '/translation/flags';
 
+      if (file_exists("$translation_path/$icon.gif")) {
+        return "$translation_url/$icon.gif";
       }
 
-      return "$base_url/$icon-icon.png";
+      if (file_exists("$translation_path/more/$icon.gif")) {
+        return "$translation_url/more/$icon.gif";
+      }
 
     }
 
+    return "$base_url/$icon-icon.png";
+
+  }
+
 }

+ 20 - 19
syntax/fugue.php

@@ -1,12 +1,12 @@
 <?php
 /**
  * Plugin Icons: Fugue helper
- * 
+ *
  * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
  * @author     Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com>
  * @copyright  (C) 2015, Giuseppe Di Terlizzi
  */
- 
+
 // must be run within Dokuwiki
 if(!defined('DOKU_INC')) die();
 
@@ -14,28 +14,29 @@ require_once(dirname(__FILE__).'/icon.php');
 
 class syntax_plugin_icons_fugue extends syntax_plugin_icons_icon {
 
-    protected $pattern = '{{fugue>.+?}}';
+  const IS_ICON      = true;
+  const IS_FONT_ICON = false;
 
-    const IS_ICON = true;
+  protected $pattern = '{{fugue>.+?}}';
 
-    public static function makePath($icon, $size, $base_url) {
+  public static function makePath($icon, $size, $base_url) {
 
-        $sizes = array(16, 24, 32);
-        $size  = (($size > max($sizes)) ? max($sizes) : $size);
+    $sizes = array(16, 24, 32);
+    $size  = (($size > max($sizes)) ? max($sizes) : $size);
 
-        switch ($size) {
-            case 0:
-            case 16:
-               $size = 'icons'; break;
-            case 24:
-              $size = 'bonus/icons-24'; break;
-            case 32:
-              $size = 'bonus/icons-32'; break;
-            default:
-              $size = 'icons';
-        }
+    switch ($size) {
+      case 0:
+      case 16:
+         $size = 'icons'; break;
+      case 24:
+        $size = 'bonus/icons-24'; break;
+      case 32:
+        $size = 'bonus/icons-32'; break;
+      default:
+        $size = 'icons';
+    }
 
-        return "$base_url/$size/$icon.png";
+    return "$base_url/$size/$icon.png";
 
     }
 

+ 8 - 4
syntax/glyphicon.php

@@ -1,18 +1,22 @@
 <?php
 /**
  * Plugin Icons: Glyphicons helper
- * 
+ *
  * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
  * @author     Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com>
  * @copyright  (C) 2015, Giuseppe Di Terlizzi
  */
- 
+
 // must be run within Dokuwiki
 if(!defined('DOKU_INC')) die();
 
 require_once(dirname(__FILE__).'/icon.php');
 
 class syntax_plugin_icons_glyphicon extends syntax_plugin_icons_icon {
-    protected $pattern = '{{glyphicon>.+?}}';
-    const IS_ICON = false;
+
+  const IS_ICON      = false;
+  const IS_FONT_ICON = true;
+
+  protected $pattern = '{{glyphicon>.+?}}';
+
 }

+ 257 - 227
syntax/icon.php

@@ -1,7 +1,7 @@
 <?php
 /**
  * Plugin Icons for DokuWiki
- * 
+ *
  * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
  * @author     Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com>
  * @copyright  (C) 2015, Giuseppe Di Terlizzi
@@ -12,306 +12,336 @@ if(!defined('DOKU_INC')) die();
 
 class syntax_plugin_icons_icon extends DokuWiki_Syntax_Plugin {
 
-    protected $pattern = '{{icon>.+?}}';
-    protected $flags   = array();
-    protected $classes = array();
-    protected $styles  = array();
-
-    /**
-     * Syntax Type
-     *
-     * Needs to return one of the mode types defined in $PARSER_MODES in parser.php
-     *
-     * @return string
-     */
-    public function getType() { return 'substition'; }
-
-    /**
-     * Sort for applying this mode
-     *
-     * @return int
-     */
-    public function getSort() { return 299; }
-
-    /**
-     * @param  string  $mode
-     */
-    public function connectTo($mode) {
-        $this->Lexer->addSpecialPattern($this->pattern, $mode, 'plugin_icons_'.$this->getPluginComponent());
-        $this->Lexer->addSpecialPattern('\[\[[^\}]+\|'.$this->pattern.'\]\]', $mode, 'plugin_icons_'.$this->getPluginComponent());
+  const IS_ICON      = null;
+  const IS_FONT_ICON = null;
+
+  protected $pattern     = '{{icon>.+?}}';
+  protected $linkPattern = '\[\[[^\]\r\n]*\|%s\]\]';
+
+  protected $flags   = array();
+  protected $classes = array();
+  protected $styles  = array();
+
+  /**
+   * Syntax Type
+   *
+   * Needs to return one of the mode types defined in $PARSER_MODES in parser.php
+   *
+   * @return string
+   */
+  public function getType() { return 'substition'; }
+
+  /**
+   * Sort for applying this mode
+   *
+   * @return int
+   */
+  public function getSort() { return 299; }
+
+  /**
+   * @param  string  $mode
+   */
+  public function connectTo($mode) {
+    $this->Lexer->addSpecialPattern($this->pattern, $mode, 'plugin_icons_'.$this->getPluginComponent());
+    $this->Lexer->addSpecialPattern(sprintf($this->linkPattern, $this->pattern), $mode, 'plugin_icons_'.$this->getPluginComponent());
+  }
+
+  /**
+   * Handler to prepare matched data for the rendering process
+   *
+   * @param   string        $match    The text matched by the patterns
+   * @param   int           $state    The lexer state for the match
+   * @param   int           $pos      The character position of the matched text
+   * @param   Doku_Handler  $handler  The Doku_Handler object
+   * @return  bool|array              Return an array with all data you want to use in render, false don't add an instruction
+   */
+  public function handle($match, $state, $pos, Doku_Handler $handler) {
+
+    $url   = null;
+    $flags = array();
+    $title = null;
+    $pack  = null;
+    $icon  = null;
+
+    $match = substr($match, 2, -2); // strip markup
+
+    @list($match, $title, $title2) = explode('|', $match);
+
+    if (isset($title2)) $title .= '}}';
+
+    if (isset($title) && preg_match('/'.$this->pattern.'/', $title)) {
+
+      $url   = $match;
+      $match = $title;
+
+      $match = substr($match, 2, -2); // strip markup
+      list($match, $title) = explode('|', $match);
+
+      if (isset($title2)) $title = rtrim($title2, '}');
+
     }
 
-    /**
-     * Handler to prepare matched data for the rendering process
-     *
-     * @param   string        $match    The text matched by the patterns
-     * @param   int           $state    The lexer state for the match
-     * @param   int           $pos      The character position of the matched text
-     * @param   Doku_Handler  $handler  The Doku_Handler object
-     * @return  bool|array              Return an array with all data you want to use in render, false don't add an instruction
-     */ 
-    public function handle($match, $state, $pos, Doku_Handler $handler) {
+    list($match, $flags)  = explode('?', $match, 2);
+    list($pack, $icon)    = explode('>', $match, 2);
 
-        $url   = null;
-        $flags = array();
-        $title = null;
-        $pack  = null;
-        $icon  = null;
+    return array($pack, $icon, explode('&', $flags), $title, $url, $match, $state, $pos);
 
-        $match = substr($match, 2, -2); // strip markup
+  }
 
-        @list($match, $title, $title2) = explode('|', $match);
+  /**
+   * Handles the actual output creation.
+   *
+   * @param   string         $mode      output format being rendered
+   * @param   Doku_Renderer  $renderer  the current renderer object
+   * @param   array          $data      data created by handler()
+   * @return  boolean                   rendered correctly? (however, returned value is not used at the moment)
+   */
+  public function render($mode, Doku_Renderer $renderer, $data) {
 
-        if (isset($title2)) $title .= '}}';
+    if ($mode !== 'xhtml') return false;
 
-        if (isset($title) && preg_match('/'.$this->pattern.'/', $title)) {
+    /** @var Doku_Renderer_xhtml $renderer */
 
-          $url   = $match;
-          $match = $title;
+    list($pack, $icon, $flags, $title, $url) = $data;
+    $this->parseFlags($pack, $icon, $flags);
 
-          $match = substr($match, 2, -2); // strip markup
-          list($match, $title) = explode('|', $match);
+    if ($this->isIcon()) {
 
-          if (isset($title2)) $title = rtrim($title2, '}');
+      $icon_size   = $this->getFlag('size');
+      $icon_pack   = $this->getFlag('pack');
+      $base_path   = rtrim($this->getConf(sprintf('%sURL', $icon_pack)), '/');
+      $icon_path   = $this->makePath($icon, $icon_size, $base_path);
+      $icon_markup = sprintf('<img src="%s" title="%s" class="%s" style="%s" />',
+                             $icon_path, $title,
+                             $this->toClassString($this->getClasses()),
+                             $this->toInlineStyle($this->getStyles()));
 
-        }
+    } else {
 
-        list($match, $flags)  = explode('?', $match, 2);
-        list($pack, $icon)    = explode('>', $match, 2);
+      $this->classes[] = $this->getFlag('pack');
+      $this->classes[] = sprintf('%s-%s', $this->getFlag('pack'), $icon);
 
-        return array($pack, $icon, explode('&', $flags), $title, $url, $match, $state, $pos);
+      $icon_markup = sprintf('<i class="%s" style="%s" title="%s"></i>',
+                             $this->toClassString($this->getClasses()),
+                             $this->toInlineStyle($this->getStyles()),
+                             $title);
 
     }
 
-    /**
-     * Handles the actual output creation.
-     *
-     * @param   string         $mode      output format being rendered
-     * @param   Doku_Renderer  $renderer  the current renderer object
-     * @param   array          $data      data created by handler()
-     * @return  boolean                   rendered correctly? (however, returned value is not used at the moment)
-     */
-    public function render($mode, Doku_Renderer $renderer, $data) {
+    if (isset($url)) {
 
-        if ($mode == 'xhtml') {
+      global $conf;
+      global $ID;
 
-            /** @var Doku_Renderer_xhtml $renderer */
+      $is_external = false;
+      $exists      = false;
+      $link        = array();
 
-            list($pack, $icon, $flags, $title, $url) = $data;
-            $this->parseFlags($pack, $icon, $flags);
+      if (preg_match('/^(http?|ftp?|www?)/', $url)) {
+        $is_external = true;
+      } else {
+        resolve_pageid(getNS($ID), $url, $exists);
+        $url = wl($url);
+      }
 
-            $class_icon = 'syntax_plugin_icons_'.$this->getFlag('pack');
+      $link['target'] = ($is_external) ? $conf['target']['extern'] : $conf['target']['wiki'];
+      $link['style']  = '';
+      $link['pre']    = '';
+      $link['suf']    = '';
+      $link['more']   = '';
+      $link['class']  = '';
+      $link['url']    = $url;
+      $link['name']   = $icon_markup;
 
-            if (constant("$class_icon::IS_ICON")) {
+      if ($exists) {
+        $link['class'] = 'wikilink1';
+      } else {
 
-              unset($this->styles['font-size']);
-              $size      = $this->getFlag('size');
-              $base_path = rtrim($this->getConf("{$pack}URL"), '/');
-              $path      = call_user_func_array(array($class_icon, 'makePath'), array($icon, $size, $base_path));
+        $link['rel'] = 'nofollow';
 
-              $icon_markup = sprintf('<img src="%s" title="%s" class="%s" style="%s" />',
-                                     $path, $title,
-                                     $this->toClassString($this->getClasses()),
-                                     $this->toInlineStyle($this->getStyles()));
+        if (! $is_external) {
+          $link['class'] = 'wikilink2';
+        }
 
-            } else {
+      }
 
-              $this->classes[] = $this->getFlag('pack');
-              $this->classes[] = $this->getFlag('pack') . '-' . $icon;
-  
-              $icon_markup = sprintf('<i class="%s" style="%s" title="%s"></i>',
-                                     $this->toClassString($this->getClasses()),
-                                     $this->toInlineStyle($this->getStyles()),
-                                     $title);
+      $renderer->doc .= $renderer->_formatLink($link);
+      return true;
 
-            }
+    }
 
-            if (isset($url)) {
+    $renderer->doc .= $icon_markup;
+    return true;
 
-              global $conf;
-              global $ID;
+  }
 
-              resolve_pageid(getNS($ID), $url, $exists, $this->date_at, true);
+  protected function isIcon() {
+    $class_icon = get_class($this);
+    return constant("$class_icon::IS_ICON");
+  }
 
-              $link['target'] = $conf['target']['wiki'];
-              $link['style']  = '';
-              $link['pre']    = '';
-              $link['suf']    = '';
-              $link['more']   = '';
-              $link['class']  = '';
-              $link['url']    = wl($url);
-              $link['name']   = $icon_markup;
+  protected function isFontIcon() {
+    $class_icon = get_class($this);
+    return constant("$class_icon::IS_FONT_ICON");
+  }
 
-              if ($exists) {
-                $link['class'] = 'wikilink1';
-              } else {
-                $link['class'] = 'wikilink2';
-                $link['rel']   = 'nofollow';
-              }
+  protected function toClassString($things) {
+    return trim(implode(' ', $things), ' ');
+  }
 
-              $renderer->doc .= $renderer->_formatLink($link);
+  protected function toInlineStyle($things) {
 
-            } else {
-              $renderer->doc .= $icon_markup;
-            }
+    $result = '';
 
-            return true;
+    foreach ($things as $property => $value) {
+      $result .= "$property:$value;";
+    }
 
-        }
+    $result = trim($result, ';');
 
-        return false;
+    return $result;
 
-    }
+  }
 
-    protected function toClassString($things) {
-      return trim(implode(' ', $things), ' ');
-    }
+  protected function getFlag($name) {
+    return (isset($this->flags[$name]) ? $this->flags[$name] : null);
+  }
 
-    protected function toInlineStyle($things) {
+  protected function getFlags() {
+    return $this->flags;
+  }
 
-      $result = '';
+  protected function parseFlags($pack, $icon, $flags) {
 
-      foreach ($things as $property => $value) {
-        $result .= "$property:$value;";
-      }
+    $this->flags   = array();
+    $this->classes = array();
+    $this->styles  = array();
 
-      $result = trim($result, ';');
+    $this->flags['pack'] = $pack;
+    $this->flags['icon'] = $icon;
 
-      return $result;
+    if ((int) $flags[0] > 0) {
+      $flags[] = "size=" . $flags[0];
+      unset($flags[0]);
+    }
 
+    if ($left = array_search('left', $flags)) {
+      $flags[] = 'align=left';
+      unset($flags[$left]);
     }
 
-    protected function getFlag($name) {
-      return (isset($this->flags[$name]) ? $this->flags[$name] : null);
+    if ($right = array_search('right', $flags)) {
+      $flags[] = 'align=right';
+      unset($flags[$right]);
     }
 
-    protected function getFlags() {
-      return $this->flags;
+    if ($center = array_search('center', $flags)) {
+      $flags[] = 'align=center';
+      unset($flags[$center]);
     }
 
-    protected function parseFlags($pack, $icon, $flags) {
+    foreach ($flags as $flag) {
 
-      $this->flags   = array();
-      $this->classes = array();
-      $this->styles  = array();
+      @list($flag, $value) = explode('=', $flag);
 
-      $this->flags['pack'] = $pack;
-      $this->flags['icon'] = $icon;
+      if (! $flag) continue;
 
-      if ((int) $flags[0] > 0) {
-        $flags[] = "size=" . $flags[0];
-        unset($flags[0]);
-      }
+      $this->flags[$flag] = $value;
 
-      if ($left = array_search('left', $flags)) {
-        $flags[] = 'align=left';
-        unset($flags[$left]);
-      }
+      switch ($flag) {
 
-      if ($right = array_search('right', $flags)) {
-        $flags[] = 'align=right';
-        unset($flags[$right]);
-      }
+        case 'size':
 
-      if ($center = array_search('center', $flags)) {
-        $flags[] = 'align=center';
-        unset($flags[$center]);
-      }
+          $this->flags[$flag] = (int) $value;
+
+          if ($this->isFontIcon()) {
+            $this->styles['font-size'] = "{$value}px";
+          }
 
-      foreach ($flags as $flag) {
+          break;
 
-        list($flag, $value) = explode('=', $flag);
+        case 'circle':
+          $this->flags[$flag]                    = true;
+          $this->styles['border-radius']         = '50%';
+          $this->styles['-moz-border-radius']    = '50%';
+          $this->styles['-webkit-border-radius'] = '50%';
+          break;
 
-        switch ($flag) {
+        case 'border':
+          $this->flags[$flag]     = true;
+          $this->styles['border'] = '0.08em solid #EEE';
+          break;
 
-          case 'pack':
-            $this->flags[$flag] = $value;
-            break;
+        case 'borderColor':
+          $this->styles['border-color'] = $value;
+          break;
 
-          case 'size':
-            $this->flags[$flag]       = (int) $value;
-            $this->styles['font-size'] = "{$value}px";
-            break;
-
-          case 'circle':
-            $this->flags[$flag]                 = true;
-            $this->styles['border-radius']         = '50%';
-            $this->styles['-moz-border-radius']    = '50%';
-            $this->styles['-webkit-border-radius'] = '50%';
-            break;
-
-          case 'border':
-            $this->flags[$flag]     = true;
-            $this->styles['border'] = '0.08em solid #EEE';
-            break;
-
-          case 'borderColor':
-            $this->flags[$flag] = $value;
-            $this->styles['border-color'] = $value;
-            break;
-
-          case 'padding':
-            $this->flags[$flag]  = $value;
-            $this->styles['padding'] = $value;
-            break;
-
-          case 'background':
-            $this->flags[$flag]        = $value;
-            $this->styles['background-color'] = $value;
-            break;
-
-          case 'color':
-            $this->flags[$flag]  = $value;
-            $this->styles['color'] = $value;
-            break;
-
-          case 'class':
-            $this->flags[$flag] = $value;
-            $this->classes[] = $value;
-            break;
-
-          case 'align':
-
-            $this->flags[$flag] = $value;
-            $class_icon = 'syntax_plugin_icons_'.$this->getFlag('pack');
-
-            if (constant("$class_icon::IS_ICON")) {
-              $this->classes[] = "media$value";
-            } else {
+        case 'padding':
+          $this->styles['padding'] = $value;
+          break;
+
+        case 'background':
+          $this->styles['background-color'] = $value;
+          break;
+
+        case 'color':
+          $this->styles['color'] = $value;
+          break;
+
+        case 'class':
+          $this->classes[] = $value;
+          break;
 
-              if ($value == 'center') {
-                $this->styles['text-align'] = 'center';
-              } else {
-                $this->styles['padding-'.(($value == 'left') ? 'right' : 'left')] = '.2em';
-                $this->styles['float'] = $value;
-              }
+        case 'align':
 
+          if ($this->isIcon()) {
+            $this->classes[] = "media$value";
+          } else {
+
+            if ($value == 'center') {
+              $this->styles['text-align'] = 'center';
+            } else {
+              $this->styles['padding-'.(($value == 'left') ? 'right' : 'left')] = '.2em';
+              $this->styles['float'] = $value;
             }
 
-            break;
+          }
 
-          default:
-            $this->classes[] = $flag;
-        }
-      }
+          break;
+
+        default:
+          $this->classes[] = $flag;
 
-      if (! isset($this->flags['size'])) {
-        $this->flags['size'] = $this->getConf('defaultSize');
-        $this->styles['font-size'] = $this->getConf('defaultSize') . "px";
       }
+    }
+
+    if (! isset($this->flags['size'])) {
 
-      if ($this->flags['pack'] == 'icon') {
-        $this->flags['pack'] = $this->getConf('defaultPack');
+      $this->flags['size'] = (int) $this->getConf('defaultSize');
+
+      if ($this->isFontIcon()) {
+        $this->styles['font-size'] = $this->getConf('defaultSize') . "px";
       }
 
     }
 
-    protected function getStyles() {
-      return $this->styles;
+    if ($this->flags['pack'] == 'icon') {
+      $this->flags['pack'] = $this->getConf('defaultPack');
     }
 
-    protected function getClasses() {
-      return $this->classes;
-    }
+  }
+
+  protected function getStyles() {
+    return $this->styles;
+  }
+
+  protected function getClasses() {
+    return $this->classes;
+  }
+
+
+  public static function makePath($icon, $size, $base_url) {
+    return true;
+  }
 
 }

+ 10 - 9
syntax/oxygen.php

@@ -1,12 +1,12 @@
 <?php
 /**
  * Plugin Icons: KDE Oxygen helper
- * 
+ *
  * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
  * @author     Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com>
  * @copyright  (C) 2015, Giuseppe Di Terlizzi
  */
- 
+
 // must be run within Dokuwiki
 if(!defined('DOKU_INC')) die();
 
@@ -14,17 +14,18 @@ require_once(dirname(__FILE__).'/icon.php');
 
 class syntax_plugin_icons_oxygen extends syntax_plugin_icons_icon {
 
-    protected $pattern = '{{oxygen>.+?}}';
+  const IS_ICON      = true;
+  const IS_FONT_ICON = false;
 
-    const IS_ICON = true;
+  protected $pattern = '{{oxygen>.+?}}';
 
-    public static function makePath($icon, $size, $base_url) {
+  public static function makePath($icon, $size, $base_url) {
 
-        $sizes = array(8, 16, 22, 32, 48, 64, 128, 256, 512);
-        $size  = (($size > max($sizes)) ? max($sizes) : $size);
+    $sizes = array(8, 16, 22, 32, 48, 64, 128, 256, 512);
+    $size  = (($size > max($sizes)) ? max($sizes) : $size);
 
-        return "$base_url/{$size}x{$size}/$icon.png";
+    return "$base_url/{$size}x{$size}/$icon.png";
 
-    }
+  }
 
 }

+ 5 - 4
syntax/silk.php

@@ -1,12 +1,12 @@
 <?php
 /**
  * Plugin Icons: Silk helper
- * 
+ *
  * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
  * @author     Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com>
  * @copyright  (C) 2015, Giuseppe Di Terlizzi
  */
- 
+
 // must be run within Dokuwiki
 if(!defined('DOKU_INC')) die();
 
@@ -14,9 +14,10 @@ require_once(dirname(__FILE__).'/icon.php');
 
 class syntax_plugin_icons_silk extends syntax_plugin_icons_icon {
 
-    protected $pattern = '{{silk>.+?}}';
+    const IS_ICON      = true;
+    const IS_FONT_ICON = false;
 
-    const IS_ICON = true;
+    protected $pattern = '{{silk>.+?}}';
 
     public static function makePath($icon, $size, $base_url) {
       return "$base_url/$icon-icon.png";