Beispiel #1
0
 /**
  * __construct
  *
  * @param array $attributes array of attribute name => value pairs for img tag
  */
 public function __construct($attributes = array())
 {
     parent::__construct($attributes);
 }
Beispiel #2
0
 public function __construct($data)
 {
     parent::__construct($data);
     $this->tpl = \RMTemplate::get();
 }
Beispiel #3
0
 /**
  * Get an icon SVG, font icon or bitmap
  * @param string $icon
  * @return string
  */
 public function getIcon($icon, $attributes = [])
 {
     parent::__construct($attributes);
     $this->add('class', 'cu-icon');
     /**
      * Check if this is a SVG icon
      */
     if ('svg-' == substr($icon, 0, 4)) {
         /**
          * The icon has additional css classes?
          * If yes, then the classes must be separated by a blank space
          * (e.g. svg-rmcommon-rmcommon text-blue)
          */
         $iconExploded = explode(" ", trim($icon));
         $this->add('class', str_replace($iconExploded[0], ' ', $icon));
         $renderedAttrs = $this->renderAttributeString();
         // Index 0 has the SVG icon
         $iconSVG = $this->providerIcon($iconExploded[0]);
         return '<span ' . $renderedAttrs . '>' . $iconSVG . '</span>';
     }
     $renderedAttrs = $this->renderAttributeString();
     // Relative or absolute url?
     $matches = array();
     $absolute = preg_match("/^(http:\\/\\/|https:\\/\\/|ftp:\\/\\/|\\/\\/)/m", $icon, $matches, PREG_OFFSET_CAPTURE);
     $is_svg = substr($icon, -4) == '.svg';
     // Icon with absolute path
     if ($absolute) {
         if ($is_svg) {
             return '<span ' . $renderedAttrs . '>' . file_get_contents($icon) . '</span>';
             //returns SVG code
         } else {
             return '<span ' . $renderedAttrs . '><img src="' . $icon . '"></span>';
             // returns image URL
         }
     }
     // Relative image url?
     $imageFormats = array('.jpg', '.gif', '.png', 'jpeg');
     if (in_array(substr($icon, -4), $imageFormats)) {
         return '<span ' . $renderedAttrs . '><img src="' . $icon . '"></span>';
     }
     // Last option: icon font
     return '<span ' . $renderedAttrs . '><span class="' . $icon . '"></span></span>';
 }
Beispiel #4
0
 /**
  * @param string $bundle
  * @param string $resource
  * @param string $action
  * @param array $args
  * @param array $options
  */
 public function __construct($bundle, $resource, $action, $args = [], $options = [])
 {
     parent::__construct($bundle, $resource, $action, $args);
     $default_options = ['prefix' => 'App\\Controller', 'suffix' => 'Controller'];
     $this->options = array_merge($default_options, (array) $options);
 }