| @@ 153-173 (lines=21) @@ | ||
| 150 | * @param string $title The field label. |
|
| 151 | * @param Form $form Reference to the container form |
|
| 152 | */ |
|
| 153 | public function __construct($name, $title = null) { |
|
| 154 | $this->addExtraClass('ss-upload'); // class, used by js |
|
| 155 | $this->addExtraClass('ss-uploadfield'); // class, used by css for uploadfield only |
|
| 156 | ||
| 157 | $this->ufConfig = array_merge($this->ufConfig, self::config()->defaultConfig); |
|
| 158 | ||
| 159 | parent::__construct($name, $title); |
|
| 160 | ||
| 161 | // AssetField always uses rename replacement method |
|
| 162 | $this->getUpload()->setReplaceFile(false); |
|
| 163 | ||
| 164 | // filter out '' since this would be a regex problem on JS end |
|
| 165 | $this->getValidator()->setAllowedExtensions( |
|
| 166 | array_filter(Config::inst()->get('File', 'allowed_extensions')) |
|
| 167 | ); |
|
| 168 | ||
| 169 | // get the lower max size |
|
| 170 | $maxUpload = File::ini2bytes(ini_get('upload_max_filesize')); |
|
| 171 | $maxPost = File::ini2bytes(ini_get('post_max_size')); |
|
| 172 | $this->getValidator()->setAllowedMaxFileSize(min($maxUpload, $maxPost)); |
|
| 173 | } |
|
| 174 | ||
| 175 | /** |
|
| 176 | * Set name of template used for Buttons on each file (replace, edit, remove, delete) (without path or extension) |
|
| @@ 223-244 (lines=22) @@ | ||
| 220 | * @link $record}, with the same name as the field name. |
|
| 221 | * @param Form $form Reference to the container form |
|
| 222 | */ |
|
| 223 | public function __construct($name, $title = null, SS_List $items = null) { |
|
| 224 | ||
| 225 | // TODO thats the first thing that came to my head, feel free to change it |
|
| 226 | $this->addExtraClass('ss-upload'); // class, used by js |
|
| 227 | $this->addExtraClass('ss-uploadfield'); // class, used by css for uploadfield only |
|
| 228 | ||
| 229 | $this->ufConfig = self::config()->defaultConfig; |
|
| 230 | ||
| 231 | parent::__construct($name, $title); |
|
| 232 | ||
| 233 | if($items) $this->setItems($items); |
|
| 234 | ||
| 235 | // filter out '' since this would be a regex problem on JS end |
|
| 236 | $this->getValidator()->setAllowedExtensions( |
|
| 237 | array_filter(Config::inst()->get('File', 'allowed_extensions')) |
|
| 238 | ); |
|
| 239 | ||
| 240 | // get the lower max size |
|
| 241 | $maxUpload = File::ini2bytes(ini_get('upload_max_filesize')); |
|
| 242 | $maxPost = File::ini2bytes(ini_get('post_max_size')); |
|
| 243 | $this->getValidator()->setAllowedMaxFileSize(min($maxUpload, $maxPost)); |
|
| 244 | } |
|
| 245 | ||
| 246 | /** |
|
| 247 | * Set name of template used for Buttons on each file (replace, edit, remove, delete) (without path or extension) |
|