<?php
goweb::loadClass('Zend_View_Helper_FormText');
/**
 * Goweb Sitemanager 5 Framework
 *
 * @version    5.1.4
 * @category   Goweb
 * @package    Zend_Form_Element
 * @author     I&D <dev@goweb.pt>, Pedro Pinto <ppinto@goweb.pt>
 * @copyright  2010 (c) Goweb (http://www.goweb.pt)
 */

/**
 *
 * @version    5.1.4
 * @category   Goweb
 * @package    Zend_Form_Element_FormDate
 * @author     I&D <dev@goweb.pt>, Pedro Pinto <ppinto@goweb.pt>
 * @copyright  2010 (c) Goweb (http://www.goweb.pt)
 */
class Zend_View_Helper_formDate extends Zend_View_Helper_FormText {
    public function formDate($name, $value = null, $attribs = null){
        Goweb::loadCSS('/admin/media/js/date-picker/css/datepicker.css');
        Goweb::loadJavascript('/admin/media/js/prototype.js');
        Goweb::loadJavascript('/admin/media/js/scriptaculous/scriptaculous.js');
        Goweb::loadJavascript('/admin/media/js/scriptaculous/effects.js');
        Goweb::loadJavascript('/admin/media/js/date-picker/js/datepicker.packed.js');
        if (is_null($attribs) || !isset($attribs['class'])){
            $attribs['class'] = 'split-date dateformat-Y-ds-m-ds-d';
        } else if (isset($attribs['class']) && !is_numeric(strpos($attribs['class'], 'dateformat'))){
            $attribs['class'] .= ' split-date dateformat-Y-ds-m-ds-d';
        }
        if (isset($attribs['jscalendar'])) unset($attribs['jscalendar']);
        $return = $this->formText($name, $value, $attribs);
        return $return;
    }
}