Alpha Framework alpha--controller
[ class tree: alpha--controller ] [ index: alpha--controller ] [ all elements ]

Source for file ViewMetrics.php

Documentation is available at ViewMetrics.php

  1. <?php
  2.  
  3. // include the config file
  4. if(!isset($config)) {
  5.     require_once '../util/AlphaConfig.inc';
  6.     $config AlphaConfig::getInstance();
  7. }
  8.  
  9. require_once $config->get('sysRoot').'alpha/util/Logger.inc';
  10. require_once $config->get('sysRoot').'alpha/controller/AlphaController.inc';
  11. require_once $config->get('sysRoot').'alpha/controller/AlphaControllerInterface.inc';
  12. require_once $config->get('sysRoot').'alpha/util/metrics/AlphaMetrics.inc';
  13. require_once $config->get('sysRoot').'alpha/view/AlphaView.inc';
  14.  
  15. /**
  16.  * 
  17.  * Controller used to display the software metrics for the application
  18.  * 
  19.  * @package alpha::controller
  20.  * @since 1.0
  21.  * @author John Collins <dev@alphaframework.org>
  22.  * @version $Id: ViewMetrics.php 1453 2011-12-04 15:12:54Z johnc $
  23.  * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
  24.  * @copyright Copyright (c) 2011, John Collins (founder of Alpha Framework).
  25.  *  All rights reserved.
  26.  * 
  27.  *  <pre>
  28.  *  Redistribution and use in source and binary forms, with or
  29.  *  without modification, are permitted provided that the
  30.  *  following conditions are met:
  31.  * 
  32.  *  * Redistributions of source code must retain the above
  33.  *    copyright notice, this list of conditions and the
  34.  *    following disclaimer.
  35.  *  * Redistributions in binary form must reproduce the above
  36.  *    copyright notice, this list of conditions and the
  37.  *    following disclaimer in the documentation and/or other
  38.  *    materials provided with the distribution.
  39.  *  * Neither the name of the Alpha Framework nor the names
  40.  *    of its contributors may be used to endorse or promote
  41.  *    products derived from this software without specific
  42.  *    prior written permission.
  43.  *   
  44.  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  45.  *  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  46.  *  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  47.  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  48.  *  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  49.  *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  50.  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  51.  *  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  52.  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  53.  *  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  54.  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  55.  *  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  56.  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  57.  *  </pre>
  58.  *  
  59.  */
  60.     /**
  61.      * Trace logger
  62.      * 
  63.      * @var Logger 
  64.      * @since 1.0
  65.      */
  66.     private static $logger null;
  67.     
  68.     /**
  69.      * The constructor
  70.      * 
  71.      * @since 1.0
  72.      */
  73.     public function __construct({
  74.         self::$logger new Logger('ViewMetrics');
  75.         self::$logger->debug('>>__construct()');
  76.         
  77.         // ensure that the super class constructor is called, indicating the rights group
  78.         parent::__construct('Admin');
  79.         
  80.         $this->setTitle('Application Metrics');
  81.         
  82.         self::$logger->debug('<<__construct');
  83.     }
  84.     
  85.     /**
  86.      * Handle GET requests
  87.      * 
  88.      * @param array $params 
  89.      * @since 1.0
  90.      */
  91.     public function doGET($params{
  92.         self::$logger->debug('>>doGET($params=['.var_export($paramstrue).'])');
  93.         
  94.         global $config;
  95.         
  96.         echo AlphaView::displayPageHead($this);
  97.  
  98.         $dir $config->get('sysRoot');
  99.         
  100.         $metrics new AlphaMetrics($dir);
  101.         $metrics->calculateLOC();
  102.         echo $metrics->resultsToHTML();
  103.         
  104.         echo AlphaView::displayPageFoot($this);
  105.         
  106.         self::$logger->debug('<<doGET');
  107.     }
  108.     
  109.     /**
  110.      * Handle POST requests
  111.      * 
  112.      * @param array $params 
  113.      * @since 1.0
  114.      */
  115.     public function doPOST($params{
  116.         self::$logger->debug('>>doPOST($params=['.var_export($paramstrue).'])');
  117.         
  118.         self::$logger->debug('<<doPOST');
  119.     }
  120.     
  121.     /**
  122.      * Renders the JQuery code to do zebra-style table colouring
  123.      *
  124.      * @return string 
  125.      * @since 1.0
  126.      */
  127.     public function during_displayPageHead_callback({
  128.         global $config;
  129.         
  130.         $html '<script type="text/javascript">'.
  131.             '$(document).ready(function(){'.
  132.             '    $(".list_view tr:even").addClass("zebraAlt");'.
  133.             '    $(".list_view tr").mouseover(function(){'.
  134.             '        $(this).addClass("zebraOver");'.
  135.             '    });'.
  136.             '    $(".list_view tr").mouseout(function(){'.
  137.             '        $(this).removeClass("zebraOver");'.
  138.             '    });'.
  139.             '});</script>';
  140.         
  141.         return $html;
  142.     }
  143. }
  144.  
  145. // now build the new controller if this file is called directly
  146. if ('ViewMetrics.php' == basename($_SERVER['PHP_SELF'])) {
  147.     $controller new ViewMetrics();
  148.     
  149.     if(!empty($_POST)) {            
  150.         $controller->doPOST($_POST);
  151.     }else{
  152.         $controller->doGET($_GET);
  153.     }
  154. }
  155.  
  156. ?>

Documentation generated on Tue, 13 Dec 2011 20:27:53 +0000 by phpDocumentor 1.4.3