/**
  * Refresh this MetaControl with Data from the local AttributeOption object.
  * @param boolean $blnReload reload AttributeOption from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objAttributeOption->Reload();
     }
     if ($this->lblId) {
         if ($this->blnEditMode) {
             $this->lblId->Text = $this->objAttributeOption->Id;
         }
     }
     if ($this->lstAttribute) {
         $this->lstAttribute->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstAttribute->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objAttributeArray = Attribute::LoadAll();
         if ($objAttributeArray) {
             foreach ($objAttributeArray as $objAttribute) {
                 $objListItem = new QListItem($objAttribute->__toString(), $objAttribute->Id);
                 if ($this->objAttributeOption->Attribute && $this->objAttributeOption->Attribute->Id == $objAttribute->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstAttribute->AddItem($objListItem);
             }
         }
     }
     if ($this->lblAttributeId) {
         $this->lblAttributeId->Text = $this->objAttributeOption->Attribute ? $this->objAttributeOption->Attribute->__toString() : null;
     }
     if ($this->txtName) {
         $this->txtName->Text = $this->objAttributeOption->Name;
     }
     if ($this->lblName) {
         $this->lblName->Text = $this->objAttributeOption->Name;
     }
     if ($this->lstAttributeValuesAsMultiple) {
         $this->lstAttributeValuesAsMultiple->RemoveAllItems();
         $objAssociatedArray = $this->objAttributeOption->GetAttributeValueAsMultipleArray();
         $objAttributeValueArray = AttributeValue::LoadAll();
         if ($objAttributeValueArray) {
             foreach ($objAttributeValueArray as $objAttributeValue) {
                 $objListItem = new QListItem($objAttributeValue->__toString(), $objAttributeValue->Id);
                 foreach ($objAssociatedArray as $objAssociated) {
                     if ($objAssociated->Id == $objAttributeValue->Id) {
                         $objListItem->Selected = true;
                     }
                 }
                 $this->lstAttributeValuesAsMultiple->AddItem($objListItem);
             }
         }
     }
     if ($this->lblAttributeValuesAsMultiple) {
         $objAssociatedArray = $this->objAttributeOption->GetAttributeValueAsMultipleArray();
         $strItems = array();
         foreach ($objAssociatedArray as $objAssociated) {
             $strItems[] = $objAssociated->__toString();
         }
         $this->lblAttributeValuesAsMultiple->Text = implode($strGlue, $strItems);
     }
 }
 /**
  * Refresh this MetaControl with Data from the local AttributeValue object.
  * @param boolean $blnReload reload AttributeValue from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objAttributeValue->Reload();
     }
     if ($this->lblId) {
         if ($this->blnEditMode) {
             $this->lblId->Text = $this->objAttributeValue->Id;
         }
     }
     if ($this->lstAttribute) {
         $this->lstAttribute->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstAttribute->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objAttributeArray = Attribute::LoadAll();
         if ($objAttributeArray) {
             foreach ($objAttributeArray as $objAttribute) {
                 $objListItem = new QListItem($objAttribute->__toString(), $objAttribute->Id);
                 if ($this->objAttributeValue->Attribute && $this->objAttributeValue->Attribute->Id == $objAttribute->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstAttribute->AddItem($objListItem);
             }
         }
     }
     if ($this->lblAttributeId) {
         $this->lblAttributeId->Text = $this->objAttributeValue->Attribute ? $this->objAttributeValue->Attribute->__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->objAttributeValue->Person && $this->objAttributeValue->Person->Id == $objPerson->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstPerson->AddItem($objListItem);
             }
         }
     }
     if ($this->lblPersonId) {
         $this->lblPersonId->Text = $this->objAttributeValue->Person ? $this->objAttributeValue->Person->__toString() : null;
     }
     if ($this->calDateValue) {
         $this->calDateValue->DateTime = $this->objAttributeValue->DateValue;
     }
     if ($this->lblDateValue) {
         $this->lblDateValue->Text = sprintf($this->objAttributeValue->DateValue) ? $this->objAttributeValue->__toString($this->strDateValueDateTimeFormat) : null;
     }
     if ($this->calDatetimeValue) {
         $this->calDatetimeValue->DateTime = $this->objAttributeValue->DatetimeValue;
     }
     if ($this->lblDatetimeValue) {
         $this->lblDatetimeValue->Text = sprintf($this->objAttributeValue->DatetimeValue) ? $this->objAttributeValue->__toString($this->strDatetimeValueDateTimeFormat) : null;
     }
     if ($this->txtTextValue) {
         $this->txtTextValue->Text = $this->objAttributeValue->TextValue;
     }
     if ($this->lblTextValue) {
         $this->lblTextValue->Text = $this->objAttributeValue->TextValue;
     }
     if ($this->chkBooleanValue) {
         $this->chkBooleanValue->Checked = $this->objAttributeValue->BooleanValue;
     }
     if ($this->lblBooleanValue) {
         $this->lblBooleanValue->Text = $this->objAttributeValue->BooleanValue ? QApplication::Translate('Yes') : QApplication::Translate('No');
     }
     if ($this->lstSingleAttributeOption) {
         $this->lstSingleAttributeOption->RemoveAllItems();
         $this->lstSingleAttributeOption->AddItem(QApplication::Translate('- Select One -'), null);
         $objSingleAttributeOptionArray = AttributeOption::LoadAll();
         if ($objSingleAttributeOptionArray) {
             foreach ($objSingleAttributeOptionArray as $objSingleAttributeOption) {
                 $objListItem = new QListItem($objSingleAttributeOption->__toString(), $objSingleAttributeOption->Id);
                 if ($this->objAttributeValue->SingleAttributeOption && $this->objAttributeValue->SingleAttributeOption->Id == $objSingleAttributeOption->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstSingleAttributeOption->AddItem($objListItem);
             }
         }
     }
     if ($this->lblSingleAttributeOptionId) {
         $this->lblSingleAttributeOptionId->Text = $this->objAttributeValue->SingleAttributeOption ? $this->objAttributeValue->SingleAttributeOption->__toString() : null;
     }
     if ($this->lstAttributeOptionsAsMultiple) {
         $this->lstAttributeOptionsAsMultiple->RemoveAllItems();
         $objAssociatedArray = $this->objAttributeValue->GetAttributeOptionAsMultipleArray();
         $objAttributeOptionArray = AttributeOption::LoadAll();
         if ($objAttributeOptionArray) {
             foreach ($objAttributeOptionArray as $objAttributeOption) {
                 $objListItem = new QListItem($objAttributeOption->__toString(), $objAttributeOption->Id);
                 foreach ($objAssociatedArray as $objAssociated) {
                     if ($objAssociated->Id == $objAttributeOption->Id) {
                         $objListItem->Selected = true;
                     }
                 }
                 $this->lstAttributeOptionsAsMultiple->AddItem($objListItem);
             }
         }
     }
     if ($this->lblAttributeOptionsAsMultiple) {
         $objAssociatedArray = $this->objAttributeValue->GetAttributeOptionAsMultipleArray();
         $strItems = array();
         foreach ($objAssociatedArray as $objAssociated) {
             $strItems[] = $objAssociated->__toString();
         }
         $this->lblAttributeOptionsAsMultiple->Text = implode($strGlue, $strItems);
     }
 }
Esempio n. 3
0
 protected static function GenerateAttributesForPerson($objPerson)
 {
     foreach (Attribute::LoadAll() as $objAttribute) {
         if (!rand(0, 3)) {
             switch ($objAttribute->AttributeDataTypeId) {
                 case AttributeDataType::Text:
                     $mixData = QDataGen::GenerateTitle(5, 25);
                     break;
                 case AttributeDataType::Checkbox:
                     $mixData = rand(0, 1) ? true : false;
                     break;
                 case AttributeDataType::Date:
                     $mixData = QDataGen::GenerateDateTime(self::$LifeStartDate, QDateTime::Now());
                     break;
                 case AttributeDataType::ImmutableSingleDropdown:
                 case AttributeDataType::MutableSingleDropdown:
                     $mixData = QDataGen::GenerateFromArray($objAttribute->GetAttributeOptionArray());
                     break;
                 case AttributeDataType::ImmutableMultipleDropdown:
                 case AttributeDataType::MutableMultipleDropdown:
                     $mixData = array();
                     while (!count($mixData)) {
                         foreach ($objAttribute->GetAttributeOptionArray() as $objAttributeOption) {
                             if (rand(0, 1)) {
                                 $mixData[] = $objAttributeOption;
                             }
                         }
                     }
                     break;
                 default:
                     throw new Exception('Unhandled Attribute Data Type');
             }
             $objPerson->SetAttribute($objAttribute, $mixData);
         }
     }
 }
<?php

foreach (Attribute::LoadAll() as $objAttribute) {
    $objNodes = QueryNode::QueryArray(QQ::AndCondition(QQ::Equal(QQN::QueryNode()->QueryNodeTypeId, QueryNodeType::AttributeNode), QQ::Equal(QQN::QueryNode()->NodeDetail, $objAttribute->Id)));
    if (count($objNodes)) {
        foreach ($objNodes as $objQueryNode) {
            $objQueryNode->Name = $objAttribute->Name;
            $objQueryNode->QcodoQueryNode = null;
            $objQueryNode->QueryNodeTypeId = QueryNodeType::AttributeNode;
            $objQueryNode->QueryDataTypeId = AttributeDataType::$QueryDataTypeArray[$objAttribute->AttributeDataTypeId];
            $objQueryNode->NodeDetail = $objAttribute->Id;
            $objQueryNode->Save();
        }
    } else {
        $objQueryNode = new QueryNode();
        $objQueryNode->Name = $objAttribute->Name;
        $objQueryNode->QcodoQueryNode = null;
        $objQueryNode->QueryNodeTypeId = QueryNodeType::AttributeNode;
        $objQueryNode->QueryDataTypeId = AttributeDataType::$QueryDataTypeArray[$objAttribute->AttributeDataTypeId];
        $objQueryNode->NodeDetail = $objAttribute->Id;
        $objQueryNode->Save();
    }
}
Esempio n. 5
0
 public function dtgAttributes_Bind()
 {
     $objExisting = array();
     foreach ($this->objPerson->GetAttributeValueArray() as $objAttributeValue) {
         $objExisting[$objAttributeValue->AttributeId] = true;
     }
     $objAttributeArray = array();
     foreach (Attribute::LoadAll(QQ::OrderBy(QQN::Attribute()->Name)) as $objAttribute) {
         if (!array_key_exists($objAttribute->Id, $objExisting)) {
             $objAttributeArray[] = $objAttribute;
         }
     }
     $this->iAttributeCount = count($objAttributeArray);
     $this->dtgAttributes->DataSource = $objAttributeArray;
 }