Ejemplo n.º 1
0
 /**
  * 默认函数
  * Enter description here ...
  */
 public function index()
 {
     $pageIndex = $this->input->get('page') ? $this->input->get('page') : 1;
     $xml = new XML();
     $file = fopen("Area.xml", "r") or die("Unable to open file!");
     //读取XML内容
     $filetxt = "";
     $filetxt = fread($file, filesize("../uploadfile/Area/Area.xml"));
     //将文件中的序列化字符串读出
     $unTreeresult = $xml->xml_unserialize($filetxt);
     //反序成内容
     fclose($file);
     //关闭文件
     $tree = new Tree();
     //新建一个树
     $totalCount = count($unTreeresult["root"]["item"]);
     //获得数据总条目
     $pageSize = 100;
     $first = ($pageIndex - 1) * $pageSize;
     //得到获得数组循环的首下表
     $end = $pageIndex * $pageSize;
     //尾下标-1
     $end <= $totalCount ? "" : ($end = $totalCount);
     $result = array();
     //取得小树
     for ($first; $first < $end; $first++) {
         $result[] = $unTreeresult["root"]["item"][$first];
     }
     $page = new Page();
     $str_page = $page->create($pageIndex, $pageSize, $totalCount, array(), array());
     $data['page'] = $str_page;
     $data['result'] = $result;
     $this->load->view('Area/list', $data);
 }
Ejemplo n.º 2
0
	/**
	 * 默认函数
	 * Enter description here ...
	 */
	public function index()
	{
		$pageIndex=$this->input->get('page')?$this->input->get('page'):1;

          //$res = wddx_serialize_value($treeResult );//序列化为XML
          //echo ($res."</br>-----------------" );
          //$file=fopen("Area.txt","w");
          //fwrite($file, $res);

        //$filetxt=fread($file,1000);
        //$unres = wddx_deserialize($filetxt);//反序列化为数组
       // print_r($filetxt);
        //fclose("uploadfile/Area/Area.txt");

       $xml = new XML();
       //$res=$xml->xml_serialize($treeResult,0,null);
       // $file = fopen("Area.xml", "w");
        //fwrite($file, $res);//将序列化的字符写进文件
       // print_r($res);
        //fclose($file);



        //$file = fopen("Area.txt", "r");
        //$filetxt = fread($file,filesize("Area.txt"));//将文件中的序列化字符串读出
       //while(!feof($file))
		//{
		  //	$filetxt=$filetxt.fgets($file);
		//}
        //echo $filetxt;

        $file = fopen("Area.xml","r") or die("Unable to open file!");//读取XML内容
		$filetxt ="";	
		$filetxt = fread($file,filesize("../uploadfile/Area/Area.xml"));//将文件中的序列化字符串读出
        $unTreeresult =$xml->xml_unserialize($filetxt);//反序成内容
        fclose($file);//关闭文件
        $tree=new Tree();//新建一个树
		$totalCount = count($unTreeresult["root"]["item"]);//获得数据总条目
		$pageSize=100;				
		$first =($pageIndex-1)*$pageSize; //得到获得数组循环的首下表
		$end = $pageIndex*$pageSize;//尾下标-1
		$end <= $totalCount?"":$end=$totalCount;
		$result = array();//取得小树
		for ($first;$first<$end;$first++)
			{ 
				$result[] = $unTreeresult["root"]["item"][$first];
			}			
		$page=new Page();
		$str_page=$page->create($pageIndex, $pageSize, $totalCount, array(), array());
		$data['page']=$str_page;
		$data['result']=$result;
		$this->load->view('Area/list',$data);

	}