Пример #1
0
 /**
  * Add element of container that contains form element and caption
  * 
  * @param HtmlElement $inputContainer
  * @param HtmlElement $captionContainer
  */
 protected function addFormElementContainer(HtmlElement $inputContainer, HtmlElement $captionContainer)
 {
     $div = new HtmlElement('div');
     $div->addElement($captionContainer);
     $div->addElement($inputContainer);
     $this->addElement($div);
 }
 public function __construct($name, $options, $selectedValue = '', $type = self::TYPE_RADIO, $validator = null)
 {
     static::$instanceCount++;
     HtmlElement::__construct('div');
     $this->validator = $validator;
     $this->type = $type;
     $this->setAttribute('name', $name);
     $selectedValues = array();
     if ($type == self::TYPE_RADIO) {
         $selectedValues = array($selectedValue);
     } else {
         $selectedValues = explode(',', $selectedValue);
     }
     $i = 0;
     foreach ($options as $key => $value) {
         $optionId = 'data-element-group-' . static::$instanceCount . '-' . $i;
         $option = new HtmlElement('input');
         $option->setAttribute('type', $this->type);
         $option->setAttribute('name', $name);
         $option->setAttribute('id', $optionId);
         $option->setAttribute('value', $value);
         if (in_array($key, $selectedValues)) {
             $option->setAttribute('checked');
         }
         $label = new HtmlElement('label');
         $label->setAttribute('for', $optionId);
         $label->addChild(new TextElement($value));
         $this->addChild($option);
         $this->addChild($label);
         $i++;
     }
 }
Пример #3
0
 public function addOption($value, $label, $properties = array())
 {
     $option = new HtmlElement(false, 'option', $properties);
     $option->setProperty('value', $value);
     $option->setContent($label);
     $this->html->setContent($option, $value);
 }
Пример #4
0
 /**
  * A widget for displaying an image (img)
  * @param string $imgurl The url of the image
  * @param string $alttext A text that will be shown if the image could not be loaded
  * @param boolean $forcehttps Specify if the link has to have https 
  * @param HtmlAttributes $args Allows custom html tag arguments to be specified (not recommended)
  **/
 public function __construct($imgurl = EMPTYSTRING, $alttext = '[IMG]', $args = null)
 {
     parent::__construct();
     $img = new HtmlElement('img', $args);
     $img->AddAttributes(array('src' => RTK::GetBaseURL() . $imgurl, 'alt' => $alttext));
     $this->AddChild($img);
 }
Пример #5
0
 /**
  * Add element of container that contains form element and caption
  * 
  * @param HtmlElement $inputContainer
  * @param HtmlElement $captionContainer
  */
 protected function addFormElementContainer(HtmlElement $inputContainer, HtmlElement $captionContainer)
 {
     $container = new HtmlElement($this->_containerTagName);
     $container->setClass($this->_containerClass);
     $container->addElement($captionContainer);
     $container->addElement($inputContainer);
     $this->_parentForm->addElement($container);
 }
Пример #6
0
 function setLabel($label_text, $attributes = array())
 {
     $label = new HtmlElement('label', null, true);
     $label->setAttribute('class', 'phaxsi_label');
     $label->setAttributes($attributes);
     $label->innerHTML = $label_text;
     $this->label = $label;
 }
Пример #7
0
 public function begin()
 {
     echo $this->getElementOpenTag() . "\n";
     $legend = new HtmlElement("legend");
     $legend->setBody($this->title);
     echo $legend;
     $this->started = true;
 }
Пример #8
0
 /**
  * Add element of container that contains form element and caption
  * 
  * @param HtmlElement $inputContainer
  * @param HtmlElement $captionContainer
  */
 protected function addFormElementContainer(HtmlElement $inputContainer, HtmlElement $captionContainer)
 {
     if (!$this->_tbody instanceof HtmlElement) {
         $this->_tbody = new HtmlElement('tbody');
         $this->addElement($this->_tbody);
     }
     $tr = new HtmlElement('tr');
     $tr->addElement($captionContainer);
     $tr->addElement($inputContainer);
     $this->_tbody->addElement($tr);
 }
Пример #9
0
 public function getData()
 {
     $listHtml = array('<ul>');
     $li = new HtmlElement('li');
     foreach ($this->content as $key => $value) {
         $li->setAttribute('id', $key);
         $li->setContent($value);
         $listHtml[] = $li->render();
     }
     $listHtml[] = '</ul>';
     return implode("\n", $listHtml);
 }
Пример #10
0
 /**
  * Shorten string if mor that max - and outputs span with original text in title
  * @param int max | max length
  * @container
  */
 protected function tagShort($attrs)
 {
     $max = intval($attrs->max);
     $string = trim($this->body());
     $orig = $string;
     if (strlen($string) > $max) {
         $string = substr($string, 0, $max - 3) . '...';
     }
     $span = new HtmlElement('span', array('title' => $orig));
     $span->addChild(new HtmlText($string));
     return $span;
 }
Пример #11
0
/**
 * Smarty block plugin, for generating page menus
 *
 * @param array $params
 * @param Smarty $smarty
 * @param $repeat
 *
 * <code>
 *	{pageMenu id="menu"}
 *		{menuItem}
 *			{menuCaption}Click Me{/menuCaption}
 *			{menuAction}http://click.me.com{/menuAction} 
 *		{/menuItem}
 *		{menuItem}
 *			{menuCaption}Another menu item{/menuCaption}
 *			{pageAction}alert('Somebody clicked on me too!'){/menuAction}
 *		{/menuItem}
 *  {/pageMenu}
 * </code>
 *
 * @return string Menu HTML code
 * @package application.helper.smarty
 * @author Integry Systems
 */
function smarty_block_pageMenu($params, $content, LiveCartSmarty $smarty, &$repeat)
{
    if ($repeat) {
        $smarty->clear_assign('pageMenuItems');
    } else {
        $items = $smarty->get_template_vars('pageMenuItems');
        $menuDiv = new HtmlElement('div');
        $menuDiv->setAttribute('id', $params['id']);
        $menuDiv->setAttribute('tabIndex', 1);
        $menuDiv->setContent(implode(' | ', $items));
        return $menuDiv->render();
    }
}
Пример #12
0
 /**
  * A button widget
  * @param string $name The name/id of the button
  * @param string $title The text written on the button
  * @param HtmlAttributes $args Allows custom html tag arguments to be specified (not recommended)
  **/
 public function __construct($name = 'submit', $title = 'Submit', $args = null)
 {
     parent::__construct('input', array('type' => 'submit', 'name' => $name, 'class' => 'submit', 'value' => $title));
     if (RTK::SetAndNotNull($args)) {
         $this->AddAttributes($args);
     }
 }
Пример #13
0
 /**
  * A widget for containing/structuring other widgets (div)
  * @param string $id The HTML #id of the box
  * @param string $class The HTML .class of box
  * @param HtmlAttributes $args Allows custom html tag arguments to be specified (not recommended)
  **/
 public function __construct($id = null, $class = null, $args = null)
 {
     parent::__construct('div', array('id' => $id, 'class' => $class));
     if (RTK::SetAndNotNull($args)) {
         $this->AddAttributes($args);
     }
 }
Пример #14
0
 /**
  * Build and get HTMLv
  * 
  * @param int $level
  * @return type
  */
 protected function _getHtml($level = 0)
 {
     foreach ($this->getFormElements() as $formElem) {
         // set form values
         $name = $formElem->getName();
         if (isset($this->_formValues[$name])) {
             $formElem->setValue($this->_formValues[$name]);
         }
         // set input errors
         if (isset($this->_errors[$name])) {
             $formElem->setErrorMessage($this->_errors[$name]);
         }
         // set captions
         if (isset($this->_captions[$name])) {
             $formElem->setCaption($this->_captions[$name]);
         }
     }
     if ($this->_innerContainer instanceof HtmlElement) {
         $elements = $this->getElements();
         $this->clearNodes();
         $this->_innerContainer->addElements($elements);
         $this->addElement($this->_innerContainer);
     }
     return parent::_getHtml($level);
 }
Пример #15
0
 public function __construct($children = null)
 {
     parent::__construct('fieldset');
     if (is_array($children)) {
         $this->addChildren($children);
     }
 }
Пример #16
0
 /**
  * A widget for containing/structuring other widgets (div)
  * @param string $id The HTML #id of the box
  * @param string $class The HTML .class of box
  * @param HtmlAttributes $args Allows custom html tag arguments to be specified (not recommended)
  **/
 public function __construct($id = null, $class = null, $args = null)
 {
     HtmlAttributes::Assure($args);
     $args->Add('id', $id);
     $args->Add('class', $class);
     parent::__construct('div', $args);
 }
Пример #17
0
 /**
  * Get all elements of header rows
  * 
  * @return array
  */
 public function getHeaders()
 {
     $ret = null;
     if ($this->_thead instanceof HtmlElement) {
         $ret = $this->_thead->getElements();
     }
     return $ret;
 }
Пример #18
0
 /**
  * Renders a button. All attributes not listed below will be forwarded to the actual html element
  * @param string elm | tag type - defaults to a
  * @param string class | CSS class to apply to button 
  * @param string event | event to trigger when clicked
  * @deprecated
  * @container
  */
 protected function tagButton($attrs, $view)
 {
     if (!$attrs->elm) {
         $attrs->elm = 'a';
     }
     if (!$attrs->class) {
         $attrs->class = '';
     }
     $class = $this->evt2css($attrs->event);
     $attrs->class = trim(trim(self::CSS_BTN . ' ' . $class) . ' ' . $attrs->class);
     $elmAttr = ArrayUtil::fromObject($attrs);
     unset($elmAttr['elm']);
     unset($elmAttr['event']);
     $elm = new HtmlElement($attrs->elm, $elmAttr);
     $elm->addChild(new HtmlText(trim($this->body())));
     return $elm;
 }
Пример #19
0
 /**
  * A widget for displaying a title/header (h1)
  * @param string $text The text in the title
  * @param integer $level The level (or "debth") of the title (1-6)
  * @param HtmlAttributes $args Allows custom html tag arguments to be specified (not recommended)
  **/
 public function __construct($text = null, $level = 1, $args = null)
 {
     if ($text == null) {
         $text = RTK_EMPTYSTRING;
     }
     $tag = is_numeric($level) && $level > 0 && $level <= 6 ? 'h' . $level : 'h1';
     parent::__construct($tag, $args, $text);
 }
Пример #20
0
 /**
  * @covers HtmlElement::set
  */
 public function testSetCss()
 {
     $elt = $this->element->set("class", "col-lg-12");
     $actual = $elt->getCssClasses();
     $excepted = "col-lg-12";
     $this->assertInstanceOf("HtmlElement", $elt);
     $this->assertContains($excepted, $actual);
 }
Пример #21
0
 /**
  * A widget for displaying an image (img)
  * @param string $imgurl The url of the image
  * @param string $alttext A text that will be shown if the image could not be loaded
  * @param boolean $forcehttps Specify if the link has to have https 
  * @param HtmlAttributes $args Allows custom html tag arguments to be specified (not recommended)
  **/
 public function __construct($imgurl = EMPTYSTRING, $alttext = EMPTYSTRING, $args = null)
 {
     HtmlAttributes::Assure($args);
     $args->Add('src', $imgurl, true);
     $args->Add('alt', $alttext, true);
     parent::__construct();
     $this->AddChild(new HtmlElement('img', $args));
 }
Пример #22
0
 function recursiveRender()
 {
     if (!is_null($this->sub)) {
         $this->add('Text')->set($this->text);
         $this->add('HtmlElement')->setElement('small')->set($this->sub);
     }
     parent::recursiveRender();
 }
Пример #23
0
 /**
  * A widget containing an unordered list (ul)
  * @param HtmlElement[] $items The items for the list
  * @param HtmlAttributes $args Allows custom html tag arguments to be specified (not recommended)
  **/
 public function __construct($items = null, $args = null)
 {
     parent::__construct('ul', $args);
     foreach ($items as $item) {
         if (is_a($item, 'HtmlElement')) {
             $this->AddChild($item);
         }
     }
 }
Пример #24
0
 /**
  * A button widget
  * @param string $name The name/id of the button
  * @param string $title The text written on the button
  * @param HtmlAttributes $args Allows custom html tag arguments to be specified (not recommended)
  **/
 public function __construct($name = 'submit', $title = 'Submit', $args = null)
 {
     HtmlAttributes::Assure($args);
     $args->Add('type', 'submit', false);
     $args->Add('name', $name, false);
     $args->Add('class', 'submit', false);
     $args->Add('value', $title, false);
     parent::__construct('input', $args);
 }
Пример #25
0
 public function __construct($name, $className = '', $ctx = null)
 {
     parent::__construct("table", $name);
     if ($className != '') {
         $this->set('class', $className);
     }
     $this->set("cellpadding", 0);
     $this->set("cellspacing", 0);
     $this->pagingInfo = $this->createPagingInfo($ctx);
 }
Пример #26
0
 /**
  * A widget containing a clickable link (a)
  * @param string $url The url of the link
  * @param string $name The title of the list
  * @param boolean $forcehttps Specify if the link has to have https
  * @param HtmlAttributes $args Allows custom html tag arguments to be specified (not recommended)
  **/
 public function __construct($url = null, $name = null, $forcehttps = false, $args = null)
 {
     if ($url == null) {
         $url = RTK_EMPTYSTRING;
     }
     if ($name == null) {
         $name = RTK_EMPTYSTRING;
     }
     parent::__construct('a', array('href' => RTK::GetBaseURL($forcehttps) . $url), $name);
     $this->AddAttributes($args);
 }
Пример #27
0
 /**
  * A widget containing a line of user inputs for a form element
  * @param string $name The HTML name (and #id) of the input element(s) and label
  * @param string $title The text written next to the input element(s)
  * @param string $inputs The input element(s) for the form line
  **/
 public function __construct($name, $title, $inputs)
 {
     parent::__construct('div', array('class' => 'formline'));
     // Add the label
     $this->AddContainer(new HtmlElement('label', array('for' => $name), $title), 'LABEL');
     // Create the input group
     $group = new HtmlElement('div', array('class' => 'formgroup'));
     if (is_a($inputs, 'HtmlElement')) {
         $group->AddChild($inputs);
     } elseif (RTK::ArrayIsLongerThan($array, 0)) {
         foreach ($inputs as $input) {
             if (is_a($input, 'HtmlElement')) {
                 $group->AddChild($input);
             }
         }
     }
     $this->AddContainer($group, 'GROUP');
     // Add the error section
     $this->AddContainer(new HtmlElement(), 'ERROR');
 }
 function html($showErrors = false)
 {
     if (!$this->isContainer) {
         return parent::html($showErrors);
     }
     $elementsHtml = '';
     foreach ($this->elements as $e) {
         $elementsHtml .= $e->html() . Html::br();
     }
     parent::setContent($elementsHtml);
     return parent::html();
 }
Пример #29
0
 /**
  * A widget containing text (essentially just a div or span with text)
  * @param string $text The text to display
  * @param boolean $inline Determines if the widget should be span(true) or div(false)
  * @param string $id The HTML #id of the element
  * @param string $class The HTML .class of element
  * @param HtmlAttributes $args Allows custom html tag arguments to be specified (not recommended)
  **/
 public function __construct($text = EMPTYSTRING, $inline = false, $id = null, $class = null, $args = null)
 {
     HtmlAttributes::Assure($args);
     if (Value::SetAndNotNull($id)) {
         $args->Add('id', $id);
     }
     if (Value::SetAndNotNull($class)) {
         $args->Add('class', $class);
     }
     $tag = $inline ? 'span' : 'div';
     parent::__construct($tag, $args, $text);
 }
Пример #30
0
Файл: HX.php Проект: atk4/atk4
 public function recursiveRender()
 {
     if (!is_null($this->sub)) {
         /** @type Text $t */
         $t = $this->add('Text');
         $t->set($this->text);
         /** @type HtmlElement $e */
         $e = $this->add('HtmlElement');
         $e->setElement('small')->set($this->sub);
     }
     parent::recursiveRender();
 }