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; }
/** * @param DataTable $dt * @param Button|Text $action * @param Block $codeBlock */ private static function createActionTest(DataTable $dt, $action, Block $codeBlock) { $options = ['session' => '$session', 'xpath' => $action->getXpath()]; if ($action->hasClass('ColVis_Button')) { if ($action->getLabel() === 'Kolumny') { // clear filtr $codeBlock->appendRenderable(new Comment('action columns: ' . $action->getLabel())); $codeBlock->appendRenderable(new Statement(new StaticMethodCall('parent', 'dtActionColumns', $options))); } else { $x = 1; } } elseif ($action->getLabel() === 'filtr') { // visible columns $codeBlock->appendRenderable(new Comment('action filter: ' . $action->getLabel())); $codeBlock->appendRenderable(new Statement(new StaticMethodCall('parent', 'dtActionFilter', $options))); } elseif ($action->getLabel() === 'dtsearch') { $codeBlock->appendRenderable(new Comment('action globalsearch: ' . $action->getLabel())); $codeBlock->appendRenderable(new Statement(new StaticMethodCall('parent', 'dtActionGlobalSearch', $options))); } else { $x = 1; } }