1: <?php
2:
3:
4: if(!isset($config)) {
5: require_once '../util/configLoader.inc';
6: $config = configLoader::getInstance();
7:
8: require_once $config->get('app.root').'alpha/util/AlphaAutoLoader.inc';
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: class ListDEnums extends ListAll implements AlphaControllerInterface {
57: 58: 59: 60: 61: 62:
63: private static $logger = null;
64:
65: 66: 67: 68: 69:
70: public function __construct() {
71: self::$logger = new Logger('ListDEnums');
72: self::$logger->debug('>>__construct()');
73:
74:
75: parent::__construct('Admin');
76:
77: $this->BO = new DEnum();
78:
79:
80: if(!$this->BO->checkTableExists()) {
81: echo AlphaView::displayErrorMessage('Warning! The DEnum tables do not exist, attempting to create them now...');
82: $this->createDEnumTables();
83: }
84:
85: $this->BOname = 'DEnum';
86:
87: $this->BOView = AlphaView::getInstance($this->BO);
88:
89:
90: $this->setTitle('Listing all DEnums');
91: $this->setDescription('Page to list all DEnums.');
92: $this->setKeywords('list,all,DEnums');
93:
94: self::$logger->debug('<<__construct');
95: }
96:
97: 98: 99: 100: 101: 102:
103: public function doGET($params) {
104: self::$logger->debug('>>doGET($params=['.var_export($params, true).'])');
105:
106: echo AlphaView::displayPageHead($this);
107:
108:
109: $temp = new DEnum();
110:
111: if (isset($params['start']) ? $this->startPoint = $params['start']: $this->startPoint = 1);
112:
113: $objects = $temp->loadAll($this->startPoint);
114:
115: AlphaDAO::disconnect();
116:
117: $this->BOCount = $this->BO->getCount();
118:
119: echo AlphaView::renderDeleteForm();
120:
121: foreach($objects as $object) {
122: $temp = AlphaView::getInstance($object);
123: echo $temp->listView();
124: }
125:
126: echo AlphaView::displayPageFoot($this);
127:
128: self::$logger->debug('<<doGET');
129: }
130:
131: 132: 133: 134: 135: 136:
137: public function doPOST($params) {
138: self::$logger->debug('>>doPOST($params=['.var_export($params, true).'])');
139:
140: self::$logger->debug('<<doPOST');
141: }
142:
143: 144: 145: 146: 147:
148: private function createDEnumTables() {
149: $tmpDEnum = new DEnum();
150:
151: echo '<p>Attempting to build table '.DEnum::TABLE_NAME.' for class DEnum : </p>';
152:
153: try {
154: $tmpDEnum->makeTable();
155: echo AlphaView::displayUpdateMessage('Successfully re-created the database table '.DEnum::TABLE_NAME);
156: self::$logger->action('Re-created the table '.DEnum::TABLE_NAME);
157: }catch(AlphaException $e) {
158: echo AlphaView::displayErrorMessage('Failed re-created the database table '.DEnum::TABLE_NAME.', check the log');
159: self::$logger->error($e->getMessage());
160: }
161:
162: $tmpDEnumItem = new DEnumItem();
163:
164: echo '<p>Attempting to build table '.DEnumItem::TABLE_NAME.' for class DEnumItem : </p>';
165:
166: try {
167: $tmpDEnumItem->makeTable();
168: echo AlphaView::displayUpdateMessage('Successfully re-created the database table '.DEnumItem::TABLE_NAME);
169: self::$logger->action('Re-created the table '.DEnumItem::TABLE_NAME);
170: }catch(AlphaException $e) {
171: echo AlphaView::displayErrorMessage('Failed re-created the database table '.DEnumItem::TABLE_NAME.', check the log');
172: self::$logger->error($e->getMessage());
173: }
174: }
175:
176: 177: 178: 179: 180:
181: public function after_displayPageHead_callback() {
182: $menu = AlphaView::loadTemplateFragment('html', 'adminmenu.phtml', array());
183:
184: return $menu;
185: }
186: }
187:
188:
189: if ('ListDEnums.php' == basename($_SERVER['PHP_SELF'])) {
190: $controller = new ListDEnums();
191:
192: if(!empty($_POST)) {
193: $controller->doPOST($_POST);
194: }else{
195: $controller->doGET($_GET);
196: }
197: }
198:
199: ?>