public function __construct($objParentObject, $strSetEditPanelMethod, $strCloseEditPanelMethod, $strControlId = null) { // Call the Parent try { parent::__construct($objParentObject, $strControlId); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } // Record Method Callbacks $this->strSetEditPanelMethod = $strSetEditPanelMethod; $this->strCloseEditPanelMethod = $strCloseEditPanelMethod; // Setup DataGrid Columns $this->colEditLinkColumn = new QDataGridColumn(QApplication::Translate('Edit'), '<?= $_CONTROL->ParentControl->dtgAttachment_EditLinkColumn_Render($_ITEM) ?>'); $this->colEditLinkColumn->HtmlEntities = false; $this->colAttachmentId = new QDataGridColumn(QApplication::Translate('Attachment Id'), '<?= $_ITEM->AttachmentId; ?>', array('OrderByClause' => QQ::OrderBy(QQN::Attachment()->AttachmentId), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Attachment()->AttachmentId, false))); $this->colEntityQtypeId = new QDataGridColumn(QApplication::Translate('Entity Qtype'), '<?= $_CONTROL->ParentControl->dtgAttachment_EntityQtypeId_Render($_ITEM); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Attachment()->EntityQtypeId), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Attachment()->EntityQtypeId, false))); $this->colEntityId = new QDataGridColumn(QApplication::Translate('Entity Id'), '<?= $_ITEM->EntityId; ?>', array('OrderByClause' => QQ::OrderBy(QQN::Attachment()->EntityId), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Attachment()->EntityId, false))); $this->colFilename = new QDataGridColumn(QApplication::Translate('Filename'), '<?= QString::Truncate($_ITEM->Filename, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Attachment()->Filename), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Attachment()->Filename, false))); $this->colTmpFilename = new QDataGridColumn(QApplication::Translate('Tmp Filename'), '<?= QString::Truncate($_ITEM->TmpFilename, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Attachment()->TmpFilename), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Attachment()->TmpFilename, false))); $this->colFileType = new QDataGridColumn(QApplication::Translate('File Type'), '<?= QString::Truncate($_ITEM->FileType, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Attachment()->FileType), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Attachment()->FileType, false))); $this->colPath = new QDataGridColumn(QApplication::Translate('Path'), '<?= QString::Truncate($_ITEM->Path, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Attachment()->Path), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Attachment()->Path, false))); $this->colSize = new QDataGridColumn(QApplication::Translate('Size'), '<?= $_ITEM->Size; ?>', array('OrderByClause' => QQ::OrderBy(QQN::Attachment()->Size), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Attachment()->Size, false))); $this->colCreatedBy = new QDataGridColumn(QApplication::Translate('Created By'), '<?= $_CONTROL->ParentControl->dtgAttachment_CreatedByObject_Render($_ITEM); ?>'); $this->colCreationDate = new QDataGridColumn(QApplication::Translate('Creation Date'), '<?= $_CONTROL->ParentControl->dtgAttachment_CreationDate_Render($_ITEM); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Attachment()->CreationDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Attachment()->CreationDate, false))); // Setup DataGrid $this->dtgAttachment = new QDataGrid($this); $this->dtgAttachment->CellSpacing = 0; $this->dtgAttachment->CellPadding = 4; $this->dtgAttachment->BorderStyle = QBorderStyle::Solid; $this->dtgAttachment->BorderWidth = 1; $this->dtgAttachment->GridLines = QGridLines::Both; // Datagrid Paginator $this->dtgAttachment->Paginator = new QPaginator($this->dtgAttachment); $this->dtgAttachment->ItemsPerPage = 10; // Specify Whether or Not to Refresh using Ajax $this->dtgAttachment->UseAjax = true; // Specify the local databind method this datagrid will use $this->dtgAttachment->SetDataBinder('dtgAttachment_Bind', $this); $this->dtgAttachment->AddColumn($this->colEditLinkColumn); $this->dtgAttachment->AddColumn($this->colAttachmentId); $this->dtgAttachment->AddColumn($this->colEntityQtypeId); $this->dtgAttachment->AddColumn($this->colEntityId); $this->dtgAttachment->AddColumn($this->colFilename); $this->dtgAttachment->AddColumn($this->colTmpFilename); $this->dtgAttachment->AddColumn($this->colFileType); $this->dtgAttachment->AddColumn($this->colPath); $this->dtgAttachment->AddColumn($this->colSize); $this->dtgAttachment->AddColumn($this->colCreatedBy); $this->dtgAttachment->AddColumn($this->colCreationDate); // Setup the Create New button $this->btnCreateNew = new QButton($this); $this->btnCreateNew->Text = QApplication::Translate('Create a New') . ' ' . QApplication::Translate('Attachment'); $this->btnCreateNew->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCreateNew_Click')); }
protected function Form_Create() { // Setup DataGrid Columns $this->colEditLinkColumn = new QDataGridColumn(QApplication::Translate('Edit'), '<?= $_FORM->dtgAttachment_EditLinkColumn_Render($_ITEM) ?>'); $this->colEditLinkColumn->HtmlEntities = false; $this->colAttachmentId = new QDataGridColumn(QApplication::Translate('Attachment Id'), '<?= $_ITEM->AttachmentId; ?>', array('OrderByClause' => QQ::OrderBy(QQN::Attachment()->AttachmentId), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Attachment()->AttachmentId, false))); $this->colEntityQtypeId = new QDataGridColumn(QApplication::Translate('Entity Qtype'), '<?= $_FORM->dtgAttachment_EntityQtypeId_Render($_ITEM); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Attachment()->EntityQtypeId), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Attachment()->EntityQtypeId, false))); $this->colEntityId = new QDataGridColumn(QApplication::Translate('Entity Id'), '<?= $_ITEM->EntityId; ?>', array('OrderByClause' => QQ::OrderBy(QQN::Attachment()->EntityId), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Attachment()->EntityId, false))); $this->colFilename = new QDataGridColumn(QApplication::Translate('Filename'), '<?= QString::Truncate($_ITEM->Filename, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Attachment()->Filename), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Attachment()->Filename, false))); $this->colTmpFilename = new QDataGridColumn(QApplication::Translate('Tmp Filename'), '<?= QString::Truncate($_ITEM->TmpFilename, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Attachment()->TmpFilename), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Attachment()->TmpFilename, false))); $this->colFileType = new QDataGridColumn(QApplication::Translate('File Type'), '<?= QString::Truncate($_ITEM->FileType, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Attachment()->FileType), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Attachment()->FileType, false))); $this->colPath = new QDataGridColumn(QApplication::Translate('Path'), '<?= QString::Truncate($_ITEM->Path, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Attachment()->Path), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Attachment()->Path, false))); $this->colSize = new QDataGridColumn(QApplication::Translate('Size'), '<?= $_ITEM->Size; ?>', array('OrderByClause' => QQ::OrderBy(QQN::Attachment()->Size), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Attachment()->Size, false))); $this->colCreatedBy = new QDataGridColumn(QApplication::Translate('Created By'), '<?= $_FORM->dtgAttachment_CreatedByObject_Render($_ITEM); ?>'); $this->colCreationDate = new QDataGridColumn(QApplication::Translate('Creation Date'), '<?= $_FORM->dtgAttachment_CreationDate_Render($_ITEM); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Attachment()->CreationDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Attachment()->CreationDate, false))); // Setup DataGrid $this->dtgAttachment = new QDataGrid($this); $this->dtgAttachment->CellSpacing = 0; $this->dtgAttachment->CellPadding = 4; $this->dtgAttachment->BorderStyle = QBorderStyle::Solid; $this->dtgAttachment->BorderWidth = 1; $this->dtgAttachment->GridLines = QGridLines::Both; // Datagrid Paginator $this->dtgAttachment->Paginator = new QPaginator($this->dtgAttachment); $this->dtgAttachment->ItemsPerPage = 10; // Specify Whether or Not to Refresh using Ajax $this->dtgAttachment->UseAjax = false; // Specify the local databind method this datagrid will use $this->dtgAttachment->SetDataBinder('dtgAttachment_Bind'); $this->dtgAttachment->AddColumn($this->colEditLinkColumn); $this->dtgAttachment->AddColumn($this->colAttachmentId); $this->dtgAttachment->AddColumn($this->colEntityQtypeId); $this->dtgAttachment->AddColumn($this->colEntityId); $this->dtgAttachment->AddColumn($this->colFilename); $this->dtgAttachment->AddColumn($this->colTmpFilename); $this->dtgAttachment->AddColumn($this->colFileType); $this->dtgAttachment->AddColumn($this->colPath); $this->dtgAttachment->AddColumn($this->colSize); $this->dtgAttachment->AddColumn($this->colCreatedBy); $this->dtgAttachment->AddColumn($this->colCreationDate); }
/** * Count Attachments * by CreatedBy Index(es) * @param integer $intCreatedBy * @return int */ public static function CountByCreatedBy($intCreatedBy) { // Call Attachment::QueryCount to perform the CountByCreatedBy query return Attachment::QueryCount(QQ::Equal(QQN::Attachment()->CreatedBy, $intCreatedBy)); }
public static function LoadArrayByEntityQtypeIdEntityId($intEntityQtypeId, $intEntityId, $objOptionalClauses = null) { return Attachment::QueryArray(QQ::AndCondition(QQ::Equal(QQN::Attachment()->EntityQtypeId, $intEntityQtypeId), QQ::Equal(QQN::Attachment()->EntityId, $intEntityId)), $objOptionalClauses); }
/** * Used internally by the Meta-based Add Column tools. * * Given a QQNode or a Text String, this will return a Attachment-based QQNode. * It will also verify that it is a proper Attachment-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 == 'attachment') { 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 "attachment".'); } } else { if (is_string($mixContent)) { switch ($mixContent) { case 'AttachmentId': return QQN::Attachment()->AttachmentId; case 'EntityQtypeId': return QQN::Attachment()->EntityQtypeId; case 'EntityId': return QQN::Attachment()->EntityId; case 'Filename': return QQN::Attachment()->Filename; case 'TmpFilename': return QQN::Attachment()->TmpFilename; case 'FileType': return QQN::Attachment()->FileType; case 'Path': return QQN::Attachment()->Path; case 'Size': return QQN::Attachment()->Size; case 'CreatedBy': return QQN::Attachment()->CreatedBy; case 'CreatedByObject': return QQN::Attachment()->CreatedByObject; case 'CreationDate': return QQN::Attachment()->CreationDate; default: throw new QCallerException('Simple Property not found in AttachmentDataGrid 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'); } } } }
/** * Count Attachments * by CreatedBy Index(es) * @param integer $intCreatedBy * @return int */ public static function CountByCreatedBy($intCreatedBy, $objOptionalClauses = null) { // Call Attachment::QueryCount to perform the CountByCreatedBy query return Attachment::QueryCount(QQ::Equal(QQN::Attachment()->CreatedBy, $intCreatedBy), $objOptionalClauses); }