@@ -41,420 +41,420 @@ |
||
41 | 41 | class Search implements DocSearchInterface |
42 | 42 | { |
43 | 43 | |
44 | - /** |
|
45 | - * Minimum characters that can be submitted for a search. |
|
46 | - * |
|
47 | - * @var int |
|
48 | - */ |
|
49 | - protected $min_chars = 3; |
|
50 | - |
|
51 | - /** |
|
52 | - * Maximum characters that can be submitted for a search. |
|
53 | - * |
|
54 | - * @var int |
|
55 | - */ |
|
56 | - protected $max_chars = 30; |
|
57 | - |
|
58 | - /** |
|
59 | - * Valid file extensions we can search in. |
|
60 | - * |
|
61 | - * @var string |
|
62 | - */ |
|
63 | - protected $allowed_file_types = 'html|htm|php|php4|php5|txt|md'; |
|
64 | - |
|
65 | - /** |
|
66 | - * Which files should we skip over during our search? |
|
67 | - * |
|
68 | - * @var array |
|
69 | - */ |
|
70 | - protected $skip_files = ['.', '..', '_404.md', '_toc.ini']; |
|
71 | - |
|
72 | - /** |
|
73 | - * How much of each file should we read. |
|
74 | - * Use lower values for faster searches. |
|
75 | - * |
|
76 | - * @var int |
|
77 | - */ |
|
78 | - protected $byte_size = 51200; |
|
79 | - |
|
80 | - /** |
|
81 | - * Number of words long (approximately) |
|
82 | - * the result excerpt should be. |
|
83 | - * |
|
84 | - * @var int |
|
85 | - */ |
|
86 | - protected $excerpt_length = 60; |
|
87 | - |
|
88 | - /** |
|
89 | - * The maximum number of results allowed from a single file. |
|
90 | - * |
|
91 | - * @var int |
|
92 | - */ |
|
93 | - protected $max_per_file = 1; |
|
94 | - |
|
95 | - protected $doc_folders = array(); |
|
96 | - |
|
97 | - protected $formatters = array(); |
|
98 | - |
|
99 | - //-------------------------------------------------------------------- |
|
100 | - |
|
101 | - /** |
|
102 | - * The entry point for performing a search of the documentation. |
|
103 | - * |
|
104 | - * @param null $terms |
|
105 | - * @param array $folders |
|
106 | - * |
|
107 | - * @return array|null |
|
108 | - */ |
|
109 | - public function search($terms = null, $folders = []) |
|
110 | - { |
|
111 | - if (empty($terms) || empty($folders)) { |
|
112 | - return null; |
|
113 | - } |
|
114 | - |
|
115 | - $results = []; |
|
116 | - $this->doc_folders = $folders; |
|
117 | - |
|
118 | - foreach ($folders as $group => $folder) { |
|
119 | - $results = array_merge($results, $this->searchFolder($terms, $folder, $group)); |
|
120 | - } |
|
121 | - |
|
122 | - return $results; |
|
123 | - } |
|
124 | - |
|
125 | - //-------------------------------------------------------------------- |
|
126 | - |
|
127 | - //-------------------------------------------------------------------- |
|
128 | - // Private Methods |
|
129 | - //-------------------------------------------------------------------- |
|
130 | - |
|
131 | - |
|
132 | - /** |
|
133 | - * Searches a single directory worth of files. |
|
134 | - * |
|
135 | - * @param $term |
|
136 | - * @param $folder |
|
137 | - * @param $group_name |
|
138 | - * |
|
139 | - * @return array The results. |
|
140 | - */ |
|
141 | - protected function searchFolder($term, $folder, $group_name) |
|
142 | - { |
|
143 | - $results = []; |
|
144 | - |
|
145 | - $map = $this->directory_map($folder, 2); |
|
146 | - |
|
147 | - $map = $this->flattenMap($map); |
|
148 | - |
|
149 | - // Make sure we have something to work with. |
|
150 | - if (! is_array($map) || (is_array($map) && ! count($map))) { |
|
151 | - return []; |
|
152 | - } |
|
153 | - |
|
154 | - // Loop over each file and search the contents for our term. |
|
155 | - foreach ($map as $dir => $file) { |
|
156 | - $file_count = 0; |
|
157 | - |
|
158 | - if (in_array($file, $this->skip_files)) { |
|
159 | - continue; |
|
160 | - } |
|
161 | - |
|
162 | - // Is it a folder? |
|
163 | - if (is_array($file) && count($file)) { |
|
164 | - $results = array_merge($results, $this->searchFolder($term, $folder . '/' . $dir, $group_name)); |
|
165 | - continue; |
|
166 | - } |
|
167 | - |
|
168 | - // Make sure it's the right file type... |
|
169 | - if (! preg_match("/({$this->allowed_file_types})/i", $file)) { |
|
170 | - continue; |
|
171 | - } |
|
172 | - |
|
173 | - $path = is_string($dir) ? $folder . '/' . $dir . '/' . $file : $folder . '/' . $file; |
|
174 | - $term_html = htmlentities($term); |
|
175 | - |
|
176 | - // Read in the file text |
|
177 | - $handle = fopen($path, 'r'); |
|
178 | - $text = fread($handle, $this->byte_size); |
|
179 | - |
|
180 | - // Do we have a match in here somewhere? |
|
181 | - $found = stristr($text, $term) || stristr($text, $term_html); |
|
182 | - |
|
183 | - if (! $found) { |
|
184 | - continue; |
|
185 | - } |
|
186 | - |
|
187 | - // Escape our terms to safely use in a preg_match |
|
188 | - $excerpt = strip_tags($text); |
|
189 | - $term = preg_quote($term); |
|
190 | - $term = str_replace("/", "\/", "{$term}"); |
|
191 | - $term_html = preg_quote($term_html); |
|
192 | - $term_html = str_replace("/", "\/", "{$term_html}"); |
|
193 | - |
|
194 | - // Add the item to our results with extracts. |
|
195 | - if (preg_match_all( |
|
196 | - "/((\s\S*){0,3})($term|$term_html)((\s?\S*){0,3})/i", |
|
197 | - $excerpt, |
|
198 | - $matches, |
|
199 | - PREG_OFFSET_CAPTURE | PREG_SET_ORDER |
|
200 | - )) { |
|
201 | - foreach ($matches as $match) { |
|
202 | - if ($file_count >= $this->max_per_file) { |
|
203 | - continue; |
|
204 | - } |
|
205 | - $result_url = '/docs/' . $group_name . '/' . str_replace('.md', '', $file); |
|
206 | - |
|
207 | - foreach ($this->doc_folders as $alias => $folder) { |
|
208 | - $result_url = str_replace($folder, $alias, $result_url); |
|
209 | - } |
|
210 | - |
|
211 | - $results[] = [ |
|
212 | - 'title' => $this->extractTitle($excerpt, $file), |
|
213 | - 'file' => $folder . '/' . $file, |
|
214 | - 'url' => $result_url, |
|
215 | - 'extract' => $this->buildExtract($excerpt, $term, $match[0][0]) |
|
216 | - ]; |
|
217 | - |
|
218 | - $file_count++; |
|
219 | - } |
|
220 | - } |
|
221 | - } |
|
222 | - |
|
223 | - return $results; |
|
224 | - } |
|
225 | - |
|
226 | - //-------------------------------------------------------------------- |
|
227 | - |
|
228 | - /** |
|
229 | - * Stores the name of the callback method to run to convert the source |
|
230 | - * files to viewable files. By default, this should be used to register |
|
231 | - * a Mardown Extended formatter with the system, but could be used to |
|
232 | - * extend the |
|
233 | - * |
|
234 | - * @param string $callback_name |
|
235 | - * @param bool $cascade // If FALSE the formatting of a component ends here. If TRUE, will be passed to next formatter. |
|
236 | - * @return $this |
|
237 | - */ |
|
238 | - public function registerFormatter($callback_name = '', $cascade = false) |
|
239 | - { |
|
240 | - if (empty($callback_name)) return; |
|
241 | - |
|
242 | - $this->formatters[] = array($callback_name => $cascade); |
|
243 | - |
|
244 | - return $this; |
|
245 | - } |
|
246 | - |
|
247 | - //-------------------------------------------------------------------- |
|
248 | - |
|
249 | - /** |
|
250 | - * Runs the text through the registered formatters. |
|
251 | - * |
|
252 | - * @param $str |
|
253 | - * @return mixed |
|
254 | - */ |
|
255 | - public function format($str) |
|
256 | - { |
|
257 | - if (! is_array($this->formatters)) return $str; |
|
258 | - |
|
259 | - foreach ($this->formatters as $formatter) { |
|
260 | - $method = key($formatter); |
|
261 | - $cascade = $formatter[$method]; |
|
262 | - |
|
263 | - $str = call_user_func($method, $str); |
|
264 | - |
|
265 | - if (! $cascade) return $str; |
|
266 | - } |
|
267 | - |
|
268 | - return $str; |
|
269 | - } |
|
270 | - |
|
271 | - //-------------------------------------------------------------------- |
|
272 | - |
|
273 | - |
|
274 | - //-------------------------------------------------------------------- |
|
275 | - // Protected Methods |
|
276 | - //-------------------------------------------------------------------- |
|
277 | - |
|
278 | - /** |
|
279 | - * Converts an array generated by directory_map into a flat array of |
|
280 | - * folders, removing any nested folders and adding them to the path. |
|
281 | - * |
|
282 | - * @param $map |
|
283 | - * @param $prefix Used to recursively add the folder name... |
|
284 | - * @return mixed |
|
285 | - */ |
|
286 | - protected function flattenMap($map, $prefix = '') |
|
287 | - { |
|
288 | - if (! is_array($map) || ! count($map)) { |
|
289 | - return $map; |
|
290 | - } |
|
291 | - |
|
292 | - $return = []; |
|
293 | - |
|
294 | - foreach ($map as $folder => $files) { |
|
295 | - |
|
296 | - // If it's a folder name and an array of files |
|
297 | - // then call this method recursively to flatten it out. |
|
298 | - if (is_array($files)) { |
|
299 | - $return = array_merge($return, $this->flattenMap($files, $prefix . $folder)); |
|
300 | - continue; |
|
301 | - } |
|
302 | - |
|
303 | - // Else, add our prefix (if any) to the filename... |
|
304 | - $return[] = $prefix . $files; |
|
305 | - } |
|
306 | - |
|
307 | - return $return; |
|
308 | - } |
|
309 | - |
|
310 | - //-------------------------------------------------------------------- |
|
311 | - |
|
312 | - /** |
|
313 | - * Handles extracting the text surrounding our match and basic match formatting. |
|
314 | - * |
|
315 | - * @param $excerpt |
|
316 | - * @param $term |
|
317 | - * @param $match_string |
|
318 | - * |
|
319 | - * @return string |
|
320 | - */ |
|
321 | - protected function buildExtract($excerpt, $term, $match_string) |
|
322 | - { |
|
323 | - // Find the character positions within the string that our match was found at. |
|
324 | - // That way we'll know from what positions before and after this we want to grab it in. |
|
325 | - $start_offset = stripos($excerpt, $match_string); |
|
326 | - |
|
327 | - // Modify the start and end positions based on $this->excerpt_length / 2. |
|
328 | - $buffer = floor($this->excerpt_length / 2); |
|
329 | - |
|
330 | - // Adjust our start position |
|
331 | - $start_offset = $start_offset - $buffer; |
|
332 | - if ($start_offset < 0) { |
|
333 | - $start_offset = 0; |
|
334 | - } |
|
335 | - |
|
336 | - $extract = substr($excerpt, $start_offset); |
|
337 | - |
|
338 | - $extract = strip_tags($this->format($extract)); |
|
339 | - |
|
340 | - $extract = $this->firstXWords($extract, $this->excerpt_length); |
|
341 | - |
|
342 | - // Wrap the search term in a span we can style. |
|
343 | - $extract = str_ireplace($term, '<span class="term-hilight">' . $term . '</span>', $extract); |
|
344 | - |
|
345 | - return $extract; |
|
346 | - } |
|
347 | - |
|
348 | - //-------------------------------------------------------------------- |
|
349 | - |
|
350 | - /** |
|
351 | - * Extracts the title from a bit of markdown formatted text. If it doesn't |
|
352 | - * have an h1 or h2, then it uses the filename. |
|
353 | - * |
|
354 | - * @param $excerpt |
|
355 | - * @param $file |
|
356 | - * @return string |
|
357 | - */ |
|
358 | - protected function extractTitle($excerpt, $file) |
|
359 | - { |
|
360 | - $title = ''; |
|
361 | - |
|
362 | - // Easiest to work if this is split into lines. |
|
363 | - $lines = explode("\n", $excerpt); |
|
364 | - |
|
365 | - if (is_array($lines) && count($lines)) { |
|
366 | - foreach ($lines as $line) { |
|
367 | - if (strpos($line, '# ') === 0 || strpos($line, '## ') === 0) { |
|
368 | - $title = trim(str_replace('#', '', $line)); |
|
369 | - break; |
|
370 | - } |
|
371 | - } |
|
372 | - } |
|
373 | - |
|
374 | - // If it's empty, we'll use the filename. |
|
375 | - if (empty($title)) { |
|
376 | - $title = str_replace('_', ' ', $file); |
|
377 | - $title = str_replace('.md', ' ', $title); |
|
378 | - $title = ucwords($title); |
|
379 | - } |
|
380 | - |
|
381 | - return $title; |
|
382 | - } |
|
383 | - //-------------------------------------------------------------------- |
|
384 | - |
|
385 | - /** |
|
386 | - * Create a Directory Map |
|
387 | - * |
|
388 | - * Reads the specified directory and builds an array |
|
389 | - * representation of it. Sub-folders contained with the |
|
390 | - * directory will be mapped as well. |
|
391 | - * |
|
392 | - * @param string $source_dir Path to source |
|
393 | - * @param int $directory_depth Depth of directories to traverse |
|
394 | - * (0 = fully recursive, 1 = current dir, etc) |
|
395 | - * @param bool $hidden Whether to show hidden files |
|
396 | - * @return array |
|
397 | - */ |
|
398 | - protected function directory_map($source_dir, $directory_depth = 0, $hidden = FALSE) |
|
399 | - { |
|
400 | - if ($fp = @opendir($source_dir)) { |
|
401 | - $filedata = array(); |
|
402 | - $new_depth = $directory_depth - 1; |
|
403 | - $source_dir = rtrim($source_dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
|
404 | - |
|
405 | - while (FALSE !== ($file = readdir($fp))) { |
|
406 | - // Remove '.', '..', and hidden files [optional] |
|
407 | - if ($file === '.' OR $file === '..' OR ($hidden === FALSE && $file[0] === '.')) { |
|
408 | - continue; |
|
409 | - } |
|
410 | - |
|
411 | - is_dir($source_dir . $file) && $file .= DIRECTORY_SEPARATOR; |
|
412 | - |
|
413 | - if (($directory_depth < 1 OR $new_depth > 0) && is_dir($source_dir . $file)) |
|
414 | - { |
|
415 | - $filedata[$file] = $this->directory_map($source_dir . $file, $new_depth, $hidden); |
|
416 | - } else |
|
417 | - { |
|
418 | - // Replace the directory separator here with a forward slash since |
|
419 | - // Windows uses backward slashes and not all browsers will auto-replace |
|
420 | - // those slashes in URLs. |
|
421 | - $filedata[] = str_replace(DIRECTORY_SEPARATOR, '/', $file); |
|
422 | - } |
|
423 | - } |
|
424 | - |
|
425 | - closedir($fp); |
|
426 | - return $filedata; |
|
427 | - } |
|
428 | - |
|
429 | - return FALSE; |
|
430 | - } |
|
431 | - |
|
432 | - //-------------------------------------------------------------------- |
|
433 | - |
|
434 | - /** |
|
435 | - * Gets the first 'X' words of a string. |
|
436 | - * |
|
437 | - * @param $str |
|
438 | - * @param int $wordCount |
|
439 | - * @return string |
|
440 | - */ |
|
441 | - protected function firstXWords($str, $wordCount = 10) |
|
442 | - { |
|
443 | - return implode( |
|
444 | - '', |
|
445 | - array_slice( |
|
446 | - preg_split( |
|
447 | - '/([\s,\.;\?\!]+)/', |
|
448 | - $str, |
|
449 | - $wordCount * 2 + 1, |
|
450 | - PREG_SPLIT_DELIM_CAPTURE |
|
451 | - ), |
|
452 | - 0, |
|
453 | - $wordCount * 2 - 1 |
|
454 | - ) |
|
455 | - ); |
|
456 | - } |
|
457 | - |
|
458 | - //-------------------------------------------------------------------- |
|
44 | + /** |
|
45 | + * Minimum characters that can be submitted for a search. |
|
46 | + * |
|
47 | + * @var int |
|
48 | + */ |
|
49 | + protected $min_chars = 3; |
|
50 | + |
|
51 | + /** |
|
52 | + * Maximum characters that can be submitted for a search. |
|
53 | + * |
|
54 | + * @var int |
|
55 | + */ |
|
56 | + protected $max_chars = 30; |
|
57 | + |
|
58 | + /** |
|
59 | + * Valid file extensions we can search in. |
|
60 | + * |
|
61 | + * @var string |
|
62 | + */ |
|
63 | + protected $allowed_file_types = 'html|htm|php|php4|php5|txt|md'; |
|
64 | + |
|
65 | + /** |
|
66 | + * Which files should we skip over during our search? |
|
67 | + * |
|
68 | + * @var array |
|
69 | + */ |
|
70 | + protected $skip_files = ['.', '..', '_404.md', '_toc.ini']; |
|
71 | + |
|
72 | + /** |
|
73 | + * How much of each file should we read. |
|
74 | + * Use lower values for faster searches. |
|
75 | + * |
|
76 | + * @var int |
|
77 | + */ |
|
78 | + protected $byte_size = 51200; |
|
79 | + |
|
80 | + /** |
|
81 | + * Number of words long (approximately) |
|
82 | + * the result excerpt should be. |
|
83 | + * |
|
84 | + * @var int |
|
85 | + */ |
|
86 | + protected $excerpt_length = 60; |
|
87 | + |
|
88 | + /** |
|
89 | + * The maximum number of results allowed from a single file. |
|
90 | + * |
|
91 | + * @var int |
|
92 | + */ |
|
93 | + protected $max_per_file = 1; |
|
94 | + |
|
95 | + protected $doc_folders = array(); |
|
96 | + |
|
97 | + protected $formatters = array(); |
|
98 | + |
|
99 | + //-------------------------------------------------------------------- |
|
100 | + |
|
101 | + /** |
|
102 | + * The entry point for performing a search of the documentation. |
|
103 | + * |
|
104 | + * @param null $terms |
|
105 | + * @param array $folders |
|
106 | + * |
|
107 | + * @return array|null |
|
108 | + */ |
|
109 | + public function search($terms = null, $folders = []) |
|
110 | + { |
|
111 | + if (empty($terms) || empty($folders)) { |
|
112 | + return null; |
|
113 | + } |
|
114 | + |
|
115 | + $results = []; |
|
116 | + $this->doc_folders = $folders; |
|
117 | + |
|
118 | + foreach ($folders as $group => $folder) { |
|
119 | + $results = array_merge($results, $this->searchFolder($terms, $folder, $group)); |
|
120 | + } |
|
121 | + |
|
122 | + return $results; |
|
123 | + } |
|
124 | + |
|
125 | + //-------------------------------------------------------------------- |
|
126 | + |
|
127 | + //-------------------------------------------------------------------- |
|
128 | + // Private Methods |
|
129 | + //-------------------------------------------------------------------- |
|
130 | + |
|
131 | + |
|
132 | + /** |
|
133 | + * Searches a single directory worth of files. |
|
134 | + * |
|
135 | + * @param $term |
|
136 | + * @param $folder |
|
137 | + * @param $group_name |
|
138 | + * |
|
139 | + * @return array The results. |
|
140 | + */ |
|
141 | + protected function searchFolder($term, $folder, $group_name) |
|
142 | + { |
|
143 | + $results = []; |
|
144 | + |
|
145 | + $map = $this->directory_map($folder, 2); |
|
146 | + |
|
147 | + $map = $this->flattenMap($map); |
|
148 | + |
|
149 | + // Make sure we have something to work with. |
|
150 | + if (! is_array($map) || (is_array($map) && ! count($map))) { |
|
151 | + return []; |
|
152 | + } |
|
153 | + |
|
154 | + // Loop over each file and search the contents for our term. |
|
155 | + foreach ($map as $dir => $file) { |
|
156 | + $file_count = 0; |
|
157 | + |
|
158 | + if (in_array($file, $this->skip_files)) { |
|
159 | + continue; |
|
160 | + } |
|
161 | + |
|
162 | + // Is it a folder? |
|
163 | + if (is_array($file) && count($file)) { |
|
164 | + $results = array_merge($results, $this->searchFolder($term, $folder . '/' . $dir, $group_name)); |
|
165 | + continue; |
|
166 | + } |
|
167 | + |
|
168 | + // Make sure it's the right file type... |
|
169 | + if (! preg_match("/({$this->allowed_file_types})/i", $file)) { |
|
170 | + continue; |
|
171 | + } |
|
172 | + |
|
173 | + $path = is_string($dir) ? $folder . '/' . $dir . '/' . $file : $folder . '/' . $file; |
|
174 | + $term_html = htmlentities($term); |
|
175 | + |
|
176 | + // Read in the file text |
|
177 | + $handle = fopen($path, 'r'); |
|
178 | + $text = fread($handle, $this->byte_size); |
|
179 | + |
|
180 | + // Do we have a match in here somewhere? |
|
181 | + $found = stristr($text, $term) || stristr($text, $term_html); |
|
182 | + |
|
183 | + if (! $found) { |
|
184 | + continue; |
|
185 | + } |
|
186 | + |
|
187 | + // Escape our terms to safely use in a preg_match |
|
188 | + $excerpt = strip_tags($text); |
|
189 | + $term = preg_quote($term); |
|
190 | + $term = str_replace("/", "\/", "{$term}"); |
|
191 | + $term_html = preg_quote($term_html); |
|
192 | + $term_html = str_replace("/", "\/", "{$term_html}"); |
|
193 | + |
|
194 | + // Add the item to our results with extracts. |
|
195 | + if (preg_match_all( |
|
196 | + "/((\s\S*){0,3})($term|$term_html)((\s?\S*){0,3})/i", |
|
197 | + $excerpt, |
|
198 | + $matches, |
|
199 | + PREG_OFFSET_CAPTURE | PREG_SET_ORDER |
|
200 | + )) { |
|
201 | + foreach ($matches as $match) { |
|
202 | + if ($file_count >= $this->max_per_file) { |
|
203 | + continue; |
|
204 | + } |
|
205 | + $result_url = '/docs/' . $group_name . '/' . str_replace('.md', '', $file); |
|
206 | + |
|
207 | + foreach ($this->doc_folders as $alias => $folder) { |
|
208 | + $result_url = str_replace($folder, $alias, $result_url); |
|
209 | + } |
|
210 | + |
|
211 | + $results[] = [ |
|
212 | + 'title' => $this->extractTitle($excerpt, $file), |
|
213 | + 'file' => $folder . '/' . $file, |
|
214 | + 'url' => $result_url, |
|
215 | + 'extract' => $this->buildExtract($excerpt, $term, $match[0][0]) |
|
216 | + ]; |
|
217 | + |
|
218 | + $file_count++; |
|
219 | + } |
|
220 | + } |
|
221 | + } |
|
222 | + |
|
223 | + return $results; |
|
224 | + } |
|
225 | + |
|
226 | + //-------------------------------------------------------------------- |
|
227 | + |
|
228 | + /** |
|
229 | + * Stores the name of the callback method to run to convert the source |
|
230 | + * files to viewable files. By default, this should be used to register |
|
231 | + * a Mardown Extended formatter with the system, but could be used to |
|
232 | + * extend the |
|
233 | + * |
|
234 | + * @param string $callback_name |
|
235 | + * @param bool $cascade // If FALSE the formatting of a component ends here. If TRUE, will be passed to next formatter. |
|
236 | + * @return $this |
|
237 | + */ |
|
238 | + public function registerFormatter($callback_name = '', $cascade = false) |
|
239 | + { |
|
240 | + if (empty($callback_name)) return; |
|
241 | + |
|
242 | + $this->formatters[] = array($callback_name => $cascade); |
|
243 | + |
|
244 | + return $this; |
|
245 | + } |
|
246 | + |
|
247 | + //-------------------------------------------------------------------- |
|
248 | + |
|
249 | + /** |
|
250 | + * Runs the text through the registered formatters. |
|
251 | + * |
|
252 | + * @param $str |
|
253 | + * @return mixed |
|
254 | + */ |
|
255 | + public function format($str) |
|
256 | + { |
|
257 | + if (! is_array($this->formatters)) return $str; |
|
258 | + |
|
259 | + foreach ($this->formatters as $formatter) { |
|
260 | + $method = key($formatter); |
|
261 | + $cascade = $formatter[$method]; |
|
262 | + |
|
263 | + $str = call_user_func($method, $str); |
|
264 | + |
|
265 | + if (! $cascade) return $str; |
|
266 | + } |
|
267 | + |
|
268 | + return $str; |
|
269 | + } |
|
270 | + |
|
271 | + //-------------------------------------------------------------------- |
|
272 | + |
|
273 | + |
|
274 | + //-------------------------------------------------------------------- |
|
275 | + // Protected Methods |
|
276 | + //-------------------------------------------------------------------- |
|
277 | + |
|
278 | + /** |
|
279 | + * Converts an array generated by directory_map into a flat array of |
|
280 | + * folders, removing any nested folders and adding them to the path. |
|
281 | + * |
|
282 | + * @param $map |
|
283 | + * @param $prefix Used to recursively add the folder name... |
|
284 | + * @return mixed |
|
285 | + */ |
|
286 | + protected function flattenMap($map, $prefix = '') |
|
287 | + { |
|
288 | + if (! is_array($map) || ! count($map)) { |
|
289 | + return $map; |
|
290 | + } |
|
291 | + |
|
292 | + $return = []; |
|
293 | + |
|
294 | + foreach ($map as $folder => $files) { |
|
295 | + |
|
296 | + // If it's a folder name and an array of files |
|
297 | + // then call this method recursively to flatten it out. |
|
298 | + if (is_array($files)) { |
|
299 | + $return = array_merge($return, $this->flattenMap($files, $prefix . $folder)); |
|
300 | + continue; |
|
301 | + } |
|
302 | + |
|
303 | + // Else, add our prefix (if any) to the filename... |
|
304 | + $return[] = $prefix . $files; |
|
305 | + } |
|
306 | + |
|
307 | + return $return; |
|
308 | + } |
|
309 | + |
|
310 | + //-------------------------------------------------------------------- |
|
311 | + |
|
312 | + /** |
|
313 | + * Handles extracting the text surrounding our match and basic match formatting. |
|
314 | + * |
|
315 | + * @param $excerpt |
|
316 | + * @param $term |
|
317 | + * @param $match_string |
|
318 | + * |
|
319 | + * @return string |
|
320 | + */ |
|
321 | + protected function buildExtract($excerpt, $term, $match_string) |
|
322 | + { |
|
323 | + // Find the character positions within the string that our match was found at. |
|
324 | + // That way we'll know from what positions before and after this we want to grab it in. |
|
325 | + $start_offset = stripos($excerpt, $match_string); |
|
326 | + |
|
327 | + // Modify the start and end positions based on $this->excerpt_length / 2. |
|
328 | + $buffer = floor($this->excerpt_length / 2); |
|
329 | + |
|
330 | + // Adjust our start position |
|
331 | + $start_offset = $start_offset - $buffer; |
|
332 | + if ($start_offset < 0) { |
|
333 | + $start_offset = 0; |
|
334 | + } |
|
335 | + |
|
336 | + $extract = substr($excerpt, $start_offset); |
|
337 | + |
|
338 | + $extract = strip_tags($this->format($extract)); |
|
339 | + |
|
340 | + $extract = $this->firstXWords($extract, $this->excerpt_length); |
|
341 | + |
|
342 | + // Wrap the search term in a span we can style. |
|
343 | + $extract = str_ireplace($term, '<span class="term-hilight">' . $term . '</span>', $extract); |
|
344 | + |
|
345 | + return $extract; |
|
346 | + } |
|
347 | + |
|
348 | + //-------------------------------------------------------------------- |
|
349 | + |
|
350 | + /** |
|
351 | + * Extracts the title from a bit of markdown formatted text. If it doesn't |
|
352 | + * have an h1 or h2, then it uses the filename. |
|
353 | + * |
|
354 | + * @param $excerpt |
|
355 | + * @param $file |
|
356 | + * @return string |
|
357 | + */ |
|
358 | + protected function extractTitle($excerpt, $file) |
|
359 | + { |
|
360 | + $title = ''; |
|
361 | + |
|
362 | + // Easiest to work if this is split into lines. |
|
363 | + $lines = explode("\n", $excerpt); |
|
364 | + |
|
365 | + if (is_array($lines) && count($lines)) { |
|
366 | + foreach ($lines as $line) { |
|
367 | + if (strpos($line, '# ') === 0 || strpos($line, '## ') === 0) { |
|
368 | + $title = trim(str_replace('#', '', $line)); |
|
369 | + break; |
|
370 | + } |
|
371 | + } |
|
372 | + } |
|
373 | + |
|
374 | + // If it's empty, we'll use the filename. |
|
375 | + if (empty($title)) { |
|
376 | + $title = str_replace('_', ' ', $file); |
|
377 | + $title = str_replace('.md', ' ', $title); |
|
378 | + $title = ucwords($title); |
|
379 | + } |
|
380 | + |
|
381 | + return $title; |
|
382 | + } |
|
383 | + //-------------------------------------------------------------------- |
|
384 | + |
|
385 | + /** |
|
386 | + * Create a Directory Map |
|
387 | + * |
|
388 | + * Reads the specified directory and builds an array |
|
389 | + * representation of it. Sub-folders contained with the |
|
390 | + * directory will be mapped as well. |
|
391 | + * |
|
392 | + * @param string $source_dir Path to source |
|
393 | + * @param int $directory_depth Depth of directories to traverse |
|
394 | + * (0 = fully recursive, 1 = current dir, etc) |
|
395 | + * @param bool $hidden Whether to show hidden files |
|
396 | + * @return array |
|
397 | + */ |
|
398 | + protected function directory_map($source_dir, $directory_depth = 0, $hidden = FALSE) |
|
399 | + { |
|
400 | + if ($fp = @opendir($source_dir)) { |
|
401 | + $filedata = array(); |
|
402 | + $new_depth = $directory_depth - 1; |
|
403 | + $source_dir = rtrim($source_dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
|
404 | + |
|
405 | + while (FALSE !== ($file = readdir($fp))) { |
|
406 | + // Remove '.', '..', and hidden files [optional] |
|
407 | + if ($file === '.' OR $file === '..' OR ($hidden === FALSE && $file[0] === '.')) { |
|
408 | + continue; |
|
409 | + } |
|
410 | + |
|
411 | + is_dir($source_dir . $file) && $file .= DIRECTORY_SEPARATOR; |
|
412 | + |
|
413 | + if (($directory_depth < 1 OR $new_depth > 0) && is_dir($source_dir . $file)) |
|
414 | + { |
|
415 | + $filedata[$file] = $this->directory_map($source_dir . $file, $new_depth, $hidden); |
|
416 | + } else |
|
417 | + { |
|
418 | + // Replace the directory separator here with a forward slash since |
|
419 | + // Windows uses backward slashes and not all browsers will auto-replace |
|
420 | + // those slashes in URLs. |
|
421 | + $filedata[] = str_replace(DIRECTORY_SEPARATOR, '/', $file); |
|
422 | + } |
|
423 | + } |
|
424 | + |
|
425 | + closedir($fp); |
|
426 | + return $filedata; |
|
427 | + } |
|
428 | + |
|
429 | + return FALSE; |
|
430 | + } |
|
431 | + |
|
432 | + //-------------------------------------------------------------------- |
|
433 | + |
|
434 | + /** |
|
435 | + * Gets the first 'X' words of a string. |
|
436 | + * |
|
437 | + * @param $str |
|
438 | + * @param int $wordCount |
|
439 | + * @return string |
|
440 | + */ |
|
441 | + protected function firstXWords($str, $wordCount = 10) |
|
442 | + { |
|
443 | + return implode( |
|
444 | + '', |
|
445 | + array_slice( |
|
446 | + preg_split( |
|
447 | + '/([\s,\.;\?\!]+)/', |
|
448 | + $str, |
|
449 | + $wordCount * 2 + 1, |
|
450 | + PREG_SPLIT_DELIM_CAPTURE |
|
451 | + ), |
|
452 | + 0, |
|
453 | + $wordCount * 2 - 1 |
|
454 | + ) |
|
455 | + ); |
|
456 | + } |
|
457 | + |
|
458 | + //-------------------------------------------------------------------- |
|
459 | 459 | |
460 | 460 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | $map = $this->flattenMap($map); |
148 | 148 | |
149 | 149 | // Make sure we have something to work with. |
150 | - if (! is_array($map) || (is_array($map) && ! count($map))) { |
|
150 | + if ( ! is_array($map) || (is_array($map) && ! count($map))) { |
|
151 | 151 | return []; |
152 | 152 | } |
153 | 153 | |
@@ -161,16 +161,16 @@ discard block |
||
161 | 161 | |
162 | 162 | // Is it a folder? |
163 | 163 | if (is_array($file) && count($file)) { |
164 | - $results = array_merge($results, $this->searchFolder($term, $folder . '/' . $dir, $group_name)); |
|
164 | + $results = array_merge($results, $this->searchFolder($term, $folder.'/'.$dir, $group_name)); |
|
165 | 165 | continue; |
166 | 166 | } |
167 | 167 | |
168 | 168 | // Make sure it's the right file type... |
169 | - if (! preg_match("/({$this->allowed_file_types})/i", $file)) { |
|
169 | + if ( ! preg_match("/({$this->allowed_file_types})/i", $file)) { |
|
170 | 170 | continue; |
171 | 171 | } |
172 | 172 | |
173 | - $path = is_string($dir) ? $folder . '/' . $dir . '/' . $file : $folder . '/' . $file; |
|
173 | + $path = is_string($dir) ? $folder.'/'.$dir.'/'.$file : $folder.'/'.$file; |
|
174 | 174 | $term_html = htmlentities($term); |
175 | 175 | |
176 | 176 | // Read in the file text |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | // Do we have a match in here somewhere? |
181 | 181 | $found = stristr($text, $term) || stristr($text, $term_html); |
182 | 182 | |
183 | - if (! $found) { |
|
183 | + if ( ! $found) { |
|
184 | 184 | continue; |
185 | 185 | } |
186 | 186 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | if ($file_count >= $this->max_per_file) { |
203 | 203 | continue; |
204 | 204 | } |
205 | - $result_url = '/docs/' . $group_name . '/' . str_replace('.md', '', $file); |
|
205 | + $result_url = '/docs/'.$group_name.'/'.str_replace('.md', '', $file); |
|
206 | 206 | |
207 | 207 | foreach ($this->doc_folders as $alias => $folder) { |
208 | 208 | $result_url = str_replace($folder, $alias, $result_url); |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | |
211 | 211 | $results[] = [ |
212 | 212 | 'title' => $this->extractTitle($excerpt, $file), |
213 | - 'file' => $folder . '/' . $file, |
|
213 | + 'file' => $folder.'/'.$file, |
|
214 | 214 | 'url' => $result_url, |
215 | 215 | 'extract' => $this->buildExtract($excerpt, $term, $match[0][0]) |
216 | 216 | ]; |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | */ |
255 | 255 | public function format($str) |
256 | 256 | { |
257 | - if (! is_array($this->formatters)) return $str; |
|
257 | + if ( ! is_array($this->formatters)) return $str; |
|
258 | 258 | |
259 | 259 | foreach ($this->formatters as $formatter) { |
260 | 260 | $method = key($formatter); |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | |
263 | 263 | $str = call_user_func($method, $str); |
264 | 264 | |
265 | - if (! $cascade) return $str; |
|
265 | + if ( ! $cascade) return $str; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | return $str; |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | */ |
286 | 286 | protected function flattenMap($map, $prefix = '') |
287 | 287 | { |
288 | - if (! is_array($map) || ! count($map)) { |
|
288 | + if ( ! is_array($map) || ! count($map)) { |
|
289 | 289 | return $map; |
290 | 290 | } |
291 | 291 | |
@@ -296,12 +296,12 @@ discard block |
||
296 | 296 | // If it's a folder name and an array of files |
297 | 297 | // then call this method recursively to flatten it out. |
298 | 298 | if (is_array($files)) { |
299 | - $return = array_merge($return, $this->flattenMap($files, $prefix . $folder)); |
|
299 | + $return = array_merge($return, $this->flattenMap($files, $prefix.$folder)); |
|
300 | 300 | continue; |
301 | 301 | } |
302 | 302 | |
303 | 303 | // Else, add our prefix (if any) to the filename... |
304 | - $return[] = $prefix . $files; |
|
304 | + $return[] = $prefix.$files; |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | return $return; |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | $extract = $this->firstXWords($extract, $this->excerpt_length); |
341 | 341 | |
342 | 342 | // Wrap the search term in a span we can style. |
343 | - $extract = str_ireplace($term, '<span class="term-hilight">' . $term . '</span>', $extract); |
|
343 | + $extract = str_ireplace($term, '<span class="term-hilight">'.$term.'</span>', $extract); |
|
344 | 344 | |
345 | 345 | return $extract; |
346 | 346 | } |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | if ($fp = @opendir($source_dir)) { |
401 | 401 | $filedata = array(); |
402 | 402 | $new_depth = $directory_depth - 1; |
403 | - $source_dir = rtrim($source_dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
|
403 | + $source_dir = rtrim($source_dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; |
|
404 | 404 | |
405 | 405 | while (FALSE !== ($file = readdir($fp))) { |
406 | 406 | // Remove '.', '..', and hidden files [optional] |
@@ -408,11 +408,11 @@ discard block |
||
408 | 408 | continue; |
409 | 409 | } |
410 | 410 | |
411 | - is_dir($source_dir . $file) && $file .= DIRECTORY_SEPARATOR; |
|
411 | + is_dir($source_dir.$file) && $file .= DIRECTORY_SEPARATOR; |
|
412 | 412 | |
413 | - if (($directory_depth < 1 OR $new_depth > 0) && is_dir($source_dir . $file)) |
|
413 | + if (($directory_depth < 1 OR $new_depth > 0) && is_dir($source_dir.$file)) |
|
414 | 414 | { |
415 | - $filedata[$file] = $this->directory_map($source_dir . $file, $new_depth, $hidden); |
|
415 | + $filedata[$file] = $this->directory_map($source_dir.$file, $new_depth, $hidden); |
|
416 | 416 | } else |
417 | 417 | { |
418 | 418 | // Replace the directory separator here with a forward slash since |
@@ -237,7 +237,9 @@ discard block |
||
237 | 237 | */ |
238 | 238 | public function registerFormatter($callback_name = '', $cascade = false) |
239 | 239 | { |
240 | - if (empty($callback_name)) return; |
|
240 | + if (empty($callback_name)) { |
|
241 | + return; |
|
242 | + } |
|
241 | 243 | |
242 | 244 | $this->formatters[] = array($callback_name => $cascade); |
243 | 245 | |
@@ -254,7 +256,9 @@ discard block |
||
254 | 256 | */ |
255 | 257 | public function format($str) |
256 | 258 | { |
257 | - if (! is_array($this->formatters)) return $str; |
|
259 | + if (! is_array($this->formatters)) { |
|
260 | + return $str; |
|
261 | + } |
|
258 | 262 | |
259 | 263 | foreach ($this->formatters as $formatter) { |
260 | 264 | $method = key($formatter); |
@@ -262,7 +266,9 @@ discard block |
||
262 | 266 | |
263 | 267 | $str = call_user_func($method, $str); |
264 | 268 | |
265 | - if (! $cascade) return $str; |
|
269 | + if (! $cascade) { |
|
270 | + return $str; |
|
271 | + } |
|
266 | 272 | } |
267 | 273 | |
268 | 274 | return $str; |
@@ -36,176 +36,176 @@ |
||
36 | 36 | |
37 | 37 | class Events { |
38 | 38 | |
39 | - /** |
|
40 | - * The list of listeners. |
|
41 | - * |
|
42 | - * @var array |
|
43 | - */ |
|
44 | - protected static $listeners = []; |
|
45 | - |
|
46 | - /** |
|
47 | - * Flag to let us know if we've read from the config file |
|
48 | - * and have all of the defined events. |
|
49 | - * |
|
50 | - * @var bool |
|
51 | - */ |
|
52 | - protected static $have_read_from_file = false; |
|
53 | - |
|
54 | - //-------------------------------------------------------------------- |
|
55 | - |
|
56 | - /** |
|
57 | - * Registers an action to happen on an event. The action can be any sort |
|
58 | - * of callable: |
|
59 | - * |
|
60 | - * Events::on('create', 'myFunction'); // procedural function |
|
61 | - * Events::on('create', ['myClass', 'myMethod']); // Class::method |
|
62 | - * Events::on('create', [$myInstance, 'myMethod']); // Method on an existing instance |
|
63 | - * Events::on('create', function() {}); // Closure |
|
64 | - * |
|
65 | - * @param $event_name |
|
66 | - * @param callable $callback |
|
67 | - * @param int $priority |
|
68 | - */ |
|
69 | - public static function on($event_name, callable $callback, $priority=EVENTS_PRIORITY_NORMAL) |
|
70 | - { |
|
71 | - if (! isset(self::$listeners[$event_name])) |
|
72 | - { |
|
73 | - self::$listeners[$event_name] = [ |
|
74 | - true, // If there's only 1 item, it's sorted. |
|
75 | - [$priority], |
|
76 | - [$callback] |
|
77 | - ]; |
|
78 | - } |
|
79 | - else |
|
80 | - { |
|
81 | - self::$listeners[$event_name][0] = false; // Not sorted |
|
82 | - self::$listeners[$event_name][1][] = $priority; |
|
83 | - self::$listeners[$event_name][2][] = $callback; |
|
84 | - } |
|
85 | - } |
|
39 | + /** |
|
40 | + * The list of listeners. |
|
41 | + * |
|
42 | + * @var array |
|
43 | + */ |
|
44 | + protected static $listeners = []; |
|
45 | + |
|
46 | + /** |
|
47 | + * Flag to let us know if we've read from the config file |
|
48 | + * and have all of the defined events. |
|
49 | + * |
|
50 | + * @var bool |
|
51 | + */ |
|
52 | + protected static $have_read_from_file = false; |
|
53 | + |
|
54 | + //-------------------------------------------------------------------- |
|
55 | + |
|
56 | + /** |
|
57 | + * Registers an action to happen on an event. The action can be any sort |
|
58 | + * of callable: |
|
59 | + * |
|
60 | + * Events::on('create', 'myFunction'); // procedural function |
|
61 | + * Events::on('create', ['myClass', 'myMethod']); // Class::method |
|
62 | + * Events::on('create', [$myInstance, 'myMethod']); // Method on an existing instance |
|
63 | + * Events::on('create', function() {}); // Closure |
|
64 | + * |
|
65 | + * @param $event_name |
|
66 | + * @param callable $callback |
|
67 | + * @param int $priority |
|
68 | + */ |
|
69 | + public static function on($event_name, callable $callback, $priority=EVENTS_PRIORITY_NORMAL) |
|
70 | + { |
|
71 | + if (! isset(self::$listeners[$event_name])) |
|
72 | + { |
|
73 | + self::$listeners[$event_name] = [ |
|
74 | + true, // If there's only 1 item, it's sorted. |
|
75 | + [$priority], |
|
76 | + [$callback] |
|
77 | + ]; |
|
78 | + } |
|
79 | + else |
|
80 | + { |
|
81 | + self::$listeners[$event_name][0] = false; // Not sorted |
|
82 | + self::$listeners[$event_name][1][] = $priority; |
|
83 | + self::$listeners[$event_name][2][] = $callback; |
|
84 | + } |
|
85 | + } |
|
86 | 86 | |
87 | - //-------------------------------------------------------------------- |
|
88 | - |
|
89 | - /** |
|
90 | - * Runs through all subscribed methods running them one at a time, |
|
91 | - * until either: |
|
92 | - * a) All subscribers have finished or |
|
93 | - * b) a method returns false, at which point execution of subscribers stops. |
|
94 | - * |
|
95 | - * @param $event_name |
|
96 | - * @return bool |
|
97 | - */ |
|
98 | - public static function trigger($event_name, array $arguments = []) |
|
99 | - { |
|
100 | - // Read in our config/events file so that we have them all! |
|
101 | - if (! self::$have_read_from_file) |
|
102 | - { |
|
103 | - if (is_file(APPPATH .'config/events.php')) |
|
104 | - { |
|
105 | - include APPPATH .'config/events.php'; |
|
106 | - } |
|
107 | - self::$have_read_from_file = true; |
|
108 | - } |
|
109 | - |
|
110 | - foreach (self::listeners($event_name) as $listener) |
|
111 | - { |
|
112 | - $result = call_user_func_array($listener, $arguments); |
|
113 | - |
|
114 | - if ($result === false) |
|
115 | - { |
|
116 | - return false; |
|
117 | - } |
|
118 | - } |
|
119 | - |
|
120 | - return true; |
|
121 | - } |
|
87 | + //-------------------------------------------------------------------- |
|
88 | + |
|
89 | + /** |
|
90 | + * Runs through all subscribed methods running them one at a time, |
|
91 | + * until either: |
|
92 | + * a) All subscribers have finished or |
|
93 | + * b) a method returns false, at which point execution of subscribers stops. |
|
94 | + * |
|
95 | + * @param $event_name |
|
96 | + * @return bool |
|
97 | + */ |
|
98 | + public static function trigger($event_name, array $arguments = []) |
|
99 | + { |
|
100 | + // Read in our config/events file so that we have them all! |
|
101 | + if (! self::$have_read_from_file) |
|
102 | + { |
|
103 | + if (is_file(APPPATH .'config/events.php')) |
|
104 | + { |
|
105 | + include APPPATH .'config/events.php'; |
|
106 | + } |
|
107 | + self::$have_read_from_file = true; |
|
108 | + } |
|
109 | + |
|
110 | + foreach (self::listeners($event_name) as $listener) |
|
111 | + { |
|
112 | + $result = call_user_func_array($listener, $arguments); |
|
113 | + |
|
114 | + if ($result === false) |
|
115 | + { |
|
116 | + return false; |
|
117 | + } |
|
118 | + } |
|
119 | + |
|
120 | + return true; |
|
121 | + } |
|
122 | 122 | |
123 | - //-------------------------------------------------------------------- |
|
124 | - |
|
125 | - /** |
|
126 | - * Returns an array of listeners for a single event. They are |
|
127 | - * sorted by priority. |
|
128 | - * |
|
129 | - * If the listener could not be found, returns FALSE, or TRUE if |
|
130 | - * it was removed. |
|
131 | - * |
|
132 | - * @param $event_name |
|
133 | - * @return array |
|
134 | - */ |
|
135 | - public static function listeners($event_name) |
|
136 | - { |
|
137 | - if (! isset(self::$listeners[$event_name])) |
|
138 | - { |
|
139 | - return []; |
|
140 | - } |
|
141 | - |
|
142 | - // The list is not sorted |
|
143 | - if (! self::$listeners[$event_name][0]) |
|
144 | - { |
|
145 | - // Sort it! |
|
146 | - array_multisort(self::$listeners[$event_name][1], SORT_NUMERIC, self::$listeners[$event_name][2]); |
|
147 | - |
|
148 | - // Mark it as sorted already! |
|
149 | - self::$listeners[$event_name][0] = true; |
|
150 | - } |
|
151 | - |
|
152 | - return self::$listeners[$event_name][2]; |
|
153 | - } |
|
154 | - |
|
155 | - //-------------------------------------------------------------------- |
|
156 | - |
|
157 | - /** |
|
158 | - * Removes a single listener from an event. |
|
159 | - * |
|
160 | - * If the listener couldn't be found, returns FALSE, else TRUE if |
|
161 | - * it was removed. |
|
162 | - * |
|
163 | - * @param $event_name |
|
164 | - * @param callable $listener |
|
165 | - * @return bool |
|
166 | - */ |
|
167 | - public static function removeListener($event_name, callable $listener) |
|
168 | - { |
|
169 | - if (! isset(self::$listeners[$event_name])) |
|
170 | - { |
|
171 | - return false; |
|
172 | - } |
|
173 | - |
|
174 | - foreach (self::$listeners[$event_name][2] as $index => $check) |
|
175 | - { |
|
176 | - if ($check === $listener) |
|
177 | - { |
|
178 | - unset(self::$listeners[$event_name][1][$index]); |
|
179 | - unset(self::$listeners[$event_name][2][$index]); |
|
180 | - |
|
181 | - return true; |
|
182 | - } |
|
183 | - } |
|
184 | - |
|
185 | - return false; |
|
186 | - } |
|
187 | - |
|
188 | - //-------------------------------------------------------------------- |
|
189 | - |
|
190 | - /** |
|
191 | - * Removes all listeners. |
|
192 | - * |
|
193 | - * If the event_name is specified, only listeners for that event will be |
|
194 | - * removed, otherwise all listeners for all events are removed. |
|
195 | - * |
|
196 | - * @param null $event_name |
|
197 | - */ |
|
198 | - public static function removeAllListeners($event_name=null) |
|
199 | - { |
|
200 | - if (! is_null($event_name)) |
|
201 | - { |
|
202 | - unset(self::$listeners[$event_name]); |
|
203 | - } |
|
204 | - else { |
|
205 | - self::$listeners = []; |
|
206 | - } |
|
207 | - } |
|
208 | - |
|
209 | - //-------------------------------------------------------------------- |
|
123 | + //-------------------------------------------------------------------- |
|
124 | + |
|
125 | + /** |
|
126 | + * Returns an array of listeners for a single event. They are |
|
127 | + * sorted by priority. |
|
128 | + * |
|
129 | + * If the listener could not be found, returns FALSE, or TRUE if |
|
130 | + * it was removed. |
|
131 | + * |
|
132 | + * @param $event_name |
|
133 | + * @return array |
|
134 | + */ |
|
135 | + public static function listeners($event_name) |
|
136 | + { |
|
137 | + if (! isset(self::$listeners[$event_name])) |
|
138 | + { |
|
139 | + return []; |
|
140 | + } |
|
141 | + |
|
142 | + // The list is not sorted |
|
143 | + if (! self::$listeners[$event_name][0]) |
|
144 | + { |
|
145 | + // Sort it! |
|
146 | + array_multisort(self::$listeners[$event_name][1], SORT_NUMERIC, self::$listeners[$event_name][2]); |
|
147 | + |
|
148 | + // Mark it as sorted already! |
|
149 | + self::$listeners[$event_name][0] = true; |
|
150 | + } |
|
151 | + |
|
152 | + return self::$listeners[$event_name][2]; |
|
153 | + } |
|
154 | + |
|
155 | + //-------------------------------------------------------------------- |
|
156 | + |
|
157 | + /** |
|
158 | + * Removes a single listener from an event. |
|
159 | + * |
|
160 | + * If the listener couldn't be found, returns FALSE, else TRUE if |
|
161 | + * it was removed. |
|
162 | + * |
|
163 | + * @param $event_name |
|
164 | + * @param callable $listener |
|
165 | + * @return bool |
|
166 | + */ |
|
167 | + public static function removeListener($event_name, callable $listener) |
|
168 | + { |
|
169 | + if (! isset(self::$listeners[$event_name])) |
|
170 | + { |
|
171 | + return false; |
|
172 | + } |
|
173 | + |
|
174 | + foreach (self::$listeners[$event_name][2] as $index => $check) |
|
175 | + { |
|
176 | + if ($check === $listener) |
|
177 | + { |
|
178 | + unset(self::$listeners[$event_name][1][$index]); |
|
179 | + unset(self::$listeners[$event_name][2][$index]); |
|
180 | + |
|
181 | + return true; |
|
182 | + } |
|
183 | + } |
|
184 | + |
|
185 | + return false; |
|
186 | + } |
|
187 | + |
|
188 | + //-------------------------------------------------------------------- |
|
189 | + |
|
190 | + /** |
|
191 | + * Removes all listeners. |
|
192 | + * |
|
193 | + * If the event_name is specified, only listeners for that event will be |
|
194 | + * removed, otherwise all listeners for all events are removed. |
|
195 | + * |
|
196 | + * @param null $event_name |
|
197 | + */ |
|
198 | + public static function removeAllListeners($event_name=null) |
|
199 | + { |
|
200 | + if (! is_null($event_name)) |
|
201 | + { |
|
202 | + unset(self::$listeners[$event_name]); |
|
203 | + } |
|
204 | + else { |
|
205 | + self::$listeners = []; |
|
206 | + } |
|
207 | + } |
|
208 | + |
|
209 | + //-------------------------------------------------------------------- |
|
210 | 210 | |
211 | 211 | } |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | * @param callable $callback |
67 | 67 | * @param int $priority |
68 | 68 | */ |
69 | - public static function on($event_name, callable $callback, $priority=EVENTS_PRIORITY_NORMAL) |
|
69 | + public static function on($event_name, callable $callback, $priority = EVENTS_PRIORITY_NORMAL) |
|
70 | 70 | { |
71 | - if (! isset(self::$listeners[$event_name])) |
|
71 | + if ( ! isset(self::$listeners[$event_name])) |
|
72 | 72 | { |
73 | 73 | self::$listeners[$event_name] = [ |
74 | - true, // If there's only 1 item, it's sorted. |
|
74 | + true, // If there's only 1 item, it's sorted. |
|
75 | 75 | [$priority], |
76 | 76 | [$callback] |
77 | 77 | ]; |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | public static function trigger($event_name, array $arguments = []) |
99 | 99 | { |
100 | 100 | // Read in our config/events file so that we have them all! |
101 | - if (! self::$have_read_from_file) |
|
101 | + if ( ! self::$have_read_from_file) |
|
102 | 102 | { |
103 | - if (is_file(APPPATH .'config/events.php')) |
|
103 | + if (is_file(APPPATH.'config/events.php')) |
|
104 | 104 | { |
105 | - include APPPATH .'config/events.php'; |
|
105 | + include APPPATH.'config/events.php'; |
|
106 | 106 | } |
107 | 107 | self::$have_read_from_file = true; |
108 | 108 | } |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public static function listeners($event_name) |
136 | 136 | { |
137 | - if (! isset(self::$listeners[$event_name])) |
|
137 | + if ( ! isset(self::$listeners[$event_name])) |
|
138 | 138 | { |
139 | 139 | return []; |
140 | 140 | } |
141 | 141 | |
142 | 142 | // The list is not sorted |
143 | - if (! self::$listeners[$event_name][0]) |
|
143 | + if ( ! self::$listeners[$event_name][0]) |
|
144 | 144 | { |
145 | 145 | // Sort it! |
146 | 146 | array_multisort(self::$listeners[$event_name][1], SORT_NUMERIC, self::$listeners[$event_name][2]); |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public static function removeListener($event_name, callable $listener) |
168 | 168 | { |
169 | - if (! isset(self::$listeners[$event_name])) |
|
169 | + if ( ! isset(self::$listeners[$event_name])) |
|
170 | 170 | { |
171 | 171 | return false; |
172 | 172 | } |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | * |
196 | 196 | * @param null $event_name |
197 | 197 | */ |
198 | - public static function removeAllListeners($event_name=null) |
|
198 | + public static function removeAllListeners($event_name = null) |
|
199 | 199 | { |
200 | - if (! is_null($event_name)) |
|
200 | + if ( ! is_null($event_name)) |
|
201 | 201 | { |
202 | 202 | unset(self::$listeners[$event_name]); |
203 | 203 | } |
@@ -75,8 +75,7 @@ discard block |
||
75 | 75 | [$priority], |
76 | 76 | [$callback] |
77 | 77 | ]; |
78 | - } |
|
79 | - else |
|
78 | + } else |
|
80 | 79 | { |
81 | 80 | self::$listeners[$event_name][0] = false; // Not sorted |
82 | 81 | self::$listeners[$event_name][1][] = $priority; |
@@ -200,8 +199,7 @@ discard block |
||
200 | 199 | if (! is_null($event_name)) |
201 | 200 | { |
202 | 201 | unset(self::$listeners[$event_name]); |
203 | - } |
|
204 | - else { |
|
202 | + } else { |
|
205 | 203 | self::$listeners = []; |
206 | 204 | } |
207 | 205 | } |
@@ -167,11 +167,11 @@ |
||
167 | 167 | |
168 | 168 | public function reset() |
169 | 169 | { |
170 | - self::$logs = array( |
|
171 | - 'console' => array(), |
|
172 | - 'log_count' => 0, |
|
173 | - 'memory_count' => 0, |
|
174 | - ); |
|
170 | + self::$logs = array( |
|
171 | + 'console' => array(), |
|
172 | + 'log_count' => 0, |
|
173 | + 'memory_count' => 0, |
|
174 | + ); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | //-------------------------------------------------------------------- |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public static function init() |
94 | 94 | { |
95 | - self::$ci =& get_instance(); |
|
95 | + self::$ci = & get_instance(); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | //-------------------------------------------------------------------- |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | Parameters: |
106 | 106 | $data - The variable to log. |
107 | 107 | */ |
108 | - public static function log($data=null) |
|
108 | + public static function log($data = null) |
|
109 | 109 | { |
110 | 110 | if ($data !== 0 && empty($data)) |
111 | 111 | { |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $object - The object to store the memory usage of. |
132 | 132 | $name - The name to be displayed in the console. |
133 | 133 | */ |
134 | - public static function logMemory($object=false, $name='PHP') |
|
134 | + public static function logMemory($object = false, $name = 'PHP') |
|
135 | 135 | { |
136 | 136 | $memory = memory_get_usage(); |
137 | 137 | |
@@ -182,15 +182,15 @@ discard block |
||
182 | 182 | // !PRIVATE METHODS |
183 | 183 | //-------------------------------------------------------------------- |
184 | 184 | |
185 | - protected static function addToConsole($log=null, $item=null) |
|
185 | + protected static function addToConsole($log = null, $item = null) |
|
186 | 186 | { |
187 | 187 | if (empty($log) || empty($item)) |
188 | 188 | { |
189 | 189 | return; |
190 | 190 | } |
191 | 191 | |
192 | - self::$logs['console'][] = $item; |
|
193 | - self::$logs[$log] += 1; |
|
192 | + self::$logs['console'][] = $item; |
|
193 | + self::$logs[$log] += 1; |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | //-------------------------------------------------------------------- |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | Load Time |
197 | 197 | </a> |
198 | 198 | <a href="#" id="ci-profiler-menu-memory" onclick="ci_profiler_bar.show('ci-profiler-memory', 'ci-profiler-menu-memory'); return false;"> |
199 | - <span><?php echo (! function_exists('memory_get_usage')) ? '0' : round(memory_get_usage()/1024/1024, 2).' MB' ?></span> |
|
199 | + <span><?php echo ( ! function_exists('memory_get_usage')) ? '0' : round(memory_get_usage() / 1024 / 1024, 2).' MB' ?></span> |
|
200 | 200 | Memory Used |
201 | 201 | </a> |
202 | 202 | <?php endif; ?> |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | |
385 | 385 | <?php $append = ($section == 'get' || $section == 'post') ? '_data' : '' ?> |
386 | 386 | <a href="#" onclick="ci_profiler_bar.toggle_data_table('<?php echo $section ?>'); return false;"> |
387 | - <h2><?php echo lang('profiler_' . $section . $append) ?></h2> |
|
387 | + <h2><?php echo lang('profiler_'.$section.$append) ?></h2> |
|
388 | 388 | </a> |
389 | 389 | |
390 | 390 |
@@ -257,9 +257,12 @@ discard block |
||
257 | 257 | <?php endforeach; ?> |
258 | 258 | </table> |
259 | 259 | |
260 | - <?php else : ?> |
|
260 | + <?php else { |
|
261 | + : ?> |
|
261 | 262 | |
262 | - <?php echo $sections['console']; ?> |
|
263 | + <?php echo $sections['console']; |
|
264 | +} |
|
265 | +?> |
|
263 | 266 | |
264 | 267 | <?php endif; ?> |
265 | 268 | </div> |
@@ -288,9 +291,12 @@ discard block |
||
288 | 291 | <?php endforeach; ?> |
289 | 292 | </table> |
290 | 293 | |
291 | - <?php else : ?> |
|
294 | + <?php else { |
|
295 | + : ?> |
|
292 | 296 | |
293 | - <?php echo $sections['console']; ?> |
|
297 | + <?php echo $sections['console']; |
|
298 | +} |
|
299 | +?> |
|
294 | 300 | |
295 | 301 | <?php endif; ?> |
296 | 302 | </div> |
@@ -309,9 +315,12 @@ discard block |
||
309 | 315 | <?php endforeach; ?> |
310 | 316 | </table> |
311 | 317 | |
312 | - <?php else : ?> |
|
318 | + <?php else { |
|
319 | + : ?> |
|
313 | 320 | |
314 | - <?php echo $sections['benchmarks']; ?> |
|
321 | + <?php echo $sections['benchmarks']; |
|
322 | +} |
|
323 | +?> |
|
315 | 324 | |
316 | 325 | <?php endif; ?> |
317 | 326 | </div> |
@@ -332,9 +341,12 @@ discard block |
||
332 | 341 | <?php endforeach; ?> |
333 | 342 | </table> |
334 | 343 | |
335 | - <?php else : ?> |
|
344 | + <?php else { |
|
345 | + : ?> |
|
336 | 346 | |
337 | - <?php echo $sections['queries']; ?> |
|
347 | + <?php echo $sections['queries']; |
|
348 | +} |
|
349 | +?> |
|
338 | 350 | |
339 | 351 | <?php endif; ?> |
340 | 352 | </div> |
@@ -394,8 +406,11 @@ discard block |
||
394 | 406 | <?php foreach ($sections[$section] as $key => $val) : ?> |
395 | 407 | <tr><td class="hilight"><?php echo $key ?></td><td><?php echo htmlspecialchars($val) ?></td></tr> |
396 | 408 | <?php endforeach; ?> |
397 | - <?php else : ?> |
|
398 | - <tr><td><?php echo $sections[$section]; ?></td></tr> |
|
409 | + <?php else { |
|
410 | + : ?> |
|
411 | + <tr><td><?php echo $sections[$section]; |
|
412 | +} |
|
413 | +?></td></tr> |
|
399 | 414 | <?php endif; ?> |
400 | 415 | </table> |
401 | 416 | <?php endif; ?> |
@@ -422,19 +437,25 @@ discard block |
||
422 | 437 | <?php endforeach; ?> |
423 | 438 | </table> |
424 | 439 | |
425 | - <?php else : ?> |
|
440 | + <?php else { |
|
441 | + : ?> |
|
426 | 442 | |
427 | - <?php echo $sections['files']; ?> |
|
443 | + <?php echo $sections['files']; |
|
444 | +} |
|
445 | +?> |
|
428 | 446 | |
429 | 447 | <?php endif; ?> |
430 | 448 | </div> |
431 | 449 | <?php endif; ?> |
432 | 450 | |
433 | 451 | |
434 | -<?php else: ?> |
|
452 | +<?php else { |
|
453 | + : ?> |
|
435 | 454 | |
436 | 455 | <p class="ci-profiler-box"><?php echo lang('profiler_no_profiles') ?></p> |
437 | 456 | |
438 | -<?php endif; ?> |
|
457 | +<?php endif; |
|
458 | +} |
|
459 | +?> |
|
439 | 460 | |
440 | 461 | </div> <!-- /codeigniter_profiler --> |
@@ -32,206 +32,206 @@ |
||
32 | 32 | |
33 | 33 | class FileKit { |
34 | 34 | |
35 | - /** |
|
36 | - * Appends data to the end of a file. |
|
37 | - * |
|
38 | - * @param $file |
|
39 | - * @param $content |
|
40 | - * @return bool|int |
|
41 | - */ |
|
42 | - public function append($file, $content) |
|
43 | - { |
|
44 | - if (empty($content)) |
|
45 | - { |
|
46 | - return true; |
|
47 | - } |
|
48 | - |
|
49 | - // Ensure that $content has a newline at the end |
|
50 | - $content = rtrim($content) ."\n"; |
|
51 | - |
|
52 | - $fh = fopen($file, 'a'); |
|
53 | - $result = fwrite($fh, $content); |
|
54 | - fclose($fh); |
|
55 | - |
|
56 | - return $result; |
|
57 | - } |
|
58 | - |
|
59 | - //-------------------------------------------------------------------- |
|
60 | - |
|
61 | - /** |
|
62 | - * Prepends string content to a file. For very large files |
|
63 | - * this method could have memory issues, but the primary usage |
|
64 | - * of source files shouldn't ever get large enough to cause issues. |
|
65 | - * |
|
66 | - * @param $file |
|
67 | - * @param $content |
|
68 | - * @return bool|int |
|
69 | - */ |
|
70 | - public function prepend($file, $content) |
|
71 | - { |
|
72 | - if (empty($content)) |
|
73 | - { |
|
74 | - return true; |
|
75 | - } |
|
76 | - |
|
77 | - // Ensure that $content has a newline at the end |
|
78 | - $content = rtrim($content) ."\n"; |
|
79 | - |
|
80 | - $file_contents = file_get_contents($file); |
|
81 | - |
|
82 | - if ($file_contents === false) |
|
83 | - { |
|
84 | - throw new \RuntimeException( sprintf(lang('errors.reading_file'), $file)); |
|
85 | - } |
|
86 | - |
|
87 | - $result = file_put_contents($file, $content . $file_contents); |
|
88 | - |
|
89 | - return (bool)$result; |
|
90 | - } |
|
91 | - |
|
92 | - //-------------------------------------------------------------------- |
|
93 | - |
|
94 | - /** |
|
95 | - * Inserts $content before the line that matches $before. NOT case- |
|
96 | - * sensitive. |
|
97 | - * |
|
98 | - * @param $file |
|
99 | - * @param $before |
|
100 | - * @param $content |
|
101 | - * @return int |
|
102 | - */ |
|
103 | - public function before($file, $before, $content) |
|
104 | - { |
|
105 | - if (empty($content)) |
|
106 | - { |
|
107 | - return true; |
|
108 | - } |
|
109 | - |
|
110 | - // Ensure that $content has a newline at the end |
|
111 | - $content = rtrim($content) ."\n"; |
|
112 | - |
|
113 | - $lines = file($file); |
|
114 | - |
|
115 | - if ($lines === false) |
|
116 | - { |
|
117 | - throw new \RuntimeException( sprintf( lang('errors.file_not_found'), $file )); |
|
118 | - } |
|
119 | - |
|
120 | - // Where to insert the row. |
|
121 | - $location = null; |
|
122 | - |
|
123 | - foreach ($lines as $index => $line) |
|
124 | - { |
|
125 | - if (strtolower($line) == strtolower($before) ) |
|
126 | - { |
|
127 | - $location = $index; |
|
128 | - break; |
|
129 | - } |
|
130 | - } |
|
131 | - |
|
132 | - array_splice($lines, $location, 0, $content); |
|
133 | - |
|
134 | - $result = file_put_contents($file, $lines); |
|
135 | - |
|
136 | - return (bool)$result; |
|
137 | - } |
|
138 | - |
|
139 | - //-------------------------------------------------------------------- |
|
140 | - |
|
141 | - public function after($file, $after, $content) |
|
142 | - { |
|
143 | - if (empty($content)) |
|
144 | - { |
|
145 | - return true; |
|
146 | - } |
|
147 | - |
|
148 | - // Ensure that $content has a newline at the end |
|
149 | - $content = rtrim($content) ."\n"; |
|
150 | - |
|
151 | - $lines = file($file); |
|
152 | - |
|
153 | - if ($lines === false) |
|
154 | - { |
|
155 | - throw new \RuntimeException( sprintf( lang('errors.file_not_found'), $file ) ); |
|
156 | - } |
|
157 | - |
|
158 | - // Where to insert the row. |
|
159 | - $location = null; |
|
160 | - |
|
161 | - foreach ($lines as $index => $line) |
|
162 | - { |
|
163 | - if (strtolower($line) == strtolower($after) ) |
|
164 | - { |
|
165 | - $location = $index; |
|
166 | - break; |
|
167 | - } |
|
168 | - } |
|
169 | - |
|
170 | - array_splice($lines, $location +1, 0, $content); |
|
171 | - |
|
172 | - $result = file_put_contents($file, $lines); |
|
173 | - |
|
174 | - return (bool)$result; |
|
175 | - } |
|
176 | - |
|
177 | - //-------------------------------------------------------------------- |
|
178 | - |
|
179 | - /** |
|
180 | - * Replaces all instances of $search in the file with $replace. |
|
181 | - * |
|
182 | - * @param $file |
|
183 | - * @param $search |
|
184 | - * @param $replace |
|
185 | - * @return int |
|
186 | - */ |
|
187 | - public function replaceIn($file, $search, $replace) |
|
188 | - { |
|
189 | - $file_contents = file_get_contents($file); |
|
190 | - |
|
191 | - if ($file_contents === false) |
|
192 | - { |
|
193 | - throw new \RuntimeException( sprintf( lang('errors.reading_file'), $file ) ); |
|
194 | - } |
|
195 | - |
|
196 | - $file_contents = str_replace($search, $replace, $file_contents); |
|
197 | - |
|
198 | - $result = file_put_contents($file, $file_contents); |
|
199 | - |
|
200 | - return (bool)$result; |
|
201 | - } |
|
202 | - |
|
203 | - //-------------------------------------------------------------------- |
|
204 | - |
|
205 | - /** |
|
206 | - * Uses preg_replace to replace content within the file. |
|
207 | - * |
|
208 | - * @param $file |
|
209 | - * @param $pattern |
|
210 | - * @param $replace |
|
211 | - * @return int |
|
212 | - */ |
|
213 | - public function replaceWithRegex($file, $pattern, $replace) |
|
214 | - { |
|
215 | - $file_contents = file_get_contents($file); |
|
216 | - |
|
217 | - if ($file_contents === false) |
|
218 | - { |
|
219 | - throw new \RuntimeException( sprintf( lang('errors.reading_file'), $file ) ); |
|
220 | - } |
|
35 | + /** |
|
36 | + * Appends data to the end of a file. |
|
37 | + * |
|
38 | + * @param $file |
|
39 | + * @param $content |
|
40 | + * @return bool|int |
|
41 | + */ |
|
42 | + public function append($file, $content) |
|
43 | + { |
|
44 | + if (empty($content)) |
|
45 | + { |
|
46 | + return true; |
|
47 | + } |
|
48 | + |
|
49 | + // Ensure that $content has a newline at the end |
|
50 | + $content = rtrim($content) ."\n"; |
|
51 | + |
|
52 | + $fh = fopen($file, 'a'); |
|
53 | + $result = fwrite($fh, $content); |
|
54 | + fclose($fh); |
|
55 | + |
|
56 | + return $result; |
|
57 | + } |
|
58 | + |
|
59 | + //-------------------------------------------------------------------- |
|
60 | + |
|
61 | + /** |
|
62 | + * Prepends string content to a file. For very large files |
|
63 | + * this method could have memory issues, but the primary usage |
|
64 | + * of source files shouldn't ever get large enough to cause issues. |
|
65 | + * |
|
66 | + * @param $file |
|
67 | + * @param $content |
|
68 | + * @return bool|int |
|
69 | + */ |
|
70 | + public function prepend($file, $content) |
|
71 | + { |
|
72 | + if (empty($content)) |
|
73 | + { |
|
74 | + return true; |
|
75 | + } |
|
76 | + |
|
77 | + // Ensure that $content has a newline at the end |
|
78 | + $content = rtrim($content) ."\n"; |
|
79 | + |
|
80 | + $file_contents = file_get_contents($file); |
|
81 | + |
|
82 | + if ($file_contents === false) |
|
83 | + { |
|
84 | + throw new \RuntimeException( sprintf(lang('errors.reading_file'), $file)); |
|
85 | + } |
|
86 | + |
|
87 | + $result = file_put_contents($file, $content . $file_contents); |
|
88 | + |
|
89 | + return (bool)$result; |
|
90 | + } |
|
91 | + |
|
92 | + //-------------------------------------------------------------------- |
|
93 | + |
|
94 | + /** |
|
95 | + * Inserts $content before the line that matches $before. NOT case- |
|
96 | + * sensitive. |
|
97 | + * |
|
98 | + * @param $file |
|
99 | + * @param $before |
|
100 | + * @param $content |
|
101 | + * @return int |
|
102 | + */ |
|
103 | + public function before($file, $before, $content) |
|
104 | + { |
|
105 | + if (empty($content)) |
|
106 | + { |
|
107 | + return true; |
|
108 | + } |
|
109 | + |
|
110 | + // Ensure that $content has a newline at the end |
|
111 | + $content = rtrim($content) ."\n"; |
|
112 | + |
|
113 | + $lines = file($file); |
|
114 | + |
|
115 | + if ($lines === false) |
|
116 | + { |
|
117 | + throw new \RuntimeException( sprintf( lang('errors.file_not_found'), $file )); |
|
118 | + } |
|
119 | + |
|
120 | + // Where to insert the row. |
|
121 | + $location = null; |
|
122 | + |
|
123 | + foreach ($lines as $index => $line) |
|
124 | + { |
|
125 | + if (strtolower($line) == strtolower($before) ) |
|
126 | + { |
|
127 | + $location = $index; |
|
128 | + break; |
|
129 | + } |
|
130 | + } |
|
131 | + |
|
132 | + array_splice($lines, $location, 0, $content); |
|
133 | + |
|
134 | + $result = file_put_contents($file, $lines); |
|
135 | + |
|
136 | + return (bool)$result; |
|
137 | + } |
|
138 | + |
|
139 | + //-------------------------------------------------------------------- |
|
140 | + |
|
141 | + public function after($file, $after, $content) |
|
142 | + { |
|
143 | + if (empty($content)) |
|
144 | + { |
|
145 | + return true; |
|
146 | + } |
|
147 | + |
|
148 | + // Ensure that $content has a newline at the end |
|
149 | + $content = rtrim($content) ."\n"; |
|
150 | + |
|
151 | + $lines = file($file); |
|
152 | + |
|
153 | + if ($lines === false) |
|
154 | + { |
|
155 | + throw new \RuntimeException( sprintf( lang('errors.file_not_found'), $file ) ); |
|
156 | + } |
|
157 | + |
|
158 | + // Where to insert the row. |
|
159 | + $location = null; |
|
160 | + |
|
161 | + foreach ($lines as $index => $line) |
|
162 | + { |
|
163 | + if (strtolower($line) == strtolower($after) ) |
|
164 | + { |
|
165 | + $location = $index; |
|
166 | + break; |
|
167 | + } |
|
168 | + } |
|
169 | + |
|
170 | + array_splice($lines, $location +1, 0, $content); |
|
171 | + |
|
172 | + $result = file_put_contents($file, $lines); |
|
173 | + |
|
174 | + return (bool)$result; |
|
175 | + } |
|
176 | + |
|
177 | + //-------------------------------------------------------------------- |
|
178 | + |
|
179 | + /** |
|
180 | + * Replaces all instances of $search in the file with $replace. |
|
181 | + * |
|
182 | + * @param $file |
|
183 | + * @param $search |
|
184 | + * @param $replace |
|
185 | + * @return int |
|
186 | + */ |
|
187 | + public function replaceIn($file, $search, $replace) |
|
188 | + { |
|
189 | + $file_contents = file_get_contents($file); |
|
190 | + |
|
191 | + if ($file_contents === false) |
|
192 | + { |
|
193 | + throw new \RuntimeException( sprintf( lang('errors.reading_file'), $file ) ); |
|
194 | + } |
|
195 | + |
|
196 | + $file_contents = str_replace($search, $replace, $file_contents); |
|
197 | + |
|
198 | + $result = file_put_contents($file, $file_contents); |
|
199 | + |
|
200 | + return (bool)$result; |
|
201 | + } |
|
202 | + |
|
203 | + //-------------------------------------------------------------------- |
|
204 | + |
|
205 | + /** |
|
206 | + * Uses preg_replace to replace content within the file. |
|
207 | + * |
|
208 | + * @param $file |
|
209 | + * @param $pattern |
|
210 | + * @param $replace |
|
211 | + * @return int |
|
212 | + */ |
|
213 | + public function replaceWithRegex($file, $pattern, $replace) |
|
214 | + { |
|
215 | + $file_contents = file_get_contents($file); |
|
216 | + |
|
217 | + if ($file_contents === false) |
|
218 | + { |
|
219 | + throw new \RuntimeException( sprintf( lang('errors.reading_file'), $file ) ); |
|
220 | + } |
|
221 | 221 | |
222 | - $file_contents = preg_replace($pattern, $replace, $file_contents); |
|
223 | - |
|
224 | - $result = false; |
|
222 | + $file_contents = preg_replace($pattern, $replace, $file_contents); |
|
223 | + |
|
224 | + $result = false; |
|
225 | 225 | |
226 | - // Don't let us erase a file! |
|
227 | - if (! empty($file_contents)) |
|
228 | - { |
|
229 | - $result = file_put_contents( $file, $file_contents ); |
|
230 | - } |
|
226 | + // Don't let us erase a file! |
|
227 | + if (! empty($file_contents)) |
|
228 | + { |
|
229 | + $result = file_put_contents( $file, $file_contents ); |
|
230 | + } |
|
231 | 231 | |
232 | - return (bool)$result; |
|
233 | - } |
|
232 | + return (bool)$result; |
|
233 | + } |
|
234 | 234 | |
235 | - //-------------------------------------------------------------------- |
|
235 | + //-------------------------------------------------------------------- |
|
236 | 236 | |
237 | 237 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | // Ensure that $content has a newline at the end |
50 | - $content = rtrim($content) ."\n"; |
|
50 | + $content = rtrim($content)."\n"; |
|
51 | 51 | |
52 | 52 | $fh = fopen($file, 'a'); |
53 | 53 | $result = fwrite($fh, $content); |
@@ -75,18 +75,18 @@ discard block |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | // Ensure that $content has a newline at the end |
78 | - $content = rtrim($content) ."\n"; |
|
78 | + $content = rtrim($content)."\n"; |
|
79 | 79 | |
80 | 80 | $file_contents = file_get_contents($file); |
81 | 81 | |
82 | 82 | if ($file_contents === false) |
83 | 83 | { |
84 | - throw new \RuntimeException( sprintf(lang('errors.reading_file'), $file)); |
|
84 | + throw new \RuntimeException(sprintf(lang('errors.reading_file'), $file)); |
|
85 | 85 | } |
86 | 86 | |
87 | - $result = file_put_contents($file, $content . $file_contents); |
|
87 | + $result = file_put_contents($file, $content.$file_contents); |
|
88 | 88 | |
89 | - return (bool)$result; |
|
89 | + return (bool) $result; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | //-------------------------------------------------------------------- |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | } |
109 | 109 | |
110 | 110 | // Ensure that $content has a newline at the end |
111 | - $content = rtrim($content) ."\n"; |
|
111 | + $content = rtrim($content)."\n"; |
|
112 | 112 | |
113 | 113 | $lines = file($file); |
114 | 114 | |
115 | 115 | if ($lines === false) |
116 | 116 | { |
117 | - throw new \RuntimeException( sprintf( lang('errors.file_not_found'), $file )); |
|
117 | + throw new \RuntimeException(sprintf(lang('errors.file_not_found'), $file)); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | // Where to insert the row. |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | |
123 | 123 | foreach ($lines as $index => $line) |
124 | 124 | { |
125 | - if (strtolower($line) == strtolower($before) ) |
|
125 | + if (strtolower($line) == strtolower($before)) |
|
126 | 126 | { |
127 | 127 | $location = $index; |
128 | 128 | break; |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | |
134 | 134 | $result = file_put_contents($file, $lines); |
135 | 135 | |
136 | - return (bool)$result; |
|
136 | + return (bool) $result; |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | //-------------------------------------------------------------------- |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | } |
147 | 147 | |
148 | 148 | // Ensure that $content has a newline at the end |
149 | - $content = rtrim($content) ."\n"; |
|
149 | + $content = rtrim($content)."\n"; |
|
150 | 150 | |
151 | 151 | $lines = file($file); |
152 | 152 | |
153 | 153 | if ($lines === false) |
154 | 154 | { |
155 | - throw new \RuntimeException( sprintf( lang('errors.file_not_found'), $file ) ); |
|
155 | + throw new \RuntimeException(sprintf(lang('errors.file_not_found'), $file)); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | // Where to insert the row. |
@@ -160,18 +160,18 @@ discard block |
||
160 | 160 | |
161 | 161 | foreach ($lines as $index => $line) |
162 | 162 | { |
163 | - if (strtolower($line) == strtolower($after) ) |
|
163 | + if (strtolower($line) == strtolower($after)) |
|
164 | 164 | { |
165 | 165 | $location = $index; |
166 | 166 | break; |
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
170 | - array_splice($lines, $location +1, 0, $content); |
|
170 | + array_splice($lines, $location + 1, 0, $content); |
|
171 | 171 | |
172 | 172 | $result = file_put_contents($file, $lines); |
173 | 173 | |
174 | - return (bool)$result; |
|
174 | + return (bool) $result; |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | //-------------------------------------------------------------------- |
@@ -190,14 +190,14 @@ discard block |
||
190 | 190 | |
191 | 191 | if ($file_contents === false) |
192 | 192 | { |
193 | - throw new \RuntimeException( sprintf( lang('errors.reading_file'), $file ) ); |
|
193 | + throw new \RuntimeException(sprintf(lang('errors.reading_file'), $file)); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | $file_contents = str_replace($search, $replace, $file_contents); |
197 | 197 | |
198 | 198 | $result = file_put_contents($file, $file_contents); |
199 | 199 | |
200 | - return (bool)$result; |
|
200 | + return (bool) $result; |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | //-------------------------------------------------------------------- |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | |
217 | 217 | if ($file_contents === false) |
218 | 218 | { |
219 | - throw new \RuntimeException( sprintf( lang('errors.reading_file'), $file ) ); |
|
219 | + throw new \RuntimeException(sprintf(lang('errors.reading_file'), $file)); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | $file_contents = preg_replace($pattern, $replace, $file_contents); |
@@ -224,12 +224,12 @@ discard block |
||
224 | 224 | $result = false; |
225 | 225 | |
226 | 226 | // Don't let us erase a file! |
227 | - if (! empty($file_contents)) |
|
227 | + if ( ! empty($file_contents)) |
|
228 | 228 | { |
229 | - $result = file_put_contents( $file, $file_contents ); |
|
229 | + $result = file_put_contents($file, $file_contents); |
|
230 | 230 | } |
231 | 231 | |
232 | - return (bool)$result; |
|
232 | + return (bool) $result; |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | //-------------------------------------------------------------------- |
@@ -40,290 +40,290 @@ |
||
40 | 40 | */ |
41 | 41 | class BaseMailer { |
42 | 42 | |
43 | - /** |
|
44 | - * How the email is delivered. |
|
45 | - * Either 'send' or 'queue'. |
|
46 | - * @var string |
|
47 | - */ |
|
48 | - protected $action = 'send'; |
|
49 | - |
|
50 | - protected $from = null; |
|
51 | - protected $to = null; |
|
52 | - protected $reply_to = null; |
|
53 | - protected $cc = null; |
|
54 | - protected $bcc = null; |
|
55 | - |
|
56 | - protected $message = null; |
|
57 | - |
|
58 | - protected $theme = 'email'; |
|
59 | - protected $layout = 'index'; |
|
60 | - protected $view = null; |
|
61 | - |
|
62 | - /** |
|
63 | - * The MailService to use. If NULL |
|
64 | - * will use the system default. |
|
65 | - * @var null |
|
66 | - */ |
|
67 | - protected $service_name = null; |
|
68 | - |
|
69 | - protected $service = null; |
|
70 | - |
|
71 | - /** |
|
72 | - * Used for theming the email messages. |
|
73 | - * @var null |
|
74 | - */ |
|
75 | - protected $themer = null; |
|
76 | - |
|
77 | - //-------------------------------------------------------------------- |
|
78 | - |
|
79 | - /** |
|
80 | - * Constructor |
|
81 | - * |
|
82 | - * Simply allows us to override the default settings for this mailer. |
|
83 | - * |
|
84 | - * @param null $options |
|
85 | - */ |
|
86 | - public function __construct($options=null) |
|
87 | - { |
|
88 | - if (! empty($options)) |
|
89 | - { |
|
90 | - $this->setOptions($options); |
|
91 | - } |
|
92 | - } |
|
93 | - |
|
94 | - //-------------------------------------------------------------------- |
|
95 | - |
|
96 | - /** |
|
97 | - * Sets the basic options available to the mailer, like 'from', 'to', |
|
98 | - * 'cc', 'bcc', etc. |
|
99 | - * |
|
100 | - * @param $options |
|
101 | - */ |
|
102 | - public function setOptions($options) |
|
103 | - { |
|
104 | - if (is_array($options)) |
|
105 | - { |
|
106 | - foreach ($options as $key => $value) |
|
107 | - { |
|
108 | - if ($key == 'service') |
|
109 | - { |
|
110 | - $this->service =& $value; |
|
111 | - continue; |
|
112 | - } |
|
113 | - |
|
114 | - if (property_exists($this, $key)) |
|
115 | - { |
|
116 | - $this->$key = $value; |
|
117 | - } |
|
118 | - } |
|
119 | - } |
|
120 | - } |
|
121 | - |
|
122 | - //-------------------------------------------------------------------- |
|
123 | - |
|
124 | - |
|
125 | - |
|
126 | - /** |
|
127 | - * Sends an email immediately using the system-defined MailService. |
|
128 | - * |
|
129 | - * @param string $to // Who the email is being sent to. |
|
130 | - * @param string $subject // The subject line for the email |
|
131 | - * @param strign $data // the key/value pairs to send to the views. |
|
132 | - * @param string $view // You can override the view used for the email here. |
|
133 | - * // You can change themes by prepending theme name |
|
134 | - * // like: 'newtheme:newview' |
|
135 | - * |
|
136 | - * @return bool |
|
137 | - */ |
|
138 | - public function send($to, $subject, $data=[], $view=null) |
|
139 | - { |
|
140 | - // Are we pretending to send? |
|
141 | - if (config_item('mail.pretend') === true) |
|
142 | - { |
|
143 | - return true; |
|
144 | - } |
|
145 | - |
|
146 | - $this->startMailService(); |
|
147 | - |
|
148 | - $this->service->to($to); |
|
149 | - $this->service->subject($subject); |
|
150 | - |
|
151 | - if (is_array($this->from)) { |
|
152 | - $this->service->from($this->from[0], $this->from[1]); |
|
153 | - } |
|
154 | - else |
|
155 | - { |
|
156 | - $this->service->from($this->from); |
|
157 | - } |
|
158 | - |
|
159 | - if (! empty($this->cc)) $this->service->cc($this->cc); |
|
160 | - if (! empty($this->bcc)) $this->service->bcc($this->bcc); |
|
161 | - |
|
162 | - if (is_array($this->reply_to)) { |
|
163 | - $this->service->reply_to($this->reply_to[0], $this->reply_to[1]); |
|
164 | - } |
|
165 | - else |
|
166 | - { |
|
167 | - $this->service->reply_to($this->reply_to); |
|
168 | - } |
|
169 | - |
|
170 | - |
|
171 | - // Determine the view to use. We have to hack this a bit with |
|
172 | - // the debug_backtrace, though, to make it all function in the background. |
|
173 | - list(, $method) = debug_backtrace(false); |
|
174 | - |
|
175 | - $view = 'emails/'. strtolower( (new \ReflectionClass($this))->getShortName() ) .'/'. $method['function']; |
|
176 | - |
|
177 | - // Get our message's text and html versions based on which files exist... |
|
178 | - $basepath = APPPATH .'views/'. $view; |
|
179 | - |
|
180 | - // Is a text version available? |
|
181 | - if (file_exists($basepath .'.text.php')) |
|
182 | - { |
|
183 | - $text = $this->load->view($view .'.text.php', $data, true); |
|
184 | - $this->service->text_message($text); |
|
185 | - } |
|
186 | - |
|
187 | - // If an html version is around, we need to theme it out |
|
188 | - if (file_exists($basepath .'.html.php')) |
|
189 | - { |
|
190 | - $this->startThemer(); |
|
191 | - |
|
192 | - $this->themer->setTheme($this->theme); |
|
193 | - |
|
194 | - // Determine the correct layout to use |
|
195 | - $layout = ! empty($this->layout) ? $this->layout : NULL; |
|
196 | - $this->themer->setLayout($layout); |
|
197 | - |
|
198 | - $this->themer->set($data); |
|
199 | - |
|
200 | - // Render the view into a var we can pass to the layout. |
|
201 | - $content = $this->themer->display($view .'.html.php'); |
|
202 | - |
|
203 | - $this->themer->set('content', $content); |
|
204 | - |
|
205 | - $this->service->html_message( $this->themer->display($this->theme .':'. $layout) ); |
|
206 | - } |
|
207 | - |
|
208 | - if (! $this->service->send() ) |
|
209 | - { |
|
210 | - // todo do something here |
|
211 | - return false; |
|
212 | - } |
|
213 | - |
|
214 | - return true; |
|
215 | - } |
|
216 | - |
|
217 | - //-------------------------------------------------------------------- |
|
218 | - |
|
219 | - /** |
|
220 | - * Allows you to customize the headers sent with the email. You can |
|
221 | - * do them one at a time by passing $field and $value, or pass an array |
|
222 | - * of $field => $value pairs as the first parameter. |
|
223 | - * |
|
224 | - * @param string|array $field |
|
225 | - * @param string $value |
|
226 | - */ |
|
227 | - public function header($field, $value=null) |
|
228 | - { |
|
229 | - $this->startMailService(); |
|
230 | - |
|
231 | - $this->service->setHeader($field, $value); |
|
232 | - } |
|
233 | - |
|
234 | - //-------------------------------------------------------------------- |
|
235 | - |
|
236 | - /** |
|
237 | - * Adds an attachment to the current email that is being built. |
|
238 | - * |
|
239 | - * @param string $filename |
|
240 | - * @param string $disposition like 'inline'. Default is 'attachment' |
|
241 | - * @param string $newname If you'd like to rename the file for delivery |
|
242 | - * @param string $mime Custom defined mime type. |
|
243 | - */ |
|
244 | - public function attach($filename, $disposition=null, $newname=null, $mime=null) |
|
245 | - { |
|
246 | - $this->startMailService(); |
|
247 | - |
|
248 | - $this->service->attach($filename, $disposition, $newname, $mime); |
|
249 | - } |
|
250 | - |
|
251 | - //-------------------------------------------------------------------- |
|
252 | - |
|
253 | - //-------------------------------------------------------------------- |
|
254 | - // Private Methods |
|
255 | - //-------------------------------------------------------------------- |
|
256 | - |
|
257 | - /** |
|
258 | - * Starts up the service name specified in $service_name. |
|
259 | - * |
|
260 | - * @param $service_name |
|
261 | - */ |
|
262 | - protected function startMailService() |
|
263 | - { |
|
264 | - // Only once! |
|
265 | - if (! empty($this->service) && is_object($this->service)) |
|
266 | - { |
|
267 | - return; |
|
268 | - } |
|
269 | - |
|
270 | - $service_name = ! empty($this->service_name) ? $this->service_name : config_item('mail.default_service'); |
|
271 | - |
|
272 | - if (! class_exists($service_name)) |
|
273 | - { |
|
274 | - throw new \RuntimeException( sprintf( lang('mail.invalid_service'), $service_name) ); |
|
275 | - } |
|
276 | - |
|
277 | - $this->service = new $service_name(); |
|
278 | - } |
|
279 | - |
|
280 | - //-------------------------------------------------------------------- |
|
281 | - |
|
282 | - /** |
|
283 | - * Fires up the default themer so we can use it to theme our HTML messages. |
|
284 | - */ |
|
285 | - protected function startThemer() |
|
286 | - { |
|
287 | - /* |
|
43 | + /** |
|
44 | + * How the email is delivered. |
|
45 | + * Either 'send' or 'queue'. |
|
46 | + * @var string |
|
47 | + */ |
|
48 | + protected $action = 'send'; |
|
49 | + |
|
50 | + protected $from = null; |
|
51 | + protected $to = null; |
|
52 | + protected $reply_to = null; |
|
53 | + protected $cc = null; |
|
54 | + protected $bcc = null; |
|
55 | + |
|
56 | + protected $message = null; |
|
57 | + |
|
58 | + protected $theme = 'email'; |
|
59 | + protected $layout = 'index'; |
|
60 | + protected $view = null; |
|
61 | + |
|
62 | + /** |
|
63 | + * The MailService to use. If NULL |
|
64 | + * will use the system default. |
|
65 | + * @var null |
|
66 | + */ |
|
67 | + protected $service_name = null; |
|
68 | + |
|
69 | + protected $service = null; |
|
70 | + |
|
71 | + /** |
|
72 | + * Used for theming the email messages. |
|
73 | + * @var null |
|
74 | + */ |
|
75 | + protected $themer = null; |
|
76 | + |
|
77 | + //-------------------------------------------------------------------- |
|
78 | + |
|
79 | + /** |
|
80 | + * Constructor |
|
81 | + * |
|
82 | + * Simply allows us to override the default settings for this mailer. |
|
83 | + * |
|
84 | + * @param null $options |
|
85 | + */ |
|
86 | + public function __construct($options=null) |
|
87 | + { |
|
88 | + if (! empty($options)) |
|
89 | + { |
|
90 | + $this->setOptions($options); |
|
91 | + } |
|
92 | + } |
|
93 | + |
|
94 | + //-------------------------------------------------------------------- |
|
95 | + |
|
96 | + /** |
|
97 | + * Sets the basic options available to the mailer, like 'from', 'to', |
|
98 | + * 'cc', 'bcc', etc. |
|
99 | + * |
|
100 | + * @param $options |
|
101 | + */ |
|
102 | + public function setOptions($options) |
|
103 | + { |
|
104 | + if (is_array($options)) |
|
105 | + { |
|
106 | + foreach ($options as $key => $value) |
|
107 | + { |
|
108 | + if ($key == 'service') |
|
109 | + { |
|
110 | + $this->service =& $value; |
|
111 | + continue; |
|
112 | + } |
|
113 | + |
|
114 | + if (property_exists($this, $key)) |
|
115 | + { |
|
116 | + $this->$key = $value; |
|
117 | + } |
|
118 | + } |
|
119 | + } |
|
120 | + } |
|
121 | + |
|
122 | + //-------------------------------------------------------------------- |
|
123 | + |
|
124 | + |
|
125 | + |
|
126 | + /** |
|
127 | + * Sends an email immediately using the system-defined MailService. |
|
128 | + * |
|
129 | + * @param string $to // Who the email is being sent to. |
|
130 | + * @param string $subject // The subject line for the email |
|
131 | + * @param strign $data // the key/value pairs to send to the views. |
|
132 | + * @param string $view // You can override the view used for the email here. |
|
133 | + * // You can change themes by prepending theme name |
|
134 | + * // like: 'newtheme:newview' |
|
135 | + * |
|
136 | + * @return bool |
|
137 | + */ |
|
138 | + public function send($to, $subject, $data=[], $view=null) |
|
139 | + { |
|
140 | + // Are we pretending to send? |
|
141 | + if (config_item('mail.pretend') === true) |
|
142 | + { |
|
143 | + return true; |
|
144 | + } |
|
145 | + |
|
146 | + $this->startMailService(); |
|
147 | + |
|
148 | + $this->service->to($to); |
|
149 | + $this->service->subject($subject); |
|
150 | + |
|
151 | + if (is_array($this->from)) { |
|
152 | + $this->service->from($this->from[0], $this->from[1]); |
|
153 | + } |
|
154 | + else |
|
155 | + { |
|
156 | + $this->service->from($this->from); |
|
157 | + } |
|
158 | + |
|
159 | + if (! empty($this->cc)) $this->service->cc($this->cc); |
|
160 | + if (! empty($this->bcc)) $this->service->bcc($this->bcc); |
|
161 | + |
|
162 | + if (is_array($this->reply_to)) { |
|
163 | + $this->service->reply_to($this->reply_to[0], $this->reply_to[1]); |
|
164 | + } |
|
165 | + else |
|
166 | + { |
|
167 | + $this->service->reply_to($this->reply_to); |
|
168 | + } |
|
169 | + |
|
170 | + |
|
171 | + // Determine the view to use. We have to hack this a bit with |
|
172 | + // the debug_backtrace, though, to make it all function in the background. |
|
173 | + list(, $method) = debug_backtrace(false); |
|
174 | + |
|
175 | + $view = 'emails/'. strtolower( (new \ReflectionClass($this))->getShortName() ) .'/'. $method['function']; |
|
176 | + |
|
177 | + // Get our message's text and html versions based on which files exist... |
|
178 | + $basepath = APPPATH .'views/'. $view; |
|
179 | + |
|
180 | + // Is a text version available? |
|
181 | + if (file_exists($basepath .'.text.php')) |
|
182 | + { |
|
183 | + $text = $this->load->view($view .'.text.php', $data, true); |
|
184 | + $this->service->text_message($text); |
|
185 | + } |
|
186 | + |
|
187 | + // If an html version is around, we need to theme it out |
|
188 | + if (file_exists($basepath .'.html.php')) |
|
189 | + { |
|
190 | + $this->startThemer(); |
|
191 | + |
|
192 | + $this->themer->setTheme($this->theme); |
|
193 | + |
|
194 | + // Determine the correct layout to use |
|
195 | + $layout = ! empty($this->layout) ? $this->layout : NULL; |
|
196 | + $this->themer->setLayout($layout); |
|
197 | + |
|
198 | + $this->themer->set($data); |
|
199 | + |
|
200 | + // Render the view into a var we can pass to the layout. |
|
201 | + $content = $this->themer->display($view .'.html.php'); |
|
202 | + |
|
203 | + $this->themer->set('content', $content); |
|
204 | + |
|
205 | + $this->service->html_message( $this->themer->display($this->theme .':'. $layout) ); |
|
206 | + } |
|
207 | + |
|
208 | + if (! $this->service->send() ) |
|
209 | + { |
|
210 | + // todo do something here |
|
211 | + return false; |
|
212 | + } |
|
213 | + |
|
214 | + return true; |
|
215 | + } |
|
216 | + |
|
217 | + //-------------------------------------------------------------------- |
|
218 | + |
|
219 | + /** |
|
220 | + * Allows you to customize the headers sent with the email. You can |
|
221 | + * do them one at a time by passing $field and $value, or pass an array |
|
222 | + * of $field => $value pairs as the first parameter. |
|
223 | + * |
|
224 | + * @param string|array $field |
|
225 | + * @param string $value |
|
226 | + */ |
|
227 | + public function header($field, $value=null) |
|
228 | + { |
|
229 | + $this->startMailService(); |
|
230 | + |
|
231 | + $this->service->setHeader($field, $value); |
|
232 | + } |
|
233 | + |
|
234 | + //-------------------------------------------------------------------- |
|
235 | + |
|
236 | + /** |
|
237 | + * Adds an attachment to the current email that is being built. |
|
238 | + * |
|
239 | + * @param string $filename |
|
240 | + * @param string $disposition like 'inline'. Default is 'attachment' |
|
241 | + * @param string $newname If you'd like to rename the file for delivery |
|
242 | + * @param string $mime Custom defined mime type. |
|
243 | + */ |
|
244 | + public function attach($filename, $disposition=null, $newname=null, $mime=null) |
|
245 | + { |
|
246 | + $this->startMailService(); |
|
247 | + |
|
248 | + $this->service->attach($filename, $disposition, $newname, $mime); |
|
249 | + } |
|
250 | + |
|
251 | + //-------------------------------------------------------------------- |
|
252 | + |
|
253 | + //-------------------------------------------------------------------- |
|
254 | + // Private Methods |
|
255 | + //-------------------------------------------------------------------- |
|
256 | + |
|
257 | + /** |
|
258 | + * Starts up the service name specified in $service_name. |
|
259 | + * |
|
260 | + * @param $service_name |
|
261 | + */ |
|
262 | + protected function startMailService() |
|
263 | + { |
|
264 | + // Only once! |
|
265 | + if (! empty($this->service) && is_object($this->service)) |
|
266 | + { |
|
267 | + return; |
|
268 | + } |
|
269 | + |
|
270 | + $service_name = ! empty($this->service_name) ? $this->service_name : config_item('mail.default_service'); |
|
271 | + |
|
272 | + if (! class_exists($service_name)) |
|
273 | + { |
|
274 | + throw new \RuntimeException( sprintf( lang('mail.invalid_service'), $service_name) ); |
|
275 | + } |
|
276 | + |
|
277 | + $this->service = new $service_name(); |
|
278 | + } |
|
279 | + |
|
280 | + //-------------------------------------------------------------------- |
|
281 | + |
|
282 | + /** |
|
283 | + * Fires up the default themer so we can use it to theme our HTML messages. |
|
284 | + */ |
|
285 | + protected function startThemer() |
|
286 | + { |
|
287 | + /* |
|
288 | 288 | * Setup our Template Engine |
289 | 289 | */ |
290 | - $themer = config_item('active_themer'); |
|
291 | - |
|
292 | - if (empty($themer)) { |
|
293 | - throw new \RuntimeException( lang('no_themer') ); |
|
294 | - } |
|
295 | - |
|
296 | - if (empty($this->themer)) |
|
297 | - { |
|
298 | - $this->themer = new $themer( get_instance() ); |
|
299 | - } |
|
300 | - |
|
301 | - // Register our paths with the themer |
|
302 | - $paths = config_item('theme.paths'); |
|
303 | - |
|
304 | - foreach ($paths as $key => $path) { |
|
305 | - $this->themer->addThemePath($key, $path); |
|
306 | - } |
|
307 | - |
|
308 | - // Set our default theme. |
|
309 | - $this->themer->setDefaultTheme( 'email' ); |
|
310 | - } |
|
311 | - |
|
312 | - //-------------------------------------------------------------------- |
|
313 | - |
|
314 | - /** |
|
315 | - * __get magic |
|
316 | - * |
|
317 | - * Allows models to access CI's loaded classes using the same |
|
318 | - * syntax as controllers. |
|
319 | - * |
|
320 | - * @param string $key |
|
321 | - */ |
|
322 | - public function __get($key) |
|
323 | - { |
|
324 | - return get_instance()->$key; |
|
325 | - } |
|
326 | - |
|
327 | - //-------------------------------------------------------------------- |
|
290 | + $themer = config_item('active_themer'); |
|
291 | + |
|
292 | + if (empty($themer)) { |
|
293 | + throw new \RuntimeException( lang('no_themer') ); |
|
294 | + } |
|
295 | + |
|
296 | + if (empty($this->themer)) |
|
297 | + { |
|
298 | + $this->themer = new $themer( get_instance() ); |
|
299 | + } |
|
300 | + |
|
301 | + // Register our paths with the themer |
|
302 | + $paths = config_item('theme.paths'); |
|
303 | + |
|
304 | + foreach ($paths as $key => $path) { |
|
305 | + $this->themer->addThemePath($key, $path); |
|
306 | + } |
|
307 | + |
|
308 | + // Set our default theme. |
|
309 | + $this->themer->setDefaultTheme( 'email' ); |
|
310 | + } |
|
311 | + |
|
312 | + //-------------------------------------------------------------------- |
|
313 | + |
|
314 | + /** |
|
315 | + * __get magic |
|
316 | + * |
|
317 | + * Allows models to access CI's loaded classes using the same |
|
318 | + * syntax as controllers. |
|
319 | + * |
|
320 | + * @param string $key |
|
321 | + */ |
|
322 | + public function __get($key) |
|
323 | + { |
|
324 | + return get_instance()->$key; |
|
325 | + } |
|
326 | + |
|
327 | + //-------------------------------------------------------------------- |
|
328 | 328 | |
329 | 329 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * will use the system default. |
65 | 65 | * @var null |
66 | 66 | */ |
67 | - protected $service_name = null; |
|
67 | + protected $service_name = null; |
|
68 | 68 | |
69 | 69 | protected $service = null; |
70 | 70 | |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @param null $options |
85 | 85 | */ |
86 | - public function __construct($options=null) |
|
86 | + public function __construct($options = null) |
|
87 | 87 | { |
88 | - if (! empty($options)) |
|
88 | + if ( ! empty($options)) |
|
89 | 89 | { |
90 | 90 | $this->setOptions($options); |
91 | 91 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | { |
108 | 108 | if ($key == 'service') |
109 | 109 | { |
110 | - $this->service =& $value; |
|
110 | + $this->service = & $value; |
|
111 | 111 | continue; |
112 | 112 | } |
113 | 113 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return bool |
137 | 137 | */ |
138 | - public function send($to, $subject, $data=[], $view=null) |
|
138 | + public function send($to, $subject, $data = [], $view = null) |
|
139 | 139 | { |
140 | 140 | // Are we pretending to send? |
141 | 141 | if (config_item('mail.pretend') === true) |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | $this->service->from($this->from); |
157 | 157 | } |
158 | 158 | |
159 | - if (! empty($this->cc)) $this->service->cc($this->cc); |
|
160 | - if (! empty($this->bcc)) $this->service->bcc($this->bcc); |
|
159 | + if ( ! empty($this->cc)) $this->service->cc($this->cc); |
|
160 | + if ( ! empty($this->bcc)) $this->service->bcc($this->bcc); |
|
161 | 161 | |
162 | 162 | if (is_array($this->reply_to)) { |
163 | 163 | $this->service->reply_to($this->reply_to[0], $this->reply_to[1]); |
@@ -172,20 +172,20 @@ discard block |
||
172 | 172 | // the debug_backtrace, though, to make it all function in the background. |
173 | 173 | list(, $method) = debug_backtrace(false); |
174 | 174 | |
175 | - $view = 'emails/'. strtolower( (new \ReflectionClass($this))->getShortName() ) .'/'. $method['function']; |
|
175 | + $view = 'emails/'.strtolower((new \ReflectionClass($this))->getShortName()).'/'.$method['function']; |
|
176 | 176 | |
177 | 177 | // Get our message's text and html versions based on which files exist... |
178 | - $basepath = APPPATH .'views/'. $view; |
|
178 | + $basepath = APPPATH.'views/'.$view; |
|
179 | 179 | |
180 | 180 | // Is a text version available? |
181 | - if (file_exists($basepath .'.text.php')) |
|
181 | + if (file_exists($basepath.'.text.php')) |
|
182 | 182 | { |
183 | - $text = $this->load->view($view .'.text.php', $data, true); |
|
183 | + $text = $this->load->view($view.'.text.php', $data, true); |
|
184 | 184 | $this->service->text_message($text); |
185 | 185 | } |
186 | 186 | |
187 | 187 | // If an html version is around, we need to theme it out |
188 | - if (file_exists($basepath .'.html.php')) |
|
188 | + if (file_exists($basepath.'.html.php')) |
|
189 | 189 | { |
190 | 190 | $this->startThemer(); |
191 | 191 | |
@@ -198,14 +198,14 @@ discard block |
||
198 | 198 | $this->themer->set($data); |
199 | 199 | |
200 | 200 | // Render the view into a var we can pass to the layout. |
201 | - $content = $this->themer->display($view .'.html.php'); |
|
201 | + $content = $this->themer->display($view.'.html.php'); |
|
202 | 202 | |
203 | 203 | $this->themer->set('content', $content); |
204 | 204 | |
205 | - $this->service->html_message( $this->themer->display($this->theme .':'. $layout) ); |
|
205 | + $this->service->html_message($this->themer->display($this->theme.':'.$layout)); |
|
206 | 206 | } |
207 | 207 | |
208 | - if (! $this->service->send() ) |
|
208 | + if ( ! $this->service->send()) |
|
209 | 209 | { |
210 | 210 | // todo do something here |
211 | 211 | return false; |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * @param string|array $field |
225 | 225 | * @param string $value |
226 | 226 | */ |
227 | - public function header($field, $value=null) |
|
227 | + public function header($field, $value = null) |
|
228 | 228 | { |
229 | 229 | $this->startMailService(); |
230 | 230 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @param string $newname If you'd like to rename the file for delivery |
242 | 242 | * @param string $mime Custom defined mime type. |
243 | 243 | */ |
244 | - public function attach($filename, $disposition=null, $newname=null, $mime=null) |
|
244 | + public function attach($filename, $disposition = null, $newname = null, $mime = null) |
|
245 | 245 | { |
246 | 246 | $this->startMailService(); |
247 | 247 | |
@@ -262,16 +262,16 @@ discard block |
||
262 | 262 | protected function startMailService() |
263 | 263 | { |
264 | 264 | // Only once! |
265 | - if (! empty($this->service) && is_object($this->service)) |
|
265 | + if ( ! empty($this->service) && is_object($this->service)) |
|
266 | 266 | { |
267 | 267 | return; |
268 | 268 | } |
269 | 269 | |
270 | 270 | $service_name = ! empty($this->service_name) ? $this->service_name : config_item('mail.default_service'); |
271 | 271 | |
272 | - if (! class_exists($service_name)) |
|
272 | + if ( ! class_exists($service_name)) |
|
273 | 273 | { |
274 | - throw new \RuntimeException( sprintf( lang('mail.invalid_service'), $service_name) ); |
|
274 | + throw new \RuntimeException(sprintf(lang('mail.invalid_service'), $service_name)); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | $this->service = new $service_name(); |
@@ -290,12 +290,12 @@ discard block |
||
290 | 290 | $themer = config_item('active_themer'); |
291 | 291 | |
292 | 292 | if (empty($themer)) { |
293 | - throw new \RuntimeException( lang('no_themer') ); |
|
293 | + throw new \RuntimeException(lang('no_themer')); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | if (empty($this->themer)) |
297 | 297 | { |
298 | - $this->themer = new $themer( get_instance() ); |
|
298 | + $this->themer = new $themer(get_instance()); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | // Register our paths with the themer |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | } |
307 | 307 | |
308 | 308 | // Set our default theme. |
309 | - $this->themer->setDefaultTheme( 'email' ); |
|
309 | + $this->themer->setDefaultTheme('email'); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | //-------------------------------------------------------------------- |
@@ -150,19 +150,21 @@ |
||
150 | 150 | |
151 | 151 | if (is_array($this->from)) { |
152 | 152 | $this->service->from($this->from[0], $this->from[1]); |
153 | - } |
|
154 | - else |
|
153 | + } else |
|
155 | 154 | { |
156 | 155 | $this->service->from($this->from); |
157 | 156 | } |
158 | 157 | |
159 | - if (! empty($this->cc)) $this->service->cc($this->cc); |
|
160 | - if (! empty($this->bcc)) $this->service->bcc($this->bcc); |
|
158 | + if (! empty($this->cc)) { |
|
159 | + $this->service->cc($this->cc); |
|
160 | + } |
|
161 | + if (! empty($this->bcc)) { |
|
162 | + $this->service->bcc($this->bcc); |
|
163 | + } |
|
161 | 164 | |
162 | 165 | if (is_array($this->reply_to)) { |
163 | 166 | $this->service->reply_to($this->reply_to[0], $this->reply_to[1]); |
164 | - } |
|
165 | - else |
|
167 | + } else |
|
166 | 168 | { |
167 | 169 | $this->service->reply_to($this->reply_to); |
168 | 170 | } |
@@ -40,226 +40,226 @@ |
||
40 | 40 | */ |
41 | 41 | class CIMailService implements MailServiceInterface { |
42 | 42 | |
43 | - protected $ci = null; |
|
44 | - |
|
45 | - protected $format = 'html'; |
|
46 | - |
|
47 | - //-------------------------------------------------------------------- |
|
48 | - |
|
49 | - public function __construct() |
|
50 | - { |
|
51 | - $this->ci =& get_instance(); |
|
52 | - |
|
53 | - $this->ci->load->library('email'); |
|
54 | - } |
|
55 | - |
|
56 | - //-------------------------------------------------------------------- |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * Does the actual delivery of a message. |
|
61 | - * |
|
62 | - * @param bool $clear_after If TRUE, will reset the class after sending. |
|
63 | - * |
|
64 | - * @return mixed |
|
65 | - */ |
|
66 | - public function send($clear_after=true) |
|
67 | - { |
|
68 | - $this->ci->email->mailtype = $this->format; |
|
69 | - |
|
70 | - $result = $this->ci->email->send(false); |
|
71 | - |
|
72 | - return $result; |
|
73 | - } |
|
74 | - |
|
75 | - //-------------------------------------------------------------------- |
|
76 | - |
|
77 | - /** |
|
78 | - * Adds an attachment to the current email that is being built. |
|
79 | - * |
|
80 | - * @param string $filename |
|
81 | - * @param string $disposition like 'inline'. Default is 'attachment' |
|
82 | - * @param string $newname If you'd like to rename the file for delivery |
|
83 | - * @param string $mime Custom defined mime type. |
|
84 | - */ |
|
85 | - public function attach($filename, $disposition=null, $newname=null, $mime=null) |
|
86 | - { |
|
87 | - $this->ci->email->attach($filename, $disposition, $newname, $mime); |
|
88 | - } |
|
89 | - |
|
90 | - //-------------------------------------------------------------------- |
|
91 | - |
|
92 | - /** |
|
93 | - * Sets a header value for the email. Not every service will provide this. |
|
94 | - * |
|
95 | - * @param $field |
|
96 | - * @param $value |
|
97 | - * @return mixed |
|
98 | - */ |
|
99 | - public function setHeader($field, $value) |
|
100 | - { |
|
101 | - $this->ci->email->set_header($field, $value); |
|
102 | - |
|
103 | - return $this; |
|
104 | - } |
|
105 | - |
|
106 | - //-------------------------------------------------------------------- |
|
107 | - |
|
108 | - //-------------------------------------------------------------------- |
|
109 | - // Options |
|
110 | - //-------------------------------------------------------------------- |
|
111 | - |
|
112 | - /** |
|
113 | - * Sets the email address to send the email to. |
|
114 | - * |
|
115 | - * @param $email |
|
116 | - * @return mixed |
|
117 | - */ |
|
118 | - public function to($email) |
|
119 | - { |
|
120 | - $this->ci->email->to($email); |
|
121 | - |
|
122 | - return $this; |
|
123 | - } |
|
124 | - |
|
125 | - //-------------------------------------------------------------------- |
|
126 | - |
|
127 | - /** |
|
128 | - * Sets who the email is coming from. |
|
129 | - * |
|
130 | - * @param $email |
|
131 | - * @param null $name |
|
132 | - * @return mixed |
|
133 | - */ |
|
134 | - public function from($email, $name=null) |
|
135 | - { |
|
136 | - $this->ci->email->from($email, $name); |
|
137 | - |
|
138 | - return $this; |
|
139 | - } |
|
140 | - |
|
141 | - //-------------------------------------------------------------------- |
|
142 | - |
|
143 | - /** |
|
144 | - * Sets a single additional email address to 'cc'. |
|
145 | - * |
|
146 | - * @param $email |
|
147 | - * @return mixed |
|
148 | - */ |
|
149 | - public function cc($email) |
|
150 | - { |
|
151 | - $this->ci->email->cc($email); |
|
152 | - |
|
153 | - return $this; |
|
154 | - } |
|
155 | - |
|
156 | - //-------------------------------------------------------------------- |
|
157 | - |
|
158 | - /** |
|
159 | - * Sets a single email address to 'bcc' to. |
|
160 | - * |
|
161 | - * @param $email |
|
162 | - * @return mixed |
|
163 | - */ |
|
164 | - public function bcc($email) |
|
165 | - { |
|
166 | - $this->ci->email->bcc($email); |
|
167 | - |
|
168 | - return $this; |
|
169 | - } |
|
170 | - |
|
171 | - //-------------------------------------------------------------------- |
|
172 | - |
|
173 | - /** |
|
174 | - * Sets the reply to address. |
|
175 | - * |
|
176 | - * @param $email |
|
177 | - * @return mixed |
|
178 | - */ |
|
179 | - public function reply_to($email, $name=null) |
|
180 | - { |
|
181 | - $this->ci->email->reply_to($email, $name); |
|
182 | - } |
|
183 | - |
|
184 | - //-------------------------------------------------------------------- |
|
185 | - |
|
186 | - /** |
|
187 | - * Sets the subject line of the email. |
|
188 | - * |
|
189 | - * @param $subject |
|
190 | - * @return mixed |
|
191 | - */ |
|
192 | - public function subject($subject) |
|
193 | - { |
|
194 | - $this->ci->email->subject($subject); |
|
195 | - |
|
196 | - return $this; |
|
197 | - } |
|
198 | - |
|
199 | - //-------------------------------------------------------------------- |
|
200 | - |
|
201 | - /** |
|
202 | - * Sets the HTML portion of the email address. Optional. |
|
203 | - * |
|
204 | - * @param $message |
|
205 | - * @return mixed |
|
206 | - */ |
|
207 | - public function html_message($message) |
|
208 | - { |
|
209 | - $this->ci->email->message($message); |
|
210 | - |
|
211 | - $this->format = 'html'; |
|
212 | - |
|
213 | - return $this; |
|
214 | - } |
|
215 | - |
|
216 | - //-------------------------------------------------------------------- |
|
217 | - |
|
218 | - /** |
|
219 | - * Sets the text portion of the email address. Optional. |
|
220 | - * |
|
221 | - * @param $message |
|
222 | - * @return mixed |
|
223 | - */ |
|
224 | - public function text_message($message) |
|
225 | - { |
|
226 | - $this->ci->email->set_alt_message($message); |
|
227 | - |
|
228 | - $this->format = 'text'; |
|
229 | - |
|
230 | - return $this; |
|
231 | - } |
|
232 | - |
|
233 | - //-------------------------------------------------------------------- |
|
234 | - |
|
235 | - /** |
|
236 | - * Sets the format to send the email in. Either 'html' or 'text'. |
|
237 | - * |
|
238 | - * @param $format |
|
239 | - * @return mixed |
|
240 | - */ |
|
241 | - public function format($format) |
|
242 | - { |
|
243 | - $this->format = $format; |
|
244 | - |
|
245 | - return $this; |
|
246 | - } |
|
247 | - |
|
248 | - //-------------------------------------------------------------------- |
|
249 | - /** |
|
250 | - * Resets the state to blank, ready for a new email. Useful when |
|
251 | - * sending emails in a loop and you need to make sure that the |
|
252 | - * email is reset. |
|
253 | - * |
|
254 | - * @param bool $clear_attachments |
|
255 | - * @return mixed |
|
256 | - */ |
|
257 | - public function reset($clear_attachments=true) |
|
258 | - { |
|
259 | - $this->ci->email->clear($clear_attachments); |
|
260 | - |
|
261 | - return $this; |
|
262 | - } |
|
263 | - |
|
264 | - //-------------------------------------------------------------------- |
|
43 | + protected $ci = null; |
|
44 | + |
|
45 | + protected $format = 'html'; |
|
46 | + |
|
47 | + //-------------------------------------------------------------------- |
|
48 | + |
|
49 | + public function __construct() |
|
50 | + { |
|
51 | + $this->ci =& get_instance(); |
|
52 | + |
|
53 | + $this->ci->load->library('email'); |
|
54 | + } |
|
55 | + |
|
56 | + //-------------------------------------------------------------------- |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * Does the actual delivery of a message. |
|
61 | + * |
|
62 | + * @param bool $clear_after If TRUE, will reset the class after sending. |
|
63 | + * |
|
64 | + * @return mixed |
|
65 | + */ |
|
66 | + public function send($clear_after=true) |
|
67 | + { |
|
68 | + $this->ci->email->mailtype = $this->format; |
|
69 | + |
|
70 | + $result = $this->ci->email->send(false); |
|
71 | + |
|
72 | + return $result; |
|
73 | + } |
|
74 | + |
|
75 | + //-------------------------------------------------------------------- |
|
76 | + |
|
77 | + /** |
|
78 | + * Adds an attachment to the current email that is being built. |
|
79 | + * |
|
80 | + * @param string $filename |
|
81 | + * @param string $disposition like 'inline'. Default is 'attachment' |
|
82 | + * @param string $newname If you'd like to rename the file for delivery |
|
83 | + * @param string $mime Custom defined mime type. |
|
84 | + */ |
|
85 | + public function attach($filename, $disposition=null, $newname=null, $mime=null) |
|
86 | + { |
|
87 | + $this->ci->email->attach($filename, $disposition, $newname, $mime); |
|
88 | + } |
|
89 | + |
|
90 | + //-------------------------------------------------------------------- |
|
91 | + |
|
92 | + /** |
|
93 | + * Sets a header value for the email. Not every service will provide this. |
|
94 | + * |
|
95 | + * @param $field |
|
96 | + * @param $value |
|
97 | + * @return mixed |
|
98 | + */ |
|
99 | + public function setHeader($field, $value) |
|
100 | + { |
|
101 | + $this->ci->email->set_header($field, $value); |
|
102 | + |
|
103 | + return $this; |
|
104 | + } |
|
105 | + |
|
106 | + //-------------------------------------------------------------------- |
|
107 | + |
|
108 | + //-------------------------------------------------------------------- |
|
109 | + // Options |
|
110 | + //-------------------------------------------------------------------- |
|
111 | + |
|
112 | + /** |
|
113 | + * Sets the email address to send the email to. |
|
114 | + * |
|
115 | + * @param $email |
|
116 | + * @return mixed |
|
117 | + */ |
|
118 | + public function to($email) |
|
119 | + { |
|
120 | + $this->ci->email->to($email); |
|
121 | + |
|
122 | + return $this; |
|
123 | + } |
|
124 | + |
|
125 | + //-------------------------------------------------------------------- |
|
126 | + |
|
127 | + /** |
|
128 | + * Sets who the email is coming from. |
|
129 | + * |
|
130 | + * @param $email |
|
131 | + * @param null $name |
|
132 | + * @return mixed |
|
133 | + */ |
|
134 | + public function from($email, $name=null) |
|
135 | + { |
|
136 | + $this->ci->email->from($email, $name); |
|
137 | + |
|
138 | + return $this; |
|
139 | + } |
|
140 | + |
|
141 | + //-------------------------------------------------------------------- |
|
142 | + |
|
143 | + /** |
|
144 | + * Sets a single additional email address to 'cc'. |
|
145 | + * |
|
146 | + * @param $email |
|
147 | + * @return mixed |
|
148 | + */ |
|
149 | + public function cc($email) |
|
150 | + { |
|
151 | + $this->ci->email->cc($email); |
|
152 | + |
|
153 | + return $this; |
|
154 | + } |
|
155 | + |
|
156 | + //-------------------------------------------------------------------- |
|
157 | + |
|
158 | + /** |
|
159 | + * Sets a single email address to 'bcc' to. |
|
160 | + * |
|
161 | + * @param $email |
|
162 | + * @return mixed |
|
163 | + */ |
|
164 | + public function bcc($email) |
|
165 | + { |
|
166 | + $this->ci->email->bcc($email); |
|
167 | + |
|
168 | + return $this; |
|
169 | + } |
|
170 | + |
|
171 | + //-------------------------------------------------------------------- |
|
172 | + |
|
173 | + /** |
|
174 | + * Sets the reply to address. |
|
175 | + * |
|
176 | + * @param $email |
|
177 | + * @return mixed |
|
178 | + */ |
|
179 | + public function reply_to($email, $name=null) |
|
180 | + { |
|
181 | + $this->ci->email->reply_to($email, $name); |
|
182 | + } |
|
183 | + |
|
184 | + //-------------------------------------------------------------------- |
|
185 | + |
|
186 | + /** |
|
187 | + * Sets the subject line of the email. |
|
188 | + * |
|
189 | + * @param $subject |
|
190 | + * @return mixed |
|
191 | + */ |
|
192 | + public function subject($subject) |
|
193 | + { |
|
194 | + $this->ci->email->subject($subject); |
|
195 | + |
|
196 | + return $this; |
|
197 | + } |
|
198 | + |
|
199 | + //-------------------------------------------------------------------- |
|
200 | + |
|
201 | + /** |
|
202 | + * Sets the HTML portion of the email address. Optional. |
|
203 | + * |
|
204 | + * @param $message |
|
205 | + * @return mixed |
|
206 | + */ |
|
207 | + public function html_message($message) |
|
208 | + { |
|
209 | + $this->ci->email->message($message); |
|
210 | + |
|
211 | + $this->format = 'html'; |
|
212 | + |
|
213 | + return $this; |
|
214 | + } |
|
215 | + |
|
216 | + //-------------------------------------------------------------------- |
|
217 | + |
|
218 | + /** |
|
219 | + * Sets the text portion of the email address. Optional. |
|
220 | + * |
|
221 | + * @param $message |
|
222 | + * @return mixed |
|
223 | + */ |
|
224 | + public function text_message($message) |
|
225 | + { |
|
226 | + $this->ci->email->set_alt_message($message); |
|
227 | + |
|
228 | + $this->format = 'text'; |
|
229 | + |
|
230 | + return $this; |
|
231 | + } |
|
232 | + |
|
233 | + //-------------------------------------------------------------------- |
|
234 | + |
|
235 | + /** |
|
236 | + * Sets the format to send the email in. Either 'html' or 'text'. |
|
237 | + * |
|
238 | + * @param $format |
|
239 | + * @return mixed |
|
240 | + */ |
|
241 | + public function format($format) |
|
242 | + { |
|
243 | + $this->format = $format; |
|
244 | + |
|
245 | + return $this; |
|
246 | + } |
|
247 | + |
|
248 | + //-------------------------------------------------------------------- |
|
249 | + /** |
|
250 | + * Resets the state to blank, ready for a new email. Useful when |
|
251 | + * sending emails in a loop and you need to make sure that the |
|
252 | + * email is reset. |
|
253 | + * |
|
254 | + * @param bool $clear_attachments |
|
255 | + * @return mixed |
|
256 | + */ |
|
257 | + public function reset($clear_attachments=true) |
|
258 | + { |
|
259 | + $this->ci->email->clear($clear_attachments); |
|
260 | + |
|
261 | + return $this; |
|
262 | + } |
|
263 | + |
|
264 | + //-------------------------------------------------------------------- |
|
265 | 265 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | public function __construct() |
50 | 50 | { |
51 | - $this->ci =& get_instance(); |
|
51 | + $this->ci = & get_instance(); |
|
52 | 52 | |
53 | 53 | $this->ci->load->library('email'); |
54 | 54 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @return mixed |
65 | 65 | */ |
66 | - public function send($clear_after=true) |
|
66 | + public function send($clear_after = true) |
|
67 | 67 | { |
68 | 68 | $this->ci->email->mailtype = $this->format; |
69 | 69 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param string $newname If you'd like to rename the file for delivery |
83 | 83 | * @param string $mime Custom defined mime type. |
84 | 84 | */ |
85 | - public function attach($filename, $disposition=null, $newname=null, $mime=null) |
|
85 | + public function attach($filename, $disposition = null, $newname = null, $mime = null) |
|
86 | 86 | { |
87 | 87 | $this->ci->email->attach($filename, $disposition, $newname, $mime); |
88 | 88 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @param null $name |
132 | 132 | * @return mixed |
133 | 133 | */ |
134 | - public function from($email, $name=null) |
|
134 | + public function from($email, $name = null) |
|
135 | 135 | { |
136 | 136 | $this->ci->email->from($email, $name); |
137 | 137 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * @param $email |
177 | 177 | * @return mixed |
178 | 178 | */ |
179 | - public function reply_to($email, $name=null) |
|
179 | + public function reply_to($email, $name = null) |
|
180 | 180 | { |
181 | 181 | $this->ci->email->reply_to($email, $name); |
182 | 182 | } |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * @param bool $clear_attachments |
255 | 255 | * @return mixed |
256 | 256 | */ |
257 | - public function reset($clear_attachments=true) |
|
257 | + public function reset($clear_attachments = true) |
|
258 | 258 | { |
259 | 259 | $this->ci->email->clear($clear_attachments); |
260 | 260 |
@@ -42,145 +42,145 @@ |
||
42 | 42 | */ |
43 | 43 | interface MailServiceInterface { |
44 | 44 | |
45 | - /** |
|
46 | - * Does the actual delivery of a message. |
|
47 | - * |
|
48 | - * @param bool $clear_after If TRUE, will reset the class after sending. |
|
49 | - * |
|
50 | - * @return mixed |
|
51 | - */ |
|
52 | - public function send($clear_after=true); |
|
53 | - |
|
54 | - //-------------------------------------------------------------------- |
|
55 | - |
|
56 | - /** |
|
57 | - * Adds an attachment to the current email that is being built. |
|
58 | - * |
|
59 | - * @param string $filename |
|
60 | - * @param string $disposition like 'inline'. Default is 'attachment' |
|
61 | - * @param string $newname If you'd like to rename the file for delivery |
|
62 | - * @param string $mime Custom defined mime type. |
|
63 | - */ |
|
64 | - public function attach($filename, $disposition=null, $newname=null, $mime=null); |
|
65 | - |
|
66 | - //-------------------------------------------------------------------- |
|
67 | - |
|
68 | - /** |
|
69 | - * Sets a header value for the email. Not every service will provide this. |
|
70 | - * |
|
71 | - * @param $field |
|
72 | - * @param $value |
|
73 | - * @return mixed |
|
74 | - */ |
|
75 | - public function setHeader($field, $value); |
|
76 | - |
|
77 | - //-------------------------------------------------------------------- |
|
78 | - |
|
79 | - //-------------------------------------------------------------------- |
|
80 | - // Options |
|
81 | - //-------------------------------------------------------------------- |
|
82 | - |
|
83 | - /** |
|
84 | - * Sets the email address to send the email to. |
|
85 | - * |
|
86 | - * @param $email |
|
87 | - * @return mixed |
|
88 | - */ |
|
89 | - public function to($email); |
|
45 | + /** |
|
46 | + * Does the actual delivery of a message. |
|
47 | + * |
|
48 | + * @param bool $clear_after If TRUE, will reset the class after sending. |
|
49 | + * |
|
50 | + * @return mixed |
|
51 | + */ |
|
52 | + public function send($clear_after=true); |
|
53 | + |
|
54 | + //-------------------------------------------------------------------- |
|
55 | + |
|
56 | + /** |
|
57 | + * Adds an attachment to the current email that is being built. |
|
58 | + * |
|
59 | + * @param string $filename |
|
60 | + * @param string $disposition like 'inline'. Default is 'attachment' |
|
61 | + * @param string $newname If you'd like to rename the file for delivery |
|
62 | + * @param string $mime Custom defined mime type. |
|
63 | + */ |
|
64 | + public function attach($filename, $disposition=null, $newname=null, $mime=null); |
|
65 | + |
|
66 | + //-------------------------------------------------------------------- |
|
67 | + |
|
68 | + /** |
|
69 | + * Sets a header value for the email. Not every service will provide this. |
|
70 | + * |
|
71 | + * @param $field |
|
72 | + * @param $value |
|
73 | + * @return mixed |
|
74 | + */ |
|
75 | + public function setHeader($field, $value); |
|
76 | + |
|
77 | + //-------------------------------------------------------------------- |
|
78 | + |
|
79 | + //-------------------------------------------------------------------- |
|
80 | + // Options |
|
81 | + //-------------------------------------------------------------------- |
|
82 | + |
|
83 | + /** |
|
84 | + * Sets the email address to send the email to. |
|
85 | + * |
|
86 | + * @param $email |
|
87 | + * @return mixed |
|
88 | + */ |
|
89 | + public function to($email); |
|
90 | 90 | |
91 | - //-------------------------------------------------------------------- |
|
92 | - |
|
93 | - /** |
|
94 | - * Sets who the email is coming from. |
|
95 | - * |
|
96 | - * @param $email |
|
97 | - * @param null $name |
|
98 | - * @return mixed |
|
99 | - */ |
|
100 | - public function from($email, $name=null); |
|
101 | - |
|
102 | - //-------------------------------------------------------------------- |
|
103 | - |
|
104 | - /** |
|
105 | - * Sets a single additional email address to 'cc'. |
|
106 | - * |
|
107 | - * @param $email |
|
108 | - * @return mixed |
|
109 | - */ |
|
110 | - public function cc($email); |
|
111 | - |
|
112 | - //-------------------------------------------------------------------- |
|
113 | - |
|
114 | - /** |
|
115 | - * Sets a single email address to 'bcc' to. |
|
116 | - * |
|
117 | - * @param $email |
|
118 | - * @return mixed |
|
119 | - */ |
|
120 | - public function bcc($email); |
|
121 | - |
|
122 | - //-------------------------------------------------------------------- |
|
123 | - |
|
124 | - /** |
|
125 | - * Sets the reply to address. |
|
126 | - * |
|
127 | - * @param $email |
|
128 | - * @param $name |
|
129 | - * @return mixed |
|
130 | - */ |
|
131 | - public function reply_to($email, $name=null); |
|
132 | - |
|
133 | - //-------------------------------------------------------------------- |
|
134 | - |
|
135 | - /** |
|
136 | - * Sets the subject line of the email. |
|
137 | - * |
|
138 | - * @param $subject |
|
139 | - * @return mixed |
|
140 | - */ |
|
141 | - public function subject($subject); |
|
142 | - |
|
143 | - //-------------------------------------------------------------------- |
|
144 | - |
|
145 | - /** |
|
146 | - * Sets the HTML portion of the email address. Optional. |
|
147 | - * |
|
148 | - * @param $message |
|
149 | - * @return mixed |
|
150 | - */ |
|
151 | - public function html_message($message); |
|
152 | - |
|
153 | - //-------------------------------------------------------------------- |
|
154 | - |
|
155 | - /** |
|
156 | - * Sets the text portion of the email address. Optional. |
|
157 | - * |
|
158 | - * @param $message |
|
159 | - * @return mixed |
|
160 | - */ |
|
161 | - public function text_message($message); |
|
162 | - |
|
163 | - //-------------------------------------------------------------------- |
|
164 | - |
|
165 | - /** |
|
166 | - * Sets the format to send the email in. Either 'html' or 'text'. |
|
167 | - * |
|
168 | - * @param $format |
|
169 | - * @return mixed |
|
170 | - */ |
|
171 | - public function format($format); |
|
172 | - |
|
173 | - //-------------------------------------------------------------------- |
|
174 | - |
|
175 | - /** |
|
176 | - * Resets the state to blank, ready for a new email. Useful when |
|
177 | - * sending emails in a loop and you need to make sure that the |
|
178 | - * email is reset. |
|
179 | - * |
|
180 | - * @param bool $clear_attachments |
|
181 | - * @return mixed |
|
182 | - */ |
|
183 | - public function reset($clear_attachments=true); |
|
184 | - |
|
185 | - //-------------------------------------------------------------------- |
|
91 | + //-------------------------------------------------------------------- |
|
92 | + |
|
93 | + /** |
|
94 | + * Sets who the email is coming from. |
|
95 | + * |
|
96 | + * @param $email |
|
97 | + * @param null $name |
|
98 | + * @return mixed |
|
99 | + */ |
|
100 | + public function from($email, $name=null); |
|
101 | + |
|
102 | + //-------------------------------------------------------------------- |
|
103 | + |
|
104 | + /** |
|
105 | + * Sets a single additional email address to 'cc'. |
|
106 | + * |
|
107 | + * @param $email |
|
108 | + * @return mixed |
|
109 | + */ |
|
110 | + public function cc($email); |
|
111 | + |
|
112 | + //-------------------------------------------------------------------- |
|
113 | + |
|
114 | + /** |
|
115 | + * Sets a single email address to 'bcc' to. |
|
116 | + * |
|
117 | + * @param $email |
|
118 | + * @return mixed |
|
119 | + */ |
|
120 | + public function bcc($email); |
|
121 | + |
|
122 | + //-------------------------------------------------------------------- |
|
123 | + |
|
124 | + /** |
|
125 | + * Sets the reply to address. |
|
126 | + * |
|
127 | + * @param $email |
|
128 | + * @param $name |
|
129 | + * @return mixed |
|
130 | + */ |
|
131 | + public function reply_to($email, $name=null); |
|
132 | + |
|
133 | + //-------------------------------------------------------------------- |
|
134 | + |
|
135 | + /** |
|
136 | + * Sets the subject line of the email. |
|
137 | + * |
|
138 | + * @param $subject |
|
139 | + * @return mixed |
|
140 | + */ |
|
141 | + public function subject($subject); |
|
142 | + |
|
143 | + //-------------------------------------------------------------------- |
|
144 | + |
|
145 | + /** |
|
146 | + * Sets the HTML portion of the email address. Optional. |
|
147 | + * |
|
148 | + * @param $message |
|
149 | + * @return mixed |
|
150 | + */ |
|
151 | + public function html_message($message); |
|
152 | + |
|
153 | + //-------------------------------------------------------------------- |
|
154 | + |
|
155 | + /** |
|
156 | + * Sets the text portion of the email address. Optional. |
|
157 | + * |
|
158 | + * @param $message |
|
159 | + * @return mixed |
|
160 | + */ |
|
161 | + public function text_message($message); |
|
162 | + |
|
163 | + //-------------------------------------------------------------------- |
|
164 | + |
|
165 | + /** |
|
166 | + * Sets the format to send the email in. Either 'html' or 'text'. |
|
167 | + * |
|
168 | + * @param $format |
|
169 | + * @return mixed |
|
170 | + */ |
|
171 | + public function format($format); |
|
172 | + |
|
173 | + //-------------------------------------------------------------------- |
|
174 | + |
|
175 | + /** |
|
176 | + * Resets the state to blank, ready for a new email. Useful when |
|
177 | + * sending emails in a loop and you need to make sure that the |
|
178 | + * email is reset. |
|
179 | + * |
|
180 | + * @param bool $clear_attachments |
|
181 | + * @return mixed |
|
182 | + */ |
|
183 | + public function reset($clear_attachments=true); |
|
184 | + |
|
185 | + //-------------------------------------------------------------------- |
|
186 | 186 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * |
50 | 50 | * @return mixed |
51 | 51 | */ |
52 | - public function send($clear_after=true); |
|
52 | + public function send($clear_after = true); |
|
53 | 53 | |
54 | 54 | //-------------------------------------------------------------------- |
55 | 55 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @param string $newname If you'd like to rename the file for delivery |
62 | 62 | * @param string $mime Custom defined mime type. |
63 | 63 | */ |
64 | - public function attach($filename, $disposition=null, $newname=null, $mime=null); |
|
64 | + public function attach($filename, $disposition = null, $newname = null, $mime = null); |
|
65 | 65 | |
66 | 66 | //-------------------------------------------------------------------- |
67 | 67 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @param null $name |
98 | 98 | * @return mixed |
99 | 99 | */ |
100 | - public function from($email, $name=null); |
|
100 | + public function from($email, $name = null); |
|
101 | 101 | |
102 | 102 | //-------------------------------------------------------------------- |
103 | 103 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @param $name |
129 | 129 | * @return mixed |
130 | 130 | */ |
131 | - public function reply_to($email, $name=null); |
|
131 | + public function reply_to($email, $name = null); |
|
132 | 132 | |
133 | 133 | //-------------------------------------------------------------------- |
134 | 134 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * @param bool $clear_attachments |
181 | 181 | * @return mixed |
182 | 182 | */ |
183 | - public function reset($clear_attachments=true); |
|
183 | + public function reset($clear_attachments = true); |
|
184 | 184 | |
185 | 185 | //-------------------------------------------------------------------- |
186 | 186 | } |
@@ -1,41 +1,41 @@ |
||
1 | 1 | <?php namespace Myth\Mail; |
2 | 2 | /** |
3 | - * Sprint |
|
4 | - * |
|
5 | - * A set of power tools to enhance the CodeIgniter framework and provide consistent workflow. |
|
6 | - * |
|
7 | - * Permission is hereby granted, free of charge, to any person obtaining a copy |
|
8 | - * of this software and associated documentation files (the "Software"), to deal |
|
9 | - * in the Software without restriction, including without limitation the rights |
|
10 | - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
11 | - * copies of the Software, and to permit persons to whom the Software is |
|
12 | - * furnished to do so, subject to the following conditions: |
|
13 | - * |
|
14 | - * The above copyright notice and this permission notice shall be included in |
|
15 | - * all copies or substantial portions of the Software. |
|
16 | - * |
|
17 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
18 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
19 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
20 | - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
21 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
22 | - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
23 | - * THE SOFTWARE. |
|
24 | - * |
|
25 | - * @package Sprint |
|
26 | - * @author Lonnie Ezell |
|
27 | - * @copyright Copyright 2014-2015, New Myth Media, LLC (http://newmythmedia.com) |
|
28 | - * @license http://opensource.org/licenses/MIT (MIT) |
|
29 | - * @link http://sprintphp.com |
|
30 | - * @since Version 1.0 |
|
31 | - */ |
|
3 | + * Sprint |
|
4 | + * |
|
5 | + * A set of power tools to enhance the CodeIgniter framework and provide consistent workflow. |
|
6 | + * |
|
7 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
|
8 | + * of this software and associated documentation files (the "Software"), to deal |
|
9 | + * in the Software without restriction, including without limitation the rights |
|
10 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
11 | + * copies of the Software, and to permit persons to whom the Software is |
|
12 | + * furnished to do so, subject to the following conditions: |
|
13 | + * |
|
14 | + * The above copyright notice and this permission notice shall be included in |
|
15 | + * all copies or substantial portions of the Software. |
|
16 | + * |
|
17 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
18 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
19 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
20 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
21 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
22 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
23 | + * THE SOFTWARE. |
|
24 | + * |
|
25 | + * @package Sprint |
|
26 | + * @author Lonnie Ezell |
|
27 | + * @copyright Copyright 2014-2015, New Myth Media, LLC (http://newmythmedia.com) |
|
28 | + * @license http://opensource.org/licenses/MIT (MIT) |
|
29 | + * @link http://sprintphp.com |
|
30 | + * @since Version 1.0 |
|
31 | + */ |
|
32 | 32 | |
33 | 33 | use Myth\Models\CIDbModel; |
34 | 34 | |
35 | 35 | class Queue extends CIDbModel { |
36 | 36 | |
37 | - protected $table_name = 'mail_queue'; |
|
37 | + protected $table_name = 'mail_queue'; |
|
38 | 38 | |
39 | - protected $set_created = false; |
|
40 | - protected $set_modified = false; |
|
39 | + protected $set_created = false; |
|
40 | + protected $set_modified = false; |
|
41 | 41 | } |