Version: current

     1 <?php
     2
     3 class MultiUploadConfig {
     4     static $form_name;
     5     static $upload_url;
     6     static $file_destination_path;
     7     static $post_params;
     8     static $file_size_limit;
     9     static $file_types;
    10     static $browse_button_text;
    11     static $file_upload_limit;
    12     static $file_queue_limit;
    13
    14     static $reload_after_upload; // перезагружать страницу после сабмита
    15
    16     // Debug settings
    17     static $debug = "false";
    18
    19     // Silverstripe settings
    20     static $default_upload_dir = "Uploads";
    21
    22     static function addFileTypes($types) {
    23         if(!is_array(self::$file_types)) {
    24             self::$file_types = array();
    25         }
    26         if(is_array($types)) {
    27             self::$file_types = array_unique(array_merge(self::$file_types, $types));
    28         } else {
    29             self::$file_types[] = $types;
    30         }
    31     }
    32
    33     static function addStaticPostParam($param, $value) {
    34         $param_str = "'" . $param . "' : '" . $value . "'";
    35         if(stristr(self::$post_params,$param_str) === false) {
    36             if(!empty(self::$post_params))
    37                 self::$post_params .= ",";
    38             self::$post_params .= $param_str;
    39         }
    40     }
    41
    42     static function addStaticPostParams($params) {
    43         if(is_array($params)) {
    44             foreach($params as $param => $value)
    45                 self::addStaticPostParam($param,$value);
    46         }
    47     }
    48
    49     static function addDynamicPostParam($name, $id) {
    50         self::addStaticPostParam('__dynamic__'.$name, $id);
    51     }
    52
    53     static function addDynamicPostParams($params) {
    54         if(is_array($params)) {
    55             foreach($params as $name => $id)
    56                 self::addDynamicPostParam($name, $id);
    57         }
    58     }
    59
    60     static function debug() {
    61         self::set_var('debug','true');
    62     }
    63
    64     static function get_var($var) {
    65         return self::$$var;
    66     }
    67
    68     static function set_var($var, $value) {
    69         if(property_exists('MultiUploadConfig', $var))
    70             self::$$var = $value;
    71     }
    72
    73     static function set_default_upload_dir($dir) {
    74         self::$default_upload_dir = $dir;
    75     }
    76
    77     static function Configure($properties) {
    78         if(is_array($properties)) {
    79             foreach($properties as $k => $v) {
    80                 if(property_exists('MultiUploadConfig', $k)) {
    81                     self::$$k = $v;
    82                 }
    83             }
    84         }
    85     }
    86
    87     static function DumpConfiguration() {
    88         return get_class_vars(__CLASS__);
    89     }
    90 }

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