Пример #1
0
 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);
 }
Пример #2
0
 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;
         }
     }
 }
Пример #3
0
 private function _getItemInfo($item, $key, $parent, $current)
 {
     if ($item instanceof ar_htmlElement) {
         if ($item->attributes['href']) {
             $url = $item->attributes['href'];
         } else {
             $url = null;
         }
         $item = array('node' => $item, 'url' => $url);
     }
     if (!is_array($item)) {
         $item = array('name' => $item);
     }
     $path = $item['path'];
     if (!isset($path)) {
         $path = $key;
         $item['path'] = ($parent != '[root]' ? $parent : '') . $key;
     }
     if (!isset($item['url'])) {
         $item['url'] = $this->_makeURL($path, $parent);
     }
     if (!isset($item['node'])) {
         if (!isset($item['tagName'])) {
             $item['tagName'] = $this->options['itemTag'];
         }
         if (!isset($item['attributes'])) {
             //FIXME: ['attributes']['a'] / ['li'] / ['ul']
             // rest of ['attributes'] = ['attributes']['a']
             $item['attributes'] = array();
         }
         $linkAttributes = array('href' => $item['url']);
         if (isset($item['title'])) {
             $linkAttributes['title'] = $item['title'];
         }
         if (isset($item['class'])) {
             $linkAttributes['class'][] = $item['class'];
         }
         if (isset($item['id'])) {
             $linkAttributes['id'] = $item['id'];
         }
         if ($item['path'] == $current || $item['url'] == $current) {
             $linkAttributes['class']['menuCurrent'] = 'menuCurrent';
             if (!is_array($item['attributes']['class'])) {
                 $item['attributes']['class'] = array($item['attributes']['class']);
             }
             $item['attributes']['class']['menuCurrent'] = 'menuCurrent';
         } else {
             if (strpos($current, $item['path']) === 0 || strpos($current, $item['url']) === 0) {
                 if (!is_array($item['attributes']['class'])) {
                     $item['attributes']['class'] = array($item['attributes']['class']);
                 }
                 $item['attributes']['class']['menuParent'] = 'menuParent';
             }
         }
         $item['node'] = ar_html::tag($item['tagName'], $item['attributes'], ar_html::tag('a', $linkAttributes, $item['name']));
     } else {
         $link = $item['node']->a[0];
         if ($item['path'] == $current || $item['url'] == $current || $link && $link->attributes['href'] == $current) {
             if ($link) {
                 $link->setAttribute('class', array('menuCurrent' => 'menuCurrent'));
             }
             $item['node']->setAttribute('class', array('menuCurrent' => 'menuCurrent'));
         } else {
             if (strpos($current, $item['path']) === 0 || strpos($current, $item['url']) === 0 || $link && strpos($current, $link->attributes['href']) === 0) {
                 $item['node']->setAttribute('class', array('menuParent' => 'menuParent'));
             }
         }
     }
     return $item;
 }
Пример #4
0
 public static function registerEditable($name)
 {
     $context = pobject::getContext();
     $me = $context["arCurrentObject"];
     $id = self::$editCounter++;
     $prefix = self::$editPrefix;
     return array('id' => $prefix . $id, 'content' => ar_html::tag('script', " parent.registerDataField('" . $prefix . $id . "', '" . AddCSlashes($name, ARESCAPE) . "', '" . $me->path . "', '" . $me->id . "' );"));
 }
Пример #5
0
 public function caption($content, $attributes = null)
 {
     $newCaption = ar_html::tag('caption', $content, $attributes);
     if ($caption = $this->caption->firstChild) {
         $this->replaceChild($newCaption, $caption);
     } else {
         $this->insertBefore($newCaption, $this->firstChild);
     }
     return $this;
 }
Пример #6
0
 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";
 }
Пример #7
0
 public function __toString()
 {
     return (string) ar_html::tag('style', $this->attributes, (string) $this->rules);
 }