This repository has been archived by the owner on Jul 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 83
/
ApiAdmin.php
84 lines (76 loc) · 2.86 KB
/
ApiAdmin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php // vim:ts=4:sw=4:et:fdm=marker
/**
* @ignore
* Used to be more lightweight class, although now it's not used
* anymore. Please AVOID usind this class
*//*
==ATK4===================================================
This file is part of Agile Toolkit 4
http://agiletoolkit.org/
(c) 2008-2011 Romans Malinovskis <atk@agiletech.ie>
Distributed under Affero General Public License v3
See http://agiletoolkit.org/about/license
=====================================================ATK4=*/
class ApiAdmin extends ApiWeb {
public $info_messages = array();
public $ns=null; // current namespace object or null if none
public $not_html=false; // this is true if output is NOT html. It might be javascript ajax response or redirect
function init(){
parent::init();
$this->getLogger();
$this->initializeTemplate();
}
/////////////// H e l p e r f u n c t i o n s ///////////////
function initDefaults(){
ApiCLI::initDefaults(); // DTP constant checked
if(strpos($_GET['page'],';')!==false){
list($namespace,$_GET['page'])=explode(';',$_GET['page']);
if(!isset($this->namespaces[$namespace])){
throw new BaseException('Specified namespace ('.$namespace.') can\'t be found');
// it's also
}
$this->ns=$this->namespaces[$namespace];
$this->ns->initLayout();
}else{
// do nothing!
//$this->initLayout();
}
}
function initLayout(){
// This function adds layout of how the webpage looks like. It should be initializing
// content of the page, sidebars and any other elements on the page. Different
// content pages are handled by page_*
return $this
->addLayout('Content')
->addLayout('Menu')
->addLayout('LeftSidebar')
->addLayout('RightSidebar')
->addLayout('InfoWindow')
;
}
function layout_LeftSidebar(){
$this->template->del('LeftSidebar');
}
function layout_RightSidebar(){
$this->template->del('RightSidebar');
}
function layout_InfoWindow(){
$this->add('InfoWindow',null,'InfoWindow');//,'InfoWindow');
}
function outputInfo($msg){
if($this->isAjaxOutput()){
$this->ajax()->displayAlert($msg)->execute();
}else{
$this->info_messages[]=array('no'=>count($this->info_messages),'content'=>htmlspecialchars($msg),'backtrace'=>debug_backtrace());
}
}
function render(){
if($this->ns)return; // it already puts something on our page
return parent::render();
}
function outputFatal($name,$shift=0){
$this->hook('output-fatal',array($name,$shift+1));
throw new BaseException("Fatal: ".$name,'fatal',$shift+1);
}
}
?>