|  | @@ -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;
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  }
 |