/** * 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); }
/** * 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); }
/** * 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); }
public function front() { global $design_head, $content; $design_head .= '<script type="text/javascript" src="inc/AJAX/ajax_suggest.js"></script>' . "\n"; $html = new \HtmlElement("div"); $html->addCssClass("kiosk"); // Page title $html->addElement("div")->addCssClass("page-title")->addElement("h1", "Kiosk"); // Print the input field for adding new wares. $newProductWrapper = $html->addElement("div")->addCssClass("new-product"); $newProductForm = $newProductWrapper->addElement("form"); $newProductForm->setAttribute("action", "?module=kiosk")->setAttribute("method", "post"); $newProductForm->addElement("input")->setAttribute("type", "text")->setAttribute("name", "product_name")->setAttribute("id", "ware")->setAttribute("placeholder", "Produktnavn...")->setAttribute("tabindex", 1)->setAttribute("autocomplete", "off")->setAttribute("onkeyup", "suggest();"); // Suggest div for autocomplete. $newProductWrapper->addElement("div")->setAttribute("id", "suggest"); // Productlist if ($this->_kioskSession->hasProducts()) { $productListWrapper = $html->addElement("div")->addCssClass("products"); $productListWrapper->addElement("h2", "Handlekurv"); // Table $productListTable = $productListWrapper->addElement("div")->addCssClass("table"); foreach ($this->_kioskSession->getProducts() as $productArrayItem) { /** @var Product $product */ $product = $productArrayItem["object"]; $amount = $productArrayItem["amount"]; $row = $productListTable->addElement("div")->addCssClass("row"); $row->addElement("div", $product->getName())->addCssClass("cell"); $row->addElement("div", $amount . " stk")->addCssClass("cell"); $row->addElement("div", $product->getPrice() . " kr")->addCssClass("cell"); $options = $row->addElement("div")->addCssClass("cell"); $options->addElement("a")->setAttribute("href", "?module=kiosk&action=addWare&ware=" . $product->getProductID())->addElement("img")->setAttribute("src", "inc/images/plus-15px.png"); $options->addElement("a")->setAttribute("href", "?module=kiosk&action=removeWare&ware=" . $product->getProductID())->addElement("img")->setAttribute("src", "inc/images/minus-15px.png"); } } $html->addElement("a", "Reset")->setAttribute("href", "?module=kiosk&action=endSession"); $content .= $html; }
/** * Add header row element * * @param HtmlTableRow $row * @return HtmlTable */ public function addHeaderElement(HtmlTableRow $row) { $this->_createHeaderContainer(); $this->_thead->addElement($row); return $this; }
/** * Create and return element of input tags whose type are checkbox * * @param string $name * @param array $list * @param string $defaultValue * @param array $attributes * @return FormElementSet */ public function createCheckboxes($name = null, $list = array(), $defaultValue = null, $attributes = null) { $this->_checkArgumentIsArray(__METHOD__, 2, $list); $frame = $this->createFormElementSet('span'); if (!is_array($attributes)) { $attributes = array(); } $attributes['type'] = 'checkbox'; if (is_array($list)) { foreach ($list as $value => $text) { $checkbox = new FormElement('input'); $checkbox->setIsReturnInner(false); $checkbox->setAttributes($attributes); $checkbox->setValue($value); $label = new HtmlElement('label'); $label->setIsReturnInner(false); $label->addElement($checkbox); $label->addNode($text); $frame->addElement($label); } } $frame->setName($name); if ($defaultValue !== null) { $frame->setValue($defaultValue); } return $frame; }
$value->outputAsHTML($lineprefix . ' '); } if (strlen($this->myBodyText) > 0) { print $this->myBodyText; } print "\n" . $lineprefix . "</" . $this->myTagName . ">"; } } ?> <?php $mainDiv = new HtmlElement("div", array("class" => "specialDiv", "name" => "mydivname")); // create a list of paras for ($divChild = 0; $divChild < 25; $divChild++) { $newPara = new HtmlElement("p", NULL, NULL, "This is " . chr(ord("a") + $divChild) . " paragraph text"); $mainDiv->addElement($newPara); $newPara->addElement(new HtmlElement("a", array("name" => "pName" . $tagNameIDs['p']))); } $lastIndexedParaCount = $tagNameIDs['p']; // create a set of divs where each div has a para $nestedDiv = new HtmlElement("div", array("class" => "nestedDiv", "name" => "nestedDiv")); $nestedPara = new HtmlElement("p", NULL, NULL, "nested para text"); $nestedDiv->addElement($nestedPara); $mainDiv->addElement($nestedDiv); for ($nestedDivCount = 0; $nestedDivCount < 15; $nestedDivCount++) { $newDiv = $nestedDiv->cloneMe(); $nestedDiv->addElement($newDiv); $nestedDiv = $newDiv; } // create a set of hrefs to the paras $linkDiv = new HtmlElement("div", array("class" => "linkDiv", "name" => "linkdivname"));
/** * Create element by tag setting array * * @param array $setting * @return HtmlElement */ protected static function _createElement($setting) { if (!isset($setting['tag_name'])) { throw new Exception('Specification of "tag_name" is required, but not specified.'); } $elem = new HtmlElement($setting['tag_name']); if (isset($setting['attributes'])) { if (!is_array($setting['attributes'])) { throw new Exception('Specification of "attributes" in element setting must be an array, ' . gettype($setting['attributes']) . ' given.'); } $elem->setAttributes($setting['attributes']); } if (isset($setting['is_empty'])) { $elem->setIsEmptyTag($setting['is_empty']); } if (isset($setting['nodes'])) { if ($elem->isEmptyTag()) { throw new Exception('Empty tag cannot contain node.'); } if (!is_array($setting['nodes'])) { throw new Exception('Specification of "nodes" in element setting must be an array, ' . gettype($setting['nodes']) . ' given.'); } foreach ($setting['nodes'] as $node) { if (is_array($node)) { $subElem = self::_createElement($node); $elem->addElement($subElem); } else { $elem->addText($node); } } } if (isset($setting['text'])) { if ($elem->isEmptyTag()) { throw new Exception('Empty tag cannot contain node.'); } if (is_array($setting['text']) || is_object($setting['text'])) { throw new Exception('Specification of "text" in element setting must be string, ' . gettype($setting['text']) . ' given.'); } $elem->setText($setting['text']); } return $elem; }