Ejemplo n.º 1
0
 function get_nav($pid)
 {
     if (!$pid) {
         return;
     }
     //$pinfo = self::selects(null, null, array('channel_id'=>$pid),array(),array('assoc|table=channel'=>null));
     $path = $pinfo['path'];
     $channel = new channel();
     $channel->channel_id = $pid;
     $channel->select();
     //$path = preg_replace('/[0]+/is','',$pinfo['path']);//当前id也在path里。
     $path = trim($channel->path, ',');
     if (!$path) {
         self::update_path($pid);
         return self::get_nav($pid);
     }
     $paths = explode(',', $path);
     $paths = array_map('intval', $paths);
     //pecho($pid);
     //pecho($paths);
     //if($path[count($path)]!=$pid)$path.=','.$pid;
     //$sql = "SELECT * FROM channel WHERE channel_id IN($path)";
     //$pinfos = self::selects($sql,null,true,null,array(null,'assoc'=>null));
     $pinfos = self::selects(null, null, array('channel_id' => explode(',', $path)), array(), array(null, 'assoc|table=channel' => null));
     foreach ($pinfos as $k => $v) {
         if ($v['channel_id'] != $pid) {
             $nav .= '<a href="?go=channel&do=detail&channel_id=' . $v['channel_id'] . '">' . $v['name'] . '</a>&raquo;';
         } else {
             $nav .= '<strong>' . $v['name'] . '</strong>';
         }
     }
     return $nav;
 }