Example #1
0
File: Xslt.php Project: volux/dom
 /**
  * @param string $xslFile
  * @param array  $xsltParameters
  * @param Element|Tag|Field|Set $element
  * @param string $ns namespace
  *
  * @return \DOMDocument
  */
 public function transform($xslFile, $xsltParameters = array(), &$element, $ns = '')
 {
     $this->load($xslFile, LIBXML_NOCDATA, $result);
     if (!$result) {
         return $element;
     }
     foreach ($xsltParameters as $name => $value) {
         $this->processor->setParameter($ns, $name, $value);
     }
     if ($element instanceof Set) {
         $processor = $this->processor;
         $element->each(function (Element $el) use($processor, $xslFile) {
             $result = $processor->transformToDoc($el);
             if (!$result) {
                 $el->after($el->ownerDocument->createComment('not transformed with ' . $xslFile));
             } else {
                 $el->replace($result->documentElement, $el);
             }
         });
         return $element;
     }
     $result = $this->processor->transformToDoc($element);
     if (!$result) {
         $element->after($element->ownerDocument->createComment('not transformed with ' . $xslFile));
     }
     $element->replace($result->documentElement, $element);
     return $element;
 }
Example #2
0
 /**
  * @param string $prepend
  * @param string $append
  *
  * @return $this|Element|Field|Tag
  */
 public function marks($prepend = '', $append = '')
 {
     if ($this->field->isPointInput()) {
         return $this->field;
     }
     $wrapper = $this->field->wrap('div');
     if ($prepend) {
         $wrapper->addClass('input-prepend');
         $this->field->before('span')->addClass('add-on')->text($prepend);
     }
     if ($append) {
         $wrapper->addClass('input-append');
         $this->field->after('span')->addClass('add-on')->text($append);
     }
     return $this->field;
 }
Example #3
0
 /**
  * @param string|Element|Tag|Field|\DOMNode $target css selector or Element
  *
  * @return Element|Tag|Field
  */
 public function prependTo($target)
 {
     return $target->insertBefore($target->ownerDocument->importNode($this, true), $target->firstChild);
 }