/** * Add a tag to the document * @param XmlTag $tag, element to add * @param bool $generateTree, if set to true recreates the original tree structure */ public function addTag(XmlTag $tag, $generateTree = false) { if ($generateTree) { $parent = $this->getTagByTagId($tag->getParentTagId()); if ($parent instanceof XmlTag) { $parent->getChildren()->append($tag); } else { $this->_tags->append($tag); } } else { $this->_tags->append($tag); } }
public function __toString() { // These are the only tags that can self-close $selfClosingTags = array('area' => true, 'base' => true, 'br' => true, 'col' => true, 'command' => true, 'embed' => true, 'hr' => true, 'img' => true, 'input' => true, 'link' => true, 'meta' => true, 'param' => true, 'source' => true); if (!isset($selfClosingTags[$this->getTagName()]) && $this->getContent()->count() === 0) { $this->setContent(""); } else { if (isset($selfClosingTags[$this->getTagName()])) { // Force-close them. No mercy. $this->setContent(null); } } return parent::__toString(); }
<?php // No direct access to this file defined('_JEXEC') or die('Restricted Access'); function generateRow($index, $container_type) { return XmlTagHelper::formatTableRow(array(XmlTagHelper::formatTableCell(JHtmlGrid::id($index, $container_type->id)), XmlTagHelper::formatTableCell(JText::_($container_type->container_name)), XmlTagHelper::formatTableCell($container_type->liters))); } function generateTableData($container_types) { $tableData = array(); foreach ($container_types as $index => $container_type) { $tableData[] = generateRow($index, $container_type); } return $tableData; } $xmlTag = new XmlTag(); if (isset($this->container_types)) { $tableContent = generateTableData($this->container_types); $xmlTag->FORM(array('action' => 'index.php?option=com_reomi&view=container_types', 'id' => 'adminForm', 'method' => 'post', 'name' => 'adminForm'), $xmlTag()->TABLE(array('class' => 'table table-striped table-hover'), $xmlTag()->THEAD($xmlTag()->TR($xmlTag()->TH(JHtmlGrid::checkall())->TH(JText::_('COM_ROEMI_ADMIN_VIEW_CONTAINER_TYPES_TABLE_HEADER_CONTAINER'))->TH(JText::_('COM_ROEMI_ADMIN_VIEW_CONTAINER_TYPES_TABLE_HEADER_LITERS'))))->TBODY($xmlTag()->__fromArray($tableContent)))->INPUT(array('type' => 'hidden', 'name' => 'task', 'value' => ''))->INPUT(array('type' => 'hidden', 'name' => 'boxchecked', 'value' => '0'))->_(JHtmlForm::token())); } else { $xmlTag->P(JText::_('COM_ROEMI_ADMIN_VIEW_CONTAINER_TYPES_EMPTY_TABLE_MSG')); } echo $xmlTag;
<?php // No direct access defined('_JEXEC') or die('Restricted access'); $xmlTag = new XmlTag(); $xmlTag->FORM(array('action' => JRoute::_('index.php?option=com_reomi&view=collection_fee&layout=edit&id=' . (int) $this->item->id), 'id' => 'adminForm', 'method' => 'post', 'name' => 'adminForm'), $xmlTag()->DIV(array('class' => 'form-horizontal'), $xmlTag()->FIELDSET(array('class' => 'adminForm'), $xmlTag()->LEGEND(JText::_('COM_REOMI_ADMIN_VIEW_COLLECTION_FEE_FORM_LEGEND'))->DIV(array('class' => 'row-fluid'), $xmlTag()->DIV(array('class' => 'span6'), $xmlTag()->__fromArray(XmlTagHelper::formatFormFields($this->form->getFieldset()))))))->INPUT(array('name' => 'task', 'type' => 'hidden', 'value' => 'collection_fee.edit'))->_(JHtmlForm::token())); echo $xmlTag;
/** * Add a child tag * @param XmlTag $tag */ public function addChild(XmlTag $tag) { $tag->setParentTagId($this->getTagId()); $this->_children->append($tag); }
if (isset($fee_types["collection"])) { $xmlTag->H5(JText::_('COM_REOMI_VIEW_FEES_PAGE_COLLECTION_TITLE'))->TABLE(array('class' => 'table table-striped table-hover'), $xmlTag()->THEAD($xmlTag()->TR($xmlTag()->TH(JText::_('COM_ROEMI_VIEW_FEES_TABLE_HEADER_LITERS'))->TH(JText::_('COM_ROEMI_VIEW_FEES_TABLE_HEADER_FEE'))))->TBODY($xmlTag()->__fromArray(generateCollectionTableData($fee_types["collection"])))); } $xmlTag->BR(); } } function generateBulkTable($bulk_fees, $xmlTag) { if (isset($bulk_fees)) { $tableData = array(); foreach ($bulk_fees as $fee) { $tableData[] = XmlTagHelper::formatTableRow(array(XmlTagHelper::formatTableCell((string) $fee->name), XmlTagHelper::formatTableCell(money_format('%n', $fee->fee)), XmlTagHelper::formatTableCell((string) $fee->description))); } $xmlTag->TABLE(array('class' => 'table table-striped table-hover'), $xmlTag()->TBODY($xmlTag()->__fromArray($tableData))); } } $xmlTag = new XmlTag(); $xmlTag->H1(JText::_('COM_REOMI_VIEW_FEES_PAGE_TITLE'))->P(JText::_('COM_REOMI_VIEW_FEES_PAGE_DESC'))->BR(); if (isset($this->fees)) { setlocale(LC_MONETARY, 'fr_FR.utf8'); $xmlTag->H2(JText::_('COM_REOMI_VIEW_FEES_PAGE_FEES_TITLE')); foreach ($this->fees as $user_name => $containers) { $xmlTag->H3(JText::_($user_name)); generateTables($containers, $xmlTag); } $xmlTag->H3(JText::_('COM_REOMI_VIEW_FEES_PAGE_BULK_TITLE')); generateBulkTable($this->bulk, $xmlTag); } else { $xmlTag->P(JText::_('COM_ROEMI_VIEW_FEES_EMPTY_TABLE_FEES')); } echo $xmlTag;
<?php // No direct access to this file defined('_JEXEC') or die('Restricted access'); $xmlTag = new XmlTag(); $xmlTag->H1(JText::_("COM_REOMI_VIEW_REOMI_PAGE_TITLE")); echo $xmlTag;
<?php // No direct access to this file defined('_JEXEC') or die('Restricted access'); function generateRow($city) { return XmlTagHelper::formatTableRow(array(XmlTagHelper::formatTableCell($city->name), XmlTagHelper::formatTableCell($city->service))); } function generateTableData($cities) { $tableData = array(); foreach ($cities as $city) { $tableData[] = generateRow($city); } return $tableData; } $xmlTag = new XmlTag(); $xmlTag->H1(JText::_('COM_REOMI_VIEW_CITIES_PAGE_TITLE'))->P(JText::_('COM_REOMI_VIEW_CITIES_PAGE_DESC'))->BR(); if (isset($this->cities)) { $tableContent = generateTableData($this->cities); $xmlTag->TABLE(array('class' => 'table table-striped table-hover'), $xmlTag()->THEAD($xmlTag()->TR($xmlTag()->TH(JText::_('COM_ROEMI_VIEW_CITIES_TABLE_HEADER_CITY'))->TH(JText::_('COM_ROEMI_VIEW_CITIES_TABLE_HEADER_SERVICE'))))->TBODY($xmlTag()->__fromArray($tableContent))); } else { $xmlTag->P(JText::_('COM_ROEMI_VIEW_CITIES_EMPTY_TABLE_MSG')); } echo $xmlTag;
$table_header = array(XmlTagHelper::formatTableRow(array(XmlTagHelper::formatTableHeader(JText::_("COM_ROEMI_VIEW_SIMULATOR_TABLE_HEADER_LITERS")), XmlTagHelper::formatTableHeader(JText::_("COM_ROEMI_VIEW_SIMULATOR_TABLE_HEADER_CONTAINER_NUMBER")), XmlTagHelper::formatTableHeader(JText::_("COM_ROEMI_VIEW_SIMULATOR_TABLE_HEADER_COLLECTION_NUMBER"))))); return array('attrs' => array('class' => 'table table-striped table-hover'), 'tag' => 'table', 'content' => array(array('tag' => 'thead', 'content' => $table_header), array('tag' => 'tbody', 'content' => formatInputRows($container_types)))); } function formatContainerTables($containers) { $tables = array(); foreach ($containers as $container_name => $container_types) { $tables[] = formatLabelForm('', $container_name); $tables[] = formatInputTable($container_types); } return $tables; } function formatBulkInputs($bulk) { $rows = array(); foreach ($bulk as $b) { $id = 'bulks[' . $b->id . ']'; $rows[] = XmlTagHelper::formatTableRow(array(XmlTagHelper::formatTableCell($b->name), XmlTagHelper::formatTableCell(formatInputNumber($id)))); } return $rows; } function formatBulkTable($bulk) { $table = array(); $table[] = formatLabelForm('', JText::_("COM_REOMI_VIEW_FEES_PAGE_BULK_TITLE")); $table[] = array('attrs' => array('class' => 'table table-striped table-hover'), 'tag' => 'table', 'content' => array(array('tag' => 'thead', 'content' => array(XmlTagHelper::formatTableRow(array(XmlTagHelper::formatTableHeader(JText::_('COM_REOMI_VIEW_SIMULATOR_LABEL_USERS')), XmlTagHelper::formatTableHeader(JText::_("COM_ROEMI_VIEW_SIMULATOR_TABLE_HEADER_COLLECTION_NUMBER")))))), array('tag' => 'tbody', 'content' => formatBulkInputs($bulk)))); return $table; } $xmlTag = new XmlTag(); $xmlTag->H1(JText::_('COM_REOMI_VIEW_SIMULATOR_PAGE_TITLE'))->BR()->H2(JText::_('COM_REOMI_VIEW_SIMULATOR_START_TITLE'))->P(array('class' => 'lead'), JText::_('COM_REOMI_VIEW_SIMULATOR_START_EXPLAIN'))->H2(JText::_('COM_REOMI_VIEW_SIMULATOR_FORM_TITLE'))->FORM(array('action' => JRoute::_('index.php'), 'method' => 'post', 'id' => 'adminform', 'name' => 'adminform'), $xmlTag()->__fromArray(array(formatLabelForm('user', JText::_('COM_REOMI_VIEW_SIMULATOR_LABEL_USERS')), formatSelectForm('user', $this->users), formatLabelForm('service', JText::_('COM_REOMI_VIEW_SIMULATOR_LABEL_CITIES')), formatSelectForm('service', $this->cities)))->__fromArray(formatContainerTables($this->containers))->__fromArray(formatBulkTable($this->bulk))->INPUT(array('type' => 'hidden', 'name' => 'option', 'value' => 'com_reomi'))->INPUT(array('type' => 'hidden', 'name' => 'task', 'value' => 'simulator.submit'))->_(JHtmlForm::token())->BUTTON(array('type' => 'submit', 'class' => 'btn btn-primary'), JText::_('COM_REOMI_VIEW_SIMULATOR_BUTTON_VALIDATE'))); echo $xmlTag;