/**
  * doRender
  *
  * @param string            $name
  * @param XulEngine         $engine
  * @param \SimpleXmlElement $element
  * @param mixed             $data
  *
  * @throws \LogicException
  * @return  mixed
  */
 protected static function doRender($name, XulEngine $engine, \SimpleXmlElement $element, $data)
 {
     $tableOption = XmlHelper::getAttributes($element);
     $data->xulControl->columnNum = 0;
     $data->xulControl->column = array();
     $data->xulControl->grid = $grid = new JGrid($tableOption);
     $data->xulControl->classPrefix = 'Grid';
     $html = static::renderChildren($engine, $element, $data);
     return $grid;
 }
 /**
  * doRender
  *
  * @param string            $name
  * @param XulEngine         $engine
  * @param \SimpleXmlElement $element
  * @param mixed             $data
  *
  * @throws \LogicException
  * @return  mixed
  */
 protected static function doRender($name, XulEngine $engine, \SimpleXmlElement $element, $data)
 {
     $grid = $data->xulControl->grid;
     $cells = static::renderChildren($engine, $element, $data);
     $grid->addRow(XmlHelper::getAttributes($element));
     foreach ($cells as $key => $cell) {
         $content = String::parseVariable($cell, $data);
         $attribs = XmlHelper::getAttributes($element);
         $grid->setRowCell($key, $content, $attribs);
     }
     reset($element);
     return $cells;
 }
 /**
  * doRender
  *
  * @param string            $name
  * @param XulEngine         $engine
  * @param \SimpleXmlElement $element
  * @param mixed             $data
  *
  * @throws \LogicException
  * @return  mixed
  */
 protected static function doRender($name, XulEngine $engine, \SimpleXmlElement $element, $data)
 {
     $cols = static::renderChildren($engine, $element, $data);
     $gridHelper = $data->grid;
     $grid = $data->xulControl->grid;
     $grid->addRow(array(), 1);
     foreach ($cols as $key => $value) {
         $attribs = XmlHelper::getAttributes($element);
         $title = XmlHelper::get($value, 'title');
         unset($attribs['title']);
         $grid->addColumn($key, $attribs);
         $grid->setRowCell($key, $title, $attribs);
     }
 }
 /**
  * doRender
  *
  * @param string            $name
  * @param \SimpleXmlElement $element
  * @param mixed             $data
  *
  * @throws \UnexpectedValueException
  * @return  mixed
  */
 protected static function doRender($name, XulEngine $engine, \SimpleXmlElement $element, $data)
 {
     XmlHelper::def($element, 'action', $data->uri->path);
     XmlHelper::def($element, 'method', 'post');
     XmlHelper::def($element, 'id', $data->view->name . '-form');
     XmlHelper::def($element, 'name', 'adminForm');
     XmlHelper::def($element, 'class', 'form-validate');
     XmlHelper::def($element, 'enctype', 'multipart/form-data');
     $attributes = XmlHelper::getAttributes($element);
     $footerHandler = XmlHelper::get($element, 'type', 'default');
     $footerHandler = array(__CLASS__, 'render' . ucfirst($footerHandler) . 'Footer');
     // Build hidden inputs
     $footer = HtmlBuilder::create('input', null, array('type' => 'hidden', 'name' => 'option', 'value' => $data->view->option));
     $footer .= HtmlBuilder::create('input', null, array('type' => 'hidden', 'name' => 'task', 'value' => ''));
     $footer .= is_callable($footerHandler) ? call_user_func_array($footerHandler, array()) : '';
     $footer .= JHtml::_('form.token');
     // Wrap inputs
     $children = static::renderChildren($engine, $element, $data);
     $children .= HtmlBuilder::create('div', $footer, array('id' => 'hidden-inputs'));
     return HtmlBuilder::create($name, $children, $attributes);
 }
 /**
  * doRender
  *
  * @param string            $name
  * @param \SimpleXmlElement $element
  * @param mixed             $data
  *
  * @throws \UnexpectedValueException
  * @return  mixed
  */
 protected static function doRender($name, XulEngine $engine, \SimpleXmlElement $element, $data)
 {
     $formVar = XmlHelper::get($element, 'form', 'form');
     $fieldset = XmlHelper::get($element, 'name');
     if (!$fieldset) {
         throw new \UnexpectedValueException('Need "name" attribute in XUL <fieldset> element.');
     }
     $form = $data->{$formVar};
     if (!$form instanceof \JForm) {
         throw new \UnexpectedValueException(sprintf('No form data found in $data->%s.', $formVar));
     }
     $option = $data->view->option ?: 'LIB_WINDWALKER';
     $label = XmlHelper::get($element, 'label', $option . '_EDIT_FIELDSET_' . $fieldset);
     $label = String::parseVariable($label, $data);
     $html = '<legend>' . \JText::_(strtoupper($label)) . '</legend>';
     foreach ($form->getFieldset($fieldset) as $field) {
         $html .= $field->getControlGroup() . "\n\n";
     }
     $html = HtmlBuilder::create('fieldset', $html, XmlHelper::getAttributes($element));
     return $html;
 }
 /**
  * getParsedAttributes
  *
  * @param \SimpleXmlElement $element
  * @param Data              $data
  *
  * @return  mixed
  */
 protected static function getParsedAttributes($element, $data)
 {
     $attributes = XmlHelper::getAttributes($element);
     return static::replaceVariable($attributes, $data);
 }
    /**
     * testGetAttributes
     *
     * @return  void
     *
     * @covers \Windwalker\Helper\XmlHelper::getAttributes
     */
    public function testGetAttributes()
    {
        $document = '<xml>
					   <nikon type="camera" price="40000" store="20" color="black">D850</nikon>
					</xml>';
        $element = new \SimpleXMLElement($document);
        $getAttributes = XmlHelper::getAttributes($element->nikon);
        $result = array('type' => 'camera', 'price' => '40000', 'store' => '20', 'color' => 'black');
        $this->assertEquals($getAttributes, $result);
    }
 /**
  * doRender
  *
  * @param string            $name
  * @param XulEngine         $engine
  * @param \SimpleXmlElement $element
  * @param mixed             $data
  *
  * @throws \LogicException
  * @return  mixed
  */
 protected static function doRender($name, XulEngine $engine, \SimpleXmlElement $element, $data)
 {
     $attributes = XmlHelper::getAttributes($element);
     return new HtmlElement($name, static::renderChildren($engine, $element, $data), $attributes);
 }