function populate_node($node, $pageName, $remainingLevels = 3, $pages = array()) { global $wikilib, $tikilib, $user; $child = $wikilib->wiki_get_neighbours($pageName); $child = array_diff($child, $pages); foreach ($child as $page) { if (!$tikilib->user_has_perm_on_object($user, $page, 'wiki page', 'tiki_p_view')) continue; $node->appendChild($new = create_node($node->ownerDocument, $page)); if ($remainingLevels != 0) populate_node($new, $page, $remainingLevels - 1, array_merge($pages, array($page, $pageName))); else $new->setAttribute('STYLE', 'fork'); } if (count($child) == 0) $node->setAttribute('STYLE', 'fork'); }
function node_controller() { require "Modules/node/node_model.php"; global $session, $route; $output['content'] = ""; $output['message'] = ""; if ($route['action'] == 'create' && $session['write']) { $nodeid = create_node($session['userid'], "(new)", ""); $output['message'] = "Node created"; } if ($route['action'] == 'list' && $session['read']) { $list = get_node_list($session['userid']); $output['content'] = view('node/node_list.php', array('list' => $list)); } if ($route['action'] == 'edit' && $session['write']) { $nodeid = intval($_GET['id']); $title = get_node_title($nodeid); $content = get_node_content($nodeid); $output['content'] = view('node/node_edit.php', array('id' => $nodeid, 'title' => $title, 'content' => $content)); } if ($route['action'] == 'save' && $session['write']) { $nodeid = intval($_POST['id']); $title = $_POST['title']; $content = $_POST['content']; $content = db_real_escape_string($content); set_node_title($nodeid, $title); set_node_content($nodeid, $content); $output['message'] = "Node saved"; } if ($route['action'] == 'view') { $nodeid = intval($_GET['id']); $title = get_node_title($nodeid); $content = get_node_content($nodeid); include_once "Modules/node/markdown/markdown.php"; $content = Markdown($content); $output['content'] = view('node/node_view.php', array('title' => $title, 'content' => $content)); } if ($route['action'] == 'delete' && $session['write']) { $nodeid = intval($_GET['id']); delete_node($nodeid); $output['message'] = "Node deleted"; } return $output; }
/** * @param Object user: object of type Forecasts/Common representing the user downline nodes will be created for. * @param object parent_node: object of type Node, codes created in this function will have this parent. * @version since 4.5 * */ function add_downline($user, &$parent_node) { $ret = array(); $node = null; if (count($user->my_direct_reports) > 0) { //add node for manager's direct forecasts. NOT if the user preference for opportunity ownership is set to false. if (user_owns_opps($user->current_user, null)) { $node = create_node($user->current_user, true, false, true); if (!empty($parent_node)) { $parent_node->add_node($node); } $ret[] = $node; } foreach ($user->my_direct_reports as $id => $name) { $node = create_node($id); if (!empty($parent_node)) { $parent_node->add_node($node); } $ret[] = $node; } } return $ret; }
function UpdateInitXml($dir, $resType = 'img') { $uiResFile = $dir . '\\uires.idx'; $styleFile = $dir . '\\xml\\init.xml'; echo $uiResFile . "<br>"; echo $styleFile . "<br>"; //解析uires.idx文件,得到图片资源 //创建一个XML文档并设置XML版本和编码 $doc = new DomDocument(); $doc->preserveWhiteSpace = false; $doc->load($uiResFile); // $doc->formatOutput = true; //xml输出的时候要加上编码,否则输出的中文变成一堆奇怪的符号 $doc->encoding = 'UTF-8'; // echo htmlspecialchars($doc->saveXML()); //读取init.xml文件 $doc2 = new DomDocument(); $doc2->preserveWhiteSpace = false; $doc2->load($styleFile); $doc2->encoding = 'UTF-8'; $skin_node = $doc2->getElementsByTagName("skin")->item(0); //扫描<skin>下的所有name $names = array(); foreach ($skin_node->childNodes as $node) { $name = $node->getAttribute('name'); $names[] = $name; } //扫描uires.idx文件中的<img>标签 foreach ($doc->getElementsByTagName($resType) as $nodes) { foreach ($nodes->childNodes as $node) { $name = $node->getAttribute('name'); $src = $node->getAttribute('path'); $skin_name = "skin_" . strtolower($name); $src_name = $resType . ":" . strtoupper($name); if (in_array($skin_name, $names)) { continue; } echo $skin_name . '-->' . $src_name . '<br>'; xml_append_child($skin_node, create_node($doc2, 'imgframe', null, array('name' => $skin_name, 'src' => $src_name, 'tile' => 1))); } } prettyXml($doc2->saveXML(), $styleFile); }