<?php
/**
 * ISO Project
 *
 * @category   Malf
 * @package    Malf_View
 * @subpackage Helper
 * @version    1.0
 */

/** Zend_View_Helper_Abstract.php */
require_once 'Zend/View/Helper/Abstract.php';

/**
 * Helper for shorten call for retrieving values from zend form elements
 */
class Malf_View_Helper_SelVal extends Zend_View_Helper_Abstract
{
    /**
     * Shortens form datamining.
     *
     * @access public
     *
     * @return string baseUrl for the link href attribute.
     */
    public function selVal($form, $element, $params = null)
    {
    	$value =  $form->getElement($element)->getValue();
    	$multi =  $form->getElement($element)->getMultiOptions();
    	
    	$rights = null;
    	if (isset($params['rights'])) $rights = $params['rights'];
    	
    	$return = '';
    	foreach ($multi as $k => $v) {
    		
    		$sel = '';
    		$dis = '';
    		if ($k == $value) $sel =  ' selected="selected"';
    		if ($rights && @(int) $rights[$k]['add'] != 1) $dis =  ' disabled="disabled"';
			$return .= '<option value="' . $k . '"' . $sel . $dis . '>' . $v . '</option>';
    	}
    	return $return;
    }
}
