本文整理汇总了PHP中QQN::AttributeOption方法的典型用法代码示例。如果您正苦于以下问题:PHP QQN::AttributeOption方法的具体用法?PHP QQN::AttributeOption怎么用?PHP QQN::AttributeOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQN
的用法示例。
在下文中一共展示了QQN::AttributeOption方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: RenderValue
public function RenderValue(AttributeValue $objValue)
{
switch ($objValue->Attribute->AttributeDataTypeId) {
case AttributeDataType::Text:
return QApplication::HtmlEntities($objValue->TextValue);
case AttributeDataType::Checkbox:
return $objValue->BooleanValue ? 'Yes' : 'No';
case AttributeDataType::Date:
return $objValue->DateValue->ToString('MMMM D, YYYY');
case AttributeDataType::DateTime:
return $objValue->DatetimeValue->ToString('MMMM D, YYYY') . ' at ' . $objValue->DatetimeValue->ToString('h:mmz');
case AttributeDataType::ImmutableSingleDropdown:
case AttributeDataType::MutableSingleDropdown:
return $objValue->SingleAttributeOption != null ? QApplication::HtmlEntities($objValue->SingleAttributeOption->Name) : ' ';
case AttributeDataType::ImmutableMultipleDropdown:
case AttributeDataType::MutableMultipleDropdown:
$strArray = array();
foreach ($objValue->GetAttributeOptionAsMultipleArray(QQ::OrderBy(QQN::AttributeOption()->Name)) as $objOption) {
$strArray[] = '• ' . QApplication::HtmlEntities($objOption->Name);
}
return implode('<br/>', $strArray);
default:
throw new Exception('Unhandled Attribute Data Type');
}
}
示例2: Form_Create
protected function Form_Create()
{
$this->mctAttribute = AttributeMetaControl::Create($this, QApplication::PathInfo(0));
$this->strPageTitle = 'Administration - ' . ($this->mctAttribute->EditMode ? 'Edit' : 'Create New') . ' Attribute';
$this->txtName = $this->mctAttribute->txtName_Create();
$this->txtName->Required = true;
$this->lstAttributeDataType = $this->mctAttribute->lstAttributeDataType_Create();
if ($this->mctAttribute->EditMode) {
$this->lstAttributeDataType->Enabled = false;
}
$this->btnSave = new QButton($this);
$this->btnSave->Text = $this->mctAttribute->EditMode ? 'Update' : 'Create';
$this->btnSave->CssClass = 'primary';
$this->btnSave->AddAction(new QClickEvent(), new QAjaxAction('btnSave_Click'));
$this->btnSave->CausesValidation = true;
$this->btnCancel = new QLinkButton($this);
$this->btnCancel->Text = 'Cancel';
$this->btnCancel->CssClass = 'cancel';
$this->btnCancel->AddAction(new QClickEvent(), new QAjaxAction('btnCancel_Click'));
$this->btnCancel->AddAction(new QClickEvent(), new QTerminateAction());
switch ($this->mctAttribute->Attribute->AttributeDataTypeId) {
case AttributeDataType::ImmutableMultipleDropdown:
case AttributeDataType::ImmutableSingleDropdown:
case AttributeDataType::MutableMultipleDropdown:
case AttributeDataType::MutableSingleDropdown:
$this->pnlAttributeOptions = new QPanel($this);
$this->pnlAttributeOptions->AutoRenderChildren = true;
$this->btnAddMore = new QLinkButton($this);
$this->btnAddMore->Name = ' ';
$this->btnAddMore->Text = 'Add More Dropbox Values';
$this->btnAddMore->ForeColor = '#999';
$this->btnAddMore->AddAction(new QClickEvent(), new QAjaxAction('btnAddMore_Click'));
$this->btnAddMore->AddAction(new QClickEvent(), new QTerminateAction());
break;
}
if ($this->mctAttribute->EditMode) {
$this->btnDelete = new QLinkButton($this);
$this->btnDelete->Text = 'Delete';
$this->btnDelete->CssClass = 'delete';
$intCount = $this->mctAttribute->Attribute->CountAttributeValues();
$strConfirmText = sprintf('Are you SURE you want to permanently DELETE this Attribute? There are %s individual%s that have a value for this attribute which would be removed.', $intCount, $intCount == 1 ? '' : 's');
$this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction($strConfirmText));
$this->btnDelete->AddAction(new QClickEvent(), new QAjaxAction('btnDelete_Click'));
$this->btnDelete->AddAction(new QClickEvent(), new QTerminateAction());
if ($this->pnlAttributeOptions) {
foreach ($this->mctAttribute->Attribute->GetAttributeOptionArray(QQ::OrderBy(QQN::AttributeOption()->Name)) as $objAttributeOption) {
$this->pnlAttributeOptions_AddOption($objAttributeOption);
}
}
}
if ($this->pnlAttributeOptions) {
$this->pnlAttributeOptions_AddOption(null);
$this->pnlAttributeOptions_AddOption(null);
}
}
示例3: Form_Create
protected function Form_Create()
{
$this->strInitialToken = QApplication::PathInfo(0);
if ($this->strInitialToken) {
$this->objList = CommunicationList::LoadByToken($this->strInitialToken);
}
$this->chkBtnListArray = array();
foreach (CommunicationList::LoadArrayBySubscribable(true, QQ::OrderBy(QQN::CommunicationList()->Token)) as $objEmailList) {
$objItemList = new QCheckBox($this);
$objItemList->Name = $objEmailList->Token;
$objItemList->Text = $objEmailList->Name;
if ($objEmailList->Token == $this->strInitialToken) {
$objItemList->Checked = true;
}
$this->chkBtnListArray[] = $objItemList;
}
$this->txtEmail = new QTextBox($this);
$this->txtEmail->Name = 'Email: ';
$this->txtEmail->Visible = true;
$this->lstTerminationReason = new QListBox($this);
$this->lstTerminationReason->Name = 'Reason for unsubscribing: ';
$this->objAttribute = Attribute::QuerySingle(QQ::Equal(QQN::Attribute()->Name, 'Unsubscribe From Church Newsletter'));
foreach ($this->objAttribute->GetAttributeOptionArray(QQ::OrderBy(QQN::AttributeOption()->Name)) as $objOption) {
$this->lstTerminationReason->AddItem($objOption->Name, $objOption->Id);
}
$this->lstTerminationReason->AddItem('- Other... -', -1);
$this->lstTerminationReason->AddAction(new QChangeEvent(), new QAjaxAction('lstTerminationReason_Change'));
$this->txtOther = new QTextBox($this);
$this->txtOther->Name = 'Other';
$this->txtOther->Visible = false;
$this->btnUnsubscribe = new QButton($this);
$this->btnUnsubscribe->Name = 'Unsubscribe';
$this->btnUnsubscribe->Text = 'Unsubscribe';
$this->btnUnsubscribe->CssClass = 'primary';
$this->btnUnsubscribe->AddAction(new QClickEvent(), new QAjaxAction('btnUnsubscribe_Click'));
$this->lblMessage = new QLabel($this);
$this->lblMessage->FontBold = true;
$this->lblMessage->ForeColor = 'red';
$this->lblMessage->Visible = false;
}
示例4: GetCustomControlForAttributeNode
protected function GetCustomControlForAttributeNode(QPanel $pnlValue, $strControlId, $strCurrentValue)
{
// Get the Attribute object we are trying to query against
$objAttribute = Attribute::Load($this->NodeDetail);
$ctlValue = new QListBox($pnlValue, $strControlId);
foreach ($objAttribute->GetAttributeOptionArray(QQ::OrderBy(QQN::AttributeOption()->Name)) as $objOption) {
$ctlValue->AddItem($objOption->Name, $objOption->Id, $objOption->Id == $strCurrentValue);
}
return $ctlValue;
}
示例5: SetupPanel
protected function SetupPanel()
{
$this->objAttributeValue = AttributeValue::LoadByAttributeIdPersonId($this->strUrlHashArgument, $this->objPerson->Id);
if (!$this->objAttributeValue) {
$this->objAttributeValue = new AttributeValue();
$this->objAttributeValue->AttributeId = $this->strUrlHashArgument;
$this->objAttributeValue->Person = $this->objPerson;
} else {
$this->btnDelete = new QLinkButton($this);
$this->btnDelete->Text = 'Delete';
$this->btnDelete->CssClass = 'delete';
$this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction('Are you SURE you want to DELETE this attribute?'));
$this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
$this->btnDelete->AddAction(new QClickEvent(), new QTerminateAction());
}
switch ($this->objAttributeValue->Attribute->AttributeDataTypeId) {
case AttributeDataType::Checkbox:
$this->chkValue = new QRadioButtonList($this);
$this->chkValue->Name = $this->objAttributeValue->Attribute->Name;
$this->chkValue->Required = true;
$this->chkValue->AddItem('Yes', true, $this->objAttributeValue->BooleanValue === true);
$this->chkValue->AddItem('No', false, $this->objAttributeValue->BooleanValue === false);
break;
case AttributeDataType::Date:
case AttributeDataType::DateTime:
$this->dtxValue = new QDateTimeTextBox($this);
$this->dtxValue->Name = $this->objAttributeValue->Attribute->Name;
$this->dtxValue->Required = true;
if ($this->objAttributeValue->Attribute->AttributeDataTypeId == AttributeDataType::Date) {
$this->dtxValue->Text = $this->objAttributeValue->DateValue ? $this->objAttributeValue->DateValue->ToString() : null;
} else {
$this->dtxValue->Text = $this->objAttributeValue->DatetimeValue ? $this->objAttributeValue->DatetimeValue->ToString() : null;
}
$this->calValue = new QCalendar($this, $this->dtxValue);
$this->dtxValue->RemoveAllActions(QClickEvent::EventName);
break;
case AttributeDataType::Text:
$this->txtValue = new QTextBox($this);
$this->txtValue->Name = $this->objAttributeValue->Attribute->Name;
$this->txtValue->Required = true;
$this->txtValue->TextMode = QTextMode::MultiLine;
$this->txtValue->Text = trim($this->objAttributeValue->TextValue);
$this->txtValue->FontNames = QFontFamily::Arial;
$this->txtValue->FontSize = '11px';
$this->txtValue->Width = '400px';
$this->txtValue->Height = '200px';
break;
case AttributeDataType::ImmutableSingleDropdown:
$this->lstValue = new QListBox($this);
$this->lstValue->Name = $this->objAttributeValue->Attribute->Name;
$this->lstValue->Required = true;
if (!$this->objAttributeValue->SingleAttributeOptionId) {
$this->lstValue->AddItem('- Select One -');
}
foreach ($this->objAttributeValue->Attribute->GetAttributeOptionArray(QQ::OrderBy(QQN::AttributeOption()->Name)) as $objOption) {
$this->lstValue->AddItem($objOption->Name, $objOption->Id, $objOption->Id == $this->objAttributeValue->SingleAttributeOptionId);
}
break;
case AttributeDataType::ImmutableMultipleDropdown:
$this->lstValue = new QListBox($this);
$this->lstValue->Name = $this->objAttributeValue->Attribute->Name;
$this->lstValue->Required = true;
$this->lstValue->SelectionMode = QSelectionMode::Multiple;
$this->lstValue->Width = '200px';
$this->lstValue->Height = '200px';
$intSelectedIdArray = array();
if ($this->objAttributeValue->Id) {
foreach ($this->objAttributeValue->GetAttributeOptionAsMultipleArray() as $objOption) {
$intSelectedIdArray[$objOption->Id] = $objOption->Id;
}
}
foreach ($this->objAttributeValue->Attribute->GetAttributeOptionArray(QQ::OrderBy(QQN::AttributeOption()->Name)) as $objOption) {
$this->lstValue->AddItem($objOption->Name, $objOption->Id, array_key_exists($objOption->Id, $intSelectedIdArray));
}
break;
case AttributeDataType::MutableSingleDropdown:
$this->lstValue = new QListBox($this);
$this->lstValue->Name = $this->objAttributeValue->Attribute->Name;
$this->lstValue->Required = true;
if (!$this->objAttributeValue->SingleAttributeOptionId) {
$this->lstValue->AddItem('- Select One -');
}
foreach ($this->objAttributeValue->Attribute->GetAttributeOptionArray(QQ::OrderBy(QQN::AttributeOption()->Name)) as $objOption) {
$this->lstValue->AddItem($objOption->Name, $objOption->Id, $objOption->Id == $this->objAttributeValue->SingleAttributeOptionId);
}
$this->lstValue->AddItem('- Other... -', -1);
$this->txtAddItem = new QTextBox($this);
$this->txtAddItem->Name = 'Add a Value';
$this->txtAddItem->Visible = false;
$this->lstValue->AddAction(new QChangeEvent(), new QAjaxControlAction($this, 'lstValue_Change'));
$this->txtAddItem->AddAction(new QEnterKeyEvent(), new QTerminateAction());
break;
case AttributeDataType::MutableMultipleDropdown:
$this->lstValue = new QListBox($this);
$this->lstValue->Name = $this->objAttributeValue->Attribute->Name;
$this->lstValue->Required = true;
$this->lstValue->SelectionMode = QSelectionMode::Multiple;
$this->lstValue->Width = '200px';
$this->lstValue->Height = '200px';
$intSelectedIdArray = array();
//.........这里部分代码省略.........
示例6: btnEditAttribute_Click
public function btnEditAttribute_Click($strFormId, $strControlId, $strParameter)
{
$paramArray = explode("_", $strParameter);
// First, remove all children panels from pnlRight
$this->pnlRight->Display = "block";
$this->pnlRight->DisplayStyle = "block";
$this->pnlRight->RemoveChildControls(true);
// Determine where to display the panel
$range = 1;
if ($paramArray[3] < 5) {
$range = 1;
} elseif ($paramArray[3] < 15) {
$range = 2;
} else {
$range = 3;
}
$height = $this->iAttributeCount / $range * 35;
$this->strAttributeHeight = sprintf("-%dpx", $height);
$this->pnlRight->Top = $this->strAttributeHeight;
// Now create a new AttributeEditPanel, setting pnlRight as its parent
// and specifying parent form's "CloseRightPanel" as the method callback
// See the note in _constructor, above, for more information
/*new Vicp_Attributes_Edit($this->pnlRight, null, $this->objPerson,$this->strUrlHashArgument);*/
// Test to see if it works
// Special case for Co-Primary. If co-primary, then ensure there is a date of birth
if ($paramArray[2] == 'Co-Primary' && !$this->objPerson->DateOfBirth) {
$this->lblTitle = new QLabel($this->pnlRight);
$this->lblTitle->HtmlEntities = false;
$this->lblTitle->Text = "You cannot specify a Co-primary email unless the person has a Date Of Birth specified. <br>Please ensure that this is the case before setting this attribute.";
} else {
$this->objAttributeValue = AttributeValue::LoadByAttributeIdPersonId($strParameter, $this->objPerson->Id);
if (!$this->objAttributeValue) {
$this->objAttributeValue = new AttributeValue();
$this->objAttributeValue->AttributeId = $paramArray[0];
$this->objAttributeValue->Person = $this->objPerson;
$this->objAttributeValue->Attribute = Attribute::Load($paramArray[0]);
}
// Determine what to display
$this->lblTitle = new QLabel($this->pnlRight);
$this->lblTitle->Text = $paramArray[2];
if ($paramArray[2] == 'Co-Primary') {
$this->lblTitle->HtmlEntities = false;
$this->lblTitle->Text .= '<br>Please not that the Co-Primary email entered MUST be an existing person in noah.';
}
$this->lblTitle->CssClass = 'attributeLbl';
switch ($paramArray[1]) {
case AttributeDataType::Checkbox:
$this->chkValue = new QRadioButtonList($this->pnlRight);
$this->chkValue->Name = $paramArray[2];
$this->chkValue->Required = true;
$this->chkValue->AddItem('Yes', true, $this->objAttributeValue->BooleanValue === true);
$this->chkValue->AddItem('No', false, $this->objAttributeValue->BooleanValue === false);
break;
case AttributeDataType::Date:
case AttributeDataType::DateTime:
$this->dtxValue = new QDateTimeTextBox($this->pnlRight);
$this->dtxValue->Name = $paramArray[2];
$this->dtxValue->Required = true;
$this->calValue = new QCalendar($this->pnlRight, $this->dtxValue);
$this->dtxValue->RemoveAllActions(QClickEvent::EventName);
if ($this->objAttributeValue->Attribute->AttributeDataTypeId == AttributeDataType::Date) {
$this->dtxValue->Text = $this->objAttributeValue->DateValue ? $this->objAttributeValue->DateValue->ToString() : null;
} else {
$this->dtxValue->Text = $this->objAttributeValue->DatetimeValue ? $this->objAttributeValue->DatetimeValue->ToString() : null;
}
break;
case AttributeDataType::Text:
$this->txtValue = new QTextBox($this->pnlRight);
$this->txtValue->Name = $paramArray[2];
$this->txtValue->Required = true;
$this->txtValue->TextMode = QTextMode::MultiLine;
$this->txtValue->Text = trim($this->objAttributeValue->TextValue);
$this->txtValue->FontNames = QFontFamily::Arial;
$this->txtValue->FontSize = '11px';
$this->txtValue->Width = '380px';
$this->txtValue->Height = '200px';
break;
case AttributeDataType::ImmutableSingleDropdown:
$this->lstValue = new QListBox($this->pnlRight);
$this->lstValue->Name = $paramArray[2];
$this->lstValue->Required = true;
if (!$this->objAttributeValue->SingleAttributeOptionId) {
$this->lstValue->AddItem('- Select One -');
}
foreach ($this->objAttributeValue->Attribute->GetAttributeOptionArray(QQ::OrderBy(QQN::AttributeOption()->Name)) as $objOption) {
$this->lstValue->AddItem($objOption->Name, $objOption->Id, $objOption->Id == $this->objAttributeValue->SingleAttributeOptionId);
}
break;
case AttributeDataType::ImmutableMultipleDropdown:
$this->lstValue = new QListBox($this->pnlRight);
$this->lstValue->Name = $paramArray[2];
$this->lstValue->Required = true;
$this->lstValue->SelectionMode = QSelectionMode::Multiple;
$this->lstValue->Width = '200px';
$this->lstValue->Height = '200px';
$intSelectedIdArray = array();
if ($this->objAttributeValue->Id) {
foreach ($this->objAttributeValue->GetAttributeOptionAsMultipleArray() as $objOption) {
$intSelectedIdArray[$objOption->Id] = $objOption->Id;
}
//.........这里部分代码省略.........
示例7: ResolveContentItem
/**
* Used internally by the Meta-based Add Column tools.
*
* Given a QQNode or a Text String, this will return a AttributeOption-based QQNode.
* It will also verify that it is a proper AttributeOption-based QQNode, and will throw an exception otherwise.
*
* @param mixed $mixContent
* @return QQNode
*/
protected function ResolveContentItem($mixContent)
{
if ($mixContent instanceof QQNode) {
if (!$mixContent->_ParentNode) {
throw new QCallerException('Content QQNode cannot be a Top Level Node');
}
if ($mixContent->_RootTableName == 'attribute_option') {
if ($mixContent instanceof QQReverseReferenceNode && !$mixContent->_PropertyName) {
throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
}
$objCurrentNode = $mixContent;
while ($objCurrentNode = $objCurrentNode->_ParentNode) {
if (!$objCurrentNode instanceof QQNode) {
throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
}
if ($objCurrentNode instanceof QQReverseReferenceNode && !$objCurrentNode->_PropertyName) {
throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
}
}
return $mixContent;
} else {
throw new QCallerException('Content QQNode has a root table of "' . $mixContent->_RootTableName . '". Must be a root of "attribute_option".');
}
} else {
if (is_string($mixContent)) {
switch ($mixContent) {
case 'Id':
return QQN::AttributeOption()->Id;
case 'AttributeId':
return QQN::AttributeOption()->AttributeId;
case 'Attribute':
return QQN::AttributeOption()->Attribute;
case 'Name':
return QQN::AttributeOption()->Name;
default:
throw new QCallerException('Simple Property not found in AttributeOptionDataGrid content: ' . $mixContent);
}
} else {
if ($mixContent instanceof QQAssociationNode) {
throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
} else {
throw new QCallerException('Invalid Content type');
}
}
}
}
示例8: IsAttributeValueAsMultipleAssociated
/**
* Checks to see if an association exists with a specific AttributeValueAsMultiple
* @param AttributeValue $objAttributeValue
* @return bool
*/
public function IsAttributeValueAsMultipleAssociated(AttributeValue $objAttributeValue)
{
if (is_null($this->intId)) {
throw new QUndefinedPrimaryKeyException('Unable to call IsAttributeValueAsMultipleAssociated on this unsaved AttributeOption.');
}
if (is_null($objAttributeValue->Id)) {
throw new QUndefinedPrimaryKeyException('Unable to call IsAttributeValueAsMultipleAssociated on this AttributeOption with an unsaved AttributeValue.');
}
$intRowCount = AttributeOption::QueryCount(QQ::AndCondition(QQ::Equal(QQN::AttributeOption()->Id, $this->intId), QQ::Equal(QQN::AttributeOption()->AttributeValueAsMultiple->AttributeValueId, $objAttributeValue->Id)));
return $intRowCount > 0;
}