/** * Render form object * * @param EasyForm $formObj * @return string result of rendering process */ public static function render($formObj) { $tplEngine = $formObj->templateEngine; $tplAttributes = FormRenderer::buildTemplateAttributes($formObj); if (isset($formObj->jsClass)) { $subForms = $formObj->subForms ? implode(";", $formObj->subForms) : ""; if ($formObj->staticOutput != true) { $formScript = "\n<script>Openbizx.newFormObject('{$formObj->objectName}','{$formObj->jsClass}','{$subForms}'); </script>\n"; } if ($formObj->autoRefresh > 0) { $formScript .= "\n<script>setTimeout(\"Openbizx.CallFunction('{$formObj->objectName}.UpdateForm()');\",\"" . $formObj->autoRefresh * 1000 . "\") </script>\n"; } } if ($tplEngine == "Smarty" || $tplEngine == null) { return FormRenderer::renderSmarty($formObj, $tplAttributes) . $formScript; } else { return FormRenderer::renderPHP($formObj, $tplAttributes) . $formScript; } }
/** * Render html content of this form * * @return string - HTML text of this form's read mode */ protected function renderHTML() { $formHTML = FormRenderer::render($this); $otherHTML = $this->rendercontextmenu(); if (preg_match('/iPad/si', $_SERVER['HTTP_USER_AGENT']) || preg_match('/iPhone/si', $_SERVER['HTTP_USER_AGENT'])) { $otherHTML .= "\n \t\t<script>\n\t\t\t\tvar a=document.getElementsByTagName('a');\n\t\t\t\tfor(var i=0;i<a.length;i++)\n\t\t\t\t{\n\t\t\t\t\tif(a[i].getAttribute('href').indexOf('javascript:')==-1\n\t\t\t\t\t&& a[i].getAttribute('href').indexOf('#')==-1)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t a[i].onclick=function()\n\t\t\t\t\t\t {\n\t\t\t\t\t\t\t try{\n\t\t\t\t\t\t \t\tshow_loader();\n\t\t\t\t\t\t \t}catch(e){\n\t\t\t\t\t\t \t\t\n\t\t\t\t\t\t \t}\n\t\t\t\t\t\t window.location=this.getAttribute('href');\n\t\t\t\t\t\t return false\n\t\t\t\t\t\t }\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t}\n\t\t\t\t} \n\t\t\t\t</script> \t\t\n \t\t"; } if (!$this->parentFormName) { if (($viewObj = $this->getWebpageObject()) != null) { $viewObj->lastRenderedForm = $this->objectName; } } return $formHTML . "\n" . $otherHTML; }
/** * Rerender this form (form is rendered already) . * * @param boolean $redrawForm - whether render this form again or not, optional default true * @param boolean $hasRecordChange - if record change, need to render subforms, optional default true * @return string - HTML text of this form's read mode */ public function rerender($redrawForm = true, $hasRecordChange = true) { if ($redrawForm) { Openbizx::$app->getClientProxy()->redrawForm($this->objectName, FormRenderer::render($this)); } if ($hasRecordChange) { $this->rerenderSubForms(); } }