public function __construct($objParentObject, $strControlId = null, StewardshipBatch $objBatch, StewardshipStack $objStack = null, $strUrlHashArgument1 = null, $strUrlHashArgument2 = null, $strUrlHashArgument3 = null) { try { parent::__construct($objParentObject, $strControlId); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } $this->strTemplate = dirname(__FILE__) . '/' . get_class($this) . '.tpl.php'; $this->objBatch = $objBatch; $this->objStack = $objStack; $this->strUrlHashArgument = $strUrlHashArgument1; $this->strUrlHashArgument2 = $strUrlHashArgument2; $this->strUrlHashArgument3 = $strUrlHashArgument3; $this->btnSave = new QButton($this); $this->btnSave->Text = 'Save'; $this->btnSave->CssClass = 'primary'; $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click')); $this->btnSave->CausesValidation = $this; $this->btnCancel = new QLinkButton($this); $this->btnCancel->Text = 'Cancel'; $this->btnCancel->CssClass = 'cancel'; $this->btnCancel->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCancel_Click')); $this->btnCancel->AddAction(new QClickEvent(), new QTerminateAction()); $this->SetupPanel(); }
public function dtg_ButtonRender($item) { $strControl = new QButton($this); $strControl->Text = 'Button'; $strControl->ActionParameter = $item; $strControl->AddAction(new QClickEvent(), new QServerAction('btn_click')); return $strControl->Render(false); }
protected function Form_Create() { // default legacy protection, will throw an exception $this->txtTextbox1 = new QTextbox($this); $this->txtTextbox1->Text = 'Hello!'; $this->txtTextbox1->Width = 500; $this->lblLabel1 = new QLabel($this); $this->lblLabel1->HtmlEntities = false; $this->lblLabel1->Text = ""; $this->btnButton1 = new QButton($this); $this->btnButton1->Text = "Parse and Display"; $this->btnButton1->AddAction(new QClickEvent(), new QAjaxAction('btnButton1_Click')); // htmlentities mode $this->txtTextbox2 = new QTextbox($this); $this->txtTextbox2->CrossScripting = QCrossScripting::HtmlEntities; $this->txtTextbox2->Text = 'Hello! <script>alert("I am an evil attacker.")</script>'; $this->txtTextbox2->Width = 500; $this->lblLabel2 = new QLabel($this); $this->lblLabel2->Text = ""; $this->btnButton2 = new QButton($this); $this->btnButton2->Text = "Parse and Display"; $this->btnButton2->AddAction(new QClickEvent(), new QAjaxAction('btnButton2_Click')); // full protection with the HTMLPurifier defaults $this->txtTextbox3 = new QTextbox($this); $this->txtTextbox3->CrossScripting = QCrossScripting::HTMLPurifier; $this->txtTextbox3->Text = 'Hello! <script>alert("I am an evil attacker.")</script>'; $this->txtTextbox3->Width = 500; $this->lblLabel3 = new QLabel($this); $this->lblLabel3->Text = ""; $this->btnButton3 = new QButton($this); $this->btnButton3->Text = "Parse and Display"; $this->btnButton3->AddAction(new QClickEvent(), new QAjaxAction('btnButton3_Click')); // full protection with an allowed list of tags $this->txtTextbox4 = new QTextbox($this); $this->txtTextbox4->CrossScripting = QCrossScripting::HTMLPurifier; $this->txtTextbox4->SetPurifierConfig("HTML.Allowed", "b,strong,i,em,img[src]"); $this->txtTextbox4->Text = 'Hello! <script>alert("I am an evil attacker.")</script><b>Hello</b> <i>again</i>!'; $this->txtTextbox4->Width = 500; $this->lblLabel4 = new QLabel($this); $this->lblLabel4->HtmlEntities = false; $this->lblLabel4->Text = ""; $this->btnButton4 = new QButton($this); $this->btnButton4->Text = "Parse and Display"; $this->btnButton4->AddAction(new QClickEvent(), new QAjaxAction('btnButton4_Click')); // the textbox won't have the XSS protection! $this->txtTextbox5 = new QTextbox($this); $this->txtTextbox5->CrossScripting = QCrossScripting::Allow; $this->txtTextbox5->Text = 'Hello! <script>alert("I am an evil attacker.")</script><b>Hello</b> again!'; $this->txtTextbox5->Width = 500; $this->lblLabel5 = new QLabel($this); $this->lblLabel5->HtmlEntities = false; $this->lblLabel5->Text = ""; $this->btnButton5 = new QButton($this); $this->btnButton5->Text = "Parse and Display"; $this->btnButton5->AddAction(new QClickEvent(), new QAjaxAction('btnButton5_Click')); }
public function dtgNotificationUserAccount_EditLinkColumn_Render(NotificationUserAccount $objNotificationUserAccount) { $strControlId = 'btnEdit' . $this->dtgNotificationUserAccount->CurrentRowIndex; $btnEdit = $this->objForm->GetControl($strControlId); if (!$btnEdit) { $btnEdit = new QButton($this->dtgNotificationUserAccount, $strControlId); $btnEdit->Text = QApplication::Translate('Edit'); $btnEdit->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnEdit_Click')); } $btnEdit->ActionParameter = $objNotificationUserAccount->NotificationUserAccountId; return $btnEdit->Render(false); }
public function dtgDatagrid_EditLinkColumn_Render(Datagrid $objDatagrid) { $strControlId = 'btnEdit' . $this->dtgDatagrid->CurrentRowIndex; $btnEdit = $this->objForm->GetControl($strControlId); if (!$btnEdit) { $btnEdit = new QButton($this->dtgDatagrid, $strControlId); $btnEdit->Text = QApplication::Translate('Edit'); $btnEdit->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnEdit_Click')); } $btnEdit->ActionParameter = $objDatagrid->DatagridId; return $btnEdit->Render(false); }
public function renderButton(Person $objPerson) { $objControlId = "editButton" . $objPerson->Id; if (!($objControl = $this->GetControl($objControlId))) { $objControl = new QButton($this, $objControlId); $objControl->Text = "Edit Person #" . $objPerson->Id; $objControl->AddAction(new QClickEvent(), new QAjaxAction("renderButton_Click")); $objControl->ActionParameter = $objPerson->Id; } // We pass the parameter of "false" to make sure the control doesn't render // itself RIGHT HERE - that it instead returns its string rendering result. return $objControl->Render(false); }
/** * A non-delegated event version. Create a new button for each control and attach an action to it. * * @param Person $objPerson * @return String */ public function RenderDeleteButton($objPerson) { $strControlId = 'btn' . $objPerson->Id; $objControl = $this->GetControl($strControlId); if (!$objControl) { $objControl = new QButton($this); $objControl->Text = 'Edit'; $objControl->ActionParameter = $objPerson->Id; $objControl->AddAction(new QClickEvent(), new QAjaxAction('dtgPersonsButton_Click')); // This will generate a javascript call for every button created. } return $objControl->Render(false); }
public function lnkSelected_Render(Praises $objPraise) { $strControlId = 'lnkSelected' . $objPraise->Id; // Let's see if the Checkbox exists already $lnkSelected = $this->GetControl($strControlId); if (!$lnkSelected) { $lnkSelected = new QButton($this->dtgPraises, $strControlId); $lnkSelected->Text = $objPraise->Subject; $lnkSelected->ActionParameter = $objPraise->Id; $lnkSelected->CssClass = 'linkButton'; $lnkSelected->AddAction(new QClickEvent(), new QServerAction('lnkSelected_Click')); } return $lnkSelected->Render(false); }
public function __construct($objParentObject, $strControlId = null, Person $objPerson = null, $strUrlHashArgument) { try { parent::__construct($objParentObject, $strControlId); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } $this->strTemplate = dirname(__FILE__) . '/../' . $this->objForm->strSubNavItemArray[$this->objForm->strSubNavItemToken][1] . '/' . get_class($this) . '.tpl.php'; $this->objPerson = $objPerson; $this->strUrlHashArgument = $strUrlHashArgument; $this->btnSave = new QButton($this); $this->btnSave->Text = 'Save'; $this->btnSave->CssClass = 'primary'; $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click')); $this->btnSave->CausesValidation = $this; $this->btnCancel = new QLinkButton($this); $this->btnCancel->Text = 'Cancel'; $this->btnCancel->CssClass = 'cancel'; $this->btnCancel->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCancel_Click')); $this->btnCancel->AddAction(new QClickEvent(), new QTerminateAction()); $this->SetupPanel(); }
public function EditColumn_Render(Attribute $objAttribute) { // Let's specify a specific Control ID for our button, using the datagrid's CurrentRowIndex $strControlId = 'btnEditAttribute' . $this->dtgAttributes->CurrentRowIndex; $btnEdit = $this->objForm->GetControl($strControlId); if (!$btnEdit) { // Only create/instantiate a new Edit button for this Row if it doesn't yet exist $btnEdit = new QButton($this->dtgAttributes, $strControlId); $btnEdit->Text = 'Add'; $btnEdit->CssClass = 'primary'; // Define an Event Handler on the Button // Because the event handler, itself, is defined in the control, we use QAjaxControlAction instead of QAjaxAction $btnEdit->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnEditAttribute_Click')); } // Finally, update the Actionparameter for our button to store the $objAttribute's ID. $btnEdit->ActionParameter = $objAttribute->Id . "_" . $objAttribute->AttributeDataTypeId . "_" . $objAttribute->Name . "_" . $this->dtgAttributes->CurrentRowIndex; // Return the Rendered Button Control return $btnEdit->Render(false); }
/** * Sets up the EmailMessageRouteDataGrid if there are messages associated with this group * @return void */ protected function SetupEmailMessageControls() { $this->dtgEmailMessageRoute = new EmailMessageRouteDataGrid($this); $this->dtgEmailMessageRoute->MetaAddColumn(QQN::EmailMessageRoute()->EmailMessage->DateReceived, 'Width=115px', 'FontSize=11px', 'Html=<?= $_CONTROL->ParentControl->RenderEmailDateReceived($_ITEM); ?>'); $this->dtgEmailMessageRoute->MetaAddColumn(QQN::EmailMessageRoute()->EmailMessage->FromAddress, 'Width=200px', 'FontSize=11px', 'Html=<?= $_CONTROL->ParentControl->RenderEmailFromAddress($_ITEM); ?>', 'HtmlEntities=false'); $this->dtgEmailMessageRoute->MetaAddColumn(QQN::EmailMessageRoute()->EmailMessage->Subject, 'Width=420px', 'FontSize=11px', 'Html=<?= $_CONTROL->ParentControl->RenderEmailSubject($_ITEM); ?>', 'HtmlEntities=false'); $this->dtgEmailMessageRoute->SetDataBinder('dtgEmailMessageRoute_Bind', $this); $this->dtgEmailMessageRoute->Paginator = new QPaginator($this->dtgEmailMessageRoute); $this->dtgEmailMessageRoute->SortColumnIndex = 0; $this->dtgEmailMessageRoute->SortDirection = 1; $this->dlgEmailMessage = new QDialogBox($this); $this->dlgEmailMessage->Template = dirname(__FILE__) . '/dlgEmailMessage.tpl.php'; $this->dlgEmailMessage->HideDialogBox(); $this->btnEmailMessage = new QButton($this->dlgEmailMessage); $this->btnEmailMessage->Text = 'Close'; $this->btnEmailMessage->AddAction(new QClickEvent(), new QHideDialogBox($this->dlgEmailMessage)); $this->pxyEmailMessage = new QControlProxy($this); $this->pxyEmailMessage->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'pxyEmailMessage_Click')); $this->pxyEmailMessage->AddAction(new QClickEvent(), new QTerminateAction()); }
public function render_btnToggleRecordsSummary(Project $objProject) { // Create their unique id... $objControlId = 'btnToggleRecordsSummary' . $objProject->Id; if (!($objControl = $this->GetControl($objControlId))) { $intTeamMemberCount = Person::CountByProjectAsTeamMember($objProject->Id); if ($intTeamMemberCount > 0) { // If not exists create our toggle button who his parent // is our master QDataGrid... $objControl = new QButton($this->dtgProjects, $objControlId); $objControl->Width = 25; $objControl->Text = '+' . $intTeamMemberCount; $objControl->CssClass = 'inputbutton'; // Pass the id of the bounded item just for other process // on click event $objControl->ActionParameter = $objProject->Id; // Add event on click the toogle button $objControl->AddAction(new QClickEvent(), new QAjaxAction('btnToggleRecordsSummary_Click')); } } // We pass the parameter of "false" to make sure the control doesn't render // itself RIGHT HERE - that it instead returns its string rendering result. return $objControl->Render(false); }
public function RemoveColumn_Render(InventoryLocation $objInventoryLocation) { // If the transaction is a Move or a Take Out, use the InventoryLocationId as the Action Parameter if ($this->ctlInventoryTransact->intTransactionTypeId == 1 || $this->ctlInventoryTransact->intTransactionTypeId == 5) { $strControlId = 'btnRemove' . $objInventoryLocation->InventoryLocationId; } elseif ($this->ctlInventoryTransact->intTransactionTypeId == 4) { $strControlId = 'btnRemove' . $objInventoryLocation->InventoryModelId; } $btnRemove = $this->GetControl($strControlId); if (!$btnRemove) { // Create the Remove button for this row in the DataGrid // Use ActionParameter to specify the ID of the InventoryLocation or InventoryModelId, depending on the transaction type $btnRemove = new QButton($this->ctlInventoryTransact->dtgInventoryTransact, $strControlId); $btnRemove->Text = 'Remove'; // If the transaction is a Move or a Take Out, use the InventoryLocationId as the Action Parameter if ($this->ctlInventoryTransact->intTransactionTypeId == 1 || $this->ctlInventoryTransact->intTransactionTypeId == 5) { $btnRemove->ActionParameter = $objInventoryLocation->InventoryLocationId; } elseif ($this->ctlInventoryTransact->intTransactionTypeId == 4) { $btnRemove->ActionParameter = $objInventoryLocation->InventoryModelId; } $btnRemove->AddAction(new QClickEvent(), new QAjaxAction('btnRemove_Click')); $btnRemove->AddAction(new QEnterKeyEvent(), new QAjaxAction('btnRemove_Click')); $btnRemove->AddAction(new QEnterKeyEvent(), new QTerminateAction()); $btnRemove->CausesValidation = false; } return $btnRemove->Render(false); }
public function dtgUserRole_ActionsColumn_Render(NarroUserRole $objUserRole) { $strControlId = 'btnEditRole' . $objUserRole->UserRoleId; $btnEdit = $this->Form->GetControl($strControlId); if (!$btnEdit) { $btnEdit = new QButton($this->dtgUserRole, $strControlId); $btnEdit->Text = t('Edit'); if (QApplication::$UseAjax) { $btnEdit->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnEditRole_Click')); } else { $btnEdit->AddAction(new QClickEvent(), new QServerControlAction($this, 'btnEditRole_Click')); } } $btnEdit->ActionParameter = $objUserRole->UserRoleId; $btnEdit->Display = QApplication::HasPermission('Can manage user roles', $objUserRole->ProjectId, $objUserRole->LanguageId); $strControlId = 'btnDeleteRole' . $objUserRole->UserRoleId; $btnDelete = $this->Form->GetControl($strControlId); if (!$btnDelete) { $btnDelete = new QButton($this->dtgUserRole, $strControlId); $btnDelete->Text = t('Delete'); $btnDelete->AddAction(new QClickEvent(), new QConfirmAction(t('Are you sure you want to revoke this role for this user?'))); if (QApplication::$UseAjax) { $btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDeleteRole_Click')); } else { $btnDelete->AddAction(new QClickEvent(), new QServerControlAction($this, 'btnDeleteRole_Click')); } } $btnDelete->ActionParameter = $objUserRole->UserRoleId; $btnDelete->Display = QApplication::HasPermission('Can manage user roles', $objUserRole->ProjectId, $objUserRole->LanguageId); return $btnEdit->Render(false) . ' ' . $btnDelete->Render(false); }
protected function btnAddField_Click() { $intTotalCount = count($this->lstMapHeaderArray); $this->lstMapHeader_Create($this, $intTotalCount - 1, $this->chkHeaderRow->Checked ? "addfield" : null); $objTemp = $this->lstMapHeaderArray[$intTotalCount]; $this->lstMapHeaderArray[$intTotalCount] = $this->lstMapHeaderArray[$intTotalCount - 1]; $this->lstMapHeaderArray[$intTotalCount - 1] = $objTemp; $txtDefaultValue = new QTextBox($this); $txtDefaultValue->Width = 200; $this->txtMapDefaultValueArray[] = $txtDefaultValue; $lstDefaultValue = new QListBox($this); $lstDefaultValue->Width = 200; $lstDefaultValue->Display = false; $this->lstMapDefaultValueArray[] = $lstDefaultValue; $dtpDate = new QDateTimePicker($this); $dtpDate->DateTimePickerType = QDateTimePickerType::Date; $dtpDate->DateTimePickerFormat = QDateTimePickerFormat::MonthDayYear; $dtpDate->Display = false; $this->dtpDateArray[] = $dtpDate; $btnRemove = new QButton($this); $btnRemove->Text = "Remove"; $btnRemove->ActionParameter = $intTotalCount - 1; $btnRemove->AddAction(new QClickEvent(), new QServerAction('btnRemove_Click')); $btnRemove->AddAction(new QEnterKeyEvent(), new QServerAction('btnRemove_Click')); $btnRemove->AddAction(new QEnterKeyEvent(), new QTerminateAction()); if (isset($this->arrMapFields[$intTotalCount - 1])) { unset($this->arrMapFields[$intTotalCount - 1]); } $this->btnRemoveArray[$intTotalCount - 1] = $btnRemove; }
public function RemoveColumn_Render(CustomFieldValue $objCustomFieldValue) { $strControlId = 'btnRemove' . $objCustomFieldValue->CustomFieldValueId; $btnRemove = $this->GetControl($strControlId); if (!$btnRemove) { // Create the Remove button for this row in the DataGrid // Use ActionParameter to specify the ID of the asset $btnRemove = new QButton($this->dtgValue, $strControlId); $btnRemove->Text = 'Remove'; $btnRemove->ActionParameter = $objCustomFieldValue->CustomFieldValueId; $btnRemove->AddAction(new QClickEvent(), new QAjaxAction('btnRemove_Click')); $btnRemove->AddAction(new QEnterKeyEvent(), new QAjaxAction('btnRemove_Click')); $btnRemove->AddAction(new QEnterKeyEvent(), new QTerminateAction()); $btnRemove->CausesValidation = false; } return $btnRemove->RenderWithError(false); }
public function RenderSelect(Person $objPerson, $intRow) { $strControlId = 'chkSelected' . $objPerson->Id . $intRow; $btnSelect = $this->objForm->GetControl($strControlId); if (!$btnSelect) { $btnSelect = new QButton($this->dtgPeople, $strControlId); $btnSelect->Text = 'Select'; $btnSelect->CssClass = 'primary'; $btnSelect->ActionParameter = $objPerson->Id; $btnSelect->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'pxySelect_Click')); $btnSelect->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSelect_Click')); } return $btnSelect->Render(false); }
public function render_btnRecordDelete($parControl, Address $objRecord) { ++$this->tempdelete; if ($objRecord->Id == $this->intEditAddressId || $this->intEditAddressId == -1 && !$objRecord->Id) { return null; } else { $strControlId = 'btnRecordDelete' . $objRecord->Id . 'dlt' . $this->tempdelete; if (!($objControl = $this->Form->GetControl($strControlId))) { $objControl = new QButton($parControl, $strControlId); $objControl->Text = 'Delete'; $objControl->CssClass = 'inputbutton'; $objControl->ActionParameter = $objRecord->Id; $objControl->AddAction(new QClickEvent(), new QConfirmAction('Are you sure ?')); $objControl->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnRecordDelete_Click', $this->dtgAddresses->WaitIcon)); return $objControl->Render(false); } } }
public function dtgRoleEntityQtypeCustomFieldAuthorization_EditLinkColumn_Render(RoleEntityQtypeCustomFieldAuthorization $objRoleEntityQtypeCustomFieldAuthorization) { $strControlId = 'btnEdit' . $this->dtgRoleEntityQtypeCustomFieldAuthorization->CurrentRowIndex; $btnEdit = $this->objForm->GetControl($strControlId); if (!$btnEdit) { $btnEdit = new QButton($this->dtgRoleEntityQtypeCustomFieldAuthorization, $strControlId); $btnEdit->Text = QApplication::Translate('Edit'); $btnEdit->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnEdit_Click')); } $btnEdit->ActionParameter = $objRoleEntityQtypeCustomFieldAuthorization->RoleEntityQtypeCustomFieldAuthorizationId; return $btnEdit->Render(false); }
public function RemoveColumn_Render(Asset $objAsset) { $strControlId = 'btnRemove' . $objAsset->AssetId; $btnRemove = $this->GetControl($strControlId); if (!$btnRemove) { // Create the Remove button for this row in the DataGrid // Use ActionParameter to specify the ID of the asset $btnRemove = new QButton($this->ctlAssetTransact->dtgAssetTransact, $strControlId); $btnRemove->Text = 'Remove'; $btnRemove->ActionParameter = $objAsset->AssetId; $btnRemove->AddAction(new QClickEvent(), new QAjaxAction('btnRemove_Click')); $btnRemove->AddAction(new QEnterKeyEvent(), new QAjaxAction('btnRemove_Click')); $btnRemove->AddAction(new QEnterKeyEvent(), new QTerminateAction()); $btnRemove->CausesValidation = false; if ($objAsset->LinkedFlag) { $btnRemove->Enabled = false; } } return $btnRemove->Render(false); }
public function colTranslationCount_Render(NarroLanguage $objLanguage) { $btnTmx = $this->dtgLanguage->GetChildControl('tmx' . $objLanguage->LanguageId); if (!$btnTmx instanceof QButton) { $btnTmx = new QButton($this->dtgLanguage, 'tmx' . $objLanguage->LanguageId); $btnTmx->ActionParameter = $objLanguage->LanguageId; $btnTmx->AddAction(new QClickEvent(), new QServerControlAction($this, 'btnTmx_Click')); $btnTmx->Text = 'TMX'; $btnTmx->ToolTip = t('Download all translations in a TMX file'); } return $objLanguage->GetVirtualAttribute("translations_count") . ' ' . $btnTmx->Render(false); }
protected function Form_Create() { parent::Form_Create(); if (!QApplication::HasPermissionForThisLang('Administrator')) { QApplication::Redirect(NarroLink::ProjectList()); } $this->pnlTab = new QTabs($this); $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::ProjectList(t('Projects')); $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::Translate(0, '', NarroTranslatePanel::SHOW_NOT_TRANSLATED, '', 0, 0, 10, 0, 0, t('Translate')); $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::Review(0, '', NarroTranslatePanel::SHOW_NOT_APPROVED, '', 0, 0, 10, 0, 0, t('Review')); if (NarroLanguage::CountAllActive() > 2 || QApplication::HasPermission('Administrator')) { $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::LanguageList(t('Languages')); } $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::UserList('', t('Users')); $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::RoleList(0, '', t('Roles')); if (QApplication::HasPermissionForThisLang('Administrator')) { $this->pnlLog = new QPanel($this->pnlTab); $this->pnlLog->AutoRenderChildren = true; $btnClearLog = new QButton($this->pnlLog); $btnClearLog->Text = t('Clear the log'); $btnClearLog->AddAction(new QClickEvent(), new QConfirmAction(t('Are you sure you want to delete all the logged messages?'))); $btnClearLog->AddAction(new QClickEvent(), new QAjaxAction('btnClearLog_Click')); $this->dtgLog = new NarroLogDataGrid($this->pnlLog); // Datagrid Paginator $this->dtgLog->Paginator = new QPaginator($this->dtgLog); $this->dtgLog->PaginatorAlternate = new QPaginator($this->dtgLog); $this->dtgLog->ItemsPerPage = QApplication::$User->GetPreferenceValueByName('Items per page'); $this->dtgLog->SortColumnIndex = 0; $this->dtgLog->SortDirection = 1; $colDate = $this->dtgLog->MetaAddColumn(QQN::NarroLog()->Date); $colDate->OrderByClause = QQ::OrderBy(QQN::NarroLog()->LogId); $colDate->ReverseOrderByClause = QQ::OrderBy(QQN::NarroLog()->LogId, 0); if (QApplication::HasPermission('Administrator')) { $colLanguage = $this->dtgLog->MetaAddColumn(QQN::NarroLog()->Language->LanguageName); $colLanguage->Filter = null; $colLanguage->FilterAddListItem(t('-Not set-'), QQ::IsNull(QQN::NarroLog()->LanguageId)); foreach (NarroLanguage::LoadAll(QQ::OrderBy(QQN::NarroLanguage()->LanguageName)) as $objLanguage) { $colLanguage->FilterAddListItem($objLanguage->LanguageName, QQ::Equal(QQN::NarroLog()->LanguageId, $objLanguage->LanguageId)); } } else { $this->dtgLog->AdditionalConditions = QQ::Equal(QQN::NarroLog()->LanguageId, QApplication::GetLanguageId()); } $colProject = $this->dtgLog->MetaAddColumn(QQN::NarroLog()->Project->ProjectName); $colProject->Filter = null; $colProject->FilterAddListItem(t('-Not set-'), QQ::IsNull(QQN::NarroLog()->ProjectId)); foreach (NarroProject::LoadAll(QQ::OrderBy(QQN::NarroProject()->ProjectName)) as $objProject) { $colProject->FilterAddListItem($objProject->ProjectName, QQ::Equal(QQN::NarroLog()->ProjectId, $objProject->ProjectId)); } $colUser = $this->dtgLog->MetaAddColumn(QQN::NarroLog()->User->Username); $colUser->Html = '<?=(($_ITEM->UserId)?NarroLink::UserProfile($_ITEM->UserId, $_ITEM->User->Username):"")?>'; $colUser->HtmlEntities = false; $colPriority = $this->dtgLog->MetaAddColumn(QQN::NarroLog()->Priority); $colPriority->Name = 'P'; $colPriority->Width = 16; $colPriority->FilterBoxSize = 1; $colPriority->HtmlEntities = false; $colMessage = $this->dtgLog->MetaAddColumn(QQN::NarroLog()->Message); $colMessage->HtmlEntities = false; $colMessage->Html = '<?=$_FORM->dtgLog_colMessage_Render($_ITEM)?>'; $arrHeaders[] = NarroLink::Log('', t('Application Log')); $this->pnlTab->Selected = count($arrHeaders) - 1; } $this->pnlTab->Headers = $arrHeaders; }
public function render_btnToggleRecords($parControl, $strType) { $strControlId = 'btnToggleRecordsforaddressofperson' . $strType->Id . 'ofproject' . $this->objProject->Id; if (!($objControl = $parControl->GetChildControl($strControlId))) { // But in this case the parent control of the button // would be this child QDataGrid, don't forget that... $person_addresses = Address::QueryCount(QQ::Equal(QQN::Address()->PersonId, $strType->Id)); if ($person_addresses > 0) { $objControl = new QButton($parControl, $strControlId); $objControl->Width = 20; $objControl->Text = '+'; $objControl->CssClass = 'inputbutton'; $objControl->ActionParameter = "{$strType->Id}"; // Important! for a better coding we want to all // actions referer to the child QdataGris stay // in the child Qdatagrid, so the actions are now // QAjaxControlAction or QServerControlAction, were the // controlId parameter is $this, becaouse in $this class // is defined the event for this button... kind of easy, // and clean. $objControl->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnToggleRecords_Click', $this->objParentObject->WaitIcon)); } else { // No addresses to expand; we'll use an empty label control to signify that $objControl = new QLabel($parControl, $strControlId); $objControl->Text = ''; } } // We pass the parameter of "false" to make sure the control doesn't render // itself RIGHT HERE - that it instead returns its string rendering result. return $objControl->Render(false); }
/** * Creates the Filter button for the filter row * * @return void * */ protected function btnFilter_Create() { $btnFilter = new QButton($this); $btnFilter->Name = QApplication::Translate('Filter'); $btnFilter->Text = QApplication::Translate('Filter'); if ($this->blnUseAjax) { $btnFilter->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnFilter_Click', $this->objWaitIcon)); } else { $btnFilter->AddAction(new QClickEvent(), new QServerControlAction($this, 'btnFilter_Click')); } $btnFilter->AddAction(new QClickEvent(), new QTerminateAction()); $btnFilter->CausesValidation = false; return $btnFilter; }
public function dtgRole_Actions_Render(NarroRole $objNarroRole) { $strControlId = 'btnEditRole' . $objNarroRole->RoleId; $btnEdit = $this->Form->GetControl($strControlId); if (!$btnEdit) { $btnEdit = new QButton($this->dtgRole, $strControlId); $btnEdit->Text = t('Edit'); if (QApplication::$UseAjax) { $btnEdit->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnEditRole_Click')); } else { $btnEdit->AddAction(new QClickEvent(), new QServerControlAction($this, 'btnEditRole_Click')); } } $btnEdit->ActionParameter = $objNarroRole->RoleId; $btnEdit->Display = QApplication::HasPermission('Can manage user roles'); $strControlId = 'btnDeleteRole' . $objNarroRole->RoleId; $btnDelete = $this->Form->GetControl($strControlId); if (!$btnDelete) { $btnDelete = new QButton($this->dtgRole, $strControlId); $btnDelete->Text = t('Delete'); $btnDelete->AddAction(new QClickEvent(), new QConfirmAction(t('Are you sure you want to delete this role?'))); if (QApplication::$UseAjax) { $btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDeleteRole_Click')); } else { $btnDelete->AddAction(new QClickEvent(), new QServerControlAction($this, 'btnDeleteRole_Click')); } } $btnDelete->ActionParameter = $objNarroRole->RoleId; $btnDelete->Display = QApplication::HasPermission('Can manage user roles'); $strControlId = 'btnPermissions' . $objNarroRole->RoleId; $btnPermissions = $this->Form->GetControl($strControlId); if (!$btnPermissions) { $btnPermissions = new QButton($this->dtgRole, $strControlId); $btnPermissions->Text = t('Permissions'); $btnPermissions->AddAction(new QClickEvent(), new QServerControlAction($this, 'btnPermissions_Click')); } $btnPermissions->ActionParameter = $objNarroRole->RoleId; $strControlId = 'btnViewUsers' . $objNarroRole->RoleId; $btnViewUsers = $this->Form->GetControl($strControlId); if (!$btnViewUsers) { $btnViewUsers = new QButton($this->dtgRole, $strControlId); $btnViewUsers->Text = t('View users'); $btnViewUsers->AddAction(new QClickEvent(), new QServerControlAction($this, 'btnViewUsers_Click')); } $btnViewUsers->ActionParameter = $objNarroRole->RoleId; $strOutput = ''; if ($objNarroRole->RoleId > 5) { $strOutput .= $btnEdit->Render(false) . ' ' . $btnDelete->Render(false) . ' '; } $strOutput .= $btnPermissions->Render(false) . ' ' . $btnViewUsers->Render(false); return $strOutput; }
public function RemoveAssetModelsColumn_Render(AssetCustomFieldAssetModel $objAssetCustomFieldAssetModel) { $strControlId = 'btnAssetModelRemove' . $objAssetCustomFieldAssetModel->AssetModelId; $btnAssetModelRemove = new QButton($this->dtgAssetModels); $btnAssetModelRemove->Text = 'Remove'; $btnAssetModelRemove->ActionParameter = $objAssetCustomFieldAssetModel->AssetModelId; $btnAssetModelRemove->AddAction(new QClickEvent(), new QAjaxAction('btnAssetModelRemove_Click')); $btnAssetModelRemove->AddAction(new QEnterKeyEvent(), new QAjaxAction('btnAssetModelRemove_Click')); $btnAssetModelRemove->AddAction(new QEnterKeyEvent(), new QTerminateAction()); $btnAssetModelRemove->CausesValidation = false; return $btnAssetModelRemove->RenderWithError(false); }
public function EditColumn_Render(Person $objPerson) { if ($objPerson->Id == $this->intEditPersonId || $this->intEditPersonId == -1 && !$objPerson->Id) { // We are rendering the row of the person we are editing OR we are rending the row // of the NEW (blank) person. Go ahead and render the Save and Cancel buttons. return $this->btnSave->Render(false) . ' ' . $this->btnCancel->Render(false); } else { // Get the Edit button for this row (we will create it if it doesn't yet exist) $strControlId = 'btnEdit' . $objPerson->Id; $btnEdit = $this->GetControl($strControlId); if (!$btnEdit) { // Create the Edit button for this row in the DataGrid // Use ActionParameter to specify the ID of the person $btnEdit = new QButton($this->dtgPersons, $strControlId); $btnEdit->Text = 'Edit This Person'; $btnEdit->ActionParameter = $objPerson->Id; $btnEdit->AddAction(new QClickEvent(), new QAjaxAction('btnEdit_Click')); $btnEdit->CausesValidation = false; } // If we are currently editing a person, then set this Edit button to be disabled if ($this->intEditPersonId) { $btnEdit->Enabled = false; } else { $btnEdit->Enabled = true; } // Return the rendered Edit button return $btnEdit->Render(false); } }
public function RemoveInventoryColumn_Render(InventoryTransaction $objInventoryTransaction) { $strControlId = 'btnRemoveInventory' . $objInventoryTransaction->InventoryLocation->InventoryLocationId; $btnRemove = $this->GetControl($strControlId); if (!$btnRemove) { // Create the Remove button for this row in the DataGrid // Use ActionParameter to specify the ID of the InventoryLocationId $btnRemove = new QButton($this->dtgInventoryTransact, $strControlId); $btnRemove->Text = 'Remove'; $btnRemove->ActionParameter = $objInventoryTransaction->InventoryLocation->InventoryLocationId; $btnRemove->AddAction(new QClickEvent(), new QAjaxAction('btnRemoveInventory_Click')); $btnRemove->AddAction(new QEnterKeyEvent(), new QAjaxAction('btnRemoveInventory_Click')); $btnRemove->AddAction(new QEnterKeyEvent(), new QTerminateAction()); $btnRemove->CausesValidation = false; } return $btnRemove->Render(false); }
public function btnReceiveInventoryTransaction_Render(InventoryTransaction $objInventoryTransaction) { if (!$objInventoryTransaction->blnReturnReceivedStatus()) { $strControlId = 'btnReceiveInventoryTransaction' . $objInventoryTransaction->InventoryTransactionId; $btnReceiveInventory = $this->GetControl($strControlId); if (!$btnReceiveInventory) { // Create the Receive button for this row in the datagrid // Use ActionParameter to specify the ID of the InventoryTransaction $btnReceiveInventory = new QButton($this->dtgInventoryTransact, $strControlId); $btnReceiveInventory->Text = 'Receive'; $btnReceiveInventory->ActionParameter = $objInventoryTransaction->InventoryTransactionId; $btnReceiveInventory->AddAction(new QClickEvent(), new QAjaxAction('btnReceiveInventoryTransaction_Click')); $btnReceiveInventory->AddAction(new QEnterKeyEvent(), new QAjaxAction('btnReceiveInventoryTransaction_Click')); $btnReceiveInventory->AddAction(new QEnterKeyEvent(), new QTerminateAction()); $btnReceiveInventory->CausesValidation = false; } QApplication::AuthorizeControl($this->objReceipt, $btnReceiveInventory, 2); return $btnReceiveInventory->Render(false); } }
protected function Form_Create() { $strServerActionJsParam = ""; $this->btnSubmit = new QButton($this); $this->btnSubmit->Text = "ServerAction Submit"; $this->SubmitResult = new QPanel($this); // Slider $this->Slider = new QSlider($this); $this->Slider->Max = 1250; $this->Slider->AddAction(new MyQSlider_ChangeEvent(), new QAjaxAction('onSlide')); $this->SliderResult = new QPanel($this); // Resizable $this->Resizable = new QPanel($this); $this->Resizable->CssClass = 'resizable'; $this->Resizable->Resizable = true; $this->ResizableResult = new QPanel($this); $strJsParam = '{ "width": $j("#' . $this->Resizable->ControlId . '").width(), "height": $j("#' . $this->Resizable->ControlId . '").height() }'; $this->Resizable->AddAction(new QResizable_StopEvent(), new QAjaxAction("onResize", "default", null, $strJsParam)); $this->ResizableResult = new QPanel($this); $strServerActionJsParam = '{"resizable": ' . $strJsParam . ', '; // Selectable $this->Selectable = new QSelectable($this); $this->Selectable->AutoRenderChildren = true; $this->Selectable->CssClass = 'selectable'; for ($i = 1; $i <= 5; ++$i) { $pnl = new QPanel($this->Selectable); $pnl->Text = 'Item ' . $i; $pnl->CssClass = 'selitem'; } $this->Selectable->Filter = 'div.selitem'; /* * if your objects to return get more complex you can define a javascript function that returns your * object. the essential thing is the ".call()", this executes the function that you have just defined * and returns your object. * In this example a function is uesd to temporary store jquery's search result for selected items, * because it is needed twice. then the ids are stored to objRet.ids as a comma-separated string and * the contents of the selected items are stored to objRet.content as an array. * */ $this->SelectableResult = new QPanel($this); $strJsParam = 'function() { objRet = new Object(); selection = $j("#' . $this->Selectable->ControlId . '") .find(".ui-selected"); objRet.ids = selection.map(function(){ return this.id; }).get() .join(","); objRet.content = selection.map(function() { return $j(this).html(); }).get(); return objRet; }.call()'; $this->Selectable->AddAction(new QSelectable_StopEvent(), new QAjaxAction("onSelect", "default", null, $strJsParam)); $strServerActionJsParam .= '"selectable": ' . $strJsParam . ', '; // Sortable $this->Sortable = new QSortable($this); $this->Sortable->AutoRenderChildren = true; $this->Sortable->CssClass = 'sortable'; for ($i = 1; $i <= 5; ++$i) { $pnl = new QPanel($this->Sortable); $pnl->Text = 'Item ' . $i; $pnl->CssClass = 'sortitem'; } $this->Sortable->Items = 'div.sortitem'; $this->SortableResult = new QPanel($this); $strJsParam = '$j("#' . $this->Sortable->ControlId . '"). find("div.sortitem"). map(function() { return $j(this).html() }).get()'; $this->Sortable->AddAction(new QSortable_UpdateEvent(), new QAjaxAction("onSort", "default", null, $strJsParam)); $strServerActionJsParam .= '"sortable": ' . $strJsParam . '}'; //a second Sortable that can receive items from the first Sortable //when an item is dragged over from the first sortable an receive event is triggered $this->Sortable2 = new QSortable($this); $this->Sortable2->AutoRenderChildren = true; $this->Sortable2->CssClass = 'sortable'; for ($i = 6; $i <= 10; ++$i) { $pnl = new QPanel($this->Sortable2); $pnl->Text = 'Item ' . $i; $pnl->CssClass = 'sortitem'; } $this->Sortable2->Items = 'div.sortitem'; //allow dragging from Sortable to Sortable2 $this->Sortable->ConnectWith = '#' . $this->Sortable2->ControlId; //enable the following line to allow dragging Sortable2 child items to the Sortable list // $this->Sortable2->ConnectWith = '#' . $this->Sortable->ControlId; //using a QJsClosure as the ActionParameter for Sortable2 to return a Js object //the ActionParameter is used for every ajax / server action defined on this control $this->Sortable2->ActionParameter = new QJsClosure('return $j("#' . $this->Sortable2->ControlId . '") .find("div.sortitem") .map(function() { return $j(this).html() }).get();'); //(the list of names from the containing items) is returned for the following two Ajax Actions $this->Sortable2->AddAction(new QSortable_UpdateEvent(), new QAjaxAction("onSort2")); //$this->Sortable2->AddAction(new QSortable_ReceiveEvent() ,new QAjaxAction("onSort2")); $this->Sortable2Result = new QPanel($this); $this->btnSubmit->AddAction(new QClickEvent(), new QServerAction("onSubmit", null, $strServerActionJsParam)); }