      1: <?php
      2:
      3: // include the config file
      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:  * Controller used to list all Sequences
     14:  *
     15:  * @package alpha::controller
     16:  * @since 1.0
     17:  * @author John Collins <dev@alphaframework.org>
     18:  * @version $Id: ListSequences.php 1652 2013-02-26 15:13:13Z alphadevx $
     19:  * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
     20:  * @copyright Copyright (c) 2013, 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 ListSequences extends ListAll implements AlphaControllerInterface {
     57:     /**
     58:      * Trace logger
     59:      *
     60:      * @var Logger
     61:      * @since 1.0
     62:      */
     63:     private static $logger = null;
     64:
     65:     /**
     66:      * constructor to set up the object
     67:      *
     68:      * @since 1.0
     69:      */
     70:     public function __construct() {
     71:         self::$logger = new Logger('ListSequences');
     72:         self::$logger->debug('>>__construct()');
     73:
     74:         // ensure that the super class constructor is called, indicating the rights group
     75:         parent::__construct('Admin');
     76:
     77:         $BO = new Sequence();
     78:
     79:         // make sure that the Sequence tables exist
     80:         if(!$BO->checkTableExists()) {
     81:             echo AlphaView::displayErrorMessage('Warning! The Sequence table do not exist, attempting to create it now...');
     82:             $BO->makeTable();
     83:         }
     84:
     85:         // set up the title and meta details
     86:         $this->setTitle('Listing all Sequences');
     87:         $this->setDescription('Page to list all Sequences.');
     88:         $this->setKeywords('list,all,Sequences');
     89:
     90:         self::$logger->debug('<<__construct');
     91:     }
     92:
     93:     /**
     94:      * Handle GET requests
     95:      *
     96:      * @param array $params
     97:      * @since 1.0
     98:      */
     99:     public function doGET($params) {
    100:         self::$logger->debug('>>doGET($params=['.var_export($params, true).'])');
    101:
    102:         echo AlphaView::displayPageHead($this);
    103:
    104:         // get all of the BOs and invoke the list_view on each one
    105:         $temp = new Sequence();
    106:         // set the start point for the list pagination
    107:         if (isset($params['start']) ? $this->startPoint = $params['start']: $this->startPoint = 1);
    108:
    109:         $objects = $temp->loadAll($this->startPoint);
    110:
    111:         AlphaDAO::disconnect();
    112:
    113:         $BO = new Sequence();
    114:         $this->BOCount = $BO->getCount();
    115:
    116:         echo AlphaView::renderDeleteForm();
    117:
    118:         foreach($objects as $object) {
    119:             $temp = AlphaView::getInstance($object);
    120:             echo $temp->listView();
    121:         }
    122:
    123:         echo AlphaView::displayPageFoot($this);
    124:
    125:         self::$logger->debug('<<doGET');
    126:     }
    127:
    128:     /**
    129:      * Handle POST requests
    130:      *
    131:      * @param array $params
    132:      * @since 1.0
    133:      */
    134:     public function doPOST($params) {
    135:         self::$logger->debug('>>doPOST($params=['.var_export($params, true).'])');
    136:
    137:         self::$logger->debug('<<doPOST');
    138:     }
    139:
    140:     /**
    141:      * Use this callback to inject in the admin menu template fragment
    142:      *
    143:      * @since 1.2
    144:      */
    145:     public function after_displayPageHead_callback() {
    146:         $menu = AlphaView::loadTemplateFragment('html', 'adminmenu.phtml', array());
    147:
    148:         return $menu;
    149:     }
    150: }
    151:
    152: // now build the new controller if this file is called directly
    153: if ('ListSequences.php' == basename($_SERVER['PHP_SELF'])) {
    154:     $controller = new ListSequences();
    155:
    156:     if(!empty($_POST)) {
    157:         $controller->doPOST($_POST);
    158:     }else{
    159:         $controller->doGET($_GET);
    160:     }
    161: }
    162:
    163: ?>