private function compileNodes($nodes, $childNodes = null) { if (!isset($childNodes)) { $childNodes = ar_html::nodes(); } if (isset($nodes["children"])) { $childNodes = $this->compileNodes($nodes["children"], $childNodes); } unset($nodes["children"]); $result = array(); $mult = 1; if (isset($nodes["multiplier"])) { $mult = (int) $nodes["multiplier"]; unset($nodes["multiplier"]); } for ($i = 0; $i < $mult; $i++) { foreach ($nodes as $key => $value) { if ($value["tagName"]) { $tmult = 1; if (isset($value["multiplier"])) { $tmult = (int) $value["multiplier"]; } for ($j = 0; $j < $tmult; $j++) { $result[] = ar_html::tag($value["tagName"], $value["attributes"], $childNodes->cloneNode(true)); } } else { $result = array_merge($result, (array) $this->compileNodes($value, $childNodes)); } } } return ar_html::nodes($result); }
private function getCells($list, $tag = 'td') { $nodes = ar_html::nodes(); foreach ($list as $key => $content) { $nodes[] = ar_html::el($tag, $content); } return $nodes; }
public static function diff($a, $b) { $a = is_array($a) ? $a : explode("\n", $a); $b = is_array($b) ? $b : explode("\n", $b); $diff = new Diff($a, $b); if ($diff) { $formatter = new AriadneDiffFormatter(); $result = $formatter->format($diff); $rows = ar_html::nodes(); foreach ($result as $line) { $cells = ar_html::nodes(); foreach ($line as $content) { if (is_array($content)) { $options = array(); if ($content['class']) { $options['class'] = $content['class']; } if ($content['colspan']) { $options['colspan'] = $content['colspan']; } $cell = ar_html::tag("td", $options, $content['data']); $cells[] = $cell; } else { $cells[] = ar_html::tag("td", $content); } } $rows[] = ar_html::tag("tr", $cells); } if (count($rows)) { $table = ar_html::tag("table", array("class" => "diff"), $rows); $table->insertBefore(ar_html::tag("col", array("class" => "content")), $table->firstChild); $table->insertBefore(ar_html::tag("col"), $table->firstChild); $table->insertBefore(ar_html::tag("col", array("class" => "content")), $table->firstChild); $table->insertBefore(ar_html::tag("col"), $table->firstChild); return $table; } } }
public function getField($content = null) { $legend = null; if ($this->label) { $legend = ar_html::el('legend', $this->label); } if (!isset($content)) { $content = ar_html::nodes(); foreach ($this->children as $child) { $content[] = $child->getField(); } } $content = ar_html::nodes($legend, $content); $help = $this->getHelp(); if ($help) { $content[] = $help; } $class = array('formField', 'form' . ucfirst($this->type)); if ($this->class) { $class[] = $this->class; } $attributes = array('class' => $class); if ($this->id) { $attributes['id'] = $this->id; } return ar_html::el('fieldset', $content, $attributes); }
public function levels($options = array()) { $options += array('maxDepth' => 5, 'startLevel' => 0); // add level classes to the ul/li tags, level-0, level-1, etc. if ($options['maxDepth'] == 0) { return $this; } if (!isset($options['rootNode'])) { $options['rootNode'] = $this; } if ($options['rootNode'] instanceof ar_htmlElement) { $options['rootNode'] = ar_html::nodes($options['rootNode']); } if ($options['rootNode'] instanceof ar_htmlNodes && count($options['rootNode'])) { $options['rootNode']->setAttribute('class', array('menuLevels' => 'menuLevel-' . $options['startLevel'])); foreach ($options['rootNode'] as $element) { $element->childNodes->setAttribute('class', array('menuLevels' => 'menuLevel-' . $options['startLevel'])); $this->levels(array('maxDepth' => $options['maxDepth'] - 1, 'startLevel' => $options['startLevel'] + 1, 'rootNode' => $element->getElementsByTagName($this->options['itemTag'], true)->getElementsByTagName($this->options['listTag'], true))); } } $this->levelOptions = $options; return $this; }
public static function editableTextSpan($content, $name, $editTitle = '') { if (self::$editMode) { $context = pobject::getContext(); $me = $context["arCurrentObject"]; $register = self::registerEditable($name); return ar_html::nodes($register['content'], ar_html::tag('span', array('id' => $register['id'], 'class' => array('editable', 'text-only'), 'ar:path' => $me->path, 'ar:id' => $me->id, 'title' => $editTitle), self::parse($content))); } else { return self::parse($content); } }
public static function showList($data, $viewtype = 'list') { global $ARnls; if (is_array($data['objects']) && count($data['objects']) && $data['total'] > 0) { $nodes = ar_html::nodes(); switch ($viewtype) { case "details": $maxlen = 32; break; case "icons": $maxlen = 14; break; default: $maxlen = 11; break; } foreach ($data['objects'] as $node) { $content = self::getTypeIcon($node, $viewtype); if (is_array($node['svn'])) { $content[] = self::getSvnIcon($node['svn']['status']); } $item_class = "explore_item"; if ($node['priority'] < 0) { $item_class .= " hidden"; } $content[] = ar_html::tag('span', array('class' => 'explore_name'), self::labelspan($node['name'], $maxlen)); $nodes[] = ar_html::tag('li', array('class' => $item_class, 'data-path' => $node['path']), ar_html::tag('a', array('class' => 'explore_link', 'href' => $node['local_url'] . 'explore.html', 'onDblClick' => "top.muze.ariadne.explore.view('" . htmlspecialchars($node['path']) . "'); return false;", 'title' => $node['name']), $content)); } $result = ar_html::tag('ul', array('class' => array('explore_list', $viewtype)), $nodes); } else { if ($data['total'] > 1000) { $content = htmlspecialchars($ARnls['ariadne:too_many_objects_found'] . " (" . $data['total'] . ")"); $selectoptions = array("sanity-off" => $ARnls['ariadne:select:showall']); foreach ($selectoptions as $key => $value) { $content .= '<br><a href="#" onclick="muze.ariadne.explore.viewpane.setfilter(\'' . htmlspecialchars($key) . '\'); return false;">' . htmlspecialchars($value) . '</a>'; } $result = ar_html::tag('div', array('class' => 'noobjects'), $content); } else { $result = ar_html::tag('div', array('class' => 'noobjects'), htmlspecialchars($ARnls['ariadne:no_objects_found'])); } } echo $result . "\n"; }