1 <?php
2
3
4 5 6 7
8 class MagratheaAdmin {
9
10 11 12 13
14 public $title = "Magrathea Admin";
15 16 17 18
19 public $args = array();
20
21 22 23
24 public function MagratheaAdmin(){
25 $dir = __DIR__."/Magrathea_admin/";
26 $call = @$_GET["call"];
27 if(!empty($call)){
28 include($dir.$call.".php");
29 }
30 $this->LoadRequiredPlugins();
31 $this->LoadOptPlugins();
32 }
33
34 35 36 37
38 private function LoadRequiredPlugins(){
39 try{
40 $this->AddPlugin("jquery1.7", true);
41 $this->AddPlugin("bootstrap2", true);
42 } catch (Exception $ex) {
43 echo("Install missing plugins! => ".$ex->getMessage());
44 die;
45 }
46 }
47
48 49 50 51
52 private function LoadOptPlugins(){
53 try{
54 $this->AddPlugin("font-awesome4");
55 $this->AddPlugin("ibutton");
56 } catch (Exception $ex) {
57 echo("Install missing plugins! => ".$ex->getMessage());
58 }
59 }
60
61 62 63
64 public function Load(){
65 $dir = __DIR__."/Magrathea_admin/";
66 $page = @$_GET["magpage"];
67 if(empty($page)) $page = "index.php";
68
69 include ($dir.$page);
70 }
71
72 73 74
75 public function LoadCustom(){
76 $dir = __DIR__."/Magrathea_admin/";
77 $page = @$_GET["magpage"];
78 if(empty($page)) $page = "index_custom.php";
79
80 include ($dir.$page);
81 }
82
83 84 85 86 87
88 public function AddPlugin($pluginName, $required=false){
89 $site_path = MagratheaConfig::Instance()->GetFromDefault("site_path");
90 $inc = @include($site_path."/plugins/".$pluginName."/load.php");
91 if(!$inc) {
92 echo "<br/><br/><a href='?call=plugin_install_req&plugin=".$pluginName."'>[Install ".$pluginName."]</a><br/><br/>";
93 if($required) {
94 throw new MagratheaAdminException("Plugin [".$pluginName."] could not be found!");
95 }
96 }
97 return $this;
98 }
99
100 101 102 103 104
105 public function IncludeCSS($cssPath){
106 $admin_path = "../Admin";
107 MagratheaView::Instance()->IncludeCSS($admin_path."/".$cssPath);
108 return $this;
109 }
110
111 112 113 114 115
116 public function IncludeJavascript($jsPath){
117 $admin_path = "../Admin";
118 MagratheaView::Instance()->IncludeJavascript($admin_path."/".$jsPath);
119 return $this;
120 }
121
122 }
123
124 ?>