Source of file TagReport.php
Size: 2,470 Bytes - Last Modified: 2021-12-24T06:47:36+00:00
/var/www/docs.ssmods.com/process/src/code/reports/TagReport.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 | <?php /** * Content side-report listing tags and amount of usage. * * @package News/Blog module * @author Simon 'Sphere' * @todo Semantics */ class TagReport extends SS_Report { /** * Set the title. Because I still don't know why not. * * @return String Report Title */ public function title() { return _t('TagReport.TITLE', 'Tag usage report'); } /** * Setup the list of records to show. * * @param array $params of filter-rules. * @param string $sort * @param string $limit * * @return \ArrayList with the records. */ public function sourceRecords($params, $sort, $limit) { if ($sort) { $parts = explode(' ', $sort); $field = $parts[0]; $direction = $parts[1]; } $where = null; if (isset($params['Title']) && $params['Title'] != '') { $where = 'Title LIKE \'%' . $params['Title'] . '%\''; } /** @var ArrayList|Tag[] $ret */ $ret = Tag::get()->where($where); /** @var ArrayList $returnSet */ $returnSet = ArrayList::create(); if ($ret) foreach ($ret as $record) { $record->Itemcount = $record->News()->count(); $returnSet->push($record); } return $returnSet; } /** * Setup the columns in the list. * * @todo it seems HiddenCount bugs out. No idea why. * @return array of fields. */ public function columns() { $fields = array( "Title" => array( "title" => _t('TagReport.NEWSTITLE', 'News title'), 'formatting' => sprintf( '<a href=\"admin/news/Tag/EditForm/field/Tag/item/$ID/edit\" title=\"%s\">$value</a>', _t('TagReport.EDIT', 'Edit tag') ) ), "Itemcount" => array( "title" => _t('TagReport.NEWSCOUNT', 'Total items linked'), 'casting' => 'Int' ), ); return $fields; } /** * Setup the searchform. * * @return \FieldList FieldList instance with the searchfields. */ public function parameterFields() { $return = FieldList::create( $title = TextField::create( 'Title', _t('TagReport.TAGTITLE', 'Search for tag') ) ); return $return; } } |