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

Packages

  • 1c
    • exchange
      • catalog
  • auth
  • Booking
  • building
    • company
  • cart
    • shipping
    • steppedcheckout
  • Catalog
    • monument
  • 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

  • BuildTask
  • CliDebugView
  • ConvertFrom26Task
  • Debug
  • DebugView
  • DeleteUnusedCustomerFilesTask
  • DevelopmentAdmin
  • FillLinkTrackingTask
  • FillOldLogDataTask
  • FindBadLinksTask
  • ImportTestContentTask
  • MigrationTask
  • MySQLDatabaseConfigurationHelper
  • PhotoGalleryMigrationTask
  • SapphireREPL
  • SS_Backtrace
  • SS_Cli
  • SS_Log
  • SS_LogEmailWriter
  • SS_LogErrorEmailFormatter
  • SS_LogErrorFileFormatter
  • SS_LogFileWriter
  • SS_ZendLog
  • TaskRunner
 1 <?php
 2 /*
 3  * Задача удаления неиспользуемых файлов с сайта
 4  *
 5  * @author menedem
 6  */
 7 class DeleteUnusedCustomerFilesTask extends BuildTask {
 8     
 9     protected $title = "Delete Unused Files";
10 
11     protected $description = "Script delete all files, that don't use at site";
12 
13     /**
14      * Run the conversion.   
15      * 
16      * @param HTTPRequest
17      */
18     function run($request) {
19         $delete = false;        
20         if ($request->getVar('delete')) {
21             $delete = true;
22         }
23         $IDs = DB::Query("SELECT DISTINCT FileID FROM DataObjectFileTracking")->column();
24         if (count($IDs)) {
25             $where = "ClassName <> 'Folder' AND ID NOT IN(" . implode(', ', $IDs) . ")";
26             if ($files = DataObject::get('File', $where)) { // ??? по идее, памяти должно хватить ???
27                 echo "\n";
28                 $totalSize = 0;
29                 $i = 0;
30                 foreach($files as $file) {
31                     $i++;
32                     echo "{$i}. {$file->Filename} ({$file->FileSize})";
33                     $totalSize += $file->{'FileSize'};
34                     if ($delete) {
35                         $file->delete();
36                         echo " - deleted";
37                     }
38                     echo "\n";
39                 }
40                 echo "\nTotal files count: {$i}";
41                 echo "\nTotal files size: " . File::format_size($totalSize) . " \n";
42             }
43         }
44     }
45 }
[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.2 API Docs API documentation generated by ApiGen 2.8.0