public static function RestoreByNameForClass($strName, $intClassId, $strVersion, $objFile) { $objConstant = QcodoConstant::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::QcodoConstant()->QcodoClassId, $intClassId), QQ::Equal(QQN::QcodoConstant()->Variable->Name, $strName))); if (!$objConstant) { $objVariable = new Variable(); $objVariable->Name = $strName; $objVariable->VariableTypeId = VariableType::String; $objVariable->FirstVersion = $strVersion; $objVariable->Save(); $objConstant = new QcodoConstant(); $objConstant->Variable = $objVariable; $objConstant->File = $objFile; $objConstant->QcodoClassId = $intClassId; $objConstant->Save(); } else { if ($objConstant->Variable->LastVersion) { $objConstant->Variable->LastVersion = null; $objConstant->Variable->Save(); } if ($objFile->Id != $objConstant->intFileId) { $objConstant->File = $objFile; $objConstant->Save(); } } return $objConstant; }
protected function Redirect() { $objConstant = QcodoConstant::Load(QApplication::PathInfo(0)); if ($objConstant) { QApplication::Redirect('/index.php/' . $this->objConstant->QcodoClass->Name . '/Constants'); } else { QApplication::Redirect('/index.php'); } }
protected function SetupQcodoConstant() { // Lookup Object PK information from Query String (if applicable) // Set mode to Edit or New depending on what's found $intId = QApplication::QueryString('intId'); if ($intId) { $this->objQcodoConstant = QcodoConstant::Load($intId); if (!$this->objQcodoConstant) { throw new Exception('Could not find a QcodoConstant object with PK arguments: ' . $intId); } $this->strTitleVerb = QApplication::Translate('Edit'); $this->blnEditMode = true; } else { $this->objQcodoConstant = new QcodoConstant(); $this->strTitleVerb = QApplication::Translate('Create'); $this->blnEditMode = false; } }
protected function UpdateVariableFields() { $this->objVariable->Name = $this->txtName->Text; $this->objVariable->VariableTypeId = $this->lstVariableType->SelectedValue; $this->objVariable->ObjectTypeId = $this->lstObjectType->SelectedValue; $this->objVariable->ArrayFlag = $this->chkArrayFlag->Checked; $this->objVariable->DefaultValue = $this->txtDefaultValue->Text; $this->objVariable->FirstVersion = $this->txtFirstVersion->Text; $this->objVariable->LastVersion = $this->txtLastVersion->Text; $this->objVariable->ShortDescription = $this->txtShortDescription->Text; $this->objVariable->ExtendedDescription = $this->txtExtendedDescription->Text; $this->objVariable->ClassProperty = ClassProperty::Load($this->lstClassProperty->SelectedValue); $this->objVariable->ClassVariable = ClassVariable::Load($this->lstClassVariable->SelectedValue); $this->objVariable->Parameter = Parameter::Load($this->lstParameter->SelectedValue); $this->objVariable->QcodoConstant = QcodoConstant::Load($this->lstQcodoConstant->SelectedValue); }
/** * Override method to perform a property "Get" * This will get the value of $strName * * @param string $strName Name of the property to get * @return mixed */ public function __get($strName) { switch ($strName) { /////////////////// // Member Variables /////////////////// case 'Id': /** * Gets the value for intId (Read-Only PK) * @return integer */ return $this->intId; case 'Name': /** * Gets the value for strName * @return string */ return $this->strName; case 'VariableTypeId': /** * Gets the value for intVariableTypeId (Not Null) * @return integer */ return $this->intVariableTypeId; case 'ObjectTypeId': /** * Gets the value for intObjectTypeId * @return integer */ return $this->intObjectTypeId; case 'ArrayFlag': /** * Gets the value for blnArrayFlag * @return boolean */ return $this->blnArrayFlag; case 'DefaultValue': /** * Gets the value for strDefaultValue * @return string */ return $this->strDefaultValue; case 'FirstVersion': /** * Gets the value for strFirstVersion * @return string */ return $this->strFirstVersion; case 'LastVersion': /** * Gets the value for strLastVersion * @return string */ return $this->strLastVersion; case 'ShortDescription': /** * Gets the value for strShortDescription * @return string */ return $this->strShortDescription; case 'ExtendedDescription': /** * Gets the value for strExtendedDescription * @return string */ return $this->strExtendedDescription; /////////////////// // Member Objects /////////////////// /////////////////// // Member Objects /////////////////// case 'ObjectType': /** * Gets the value for the QcodoClass object referenced by intObjectTypeId * @return QcodoClass */ try { if (!$this->objObjectType && !is_null($this->intObjectTypeId)) { $this->objObjectType = QcodoClass::Load($this->intObjectTypeId); } return $this->objObjectType; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'ClassProperty': /** * Gets the value for the ClassProperty object that uniquely references this Variable * by objClassProperty (Unique) * @return ClassProperty */ try { if ($this->objClassProperty === false) { // We've attempted early binding -- and the reverse reference object does not exist return null; } if (!$this->objClassProperty) { $this->objClassProperty = ClassProperty::LoadByVariableId($this->intId); } return $this->objClassProperty; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'ClassVariable': /** * Gets the value for the ClassVariable object that uniquely references this Variable * by objClassVariable (Unique) * @return ClassVariable */ try { if ($this->objClassVariable === false) { // We've attempted early binding -- and the reverse reference object does not exist return null; } if (!$this->objClassVariable) { $this->objClassVariable = ClassVariable::LoadByVariableId($this->intId); } return $this->objClassVariable; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'Parameter': /** * Gets the value for the Parameter object that uniquely references this Variable * by objParameter (Unique) * @return Parameter */ try { if ($this->objParameter === false) { // We've attempted early binding -- and the reverse reference object does not exist return null; } if (!$this->objParameter) { $this->objParameter = Parameter::LoadByVariableId($this->intId); } return $this->objParameter; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'QcodoConstant': /** * Gets the value for the QcodoConstant object that uniquely references this Variable * by objQcodoConstant (Unique) * @return QcodoConstant */ try { if ($this->objQcodoConstant === false) { // We've attempted early binding -- and the reverse reference object does not exist return null; } if (!$this->objQcodoConstant) { $this->objQcodoConstant = QcodoConstant::LoadByVariableId($this->intId); } return $this->objQcodoConstant; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } //////////////////////////// // Virtual Object References (Many to Many and Reverse References) // (If restored via a "Many-to" expansion) //////////////////////////// //////////////////////////// // Virtual Object References (Many to Many and Reverse References) // (If restored via a "Many-to" expansion) //////////////////////////// case '_OperationAsReturn': /** * Gets the value for the private _objOperationAsReturn (Read-Only) * if set due to an expansion on the operation.return_variable_id reverse relationship * @return Operation */ return $this->_objOperationAsReturn; case '_OperationAsReturnArray': /** * Gets the value for the private _objOperationAsReturnArray (Read-Only) * if set due to an ExpandAsArray on the operation.return_variable_id reverse relationship * @return Operation[] */ return (array) $this->_objOperationAsReturnArray; case '_OperationAsAdditional': /** * Gets the value for the private _objOperationAsAdditional (Read-Only) * if set due to an expansion on the operation.additional_variable_id reverse relationship * @return Operation */ return $this->_objOperationAsAdditional; case '_OperationAsAdditionalArray': /** * Gets the value for the private _objOperationAsAdditionalArray (Read-Only) * if set due to an ExpandAsArray on the operation.additional_variable_id reverse relationship * @return Operation[] */ return (array) $this->_objOperationAsAdditionalArray; default: try { return parent::__get($strName); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } } }
public function dtgQcodoConstant_Bind() { // Get Total Count b/c of Pagination $this->dtgQcodoConstant->TotalItemCount = QcodoConstant::CountAll(); $objClauses = array(); if ($objClause = $this->dtgQcodoConstant->OrderByClause) { array_push($objClauses, $objClause); } if ($objClause = $this->dtgQcodoConstant->LimitClause) { array_push($objClauses, $objClause); } $this->dtgQcodoConstant->DataSource = QcodoConstant::LoadAll($objClauses); }
protected function ProcessFolder($strFolder) { $strLabel = substr($strFolder, strlen($this->strRoot) + 1); if (!$strLabel) { $strLabel = 'root'; } print 'Processing ' . $strLabel . ' ['; $strFileArray = array(); $strFolderArray = array(); // Iterate through all subfolders and files in this folder // Be sure not to process anything with CVS, SVN or ds_store $objDirectory = opendir($strFolder); while ($strName = readdir($objDirectory)) { if ($strName != '.' && $strName != '..' && $strName != 'SVN' && $strName != '.svnignore' && $strName != 'CVS' && $strName != '.cvsignore' && strtolower($strName) != '.ds_store') { $strFullPath = $strFolder . '/' . $strName; if (is_dir($strFullPath)) { array_push($strFolderArray, $strFullPath); } else { array_push($strFileArray, $strFullPath); } } } $intFileCount = count($strFileArray); for ($intFileIndex = 0; $intFileIndex < $intFileCount; $intFileIndex++) { print ' '; } print ']'; for ($intFileIndex = 0; $intFileIndex <= $intFileCount; $intFileIndex++) { print chr(8); } foreach ($strFileArray as $strFile) { print 'X'; $strMd5 = md5_file($strFile); $strFullPath = $strFile; $strFile = substr($strFile, strlen($this->strRoot) + 1); // Process all files other than the root _README.txt and LICENSE.txt if ($strFile != '_README.txt' && $strFile != '_LICENSE.txt') { $intDirectoryId = null; $objFileDirectory = null; foreach ($this->objDirectoryTokens as $objDirectory) { if (!$intDirectoryId) { if (strpos($strFile, $objDirectory->Path) === 0) { $intDirectoryId = $objDirectory->Id; $objFileDirectory = $objDirectory; $strFile = substr($strFile, strlen($objDirectory->Path)); } } } if (!$intDirectoryId) { var_dump($this->objDirectoryTokens); exit("FATAL ERROR: No DirectoryToken resolution for " . $strFile . "\r\n"); } $objFile = File::LoadByDirectoryIdPath($intDirectoryId, $strFile); if (!$objFile) { $objFile = new File(); $objFile->Path = $strFile; $objFile->DirectoryId = $intDirectoryId; } else { $objFile->DeprecatedMajorVersion = null; $objFile->DeprecatedMinorVersion = null; $objFile->DeprecatedBuild = null; } $objFile->Save(); $this->blnFileProcessedArray['id' . $objFile->Id] = true; $this->strXml .= sprintf("<file directoryToken=\"%s\" path=\"%s\" md5=\"%s\"/>\r\n", $objFileDirectory->Token, $strFile, $strMd5); // Parse tokens for documetation for all PHP files outside of assets and PHPUnit if (substr($strFile, strlen($strFile) - 4) == '.php' && strpos($strFullPath, '/assets/') === false && strpos($strFullPath, '/PHPUnit/') === false) { switch ($objFileDirectory->Token) { case '__INCLUDES__': case '__QCODO__': case '__QCODO_CORE__': $objParser = new QScriptParser($strFullPath); $objResult = $objParser->ParseTokens(); // Iterate through the Class Definitions foreach ($objResult->ClassArray as $objParserClass) { if ($objParserClass->Extends) { $objParentClass = QcodoClass::RestoreByName($objParserClass->Extends, $this->strVersion, null); } else { $objParentClass = null; } // TO DO // if ($strImplements) { // } $objClass = QcodoClass::RestoreByName($objParserClass->Name, $this->strVersion, $objFile); $objClass->AbstractFlag = $objParserClass->Abstract; $objClass->ParentQcodoClass = $objParentClass; $objClass->Save(); // Class Constants $strConstantArray = array(); foreach ($objParserClass->ConstantArray as $objParserConstant) { $objConstant = QcodoConstant::RestoreByNameForClass($objParserConstant->Name, $objClass->Id, $this->strVersion, $objFile); // $strValue = QBuildMaker::StripQuotes($objParserConstant->Value); $strValue = $objParserConstant->Value; $objConstant->Variable->DefaultValue = $strValue; $objConstant->Variable->Save(); $strConstantArray[$objParserConstant->Name] = true; } // Class Constants (Deprecate) foreach ($objClass->GetQcodoConstantArray(QQ::Clause(QQ::Expand(QQN::QcodoConstant()->Variable))) as $objConstant) { if (!array_key_exists($objConstant->Variable->Name, $strConstantArray)) { $objConstant->Variable->LastVersion = $this->strVersion; $objConstant->Variable->Save(); } } // Class Variables $strVariableArray = array(); foreach ($objParserClass->VariableArray as $objParserVariable) { $strName = QBuildMaker::StripDollar($objParserVariable->Name); // $strValue = QBuildMaker::StripQuotes($objParserVariable->DefaultValue); $strValue = $objParserVariable->DefaultValue; $objClassVariable = ClassVariable::RestoreByNameForClass($strName, $objClass->Id, $this->strVersion); $objClassVariable->Variable->DefaultValue = $strValue; $objClassVariable->Variable->Save(); $objClassVariable->StaticFlag = $objParserVariable->Static; switch (strtolower($objParserVariable->Visibility)) { case 'public': $objClassVariable->ProtectionTypeId = ProtectionType::_Public; break; case 'protected': $objClassVariable->ProtectionTypeId = ProtectionType::_Protected; break; case 'private': $objClassVariable->ProtectionTypeId = ProtectionType::_Private; break; default: throw new Exception('Unknown Protection Type'); } $objClassVariable->Save(); $strVariableArray[$strName] = true; } // Class Variables (deprecate) foreach ($objClass->GetClassVariableArray(QQ::Clause(QQ::Expand(QQN::ClassVariable()->Variable))) as $objClassVariable) { if (!array_key_exists($objClassVariable->Variable->Name, $strVariableArray)) { $objClassVariable->Variable->LastVersion = $this->strVersion; $objClassVariable->Variable->Save(); } } // Class Methods $strMethodArray = array(); foreach ($objParserClass->MethodArray as $objParserFunction) { $objOperation = Operation::RestoreByNameForClass($objParserFunction->Name, $objClass->Id, $this->strVersion, $objFile); $objOperation->StaticFlag = $objParserFunction->Static; $objOperation->FinalFlag = $objParserFunction->Final; $objOperation->AbstractFlag = $objParserFunction->Abstract; switch (strtolower($objParserFunction->Visibility)) { case 'public': $objOperation->ProtectionTypeId = ProtectionType::_Public; break; case 'protected': $objOperation->ProtectionTypeId = ProtectionType::_Protected; break; case 'private': $objOperation->ProtectionTypeId = ProtectionType::_Private; break; default: throw new Exception('Unknown Protection Type'); } $objOperation->Save(); $strMethodArray[$objParserFunction->Name] = true; // Figure Out the Parameters $objParserParameterArray = array(); foreach ($objParserFunction->ParameterArray as $objParserParameter) { $strName = QBuildMaker::StripDollar($objParserParameter->Name); $objParserParameterArray[$strName] = $objParserParameter; } $objParameterArray = Parameter::RestoreParameterArrayByNameForOperation(array_keys($objParserParameterArray), $objOperation->Id, $this->strVersion); foreach ($objParameterArray as $objParameter) { $objParserParameter = $objParserParameterArray[$objParameter->Variable->Name]; $objParameter->ReferenceFlag = $objParserParameter->Reference; $objParameter->Save(); $objParameter->Variable->DefaultValue = $objParserParameter->DefaultValue; $objParameter->Variable->Save(); } } // Class Methods (deprecate) foreach ($objClass->GetOperationArray() as $objOperation) { if (!array_key_exists($objOperation->Name, $strMethodArray)) { $objOperation->LastVersion = $this->strVersion; $objOperation->Save(); } } // Class Properties $strPropertyArray = array(); foreach ($objParserClass->PropertyArray as $objParserProperty) { $strName = QBuildMaker::StripQuotes($objParserProperty->Name); if ($strName != 'ttf' && $strName != 'pfb' && $strName != 'afm') { $objProperty = ClassProperty::RestoreByNameForClass($strName, $objClass->Id, $this->strVersion); if ($objParserProperty->Read && !$objParserProperty->Write) { $objProperty->ReadOnlyFlag = true; $objProperty->WriteOnlyFlag = false; } else { if (!$objParserProperty->Read && $objParserProperty->Write) { $objProperty->ReadOnlyFlag = false; $objProperty->WriteOnlyFlag = true; } else { $objProperty->ReadOnlyFlag = false; $objProperty->WriteOnlyFlag = false; } } $objProperty->Save(); $strPropertyArray[$strName] = true; } } // Class Properties (deprecate) foreach ($objClass->GetClassPropertyArray() as $objProperty) { if (!array_key_exists($objProperty->Variable->Name, $strPropertyArray)) { $objProperty->Variable->LastVersion = $this->strVersion; $objProperty->Save(); } } } // Iterate through the Interfaces // TODO // Iterate through the Global Functions foreach ($objResult->FunctionArray as $objParserFunction) { $objOperation = Operation::RestoreByNameForClass($objParserFunction->Name, null, $this->strVersion, $objFile); // Figure Out the Parameters $objParserParameterArray = array(); foreach ($objParserFunction->ParameterArray as $objParserParameter) { $strName = QBuildMaker::StripDollar($objParserParameter->Name); $objParserParameterArray[$strName] = $objParserParameter; } $objParameterArray = Parameter::RestoreParameterArrayByNameForOperation(array_keys($objParserParameterArray), $objOperation->Id, $this->strVersion); foreach ($objParameterArray as $objParameter) { $objParserParameter = $objParserParameterArray[$objParameter->Variable->Name]; $objParameter->ReferenceFlag = $objParserParameter->Reference; $objParameter->Save(); $objParameter->Variable->DefaultValue = $objParserParameter->DefaultValue; $objParameter->Variable->Save(); } } // Iterate through the Global Constants foreach ($objResult->ConstantArray as $objParserConstant) { $objConstant = QcodoConstant::RestoreByNameForClass($objParserConstant->Name, null, $this->strVersion, $objFile); // $strValue = QBuildMaker::StripQuotes($objParserConstant->Value); $strValue = $objParserConstant->Value; $objConstant->Variable->DefaultValue = $strValue; $objConstant->Variable->Save(); } // Iterate through the Global Variables // NOT SUPPORTED break; } } } } print "] Done.\r\n"; foreach ($strFolderArray as $strFolder) { $this->ProcessFolder($strFolder); } }
public static function GetSoapArrayFromArray($objArray) { if (!$objArray) { return null; } $objArrayToReturn = array(); foreach ($objArray as $objObject) { array_push($objArrayToReturn, QcodoConstant::GetSoapObjectFromObject($objObject, true)); } return unserialize(serialize($objArrayToReturn)); }
/** * Counts all associated QcodoConstants * @return int */ public function CountQcodoConstants() { if (is_null($this->intId)) { return 0; } return QcodoConstant::CountByQcodoClassId($this->intId); }