1 <?php
2 3 4 5 6
7 class DashboardAdmin extends LeftAndMain {
8 static $url_segment = 'dashboard';
9 static = 'Dashboard';
10 static = 99;
11 static $url_priority = 41;
12
13 14 15 16
17 static $plugins = array();
18
19 20 21
22 static $default_position = 0;
23
24 25 26
27 public function init() {
28 parent::init();
29
30 $vars = array(
31 'Base' => Director::baseURL()
32 );
33
34 Requirements::css('dashboard/css/Dashboard.css');
35 Requirements::insertHeadTags('<!--[if IE 6]><link type="text/css" href="dashboard/css/ie6.css" rel="stylesheet" media="screen" /><![endif]-->');
36
37
38 Requirements::javascript('dashboard/javascript/greybox.js');
39 Requirements::javascriptTemplate('dashboard/javascript/Dashboard.js',$vars);
40
41 self::load_plugins();
42 }
43
44 45 46 47 48 49
50 private static function load_plugins() {
51 foreach(DashboardPlugin::$positions as $pos)
52 self::$plugins[$pos] = array();
53
54 $classes = ClassInfo::subclassesFor("DashboardPlugin");
55
56 if(is_array($classes)) {
57 foreach($classes as $class) {
58 if($class != "DashboardPlugin" && !in_array($class,DashboardPlugin::get_disabled_plugins())) {
59 $SNG = singleton($class);
60 self::add_plugin($class, $SNG->stat('position'), $SNG->stat('sort'));
61 }
62 }
63 }
64 }
65
66 67 68 69 70
71 private static function add_plugin($class, $pos, $sort) {
72 if(!is_string($pos) || !in_array(strtolower($pos), DashboardPlugin::$positions))
73 $pos = self::$default_position;
74
75 if(!is_numeric($sort))
76 $sort = 0;
77
78 while(isset(self::$plugins[$pos][$sort]))
79 $sort++;
80
81 self::$plugins[$pos][$sort] = $class;
82 }
83
84 85 86 87 88
89 private static function get_plugins_by_position($pos) {
90 return self::$plugins[$pos];
91 }
92
93 94 95 96 97
98 private function Plugins($pos) {
99 if($plugins = self::get_plugins_by_position($pos)) {
100 ksort($plugins);
101 $data = new DataObjectSet();
102
103 foreach($plugins as $plugin) {
104 $data->push(new ArrayData(array(
105 'Plugin' => new $plugin(),
106 'Class' => $plugin
107 )));
108 }
109
110 return $data;
111 }
112
113 return false;
114 }
115
116 117 118 119 120 121
122 public function get_plugins($pos = 'left') {
123 return $this->Plugins($pos);
124 }
125
126 127 128 129
130 public function visit_site_link() {
131 return Director::baseURL();
132 }
133 }
134
135 ?>
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the
Silverstripe Forums to ask development related questions.
-