Webylon 3.1 API Docs
  • Package
  • Class
  • Tree
  • Deprecated
  • Download
Version: current
  • 3.2
  • 3.1

Packages

  • auth
  • Booking
  • cart
    • shipping
    • steppedcheckout
  • Catalog
  • cms
    • assets
    • batchaction
    • batchactions
    • bulkloading
    • comments
    • content
    • core
    • export
    • newsletter
    • publishers
    • reports
    • security
    • tasks
  • Dashboard
  • DataObjectManager
  • event
  • faq
  • forms
    • actions
    • core
    • fields-basic
    • fields-dataless
    • fields-datetime
    • fields-files
    • fields-formatted
    • fields-formattedinput
    • fields-relational
    • fields-structural
    • transformations
    • validators
  • googlesitemaps
  • guestbook
  • installer
  • newsletter
  • None
  • photo
    • gallery
  • PHP
  • polls
  • recaptcha
  • sapphire
    • api
    • bulkloading
    • control
    • core
    • cron
    • dev
    • email
    • fields-formattedinput
    • filesystem
    • formatters
    • forms
    • i18n
    • integration
    • misc
    • model
    • parsers
    • search
    • security
    • tasks
    • testing
    • tools
    • validation
    • view
    • widgets
  • seo
    • open
      • graph
  • sfDateTimePlugin
  • spamprotection
  • stealth
    • captha
  • subsites
  • userform
    • pagetypes
  • userforms
  • webylon
  • widgets

Classes

  • BigFilesReport
  • BrokenLinksReport
  • CMSMain
  • CMSMainMarkingFilter
  • CMSMenu
  • CMSMenuItem
  • CMSSiteTreeFilter
  • CMSSiteTreeFilter_ChangedPages
  • CMSSiteTreeFilter_DeletedPages
  • CMSSiteTreeFilter_Search
  • NonUsedFilesReport
  • RedirectorPage
  • RedirectorPage_Controller
  • SideReport_BrokenFiles
  • SideReport_BrokenLinks
  • SideReport_BrokenRedirectorPages
  • SideReport_BrokenVirtualPages
  • SideReport_EmptyPages
  • SideReport_RecentlyEdited
  • SideReport_ToDo
  • SideReportView
  • SideReportWrapper
  • SilverStripeNavigator
  • SilverStripeNavigatorItem
  • SilverStripeNavigatorItem_ArchiveLink
  • SilverStripeNavigatorItem_CMSLink
  • SilverStripeNavigatorItem_LiveLink
  • SilverStripeNavigatorItem_StageLink
  • WidgetAreaEditor
 1 <?php
 2 
 3 /**
 4  * Content side-report listing non used files
 5  * @package cms
 6  * @subpackage content
 7  */
 8 
 9 class NonUsedFilesReport extends SS_Report {
10 
11     protected $dataClass = 'File';
12     
13     function title() {
14         return _t('NonUsedFilesReport.NONUSEDFILES',"Non used files report");
15     }
16     
17     function sourceRecords($params, $sort, $limit) {
18         if (!$sort) {
19             $sort = "FileSize DESC";
20         }
21         $where = "ClassName <> 'Folder'";       
22         $IDs = DB::Query("SELECT DISTINCT FileID FROM DataObjectFileTracking")->column();
23         if (count($IDs)) {
24             $where .= " AND File.ID NOT IN(" . implode(', ', $IDs) . ")";
25         }
26         return DataObject::get('File', $where, $sort, '', $limit);
27     }
28     
29     function columns() {
30         $fields = array(
31             "Title" => array(
32                 "title" => _t('NonUsedFilesReport.Title', 'Title'),
33             ),
34             "Filename" => array(
35                 "title" => _t('NonUsedFilesReport.Filename', 'Filename'),
36             ),
37             'FileSize' => array(
38                 'title' => _t('NonUsedFilesReport.Size', 'File size'),
39                 'formatting' => '$Size'
40             ),
41             "Created" => array(
42                 "title" => _t('NonUsedFilesReport.Created', 'Created at'),
43             ),
44             "LastEdited" => array(
45                 "title" => _t('NonUsedFilesReport.LastEdited', 'Last edited at'),
46             ),
47             "Owner.Title" => array(
48                 "title" => _t('NonUsedFilesReport.OwnerTitle', 'Owner'),
49             )
50         );
51         return $fields;
52     }
53     
54     function sortColumns() {
55         $fields = array(
56             "Title",
57             "Filename",
58             'FileSize',
59             "Created",
60             "LastEdited"
61         );
62         return $fields;
63     }
64     
65     function getReportField() {
66         $columnTitles = array();
67         $fieldFormatting = array();
68         $csvFieldFormatting = array();
69         $fieldCasting = array();
70         
71         // Parse the column information
72         foreach($this->columns() as $source => $info) {
73             if(is_string($info)) $info = array('title' => $info);
74             
75             if(isset($info['formatting'])) $fieldFormatting[$source] = $info['formatting'];
76             if(isset($info['csvFormatting'])) $csvFieldFormatting[$source] = $info['csvFormatting'];
77             if(isset($info['casting'])) $fieldCasting[$source] = $info['casting'];
78             $columnTitles[$source] = isset($info['title']) ? $info['title'] : $source;
79         }
80         
81         // To do: implement pagination
82         $query = $this->sourceQuery($_REQUEST);
83             
84         $tlf = new FileComplexTableField($this, 'ReportContent', $this->dataClass(), $columnTitles);
85         $tlf->setCustomQuery($query);
86         
87         if($fieldFormatting) $tlf->setFieldFormatting($fieldFormatting);
88         if($csvFieldFormatting) $tlf->setCSVFieldFormatting($csvFieldFormatting);
89         if($fieldCasting) $tlf->setFieldCasting($fieldCasting);
90         
91         return $tlf;
92     }
93 }
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -
Webylon 3.1 API Docs API documentation generated by ApiGen 2.8.0