예제 #1
0
 /**
  * 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)
 {
     if (!isset($data->view->colSpan)) {
         throw new \LogicException('Please put "column" tags in "row" tag.');
     }
     $span = XmlHelper::get($element, 'span');
     $fill = XmlHelper::getBool($element, 'fill', !(bool) $span);
     if (!$span) {
         $span = 12;
     }
     if ($fill) {
         $span = $data->view->colSpan ?: 12;
     } else {
         $data->view->colSpan -= $span;
     }
     if ((int) $span <= 0) {
         $span = 12;
     }
     if ($data->view->colSpan <= 0) {
         $data->view->colSpan = 12 + $data->view->colSpan;
     }
     $colClass = 'span' . $span;
     $element['class'] = isset($element['class']) ? $colClass . ' ' . $element['class'] : $colClass;
     return HtmlRenderer::render('div', $engine, $element, $data);
 }
예제 #2
0
 /**
  * execute
  *
  * @param string $templateFile
  * @param null   $data
  *
  * @throws \InvalidArgumentException
  * @return  mixed
  */
 protected function execute($templateFile, $data = null)
 {
     if (!is_file($templateFile)) {
         throw new \InvalidArgumentException(sprintf('Template "%s" not exists.', $templateFile));
     }
     $xml = simplexml_load_file($templateFile);
     if (!$data instanceof Data) {
         $data = new Data($data);
     }
     $data->xulControl = new Data();
     return HtmlRenderer::render('div', $this, $xml, $data);
 }
예제 #3
0
 /**
  * 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)
 {
     $rowClass = XmlHelper::getBool($element, 'fluid', true) ? 'row-fluid' : 'row';
     $element['class'] = isset($element['class']) ? $rowClass . ' ' . $element['class'] : $rowClass;
     if (empty($data->view)) {
         $data->view = new Data();
     }
     $data->view->colSpan = 12;
     $html = HtmlRenderer::render('div', $engine, $element, $data);
     unset($data->view->colSpan);
     return $html;
 }