protected function Form_Create()
 {
     parent::Form_Create();
     // Instantiate the Meta DataGrid
     $this->dtgNarroTextComments = new NarroTextCommentDataGrid($this);
     // Style the DataGrid (if desired)
     $this->dtgNarroTextComments->CssClass = 'datagrid';
     $this->dtgNarroTextComments->AlternateRowStyle->CssClass = 'alternate';
     // Add Pagination (if desired)
     $this->dtgNarroTextComments->Paginator = new QPaginator($this->dtgNarroTextComments);
     $this->dtgNarroTextComments->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_text_comment_edit.php';
     $this->dtgNarroTextComments->MetaAddEditLinkColumn($strEditPageUrl, 'Edit', 'Edit');
     // Create the Other Columns (note that you can use strings for narro_text_comment's properties, or you
     // can traverse down QQN::narro_text_comment() to display fields that are down the hierarchy)
     $this->dtgNarroTextComments->MetaAddColumn('TextCommentId');
     $this->dtgNarroTextComments->MetaAddColumn(QQN::NarroTextComment()->Text);
     $this->dtgNarroTextComments->MetaAddColumn(QQN::NarroTextComment()->User);
     $this->dtgNarroTextComments->MetaAddColumn(QQN::NarroTextComment()->Language);
     $this->dtgNarroTextComments->MetaAddColumn('Created');
     $this->dtgNarroTextComments->MetaAddColumn('Modified');
     $this->dtgNarroTextComments->MetaAddColumn('CommentText');
     $this->dtgNarroTextComments->MetaAddColumn('CommentTextMd5');
 }
 public function __construct(NarroText $objText, $objParentObject, $strControlId = null)
 {
     // Call the Parent
     try {
         parent::__construct($objParentObject, $strControlId);
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
     $this->blnAutoRenderChildren = true;
     $this->intTextId = $objText->TextId;
     $this->strText = sprintf('<span class="instructions">%s</span>', t('User comments'));
     $this->dtgComments = new NarroTextCommentDataGrid($this);
     $colComment = $this->dtgComments->MetaAddColumn(QQN::NarroTextComment()->CommentText);
     $colComment->HtmlEntities = false;
     $colComment->Html = '<?=$_CONTROL->ParentControl->colComment_Render($_ITEM)?>';
     $this->dtgComments->ShowFilter = false;
     $this->dtgComments->ShowHeader = false;
     $this->dtgComments->AdditionalConditions = QQ::Equal(QQN::NarroTextComment()->TextId, $objText->TextId);
     $this->dtgComments->AdditionalClauses = array(QQ::OrderBy(QQN::NarroTextComment()->Created, 1), QQ::Expand(QQN::NarroTextComment()->Language), QQ::Expand(QQN::NarroTextComment()->User));
     $this->txtComment = new QTextBox($this);
     $this->txtComment->Name = t('Comment');
     $this->txtComment->TextMode = QTextMode::MultiLine;
     $this->txtComment->PreferedRenderMethod = 'Render';
     $this->txtComment->Columns = 80;
     $this->txtComment->ToolTip = t('Enter your comments here');
     $this->txtComment->CssClass = 'comment';
     $this->txtComment->DisplayStyle = QDisplayStyle::Block;
     $this->txtComment->Display = QApplication::HasPermissionForThisLang('Can comment');
     $this->btnSave = new QImageButton($this);
     $this->btnSave->AlternateText = t('Add comment');
     $this->btnSave->CssClass = 'imgbutton save';
     $this->btnSave->ToolTip = $this->btnSave->AlternateText;
     $this->btnSave->ImageUrl = __NARRO_IMAGE_ASSETS__ . '/comment.png';
     $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));
     $this->btnSave->Display = QApplication::HasPermissionForThisLang('Can comment');
 }
 /**
  * Count NarroTextComments
  * by LanguageId Index(es)
  * @param integer $intLanguageId
  * @return int
  */
 public static function CountByLanguageId($intLanguageId)
 {
     // Call NarroTextComment::QueryCount to perform the CountByLanguageId query
     return NarroTextComment::QueryCount(QQ::Equal(QQN::NarroTextComment()->LanguageId, $intLanguageId));
 }
 /**
  * Used internally by the Meta-based Add Column tools.
  *
  * Given a QQNode or a Text String, this will return a NarroTextComment-based QQNode.
  * It will also verify that it is a proper NarroTextComment-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_text_comment') {
             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_text_comment".');
         }
     } else {
         if (is_string($mixContent)) {
             switch ($mixContent) {
                 case 'TextCommentId':
                     return QQN::NarroTextComment()->TextCommentId;
                 case 'TextId':
                     return QQN::NarroTextComment()->TextId;
                 case 'Text':
                     return QQN::NarroTextComment()->Text;
                 case 'UserId':
                     return QQN::NarroTextComment()->UserId;
                 case 'User':
                     return QQN::NarroTextComment()->User;
                 case 'LanguageId':
                     return QQN::NarroTextComment()->LanguageId;
                 case 'Language':
                     return QQN::NarroTextComment()->Language;
                 case 'Created':
                     return QQN::NarroTextComment()->Created;
                 case 'Modified':
                     return QQN::NarroTextComment()->Modified;
                 case 'CommentText':
                     return QQN::NarroTextComment()->CommentText;
                 case 'CommentTextMd5':
                     return QQN::NarroTextComment()->CommentTextMd5;
                 default:
                     throw new QCallerException('Simple Property not found in NarroTextCommentDataGrid 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');
             }
         }
     }
 }
 protected function dtgComments_Create()
 {
     $dtgComments = new NarroTextCommentDataGrid($this->tabActivity);
     $dtgComments->SetCustomStyle('padding', '5px');
     $dtgComments->Title = sprintf(t('Comments added by <b>%s</b>'), $this->objUser->RealName);
     $colText = $dtgComments->MetaAddColumn(QQN::NarroTextComment()->Text->TextValue);
     $colText->Name = t('Text');
     $colText->Html = '<?= $_CONTROL->colText_Render($_ITEM); ?>';
     $colText->HtmlEntities = false;
     $colSuggestion = $dtgComments->MetaAddColumn(QQN::NarroTextComment()->CommentText);
     $colSuggestion->Name = t('Comment');
     $colSuggestion->Html = '<?= $_CONTROL->colCommentText_Render($_ITEM); ?>';
     $colLanguage = $dtgComments->MetaAddColumn(QQN::NarroTextComment()->Language->LanguageName);
     $colLanguage->Name = t('Language');
     $colLanguage->Filter = null;
     foreach (NarroLanguage::LoadAllActive() as $objLanguage) {
         $colLanguage->FilterAddListItem($objLanguage->LanguageName, QQ::Equal(QQN::NarroTextComment()->LanguageId, $objLanguage->LanguageId));
     }
     $colLanguage->FilterActivate(QApplication::$TargetLanguage->LanguageName);
     $colLanguage->Html = '<?= $_CONTROL->colLanguage_Render($_ITEM); ?>';
     $colCreated = $dtgComments->MetaAddColumn(QQN::NarroTextComment()->Created);
     $colCreated->Name = t('Approved');
     $colCreated->FilterType = QFilterType::None;
     $colCreated->Html = '<?= $_CONTROL->colCreated_Render($_ITEM); ?>';
     $colCreated->HtmlEntities = false;
     $colCreated->Wrap = false;
     // Datagrid Paginator
     $dtgComments->Paginator = new QPaginator($dtgComments);
     $dtgComments->ItemsPerPage = QApplication::$User->GetPreferenceValueByName('Items per page');
     // Specify Whether or Not to Refresh using Ajax
     $dtgComments->UseAjax = true;
     $dtgComments->SortColumnIndex = 3;
     $dtgComments->SortDirection = true;
     $dtgComments->AdditionalClauses = array(QQ::Expand(QQN::NarroTextComment()->Text), QQ::Expand(QQN::NarroTextComment()->Language));
     $dtgComments->AdditionalConditions = QQ::Equal(QQN::NarroTextComment()->UserId, $this->objUser->UserId);
     $dtgComments->btnFilter_Click($this->Form->FormId, $dtgComments->FilterButton->ControlId, '');
 }