forked from jwest/MorCMS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
file.php
executable file
·97 lines (74 loc) · 1.83 KB
/
file.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php defined('SYSPATH') or die('No direct script access.');
/**
* File upload/download item for CRUD ORM
* @author jwest
*/
class CRUD_Item_File extends CRUD_Item
{
/**
* Declare type for mysql migration
*/
const TYPE = "VARCHAR";
/**
* Get default param for column (for observer model class)
* @param CRUD_Item_File $item
* @return array
*/
public static function observe_param($item, $model_name)
{
$global_param = parent::observe_param($item, $model_name);
$item = $item->get_item();
$param = array
(
'var' => 255,
);
return array_merge($global_param, $param);
}
/**
* Set path for upload files
* @param string $path
* @return CRUD_Item_File
*/
public function path($path)
{
$this->item['path'] = $path;
return $this;
}
/**
* Set option for multiupload files
* @param bool $value
* @return CRUD_Item_File
*/
public function multi_upload($value = false)
{
$this->item['multi_upload'] = false;
return $this;
}
/**
* Set max size for upload file
* @param int $size
* @return CRUD_Item_File
*/
public function max_size($size)
{
$this->item['max_size'] = $size;
return $this;
}
/**
* Validate file type
* @param array $types
* @return CRUD_Item_File
*/
public function types($types = array())
{
$this->item['types'] = $types;
return $this;
}
public function rename($pattern = null)
{
$this->item['rename'] = true;
$this->item['pattern'] = $pattern;
return $this;
}
}
?>