Location: PHPKode > projects > LDAPted > ldapted/includes/controls/Combobox.php
<?php
/***************************************************************************
 *
 *                                  Combobox.php
 *                              -------------------
 *
 *   begin                : Friday, Jul 5, 2002
 *   copyright            : (C) 2002 The Kabramps Team
 *   email                : hide@address.com,
 *                          hide@address.com
 *
 *
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 *   See the GNU General Public License for more details.
 *   (http://www.gnu.org/licenses/gpl.html)
 *
 ***************************************************************************/

class Combobox extends Text {
  function Combobox ($attribute, $value, $xmlDoc, $tmpl, $lang) {
    $this->Text($attribute, $value, $xmlDoc, $tmpl, $lang);
  }
  
  function get_edit_panel () {
    global $options;
    
    $textvalue  = $this->utf8_LDAPdecode($this->value);
    $selobj     = new Selection ($this->attribute, $this->xmlDoc);
    $selections = $selobj->get_selections();
    
    for ($i=0; $i < count($selections); $i++){
      if ( $selections[$i] != "" ) {
	if ($selections[$i] == $textvalue[0] and !$found ) {
	  $found = $selections[$i];	  
	}
      } 
    }
    
    // Couldn't find the ldap-entry in the given Textfile
    if (!$found and $textvalue[0] != "") {
      $selections[] = $textvalue[0];
      $found = $textvalue[0];
    }

    $this->tmpl->assign('OPTIONS', $selections);
    $this->tmpl->assign(array("SELECTED"     => $found,
                              "DESCRIPTION"  => $this->description,
                              "ERRORMESSAGE" => $this->get_error_message(),
                              "ATTRIBLABEL"  => $this->xmlDoc->get_label($this->attribute, $this->lang),
                              "ATTRIBNAME"   => $this->attribute,
                              "WIDTH"        => $this->attributeoptions["width"]
                       ));

    return $this->tmpl->fetch($this->get_template('edit'));
  }
}
?>
Return current item: LDAPted