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 for viewing a RecordSelector widget.
 14:  * 
 15:  * @package alpha::controller
 16:  * @since 1.0
 17:  * @author John Collins <dev@alphaframework.org>
 18:  * @version $Id: ViewRecordSelector.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 ViewRecordSelector 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:      * Constructor
 67:      * 
 68:      * @since 1.0
 69:      */
 70:     public function __construct() {
 71:         self::$logger = new Logger('ViewRecordSelector');
 72:         self::$logger->debug('>>__construct()');
 73:         
 74:         // ensure that the super class constructor is called, indicating the rights group
 75:         parent::__construct('Public');
 76:         
 77:         self::$logger->debug('<<__construct');
 78:     }
 79:     
 80:     /**
 81:      * Handles get requests
 82:      *
 83:      * @param array $params
 84:      * @since 1.0
 85:      * @throws ResourceNotFoundException
 86:      */
 87:     public function doGet($params) {
 88:         self::$logger->debug('>>doGet(params=['.var_export($params, true).'])');
 89:         
 90:         $relationObject = new Relation();
 91:         
 92:         try {
 93:             $relationType = $params['relationType'];
 94:             $value = $params['value'];
 95:         }catch (Exception $e) {
 96:             self::$logger->error('Required param missing for ViewRecordSelector controller['.$e->getMessage().']');
 97:             throw new ResourceNotFoundException('File not found');
 98:         }
 99:     
100:         if($_GET['relationType'] == 'MANY-TO-MANY') {
101:             try {
102:                 $relatedClassLeft = $params['relatedClassLeft'];                
103:                 $relatedClassLeftDisplayField = $params['relatedClassLeftDisplayField'];
104:                 $relatedClassRight = $params['relatedClassRight'];
105:                 $relatedClassRightDisplayField = $params['relatedClassRightDisplayField'];              
106:                 $field = $params['field'];
107:                 $accessingClassName = $params['accessingClassName'];
108:                 $lookupOIDs = $params['lookupOIDs'];
109:             }catch (Exception $e) {
110:                 self::$logger->error('Required param missing for ViewRecordSelector controller['.$e->getMessage().']');
111:                 throw new ResourceNotFoundException('File not found');
112:             }
113:             
114:             $relationObject->setRelatedClass($relatedClassLeft, 'left');
115:             $relationObject->setRelatedClassDisplayField($relatedClassLeftDisplayField, 'left');
116:             $relationObject->setRelatedClass($relatedClassRight, 'right');
117:             $relationObject->setRelatedClassDisplayField($relatedClassRightDisplayField, 'right');
118:             $relationObject->setRelationType($relationType);
119:             $relationObject->setValue($value);
120:             
121:             $recSelector = new RecordSelector($relationObject, '', $field, $accessingClassName);
122:             echo $recSelector->renderSelector(explode(',', $lookupOIDs));
123:         }else{
124:             try {
125:                 $relatedClass = $params['relatedClass'];                
126:                 $relatedClassField = $params['relatedClassField'];
127:                 $relatedClassDisplayField = $params['relatedClassDisplayField'];
128:             }catch (Exception $e) {
129:                 self::$logger->error('Required param missing for ViewRecordSelector controller['.$e->getMessage().']');
130:                 throw new ResourceNotFoundException('File not found');
131:             }
132:             
133:             $relationObject->setRelatedClass($relatedClass);
134:             $relationObject->setRelatedClassField($relatedClassField);
135:             $relationObject->setRelatedClassDisplayField($relatedClassDisplayField);
136:             $relationObject->setRelationType($relationType);
137:             $relationObject->setValue($value);
138:             
139:             $recSelector = new RecordSelector($relationObject);
140:             echo $recSelector->renderSelector();
141:         }
142:         
143:         self::$logger->debug('<<__doGet');
144:     }
145:     
146:     /**
147:      * Handle POST requests
148:      * 
149:      * @param array $params
150:      * @since 1.0
151:      */
152:     public function doPOST($params) {
153:         self::$logger->debug('>>doPOST($params=['.var_export($params, true).'])');      
154:         
155:         self::$logger->debug('<<doPOST');
156:     }
157:     
158: }
159: 
160: // now build the new controller if this file is called directly
161: if ('ViewRecordSelector.php' == basename($_SERVER['PHP_SELF'])) {
162:     $controller = new ViewRecordSelector();
163:     
164:     if(!empty($_POST)) {            
165:         $controller->doPOST($_POST);
166:     }else{
167:         $controller->doGET($_GET);
168:     }
169: }
170: 
171: ?>
Alpha Framework ${alpha.version.new} API Documentation API documentation generated by ApiGen 2.8.0