Location: PHPKode > projects > Energine > energine-2.2/core2a/modules/share/components/LangSwitcher.class.php
<?php

/**
 * Содержит класс LangSwitcher
 *
 * @package energine
 * @author dr.Pavka
 * @copyright ColoCall 2006
 * @version $Id: LangSwitcher.class.php,v 1.6 2007/12/17 14:16:14 pavka Exp $
 */

//require_once('core/modules/share/components/DataSet.class.php');
//require_once('core/framework/Language.class.php');

/**
 * переключатель языков
 *
 * @package energine
 * @subpackage share
 */
final class LangSwitcher extends DataSet {
    /**
     * Конструктор класса
     *
     * @return void
     */
	public function __construct($name, $module, Document $document,  array $params = null) {
		parent::__construct($name, $module, $document,  $params);
		$this->setType(self::COMPONENT_TYPE_LIST);
	}

    /**
     * Method Description
     *
     * @return type
     * @access protected
     */

    protected function loadData() {
        $lang = Language::getInstance();
        $data = $lang->getLanguages();

        foreach ($data as $langID => $LangInfo) {
            $result[$langID] = $LangInfo;
            $result[$langID]['lang_id'] = $langID;
            $result[$langID]['lang_url'] = $result[$langID]['lang_abbr'].'/'.Request::getInstance()->getPath(Request::PATH_WHOLE, true);
        }
        return $result;
    }

    /**
     * Создаем перечень полей
     *
     * @return DataDescription
     * @access protected
     */

     protected function createDataDescription() {
        $result =  new DataDescription();
        $f = new FieldDescription('lang_id');
        $f->setType(FieldDescription::FIELD_TYPE_INT);
        $result->addFieldDescription($f);

        $f = new FieldDescription('lang_abbr');
        $f->setType(FieldDescription::FIELD_TYPE_STRING);
        $result->addFieldDescription($f);

        $f = new FieldDescription('lang_name');
        $f->setType(FieldDescription::FIELD_TYPE_STRING);
        $result->addFieldDescription($f);

        $f = new FieldDescription('lang_url');
        $f->setType(FieldDescription::FIELD_TYPE_STRING);
        $result->addFieldDescription($f);

        return $result;
     }


}
Return current item: Energine