/** * Initializes the QForm rendering process * @param bool $blnDisplayOutput Whether the output is to be printed (true) or simply returned (false) * * @return null|string * @throws QCallerException */ public function RenderBegin($blnDisplayOutput = true) { // Ensure that RenderBegin() has not yet been called switch ($this->intFormStatus) { case QFormBase::FormStatusUnrendered: break; case QFormBase::FormStatusRenderBegun: case QFormBase::FormStatusRenderEnded: throw new QCallerException('$this->RenderBegin() has already been called'); break; default: throw new QCallerException('FormStatus is in an unknown status'); } // Update FormStatus and Clear Included JS/CSS list $this->intFormStatus = QFormBase::FormStatusRenderBegun; // Prepare for rendering QApplicationBase::$ProcessOutput = false; $strOutputtedText = trim(ob_get_contents()); if (strpos(strtolower($strOutputtedText), '<body') === false) { $strToReturn = '<body>'; $this->blnRenderedBodyTag = true; } else { $strToReturn = ''; } QApplicationBase::$ProcessOutput = true; // Iterate through the form's ControlArray to Define FormAttributes and additional JavaScriptIncludes $this->strFormAttributeArray = array(); foreach ($this->GetAllControls() as $objControl) { // Form Attributes? if ($objControl->FormAttributes) { $this->strFormAttributeArray = array_merge($this->strFormAttributeArray, $objControl->FormAttributes); } } if (is_array($this->strCustomAttributeArray)) { $this->strFormAttributeArray = array_merge($this->strFormAttributeArray, $this->strCustomAttributeArray); } // Create $strFormAttributes $strFormAttributes = ''; foreach ($this->strFormAttributeArray as $strKey => $strValue) { $strFormAttributes .= sprintf(' %s="%s"', $strKey, $strValue); } if ($this->strCssClass) { $strFormAttributes .= ' class="' . $this->strCssClass . '"'; } // Setup Rendered HTML $strToReturn .= sprintf('<form method="post" id="%s" action="%s"%s>', $this->strFormId, htmlentities(QApplication::$RequestUri), $strFormAttributes); $strToReturn .= "\r\n"; if (!self::$blnStylesRendered) { $strToReturn .= $this->RenderStyles(false, false); } // Perhaps a strFormModifiers as an array to // allow controls to update other parts of the form, like enctype, onsubmit, etc. // Return or Display if ($blnDisplayOutput) { if (!QApplication::$CliMode) { print $strToReturn; } return null; } else { if (!QApplication::$CliMode) { return $strToReturn; } else { return ''; } } }
protected function RenderBegin($blnDisplayOutput = true) { // Ensure that RenderBegin() has not yet been called switch ($this->intFormStatus) { case QFormBase::FormStatusUnrendered: break; case QFormBase::FormStatusRenderBegun: case QFormBase::FormStatusRenderEnded: throw new QCallerException('$this->RenderBegin() has already been called'); break; default: throw new QCallerException('FormStatus is in an unknown status'); } // Update FormStatus and Clear Included JS/CSS list $this->intFormStatus = QFormBase::FormStatusRenderBegun; $this->strIncludedJavaScriptFileArray = array(); $this->strIncludedStyleSheetFileArray = array(); // Figure out initial list of JavaScriptIncludes $strJavaScriptArray = $this->ProcessJavaScriptList('_core/qcodo.js, _core/logger.js, _core/event.js, _core/post.js, _core/control.js'); if (!$strJavaScriptArray) { $strJavaScriptArray = array(); } // Figure out initial list of StyleSheet includes $strStyleSheetArray = array(); // Iterate through the form's ControlArray to Define FormAttributes and additional JavaScriptIncludes $this->strFormAttributeArray = array(); foreach ($this->GetAllControls() as $objControl) { // Include any JavaScripts? The control would have a // comma-delimited list of javascript files to include (if applicable) if ($strScriptArray = $this->ProcessJavaScriptList($objControl->JavaScripts)) { $strJavaScriptArray = array_merge($strJavaScriptArray, $strScriptArray); } // Include any StyleSheets? The control would have a // comma-delimited list of stylesheet files to include (if applicable) if ($strScriptArray = $this->ProcessStyleSheetList($objControl->StyleSheets)) { $strStyleSheetArray = array_merge($strStyleSheetArray, $strScriptArray); } // Form Attributes? if ($objControl->FormAttributes) { $this->strFormAttributeArray = array_merge($this->strFormAttributeArray, $objControl->FormAttributes); } } // Create $strFormAttributes $strFormAttributes = ''; foreach ($this->strFormAttributeArray as $strKey => $strValue) { $strFormAttributes .= sprintf(' %s="%s"', $strKey, $strValue); } QApplicationBase::$ProcessOutput = false; $strOutputtedText = strtolower(trim(ob_get_contents())); if (strpos($strOutputtedText, '<body') === false) { $strToReturn = '<body>'; $this->blnRenderedBodyTag = true; } else { $strToReturn = ''; } QApplicationBase::$ProcessOutput = true; if ($this->strCssClass) { $strFormAttributes .= ' class="' . $this->strCssClass . '"'; } // Setup Rendered HTML $strToReturn .= sprintf('<form method="post" id="%s" action="%s"%s>', $this->strFormId, QApplication::$RequestUri, $strFormAttributes); $strToReturn .= "\r\n"; // Include javascripts that need to be included foreach ($strJavaScriptArray as $strScript) { $strToReturn .= sprintf('<script type="text/javascript" src="%s/%s"></script>', __VIRTUAL_DIRECTORY__ . __JS_ASSETS__, $strScript); $strToReturn .= "\r\n"; } // Include styles that need to be included foreach ($strStyleSheetArray as $strScript) { $strToReturn .= sprintf('<style type="text/css" media="all">@import "%s/%s";</style>', __VIRTUAL_DIRECTORY__ . __CSS_ASSETS__, $strScript); $strToReturn .= "\r\n"; } // Perhaps a strFormModifiers as an array to // allow controls to update other parts of the form, like enctype, onsubmit, etc. // Return or Display if ($blnDisplayOutput) { print $strToReturn; return null; } else { return $strToReturn; } }
/** * Initializes the QForm rendering process * @param bool $blnDisplayOutput Whether the output is to be printed (true) or simply returned (false) * * @return null|string * @throws QCallerException */ public function RenderBegin($blnDisplayOutput = true) { // Ensure that RenderBegin() has not yet been called switch ($this->intFormStatus) { case QFormBase::FormStatusUnrendered: break; case QFormBase::FormStatusRenderBegun: case QFormBase::FormStatusRenderEnded: throw new QCallerException('$this->RenderBegin() has already been called'); break; default: throw new QCallerException('FormStatus is in an unknown status'); } // Update FormStatus and Clear Included JS/CSS list $this->intFormStatus = QFormBase::FormStatusRenderBegun; $this->strIncludedStyleSheetFileArray = array(); // Figure out initial list of StyleSheet includes $strStyleSheetArray = array(); // Iterate through the form's ControlArray to Define FormAttributes and additional JavaScriptIncludes $this->strFormAttributeArray = array(); foreach ($this->GetAllControls() as $objControl) { // Include any StyleSheets? The control would have a // comma-delimited list of stylesheet files to include (if applicable) if ($strScriptArray = $this->ProcessStyleSheetList($objControl->StyleSheets)) { $strStyleSheetArray = array_merge($strStyleSheetArray, $strScriptArray); } // Form Attributes? if ($objControl->FormAttributes) { $this->strFormAttributeArray = array_merge($this->strFormAttributeArray, $objControl->FormAttributes); } } if (is_array($this->strCustomAttributeArray)) { $this->strFormAttributeArray = array_merge($this->strFormAttributeArray, $this->strCustomAttributeArray); } // Create $strFormAttributes $strFormAttributes = ''; foreach ($this->strFormAttributeArray as $strKey => $strValue) { $strFormAttributes .= sprintf(' %s="%s"', $strKey, $strValue); } QApplicationBase::$ProcessOutput = false; $strOutputtedText = strtolower(trim(ob_get_contents())); if (strpos($strOutputtedText, '<body') === false) { $strToReturn = '<body>'; $this->blnRenderedBodyTag = true; } else { $strToReturn = ''; } QApplicationBase::$ProcessOutput = true; if ($this->strCssClass) { $strFormAttributes .= ' class="' . $this->strCssClass . '"'; } // Setup Rendered HTML $strToReturn .= sprintf('<form method="post" id="%s" action="%s"%s>', $this->strFormId, htmlentities(QApplication::$RequestUri), $strFormAttributes); $strToReturn .= "\r\n"; // In order to make ui-themes workable, move the jquery.css to the end of list. // It should override any rules that it can override. foreach ($strStyleSheetArray as $strScript) { if (__JQUERY_CSS__ == $strScript) { unset($strStyleSheetArray[$strScript]); $strStyleSheetArray[$strScript] = $strScript; break; } } // Include styles that need to be included foreach ($strStyleSheetArray as $strScript) { $strToReturn .= sprintf('<style type="text/css" media="all">@import "%s";</style>', $this->GetCssFileUri($strScript)); $strToReturn .= "\r\n"; } // Perhaps a strFormModifiers as an array to // allow controls to update other parts of the form, like enctype, onsubmit, etc. // Return or Display if ($blnDisplayOutput) { if (!QApplication::$CliMode) { print $strToReturn; } return null; } else { if (!QApplication::$CliMode) { return $strToReturn; } else { return ''; } } }