예제 #1
0
 protected function Form_Create()
 {
     parent::Form_Create();
     // "New" is a special keyword
     if (($strToken = trim(strtolower(QApplication::PathInfo(0)))) == 'new') {
         $strToken = null;
     }
     $objPackage = Package::LoadByToken($strToken);
     if (!$objPackage) {
         $objPackage = new Package();
         $this->blnEditMode = false;
         $this->strPageTitle .= 'Create New';
         $this->strHeadline = 'Create a New QPM Package';
     } else {
         if (!$objPackage->IsEditableForPerson(QApplication::$Person)) {
             QApplication::RedirectToLogin();
         }
         $this->blnEditMode = true;
         $this->strPageTitle .= 'Edit Package ' . $objPackage->Token;
         $this->strHeadline = 'Edit Package ' . $objPackage->Token;
     }
     $this->mctPackage = new PackageMetaControl($this, $objPackage);
     $this->txtToken = $this->mctPackage->txtToken_Create();
     $this->txtToken->Required = true;
     $this->lstCategory = $this->mctPackage->lstPackageCategory_Create();
     $this->lstCategory->Required = true;
     // Remove "Issue"
     for ($intIndex = 0; $intIndex < $this->lstCategory->ItemCount; $intIndex++) {
         $objListItem = $this->lstCategory->GetItem($intIndex);
         $objCategory = PackageCategory::Load($objListItem->Value);
         if ($objCategory && $objCategory->Token == 'issues') {
             $this->lstCategory->RemoveItem($intIndex);
             break;
         }
     }
     $this->txtName = $this->mctPackage->txtName_Create();
     $this->txtName->Required = true;
     $this->txtDescription = $this->mctPackage->txtDescription_Create();
     $this->txtDescription->Required = true;
     $this->btnOkay = new QButton($this);
     $this->btnOkay->CausesValidation = true;
     $this->btnOkay->Text = $this->blnEditMode ? 'Update Package' : 'Save New Package';
     $this->btnCancel = new QLinkButton($this);
     $this->btnCancel->Text = 'Cancel';
     $this->btnOkay->AddAction(new QClickEvent(), new QToggleEnableAction($this->btnOkay));
     $this->btnOkay->AddAction(new QClickEvent(), new QAjaxAction('btnOkay_Click'));
     $this->btnCancel->AddAction(new QClickEvent(), new QAjaxAction('btnCancel_Click'));
     $this->btnCancel->AddAction(new QClickEvent(), new QTerminateAction());
     if (!$this->blnEditMode) {
         $this->txtToken->Focus();
     } else {
         $this->txtName->Focus();
     }
 }
예제 #2
0
 /**
  * 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 'PackageCategoryId':
             // Gets the value for intPackageCategoryId (Not Null)
             // @return integer
             return $this->intPackageCategoryId;
         case 'Token':
             // Gets the value for strToken (Unique)
             // @return string
             return $this->strToken;
         case 'Name':
             // Gets the value for strName
             // @return string
             return $this->strName;
         case 'Description':
             // Gets the value for strDescription
             // @return string
             return $this->strDescription;
         case 'LastPostDate':
             // Gets the value for dttLastPostDate
             // @return QDateTime
             return $this->dttLastPostDate;
         case 'LastPostedByPersonId':
             // Gets the value for intLastPostedByPersonId
             // @return integer
             return $this->intLastPostedByPersonId;
             ///////////////////
             // Member Objects
             ///////////////////
         ///////////////////
         // Member Objects
         ///////////////////
         case 'PackageCategory':
             // Gets the value for the PackageCategory object referenced by intPackageCategoryId (Not Null)
             // @return PackageCategory
             try {
                 if (!$this->objPackageCategory && !is_null($this->intPackageCategoryId)) {
                     $this->objPackageCategory = PackageCategory::Load($this->intPackageCategoryId);
                 }
                 return $this->objPackageCategory;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'LastPostedByPerson':
             // Gets the value for the Person object referenced by intLastPostedByPersonId
             // @return Person
             try {
                 if (!$this->objLastPostedByPerson && !is_null($this->intLastPostedByPersonId)) {
                     $this->objLastPostedByPerson = Person::Load($this->intLastPostedByPersonId);
                 }
                 return $this->objLastPostedByPerson;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'TopicLink':
             // Gets the value for the TopicLink object that uniquely references this Package
             // by objTopicLink (Unique)
             // @return TopicLink
             try {
                 if ($this->objTopicLink === false) {
                     // We've attempted early binding -- and the reverse reference object does not exist
                     return null;
                 }
                 if (!$this->objTopicLink) {
                     $this->objTopicLink = TopicLink::LoadByPackageId($this->intId);
                 }
                 return $this->objTopicLink;
             } 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 '_PackageContribution':
             // Gets the value for the private _objPackageContribution (Read-Only)
             // if set due to an expansion on the package_contribution.package_id reverse relationship
             // @return PackageContribution
             return $this->_objPackageContribution;
         case '_PackageContributionArray':
             // Gets the value for the private _objPackageContributionArray (Read-Only)
             // if set due to an ExpandAsArray on the package_contribution.package_id reverse relationship
             // @return PackageContribution[]
             return (array) $this->_objPackageContributionArray;
         case '__Restored':
             return $this->__blnRestored;
         default:
             try {
                 return parent::__get($strName);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
     }
 }
 /**
  * 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 'ParentPackageCategoryId':
             // Gets the value for intParentPackageCategoryId
             // @return integer
             return $this->intParentPackageCategoryId;
         case 'Token':
             // Gets the value for strToken (Unique)
             // @return string
             return $this->strToken;
         case 'OrderNumber':
             // Gets the value for intOrderNumber
             // @return integer
             return $this->intOrderNumber;
         case 'Name':
             // Gets the value for strName
             // @return string
             return $this->strName;
         case 'Description':
             // Gets the value for strDescription
             // @return string
             return $this->strDescription;
         case 'PackageCount':
             // Gets the value for intPackageCount
             // @return integer
             return $this->intPackageCount;
         case 'LastPostDate':
             // Gets the value for dttLastPostDate
             // @return QDateTime
             return $this->dttLastPostDate;
             ///////////////////
             // Member Objects
             ///////////////////
         ///////////////////
         // Member Objects
         ///////////////////
         case 'ParentPackageCategory':
             // Gets the value for the PackageCategory object referenced by intParentPackageCategoryId
             // @return PackageCategory
             try {
                 if (!$this->objParentPackageCategory && !is_null($this->intParentPackageCategoryId)) {
                     $this->objParentPackageCategory = PackageCategory::Load($this->intParentPackageCategoryId);
                 }
                 return $this->objParentPackageCategory;
             } 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 '_Package':
             // Gets the value for the private _objPackage (Read-Only)
             // if set due to an expansion on the package.package_category_id reverse relationship
             // @return Package
             return $this->_objPackage;
         case '_PackageArray':
             // Gets the value for the private _objPackageArray (Read-Only)
             // if set due to an ExpandAsArray on the package.package_category_id reverse relationship
             // @return Package[]
             return (array) $this->_objPackageArray;
         case '_ChildPackageCategory':
             // Gets the value for the private _objChildPackageCategory (Read-Only)
             // if set due to an expansion on the package_category.parent_package_category_id reverse relationship
             // @return PackageCategory
             return $this->_objChildPackageCategory;
         case '_ChildPackageCategoryArray':
             // Gets the value for the private _objChildPackageCategoryArray (Read-Only)
             // if set due to an ExpandAsArray on the package_category.parent_package_category_id reverse relationship
             // @return PackageCategory[]
             return (array) $this->_objChildPackageCategoryArray;
         case '__Restored':
             return $this->__blnRestored;
         default:
             try {
                 return parent::__get($strName);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
     }
 }
 /**
  * Static Helper Method to Create using PK arguments
  * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
  * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
  * static helper methods.  Finally, specify a CreateType to define whether or not we are only allowed to 
  * edit, or if we are also allowed to create a new one, etc.
  * 
  * @param mixed $objParentObject QForm or QPanel which will be using this PackageCategoryMetaControl
  * @param integer $intId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing PackageCategory object creation - defaults to CreateOrEdit
  * @return PackageCategoryMetaControl
  */
 public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intId)) {
         $objPackageCategory = PackageCategory::Load($intId);
         // PackageCategory was found -- return it!
         if ($objPackageCategory) {
             return new PackageCategoryMetaControl($objParentObject, $objPackageCategory);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a PackageCategory object with PK arguments: ' . $intId);
             }
         }
         // If EditOnly is specified, throw an exception
     } else {
         if ($intCreateType == QMetaControlCreateType::EditOnly) {
             throw new QCallerException('No PK arguments specified');
         }
     }
     // If we are here, then we need to create a new record
     return new PackageCategoryMetaControl($objParentObject, new PackageCategory());
 }