function select_periodo_meses($nombre, $valor = '', $duracion_periodo_meses = 1, $include_blank = true)
{
    use_helper('DateForm');
    $opciones = array();
    if ($duracion_periodo_meses == 1) {
        $value = select_month_tag($nombre, $valor, array('control_name' => $nombre));
    } else {
        $lista_periodos = array('2' => 'bimestre', '3' => 'trimestre', '4' => 'cuatrimestre', '6' => 'semestre');
        $periodo = $lista_periodos[$duracion_periodo_meses];
        $lista_posiciones = array('1' => __('primer'), '2' => __('segundo'), '3' => __('tercer'), '4' => __('cuarto'), '5' => __('quinto'), '6' => __('sexto'));
        $cuantos = floor(12 / $duracion_periodo_meses);
        $opciones = array();
        for ($i = 1; $i <= $cuantos; $i++) {
            $opciones[$i] = __('%1% %2%', array('%1%' => $lista_posiciones[$i], '%2%' => $periodo));
        }
        $value = select_tag($nombre, options_for_select($opciones, $valor, array('include_blank' => $include_blank)), array('control_name' => $nombre));
    }
    return $value;
}
/**
 * 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);
}
Exemple #3
0
<select name="section"> 
	<option value="job" <?php 
if ($section == "job") {
    echo "selected";
}
?>
> Jobs section </option> 
	<option value="house" <?php 
if ($section == "house") {
    echo "selected";
}
?>
> Housing section </option> 
</select> 

<?php 
echo select_month_tag('month', $month);
?>
 
<?php 
echo select_year_tag('year', $year, array('year_end' => date("Y"), 'year_start' => date("Y") - 2));
?>
 

<input type="submit" value="check">
</form>

</body>
</html>
    
Exemple #4
0
            </div>
            <div class="wrap"><label
                    for="<?php 
echo $form['ccard_expire']->renderId();
?>
"> <?php 
echo $form['ccard_expire']->renderLabelName();
?>
            </label> <?php 
//echo $form['ccard_expire']
?>
 <?php 
//echo $form['ccard_expire']->renderError()
?>
                <?php 
echo select_month_tag('month', 'Select month', array('use_month_numbers' => true, 'include_custom' => 'Select month'), array('style' => 'width:95px'));
$year_start = date('Y', strtotime('now'));
$year_end = date('Y', strtotime('+20 years'));
echo select_year_tag('year', 'Select year', array('year_start' => $year_start, 'year_end' => $year_end, 'include_custom' => 'Select year'), array('style' => 'width:90px'));
//'include_blank' => true
?>
                <?php 
if ($exp == 1) {
    ?>
                <ul class="error_list">
                    <li>Please select expiration date </li>
                </ul>
                <?php 
}
?>
            <?php 
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);
}
Exemple #6
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);
}
// 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');
$t->like(select_month_tag('month', null, array(), array('id' => 'foo')), '<select name="month" id="foo">', 'select_month_tag() takes an array of attribute options as its fourth argument');
// select_year_tag()
$t->diag('select_year_tag()');
$t->like(select_year_tag('year'), '/<select name="year" id="year">/', 'select_year_tag() outputs a select tag for years');
$t->like(select_year_tag('year'), '/<option value="' . date('Y') . '" selected="selected">/', 'select_year_tag() selects the current year by default');
$t->like(select_year_tag('year', 2006), '/<option value="2006" selected="selected">/', 'select_year_tag() takes a year as its second argument');
// options
$t->is(preg_match_all('/<option /', select_year_tag('year', 2006, array('year_start' => 2005, 'year_end' => 2007)), $matches), 3, 'select_year_tag() takes a "year_start" and a "year_end" options');
$t->like(select_year_tag('year', null, array('include_custom' => 'test')), "/<option value=\"\">test<\\/option>/", 'select_year_tag() can take an "include_custom" option');
$t->like(select_year_tag('year', null, array('include_blank' => true)), "/<option value=\"\"><\\/option>/", 'select_year_tag() can take an "include_blank" option');
$t->like(select_year_tag('year', null, array(), array('class' => 'foo')), '<select name="year" id="year" class="foo">', 'select_year_tag() takes an array of attribute options as its fourth argument');
$t->like(select_year_tag('year', null, array(), array('id' => 'foo')), '<select name="year" id="foo">', 'select_year_tag() takes an array of attribute options as its fourth argument');
// select_date_tag()
$t->diag('select_date_tag()');
$t->todo('select_date_tag()');
// select_second_tag()
Exemple #8
0
function select_month($path, $options = array(), $html_options = array())
{
    $name = _get_complete_bind_path($path);
    $bindStatus =& new BindStatus(_get_bind_path($path));
    $boundValue = $bindStatus->getDisplayValue();
    return select_month_tag($name, $boundValue, $options, $html_options);
}
Exemple #9
0
?>
                </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 
echo select_tag('vistas', options_for_select($aVistas, $vista_id));
?>
                </td>