public static function LoadArrayByActive($intActive, $objOptionalClauses = null) { if (is_null($objOptionalClauses)) { $objOptionalClauses = array(QQ::OrderBy(QQN::NarroProject()->ProjectName)); } return parent::LoadArrayByActive($intActive, $objOptionalClauses); }
protected function Form_Create() { parent::Form_Create(); // Instantiate the Meta DataGrid $this->dtgNarroProjects = new NarroProjectDataGrid($this); // Style the DataGrid (if desired) $this->dtgNarroProjects->CssClass = 'datagrid'; $this->dtgNarroProjects->AlternateRowStyle->CssClass = 'alternate'; // Add Pagination (if desired) $this->dtgNarroProjects->Paginator = new QPaginator($this->dtgNarroProjects); $this->dtgNarroProjects->ItemsPerPage = __FORM_DRAFTS_FORM_LIST_ITEMS_PER_PAGE__; // Use the MetaDataGrid functionality to add Columns for this datagrid // Create an Edit Column $strEditPageUrl = __VIRTUAL_DIRECTORY__ . __FORM_DRAFTS__ . '/narro_project_edit.php'; $this->dtgNarroProjects->MetaAddEditLinkColumn($strEditPageUrl, 'Edit', 'Edit'); // Create the Other Columns (note that you can use strings for narro_project's properties, or you // can traverse down QQN::narro_project() to display fields that are down the hierarchy) $this->dtgNarroProjects->MetaAddColumn('ProjectId'); $this->dtgNarroProjects->MetaAddColumn(QQN::NarroProject()->ProjectCategory); $this->dtgNarroProjects->MetaAddColumn('ProjectName'); $this->dtgNarroProjects->MetaAddTypeColumn('ProjectType', 'NarroProjectType'); $this->dtgNarroProjects->MetaAddColumn('ProjectDescription'); $this->dtgNarroProjects->MetaAddColumn('Data'); $this->dtgNarroProjects->MetaAddColumn('Active'); }
public function __construct(NarroProject $objProject, NarroLanguage $objLanguage, $objParentObject, $strControlId = null) { // Call the Parent try { parent::__construct($objParentObject, $strControlId); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } $this->objProject = $objProject; $this->objLanguage = $objLanguage; $this->lstProject = new QListBox($this); $this->lstProject->DisplayStyle = QDisplayStyle::Block; $this->lstProject->Instructions = t('Please choose the project from which you will import matching approved translations'); $this->lstProject->PreferedRenderMethod = 'RenderWithName'; $this->blnAutoRenderChildren = true; foreach (NarroProject::QueryArray(QQ::Equal(QQN::NarroProject()->Active, 1), array(QQ::OrderBy(QQN::NarroProject()->ProjectName))) as $objProject) { $this->lstProject->AddItem($objProject->ProjectName, $objProject->ProjectId); } }
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; }
/** * Used internally by the Meta-based Add Column tools. * * Given a QQNode or a Text String, this will return a NarroProject-based QQNode. * It will also verify that it is a proper NarroProject-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 == 'narro_project') { 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 "narro_project".'); } } else { if (is_string($mixContent)) { switch ($mixContent) { case 'ProjectId': return QQN::NarroProject()->ProjectId; case 'ProjectCategoryId': return QQN::NarroProject()->ProjectCategoryId; case 'ProjectCategory': return QQN::NarroProject()->ProjectCategory; case 'ProjectName': return QQN::NarroProject()->ProjectName; case 'ProjectType': return QQN::NarroProject()->ProjectType; case 'ProjectDescription': return QQN::NarroProject()->ProjectDescription; case 'Data': return QQN::NarroProject()->Data; case 'Active': return QQN::NarroProject()->Active; default: throw new QCallerException('Simple Property not found in NarroProjectDataGrid 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'); } } } }
public function lstProject_Create() { $this->lstProject = new QListBox($this); $this->lstProject->AddItem(t('all projects')); foreach (NarroProject::LoadArrayByActive(1, array(QQ::OrderBy(QQN::NarroProject()->ProjectName))) as $objProject) { $this->lstProject->AddItem($objProject->ProjectName, $objProject->ProjectId); } $this->lstProject->AddAction(new QChangeEvent(), new QAjaxControlAction($this, 'btnSearch_Click', $this->objWaitIcon)); if (QApplication::QueryString('p') > 0) { $this->lstProject->SelectedValue = QApplication::QueryString('p'); } }
public function dtgProjectList_Bind() { if ($this->txtSearch->Text != '') { $arrConditions[] = QQ::Like(QQN::NarroProject()->ProjectName, sprintf('%%%s%%', $this->txtSearch->Text)); } else { $arrConditions[] = QQ::All(); } if (QApplication::HasPermissionForThisLang('Can manage project')) { $arrConditions[] = QQ::All(); } else { $arrConditions[] = QQ::AndCondition(QQ::Equal(QQN::NarroProject()->NarroProjectProgressAsProject->Active, 1), QQ::Equal(QQN::NarroProject()->Active, 1)); } // Setup the $objClauses Array $objClauses = array(QQ::Expand(QQN::NarroProject()->NarroProjectProgressAsProject, QQ::Equal(QQN::NarroProject()->NarroProjectProgressAsProject->LanguageId, QApplication::GetLanguageId()))); // Remember! We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below $this->dtgProjectList->TotalItemCount = NarroProject::QueryCount(QQ::AndCondition($arrConditions), $objClauses); // 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->dtgProjectList->OrderByClause) { array_push($objClauses, $objClause); } // Add the LimitClause information, as well if ($objClause = $this->dtgProjectList->LimitClause) { array_push($objClauses, $objClause); } // Set the DataSource to be the array of all NarroProjectProgress objects, given the clauses above $this->dtgProjectList->DataSource = NarroProject::QueryArray(QQ::AndCondition($arrConditions), $objClauses); }
public function __construct($objUser, $objParentObject, $strControlId = null) { // Call the Parent try { parent::__construct($objParentObject, $strControlId); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } $this->strTemplate = __NARRO_INCLUDES__ . '/narro/panel/NarroUserRolePanel.tpl.php'; $this->objUser = $objUser; // Setup DataGrid Columns $this->colLanguage = new QDataGridColumn(t('Language'), '<?= $_CONTROL->ParentControl->dtgUserRole_LanguageColumn_Render($_ITEM) ?>', array('OrderByClause' => QQ::OrderBy(QQN::NarroUserRole()->Language->LanguageName), 'ReverseOrderByClause' => QQ::OrderBy(QQN::NarroUserRole()->Language->LanguageName, false))); $this->colLanguage->HtmlEntities = false; $this->colProject = new QDataGridColumn(t('Project'), '<?= $_CONTROL->ParentControl->dtgUserRole_ProjectColumn_Render($_ITEM) ?>', array('OrderByClause' => QQ::OrderBy(QQN::NarroUserRole()->Project->ProjectName), 'ReverseOrderByClause' => QQ::OrderBy(QQN::NarroUserRole()->Project->ProjectName, false))); $this->colProject->HtmlEntities = false; $this->colRole = new QDataGridColumn(t('Roles'), '<?= $_CONTROL->ParentControl->dtgUserRole_RoleColumn_Render($_ITEM) ?>', array('OrderByClause' => QQ::OrderBy(QQN::NarroUserRole()->Role->RoleName), 'ReverseOrderByClause' => QQ::OrderBy(QQN::NarroUserRole()->Role->RoleName, false))); $this->colRole->HtmlEntities = false; $this->colActions = new QDataGridColumn(t('Actions'), '<?= $_CONTROL->ParentControl->dtgUserRole_ActionsColumn_Render($_ITEM) ?>'); $this->colActions->HtmlEntities = false; // Setup DataGrid $this->dtgUserRole = new NarroDataGrid($this); $this->dtgUserRole->Title = sprintf(t('<b>%s</b>\'s roles'), NarroLink::UserProfile($this->objUser->UserId, $this->objUser->RealName)); $this->dtgUserRole->ShowHeader = true; $this->dtgUserRole->Paginator = new QPaginator($this->dtgUserRole); $this->dtgUserRole->PaginatorAlternate = new QPaginator($this->dtgUserRole); $this->dtgUserRole->ItemsPerPage = QApplication::$User->GetPreferenceValueByName('Items per page'); // Specify Whether or Not to Refresh using Ajax $this->dtgUserRole->UseAjax = QApplication::$UseAjax; // Specify the local databind method this datagrid will use $this->dtgUserRole->SetDataBinder('dtgUserRole_Bind', $this); $this->dtgUserRole->AddColumn($this->colLanguage); $this->dtgUserRole->AddColumn($this->colProject); $this->dtgUserRole->AddColumn($this->colRole); $this->lstLanguage = new QListBox($this); $this->lstLanguage->AddItem('Any'); foreach (NarroLanguage::LoadAllActive(array(QQ::OrderBy(QQN::NarroLanguage()->LanguageName))) as $objNarroLanguage) { if (QApplication::HasPermission('Can manage user roles', null, $objNarroLanguage->LanguageId)) { $this->blnCanManageSomeRoles = true; } $this->lstLanguage->AddItem($objNarroLanguage->LanguageName, $objNarroLanguage->LanguageId); } $this->lstLanguage->SelectedValue = QApplication::GetLanguageId(); $this->lstProject = new QListBox($this); $this->lstProject->AddItem('Any'); foreach (NarroProject::QueryArray(QQ::Equal(QQN::NarroProject()->Active, 1), array(QQ::OrderBy(QQN::NarroProject()->ProjectName))) as $objNarroProject) { if (QApplication::HasPermission('Can manage user roles', $objNarroProject->ProjectId)) { $this->blnCanManageSomeRoles = true; } $this->lstProject->AddItem($objNarroProject->ProjectName, $objNarroProject->ProjectId); } if (!$this->blnCanManageSomeRoles && QApplication::HasPermission('Can manage user roles')) { $this->blnCanManageSomeRoles = true; } if ($this->blnCanManageSomeRoles) { $this->dtgUserRole->AddColumn($this->colActions); } $this->lstRole = new QListBox($this); foreach (NarroRole::LoadAll(array(QQ::OrderBy(QQN::NarroRole()->RoleName))) as $objNarroRole) { if ($objNarroRole->RoleName == 'Administrator' && !QApplication::HasPermission('Administrator')) { continue; } $this->lstRole->AddItem($objNarroRole->RoleName, $objNarroRole->RoleId); } $this->btnAddRole = new QButton($this); $this->btnAddRole->Text = t('Add'); $this->btnAddRole->AddAction(new QClickEvent(), new QServerControlAction($this, 'btnAddRole_Click')); }
/** * Count NarroProjects * by Active Index(es) * @param integer $intActive * @return int */ public static function CountByActive($intActive) { // Call NarroProject::QueryCount to perform the CountByActive query return NarroProject::QueryCount(QQ::Equal(QQN::NarroProject()->Active, $intActive)); }