/** * Default / simple DataBinder for this Meta DataGrid. This can easily be overridden * by calling SetDataBinder() on this DataGrid with another DataBinder of your choice. * * If a paginator is set on this DataBinder, it will use it. If not, then no pagination will be used. * It will also perform any sorting (if applicable). */ public function MetaDataBinder() { // Remember! We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below if ($this->Paginator) { $this->TotalItemCount = PackageVersion::CountAll(); } // Setup the $objClauses Array $objClauses = array(); // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add // the OrderByClause to the $objClauses array if ($objClause = $this->OrderByClause) { array_push($objClauses, $objClause); } // Add the LimitClause information, as well if ($objClause = $this->LimitClause) { array_push($objClauses, $objClause); } // Set the DataSource to be a Query result from PackageVersion, given the clauses above $this->DataSource = PackageVersion::LoadAll($objClauses); }
/** * Refresh this MetaControl with Data from the local PackageContribution object. * @param boolean $blnReload reload PackageContribution from the database * @return void */ public function Refresh($blnReload = false) { if ($blnReload) { $this->objPackageContribution->Reload(); } if ($this->lblId) { if ($this->blnEditMode) { $this->lblId->Text = $this->objPackageContribution->Id; } } if ($this->lstPackage) { $this->lstPackage->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstPackage->AddItem(QApplication::Translate('- Select One -'), null); } $objPackageArray = Package::LoadAll(); if ($objPackageArray) { foreach ($objPackageArray as $objPackage) { $objListItem = new QListItem($objPackage->__toString(), $objPackage->Id); if ($this->objPackageContribution->Package && $this->objPackageContribution->Package->Id == $objPackage->Id) { $objListItem->Selected = true; } $this->lstPackage->AddItem($objListItem); } } } if ($this->lblPackageId) { $this->lblPackageId->Text = $this->objPackageContribution->Package ? $this->objPackageContribution->Package->__toString() : null; } if ($this->lstPerson) { $this->lstPerson->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstPerson->AddItem(QApplication::Translate('- Select One -'), null); } $objPersonArray = Person::LoadAll(); if ($objPersonArray) { foreach ($objPersonArray as $objPerson) { $objListItem = new QListItem($objPerson->__toString(), $objPerson->Id); if ($this->objPackageContribution->Person && $this->objPackageContribution->Person->Id == $objPerson->Id) { $objListItem->Selected = true; } $this->lstPerson->AddItem($objListItem); } } } if ($this->lblPersonId) { $this->lblPersonId->Text = $this->objPackageContribution->Person ? $this->objPackageContribution->Person->__toString() : null; } if ($this->lstCurrentPackageVersion) { $this->lstCurrentPackageVersion->RemoveAllItems(); $this->lstCurrentPackageVersion->AddItem(QApplication::Translate('- Select One -'), null); $objCurrentPackageVersionArray = PackageVersion::LoadAll(); if ($objCurrentPackageVersionArray) { foreach ($objCurrentPackageVersionArray as $objCurrentPackageVersion) { $objListItem = new QListItem($objCurrentPackageVersion->__toString(), $objCurrentPackageVersion->Id); if ($this->objPackageContribution->CurrentPackageVersion && $this->objPackageContribution->CurrentPackageVersion->Id == $objCurrentPackageVersion->Id) { $objListItem->Selected = true; } $this->lstCurrentPackageVersion->AddItem($objListItem); } } } if ($this->lblCurrentPackageVersionId) { $this->lblCurrentPackageVersionId->Text = $this->objPackageContribution->CurrentPackageVersion ? $this->objPackageContribution->CurrentPackageVersion->__toString() : null; } if ($this->calCurrentPostDate) { $this->calCurrentPostDate->DateTime = $this->objPackageContribution->CurrentPostDate; } if ($this->lblCurrentPostDate) { $this->lblCurrentPostDate->Text = sprintf($this->objPackageContribution->CurrentPostDate) ? $this->objPackageContribution->__toString($this->strCurrentPostDateDateTimeFormat) : null; } if ($this->txtDownloadCount) { $this->txtDownloadCount->Text = $this->objPackageContribution->DownloadCount; } if ($this->lblDownloadCount) { $this->lblDownloadCount->Text = $this->objPackageContribution->DownloadCount; } }