1 | <?php |
||
10 | class Draft |
||
11 | { |
||
12 | |||
13 | protected $errors = []; |
||
14 | protected $cname; |
||
15 | protected $id; |
||
16 | protected $client; |
||
17 | |||
18 | public function __construct($ID, $client) |
||
30 | |||
31 | /** |
||
32 | * Get the filename for this draft (whether or not it exists) |
||
33 | * |
||
34 | * @return string |
||
35 | */ |
||
36 | public function getDraftFilename() |
||
40 | |||
41 | /** |
||
42 | * Checks if this draft exists on the filesystem |
||
43 | * |
||
44 | * @return bool |
||
45 | */ |
||
46 | public function isDraftAvailable() |
||
50 | |||
51 | /** |
||
52 | * Save a draft of a current edit session |
||
53 | * |
||
54 | * The draft will not be saved if |
||
55 | * - drafts are deactivated in the config |
||
56 | * - or the editarea is empty and there are no event handlers registered |
||
57 | * - or the event is prevented |
||
58 | * |
||
59 | * @triggers DRAFT_SAVE |
||
60 | * |
||
61 | * @return bool whether has the draft been saved |
||
62 | */ |
||
63 | public function saveDraft() |
||
98 | |||
99 | /** |
||
100 | * Get the text from the draft file |
||
101 | * |
||
102 | * @throws \RuntimeException if the draft file doesn't exist |
||
103 | * |
||
104 | * @return string |
||
105 | */ |
||
106 | public function getDraftText() |
||
116 | |||
117 | /** |
||
118 | * Remove the draft from the filesystem |
||
119 | * |
||
120 | * Also sets $INFO['draft'] to null |
||
121 | */ |
||
122 | public function deleteDraft() |
||
128 | |||
129 | /** |
||
130 | * Get a formatted message stating when the draft was saved |
||
131 | * |
||
132 | * @return string |
||
133 | */ |
||
134 | public function getDraftMessage() |
||
139 | |||
140 | /** |
||
141 | * Retrieve the errors that occured when saving the draft |
||
142 | * |
||
143 | * @return array |
||
144 | */ |
||
145 | public function getErrors() |
||
149 | } |
||
150 |
If you suppress an error, we recommend checking for the error condition explicitly: