Example #1
0
 /**
  * @param string $content
  * @param string $type Const Alert::TYPE_.
  * @param bool   $withDismissButton Default is true.
  */
 public function __construct($content = null, $type = self::TYPE_INFO, $withDismissButton = true)
 {
     $this->addClass('alert');
     if (!in_array($type, $this->types)) {
         $type = self::TYPE_INFO;
     }
     $this->addClass('alert-' . $type);
     parent::__construct('div', $content);
     if ($withDismissButton) {
         $this->addDefaultDismissButton();
     }
 }
Example #2
0
 /**
  * @param string $id
  * @param string $title
  * @param string $content
  */
 public function __construct($id = '', $title = null, $content = null)
 {
     $this->addClass('collapse-wrapper');
     $this->link = new GenericTag('a');
     $this->link->setAttribute('data-toggle', 'collapse');
     $this->title = new GenericTag('legend', $this->link);
     $this->content = new GenericTag('div');
     $this->content->addClass('collapse');
     $this->content->setAttribute('id', $id);
     $this->setCollapseStateIndicators();
     parent::__construct('fieldset', $content);
     $this->setTitleContent($title);
 }
Example #3
0
 /**
  * @param	mixed	$data	style content
  * @param	string	$type	
  * @param	string	$sep	content separator 
  * @return	StyleTag
  */
 public function __construct($data = null, $type = null, $sep = null)
 {
     $this->disableRenderWhenEmpty();
     if (empty($type) || !is_string($type)) {
         $type = 'text/css';
     }
     if (null === $sep) {
         $sep = PHP_EOL;
     }
     $content = new TagContent($data, $sep);
     $attrs = new TagAttributes(array('media', 'scope', 'type'));
     $attrs->add('type', $type);
     parent::__construct('style', $content, $attrs);
 }
Example #4
0
 /**
  * @param	string	$href	url or file path to resource
  * @param	string	$rel	relationship between current doc and link
  * @param	string  $type	mime type
  * @return	LinkTag
  */
 public function __construct($href, $rel = null, $type = null)
 {
     if (empty($href) || !is_string($href)) {
         $err = 'href must be a non empty string';
         throw new InvalidArgumentException($err);
     }
     parent::__construct('link');
     $this->disableClosingTag();
     $attrs = $this->getTagAttributes();
     $attrs->loadWhiteList(array('href', 'hreflang', 'media', 'rel', 'sizes', 'type'));
     if (empty($rel) || !is_string($rel)) {
         $rel = 'stylesheet';
     }
     if (empty($type) || !is_string($type)) {
         $type = 'text/css';
     }
     $attrs->add('rel', $rel)->add('type', $type)->add('href', $href);
 }
Example #5
0
 /**
  * @param	string	$href	url or file path to resource
  * @param	string	$rel	relationship between current doc and link
  * @param	string  $type	mime type
  * @return	LinkTag
  */
 public function __construct($href, $content = null)
 {
     if (empty($href) || !is_string($href)) {
         $err = 'href must be a non empty string';
         throw new InvalidArgumentException($err);
     }
     parent::__construct('a');
     $attrs = $this->getTagAttributes();
     $attrs->loadWhiteList(array('href', 'hreflang', 'media', 'rel', 'target'));
     $attrs->add('rel', $rel)->add('type', $type)->add('href', $href);
     if (null !== $content) {
         if (is_array($content)) {
             $this->loadContent($content);
         } else {
             $this->addContent($content);
         }
     }
 }
Example #6
0
 /**
  * Only has two valid attributes href and target
  *
  * @param	string	$name
  * @param	string	$content
  * @param	string	$httpEquiv
  * @param	string	$charset
  * @return	MetaTag
  */
 public function __construct($name = null, $content = null, $httpEquiv = null, $charset = null)
 {
     parent::__construct('meta');
     $attrs = $this->getTagAttributes();
     $attrs->loadWhiteList(array('charset', 'content', 'http-equiv', 'name'));
     if (null !== $httpEquiv) {
         $attrs->add('http-equiv', $httpEquiv);
     }
     if (null !== $name) {
         $attrs->add('name', $name);
     }
     if (null !== $content) {
         $attrs->add('content', $content);
     }
     if (null !== $charset) {
         $attrs->add('charset', $charset);
     }
     $this->disableClosingTag();
 }
Example #7
0
 /**
  * @param	string	$href	url or file path to resource
  * @param	string	$rel	relationship between current doc and link
  * @param	string  $type	mime type
  * @return	LinkTag
  */
 public function __construct($src, $width = null, $height = null, $alt = null)
 {
     if (empty($href) || !is_string($href)) {
         $err = 'href must be a non empty string';
         throw new InvalidArgumentException($err);
     }
     parent::__construct('img');
     $attrs = $this->getTagAttributes();
     $attrs->loadWhiteList(array('alt', 'src', 'usemap', 'ismap', 'height', 'width'));
     $this->setSource($src);
     if (null !== $width) {
         $this->setWidth($width);
     }
     if (null !== $height) {
         $this->setHeight($height);
     }
     if (null !== $alt) {
         $this->setAlt($alt);
     }
 }
Example #8
0
 /**
  * @param string $content
  * @param string $header
  * @param string $footer
  * @param string $type Const Panel::TYPE_.
  */
 public function __construct($content = null, $header = null, $footer = null, $type = self::TYPE_DEFAULT)
 {
     $this->addClass('panel');
     if (!in_array($type, $this->types)) {
         $type = self::TYPE_DEFAULT;
     }
     $this->addClass('panel-' . $type);
     $this->header = new GenericTag('div');
     $this->header->addClass('panel-header');
     $this->footer = new GenericTag('div');
     $this->footer->addClass('panel-footer');
     $this->content = new GenericTag('div');
     $this->content->addClass('panel-body');
     parent::__construct('div', $content);
     if ($header !== null) {
         $this->addTitle($header);
     }
     if ($footer !== null) {
         $this->setFooterContent($footer);
     }
 }
Example #9
0
 /**
  * @param string $content
  * @param string $header
  * @param string $footer
  * @param bool   $withDismissButton
  */
 public function __construct($content = null, $header = null, $footer = null, $withDismissButton = true)
 {
     $this->addClass('modal');
     $this->header = new GenericTag('div');
     $this->header->addClass('modal-header');
     $this->footer = new GenericTag('div');
     $this->footer->addClass('modal-footer');
     $this->body = new GenericTag('div');
     $this->body->addClass('modal-body');
     $this->modalContent = new GenericTag('div', $this->body);
     $this->modalContent->addClass('modal-content');
     $this->content = new GenericTag('div', $this->modalContent);
     $this->content->addClass('modal-dialog');
     parent::__construct('div', $content);
     if ($header !== null) {
         $this->addTitle($header);
     }
     if ($footer !== null) {
         $this->setFooterContent($footer);
     }
     if ($header !== null && $withDismissButton) {
         $this->addDefaultDismissButton();
     }
 }
Example #10
0
 /**
  * @param	string	$data	content for the title
  * @return	Title
  */
 public function __construct($data = null, $sep = ' ')
 {
     $content = new TagContent($data, $sep);
     parent::__construct('title', $content);
     $this->disableRenderWhenEmpty();
 }