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

Source for file RecordSelector.inc

Documentation is available at RecordSelector.inc

  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/model/AlphaDAO.inc';
  10. require_once $config->get('sysRoot').'alpha/model/PersonObject.inc';
  11. require_once $config->get('sysRoot').'alpha/model/types/Relation.inc';
  12. require_once $config->get('sysRoot').'alpha/view/widgets/Button.inc';
  13.  
  14. /**
  15.  * Record selection HTML widget.
  16.  * 
  17.  * @package alpha::view::widgets
  18.  * @since 1.0
  19.  * @author John Collins <dev@alphaframework.org>
  20.  * @version $Id: RecordSelector.inc 1341 2011-03-17 15:02:02Z johnc $
  21.  * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
  22.  * @copyright Copyright (c) 2011, John Collins (founder of Alpha Framework).
  23.  *  All rights reserved.
  24.  * 
  25.  *  <pre>
  26.  *  Redistribution and use in source and binary forms, with or
  27.  *  without modification, are permitted provided that the
  28.  *  following conditions are met:
  29.  * 
  30.  *  * Redistributions of source code must retain the above
  31.  *    copyright notice, this list of conditions and the
  32.  *    following disclaimer.
  33.  *  * Redistributions in binary form must reproduce the above
  34.  *    copyright notice, this list of conditions and the
  35.  *    following disclaimer in the documentation and/or other
  36.  *    materials provided with the distribution.
  37.  *  * Neither the name of the Alpha Framework nor the names
  38.  *    of its contributors may be used to endorse or promote
  39.  *    products derived from this software without specific
  40.  *    prior written permission.
  41.  *   
  42.  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  43.  *  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  44.  *  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  45.  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  46.  *  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  47.  *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  48.  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  49.  *  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  50.  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  51.  *  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  52.  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  53.  *  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  54.  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  55.  *  </pre>
  56.  *  
  57.  */
  58. class RecordSelector {
  59.     /**
  60.      * The relation object that we are going to render a view for.
  61.      * 
  62.      * @var Relation 
  63.      * @since 1.0
  64.      */
  65.     private $relationObject null;
  66.  
  67.     /**
  68.      * The label text to use where required.
  69.      *  
  70.      * @var string 
  71.      * @since 1.0
  72.      */
  73.     private $label;
  74.     
  75.     /**
  76.      * Used to indicate the reading side when accessing from MANY-TO-MANY relation
  77.      * (leave blank for other relation types).
  78.      * 
  79.      * @var string 
  80.      * @since 1.0
  81.      */
  82.     private $accessingClassName;
  83.     
  84.     /**
  85.      * Javascript to run when the widget opens in a new window.
  86.      * 
  87.      * @var string 
  88.      * @since 1.0
  89.      */
  90.     private $onloadJS '';
  91.     
  92.     /**
  93.      * The name of the HTML input box for storing the hidden and display values.
  94.      * 
  95.      * @var string 
  96.      * @since 1.0
  97.      */
  98.     private $name;
  99.     
  100.     /**
  101.      * Trace logger
  102.      * 
  103.      * @var Logger 
  104.      * @since 1.0
  105.      */
  106.     private static $logger null;
  107.     
  108.     /**
  109.      * The constructor.
  110.      * 
  111.      * @param Relation $relation 
  112.      * @param string $label 
  113.      * @param string $name 
  114.      * @param string $accessingClassName 
  115.      * @since 1.0
  116.      * @throws IllegalArguementException
  117.      */
  118.     public function __construct($relation$label=''$name=''$accessingClassName=''{
  119.         self::$logger new Logger('RecordSelector');
  120.         self::$logger->debug('>>__construct(relation=['.$relation.'], label=['.$label.'], name=['.$name.'], accessingClassName=['.$accessingClassName.'])');
  121.         
  122.         if(!$relation instanceof Relation)
  123.             throw new IllegalArguementException('Invalid Relation object provided to the RecordSelector constructor!');
  124.         
  125.         $this->relationObject $relation;        
  126.         $this->label $label;
  127.         $this->name $name;
  128.         $this->accessingClassName $accessingClassName;
  129.         
  130.         self::$logger->debug('<<__construct');
  131.     }
  132.     
  133.     /**
  134.      * Renders the text boxes and buttons for the widget, that will appear in user forms.
  135.      * 
  136.      * @param bool $tableTags Include table tags and label (optional)
  137.      * @param bool $expanded Render the related fields in expanded format or not (optional)
  138.      * @param bool $buttons Render buttons for expanding/contacting the related fields (optional)
  139.      * @return string 
  140.      * @since 1.0
  141.      */
  142.     public function render($tableTags=true$expanded=false$buttons=true{
  143.         self::$logger->debug('>>render(tableTags=['.$tableTags.'], expanded=['.$expanded.'], buttons=['.$buttons.'])');
  144.         
  145.         global $config;
  146.         
  147.         $html '';
  148.         
  149.         // render text-box for many-to-one relations
  150.         if($this->relationObject->getRelationType(== 'MANY-TO-ONE'{
  151.             // value to appear in the text-box
  152.             $inputBoxValue $this->relationObject->getRelatedClassDisplayFieldValue();        
  153.                 
  154.             if($tableTags{
  155.                 $html .= '<tr><th style="width:25%;">';
  156.                 $html .= $this->label;
  157.                 $html .= '</th>';
  158.                     
  159.                 $html .= '<td>';            
  160.                 $html .= '<input type="text" size="70" class="readonly" name="'.$this->name.'_display" id="'.$this->name.'_display" value="'.$inputBoxValue.'" readonly/>';
  161.                 $js "$('#recordSelector').dialog('open');
  162.                  $('#recordSelector').load('".$config->get('sysURL')."ViewRecordSelector/value/'+document.getElementById('".$this->name."').value+'/field/".$this->name."/relatedClass/".$this->relationObject->getRelatedClass()."/relatedClassField/".$this->relationObject->getRelatedClassField()."/relatedClassDisplayField/".$this->relationObject->getRelatedClassDisplayField()."/relationType/".$this->relationObject->getRelationType()."');";
  163.                 $tmp new Button($js"Insert record link""relBut"$config->get('sysURL')."/alpha/images/icons/application_link.png");
  164.                 $html .= $tmp->render();
  165.                 $html .= '</td></tr>';
  166.             }else{
  167.                 $html .= '<input type="text" size="70" class="readonly" name="'.$this->name.'_display" id="'.$this->name.'_display" value="'.$inputBoxValue.'" readonly/>';
  168.                 $js "$('#recordSelector').dialog('open');
  169.                  $('#recordSelector').load('".$config->get('sysURL')."ViewRecordSelector/value/'+document.getElementById('".$this->name."').value+'/field/".$this->name."/relatedClass/".$this->relationObject->getRelatedClass()."/relatedClassField/".$this->relationObject->getRelatedClassField()."/relatedClassDisplayField/".$this->relationObject->getRelatedClassDisplayField()."/relationType/".$this->relationObject->getRelationType()."');";
  170.                 $tmp new Button($js"Insert record link""relBut"$config->get('sysURL')."/alpha/images/icons/application_link.png");
  171.                 $html .= $tmp->render();
  172.             }
  173.                 
  174.             // hidden field to store the actual value of the relation
  175.             $html .= '<input type="hidden" name="'.$this->name.'" id="'.$this->name.'" value="'.$this->relationObject->getValue().'"/>';
  176.             
  177.             if($this->relationObject->getRule(!= ''{
  178.                 $html .= '<input type="hidden" id="'.$this->name.'_msg" value="'.$this->relationObject->getHelper().'"/>';
  179.                 $html .= '<input type="hidden" id="'.$this->name.'_rule" value="'.$this->relationObject->getRule().'"/>';
  180.             }
  181.         }
  182.         
  183.         // render read-only list for one-to-many relations
  184.         if($this->relationObject->getRelationType(== 'ONE-TO-MANY'{
  185.             $objects $this->relationObject->getRelatedObjects();            
  186.             
  187.             if(count($objects&& $tableTags{
  188.                 // render tags differently            
  189.                 if($this->name == 'tags' && $this->relationObject->getRelatedClass(== 'TagObject'{
  190.                     $html .= '<tr><td colspan="2">'.$this->label.': ';
  191.                         
  192.                     foreach($objects as $tag{
  193.                         $html .= ' <a href="'.$config->get('sysURL').'search/q/'.$tag->get('content').'">'.$tag->get('content').'</a>';
  194.                     }                    
  195.                     
  196.                     $html .= '</td></tr>';
  197.                 }else{
  198.                     $html .= '<tr><th style="text-align:center;" colspan="2">';
  199.                     $html .= $this->label;
  200.                     if($buttons{
  201.                         $tmp new Button("document.getElementById('relation_field_".$this->name."').style.display = '';""Display related objects"$this->name."DisBut"$config->get('sysURL')."/alpha/images/icons/arrow_down.png");
  202.                         $html .= $tmp->render();
  203.                         $tmp new Button("document.getElementById('relation_field_".$this->name."').style.display = 'none';""Hide related objects"$this->name."HidBut"$config->get('sysURL')."/alpha/images/icons/arrow_up.png");
  204.                         $html .= $tmp->render();
  205.                     }
  206.                     $html .= '</th></tr>';
  207.                     
  208.                     $html .= '<tr><td colspan="2">';                
  209.                     $html .= '<table id="relation_field_'.$this->name.'" style="width:100%; display:'.($expanded '' 'none').';" class="relationTable">';
  210.                     
  211.                     $customViewControllerName AlphaController::getCustomControllerName(get_class($objects[0])'view');
  212.                     $customEditControllerName AlphaController::getCustomControllerName(get_class($objects[0])'edit');
  213.                     
  214.                     foreach($objects as $obj{
  215.                         $html .= '<tr><td>';                    
  216.                         // check to see if we are in the admin back-end
  217.                         if(strpos($_SERVER['REQUEST_URI']'/tk/'!== false{                    
  218.                             $viewURL FrontController::generateSecureURL('act=Detail&bo='.get_class($obj).'&oid='.$obj->getOID());
  219.                             $editURL FrontController::generateSecureURL('act=Edit&bo='.get_class($obj).'&oid='.$obj->getOID());
  220.                         }else{                        
  221.                             if(isset($customViewControllerName)) {
  222.                                 if($config->get('sysUseModRewrite'))
  223.                                     $viewURL $config->get('sysURL').$customViewControllerName.'/oid/'.$obj->getOID();
  224.                                 else
  225.                                     $viewURL $config->get('sysURL').'controller/'.$customViewControllerName.'.php?oid='.$obj->getOID();
  226.                             }else{
  227.                                 $viewURL $config->get('sysURL').'alpha/controller/Detail.php?bo='.get_class($obj).'&oid='.$obj->getOID();
  228.                             }
  229.                             if(isset($customEditControllerName)) {
  230.                                 if($config->get('sysUseModRewrite'))
  231.                                     $editURL $config->get('sysURL').$customEditControllerName.'/oid/'.$obj->getOID();
  232.                                 else
  233.                                     $editURL $config->get('sysURL').'controller/'.$customEditControllerName.'.php?oid='.$obj->getOID();
  234.                             }else{
  235.                                 $editURL $config->get('sysURL').'alpha/controller/Edit.php?bo='.get_class($obj).'&oid='.$obj->getOID();
  236.                             }
  237.                         }                        
  238.                                             
  239.                         /*
  240.                          * If any display headers were set with setRelatedClassHeaderFields, use them otherwise
  241.                          * use the OID of the related class as the only header.
  242.                          */ 
  243.                         $headerFields $this->relationObject->getRelatedClassHeaderFields();
  244.                         if(count($headerFields0{
  245.                             foreach($headerFields as $field{
  246.                                 $label $obj->getDataLabel($field);
  247.                                 $value $obj->get($field);
  248.                                 
  249.                                 if($field == 'created_by' || $field == 'updated_by'{
  250.                                     $person new PersonObject();
  251.                                     $person->load($value);
  252.                                     $value $person->getDisplayName();
  253.                                 }
  254.                                 
  255.                                 $html .= '<em>'.$label.': </em>'.$value.'&nbsp;&nbsp;&nbsp;&nbsp;';
  256.                             }
  257.                             // if the related BO has been updated, render the update time
  258.                             if($obj->getCreateTS(!= $obj->getUpdateTS()) {
  259.                                 try {
  260.                                     $html .= '<em>'.$obj->getDataLabel('updated_ts').': </em>'.$obj->get('updated_ts');
  261.                                 }catch(IllegalArguementException $e{
  262.                                     $html .= '<em>Updated: </em>'.$obj->get('updated_ts');
  263.                                 }
  264.                             }
  265.                         }else{
  266.                             $html .= '<em>'.$obj->getDataLabel('OID').': </em>'.$obj->get('OID');
  267.                         }
  268.                         // ensures that line returns are rendered
  269.                         $value str_replace("\n"'<br>'$obj->get($this->relationObject->getRelatedClassDisplayField()));
  270.                         $html .= '<p>'.$value.'</p>';
  271.                         
  272.                         $html .= '<div align="center">';
  273.                         $html .= '<a href="'.$viewURL.'">View</a>';
  274.                         // if the current user owns it, they get the edit link
  275.                         if(isset($_SESSION['currentUser']&& $_SESSION['currentUser']->getOID(== $obj->getCreatorId())
  276.                             $html .= '&nbsp;&nbsp;&nbsp;&nbsp;<a href="'.$editURL.'">Edit</a></div>';
  277.                         $html .= '</div>';                    
  278.                     }                
  279.                     $html .= '</table>';                
  280.                     
  281.                     $html .= '</td></tr>';
  282.                 }
  283.             }
  284.         }
  285.         
  286.         // render text-box for many-to-many relations
  287.         if($this->relationObject->getRelationType(== 'MANY-TO-MANY'{
  288.             // value to appear in the text-box
  289.             $inputBoxValue $this->relationObject->getRelatedClassDisplayFieldValue($this->accessingClassName);        
  290.             // replace commas with line returns
  291.             $inputBoxValue str_replace(",""\n"$inputBoxValue);
  292.             
  293.             if($tableTags{
  294.                 $html .= '<tr><th style="width:25%;">';
  295.                 $html .= $this->label;
  296.                 $html .= '</th>';
  297.                 
  298.                 $html .= '<td>';            
  299.                 $html .= '<textarea id="'.$this->name.'_display" style="width:100%;" rows="4" readonly>';
  300.                 $html .= $inputBoxValue;
  301.                 $html .= '</textarea>';
  302.                 $html .= '<div align="center">';
  303.                 $js "$('#recordSelector').dialog('open');
  304.                  $('#recordSelector').load('".$config->get('sysURL')."ViewRecordSelector/lookupOIDs/'+document.getElementById('".$this->name."').value+'/value/'+document.getElementById('".$this->name."_OID').value+'/field/".$this->name."/relatedClassLeft/".$this->relationObject->getRelatedClass('left')."/relatedClassLeftDisplayField/".$this->relationObject->getRelatedClassDisplayField('left')."/relatedClassRight/".$this->relationObject->getRelatedClass('right')."/relatedClassRightDisplayField/".$this->relationObject->getRelatedClassDisplayField('right')."/accessingClassName/".$this->accessingClassName."/relationType/".$this->relationObject->getRelationType()."');";
  305.                 $tmp new Button($js"Insert record link""relBut"$config->get('sysURL')."/alpha/images/icons/application_link.png");
  306.                 $html .= $tmp->render();
  307.                 $html .= '</div>';
  308.                 $html .= '</td></tr>';
  309.             }else{
  310.                 $html .= '<textarea id="'.$this->name.'_display" style="width:95%;" rows="5" readonly>';
  311.                 $html .= $inputBoxValue;
  312.                 $html .= '</textarea>';
  313.                 $js "$('#recordSelector').dialog('open');
  314.                  $('#recordSelector').load('".$config->get('sysURL')."ViewRecordSelector/lookupOIDs/'+document.getElementById('".$this->name."').value+'/value/'+document.getElementById('".$this->name."_OID').value+'/field/".$this->name."/relatedClassLeft/".$this->relationObject->getRelatedClass('left')."/relatedClassLeftDisplayField/".$this->relationObject->getRelatedClassDisplayField('left')."/relatedClassRight/".$this->relationObject->getRelatedClass('right')."/relatedClassRightDisplayField/".$this->relationObject->getRelatedClassDisplayField('right')."/accessingClassName/".$this->accessingClassName."/relationType/".$this->relationObject->getRelationType()."');";
  315.                 $tmp new Button($js"Insert record link""relBut"$config->get('sysURL')."/alpha/images/icons/application_link.png");
  316.                 $html .= $tmp->render();
  317.             }
  318.             
  319.             // hidden field to store the OID of the current BO
  320.             $html .= '<input type="hidden" name="'.$this->name.'_OID" id="'.$this->name.'_OID" value="'.$this->relationObject->getValue().'"/>';
  321.             
  322.             // hidden field to store the OIDs of the related BOs on the other side of the rel (this is what we check for when saving)
  323.             if($this->relationObject->getSide($this->accessingClassName== 'left')
  324.                 $lookupOIDs $this->relationObject->getLookup()->loadAllFieldValuesByAttribute('leftID'$this->relationObject->getValue()'rightID''DESC');
  325.             else
  326.                 $lookupOIDs $this->relationObject->getLookup()->loadAllFieldValuesByAttribute('rightID'$this->relationObject->getValue()'leftID''DESC');
  327.             $html .= '<input type="hidden" name="'.$this->name.'" id="'.$this->name.'" value="'.implode(','$lookupOIDs).'"/>';
  328.         }
  329.         
  330.         self::$logger->debug('<<__render [html]');
  331.         return $html;
  332.     }
  333.     
  334.     /**
  335.      * Returns the HTML for the record selector that will appear in a pop-up window.
  336.      * 
  337.      * @param array $lookupOIDs An optional array of related look-up OIDs, only required for rendering MANY-TO-MANY rels
  338.      * @since 1.0
  339.      * @return string 
  340.      */
  341.     public function renderSelector($lookupOIDs=array()) {
  342.         self::$logger->debug('>>renderSelector(lookupOIDs=['.var_export($lookupOIDstrue).'])');
  343.         
  344.         global $config;
  345.         
  346.         $html $this->displayPageHead();
  347.         
  348.         if($this->relationObject->getRelationType(== 'MANY-TO-MANY'{
  349.             
  350.             $classNameLeft $this->relationObject->getRelatedClass('left');
  351.             $classNameRight $this->relationObject->getRelatedClass('right');
  352.             
  353.             if($this->accessingClassName == $classNameLeft{
  354.                 AlphaDAO::loadClassDef($classNameRight);
  355.                 $tmpObject new $classNameRight;
  356.                 $fieldName $this->relationObject->getRelatedClassDisplayField('right');        
  357.                 $fieldLabel $tmpObject->getDataLabel($fieldName);
  358.                 $oidLabel $tmpObject->getDataLabel('OID');
  359.                 
  360.                 $objects $tmpObject->loadAll(00'OID''ASC'true);
  361.                 
  362.                 self::$logger->debug('['.count($objects).'] related ['.$classNameLeft.'] objects loaded');
  363.             }else{
  364.                 AlphaDAO::loadClassDef($classNameLeft);
  365.                 $tmpObject new $classNameLeft;
  366.                 $fieldName $this->relationObject->getRelatedClassDisplayField('left');
  367.                 $fieldLabel $tmpObject->getDataLabel($fieldName);
  368.                 $oidLabel $tmpObject->getDataLabel('OID');
  369.                 
  370.                 $objects $tmpObject->loadAll(00'OID''ASC'true);
  371.                 
  372.                 self::$logger->debug('['.count($objects).'] related ['.$classNameLeft.'] objects loaded');
  373.             }
  374.             
  375.             $html .= '<table cols="3" width="100%" class="bordered">';
  376.             $html .= '<tr>';        
  377.             $html .= '<th>'.$oidLabel.'</th>';
  378.             $html .= '<th>'.$fieldLabel.'</th>';
  379.             $html .= '<th>Connect?</th>';        
  380.             $html .= '</tr>';
  381.             
  382.             foreach($objects as $obj){
  383.                 $html .= '<tr>';
  384.                 $html .= '<td width="20%">';
  385.                 $html .= $obj->getOID();
  386.                 $html .= '</td>';
  387.                 $html .= '<td width="60%">';
  388.                 $html .= $obj->get($fieldName);
  389.                 $html .= '</td>';            
  390.                 $html .= '<td width="20%">';
  391.                 
  392.                 if(in_array($obj->getOID()$lookupOIDs)) {
  393.                     $this->onloadJS .= 'toggelOID(\''.$obj->getOID().'\',\''.$obj->get($fieldName).'\',true);';
  394.                     $html .= '<input name = "'.$obj->getOID().'" type="checkbox" checked onclick="toggelOID(\''.$obj->getOID().'\',\''.$obj->get($fieldName).'\',this.checked);"/>';
  395.                 }else{
  396.                     $html .= '<input name = "'.$obj->getOID().'" type="checkbox" onclick="toggelOID(\''.$obj->getOID().'\',\''.$obj->get($fieldName).'\',this.checked);"/>';
  397.                 }
  398.                 $html .= '</td>';
  399.                 $html .= '</tr>';
  400.             }
  401.             $html .= '</table>';
  402.             
  403.             $html .= '<div align="center" style="padding:10px;">';
  404.             $tmp new Button("$('#recordSelector').dialog('close');""Cancel""cancelBut"$config->get('sysURL')."/alpha/images/icons/cancel.png");
  405.             $html .= $tmp->render();
  406.             $html .= '&nbsp;&nbsp;&nbsp;';        
  407.             $tmp new Button("setParentFieldValues(); $('#".$_GET['field']."_display').blur(); $('#recordSelector').dialog('close');""Accept""acceptBut"$config->get('sysURL')."/alpha/images/icons/accept.png");
  408.             $html .= $tmp->render();
  409.             $html .= '</div>';
  410.         }else{            
  411.             $className $this->relationObject->getRelatedClass();
  412.             
  413.             AlphaDAO::loadClassDef($className);
  414.             
  415.             $tmpObject new $className;        
  416.             $label $tmpObject->getDataLabel($this->relationObject->getRelatedClassDisplayField());
  417.             $oidLabel $tmpObject->getDataLabel('OID');
  418.             
  419.             $objects $tmpObject->loadAll(00'OID''DESC');
  420.             
  421.             $html '<table cols="3" width="100%" class="bordered">';
  422.             $html .= '<tr>';        
  423.             $html .= '<th>'.$oidLabel.'</th>';
  424.             $html .= '<th>'.$label.'</th>';
  425.             $html .= '<th>Connect?</th>';        
  426.             $html .= '</tr>';
  427.             
  428.             foreach($objects as $obj){
  429.                 $html .= '<tr>';
  430.                 $html .= '<td width="20%">';
  431.                 $html .= $obj->getOID();
  432.                 $html .= '</td>';
  433.                 $html .= '<td width="60%">';
  434.                 $html .= $obj->get($this->relationObject->getRelatedClassDisplayField());
  435.                 $html .= '</td>';            
  436.                 $html .= '<td width="20%">';
  437.                 if($obj->getOID(== $this->relationObject->getValue()) {
  438.                     $html .= '<img src="'.$config->get('sysURL').'/alpha/images/icons/accept_ghost.png"/>';
  439.                 }else{
  440.                     $tmp new Button("document.getElementById('".$_GET['field']."').value = '".$obj->getOID()."'; document.getElementById('".$_GET['field']."_display').value = '".$obj->get($this->relationObject->getRelatedClassDisplayField())."'; $('#".$_GET['field']."_display').blur(); $('#recordSelector').dialog('close');""""selBut"$config->get('sysURL')."/alpha/images/icons/accept.png");
  441.                     $html .= $tmp->render();
  442.                 }
  443.                 $html .= '</td>';
  444.                 $html .= '</tr>';
  445.             }
  446.             $html .= '</table>';
  447.         }
  448.         
  449.         $html .= '<body>';
  450.         $html .= '<script type="text/javascript">'.
  451.                 '$(document).ready(function() {';
  452.             
  453.         $html .= $this->onloadJS;
  454.             
  455.         $html .= '});</script>';
  456.         
  457.         $html .= $this->displayPageFoot();
  458.         
  459.         self::$logger->debug('<<renderSelector[html]');
  460.         return $html;
  461.     }
  462.     
  463.     /**
  464.      * Renders the header HTML and JS for the record selector pop-up page.
  465.      * 
  466.      * @since 1.0
  467.      * @return string 
  468.      */
  469.     private function displayPageHead({
  470.         self::$logger->debug('>>displayPageHead()');
  471.         
  472.         global $config;        
  473.         
  474.         $html '<html>';
  475.         $html .= '<head>';
  476.         $html .= '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">';
  477.         $html .= '<title>Record Selector</title>';        
  478.         
  479.         $html .= '<link rel="StyleSheet" type="text/css" href="'.$config->get('sysURL').'alpha/lib/jquery/ui/themes/'.$config->get('sysTheme').'/ui.all.css">';
  480.         $html .= '<link rel="StyleSheet" type="text/css" href="'.$config->get('sysURL').'alpha/css/alpha.css">';
  481.         $html .= '<link rel="StyleSheet" type="text/css" href="'.$config->get('sysURL').'config/css/overrides.css">';
  482.         
  483.         $html .= '<script language="JavaScript" src="'.$config->get('sysURL').'/alpha/scripts/addOnloadEvent.js"></script>';
  484.         
  485.         $html .= '<script type="text/javascript">';
  486.         $html .= Button::renderJavascript();
  487.         $html .= '</script>';
  488.         
  489.         $html .= '<script language="JavaScript">
  490.             var selectedOIDs = new Object();
  491.             
  492.             function toggelOID(oid, displayValue, isSelected) {            
  493.                 if(isSelected)
  494.                     selectedOIDs[oid] = displayValue;
  495.                 else
  496.                     delete selectedOIDs[oid];
  497.             }
  498.             
  499.             function setParentFieldValues() {            
  500.                 var OIDs;
  501.                 var displayValues;
  502.                 
  503.                 for(key in selectedOIDs) {
  504.                     if(OIDs == null)
  505.                         OIDs = key;
  506.                     else
  507.                         OIDs = OIDs + \',\' + key;
  508.                         
  509.                     if(displayValues == null)
  510.                         displayValues = selectedOIDs[key];
  511.                     else
  512.                         displayValues = displayValues + \'\\n\' + selectedOIDs[key];
  513.                 }
  514.                 
  515.                 if(OIDs == null) {
  516.                     document.getElementById(\''.$_GET['field'].'\').value = "00000000000";
  517.                     document.getElementById(\''.$_GET['field'].'_display\').value = "";
  518.                 }else{
  519.                     document.getElementById(\''.$_GET['field'].'\').value = OIDs;
  520.                     document.getElementById(\''.$_GET['field'].'_display\').value = displayValues;
  521.                 }
  522.             }
  523.             
  524.             </script>';
  525.         
  526.         $html .= '</head>';
  527.         
  528.         self::$logger->debug('<<displayPageHead [html]');
  529.         return $html;
  530.     }
  531.     
  532.     /**
  533.      * Renders the footer HTML and JS for the record selector pop-up page.
  534.      * 
  535.      * @since 1.0
  536.      * @return string 
  537.      */
  538.     private function displayPageFoot({
  539.         $html '</body>';
  540.         $html .= '</html>';
  541.         
  542.         return $html;
  543.     }
  544. }
  545.  
  546.  
  547. ?>

Documentation generated on Thu, 17 Mar 2011 16:44:40 +0000 by phpDocumentor 1.4.3