Ejemplo n.º 1
0
 public function look($agent)
 {
     $this->load->model('dynamicui_model');
     $model = new Dynamicui_model();
     //$data['list'] = $model->getGerendata();
     //$data['list_id'] = $model->getGereniddata();
     $data['list'] = array_combine($model->getGerendata(), $model->getGereniddata());
     //print_r($data['list']);
     //foreach($data['list'] as $keys=>$values)
     //{
     //	$arr_n = count($data['list']);
     //}
     //echo $arr_n;
     $this->load->view('custom_view', $data);
 }
Ejemplo n.º 2
0
 public function ajaxAddClient()
 {
     //header('Content-type: Application/json',true);
     $req = $this->input->post();
     if (empty($req)) {
         return false;
     }
     function add_new_item($new_item, $req)
     {
         $new_item->addChild("id", $req['client_id']);
         $new_item->addChild("dbfield", $req['client_dbfield']);
         $new_item->addChild("type", $req['client_type']);
         $new_item->addChild("name", $req['client_name']);
         $new_item->addChild("colspan", $req['client_colspan']);
         $new_item->addChild("lspace", $req['client_lspace']);
         $new_item->addChild("width", $req['client_width']);
         $new_item->addChild("height", $req['client_height']);
         $new_item->addChild("valuesource", $req['client_valuesource']);
     }
     function serch_insert_post($xml, $cout)
     {
         for ($i = 0; $i < $cout; $i++) {
             $lenth = count($xml->baseInfoTable->row[$i]->item);
             if ($lenth < 3) {
                 return $i;
             }
         }
     }
     $data = "./layoutxml/beijing-jiaoyu.xml";
     $xml = simplexml_load_file($data);
     //创建 SimpleXML对象
     $res = "";
     //判断标志位
     $cont = 0;
     $cout = count($xml->baseInfoTable->row);
     //计算row的个数
     $lenth = count($xml->baseInfoTable->row[$cout - 1]->item);
     //返回最后一个row中item的个数
     $ret = serch_insert_post($xml, $cout);
     if ($cout == 0) {
         $root = $xml->baseInfoTable;
         $new_row = $root->addChild('row');
         $new_item = $new_row->addChild('item');
         add_new_item($new_item, $req);
         $xml->asXML($data);
         $res = "添加成功!!";
         $cont = 1;
         //echo $cout;
     } else {
         if ($lenth < 3) {
             $root = $xml->baseInfoTable->row[$ret];
             $new_item = $root->addChild('item');
             add_new_item($new_item, $req);
             $xml->asXML($data);
             $res = "添加成功!!";
             $cont = 1;
         } else {
             if ($lenth == 3) {
                 $root = $xml->baseInfoTable;
                 $new_row = $root->addChild('row');
                 $new_item = $new_row->addChild('item');
                 add_new_item($new_item, $req);
                 $xml->asXML($data);
                 $res = "添加成功!!";
                 $cont = 1;
             }
         }
     }
     if ($cont) {
         $this->load->model('dynamicui_model');
         $model = new Dynamicui_model();
         $data_r = array_combine($model->getGerendata(), $model->getGereniddata());
     } else {
         $data_r = "";
     }
     $ret = array();
     $ret["cont"] = $cont;
     $ret["res"] = $res;
     $ret["data"] = $data_r;
     echo json_encode($ret);
 }