protected function RenderEnd($blnDisplayOutput = true)
 {
     // Ensure that RenderEnd() has not yet been called
     switch ($this->intFormStatus) {
         case QFormBase::FormStatusUnrendered:
             throw new QCallerException('$this->RenderBegin() was never called');
         case QFormBase::FormStatusRenderBegun:
             break;
         case QFormBase::FormStatusRenderEnded:
             throw new QCallerException('$this->RenderEnd() has already been called');
             break;
         default:
             throw new QCallerException('FormStatus is in an unknown status');
     }
     // Setup End Script
     $strEndScript = '';
     // First, call regC on all Controls
     $strControlIdToRegister = array();
     foreach ($this->GetAllControls() as $objControl) {
         if ($objControl->Rendered) {
             array_push($strControlIdToRegister, '"' . $objControl->ControlId . '"');
         }
     }
     if (count($strControlIdToRegister)) {
         $strEndScript .= sprintf('qc.regCA(new Array(%s)); ', implode(',', $strControlIdToRegister));
     }
     // Next, run any GetEndScrips on Controls and Groupings
     foreach ($this->GetAllControls() as $objControl) {
         if ($objControl->Rendered) {
             $strEndScript .= $objControl->GetEndScript();
         }
     }
     foreach ($this->objGroupingArray as $objGrouping) {
         $strEndScript .= $objGrouping->Render();
     }
     // Run End Script Compressor
     $strEndScriptArray = explode('; ', $strEndScript);
     $strEndScriptCommands = array();
     foreach ($strEndScriptArray as $strEndScript) {
         $strEndScriptCommands[trim($strEndScript)] = true;
     }
     $strEndScript = implode('; ', array_keys($strEndScriptCommands));
     // Finally, add any application level js commands
     $strEndScript .= QApplication::RenderJavaScript(false);
     // Next, go through all controls and gather up any JS or CSS to run or Form Attributes to modify
     // due to dynamically created controls
     $strJavaScriptToAddArray = array();
     $strStyleSheetToAddArray = array();
     $strFormAttributeToModifyArray = 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)) {
             $strJavaScriptToAddArray = array_merge($strJavaScriptToAddArray, $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)) {
             $strStyleSheetToAddArray = array_merge($strStyleSheetArray, $strScriptArray);
         }
         // Form Attributes?
         if ($objControl->FormAttributes) {
             foreach ($objControl->FormAttributes as $strKey => $strValue) {
                 if (!array_key_exists($strKey, $this->strFormAttributeArray)) {
                     $this->strFormAttributeArray[$strKey] = $strValue;
                     $strFormAttributeToModifyArray[$strKey] = $strValue;
                 } else {
                     if ($this->strFormAttributeArray[$strKey] != $strValue) {
                         $this->strFormAttributeArray[$strKey] = $strValue;
                         $strFormAttributeToModifyArray[$strKey] = $strValue;
                     }
                 }
             }
         }
     }
     // Finally, render the JS Commands to Execute
     // First, alter any <Form> settings that need to be altered
     foreach ($strFormAttributeToModifyArray as $strKey => $strValue) {
         $strEndScript .= sprintf('document.getElementById("%s").%s = "%s"; ', $this->strFormId, $strKey, $strValue);
     }
     // Next, add any new CSS files that haven't yet been included to the end of the High Priority commands string
     foreach ($strStyleSheetToAddArray as $strScript) {
         $strEndScript .= 'qc.loadStyleSheetFile("' . $strScript . '", "all"); ';
     }
     // Next, add any new JS files that haven't yet been included to the BEGINNING of the High Priority commands string
     // (already rendered HP commands up to this point will be placed into the callback)
     foreach ($strJavaScriptToAddArray as $strScript) {
         if ($strEndScript) {
             $strEndScript = 'qc.loadJavaScriptFile("' . $strScript . '", function() {' . $strEndScript . '}); ';
         } else {
             $strEndScript = 'qc.loadJavaScriptFile("' . $strScript . '", null); ';
         }
     }
     // Finally, add qcodo includes path
     $strEndScript = sprintf('qc.jsAssets = "%s"; ', __VIRTUAL_DIRECTORY__ . __JS_ASSETS__) . $strEndScript;
     $strEndScript = sprintf('qc.phpAssets = "%s"; ', __VIRTUAL_DIRECTORY__ . __PHP_ASSETS__) . $strEndScript;
     $strEndScript = sprintf('qc.cssAssets = "%s"; ', __VIRTUAL_DIRECTORY__ . __CSS_ASSETS__) . $strEndScript;
     $strEndScript = sprintf('qc.imageAssets = "%s"; ', __VIRTUAL_DIRECTORY__ . __IMAGE_ASSETS__) . $strEndScript;
     // Create Final EndScript Script
     $strEndScript = sprintf('<script type="text/javascript">qc.registerForm(); %s</script>', $strEndScript);
     // Persist Controls (if applicable)
     foreach ($this->objPersistentControlArray as $objControl) {
         $objControl->Persist();
     }
     // Clone Myself
     $objForm = clone $this;
     // Render HTML
     $strToReturn = "\r\n<div style=\"display: none;\">\r\n\t";
     $strToReturn .= sprintf('<input type="hidden" name="Qform__FormState" id="Qform__FormState" value="%s" />', QForm::Serialize($objForm));
     $strToReturn .= "\r\n\t";
     $strToReturn .= sprintf('<input type="hidden" name="Qform__FormId" id="Qform__FormId" value="%s" />', $this->strFormId);
     $strToReturn .= "\r\n</div>\r\n";
     // The Following "Hidden Form Variables" are no longer explicitly rendered in HTML, but are now
     // added to the DOM by the Qcodo JavaScript Library method qc.initialize():
     // * Qform__FormControl
     // * Qform__FormEvent
     // * Qform__FormParameter
     // * Qform__FormCallType
     // * Qform__FormUpdates
     // * Qform__FormCheckableControls
     foreach ($this->GetAllControls() as $objControl) {
         if ($objControl->Rendered) {
             $strToReturn .= $objControl->GetEndHtml();
         }
     }
     $strToReturn .= "\n</form>";
     $strToReturn .= $strEndScript;
     if ($this->blnRenderedBodyTag) {
         $strToReturn .= '</body>';
     }
     // Update Form Status
     $this->intFormStatus = QFormBase::FormStatusRenderEnded;
     // Display or Return
     if ($blnDisplayOutput) {
         print $strToReturn;
         return null;
     } else {
         return $strToReturn;
     }
 }
 /**
  * @param bool $blnDisplayOutput should the output be returned or directly printed to screen.
  *
  * @return null|string
  * @throws QCallerException
  */
 public function RenderEnd($blnDisplayOutput = true)
 {
     // Ensure that RenderEnd() has not yet been called
     switch ($this->intFormStatus) {
         case QFormBase::FormStatusUnrendered:
             throw new QCallerException('$this->RenderBegin() was never called');
         case QFormBase::FormStatusRenderBegun:
             break;
         case QFormBase::FormStatusRenderEnded:
             throw new QCallerException('$this->RenderEnd() has already been called');
             break;
         default:
             throw new QCallerException('FormStatus is in an unknown status');
     }
     //Clear included javascript array
     $this->strIncludedJavaScriptFileArray = array();
     // Setup End Script
     $strEndScript = '';
     $strEvents = '';
     // First, call regC on all Controls
     $strControlIdToRegister = array();
     foreach ($this->GetAllControls() as $objControl) {
         if ($objControl->Rendered) {
             array_push($strControlIdToRegister, '"' . $objControl->ControlId . '"');
         }
     }
     if (count($strControlIdToRegister)) {
         $strEndScript .= sprintf('qc.regCA(new Array(%s)); ', implode(',', $strControlIdToRegister));
     }
     // Next, run any GetEndScrips on Controls and Groupings
     foreach ($this->GetAllControls() as $objControl) {
         if ($objControl->Rendered) {
             $strControlScript = $objControl->GetEndScript();
             if (strlen($strControlScript) > 0) {
                 $strEvents .= $strControlScript . ";\n";
             }
         }
     }
     foreach ($this->objGroupingArray as $objGrouping) {
         $strGroupingScript = $objGrouping->Render();
         if (strlen($strGroupingScript) > 0) {
             $strEvents .= $strGroupingScript . ";\n";
         }
     }
     // Run End Script Compressor
     $strEndScriptArray = explode(";\n", $strEndScript);
     $strEndScriptCommands = array();
     foreach ($strEndScriptArray as $strEndScript) {
         $strEndScriptCommands[trim($strEndScript)] = true;
     }
     $strEndScript = implode(";\n", array_keys($strEndScriptCommands));
     // Next, go through all controls and gather up any JS or CSS to run or Form Attributes to modify
     // due to dynamically created controls
     $strJavaScriptToAddArray = array();
     $strStyleSheetToAddArray = array();
     $strFormAttributeToModifyArray = 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)) {
             $strJavaScriptToAddArray = array_merge($strJavaScriptToAddArray, $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)) {
             $strStyleSheetToAddArray = array_merge($strStyleSheetToAddArray, $strScriptArray);
         }
         // Form Attributes?
         if ($objControl->FormAttributes) {
             foreach ($objControl->FormAttributes as $strKey => $strValue) {
                 if (!array_key_exists($strKey, $this->strFormAttributeArray)) {
                     $this->strFormAttributeArray[$strKey] = $strValue;
                     $strFormAttributeToModifyArray[$strKey] = $strValue;
                 } else {
                     if ($this->strFormAttributeArray[$strKey] != $strValue) {
                         $this->strFormAttributeArray[$strKey] = $strValue;
                         $strFormAttributeToModifyArray[$strKey] = $strValue;
                     }
                 }
             }
         }
     }
     // Figure out initial list of JavaScriptIncludes
     $strJavaScriptArray = $this->ProcessJavaScriptList(__JQUERY_BASE__ . ', ' . __JQUERY_EFFECTS__ . ',jquery/jquery.ajaxq-0.0.1.js,' . __QCUBED_JS_CORE__);
     if (defined('__PRELOAD_JS_FILES__') && __PRELOAD_JS_FILES__) {
         $strJavaScriptArray = array_merge($strJavaScriptArray, $strJavaScriptToAddArray);
         $strJavaScriptToAddArray = array();
     }
     // Setup IncludeJs
     $strToReturn = "\r\n";
     // Include javascripts that need to be included
     foreach ($strJavaScriptArray as $strScript) {
         $strToReturn .= sprintf('<script type="text/javascript" src="%s"></script>', $this->GetJsFileUri($strScript));
         $strToReturn .= "\r\n";
     }
     // First, alter any <Form> settings that need to be altered
     foreach ($strFormAttributeToModifyArray as $strKey => $strValue) {
         $strEndScript .= sprintf('document.getElementById("%s").%s = "%s"; ', $this->strFormId, $strKey, $strValue);
     }
     // Next, add any new CSS files that haven't yet been included to the end of the High Priority commands string
     foreach ($strStyleSheetToAddArray as $strScript) {
         $strEndScript .= 'qc.loadStyleSheetFile("' . $strScript . '", "all"); ';
     }
     if ($strEvents) {
         // qc.regCA first, $strEvents 2nd, application scripts 3rd
         $strEndScript = $strEndScript . ';' . $strEvents;
     }
     // Add any application level js commands. These might refer to previous objects.
     $strEndScript .= QApplication::RenderJavaScript(false);
     // Next, add any new JS files that haven't yet been included to the BEGINNING of the High Priority commands string
     // (already rendered HP commands up to this point will be placed into the callback)
     foreach (array_reverse($strJavaScriptToAddArray) as $strScript) {
         if ($strEndScript) {
             $strEndScript = 'qc.loadJavaScriptFile("' . $strScript . '", function() {' . $strEndScript . '}); ';
         } else {
             $strEndScript = 'qc.loadJavaScriptFile("' . $strScript . '", null); ';
         }
     }
     // Finally, add QCubed includes path
     $strEndScript = sprintf('qc.baseDir = "%s"; ', __VIRTUAL_DIRECTORY__) . $strEndScript;
     $strEndScript = sprintf('qc.jsAssets = "%s"; ', __VIRTUAL_DIRECTORY__ . __JS_ASSETS__) . $strEndScript;
     $strEndScript = sprintf('qc.phpAssets = "%s"; ', __VIRTUAL_DIRECTORY__ . __PHP_ASSETS__) . $strEndScript;
     $strEndScript = sprintf('qc.cssAssets = "%s"; ', __VIRTUAL_DIRECTORY__ . __CSS_ASSETS__) . $strEndScript;
     $strEndScript = sprintf('qc.imageAssets = "%s"; ', __VIRTUAL_DIRECTORY__ . __IMAGE_ASSETS__) . $strEndScript;
     // Create Final EndScript Script
     $strEndScript = sprintf('<script type="text/javascript">$j(document).ready(function() { %s; });</script>', $strEndScript);
     // Persist Controls (if applicable)
     foreach ($this->objPersistentControlArray as $objControl) {
         $objControl->Persist();
     }
     // Clone Myself
     $objForm = clone $this;
     // Render HTML
     $strToReturn .= "\r\n<div style=\"display: none;\">\r\n\t";
     $strToReturn .= sprintf('<input type="hidden" name="Qform__FormState" id="Qform__FormState" value="%s" />', QForm::Serialize($objForm));
     $strToReturn .= "\r\n\t";
     $strToReturn .= sprintf('<input type="hidden" name="Qform__FormId" id="Qform__FormId" value="%s" />', $this->strFormId);
     $strToReturn .= "\r\n</div>\r\n";
     $strToReturn .= sprintf('<input type="hidden" name="Qform__FormControl" id="Qform__FormControl" value="" />');
     $strToReturn .= sprintf('<input type="hidden" name="Qform__FormEvent" id="Qform__FormEvent" value="" />');
     $strToReturn .= sprintf('<input type="hidden" name="Qform__FormParameter" id="Qform__FormParameter" value="" />');
     $strToReturn .= sprintf('<input type="hidden" name="Qform__FormCallType" id="Qform__FormCallType" value="" />');
     $strToReturn .= sprintf('<input type="hidden" name="Qform__FormUpdates" id="Qform__FormUpdates" value="" />');
     $strToReturn .= sprintf('<input type="hidden" name="Qform__FormCheckableControls" id="Qform__FormCheckableControls" value="" />');
     foreach ($this->GetAllControls() as $objControl) {
         if ($objControl->Rendered) {
             $strToReturn .= $objControl->GetEndHtml();
         }
     }
     $strToReturn .= "\n</form>";
     $strToReturn .= $strEndScript;
     if ($this->blnRenderedBodyTag) {
         $strToReturn .= '</body>';
     }
     // Update Form Status
     $this->intFormStatus = QFormBase::FormStatusRenderEnded;
     // Display or Return
     if ($blnDisplayOutput) {
         if (!QApplication::$CliMode) {
             print $strToReturn;
         }
         return null;
     } else {
         if (!QApplication::$CliMode) {
             return $strToReturn;
         } else {
             return '';
         }
     }
 }
    /**
     * Renders the end of the form, including the closing form and body tags.
     * Renders the html for hidden controls.
     * @param bool $blnDisplayOutput should the output be returned or directly printed to screen.
     *
     * @return null|string
     * @throws QCallerException
     */
    public function RenderEnd($blnDisplayOutput = true)
    {
        // Ensure that RenderEnd() has not yet been called
        switch ($this->intFormStatus) {
            case QFormBase::FormStatusUnrendered:
                throw new QCallerException('$this->RenderBegin() was never called');
            case QFormBase::FormStatusRenderBegun:
                break;
            case QFormBase::FormStatusRenderEnded:
                throw new QCallerException('$this->RenderEnd() has already been called');
                break;
            default:
                throw new QCallerException('FormStatus is in an unknown status');
        }
        $strHtml = '';
        // This will be the final output
        /**** Render any controls that get automatically rendered ****/
        foreach ($this->GetAllControls() as $objControl) {
            if ($objControl->AutoRender && !$objControl->Rendered) {
                $strRenderMethod = $objControl->PreferredRenderMethod;
                $strHtml .= $objControl->{$strRenderMethod}(false) . _nl();
            }
        }
        /**** Prepare Javascripts ****/
        // Clear included javascript array since we are completely redrawing the page
        $this->strIncludedJavaScriptFileArray = array();
        $strControlIdToRegister = array();
        $strEventScripts = '';
        // Add form level javascripts and libraries
        $strJavaScriptArray = $this->ProcessJavaScriptList($this->GetFormJavaScripts());
        QApplication::AddJavaScriptFiles($strJavaScriptArray);
        $strFormJsFiles = QApplication::RenderFiles();
        // Render the form-level javascript files separately
        // Go through all controls and gather up any JS or CSS to run or Form Attributes to modify
        foreach ($this->GetAllControls() as $objControl) {
            if ($objControl->Rendered || $objControl->ScriptsOnly) {
                $strControlIdToRegister[] = $objControl->ControlId;
                /* Note: GetEndScript may cause the control to register additional commands, or even add javascripts, so those should be handled after this. */
                if ($strControlScript = $objControl->GetEndScript()) {
                    $strControlScript = JavaScriptHelper::TerminateScript($strControlScript);
                    // Add comments for developer version of output
                    if (!QApplication::$Minimize) {
                        // Render a comment
                        $strControlScript = _nl() . _nl() . sprintf('/*** EndScript -- Control Type: %s, Control Name: %s, Control Id: %s  ***/', get_class($objControl), $objControl->Name, $objControl->ControlId) . _nl() . _indent($strControlScript);
                    }
                    $strEventScripts .= $strControlScript;
                }
            }
            // Include the javascripts specified by each control.
            if ($strScriptArray = $this->ProcessJavaScriptList($objControl->JavaScripts)) {
                QApplication::AddJavaScriptFiles($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)) {
                QApplication::AddStyleSheets(array_keys($strScriptArray));
            }
            // Form Attributes?
            if ($objControl->FormAttributes) {
                QApplication::ExecuteControlCommand($this->strFormId, 'attr', $objControl->FormAttributes);
                foreach ($objControl->FormAttributes as $strKey => $strValue) {
                    if (!array_key_exists($strKey, $this->strFormAttributeArray)) {
                        $this->strFormAttributeArray[$strKey] = $strValue;
                    } else {
                        if ($this->strFormAttributeArray[$strKey] != $strValue) {
                            $this->strFormAttributeArray[$strKey] = $strValue;
                        }
                    }
                }
            }
        }
        // Add grouping commands to events (Used for deprecated drag and drop, but not removed yet)
        foreach ($this->objGroupingArray as $objGrouping) {
            $strGroupingScript = $objGrouping->Render();
            if (strlen($strGroupingScript) > 0) {
                $strGroupingScript = JavaScriptHelper::TerminateScript($strGroupingScript);
                $strEventScripts .= $strGroupingScript;
            }
        }
        /*** Build the javascript block ****/
        // Start with variable settings and initForm
        $strEndScript = sprintf('qc.initForm("%s"); ', $this->strFormId);
        // Register controls
        if ($strControlIdToRegister) {
            $strEndScript .= sprintf("qc.regCA(%s); \n", JavaScriptHelper::toJsObject($strControlIdToRegister));
        }
        // Design mode event
        if (defined('__DESIGN_MODE__') && __DESIGN_MODE__ == 1) {
            // attach an event listener to the form to send context menu selections to the designer dialog for processing
            $strEndScript .= sprintf('$j("#%s").on("contextmenu", "[id]", 
						function(event) {
							$j("#qconnectoreditdlg").trigger("qdesignerclick", 
								[{id: event.target.id ? event.target.id : $j(event.target).parents("[id]").attr("id"), for: $j(event.target).attr("for")}]
							);
							return false;
						}
					);', $this->FormId);
        }
        // Add any application level js commands.
        // This will include high and medimum level commands
        $strEndScript .= QApplication::RenderJavascript(true);
        // Add the javascript coming from controls and events just after the medium level commands
        $strEndScript .= ';' . $strEventScripts;
        // Add low level commands and other things that need to execute at the end
        $strEndScript .= ';' . QApplication::RenderJavascript(false);
        // Create Final EndScript Script
        $strEndScript = sprintf('<script type="text/javascript">$j(document).ready(function() { %s; });</script>', $strEndScript);
        /**** Render the HTML itself, appending the javascript we generated above ****/
        foreach ($this->GetAllControls() as $objControl) {
            if ($objControl->Rendered) {
                $strHtml .= $objControl->GetEndHtml();
            }
            $objControl->ResetFlags();
            // Make sure controls are serialized in a reset state
        }
        $strHtml .= $strFormJsFiles . _nl();
        // Add form level javascript files
        // put javascript environment defines up early for use by other js files.
        $strHtml .= '<script type="text/javascript">' . sprintf('qc.baseDir = "%s"; ', __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__) . sprintf('qc.jsAssets = "%s"; ', __VIRTUAL_DIRECTORY__ . __JS_ASSETS__) . sprintf('qc.phpAssets = "%s"; ', __VIRTUAL_DIRECTORY__ . __PHP_ASSETS__) . sprintf('qc.cssAssets = "%s"; ', __VIRTUAL_DIRECTORY__ . __CSS_ASSETS__) . sprintf('qc.imageAssets = "%s"; ', __VIRTUAL_DIRECTORY__ . __IMAGE_ASSETS__) . '</script>' . _nl();
        $strHtml .= QApplication::RenderFiles() . _nl();
        // add plugin and control js files
        // Render hidden controls related to the form
        $strHtml .= sprintf('<input type="hidden" name="Qform__FormId" id="Qform__FormId" value="%s" />', $this->strFormId) . _nl();
        $strHtml .= sprintf('<input type="hidden" name="Qform__FormControl" id="Qform__FormControl" value="" />') . _nl();
        $strHtml .= sprintf('<input type="hidden" name="Qform__FormEvent" id="Qform__FormEvent" value="" />') . _nl();
        $strHtml .= sprintf('<input type="hidden" name="Qform__FormParameter" id="Qform__FormParameter" value="" />') . _nl();
        $strHtml .= sprintf('<input type="hidden" name="Qform__FormCallType" id="Qform__FormCallType" value="" />') . _nl();
        $strHtml .= sprintf('<input type="hidden" name="Qform__FormUpdates" id="Qform__FormUpdates" value="" />') . _nl();
        $strHtml .= sprintf('<input type="hidden" name="Qform__FormCheckableControls" id="Qform__FormCheckableControls" value="" />') . _nl();
        // Serialize and write out the formstate
        $strHtml .= sprintf('<input type="hidden" name="Qform__FormState" id="Qform__FormState" value="%s" />', QForm::Serialize(clone $this)) . _nl();
        // close the form tag
        $strHtml .= "</form>";
        // Add the JavaScripts rendered above
        $strHtml .= $strEndScript;
        // close the body tag
        if ($this->blnRenderedBodyTag) {
            $strHtml .= '</body>';
        }
        /**** Cleanup ****/
        // Update Form Status
        $this->intFormStatus = QFormBase::FormStatusRenderEnded;
        // Display or Return
        if ($blnDisplayOutput) {
            if (!QApplication::$CliMode) {
                print $strHtml;
            }
            return null;
        } else {
            if (!QApplication::$CliMode) {
                return $strHtml;
            } else {
                return '';
            }
        }
    }
Exemple #4
0
 protected function RenderEnd($blnDisplayOutput = true)
 {
     // Ensure that RenderEnd() has not yet been called
     switch ($this->intFormStatus) {
         case QFormBase::FormStatusUnrendered:
             throw new QCallerException('$this->RenderBegin() was never called');
         case QFormBase::FormStatusRenderBegun:
             break;
         case QFormBase::FormStatusRenderEnded:
             throw new QCallerException('$this->RenderEnd() has already been called');
             break;
         default:
             throw new QCallerException('FormStatus is in an unknown status');
     }
     // Get End Script
     $strEndScript = '';
     // First, regC on all Controls
     $strControlIdToRegister = array();
     foreach ($this->GetAllControls() as $objControl) {
         if ($objControl->Rendered) {
             array_push($strControlIdToRegister, '"' . $objControl->ControlId . '"');
         }
     }
     if (count($strControlIdToRegister)) {
         $strEndScript = sprintf('qc.regCA(new Array(%s)); ', implode(',', $strControlIdToRegister));
     }
     // Next, run any GetEndScrips on Controls and Groupings
     foreach ($this->GetAllControls() as $objControl) {
         if ($objControl->Rendered) {
             $strEndScript .= $objControl->GetEndScript();
         }
     }
     foreach ($this->objGroupingArray as $objGrouping) {
         $strEndScript .= $objGrouping->Render();
     }
     // Run End Script Compressor
     $strEndScriptArray = explode('; ', $strEndScript);
     $strEndScriptCommands = array();
     foreach ($strEndScriptArray as $strEndScript) {
         $strEndScriptCommands[trim($strEndScript)] = true;
     }
     $strEndScript = implode('; ', array_keys($strEndScriptCommands));
     // Next, add qcodo includes path
     $strEndScript .= sprintf('qc.jsAssets = "%s"; ', __VIRTUAL_DIRECTORY__ . __JS_ASSETS__);
     $strEndScript .= sprintf('qc.phpAssets = "%s"; ', __VIRTUAL_DIRECTORY__ . __PHP_ASSETS__);
     $strEndScript .= sprintf('qc.cssAssets = "%s"; ', __VIRTUAL_DIRECTORY__ . __CSS_ASSETS__);
     $strEndScript .= sprintf('qc.imageAssets = "%s"; ', __VIRTUAL_DIRECTORY__ . __IMAGE_ASSETS__);
     // Finally, add any application level js commands
     $strEndScript .= QApplication::RenderJavaScript(false);
     // Create Final EndScript Script
     $strEndScript = sprintf('<script type="text/javascript">qc.registerForm(); %s</script>', $strEndScript);
     // Clone Myself
     $objForm = clone $this;
     // Render HTML
     $strToReturn = "\r\n<div>\r\n\t";
     $strToReturn .= sprintf('<input type="hidden" name="Qform__FormState" id="Qform__FormState" value="%s" />', QForm::Serialize($objForm));
     $strToReturn .= "\r\n\t";
     $strToReturn .= sprintf('<input type="hidden" name="Qform__FormId" id="Qform__FormId" value="%s" />', $this->strFormId);
     $strToReturn .= "\r\n</div>\r\n";
     //			$strToReturn .= "\n\t";
     //			$strToReturn .= '<input type="hidden" name="Qform__FormControl" id="Qform__FormControl" value="" />';
     //			$strToReturn .= '<input type="hidden" name="Qform__FormEvent" id="Qform__FormEvent" value="" />';
     //			$strToReturn .= '<input type="hidden" name="Qform__FormParameter" id="Qform__FormParameter" value="" />';
     //			$strToReturn .= '<input type="hidden" name="Qform__FormCallType" id="Qform__FormCallType" value="" />';
     //			$strToReturn .= '<input type="hidden" name="Qform__FormUpdates" id="Qform__FormUpdates" value="" />';
     //			$strToReturn .= '<input type="hidden" name="Qform__FormCheckableControls" id="Qform__FormCheckableControls" value="" />';
     /*			$strToReturn .= '<div id="Qform_Logger" style="display:none;width:400px;background-color:#dddddd;font-size:10px;font-family:lucida console, courier, monospaced;padding:6px;';
     			if (QApplication::IsBrowser(QBrowserType::InternetExplorer))
     				$strToReturn .= 'filter:alpha(opacity=50);';
     			else
     				$strToReturn .= 'opacity:0.5;';
     			$strToReturn .= 'overflow:auto;"></div>';*/
     foreach ($this->GetAllControls() as $objControl) {
         if ($objControl->Rendered) {
             $strToReturn .= $objControl->GetEndHtml();
         }
     }
     $strToReturn .= "\n</form>";
     $strToReturn .= $strEndScript;
     if ($this->blnRenderedBodyTag) {
         $strToReturn .= '</body>';
     }
     // Update Form Status
     $this->intFormStatus = QFormBase::FormStatusRenderEnded;
     // Display or Return
     if ($blnDisplayOutput) {
         print $strToReturn;
         return null;
     } else {
         return $strToReturn;
     }
 }