<?php  defined('_JEXEC') or die();
/**
 * @version $Id: klarnamultilist.php 6369 2012-08-22 14:33:46Z alatak $
 *
 * @author Valérie Isaksen
 * @package VirtueMart
 * @copyright Copyright (c) 2004 - 2012 VirtueMart Team. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * VirtueMart is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 */

// Check to ensure this file is within the rest of the framework
defined('JPATH_BASE') or die();

/**
 * Renders a multiple item select element
 *
 */

class JElementKlarnaMultiList extends JElement
{
	/**
	 * Element name
	 *
	 * @access       protected
	 * @var          string
	 */
	var $_name = 'KlarnaMultiList';

	function fetchElement ($name, $value, &$node, $control_name)
	{
		// Base name of the HTML control.
		$ctrl = $control_name . '[' . $name . ']';

		// Construct an array of the HTML OPTION statements.
		$options = array();
		foreach ($node->children() as $option) {
			$val = $option->attributes('value');
			$text = $option->data();
			$options[] = JHTML::_('select.option', $val, vmText::_($text));
		}

		// Construct the various argument calls that are supported.
		$attribs = ' ';
		if ($v = $node->attributes('size')) {
			$attribs .= 'size="' . $v . '"';
		}
		if ($v = $node->attributes('class')) {
			$attribs .= 'class="' . $v . '"';
		} else {
			$attribs .= 'class="inputbox"';
		}
		if ($m = $node->attributes('multiple')) {

			$attribs = 'multiple="true"   data-placeholder="' . vmText::_('COM_VIRTUEMART_DRDOWN_SELECT_SOME_OPTIONS') . '"';
			$ctrl .= '[]';
		}

		// Render the HTML SELECT list.
		return JHTML::_('select.genericlist', $options, $ctrl, $attribs, 'value', 'text', $value, $control_name . $name);
	}
}