public function GetControlHtml() { $strLogContents = ''; foreach (NarroLog::QueryArray(QQ::AndCondition(QQ::Equal(QQN::NarroLog()->ProjectId, $this->intProjectId), QQ::Equal(QQN::NarroLog()->LanguageId, $this->intLanguageId), QQ::GreaterThan(QQN::NarroLog()->Date, $this->dttStart))) as $objLogEntry) { switch ($objLogEntry->Priority) { case NarroLog::PRIORITY_INFO: $strLogContents .= '<div class="info"'; break; case NarroLog::PRIORITY_WARN: $strLogContents .= '<div class="warning"'; break; case NarroLog::PRIORITY_ERROR: $strLogContents .= '<div class="error"'; break; default: $strLogContents .= '<div'; } $strLogContents .= sprintf('title="%s">%s</div>', $objLogEntry->Date, nl2br(NarroString::HtmlEntities($objLogEntry->Message))); } $this->strText = sprintf('<div class="ui-accordion ui-widget ui-helper-reset ui-accordion-icons"> <h3 class="ui-accordion-header ui-helper-reset ui-state-default ui-state-active ui-corner-top"> <span class="ui-icon ui-icon-triangle-1-s"></span> <a>%s</a> </h3> <div class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content-active" style="max-height:300px;overflow:auto"> %s </div> </div>', t('Operation log'), $strLogContents); return parent::GetControlHtml(); }
protected function Form_Create() { parent::Form_Create(); // Instantiate the Meta DataGrid $this->dtgNarroLogs = new NarroLogDataGrid($this); // Style the DataGrid (if desired) $this->dtgNarroLogs->CssClass = 'datagrid'; $this->dtgNarroLogs->AlternateRowStyle->CssClass = 'alternate'; // Add Pagination (if desired) $this->dtgNarroLogs->Paginator = new QPaginator($this->dtgNarroLogs); $this->dtgNarroLogs->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_log_edit.php'; $this->dtgNarroLogs->MetaAddEditLinkColumn($strEditPageUrl, 'Edit', 'Edit'); // Create the Other Columns (note that you can use strings for narro_log's properties, or you // can traverse down QQN::narro_log() to display fields that are down the hierarchy) $this->dtgNarroLogs->MetaAddColumn('LogId'); $this->dtgNarroLogs->MetaAddColumn(QQN::NarroLog()->Language); $this->dtgNarroLogs->MetaAddColumn(QQN::NarroLog()->Project); $this->dtgNarroLogs->MetaAddColumn(QQN::NarroLog()->User); $this->dtgNarroLogs->MetaAddColumn('Message'); $this->dtgNarroLogs->MetaAddColumn('Priority'); $this->dtgNarroLogs->MetaAddColumn('Date'); }
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; }
/** * Count NarroLogs * by LanguageId Index(es) * @param integer $intLanguageId * @return int */ public static function CountByLanguageId($intLanguageId) { // Call NarroLog::QueryCount to perform the CountByLanguageId query return NarroLog::QueryCount(QQ::Equal(QQN::NarroLog()->LanguageId, $intLanguageId)); }
protected function dtgLog_Create() { $dtgLog = new NarroLogDataGrid($this->tabActivity); $dtgLog->SetCustomStyle('padding', '5px'); $dtgLog->Title = sprintf(t('Logged messages for <b>%s</b>'), $this->objUser->RealName); $colProject = $dtgLog->MetaAddColumn(QQN::NarroLog()->Project->ProjectName); $colProject->Name = t('Project'); $colLanguage = $dtgLog->MetaAddColumn(QQN::NarroLog()->Language->LanguageName); $colLanguage->Name = t('Language'); $colLanguage->Html = '<?= $_CONTROL->colLanguage_Render($_ITEM); ?>'; $colPriority = $dtgLog->MetaAddColumn(QQN::NarroLog()->Priority); $colPriority->Name = t('Priority'); $colMessage = $dtgLog->MetaAddColumn(QQN::NarroLog()->Message); $colMessage->Name = t('Message'); $colMessage->Html = '<?= $_CONTROL->colMessage_Render($_ITEM); ?>'; $colMessage->HtmlEntities = false; $colCreated = $dtgLog->MetaAddColumn(QQN::NarroLog()->Date); $colCreated->Name = t('Added'); $colCreated->FilterType = QFilterType::None; $colCreated->Html = '<?= $_CONTROL->colCreated_Render($_ITEM); ?>'; $colCreated->HtmlEntities = false; $colCreated->Wrap = false; // Datagrid Paginator $dtgLog->Paginator = new QPaginator($dtgLog); $dtgLog->ItemsPerPage = QApplication::$User->GetPreferenceValueByName('Items per page'); // Specify Whether or Not to Refresh using Ajax $dtgLog->UseAjax = true; $dtgLog->SortColumnIndex = 2; $dtgLog->SortDirection = true; $dtgLog->AdditionalClauses = array(QQ::Expand(QQN::NarroLog()->Project), QQ::Expand(QQN::NarroLog()->Language)); $dtgLog->AdditionalConditions = QQ::Equal(QQN::NarroLog()->UserId, $this->objUser->UserId); $dtgLog->btnFilter_Click($this->Form->FormId, $dtgLog->FilterButton->ControlId, ''); }
/** * Used internally by the Meta-based Add Column tools. * * Given a QQNode or a Text String, this will return a NarroLog-based QQNode. * It will also verify that it is a proper NarroLog-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_log') { 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_log".'); } } else { if (is_string($mixContent)) { switch ($mixContent) { case 'LogId': return QQN::NarroLog()->LogId; case 'LanguageId': return QQN::NarroLog()->LanguageId; case 'Language': return QQN::NarroLog()->Language; case 'ProjectId': return QQN::NarroLog()->ProjectId; case 'Project': return QQN::NarroLog()->Project; case 'UserId': return QQN::NarroLog()->UserId; case 'User': return QQN::NarroLog()->User; case 'Message': return QQN::NarroLog()->Message; case 'Priority': return QQN::NarroLog()->Priority; case 'Date': return QQN::NarroLog()->Date; default: throw new QCallerException('Simple Property not found in NarroLogDataGrid 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'); } } } }