function pub($params)
 {
     $a = array();
     foreach ($params as $i) {
         $a[] = get_w($i);
     }
     $this->sf("_pub/" . join("/", $a));
 }
 function x2f($params, $confirm = false, $procedure = "in_controller__form_mail")
 {
     $formG = new FormGeneratorList($_POST);
     $file = get_w($params[0]);
     $option = get_w($params[1]);
     if (!$option) {
         $option = "";
     }
     if (!$file or !file_exists(ROOT . "data/xml/{$file}.xml")) {
         exit;
     }
     $xml = simplexml_load_file(ROOT . "data/xml/{$file}.xml");
     //setting
     $sendmail = $xml->sendmail == "yes";
     $mailto = (string) $this->getOption($xml, "mailto", $option);
     $formG->title = (string) $this->getOption($xml, "title", $option);
     $formG->postTo = (string) $this->getOption($xml, "postback", $option);
     $formG->md5seed = (string) $this->getOption($xml, "md5seed", "");
     if ((string) $this->getOption($xml, "confirm", "") == "yes") {
         $confirm = true;
     }
     $form = $xml->form;
     $counti = 1;
     foreach ($form->field as $field) {
         $field = (array) $field;
         $temp = array();
         $temp["DISPLAY"] = $this->getOptionArr($field, "display", $option);
         $temp["NAME"] = either($field["name"], "formelement_" . $counti++);
         $html = $field["htmlgenerator"];
         $classname = (string) $html->name;
         if ($classname == "HiddenGenerator") {
             $temp["HTML"] = new $classname(either((string) $html->param1, f($temp["NAME"])));
         } else {
             $temp["HTML"] = new $classname((string) $html->param1, (string) $html->param2, (string) $html->param3);
         }
         $tempvalid = array();
         foreach ($field["valids"] as $validitem) {
             $classname = (string) $validitem->name;
             $tempvalid[] = new $classname((string) $validitem->param1, (string) $validitem->param2, (string) $validitem->param3);
         }
         $temp["VALID"] = $tempvalid;
         $temp["ERROR"] = $this->getOptionArr($field, "error", $option);
         $formG->addGenerator($temp);
     }
     $ra_param = array();
     $ra_param["sendmail"] = $sendmail;
     $ra_param["confirm"] = $confirm;
     echo $this->processForm($formG, $procedure, $ra_param);
     echo $this->htmlfooter();
     exit;
 }
 function edit($params)
 {
     if ($this->is_post()) {
         $data = p("data");
         $datadb = array();
         $datadb['id'] = $data['id'];
         $datadb['guid'] = $data['guid'];
         $datadb['gushu'] = $data['gushu'];
         $datadb['guin'] = $data['guin'];
         $datadb['gunow'] = $data['gunow'];
         $datadb['comment'] = $data['comment'];
         $datadb['fenxi'] = $data['fenxi'];
         $datadb['danwei'] = $data['danwei'];
         if (f("inguprice") && f("ingunum")) {
             $datadb['guin'] = ($datadb['guin'] * $datadb['gushu'] + f("inguprice")) / ($datadb['gushu'] + f("ingunum"));
             //echo $datadb['guin'];exit;
             $datadb['gushu'] = $datadb['gushu'] + f("ingunum");
         }
         $re = $this->modeldb->save($datadb);
         if ($re) {
             $this->jump(PREFIXURL . "/" . $this->ctl . "/show/" . get_w($data[guid]), "data updated.");
         } else {
             $this->sv("error_field", $this->modeldb->error_detail());
         }
         $this->sv("data", p("data"));
     } else {
         $this->sv("data", $this->modeldb->peek(array("guid" => $params[0])));
     }
 }
 function default_func($params)
 {
     $a = array();
     foreach ($params as $i) {
         $a[] = get_w($i);
     }
     if (file_exists(ROOT . $this->ctl . "/" . join("/", $a))) {
         $this->sf($this->ctl . "/" . join("/", $a));
     } else {
         //return new ControlUnit("redirect_action",array("quick","blog",$params));
     }
 }
 function picture($params)
 {
     $filename = get_w($params[0]) ? get_w($params[0]) : "my";
     $filepath = ROOT . "data/pic-{$filename}.data";
     if (!file_exists($filepath)) {
         $this->do404();
     }
     $files = file($filepath);
     $foot = pagerfoot2(f("page"), $files, '/' . $this->ctl . '/' . $this->action, 6);
     $files = $foot["data"];
     foreach ($files as &$i) {
         $i = 'http://dl.getdropbox.com/u/637079/album/' . $i;
     }
     $this->sv("piclist", $files);
     $this->sv("foot", $foot["pagecode"]);
 }
 function edit($params)
 {
     if ($this->is_post()) {
         $data = p("data");
         $re = $this->modeldb->save($data);
         if ($re) {
             $this->jump_cookie(PREFIXURL . "/" . $this->ctl . "/show/" . get_w($data[id]), "data updated.");
         } else {
             $this->sv("error_field", $this->modeldb->error_detail());
         }
         $this->sv("data", p("data"));
     } else {
         $data = $this->modeldb->peek(array("id" => $params[0]));
         $this->sv("data", $data);
     }
     $this->sf("scaffold/edit");
     if ($this->format == "javaform") {
         foreach ($this->table_detail as $col) {
             $init = $data[$col[name]];
             $init = preg_replace('/\\r|\\n/', "[CRLF]", $init);
             if ($col[name] != "id" && $col[name] != "created_at" && $col[name] != "updated_at") {
                 if ($col["type"] == "text" || $col["type"] == "blob" || $col["type"] == "longtext") {
                     echo "-n data[{$col['name']}] -s {$col['name']} -g TextareaGenerator -i {$init}\n";
                 } else {
                     echo "-n data[{$col['name']}] -s {$col['name']} -g InputTextGenerator -i {$init}\n";
                 }
             } else {
                 echo "-n data[{$col['name']}] -s {$col['name']} -g HiddenGenerator -i {$init}\n";
             }
         }
         exit;
     }
 }