<?php
// $Id$
/**
 * 友情链接管理
 */
function link_admin_page(){                  //$vid是搜索表单需要的，当友情链接模块开启添加自定义字段后填写
  $args = NULL;
  $where = ' n.id>0';
	if($_GET['title']){
	  $where .= ' and n.title LIKE ?';
	  $args[] = '%'.$_GET['title'].'%';
	}
	if($_GET['url']){
	  $where .= ' and n.url LIKE ?';
	  $args[] = '%'.$_GET['url'].'%';
	}
  $output = dd_get_form('link_search_form');
  if($fetch = pager_query('SELECT n.* FROM {link} n WHERE '.$where.' ORDER BY n.id DESC',10,0,'',$args)){  
  $output .= '<form name="oform" id="oform" accept-charset="UTF-8" action="link/duoxuan" method="post">';
	foreach($fetch as $o){
		$term = get_term_bynid($o->id);
		$table[] = array('<input name="id[]" type="checkbox" value="'.$o->id.'" />'.$o->id,$o->title,l($o->url,$o->url,array('attributes' => array('target' => '_blank'))), date('Y-m-d',$o->created),l('编辑','admin/link/'.$o->id.'/edit').' | '.l('删除','link/'.$o->id.'/delete', array('attributes' => array('class' => 'confirm'))));
	}
  $output .= theme('table', array('序号','标题', 'url', '时间','操作'), $table);
  $output .= '<div id="duoxuan"><input type="submit" name="submit" value="删除" id="delete"/></div>
</form>';
    $output .= pager_view(); // 调用分页
  }

  return $output;
}