1 | <?php |
||
10 | class Draft |
||
11 | { |
||
12 | |||
13 | protected $errors = []; |
||
14 | protected $cname; |
||
15 | protected $id; |
||
16 | protected $client; |
||
17 | |||
18 | /** |
||
19 | * Draft constructor. |
||
20 | * |
||
21 | * @param string $ID the page id for this draft |
||
22 | * @param string $client the client identification (username or ip or similar) for this draft |
||
23 | */ |
||
24 | public function __construct($ID, $client) |
||
36 | |||
37 | /** |
||
38 | * Get the filename for this draft (whether or not it exists) |
||
39 | * |
||
40 | * @return string |
||
41 | */ |
||
42 | public function getDraftFilename() |
||
46 | |||
47 | /** |
||
48 | * Checks if this draft exists on the filesystem |
||
49 | * |
||
50 | * @return bool |
||
51 | */ |
||
52 | public function isDraftAvailable() |
||
56 | |||
57 | /** |
||
58 | * Save a draft of a current edit session |
||
59 | * |
||
60 | * The draft will not be saved if |
||
61 | * - drafts are deactivated in the config |
||
62 | * - or the editarea is empty and there are no event handlers registered |
||
63 | * - or the event is prevented |
||
64 | * |
||
65 | * @triggers DRAFT_SAVE |
||
66 | * |
||
67 | * @return bool whether has the draft been saved |
||
68 | */ |
||
69 | public function saveDraft() |
||
104 | |||
105 | /** |
||
106 | * Get the text from the draft file |
||
107 | * |
||
108 | * @throws \RuntimeException if the draft file doesn't exist |
||
109 | * |
||
110 | * @return string |
||
111 | */ |
||
112 | public function getDraftText() |
||
122 | |||
123 | /** |
||
124 | * Remove the draft from the filesystem |
||
125 | * |
||
126 | * Also sets $INFO['draft'] to null |
||
127 | */ |
||
128 | public function deleteDraft() |
||
134 | |||
135 | /** |
||
136 | * Get a formatted message stating when the draft was saved |
||
137 | * |
||
138 | * @return string |
||
139 | */ |
||
140 | public function getDraftMessage() |
||
145 | |||
146 | /** |
||
147 | * Retrieve the errors that occured when saving the draft |
||
148 | * |
||
149 | * @return array |
||
150 | */ |
||
151 | public function getErrors() |
||
155 | } |
||
156 |