function getCMSFields() { $fields = parent::getCMSFields(); $tf = new TableListField('CompaniesTF', 'Company'); $tf->setShowPagination(true); $ctf = new ComplexTableField($this, 'CompaniesCTF', 'Company'); $fields->addFieldsToTab('Root.Fields', array($tf, $ctf)); return $fields; }
/** * Return a TableListField for viewing the related * BrokenLink records through the one-to-many relation. * * @return TableListField */ public function brokenLinksTable() { // Get a singleton instance of BrokenLink $SNG_brokenLink = singleton('BrokenLink'); // Set up the TableListField, for viewing BrokenLink // records that have the current LinkCheckRun ID $table = new TableListField('BrokenLinks', 'BrokenLink', $SNG_brokenLink->tableOverviewFields(), "\"LinkCheckRunID\" = {$this->ID}"); $table->setFieldFormatting(array('PageTitle' => '<a href=\\"admin/show/$PageID\\">$PageTitle</a>', 'Link' => '<a href=\\"$Link\\">$Link</a>')); // Set permissions (we don't want to allow adding) $table->setPermissions(array('export')); $table->setPageSize(20); $table->setShowPagination(true); return $table; }
/** * Return a field, such as a {@link ComplexTableField} that is * used to show and manipulate data relating to this report. * * Generally, you should override {@link columns()} and {@link records()} to make your report, * but if they aren't sufficiently flexible, then you can override this method. * * @return FormField subclass */ function getReportField() { $columnTitles = array(); $fieldFormatting = array(); $csvFieldFormatting = array(); $fieldCasting = array(); // Parse the column information foreach($this->columns() as $source => $info) { if(is_string($info)) $info = array('title' => $info); if(isset($info['formatting'])) $fieldFormatting[$source] = $info['formatting']; if(isset($info['csvFormatting'])) $csvFieldFormatting[$source] = $info['csvFormatting']; if(isset($info['casting'])) $fieldCasting[$source] = $info['casting']; $columnTitles[$source] = isset($info['title']) ? $info['title'] : $source; } // To do: implement pagination $query = $this->sourceQuery($_REQUEST); $tlf = new TableListField('ReportContent', $this->dataClass(), $columnTitles); $tlf->setCustomQuery($query); $tlf->setShowPagination(true); $tlf->setPageSize(50); $tlf->setPermissions(array('export', 'print')); // Hack to figure out if we are printing if (isset($_REQUEST['url']) && array_pop(explode('/', $_REQUEST['url'])) == 'printall') { $tlf->setTemplate('SSReportTableField'); } if($fieldFormatting) $tlf->setFieldFormatting($fieldFormatting); if($csvFieldFormatting) $tlf->setCSVFieldFormatting($csvFieldFormatting); if($fieldCasting) $tlf->setFieldCasting($fieldCasting); return $tlf; }
function getReferrerTableListField() { $tf = new TableListField( 'Referrers', 'Referrer', array( 'URL' => 'URL', 'IsExternal' => 'External?', 'ReferrerCount' => 'Count' ) ); $tf->setShowPagination(true); $tf->setFieldFormatting(array( 'URL' => '<a href=\"$URL\">$URL</a>' )); $tf->setFieldCasting(array( 'IsExternal' => 'Boolean->Nice' )); $tf->setPermissions(array( 'show','export' )); $query = $this->getComponentsQuery( 'Referrers', null, // filter 'ReferrerCount DESC' // sort ); $query->groupby('`Referrer`.`URL`'); $query->select[] = 'COUNT(*) AS ReferrerCount'; $tf->setCustomQuery($query); return $tf; }