<?
class TModuleComboBox extends TComboBox
{
    function __construct()
    {
        $this->jsClassName = "TComboBox";
        
        parent::__construct();
    }

    public static function getFieldInfo($params=array())
    {
        return(array(
            "dataType" => "CHAR",
            "dataTypeParams" => "36",
            "defaultValue" => "",
        ));
    }

    function getHeadHtml($params=array())
    {
        parent::getHeadHtml($params);
        
        //addHeadHtml("<script type='text/javascript' src='".getUrlFromPath(__FILE__, true)."FontComboBox.class.js'></script>",true);
        //addHeadHtml("<script type='text/javascript' src='".getUrlFromPath(__FILE__, true)."../FontDetector/FontDetector.class.js'></script>",true);
        //addHeadHtml("<link href='".getUrlFromPath(__FILE__, true)."admin.css' rel='stylesheet' type='text/css' />",true);
        addExtendingHeadHtml($params, __CLASS__);
    }

    function onGetContent($params=array(), $value="")
    {
        $params = $this->extractParams($params);
        if (true/*!$params["values"]*/)
        {
            $params["values"] = array("");
            $params["texts"] = array("");
            foreach(getObject("Modules")->records as $record)
            {
                $params["values"][] = $record["id"];
                $params["texts"][] = $record["name"];
            }
            
            //dump("!");
            //dump($params);
            //$params["values"] = explode("|", "|Arial|Arial Black|Arial Narrow|Arial Rounded MT Bold|Bookman Old Style|Bradley Hand ITC|Century|Century Gothic|Comic Sans MS|Courier|Courier New|Georgia|Gentium|Impact|King|Lucida Console|Lalit|Modena|Monotype Corsiva|Papyrus|Tahoma|TeX|Times|Times New Roman|Trebuchet MS|Verdana|Verona|cursive|monospace|serif|sans-serif|fantasy|default");

            //foreach($params["values"] as $val)
            //{
            //    $params["texts"][] = "<span style='font-family:".$val."'>".$val."</span>";
            //}
        }    
        $params["sort"] = true;

        return(parent::onGetContent($params, $value));
    }

    function onGetDisplayValue($recordValues=array())
    {
        $value = $this->getValue($recordValues);
        
        if ($value)
        {
            $Module = getObject("Modules")->getModule($value);
            return($Module->name);
        }
        
    }
    
    function getValueFromText($recordValues)
    {
        $value = $recordValues[$this->name];

        foreach(getObject("Modules")->records as $record)
        {
            if ($record["name"] == $value)
            {
                $value = $record["id"];
                break;
            }
        }

        return($value);
    }
    
}
?>