public function Render($blnPrint = true, $blnRenderAsAjax = false) { //Render Actions first if applicable $strRendered = parent::Render(); if (!$blnRenderAsAjax) { $strText = $this->strText; } else { $strText = QString::XmlEscape(trim($this->strText)); } $strRendered .= sprintf("<a id='%s' name='%s' %s>%s</a>", $this->strControlId, $this->strControlId, $this->GetAttrString(), $strText); if ($blnPrint) { _p($strRendered, false); } else { return $strRendered; } }
public function Render($blnPrint = true, $blnRenderAsAjax = false) { if ($blnRenderAsAjax) { $strElementOverride = 'control'; $this->Attr('transition', $this->strTransition); } else { $strElementOverride = 'div'; } $strRendered = parent::Render(); $strHeader = sprintf("<%s id='%s' name='%s' %s>\n", $strElementOverride, $this->strControlId, $this->strControlId, $this->GetAttrString()); //If template is set render template if (!is_null($this->strTemplate)) { if (!file_exists($this->strTemplate)) { throw new QCallerException("Template file (" . $this->strTemplate . ") does not exist"); } global $_CONTROL; $objPrevControl = $_CONTROL; $_CONTROL = $this; $_FORM = $this->objForm; $strRendered .= $this->objForm->EvaluateTemplate($this->strTemplate); $_CONTROL = $objPrevControl; } //Render Text $strRendered .= $this->strText; //Check/Do autorender children if ($this->blnAutoRenderChildren) { foreach ($this->arrChildControls as $objChildControl) { $strRendered .= $objChildControl->Render(false); } } $strFooter = sprintf("</%s>", $strElementOverride); if (!$blnRenderAsAjax) { $strRendered = $strHeader . $strRendered . $strFooter; } else { $strRendered = $strHeader . QString::XmlEscape(trim($strRendered)) . $strFooter; } $this->blnModified = false; if ($blnPrint) { _p($strRendered, false); } else { return $strRendered; } }
protected function RenderAjax() { // Update the Status $this->intFormStatus = QFormBase::FormStatusRenderBegun; // Create the Control collection $strToReturn = '<controls>'; // Include each control (if applicable) that has been changed/modified foreach ($this->GetAllControls() as $objControl) { if (!$objControl->ParentControl) { // $strToReturn .= $objControl->RenderAjax(false) . "\r\n"; $strToReturn .= $this->RenderAjaxHelper($objControl); } } // First, go through all controls and gather up any JS or CSS to run or Form Attributes to modify $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; } } } } } // Render the JS Commands to Execute $strCommands = ''; // First, get all controls that need to run regC $strControlIdToRegister = array(); foreach ($this->GetAllControls() as $objControl) { if ($objControl->Rendered) { array_push($strControlIdToRegister, '"' . $objControl->ControlId . '"'); } } if (count($strControlIdToRegister)) { $strCommands .= sprintf('qc.regCA(new Array(%s)); ', implode(',', $strControlIdToRegister)); } // Next, go through all controls and groupings for their GetEndScripts foreach ($this->GetAllControls() as $objControl) { if ($objControl->Rendered) { $strJavaScript = $objControl->GetEndScript(); if (trim($strJavaScript)) { $strCommands .= trim($strJavaScript); } } } foreach ($this->objGroupingArray as $objGrouping) { $strRender = $objGrouping->Render(); if (trim($strRender)) { $strCommands .= trim($strRender); } } // Next, look to the Application object for any commands to run $strCommands .= QApplication::RenderJavaScript(false); // Finally, bring in "high priority commands" // First, alter any <Form> settings that need to be altered foreach ($strFormAttributeToModifyArray as $strKey => $strValue) { $strCommands = sprintf('document.getElementById("%s").%s = "%s"; ', $this->strFormId, $strKey, $strValue) . $strCommands; } // 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) { $strCommands = 'qc.loadStyleSheetFile("' . $strScript . '", "all"); ' . $strCommands; } // 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 ($strCommands) { $strCommands = 'qc.loadJavaScriptFile("' . $strScript . '", function() {' . $strCommands . '}); '; } else { $strCommands = 'qc.loadJavaScriptFile("' . $strScript . '", null); '; } } // Set Up the Command Node if (trim($strCommands)) { $strCommands = '<command>' . QString::XmlEscape(trim($strCommands)) . '</command>'; } // Persist Controls (if applicable) foreach ($this->objPersistentControlArray as $objControl) { $objControl->Persist(); } // Add in the form state $strFormState = QForm::Serialize($this); $strToReturn .= sprintf('<control id="Qform__FormState">%s</control>', $strFormState); // close Control collection, Open the Command collection $strToReturn .= '</controls><commands>'; $strToReturn .= $strCommands; // close Command collection $strToReturn .= '</commands>'; $strContents = trim(ob_get_contents()); if (strtolower(substr($strContents, 0, 5)) == 'debug') { } else { ob_clean(); // Response is in XML Format header('Content-Type: text/xml'); // Output it and update render state if (QApplication::$EncodingType) { printf("<?xml version=\"1.0\" encoding=\"%s\"?><response>%s</response>\r\n", QApplication::$EncodingType, $strToReturn); } else { printf("<?xml version=\"1.0\"?><response>%s</response>\r\n", $strToReturn); } } // Update Render State $this->intFormStatus = QFormBase::FormStatusRenderEnded; }
protected function RenderOutput($strOutput, $blnDisplayOutput, $blnForceAsBlockElement = false) { // First, let's mark this control as being rendered and is ON the Page $this->blnRendering = false; $this->blnRendered = true; $this->blnOnPage = true; // Determine whether or not $strOutput is considered a XHTML "Block" Element if ($blnForceAsBlockElement || $this->blnIsBlockElement) { $blnIsBlockElement = true; } else { $blnIsBlockElement = false; } // Check for Visibility if (!$this->blnVisible) { $strOutput = ''; } $strStyle = ''; if ($this->strPosition && $this->strPosition != QPosition::NotSet) { $strStyle .= sprintf('position:%s;', $this->strPosition); } if (!$this->blnDisplay) { $strStyle .= 'display:none;'; } else { if ($blnIsBlockElement) { $strStyle .= 'display:inline;'; } } if (strlen(trim($this->strLeft)) > 0) { $strLeft = null; try { $strLeft = QType::Cast($this->strLeft, QType::Integer); } catch (QInvalidCastException $objExc) { } if (is_null($strLeft)) { $strStyle .= sprintf('left:%s;', $this->strLeft); } else { $strStyle .= sprintf('left:%spx;', $this->strLeft); } } if (strlen(trim($this->strTop)) > 0) { $strTop = null; try { $strTop = QType::Cast($this->strTop, QType::Integer); } catch (QInvalidCastException $objExc) { } if (is_null($strTop)) { $strStyle .= sprintf('top:%s;', $this->strTop); } else { $strStyle .= sprintf('top:%spx;', $this->strTop); } } switch ($this->objForm->CallType) { case QCallType::Ajax: // If we have a ParentControl and the ParentControl has NOT been rendered, then output // as standard HTML if ($this->objParentControl && ($this->objParentControl->Rendered || $this->objParentControl->Rendering)) { if ($strStyle) { $strStyle = sprintf('style="%s"', $strStyle); } if ($blnIsBlockElement) { $strOutput = sprintf('<div id="%s_ctl" %s>%s</div>%s', $this->strControlId, $strStyle, $strOutput, $this->GetNonWrappedHtml()); } else { $strOutput = sprintf('<span id="%s_ctl" %s>%s</span>%s', $this->strControlId, $strStyle, $strOutput, $this->GetNonWrappedHtml()); } // $strOutput = sprintf('<ins id="%s_ctl" style="%stext-decoration:inherit;">%s</ins>%s', $this->strControlId, $strStyle, $strOutput, $this->GetNonWrappedHtml()); // $strOutput = sprintf('<q id="%s_ctl" style="%s">%s</q>%s', $this->strControlId, $strStyle, $strOutput, $this->GetNonWrappedHtml()); } else { // Otherwise, we are rendering as a top-level AJAX response // Surround Output HTML around CDATA tags $strOutput = QString::XmlEscape($strOutput); $strOutput = sprintf('<control id="%s">%s</control>', $this->strControlId, $strOutput); // QApplication::ExecuteJavaScript(sprintf('qcodo.registerControl("%s"); ', $this->strControlId), true); // QApplication::ExecuteJavaScript(sprintf('qc.regC("%s"); ', $this->strControlId), true); // $strScript = $this->GetEndScript(); // if ($strScript) // QApplication::ExecuteJavaScript($strScript); if ($this->blnWrapperModified && $this->blnVisible) { // QApplication::ExecuteJavaScript(sprintf('qcodo.getWrapper("%s").style.cssText = "%s"; ', $this->strControlId, $strStyle)); QApplication::ExecuteJavaScript(sprintf('qc.getW("%s").style.cssText = "%stext-decoration:inherit;"; ', $this->strControlId, $strStyle)); } } break; default: if ($strStyle) { $strStyle = sprintf('style="%s"', $strStyle); } // $strOutput = sprintf('<div id="%s_ctl" style="%s">%s</div>%s', $this->strControlId, $strStyle, $strOutput, $this->GetNonWrappedHtml()); // $strOutput = sprintf('<ins id="%s_ctl" style="%stext-decoration:inherit;">%s</ins>%s', $this->strControlId, $strStyle, $strOutput, $this->GetNonWrappedHtml()); if ($blnIsBlockElement) { $strOutput = sprintf('<div id="%s_ctl" %s>%s</div>%s', $this->strControlId, $strStyle, $strOutput, $this->GetNonWrappedHtml()); } else { $strOutput = sprintf('<span id="%s_ctl" %s>%s</span>%s', $this->strControlId, $strStyle, $strOutput, $this->GetNonWrappedHtml()); } break; } // Output or Return if ($blnDisplayOutput) { print $strOutput; } else { return $strOutput; } }
/** * This will redirect the user to a new web location. This can be a relative or absolute web path, or it * can be an entire URL. * * @return void */ public static function Redirect($strLocation) { // Clear the output buffer (if any) ob_clean(); if (QApplication::$RequestMode == QRequestMode::Ajax || array_key_exists('Qform__FormCallType', $_POST) && $_POST['Qform__FormCallType'] == QCallType::Ajax) { // AJAX-based Response // Response is in XML Format header('Content-Type: text/xml'); // Output it and update render state $strLocation = 'document.location="' . $strLocation . '"'; $strLocation = QString::XmlEscape($strLocation); print '<?xml version="1.0"?><response><controls/><commands><command>' . $strLocation . '</command></commands></response>'; } else { // Was "DOCUMENT_ROOT" set? if (array_key_exists('DOCUMENT_ROOT', $_SERVER) && $_SERVER['DOCUMENT_ROOT']) { // If so, we're likley using PHP as a Plugin/Module // Use 'header' to redirect header(sprintf('Location: %s', $strLocation)); } else { // We're likely using this as a CGI // Use JavaScript to redirect printf('<script type="text/javascript">document.location = "%s";</script>', $strLocation); } } // End the Response Script exit; }
public function RenderControlRegisterJS($blnPrint = true, $blnAjaxFormating = false) { $strRendered = ''; if (!$blnAjaxFormating) { $strRendered .= "<script language='javascript'>\n\t"; } $strRendered .= "\$(document).ready(function(){\n\t"; $strRendered .= "MJax.ClearRegisteredControls();\n\t"; foreach ($this->arrControls as $objControl) { $strRendered .= sprintf("MJax.RegisterControl('%s');\n\t", $objControl->ControlId); } $strRendered .= "});\n\t"; if (!$blnAjaxFormating) { $strRendered .= "</script>"; } if ($blnAjaxFormating) { $strRendered = QString::XmlEscape(trim($strRendered)); } if ($blnPrint) { _p($strRendered, false); } else { return $strRendered; } }
protected function ExecuteUpload() { // Setup QPM XML $strQpmXml = '<?xml version="1.0" encoding="UTF-8" ?>'; $strQpmXml .= "\r\n"; $strQpmXml .= '<qpm version="1.0">'; $strQpmXml .= "\r\n"; $strQpmXml .= sprintf('<package name="%s" user="******" version="%s" qcodoVersion="%s" qcodoVersionType="%s" submitted="%s">', $this->strPackageName, $this->strUsername, $this->intNewVersionNumber, $this->strManifestVersion, $this->strManifestVersionType, QDateTime::Now()->__toString(QDateTime::FormatRfc822)); $strQpmXml .= "\r\n"; $strQpmXml .= sprintf('<notes>%s</notes>', QString::XmlEscape($this->strNotes)); $strQpmXml .= "\r\n"; $strQpmXml .= '<newFiles>'; $strQpmXml .= "\r\n"; foreach ($this->objNewFileArray as $objFile) { $strQpmXml .= sprintf('<file directoryToken="%s" path="%s" md5="%s">%s</file>', $objFile->DirectoryToken, $objFile->Path, $objFile->Md5, base64_encode(file_get_contents($objFile->GetFullPath()))); $strQpmXml .= "\r\n"; } $strQpmXml .= '</newFiles>'; $strQpmXml .= "\r\n"; $strQpmXml .= '<changedFiles>'; $strQpmXml .= "\r\n"; foreach ($this->objChangedFileArray as $objFile) { $strQpmXml .= sprintf('<file directoryToken="%s" path="%s" md5="%s">%s</file>', $objFile->DirectoryToken, $objFile->Path, $objFile->Md5, base64_encode(file_get_contents($objFile->GetFullPath()))); $strQpmXml .= "\r\n"; } $strQpmXml .= '</changedFiles>'; $strQpmXml .= "\r\n"; $strQpmXml .= '</package>'; $strQpmXml .= "\r\n"; $strQpmXml .= '</qpm>'; if (function_exists('gzuncompress')) { $blnGzCompress = true; $strQpmXml = gzcompress($strQpmXml, 9); } else { $blnGzCompress = false; } print "Uploading QPM package (" . strlen($strQpmXml) . " bytes)...\r\n"; $strEndpoint = substr(QPackageManager::QpmServiceEndpoint, strlen('http://')); $strHost = substr($strEndpoint, 0, strpos($strEndpoint, '/')); $strPath = substr($strEndpoint, strpos($strEndpoint, '/')); $strHeader = sprintf("GET %s/UploadPackage?name=%s&u=%s&p=%s&gz=%s HTTP/1.1\r\nHost: %s\r\nContent-Length: %s\r\n\r\n", $strPath, $this->strPackageName, $this->strUsername, $this->strPassword, $blnGzCompress, $strHost, strlen($strQpmXml)); $objSocket = fsockopen($strHost, 80); fputs($objSocket, $strHeader); fputs($objSocket, $strQpmXml); fputs($objSocket, "\r\n\r\n"); $strResponse = null; while (($chr = fgetc($objSocket)) !== false) { $strResponse .= $chr; } $strResponseArray = explode("\r\n\r\n", trim($strResponse)); print ' ' . $strResponseArray[1] . "\r\n"; fclose($objSocket); }
public function GetXml() { $strToReturn = "\t<item>\r\n"; $strToReturn .= sprintf("\t\t<title>%s</title>\r\n", QString::XmlEscape($this->strTitle)); $strToReturn .= sprintf("\t\t<link>%s</link>\r\n", QString::XmlEscape($this->strLink)); $strToReturn .= sprintf("\t\t<description>%s</description>\r\n", QString::XmlEscape($this->strDescription)); if ($this->strAuthor) { $strToReturn .= sprintf("\t\t<author>%s</author>\r\n", QString::XmlEscape($this->strAuthor)); } foreach ($this->objCategoryArray as $objCategory) { $strToReturn .= $objCategory->GetXml(); } if ($this->strComments) { $strToReturn .= sprintf("\t\t<comments>%s</comments>\r\n", QString::XmlEscape($this->strComments)); } if ($this->strGuid) { $strToReturn .= sprintf("\t\t<guid isPermaLink=\"%s\">%s</guid>\r\n", $this->blnGuidPermaLink ? 'true' : 'false', $this->strGuid); } if ($this->dttPubDate) { $strToReturn .= sprintf("\t\t<pubDate>%s</pubDate>\r\n", $this->dttPubDate->__toString(QDateTime::FormatRfc822)); } $strToReturn .= "\t</item>\r\n"; return $strToReturn; }
protected function RenderAjax() { // Update the Status $this->intFormStatus = QFormBase::FormStatusRenderBegun; // Create the Control collection $strToReturn = '<controls>'; // Include each control (if applicable) that has been changed/modified foreach ($this->GetAllControls() as $objControl) { if (!$objControl->ParentControl) { // $strToReturn .= $objControl->RenderAjax(false) . "\r\n"; $strToReturn .= $this->RenderAjaxHelper($objControl); } } // Create JS Commands to Execute $strCommands = ''; // First, get all controls that need to run regC $strControlIdToRegister = array(); foreach ($this->GetAllControls() as $objControl) { if ($objControl->Rendered) { array_push($strControlIdToRegister, '"' . $objControl->ControlId . '"'); } } if (count($strControlIdToRegister)) { $strCommands = sprintf('qc.regCA(new Array(%s)); ', implode(',', $strControlIdToRegister)); } // Next, go through all controls and groupings for their GetEndScripts foreach ($this->GetAllControls() as $objControl) { if ($objControl->Rendered) { $strJavaScript = $objControl->GetEndScript(); if (strlen($strJavaScript)) { $strCommands .= QString::XmlEscape($strJavaScript); } } } foreach ($this->objGroupingArray as $objGrouping) { $strRender = $objGrouping->Render(); if (trim($strRender)) { $strCommands .= QString::XmlEscape($strRender); } } // Finally, look to the Application object for any commands to run $strCommands .= QApplication::RenderJavaScript(false); // Set Up the Command Node if (trim($strCommands)) { $strCommands = '<command>' . QString::XmlEscape(trim($strCommands)) . '</command>'; } // Add in the form state $strFormState = QForm::Serialize($this); $strToReturn .= sprintf('<control id="Qform__FormState">%s</control>', $strFormState); // close Control collection, Open the Command collection $strToReturn .= '</controls><commands>'; $strToReturn .= $strCommands; // close Command collection $strToReturn .= '</commands>'; $strContents = trim(ob_get_contents()); if (strtolower(substr($strContents, 0, 5)) == 'debug') { } else { ob_clean(); // Response is in XML Format header('Content-Type: text/xml'); // Output it and update render state if (QApplication::$EncodingType) { printf("<?xml version=\"1.0\" encoding=\"%s\"?><response>%s</response>\r\n", QApplication::$EncodingType, $strToReturn); } else { printf("<?xml version=\"1.0\"?><response>%s</response>\r\n", $strToReturn); } } // Update Render State $this->intFormStatus = QFormBase::FormStatusRenderEnded; }
/** * RenderOutput should be the last call in your custom RenderMethod. * * RenderOutput wraps your content with valid divs and control-identifiers, echos your code * to the content buffer or simply returns it. See {@link QControlBase::RenderHelper()}. * * @param string $strOutput * Your html-code which should be given out * @param boolean $blnDisplayOutput * should it be given out, or just be returned? * @param boolean $blnForceAsBlockElement * should it be given out as a block element, regardless of its configured tag? * @return string */ protected function RenderOutput($strOutput, $blnDisplayOutput, $blnForceAsBlockElement = false, $strWrapperAttributes = '') { // First, let's mark this control as being rendered and is ON the Page $this->blnRendering = false; $this->blnRendered = true; $this->blnOnPage = true; $strWrapperStyle = ''; // Determine whether or not $strOutput is considered a XHTML "Block" Element $blnIsBlockElement = $blnForceAsBlockElement || $this->blnIsBlockElement; if ($this->blnUseWrapper) { // Check for Visibility if (!$this->blnVisible) { $strOutput = ''; } $strWrapperStyle = $this->GetWrapperStyleAttributes($blnIsBlockElement); if ($this->strWrapperCssClass) { $strWrapperAttributes .= sprintf(' class="%s"', $this->strWrapperCssClass); } } else { if (!$this->blnVisible) { /*no wrapper is used + the control should not be visible * --> render a span with the control id and display:none * This allows us to change blnVisible to true in an Ajax call * as the span will get replaced with the real control */ $strOutput = sprintf('<span id="%s" style="display:none;"></span>', $this->strControlId); } } switch ($this->objForm->CallType) { case QCallType::Ajax: // If we have a ParentControl and the ParentControl has NOT been rendered, then output // as standard HTML if ($this->objParentControl && ($this->objParentControl->Rendered || $this->objParentControl->Rendering)) { if ($strWrapperStyle) { $strWrapperStyle = sprintf('style="%s"', $strWrapperStyle); } if ($this->blnUseWrapper) { if ($blnIsBlockElement) { $strOutput = sprintf('<div id="%s_ctl" %s%s>%s</div>%s', $this->strControlId, $strWrapperStyle, $strWrapperAttributes, $strOutput, $this->GetNonWrappedHtml()); } else { $strOutput = sprintf('<span id="%s_ctl" %s%s>%s</span>%s', $this->strControlId, $strWrapperStyle, $strWrapperAttributes, $strOutput, $this->GetNonWrappedHtml()); } } else { $strOutput = $strOutput . $this->GetNonWrappedHtml(); } } else { // Otherwise, we are rendering as a top-level AJAX response // Surround Output HTML around CDATA tags $strOutput = QString::XmlEscape($strOutput); // use the wrapper attribute to pass in the special attribute data-hasrel (if no wrappers are used and RenderWithError or similar methods are called) $strOutput = sprintf('<control id="%s" %s>%s</control>', $this->strControlId, $strWrapperAttributes, $strOutput); if ($this->blnWrapperModified && $this->blnVisible && $this->blnUseWrapper) { QApplication::ExecuteJavaScript(sprintf('w = qc.getW("%s"); w.style.cssText = "%stext-decoration:inherit;"; w.className = "%s";', $this->strControlId, $strWrapperStyle, $this->strWrapperCssClass)); } } break; default: if ($strWrapperStyle) { $strWrapperStyle = sprintf('style="%s"', $strWrapperStyle); } if ($this->blnUseWrapper) { if ($blnIsBlockElement) { $strOutput = sprintf('<div id="%s_ctl" %s%s>%s</div>%s', $this->strControlId, $strWrapperStyle, $strWrapperAttributes, $strOutput, $this->GetNonWrappedHtml()); } else { $strOutput = sprintf('<span id="%s_ctl" %s%s>%s</span>%s', $this->strControlId, $strWrapperStyle, $strWrapperAttributes, $strOutput, $this->GetNonWrappedHtml()); } } else { $strOutput = $strOutput . $this->GetNonWrappedHtml(); } break; } // Output or Return if ($blnDisplayOutput) { print $strOutput; } else { return $strOutput; } }
$dttEndRange = QDataGen::GenerateDateTime($dttStartDate, $dttEndRange); $dttPostDate = QDataGen::GenerateDateTime($dttStartDate, $dttEndRange); for ($intVersion = 0; $intVersion < $intVersionCount; $intVersion++) { // Randomize a Qcodo Version $strQcodoVersion = rand(0, 99) . '.' . rand(0, 99) . '.' . rand(0, 99); $strQcodoVersionType = rand(0, 1) ? 'Development' : 'Stable'; // Randomize a New and Changed file count $intNewFileCount = rand(0, 10); $intChangedFileCount = rand(0, 10); // Randomize Notes $strNotes = QDataGen::GenerateContent(rand(1, 3), 20, 80); // Build XML $strQpmXml = '<?xml version="1.0" encoding="UTF-8" ?>'; $strQpmXml .= '<qpm version="1.0">'; $strQpmXml .= sprintf('<package name="%s" user="******" version="%s" qcodoVersion="%s" qcodoVersionType="%s" submitted="%s">', $objPackage->Token, $objPerson->Username, $intVersion + 1, $strQcodoVersion, $strQcodoVersionType, $dttPostDate->__toString(QDateTime::FormatRfc822)); $strQpmXml .= sprintf('<notes>%s</notes>', QString::XmlEscape($strNotes)); $strQpmXml .= '<newFiles>'; for ($intFileCount = 0; $intFileCount < $intNewFileCount; $intFileCount++) { $strContent = QDataGen::GenerateContent(rand(1, 3), 20, 80); $strQpmXml .= sprintf('<file directoryToken="__FOOBAR__" path="some/random/path.txt" md5="%s">%s</file>', md5($strContent), base64_encode($strContent)); } $strQpmXml .= '</newFiles>'; $strQpmXml .= '<changedFiles>'; for ($intFileCount = 0; $intFileCount < $intChangedFileCount; $intFileCount++) { $strContent = QDataGen::GenerateContent(rand(1, 3), 20, 80); $strQpmXml .= sprintf('<file directoryToken="__FOOBAR__" path="some/random/path.txt" md5="%s">%s</file>', md5($strContent), base64_encode($strContent)); } $strQpmXml .= '</changedFiles>'; $strQpmXml .= '</package></qpm>'; $objPackage->PostContributionVersion($objPerson, $strQpmXml, $dttPostDate); $dttEndRange = QDataGen::GenerateDateTime($dttPostDate, QDateTime::Now());