function showTree(&$data, $page_id, $role_id) { foreach ($data as $key => $value) { if ($role_id == 7 && $key != 1) { continue; } if ($page_id == $key) { $link = '<span style="color:#F15A22">' . $value['name'] . ' (' . $key . ')</span>'; } else { $link = '<a href="' . Yii::app()->request->baseUrl . '/admin.php?r=pages/update&id=' . $key . '">' . $value['name'] . '</a> (' . $key . ')'; } if ($value['active'] == '0') { $link = '<span style="color:#CCC;">' . $link . '</span>'; } if (ModulesInPages::model()->find('page_id = ' . $key)) { $link = '<b>' . $link . '</b>'; } if (count($value['child']) > 0) { echo '<li>' . $link . ' <a href="' . Yii::app()->request->baseUrl . '/admin.php?r=pages/delete&id=' . $key . '" onclick="return confirm(\'Вы действительно хотите удалить страницу ?\')"><img src=\'/admin/pics/i/del-small.png\' alt="Удалить раздел" class="deletePage"></a></li>'; echo '<ul class="lvl2">'; showTree($value['child'], $page_id, $role_id); echo '</ul>'; } else { echo '<li>' . $link . ' <a href="' . Yii::app()->request->baseUrl . '/admin.php?r=pages/delete&id=' . $key . '" onclick="return confirm(\'Вы действительно хотите удалить страницу ?\')"><img src=\'/admin/pics/i/del-small.png\' alt="Удалить раздел" class="deletePage"></a></li></li>'; } } }
/** * $field = array('id'=>'','name'=>'','pid'=>,'sort') * <tr><td>ID</td><td>部门</td><td>排序</td><td>操作</td></tr> * {:showTree($tree,$field,$_func)} * @param unknown_type $data * @param unknown_type $field * @param unknown_type $func * @param unknown_type $p */ function showTree($data, $field, $func, $p = '') { $html = ''; $p = empty($p) ? '' : $p . ' - '; // $big = empty($p) ? "style='font-weight:bold'" : ''; foreach ($data as $key => $val) { $html .= "<tr><td>{$val[$field['id']]}</td>\n\t\t\t\t <td>{$p}{$val[$field['name']]}</td>" . "<td><span rel='edit' cateid='" . $val[$field['id']] . "' func='{$func}'>" . L('PUBLIC_MODIFY') . "</span>-\n\t\t\t<span rel='move' cateid='" . $val[$field['id']] . "' func='{$func}'>" . L('PUBLIC_MOVES') . "</span>-\n\t\t\t<span rel='del' cateid='" . $val[$field['id']] . "' func='{$func}'>" . L('PUBLIC_STREAM_DELETE') . "</span></td></tr>"; if (!empty($val['_child'])) { $html .= showTree($val['_child'], $field, $func, $p . $val[$field['name']]); } } return $html; }
function showTree($p_id, $db) { global $data; // глобальная переменная для записи в неё данных $sql = "SELECT * FROM categories WHERE p_id=" . $p_id; $result = $db->query($sql); $data .= "<ul>"; while ($row = $result->fetch(PDO::FETCH_ASSOC)) { $next_pid = $row['id']; $data .= "<li>"; $data .= $row['name']; $data .= "</li>"; showTree($next_pid, $db); } $data .= "</ul>"; return $data; }
function showTree(&$arr, $current = 0, $key = 0, $prefix = '', $foundusers = array()) { global $xoopsConfig; if ($key != 0) { if (0 != $arr[$key]['obj']->uid()) { if (!isset($foundusers[$arr[$key]['obj']->uid()])) { $eachposter = new XoopsUser($arr[$key]['obj']->uid()); $foundusers[$arr[$key]['obj']->uid()] =& $eachposter; } else { $eachposter =& $foundusers[$arr[$key]['obj']->uid()]; } $poster_rank = $eachposter->rank(); if ($poster_rank['image'] != '') { $poster_rank['image'] = '<img src="' . XOOPS_UPLOAD_URL . '/' . $poster_rank['image'] . '" alt="" />'; } if ($eachposter->isActive()) { $posterarr = array('poster_uid' => $eachposter->getVar('uid'), 'poster_uname' => '<a href="' . XOOPS_URL . '/userinfo.php?uid=' . $eachposter->getVar('uid') . '">' . $eachposter->getVar('uname') . '</a>'); } else { $posterarr = array('poster_uid' => 0, 'poster_uname' => $xoopsConfig['anonymous']); } } else { $posterarr = array('poster_uid' => 0, 'poster_uname' => $xoopsConfig['anonymous']); } $posticon = $arr[$key]['obj']->icon(); if (isset($posticon) && $posticon != '') { $post_image = '<img src="' . XOOPS_URL . '/images/subject/' . htmlspecialchars($posticon) . '" alt="" />'; } else { $post_image = '<img src="' . XOOPS_URL . '/images/icons/no_posticon.gif" alt="" />'; } if ($current != $key) { $subject = '<a href="viewtopic.php?viewmode=thread&topic_id=' . $arr[$key]['obj']->topic() . '&forum=' . $arr[$key]['obj']->forum() . '&post_id=' . $arr[$key]['obj']->postid() . '#forumpost' . $arr[$key]['obj']->postid() . '">' . $arr[$key]['obj']->subject() . '</a>'; $GLOBALS['xoopsTpl']->append("topic_trees", array_merge($posterarr, array("post_id" => $arr[$key]['obj']->postid(), "post_parent_id" => $arr[$key]['obj']->parent(), "post_date" => formatTimestamp($arr[$key]['obj']->posttime(), "m"), "post_image" => $post_image, "post_title" => $subject, "post_prefix" => $prefix))); } else { $subject = '<b>' . $arr[$key]['obj']->subject() . '</b>'; $thisprefix = substr($prefix, 0, -6) . "<b>»</b>"; $GLOBALS['xoopsTpl']->append("topic_trees", array_merge($posterarr, array("post_id" => $arr[$key]['obj']->postid(), "post_parent_id" => $arr[$key]['obj']->parent(), "post_date" => formatTimestamp($arr[$key]['obj']->posttime(), "m"), "post_image" => $post_image, "post_title" => $subject, "post_prefix" => $thisprefix))); } } if (isset($arr[$key]['replies']) && !empty($arr[$key]['replies'])) { $prefix .= " "; foreach ($arr[$key]['replies'] as $replykey) { $current = $current == 0 ? $replykey : $current; showTree($arr, $current, $replykey, $prefix, $foundusers); } } }
case "advsearch": advsearch($option); break; case "advsearch2": advsearch2($option); break; /* Ajax Category */ /* Ajax Category */ case "getcats": getCats($cat_id); break; /* Default Main Index */ /* Default Main Index */ case "listcats": default: showTree($cat_id, $limitstart, $option, $my); break; } // Append CSS file to Head if ($mtconf->get('load_css') && $document->getType() == 'html') { if (file_exists($savantConf['template_path'] . 'template.css')) { $document->addCustomTag("<link href=\"" . str_replace(DS, '/', str_replace($mtconf->getjconf('absolute_path'), $mtconf->getjconf('live_site'), $savantConf['template_path'] . 'template.css')) . "\" rel=\"stylesheet\" type=\"text/css\"/>"); } elseif (file_exists($mtconf->getjconf('absolute_path') . '/components/com_mtree/templates/' . $mtconf->get('template') . '/template.css')) { $document->addCustomTag("<link href=\"" . $mtconf->getjconf('live_site') . "/components/com_mtree/templates/" . $mtconf->get('template') . "/template.css\" rel=\"stylesheet\" type=\"text/css\"/>"); } else { $document->addCustomTag("<link href=\"" . $mtconf->getjconf('live_site') . "/components/com_mtree/templates/m2/template.css\" rel=\"stylesheet\" type=\"text/css\"/>"); } } function getCats($parent_cat_id) { $database =& JFactory::getDBO();
<?php echo $tVars['formc']; if ($tVars['class'] !== NULL) { echo '<pre>' . PHP_EOL; showTree($tVars['class']); echo '</pre>' . PHP_EOL; } function showTree(GWF_Tree $gdo) { if (false === ($result = $gdo->select('cat_tree_id id, cat_tree_key `key`, cat_tree_pid pid, cat_tree_left `left`, cat_tree_right `right`', '', 'cat_tree_left ASC'))) { echo GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); return false; } $stack = array(); $class = urlencode(Common::getGetString('class')); while (false !== ($node = $gdo->fetch($result, GDO::ARRAY_A))) { while (count($stack) > 0 && $stack[count($stack) - 1] < $node['right']) { array_pop($stack); } $btnU = sprintf('<a href="index.php?mo=Tree&me=Edit&class=%s&up=%s">^</a>', $class, $node['id']); $btnD = sprintf('<a href="index.php?mo=Tree&me=Edit&class=%s&down=%s">v</a>', $class, $node['id']); echo str_repeat(' ', count($stack)) . $node['key'] . ' ' . $btnU . ' ' . $btnD . PHP_EOL; $stack[] = $node['right']; } $gdo->free($result); }
function showTree($subtree, $level = -1, $expand = '') { global $fm_tree, $cfg_client, $perm, $cms_lang, $idclient; if ($level == -1) { $treeroot = array(0 => array("iddirectory" => 0, "dirname" => $cfg_client['upl_path'], "status" => 0, "idclient" => $idclient, "parentid" => 0, "name" => $cms_lang["upl_root_dir"], "description" => $cfg_client['upl_htmlpath'], "author" => 0)); showDirectory(-1, $treeroot[0], '', $treeroot[0]['status'], '#F8F8F8'); $level = 0; } if (empty($level)) { foreach ($subtree as $key => $value) { if ($value[0]['parentid'] != 0) { continue; } if ($perm->have_perm(1, 'folder', $value[0]['iddirectory'])) { showDirectory($level, $value[0], $value[0]['iddirectory'], $value[0]['status']); if (is_array($value['_members_'])) { foreach ($value['_members_'] as $membervalue) { showTree($fm_tree[$membervalue], $level + 1, $value[0]['iddirectory']); } } } } } else { if ($perm->have_perm(1, 'folder', $subtree[0]['iddirectory'])) { showDirectory($level, $subtree[0], $subtree[0]['iddirectory'] . '_' . $expand, $subtree[0]['status']); if (is_array($subtree['_members_'])) { foreach ($subtree['_members_'] as $membervalue) { showTree($fm_tree[$membervalue], $level + 1, $subtree[0]['iddirectory'] . '_' . $expand); } } } } }