Exemplo n.º 1
0
 private static function reverseActions(NodeElement $header, Header $head)
 {
     $actions = new Actions($head->getDt());
     $buttonsElems = $header->findAll('css', 'button');
     if ($buttonsElems) {
         /** @var NodeElement $element */
         foreach ($buttonsElems as $buttonElement) {
             $button = new Button();
             self::reverseButton($buttonElement, $button, self::$elements);
             if (!self::$elements->isRegisteredButton($button)) {
                 $actions->addButton($button);
             }
         }
     }
     $inputElems = $header->findAll('css', 'input,select,textarea');
     if ($inputElems) {
         /** @var NodeElement $element */
         foreach ($inputElems as $inputElement) {
             $input = self::reverseInput($inputElement, self::$elements);
             if ($input) {
                 $actions->addInput($input);
             }
         }
     }
 }
Exemplo n.º 2
0
 public static function reverse(NodeElement $content, Elements $elements = null)
 {
     $tag = $content->getTagName();
     if ($tag === 'select') {
         $input = new Select();
     } elseif ($tag === 'textarea') {
         $input = new Textarea();
     } elseif ($tag === 'input') {
         $input = new Input();
         $input->setNode($content);
         switch ($input->getAttribute('type')) {
             case 'checkbox':
                 $input = new Checkbox();
                 break;
             case 'submit':
                 $input = new Submit();
                 break;
             case 'text':
                 $input = new Text();
                 break;
             case 'radio':
                 $input = new Radio();
                 break;
             case 'file':
                 $input = new File();
                 break;
             case 'hidden':
                 return false;
             case 'search':
                 $input = new Text();
                 $input->setLabel('dtsearch');
                 $input->setNode($content);
                 return $input;
                 break;
             default:
                 //hidden
                 $x = 1;
                 return false;
                 break;
         }
     } else {
         //hidden
         $x = 1;
         return false;
     }
     /** @var Input $input */
     $input->setNode($content);
     if ($elements && $elements->isRegisteredInput($input)) {
         return false;
     }
     $outer = $content->getOuterHtml();
     $inner = $content->getHtml();
     $txt = $content->getText();
     $parents = $input->getParents();
     $res = self::findLabelByParent($input);
     if ($res) {
         $input->setLabel($res);
         return $input;
     }
     $res = self::findLabelByPlaceholder($input);
     if ($res) {
         $input->setLabel($res);
         return $input;
     }
     $res = self::findLabelByStdForm($input);
     if ($res) {
         $input->setLabel($res);
         return $input;
     }
     $res = self::findLabelByValue($input);
     if ($res) {
         $input->setLabel($res);
         return $input;
     }
     if (!$input->getId() && !$input->getName()) {
         if (false !== $input->hasClass('dtSearch')) {
             //datatables column filter
             $x = 1;
         }
         /*   $dt = $content->find('css', 'table.table-columnfilter');
              if ($dt) {
                  //skip datatable;
                  $x =1;
              }*/
         $class = $content->getAttribute('class');
         if ($class && $class === 'select2-search__field') {
             $x = 1;
         }
         if (false !== strpos($content->getParent()->getParent()->getAttribute('class'), 'CodeMirror')) {
             $x = 1;
             $p = $content->getParent()->getParent()->getParent()->getParent();
         } else {
             if ($input->getType() === 'search') {
                 $x = 1;
             }
             $x = 1;
             $p = $content;
         }
         $label = $p->find('css', 'label');
         if ($label) {
             $label = $label->getText();
         } else {
             $label = $content->getAttribute('placeholder');
         }
         //self::addNotNull($elem, 'label', $label);
         $xpath = $input->getXpath();
         //self::addNotNull($elem, 'xpath', $xpath);
     } else {
         if (false !== strpos($input->getName(), '_length')) {
             //datatables per page
             $x = 1;
         }
         if ($input->getName()) {
             $label = $content->find('css', 'label[for="' . $input->getName() . '"]');
             if (!$label) {
                 if ($input->getType() === 'checkbox') {
                     $p = $content->getParent()->getParent()->getParent();
                     $h = $p->getHtml();
                     $h = $p->getOuterHtml();
                     $label = $p->getText();
                 } else {
                     $x = 1;
                 }
             }
         } else {
             $label = $content->find('css', 'label[for=' . $input->getId() . ']');
         }
         if (!is_string($label)) {
             if ($label) {
                 $label = $label->getText();
             } else {
                 $label = $content->getValue();
             }
         }
         //self::addNotNull($elem, 'label', $label);
     }
     return $input;
 }
Exemplo n.º 3
0
 public function addRegisteredInput(FormElement $input)
 {
     $this->registeredInputs[] = $input;
     $this->elements->registerInput($input);
 }