Exemple #1
0
 public function _before_edit()
 {
     $map['id'] = $_REQUEST['id'];
     $node = new NodeModel();
     $menu = $node->getMenu();
     $pid = $node->where($map)->getField('pid');
     $selecttree = outNodeSelect($menu, $pid);
     $this->assign('selecttree', $selecttree);
 }
Exemple #2
0
function outNodeSelect($tree, $currentid)
{
    $html = '';
    foreach ($tree as $t) {
        if (empty($t['pid'])) {
            if ($currentid == $t['id']) {
                $html .= '<option value="' . $t['id'] . '" selected="selected">';
            } else {
                $html .= '<option value="' . $t['id'] . '">';
            }
            for ($i = 1; $i < $t['level']; $i++) {
                $html .= '&nbsp;&nbsp;&nbsp;&nbsp;';
                if ($i == $t['level'] - 1) {
                    $html .= '|-';
                }
            }
            $html .= $t['title'];
            $html .= '</option>';
        } else {
            if ($currentid == $t['id']) {
                $html .= '<option value="' . $t['id'] . '" selected="selected">';
            } else {
                $html .= '<option value="' . $t['id'] . '">';
            }
            for ($i = 1; $i < $t['level']; $i++) {
                $html .= '&nbsp;&nbsp;&nbsp;&nbsp;';
                if ($i == $t['level'] - 1) {
                    $html .= '|-';
                }
            }
            $html .= $t['title'];
            $html .= '</option>';
            $html .= outNodeSelect($t['pid'], $currentid);
        }
    }
    return $html;
}