function print_node_r(DomNode $node) { static $indent = ""; echo "\n" . $indent; print_node($node); echo $indent . "parent: "; if ($node->parentNode) { print_node($node->parentNode); } else { echo "NULL\n"; } echo $indent . "previousSibling: "; if ($node->previousSibling) { print_node($node->previousSibling); } else { echo "NULL\n"; } echo $indent . "nextSibling: "; if ($node->nextSibling) { print_node($node->nextSibling); } else { echo "NULL\n"; } if (!$node->hasChildNodes()) { return; } foreach ($node->childNodes as $child) { $old_indent = $indent; $indent .= " "; print_node_r($child); $indent = $old_indent; } }
function print_chart_list(&$data) { foreach ($data['root'] as $root_idx) { echo "<li>" . $data[$root_idx]['name'] . "</li>\n"; foreach ($data[$root_idx]['child'] as $key => $child_idx) { print_node($data, $child_idx); } } }
function print_node($node) { echo '<li><a href="/' . drupal_get_path_alias($node['link']['href']) . '">' . $node['link']['link_title'] . '</a>'; $current_level = $node['below']; if (count($current_level)) { echo '<div class="inner"><ul>'; foreach ($current_level as $item) { print_node($item); } echo '</ul></div>'; } echo '</li>'; return; }
function print_chart_list(&$data) { foreach ($data['root'] as $root_idx) { // 하위 부서가 존재하지 않을 경우 단일 메뉴로 구성 if ($data[$root_idx]['child'] == NULL) { echo "<li>\n" . "<a href=\"#\"><span>" . $data[$root_idx]['name'] . "</span> </a>" . "</li>\n"; } else { echo "<li class=\"treeview\"> <a href=\"#\"><span>" . $data[$root_idx]['name'] . "</span> </a>\n"; $data_count = count($data[$root_idx]['child']); foreach ($data[$root_idx]['child'] as $data_idx => $child_idx) { if ($data_idx == 0) { echo "<ul class=\"treeview-menu\">\n"; } print_node($data, $child_idx); if ($data_count == $data_idx + 1) { echo "</ul>\n"; } } echo "</li>\n"; } } }
echo "--------- Remove Attribute Node\n"; $attr = $rootnode->removeAttribute("src"); print "Removed " . $attr . " attributes.\n"; echo "--------- attributes of rootnode\n"; $attrs = $rootnode->attributes; print_node_list($attrs); echo "--------- children of an attribute\n"; $children = $attrs->item(0)->childNodes; print_node_list($children); echo "--------- Add child to root\n"; $myelement = new domElement("Silly", "Symphony"); $newchild = $rootnode->appendChild($myelement); print_node($newchild); print $dom->saveXML(); print "\n"; echo "--------- Find element by tagname\n"; echo " Using dom\n"; $children = $dom->getElementsByTagname("Silly"); print_node_list($children); echo " Using elem\n"; $children = $rootnode->getElementsByTagName("Silly"); print_node_list($children); echo "--------- Unlink Node\n"; print_node($children->item(0)); $rootnode->removeChild($children->item(0)); print_node_list($rootnode->childNodes); print $dom->savexml(); echo "--------- Find element by id\n"; print "Not implemented\n"; echo "--------- Check various node_name return values\n"; print "Not needed\n";
function print_node_list($nodelist) { foreach ($nodelist as $node) { print_node($node); } }
function print_node($n) { global $settings; global $this_server_url; echo "<ul style='padding-left:10px;'>"; echo "<a href='" . "{$this_server_url}/get.php?return=output&job=" . $n['id'] . "' target='_new'>" . $n['id'] . "</a>"; echo " "; echo "<a href='#unfinished_" . $n['id'] . "'>"; echo "("; echo getTranslation("view", $settings); echo ")"; echo "</a>"; echo "("; echo "<a href='" . "{$this_server_url}/get.php?return=status&job=" . $n['id'] . "' target='_new'>" . $n['id_status'] . "</a>"; echo ")"; if (isset($n['children'])) { foreach ($n['children'] as $c) { print_node($c); } } echo "</ul>"; }
function print_node($element, $features, $app_details) { echo '<li><input type="hidden" name="feature_ids[]" value="' . $element['id'] . '"> <a class="feature_ids" value="' . $element['id'] . '" href="#">' . $features[$element['id']] . '</a><span class="closeButton">X</span><ul>'; ?> <a class="btn" data-toggle="modal" data-target="#myModal_{{$element['id']}}">edit</a> <!-- Modal --> <div class="modal fade" id="myModal_{{$element['id']}}" role="dialog"> <div class="modal-dialog"> <!-- Modal content--> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">Feature Edit</h4> </div> <div class="modal-body"> <input class="form-control" name="each_feature[{{$element['id']}}]['section_id']" value="{{$app_details[$element['id']]->section_id}}" type="hidden" > <div class="form-group"> <label for="name" class="col-md-4 control-label">Feature Title</label> <div class="col-md-6"> <input class="form-control" name="each_feature[{{$element['id']}}]['title']" value="{{$app_details[$element['id']]->title}}" type="text" > </div> </div> <div class="form-group"> <label for="name" class="col-md-4 control-label">Feature Desc</label> <div class="col-md-6"> <input class="form-control" name="each_feature[{{$element['id']}}]['description']" value="{{$app_details[$element['id']]->description}}" type="text" > </div> </div> <div class="form-group"> <label for="name" class="col-md-4 control-label">Caption</label> <div class="col-md-6"> <input class="form-control" name="each_feature[{{$element['id']}}]['caption']" value="{{$app_details[$element['id']]->caption}}" type="text" > </div> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div> </div> </div> <!--odel--> <?php if (!empty($element['children'])) { foreach ($element['children'] as $ele) { print_node($ele, $features, $app_details); } } echo '</ul></li>'; }