Пример #1
0
 public static function import($id, $file)
 {
     $newForm = array();
     $content = FileUtil::readFile($file);
     $printModel = str_replace("'", "\\'", $content);
     if (preg_match_all("'<script[^>]*?>.*?</script>'si", $printModel, $script)) {
         $scriptStr = implode("\n\r", $script[0]);
         $scriptStr = preg_replace("'<script[^>]*?>'", "", $scriptStr);
         $scriptStr = str_ireplace("</script>", "", $scriptStr);
         $newForm["script"] = $scriptStr;
         $printModel = preg_replace("'<script[^>]*?>.*?</script>'si", "", $printModel);
     }
     if (preg_match_all("'<style[^>]*?>.*?</style>'si", $printModel, $css)) {
         $cssStr = implode("\n\r", $css[0]);
         $cssStr = preg_replace("'<style[^>]*?>'", "", $cssStr);
         $cssStr = str_ireplace("</style>", "", $cssStr);
         $newForm["css"] = $cssStr;
         $printModel = preg_replace("'<style[^>]*?>.*?</style>'si", "", $printModel);
     }
     $newForm["printmodel"] = $printModel;
     FlowFormType::model()->modify($id, $newForm);
     $form = new ICFlowForm($id);
     $form->getParser()->parse();
     FileUtil::deleteFile($file);
 }
Пример #2
0
 public function parse($isUpdate = false)
 {
     Ibos::import("application.extensions.simple_html_dom", true);
     if ($isUpdate) {
         $model = preg_replace("/\\s+data-id\\s?=\\s?\"?\\d+\"?/i", "", $this->printmodel);
         $max = 0;
     } else {
         $model = $this->printmodel;
         $max = intval($this->itemmax);
     }
     $elements = array();
     $doc = new simple_html_dom();
     $doc->load($model, true, true, CHARSET);
     $items = $doc->find("ic");
     $config = $this->getItemConfig();
     if (!empty($items) && !empty($config)) {
         $this->refactor($items, $config, $max, $elements);
     }
     $html = $doc->save();
     $this->_cache = $elements;
     CacheUtil::set("form_" . $this->ID, $elements);
     $form["printmodelshort"] = $html;
     if ($max != $this->itemmax) {
         $form["itemmax"] = $max;
     }
     $doc->clear();
     FlowFormType::model()->modify($this->ID, $form);
 }
Пример #3
0
 public function del($ids)
 {
     $id = is_array($ids) ? implode(",", $ids) : $ids;
     $con = sprintf("FIND_IN_SET(catid,'%s')", $id);
     $flowCount = FlowType::model()->count($con);
     $formCount = FlowFormType::model()->count($con);
     if ($flowCount || $formCount) {
         return false;
     } else {
         return $this->deleteAll($con);
     }
 }
Пример #4
0
 public function actionRestore()
 {
     $verID = intval(EnvUtil::getRequest("verid"));
     $ver = FlowFormVersion::model()->fetchByPk($verID);
     $formID = $ver["formid"];
     foreach (FlowType::model()->fetchAllAssociatedFlowIDByFormID($formID) as $flowID) {
         $hasRun = FlowRun::model()->countAllByFlowId($flowID);
         if ($hasRun) {
             $this->ajaxReturn(array("isSuccess" => false, "msg" => Ibos::lang("Formversion Still has run")));
         } else {
             continue;
         }
     }
     unset($ver["formid"]);
     unset($ver["id"]);
     unset($ver["time"]);
     unset($ver["mark"]);
     FlowFormType::model()->modify($formID, $ver);
     $form = new ICFlowForm($formID);
     $form->getParser()->parse(true);
     $this->ajaxReturn(array("isSuccess" => true));
 }
Пример #5
0
 public function actionCategory()
 {
     if (EnvUtil::submitCheck("formhash")) {
         if (isset($_POST["name"])) {
             foreach ($_POST["name"] as $id => $val) {
                 if (!empty($val)) {
                     $data = array("name" => StringUtil::filterCleanHtml($val), "sort" => intval($_POST["sort"][$id]), "deptid" => !empty($_POST["deptid"][$id]) ? implode(",", StringUtil::getId($_POST["deptid"][$id])) : "");
                     FlowCategory::model()->modify(intval($id), $data);
                 }
             }
         }
         if (isset($_POST["newname"])) {
             foreach ($_POST["newname"] as $id => $val) {
                 if (!empty($val)) {
                     $data = array("name" => StringUtil::filterCleanHtml($val), "sort" => intval($_POST["newsort"][$id]), "deptid" => !empty($_POST["newdeptid"][$id]) ? implode(",", StringUtil::getId($_POST["newdeptid"][$id])) : "");
                     FlowCategory::model()->add($data);
                 }
             }
         }
         if (!empty($_POST["delid"])) {
             $id = StringUtil::filterStr($_POST["delid"]);
             if (!FlowCategory::model()->del($id)) {
                 $this->error(Ibos::lang("Category delete require"));
             }
         }
         $this->success(Ibos::lang("Operation succeed", "message"));
     } else {
         $categorys = FlowCategory::model()->fetchAll(array("order" => "sort ASC"));
         foreach ($categorys as $key => &$cat) {
             if ($cat["deptid"] !== "") {
                 $cat["deptid"] = StringUtil::wrapId($cat["deptid"], "d");
             }
             $cat["flownums"] = FlowType::model()->countByAttributes(array("catid" => $cat["catid"]));
             $cat["formnums"] = FlowFormType::model()->countByAttributes(array("catid" => $cat["catid"]));
         }
         $this->render("category", array("list" => $categorys));
     }
 }
Пример #6
0
 public function actionGetNextItemID()
 {
     $id = intval(EnvUtil::getRequest("id"));
     $this->ajaxReturn(array("isSuccess" => true, "id" => FlowFormType::model()->getNextItemID($id)));
 }
Пример #7
0
 protected function beforeSave()
 {
     $_POST["catid"] = intval($_POST["catid"]);
     $_POST["sort"] = intval($_POST["sort"]);
     $_POST["autonum"] = intval($_POST["autonum"]);
     $_POST["autolen"] = intval($_POST["autolen"]);
     $_POST["deptid"] = !empty($_POST["deptid"]) ? StringUtil::getId($_POST["deptid"]) : "";
     if (is_array($_POST["deptid"])) {
         $_POST["deptid"] = implode(",", $_POST["deptid"]);
     }
     if (!isset($_POST["allowattachment"])) {
         $_POST["allowattachment"] = 0;
     }
     if (!isset($_POST["allowversion"])) {
         $_POST["allowversion"] = 0;
     }
     if (!isset($_POST["forcepreset"])) {
         $_POST["forcepreset"] = 0;
     }
     if (empty($_POST["formid"])) {
         if (empty($_POST["formname"])) {
             $this->error(Ibos::lang("Form name invalid"));
         } else {
             $_POST["formid"] = FlowFormType::model()->quickAdd($_POST["formname"], $_POST["catid"]);
         }
     }
 }
Пример #8
0
 protected function setForm($formId)
 {
     $attr = FlowFormType::model()->fetchByPk(intval($formId));
     $this->setAttributes($attr);
 }
Пример #9
0
 public function actionPreview()
 {
     $formId = intval(EnvUtil::getRequest("formid"));
     $ver = intval(EnvUtil::getRequest("verid"));
     if (!$ver) {
         $arr = FlowFormType::model()->fetchByPk($formId);
     } else {
         $arr = FlowFormVersion::model()->fetchByPk($ver);
     }
     if ($arr) {
         $form = new ICFlowForm($arr["formid"]);
         $printmodel = $form->printmodelshort;
         $hidden = $read = array();
         $viewer = new ICFlowFormViewer(array("form" => $form));
         $viewer->handleForm($printmodel, $hidden, $read, true);
         $data = array("formname" => $form->formname, "printmodel" => $printmodel, "script" => $form->script, "css" => $form->css);
         $this->layout = false;
         $this->render("preview", $data);
     }
 }