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

  • Aggregate
  • Aggregate_Relationship
  • AssetAdminQuotaExtension
  • AttachedFilesExtension
  • BookingWidget
  • CheckoutPageExchangeExtension
  • ClassInfo
  • ControllerRedirectExtension
  • CSSContentParser
  • DisableJSValidation
  • Extension
  • HtmlEditorQuotaExtension
  • ManifestBuilder
  • MobileExtension
  • Object
  • PaymentMethodAutoHide
  • ProductSearchFormExtension
  • SS_Cache
  • TokenisedRegularExpression
  • ValidationResult
  • YamlFixture

Functions

  • __autoload
  • _t
  • array_fill_keys
  • getClassFile
  • getSysTempDir
  • getTempFolder
  • increase_memory_limit_to
  • increase_time_limit_to
  • project
  • singleton
  • stripslashes_recursively
  • translate_memstring
 1 <?php
 2 
 3 /**
 4  * Расширение для прикрепленных файлов
 5  *
 6  * @author inxo
 7  */
 8 class AttachedFiles extends DataObjectDecorator {
 9 
10     static function add_extension($class, $extension_class='AttachedFiles') {
11         Object::add_extension($class, 'AssociatedFolderDecorator');
12         Object::add_extension($class . '_Controller', 'AttachedFilesExtension');
13         Object::add_extension($class, $extension_class);
14     }
15 
16     function extraStatics() {
17         return array(
18             'has_many' => array(
19                 "Photos" => "MediawebPage_Photo.MediawebPage",
20                 "Files" => "MediawebPage_File.MediawebPage",
21             )
22         );
23     }
24 
25     function updateCMSFields(FieldSet &$fields) {
26         if (!$this->owner->ID || (!$this->owner->ExistsOnLive && $this->owner->IsDeletedFromStage)) // если страница не сохранена, то не нужно создавать AssociatedFolder и показывать вкладки с прикрепленными фотками и файлами
27             return;         
28             
29         if ($this->owner->AssociatedFolderID && $this->owner->AssociatedFolder()->ID)
30             $folder = $this->owner->AssociatedFolder();
31         else
32             $folder = $this->owner->createAssociatedFolder();
33             
34         $folder = substr_replace(str_replace(ASSETS_DIR.'/', '', $folder->Filename), "", -1);
35 
36         $fields->addFieldToTab('Root.Content', new Tab("PagePhotos", _t("MediawebPage.PagePhotos", "Photos")), 'Metadata');
37         $photoManager = new MediawebPagePhoto_Manager($this->owner, "Photos", "MediawebPage_Photo", "Photo", array("Caption" => _t("MediawebPage.Caption", "Caption")), "getCMSFields_forPopup");
38         $photoManager->setUploadFolder($folder);
39         $fields->addFieldToTab('Root.Content.PagePhotos', $photoManager);
40 
41         $fields->addFieldToTab('Root.Content', new Tab("PageFiles", _t("MediawebPage.PageFiles", "Files")), 'Metadata');
42         $fileManager = new MediawebPageFiles_Manager($this->owner, "Files", "MediawebPage_File", "Attach", array("Caption" => _t("MediawebPage.Caption", "Caption")), "getCMSFields_forPopup");
43         $fileManager->setUploadFolder($folder);
44         $fields->addFieldToTab('Root.Content.PageFiles', $fileManager);
45     }
46 
47     public function ImageCount() {
48         $images = DataObject::get("MediawebPage_Photo", "MediawebPageID = {$this->owner->ID}");
49         return $images ? $images->Count() : 0;
50     }
51 
52     public function FileCount() {
53         $files = DataObject::get("MediawebPage_File", "MediawebPageID = {$this->owner->ID}");
54         return $files ? $files->Count() : 0;
55     }
56 
57     function onAfterDelete() {
58         if ($this->owner->IsDeletedFromStage && !$this->owner->ExistsOnLive) {
59             if ($this->owner->Files()) {
60                 foreach ($this->owner->Files() as $obj) {
61                     $obj->delete();
62                 }
63             }
64             if ($this->owner->Photos()) {
65                 foreach ($this->owner->Photos() as $obj) {
66                     $obj->delete();
67                 }
68             }
69         }
70         parent::onAfterDelete();
71     }
72 
73 }
74 
75 class AttachedFilesExtension extends Extension {
76 
77     public function rotateimage() {
78         if ($image = DataObject::get_by_id("Image", $this->urlParams['ID'])) {
79             $rotatedImage = $this->urlParams['OtherID'] == 'cw' ? $image->RotateClockwise() : $image->RotateCounterClockwise();
80             if (copy(Director::baseFolder() . '/' . $rotatedImage->Filename, Director::baseFolder() . '/' . $image->Filename)) {
81                 $image->flushCache();
82                 $image->deleteFormattedImages();
83             }
84             echo $image->SetHeight(200)->URL . "?t=" . time();
85         }
86     }
87 
88 }
89 
90 
91 
[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