Version: current

     1 <?php
     2 /**
     3  * Snippets have the following generic variables, that can be used in generic templates:
     4  *
     5  * $Title
     6  * $URL
     7  * $Date
     8  * $ID
     9  * $EditLink
    10  *
    11  */
    12
    13 class RecentFiles extends DashboardPlugin {
    14     static $position = "snippet";
    15     static $sort = 1;
    16     static $title = "Recent files";
    17     static $link = "admin/assets/";
    18     static $limit_count = 10;
    19     static $caption = "Последние изменения в файлах.";
    20     static $null_message = 'Нет файлов';
    21     static $edit_link = 'admin/assets/EditForm/field/Files/item';
    22     static $edit_popup = TRUE;
    23
    24     public function GenericSnippetList() {
    25         $output = new DataObjectSet();
    26
    27         $items = DataObject::get("File", "ClassName <> 'Folder'", "`LastEdited` DESC", NULL, "0,".self::$limit_count);
    28
    29         if($items) {
    30             foreach($items as $item) {
    31                 $date = new Date('Date');
    32                 $date->setValue($item->LastEdited);
    33
    34                 $output->push(new ArrayData(array(
    35                     'URL'           => Director::baseURL().$item->Filename,
    36                     'Title'         => $item->Title,
    37                     'Date'          => $date,
    38                     'ID'            => $item->ID,
    39                     'EditLink'      => self::$edit_link.'/'.$item->ID.'/edit',
    40                     'DeleteLink'    => self::$edit_link.'/'.$item->ID.'/delete',
    41                     'EditPopup'     => self::$edit_popup
    42                 )));
    43             }
    44         }
    45         return $output;
    46     }
    47 }

[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. -