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); }
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)); }