Overview

Packages

  • alpha::controller
  • alpha::controller::front
  • alpha::exceptions
  • alpha::model
  • alpha::model::types
  • alpha::tasks
  • alpha::tests
  • alpha::util
  • alpha::util::cache
  • alpha::util::codehighlight
  • alpha::util::convertors
  • alpha::util::feeds
  • alpha::util::filters
  • alpha::util::graphs
  • alpha::util::helpers
  • alpha::util::metrics
  • alpha::view
  • alpha::view::renderers
  • alpha::view::widgets

Classes

  • AlphaController
  • CacheManager
  • Create
  • CreateArticle
  • Detail
  • Edit
  • EditArticle
  • EditDEnum
  • EditTags
  • GenSecureQueryStrings
  • Install
  • ListAll
  • ListBusinessObjects
  • ListDEnums
  • ListSequences
  • Login
  • Logout
  • PreviewArticle
  • Search
  • TagManager
  • ViewArticle
  • ViewArticleFile
  • ViewArticlePDF
  • ViewArticlePrint
  • ViewArticleTitle
  • ViewAttachment
  • ViewExcel
  • ViewFeed
  • ViewImage
  • ViewLog
  • ViewMetrics
  • ViewRecordSelector
  • ViewTestResults

Interfaces

  • AlphaControllerInterface
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  1: <?php
  2: 
  3: // include the config file
  4: if(!isset($config)) {
  5:     require_once '../util/AlphaConfig.inc';
  6:     $config = AlphaConfig::getInstance();
  7:     
  8:     require_once $config->get('app.root').'alpha/util/AlphaAutoLoader.inc';
  9: }
 10: 
 11: /**
 12:  * 
 13:  * Controller used to list all of the business objects for the system
 14:  * 
 15:  * @package alpha::controller
 16:  * @since 1.0
 17:  * @author John Collins <dev@alphaframework.org>
 18:  * @version $Id: ListBusinessObjects.php 1548 2012-07-29 17:07:07Z alphadevx $
 19:  * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
 20:  * @copyright Copyright (c) 2012, John Collins (founder of Alpha Framework).  
 21:  * All rights reserved.
 22:  * 
 23:  * <pre>
 24:  * Redistribution and use in source and binary forms, with or 
 25:  * without modification, are permitted provided that the 
 26:  * following conditions are met:
 27:  * 
 28:  * * Redistributions of source code must retain the above 
 29:  *   copyright notice, this list of conditions and the 
 30:  *   following disclaimer.
 31:  * * Redistributions in binary form must reproduce the above 
 32:  *   copyright notice, this list of conditions and the 
 33:  *   following disclaimer in the documentation and/or other 
 34:  *   materials provided with the distribution.
 35:  * * Neither the name of the Alpha Framework nor the names 
 36:  *   of its contributors may be used to endorse or promote 
 37:  *   products derived from this software without specific 
 38:  *   prior written permission.
 39:  *   
 40:  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
 41:  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
 42:  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
 43:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
 44:  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
 45:  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
 46:  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
 47:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
 48:  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
 49:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 50:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
 51:  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
 52:  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 53:  * </pre>
 54:  *  
 55:  */
 56: class ListBusinessObjects extends AlphaController implements AlphaControllerInterface {
 57:     /**
 58:      * Trace logger
 59:      * 
 60:      * @var Logger
 61:      * @since 1.0
 62:      */
 63:     private static $logger = null;
 64:     
 65:     /**
 66:      * the constructor
 67:      * 
 68:      * @since 1.0
 69:      */
 70:     public function __construct() {
 71:         self::$logger = new Logger('ListBusinessObjects');
 72:         self::$logger->debug('>>__construct()');
 73:         
 74:         global $config;
 75:         
 76:         // ensure that the super class constructor is called, indicating the rights group
 77:         parent::__construct('Admin');
 78:         
 79:         // set up the title and meta details
 80:         $this->setTitle('Listing all business objects in the system');
 81:         $this->setDescription('Page to list all business objects.');
 82:         $this->setKeywords('list,all,business,objects');
 83:         
 84:         self::$logger->debug('<<__construct');
 85:     }
 86:     
 87:     /**
 88:      * Handle GET requests
 89:      * 
 90:      * @param array $params
 91:      * @since 1.0
 92:      */
 93:     public function doGET($params) {
 94:         self::$logger->debug('>>doGET($params=['.var_export($params, true).'])');
 95:         
 96:         echo AlphaView::displayPageHead($this);
 97:         
 98:         $this->displayBodyContent();
 99:         
100:         echo AlphaView::displayPageFoot($this);
101:         
102:         self::$logger->debug('<<doGET');
103:     }
104:     
105:     /**
106:      * Handle POST requests
107:      * 
108:      * @param array $params
109:      * @since 1.0
110:      */
111:     public function doPOST($params) {
112:         self::$logger->debug('>>doPOST($params=['.var_export($params, true).'])');
113:         
114:         global $config;
115:         
116:         echo AlphaView::displayPageHead($this);
117:         
118:         try {
119:             // check the hidden security fields before accepting the form POST data
120:             if(!$this->checkSecurityFields())
121:                 throw new SecurityException('This page cannot accept post data from remote servers!');
122:         
123:             if(isset($params['createTableBut'])) {
124:                 try {                   
125:                     $classname = $params['createTableClass'];
126:                     AlphaDAO::loadClassDef($classname);
127:                         
128:                     $BO = new $classname(); 
129:                     $BO->makeTable();
130:                 
131:                     echo AlphaView::displayUpdateMessage('The table for the class '.$classname.' has been successfully created.');
132:                 }catch(AlphaException $e) {
133:                     self::$logger->error($e->getMessage());
134:                     echo AlphaView::displayErrorMessage('Error creating the table for the class '.$classname.', check the log!');
135:                 }
136:             }
137: 
138:             if(isset($params['createHistoryTableBut'])) {
139:                                 try {
140:                                         $classname = $params['createTableClass'];
141:                                         AlphaDAO::loadClassDef($classname);
142: 
143:                                     $BO = new $classname();
144:                                         $BO->makeHistoryTable();
145: 
146:                                         echo AlphaView::displayUpdateMessage('The history table for the class '.$classname.' has been successfully created.');
147:                                 }catch(AlphaException $e) {
148:                                         self::$logger->error($e->getMessage());
149:                                         echo AlphaView::displayErrorMessage('Error creating the history table for the class '.$classname.', check the log!');
150:                                 }
151:                         }
152:             
153:             if(isset($params['recreateTableClass']) && $params['admin_'.$params['recreateTableClass'].'_button_pressed'] == 'recreateTableBut') {
154:                 try {                   
155:                     $classname = $params['recreateTableClass'];
156:                     AlphaDAO::loadClassDef($classname);                 
157:                     $BO = new $classname(); 
158:                     $BO->rebuildTable();
159:                     
160:                     echo AlphaView::displayUpdateMessage('The table for the class '.$classname.' has been successfully recreated.');
161:                 }catch(AlphaException $e) {
162:                     self::$logger->error($e->getMessage());
163:                     echo AlphaView::displayErrorMessage('Error recreating the table for the class '.$classname.', check the log!');
164:                 }
165:             }
166:             
167:             if(isset($params['updateTableClass']) && $params['admin_'.$params['updateTableClass'].'_button_pressed'] == 'updateTableBut') {
168:                 try {
169:                     $classname = $params['updateTableClass'];
170:                     AlphaDAO::loadClassDef($classname);
171:                         
172:                     $BO = new $classname();
173:                     $missingFields = $BO->findMissingFields();
174:                     
175:                     $count = count($missingFields);
176:                     
177:                     for($i = 0; $i < $count; $i++)
178:                         $BO->addProperty($missingFields[$i]);
179:                     
180:                     echo AlphaView::displayUpdateMessage('The table for the class '.$classname.' has been successfully updated.');
181:                 }catch(AlphaException $e) {
182:                     self::$logger->error($e->getMessage());
183:                     echo AlphaView::displayErrorMessage('Error updating the table for the class '.$classname.', check the log!');
184:                 }
185:             }
186:         }catch(SecurityException $e) {
187:             echo AlphaView::displayErrorMessage($e->getMessage());
188:             self::$logger->warn($e->getMessage());
189:         }
190:         
191:         $this->displayBodyContent();
192:                 
193:         echo AlphaView::displayPageFoot($this);
194:         
195:         self::$logger->debug('<<doPOST');
196:     }
197:     
198:     /**
199:      * Private method to display the main body HTML for this page
200:      * 
201:      * @since 1.0
202:      */
203:     private function displayBodyContent() {
204:         
205:         $classNames = AlphaDAO::getBOClassNames();
206:         $loadedClasses = array();
207:         
208:         foreach($classNames as $classname) {
209:             AlphaDAO::loadClassDef($classname);
210:             array_push($loadedClasses, $classname);
211:         }
212:         
213:         foreach($loadedClasses as $classname) {
214:             try {
215:                 $BO = new $classname();
216:                 $BO_View = AlphaView::getInstance($BO);             
217:                 $BO_View->adminView();              
218:             }catch (AlphaException $e) {
219:                 self::$logger->error("[$classname]:".$e->getMessage());
220:                 // its possible that the exception occured due to the table schema being out of date
221:                 if($BO->checkTableExists() && $BO->checkTableNeedsUpdate()) {               
222:                     $missingFields = $BO->findMissingFields();
223:                 
224:                     $count = count($missingFields);
225:                     
226:                     for($i = 0; $i < $count; $i++)
227:                         $BO->addProperty($missingFields[$i]);
228:                         
229:                     // now try again...
230:                     $BO = new $classname();
231:                     $BO_View = AlphaView::getInstance($BO);
232:                     $BO_View->adminView();
233:                 }
234:             }catch (Exception $e) {
235:                 self::$logger->error($e->getMessage());
236:                 echo AlphaView::displayErrorMessage('Error accessing the class ['.$classname.'], check the log!');
237:             }
238:         }
239:     }
240:     
241:     /**
242:      * Use this callback to inject in the admin menu template fragment
243:      * 
244:      * @since 1.2
245:      */
246:     public function after_displayPageHead_callback() {
247:         $menu = AlphaView::loadTemplateFragment('html', 'adminmenu.phtml', array());
248:         
249:         return $menu;
250:     }
251: }
252: 
253: // now build the new controller
254: if(basename($_SERVER['PHP_SELF']) == 'ListBusinessObjects.php') {
255:     $controller = new ListBusinessObjects();
256:     
257:     if(!empty($_POST)) {            
258:         $controller->doPOST($_REQUEST);
259:     }else{
260:         $controller->doGET($_GET);
261:     }
262: }
263: 
264: ?>
265: 
Alpha Framework API Documentation API documentation generated by ApiGen 2.8.0