/**
 * Returns three <select> tags populated with a range of months, days, and years.
 *
 * By default, the <i>$value</i> parameter is set to today's month, day and year. To override this, simply pass a valid date
 * or a correctly formatted date array (see example) to the <i>$value</i> parameter. You can also set the <i>$value</i> 
 * parameter to null which will disable the <i>$value</i>, however this will only be useful if you pass 'include_blank' or 
 * 'include_custom' to the <i>$options</i> parameter. Also, the default selectable range of years is set to show five years 
 * back and five years forward from today's year. For instance, if today's year is 2006, the default 'year_start' option will 
 * be set to 2001 and the 'year_end' option will be set to 2011.  These start and end dates can easily be overwritten by 
 * setting the 'year_start' and 'year_end' options in the <i>$options</i> parameter. 
 *
 * <b>Note:</b> The <i>$name</i> parameter will automatically converted to array names. For example, a <i>$name</i> of "date" becomes:
 * <samp>
 *  <select name="date[month]">...</select>
 *  <select name="date[day]">...</select>
 *  <select name="date[year]">...</select>
 * </samp>
 *  
 * <b>Options:</b>
 * - include_blank     - Includes a blank <option> tag at the beginning of the string with an empty value.
 * - include_custom    - Includes an <option> tag with a custom display title at the beginning of the string with an empty value.
 * - discard_month     - If set to true, will only return select tags for day and year.
 * - discard_day       - If set to true, will only return select tags for month and year.
 * - discard_year      - If set to true, will only return select tags for month and day.
 * - use_month_numbers - If set to true, will show the month's numerical value (1 - 12) instead of the months full name.
 * - use_short_month   - If set to true, will show the month's short name (i.e. Jan, Feb, Mar) instead of its full name.
 * - year_start        - If set, the range of years will begin at this four-digit date (i.e. 1979)
 * - year_end          - If set, the range of years will end at this four-digit date (i.e. 2025)
 * - date_seperator    - Includes a string of defined text between each generated select tag
 *  
 * <b>Examples:</b>
 * <code>
 *  echo select_date_tag('date');
 * </code>
 *
 * <code>
 *  echo select_date_tag('date', '2006-10-30');
 * </code>
 *
 * <code>
 *  $date = array('year' => '1979', 'month' => 10, 'day' => 30);
 *  echo select_date_tag('date', $date, array('year_start' => $date['year'] - 10, 'year_end' => $date['year'] + 10));
 * </code>
 *
 * @param  string field name (automatically becomes an array of parts: name[year], name[month], year[day])
 * @param  mixed  accepts a valid date string or properly formatted date array
 * @param  array  additional HTML compliant <select> tag parameters
 * @return string three <select> tags populated with a months, days and years
 * @see select datetime_tag, select_month_tag, select_date_tag, select_year_tag
 */
function select_date_tag($name, $value = null, $options = array(), $html_options = array())
{
    $options = _parse_attributes($options);
    $culture = _get_option($options, 'culture', sfContext::getInstance()->getUser()->getCulture());
    // set it back for month tag
    $options['culture'] = $culture;
    $I18n_arr = _get_I18n_date_locales($culture);
    $date_seperator = _get_option($options, 'date_seperator', $I18n_arr['date_seperator']);
    $discard_month = _get_option($options, 'discard_month');
    $discard_day = _get_option($options, 'discard_day');
    $discard_year = _get_option($options, 'discard_year');
    // discarding month automatically discards day
    if ($discard_month) {
        $discard_day = true;
    }
    $order = _get_option($options, 'order');
    $tags = array();
    if (is_array($order) && count($order) == 3) {
        foreach ($order as $v) {
            $tags[] = $v[0];
        }
    } else {
        $tags = $I18n_arr['date_order'];
    }
    if ($include_custom = _get_option($options, 'include_custom')) {
        $include_custom_month = is_array($include_custom) ? isset($include_custom['month']) ? array('include_custom' => $include_custom['month']) : array() : array('include_custom' => $include_custom);
        $include_custom_day = is_array($include_custom) ? isset($include_custom['day']) ? array('include_custom' => $include_custom['day']) : array() : array('include_custom' => $include_custom);
        $include_custom_year = is_array($include_custom) ? isset($include_custom['year']) ? array('include_custom' => $include_custom['year']) : array() : array('include_custom' => $include_custom);
    } else {
        $include_custom_month = array();
        $include_custom_day = array();
        $include_custom_year = array();
    }
    $month_name = $name . '[month]';
    $m = !$discard_month ? select_month_tag($month_name, _parse_value_for_date($value, 'month', 'm'), $options + $include_custom_month, $html_options) : '';
    $day_name = $name . '[day]';
    $d = !$discard_day ? select_day_tag($day_name, _parse_value_for_date($value, 'day', 'd'), $options + $include_custom_day, $html_options) : '';
    $year_name = $name . '[year]';
    $y = !$discard_year ? select_year_tag($year_name, _parse_value_for_date($value, 'year', 'Y'), $options + $include_custom_year, $html_options) : '';
    // we have $tags = array ('m','d','y')
    foreach ($tags as $k => $v) {
        // $tags['m|d|y'] = $m|$d|$y
        if (strlen(${$v})) {
            $tags[$k] = ${$v};
        } else {
            unset($tags[$k]);
        }
    }
    return implode($date_seperator, $tags);
}
function my_input_date_tag($name, $value = null, $options = array(), $html_options = array())
{
    $options = _parse_attributes($options);
    $context = sfContext::getInstance();
    $culture = _get_option($options, 'culture', $context->getUser()->getCulture());
    // set it back for month tag
    $options['culture'] = $culture;
    $I18n_arr = _get_I18n_date_locales($culture);
    $date_seperator = _get_option($options, 'date_seperator', $I18n_arr['date_seperator']);
    $include_blank_month = array('include_blank' => _get_option($options, 'include_blank_month', false));
    $include_blank_day = array('include_blank' => _get_option($options, 'include_blank_day', false));
    $include_blank_year = array('include_blank' => _get_option($options, 'include_blank_year', false));
    $order = _get_option($options, 'order');
    $tags = array();
    if (is_array($order) && count($order) == 3) {
        foreach ($order as $v) {
            $tags[] = $v[0];
        }
    } else {
        $tags = $I18n_arr['date_order'];
    }
    $month_name = $name . '[month]';
    $m = select_month_tag($month_name, _parse_value_for_date($value, 'month', 'm'), $options + $include_blank_month, $html_options);
    $day_name = $name . '[day]';
    $d = select_day_tag($day_name, _parse_value_for_date($value, 'day', 'd'), $options + $include_blank_day, $html_options);
    $year_name = $name . '[year]';
    $y = select_year_tag($year_name, _parse_value_for_date($value, 'year', 'Y'), $options + $include_blank_year, $html_options);
    // we have $tags = array ('m','d','y')
    foreach ($tags as $k => $v) {
        // $tags['m|d|y'] = $m|$d|$y
        $tags[$k] = ${$v};
    }
    return implode($date_seperator, $tags);
}
Esempio n. 3
0
/**
 * Returns three <select> tags populated with a range of months, days, and years.
 *
 * By default, the <i>$value</i> parameter is set to today's month, day and year. To override this, simply pass a valid date
 * or a correctly formatted date array (see example) to the <i>$value</i> parameter. You can also set the <i>$value</i>
 * parameter to null which will disable the <i>$value</i>, however this will only be useful if you pass 'include_blank' or
 * 'include_custom' to the <i>$options</i> parameter. Also, the default selectable range of years is set to show five years
 * back and five years forward from today's year. For instance, if today's year is 2006, the default 'year_start' option will
 * be set to 2001 and the 'year_end' option will be set to 2011.  These start and end dates can easily be overwritten by
 * setting the 'year_start' and 'year_end' options in the <i>$options</i> parameter.
 *
 * <b>Note:</b> The <i>$name</i> parameter will automatically converted to array names. For example, a <i>$name</i> of "date" becomes:
 * <samp>
 *  <select name="date[month]">...</select>
 *  <select name="date[day]">...</select>
 *  <select name="date[year]">...</select>
 * </samp>
 *
 * <b>Options:</b>
 * - include_blank     - Includes a blank <option> tag at the beginning of the string with an empty value.
 * - include_custom    - Includes an <option> tag with a custom display title at the beginning of the string with an empty value.
 * - discard_month     - If set to true, will only return select tags for day and year.
 * - discard_day       - If set to true, will only return select tags for month and year.
 * - discard_year      - If set to true, will only return select tags for month and day.
 * - use_month_numbers - If set to true, will show the month's numerical value (1 - 12) instead of the months full name.
 * - use_short_month   - If set to true, will show the month's short name (i.e. Jan, Feb, Mar) instead of its full name.
 * - year_start        - If set, the range of years will begin at this four-digit date (i.e. 1979)
 * - year_end          - If set, the range of years will end at this four-digit date (i.e. 2025)
 * - date_seperator    - Includes a string of defined text between each generated select tag
 *
 * <b>Examples:</b>
 * <code>
 *  echo submit_date_tag('date');
 * </code>
 *
 * <code>
 *  echo select_date_tag('date', '2006-10-30');
 * </code>
 *
 * <code>
 *  $date = array('year' => '1979', 'month' => 10, 'day' => 30);
 *  echo select_date_tag('date', $date, array('year_start' => $date['year'] - 10, 'year_end' => $date['year'] + 10));
 * </code>
 *
 * @param  string field name (automatically becomes an array of parts: name[year], name[month], year[day])
 * @param  mixed  accepts a valid date string or properly formatted date array
 * @param  array  additional HTML compliant <select> tag parameters
 * @return string three <select> tags populated with a months, days and years
 * @see select datetime_tag, select_month_tag, select_date_tag, select_year_tag
 */
function select_date_tag($name, $value = null, $options = array(), $html_options = array())
{
    $options = _parse_attributes($options);
    $date_seperator = _get_option($options, 'date_seperator', '/');
    $discard_month = _get_option($options, 'discard_month');
    $discard_day = _get_option($options, 'discard_day');
    $discard_year = _get_option($options, 'discard_year');
    //discarding month automatically discards day
    if ($discard_month) {
        $discard_day = true;
    }
    $order = _get_option($options, 'order');
    $tags = array();
    if (is_array($order) && count($order) == 3) {
        foreach ($order as $v) {
            $tags[] = $v[0];
        }
    } else {
        $tags = array('m', 'd', 'y');
    }
    if ($include_custom = _get_option($options, 'include_custom')) {
        $include_custom_month = is_array($include_custom) ? isset($include_custom['month']) ? array('include_custom' => $include_custom['month']) : array() : array('include_custom' => $include_custom);
        $include_custom_day = is_array($include_custom) ? isset($include_custom['day']) ? array('include_custom' => $include_custom['day']) : array() : array('include_custom' => $include_custom);
        $include_custom_year = is_array($include_custom) ? isset($include_custom['year']) ? array('include_custom' => $include_custom['year']) : array() : array('include_custom' => $include_custom);
    } else {
        $include_custom_month = array();
        $include_custom_day = array();
        $include_custom_year = array();
    }
    $month_name = $name . '[month]';
    $m = !$discard_month ? select_month_tag($month_name, _parse_value_for_date($value, 'month', 'm'), $options + $include_custom_month, $html_options) : '';
    $day_name = $name . '[day]';
    $d = !$discard_day ? select_day_tag($day_name, _parse_value_for_date($value, 'day', 'd'), $options + $include_custom_day, $html_options) : '';
    $year_name = $name . '[year]';
    $y = !$discard_year ? select_year_tag($year_name, _parse_value_for_date($value, 'year', 'Y'), $options + $include_custom_year, $html_options) : '';
    // we have $tags = array ('m','d','y')
    foreach ($tags as $k => $v) {
        // $tags['m|d|y'] = $m|$d|$y
        $tags[$k] = ${$v};
    }
    return implode($date_seperator, $tags);
}
Esempio n. 4
0
require_once dirname(__FILE__) . '/../../../lib/helper/HelperHelper.php';
require_once dirname(__FILE__) . '/../../../lib/helper/TagHelper.php';
require_once dirname(__FILE__) . '/../../../lib/helper/AssetHelper.php';
require_once dirname(__FILE__) . '/../../../lib/helper/UrlHelper.php';
require_once dirname(__FILE__) . '/../../../lib/helper/DateFormHelper.php';
// select_day_tag()
$t->diag('select_day_tag()');
$t->like(select_day_tag('day'), '/<select name="day" id="day">/', 'select_day_tag() outputs a select tag for days');
$t->like(select_day_tag('day'), '/<option value="' . date('j') . '" selected="selected">/', 'select_day_tag() selects the current day by default');
$t->like(select_day_tag('day', 31), '/<option value="31" selected="selected">/', 'select_day_tag() takes a day as its second argument');
$t->like(select_day_tag('day', '01'), '/<option value="1" selected="selected">/', 'select_day_tag() takes a day as its second argument');
// options
$t->like(select_day_tag('day', null, array('include_custom' => 'test')), "/<option value=\"\">test<\\/option>/", 'select_day_tag() can take an "include_custom" option');
$t->like(select_day_tag('day', null, array('include_blank' => true)), "/<option value=\"\"><\\/option>/", 'select_day_tag() can take an "include_blank" option');
$t->like(select_day_tag('day', null, array(), array('class' => 'foo')), '<select name="day" id="day" class="foo">', 'select_day_tag() takes an array of attribute options as its fourth argument');
$t->like(select_day_tag('day', null, array(), array('id' => 'foo')), '<select name="day" id="foo">', 'select_day_tag() takes an array of attribute options as its fourth argument');
// select_month_tag()
$t->diag('select_month_tag()');
$t->like(select_month_tag('month'), '/<select name="month" id="month">/', 'select_month_tag() outputs a select tag for months');
$t->like(select_month_tag('month'), '/<option value="' . date('n') . '" selected="selected">/', 'select_month_tag() selects the current month by default');
$t->like(select_month_tag('month', 12), '/<option value="12" selected="selected">/', 'select_month_tag() takes a month as its second argument');
$t->like(select_month_tag('month', '02'), '/<option value="1">January<\\/option>/i', 'select_month_tag() displays month names by default');
// options
$t->like(select_month_tag('month', 2, array('use_short_month' => true)), '/<option value="1">Jan<\\/option>/i', 'select_month_tag() displays short month names if passed a "use_short_month" options');
$t->like(select_month_tag('month', 2, array('use_month_numbers' => true)), '/<option value="1">01<\\/option>/i', 'select_month_tag() displays numbers if passed a "use_month_numbers" options');
$t->like(select_month_tag('month', 2, array('culture' => 'fr')), '/<option value="1">janvier<\\/option>/i', 'select_month_tag() takes a culture option');
$t->like(select_month_tag('month', 2, array('use_short_month' => true, 'culture' => 'fr')), '/<option value="1">janv.<\\/option>/i', 'select_month_tag() displays short month names if passed a "use_short_month" options');
$t->like(select_month_tag('month', 2, array('use_short_month' => true, 'add_month_numbers' => true)), '/<option value="1">1 - Jan<\\/option>/i', 'select_month_tag() displays month names and month number if passed a "add_month_numbers" options');
$t->like(select_month_tag('month', null, array('include_custom' => 'test')), "/<option value=\"\">test<\\/option>/", 'select_month_tag() can take an "include_custom" option');
$t->like(select_month_tag('month', null, array('include_blank' => true)), "/<option value=\"\"><\\/option>/", 'select_month_tag() can take an "include_blank" option');
$t->like(select_month_tag('month', null, array(), array('class' => 'foo')), '<select name="month" id="month" class="foo">', 'select_month_tag() takes an array of attribute options as its fourth argument');
Esempio n. 5
0
function select_day($path, $options = array(), $html_options = array())
{
    $name = _get_complete_bind_path($path);
    $bindStatus =& new BindStatus(_get_bind_path($path));
    $boundValue = $bindStatus->getDisplayValue();
    return select_day_tag($name, $boundValue, $options, $html_options);
}
Esempio n. 6
0
?>
                    <?php 
echo select_tag('division_id', options_for_select($optionsDivision, $division_id));
?>
                </td>
                <td style='padding-left:50px'>
                    <?php 
echo label_for('fecha', __('Fecha Inicio:'), 'class="required" ');
?>
       
                </td>
                <td>
                    <?php 
//----- Nuevo -----//
//@TODO Obtener el año de inicio y de fin del cliclo lectivo
echo select_day_tag('dia', $d, 'include_custom=Elija un d&iacute;a');
?>
                    <?php 
echo select_month_tag('mes', $m, 'include_custom=Elija un mes use_short_month=true');
?>
                    <?php 
echo select_year_tag('ano', $y, 'include_custom=Elija un a&ntilde;o year_end=' . $anio_hasta . ' year_start=' . $anio_desde);
?>
                </td>
                <td style='padding-left:50px'>
                    <?php 
echo label_for('vista', __('Vista:'), 'class="required"');
?>
                </td>
                <td>  
                    <?php