1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Fancy Dev Build base class |
5
|
|
|
* |
6
|
|
|
* @package DevTasks |
7
|
|
|
* |
8
|
|
|
*/ |
9
|
|
|
class DevTasks extends LeftAndMainExtension implements PermissionProvider |
10
|
|
|
{ |
11
|
|
|
|
12
|
|
|
public function init() |
13
|
|
|
{ |
14
|
|
|
parent::init(); |
15
|
|
|
|
16
|
|
|
if (!Permission::check("VIEW_DEVTASKS")) { |
17
|
|
|
return; |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
$default_tasks = array( |
21
|
|
|
'devbuild' => array( |
22
|
|
|
'title' => 'Dev/Build', |
23
|
|
|
'link' => 'dev/build', |
24
|
|
|
'reset_time' => '5000', |
25
|
|
|
'error_markup'=> '.xdebug-error,.xe-parse-error', |
26
|
|
|
'error_handler' => 'newtab', |
27
|
|
|
'success_markup'=> 'li[style="color: blue"],li[style="color: green"]', |
28
|
|
|
'success_handler' => 'ignore' |
29
|
|
|
) |
30
|
|
|
); |
31
|
|
|
|
32
|
|
|
$config_tasks = Config::inst()->get(__CLASS__, 'tasks'); |
33
|
|
|
|
34
|
|
|
if (is_array($config_tasks)) { |
35
|
|
|
$tasks = array_merge($default_tasks, $config_tasks); |
36
|
|
|
}else{ |
37
|
|
|
$tasks = $default_tasks; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
foreach ($tasks as $item => $values) { |
41
|
|
|
|
42
|
|
|
$attributes = array( |
43
|
|
|
'class' => 'devbuild-trigger', |
44
|
|
|
'data-title' => (isset($values['title']) ? $values['title'] : $item), |
45
|
|
|
'data-link' => (isset($values['link']) ? $values['link'] : $default_tasks['devbuild']['link']), |
46
|
|
|
'data-reset-time' => (isset($values['reset_time']) ? $values['reset_time'] : $default_tasks['devbuild']['reset_time']), |
47
|
|
|
'data-error-markup' => (isset($values['error_markup']) ? $values['error_markup'] : $default_tasks['devbuild']['error_markup']), |
48
|
|
|
'data-error-handler' => (isset($values['error_handler']) ? $values['error_handler'] : $default_tasks['devbuild']['error_handler']), |
49
|
|
|
'data-success-markup' => (isset($values['success_markup']) ? $values['success_markup'] : $default_tasks['devbuild']['success_markup']), |
50
|
|
|
'data-success-handler' => (isset($values['success_handler']) ? $values['success_handler'] : $default_tasks['devbuild']['success_handler']) |
51
|
|
|
); |
52
|
|
|
|
53
|
|
|
// priority controls the ordering of the link in the stack. The |
54
|
|
|
// lower the number, the lower in the list |
55
|
|
|
$priority = -90; |
56
|
|
|
|
57
|
|
|
CMSMenu::add_link($item, '', '#', $priority, $attributes); |
58
|
|
|
|
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function providePermissions() |
63
|
|
|
{ |
64
|
|
|
return array( |
65
|
|
|
"VIEW_DEVTASKS" => "Access dev task menu", |
66
|
|
|
); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
?> |
|
|
|
|
72
|
|
|
|
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.
A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.