mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
update html_select_date with month_value_format attribute for controlling the format of the month values.
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
/**
|
/**
|
||||||
* Config_File class.
|
* Config_File class.
|
||||||
*
|
*
|
||||||
* @version 2.0.1
|
* @version 2.1.1
|
||||||
* @author Andrei Zmievski <andrei@php.net>
|
* @author Andrei Zmievski <andrei@php.net>
|
||||||
* @access public
|
* @access public
|
||||||
*
|
*
|
||||||
|
@@ -2,6 +2,7 @@ Smarty Resources on the Web:
|
|||||||
(if you have something to add, e-mail monte at ispi dot net)
|
(if you have something to add, e-mail monte at ispi dot net)
|
||||||
|
|
||||||
Home Page:
|
Home Page:
|
||||||
|
http://smarty.php.net
|
||||||
http://www.phpinsider.com/php/code/Smarty
|
http://www.phpinsider.com/php/code/Smarty
|
||||||
|
|
||||||
Tutorials:
|
Tutorials:
|
||||||
|
@@ -131,7 +131,7 @@
|
|||||||
|
|
||||||
{$Contacts[row].Phone}
|
{$Contacts[row].Phone}
|
||||||
|
|
||||||
<body bgcolr="{#bgcolor#}"></programlisting>
|
<body bgcolor="{#bgcolor#}"></programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<sect1 id="language.assigned.variables">
|
<sect1 id="language.assigned.variables">
|
||||||
@@ -1253,8 +1253,8 @@ s m o k e r s a r e p. . .</programlisting>
|
|||||||
</para>
|
</para>
|
||||||
<caution>
|
<caution>
|
||||||
<para>
|
<para>
|
||||||
Be careful when capturing <command>{insert}</command> output. If
|
Be careful when capturing <command>insert</command> output. If
|
||||||
you have caching turned on and you have <command>{insert}</command>
|
you have caching turned on and you have <command>insert</command>
|
||||||
commands that you expect to run within cached content, do not
|
commands that you expect to run within cached content, do not
|
||||||
capture this content.
|
capture this content.
|
||||||
</para>
|
</para>
|
||||||
@@ -3289,6 +3289,14 @@ OUTPUT:
|
|||||||
<entry>\n</entry>
|
<entry>\n</entry>
|
||||||
<entry>string printed between different fields</entry>
|
<entry>string printed between different fields</entry>
|
||||||
</row>
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>month_value_format</entry>
|
||||||
|
<entry>string</entry>
|
||||||
|
<entry>No</entry>
|
||||||
|
<entry>%m</entry>
|
||||||
|
<entry>strftime format of the month values, default is
|
||||||
|
%m for month numbers.</entry>
|
||||||
|
</row>
|
||||||
</tbody>
|
</tbody>
|
||||||
</tgroup>
|
</tgroup>
|
||||||
</informaltable>
|
</informaltable>
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
/**
|
/**
|
||||||
* Config_File class.
|
* Config_File class.
|
||||||
*
|
*
|
||||||
* @version 2.0.1
|
* @version 2.1.1
|
||||||
* @author Andrei Zmievski <andrei@php.net>
|
* @author Andrei Zmievski <andrei@php.net>
|
||||||
* @access public
|
* @access public
|
||||||
*
|
*
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
* Type: function
|
* Type: function
|
||||||
* Name: html_select_date
|
* Name: html_select_date
|
||||||
* Version: 1.2
|
* Version: 1.3
|
||||||
* Purpose: Prints the dropdowns for date selection.
|
* Purpose: Prints the dropdowns for date selection.
|
||||||
* Author: Andrei Zmievski
|
* Author: Andrei Zmievski
|
||||||
*
|
*
|
||||||
@@ -13,6 +13,8 @@
|
|||||||
* and end year values. (Monte)
|
* and end year values. (Monte)
|
||||||
* 1.2 added support for yyyy-mm-dd syntax for
|
* 1.2 added support for yyyy-mm-dd syntax for
|
||||||
* time value. (Jan Rosier)
|
* time value. (Jan Rosier)
|
||||||
|
* 1.3 added support for choosing format for
|
||||||
|
* month values (Gary Loescher)
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
require_once SMARTY_DIR . $this->plugins_dir . '/shared.make_timestamp.php';
|
require_once SMARTY_DIR . $this->plugins_dir . '/shared.make_timestamp.php';
|
||||||
@@ -27,6 +29,8 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||||||
$display_months = true;
|
$display_months = true;
|
||||||
$display_years = true;
|
$display_years = true;
|
||||||
$month_format = "%B";
|
$month_format = "%B";
|
||||||
|
/* Write months as numbers by default GL */
|
||||||
|
$month_value_format = "%m";
|
||||||
$day_format = "%02d";
|
$day_format = "%02d";
|
||||||
$year_as_text = false;
|
$year_as_text = false;
|
||||||
/* Display years in reverse order? Ie. 2000,1999,.... */
|
/* Display years in reverse order? Ie. 2000,1999,.... */
|
||||||
@@ -53,6 +57,7 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||||||
/* String printed between the different fields. */
|
/* String printed between the different fields. */
|
||||||
$field_separator = "\n";
|
$field_separator = "\n";
|
||||||
|
|
||||||
|
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
// If $time is not in format yyyy-mm-dd
|
// If $time is not in format yyyy-mm-dd
|
||||||
@@ -87,9 +92,12 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||||||
|
|
||||||
if ($display_months) {
|
if ($display_months) {
|
||||||
$month_names = array();
|
$month_names = array();
|
||||||
|
$month_values = array();
|
||||||
|
|
||||||
for ($i = 1; $i <= 12; $i++)
|
for ($i = 1; $i <= 12; $i++) {
|
||||||
$month_names[] = strftime($month_format, mktime(0, 0, 0, $i, 1, 2000));
|
$month_names[] = strftime($month_format, mktime(0, 0, 0, $i, 1, 2000));
|
||||||
|
$month_values[] = strftime($month_value_format, mktime(0, 0, 0, $i, 1, 2000));
|
||||||
|
}
|
||||||
|
|
||||||
$month_result .= '<select name=';
|
$month_result .= '<select name=';
|
||||||
if (null !== $field_array){
|
if (null !== $field_array){
|
||||||
@@ -107,11 +115,13 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||||||
$month_result .= ' ' . $all_extra;
|
$month_result .= ' ' . $all_extra;
|
||||||
}
|
}
|
||||||
$month_result .= '>'."\n";
|
$month_result .= '>'."\n";
|
||||||
|
|
||||||
$month_result .= smarty_function_html_options(array('output' => $month_names,
|
$month_result .= smarty_function_html_options(array('output' => $month_names,
|
||||||
'values' => range(1, 12),
|
'values' => $month_values,
|
||||||
'selected' => $time[1],
|
'selected' => $month_values[$time[1]-1],
|
||||||
'print_result' => false),
|
'print_result' => false),
|
||||||
$smarty);
|
$smarty);
|
||||||
|
|
||||||
$month_result .= '</select>';
|
$month_result .= '</select>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
* Type: function
|
* Type: function
|
||||||
* Name: html_select_date
|
* Name: html_select_date
|
||||||
* Version: 1.2
|
* Version: 1.3
|
||||||
* Purpose: Prints the dropdowns for date selection.
|
* Purpose: Prints the dropdowns for date selection.
|
||||||
* Author: Andrei Zmievski
|
* Author: Andrei Zmievski
|
||||||
*
|
*
|
||||||
@@ -13,6 +13,8 @@
|
|||||||
* and end year values. (Monte)
|
* and end year values. (Monte)
|
||||||
* 1.2 added support for yyyy-mm-dd syntax for
|
* 1.2 added support for yyyy-mm-dd syntax for
|
||||||
* time value. (Jan Rosier)
|
* time value. (Jan Rosier)
|
||||||
|
* 1.3 added support for choosing format for
|
||||||
|
* month values (Gary Loescher)
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
require_once SMARTY_DIR . $this->plugins_dir . '/shared.make_timestamp.php';
|
require_once SMARTY_DIR . $this->plugins_dir . '/shared.make_timestamp.php';
|
||||||
@@ -27,6 +29,8 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||||||
$display_months = true;
|
$display_months = true;
|
||||||
$display_years = true;
|
$display_years = true;
|
||||||
$month_format = "%B";
|
$month_format = "%B";
|
||||||
|
/* Write months as numbers by default GL */
|
||||||
|
$month_value_format = "%m";
|
||||||
$day_format = "%02d";
|
$day_format = "%02d";
|
||||||
$year_as_text = false;
|
$year_as_text = false;
|
||||||
/* Display years in reverse order? Ie. 2000,1999,.... */
|
/* Display years in reverse order? Ie. 2000,1999,.... */
|
||||||
@@ -53,6 +57,7 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||||||
/* String printed between the different fields. */
|
/* String printed between the different fields. */
|
||||||
$field_separator = "\n";
|
$field_separator = "\n";
|
||||||
|
|
||||||
|
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
// If $time is not in format yyyy-mm-dd
|
// If $time is not in format yyyy-mm-dd
|
||||||
@@ -87,9 +92,12 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||||||
|
|
||||||
if ($display_months) {
|
if ($display_months) {
|
||||||
$month_names = array();
|
$month_names = array();
|
||||||
|
$month_values = array();
|
||||||
|
|
||||||
for ($i = 1; $i <= 12; $i++)
|
for ($i = 1; $i <= 12; $i++) {
|
||||||
$month_names[] = strftime($month_format, mktime(0, 0, 0, $i, 1, 2000));
|
$month_names[] = strftime($month_format, mktime(0, 0, 0, $i, 1, 2000));
|
||||||
|
$month_values[] = strftime($month_value_format, mktime(0, 0, 0, $i, 1, 2000));
|
||||||
|
}
|
||||||
|
|
||||||
$month_result .= '<select name=';
|
$month_result .= '<select name=';
|
||||||
if (null !== $field_array){
|
if (null !== $field_array){
|
||||||
@@ -107,11 +115,13 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||||||
$month_result .= ' ' . $all_extra;
|
$month_result .= ' ' . $all_extra;
|
||||||
}
|
}
|
||||||
$month_result .= '>'."\n";
|
$month_result .= '>'."\n";
|
||||||
|
|
||||||
$month_result .= smarty_function_html_options(array('output' => $month_names,
|
$month_result .= smarty_function_html_options(array('output' => $month_names,
|
||||||
'values' => range(1, 12),
|
'values' => $month_values,
|
||||||
'selected' => $time[1],
|
'selected' => $month_values[$time[1]-1],
|
||||||
'print_result' => false),
|
'print_result' => false),
|
||||||
$smarty);
|
$smarty);
|
||||||
|
|
||||||
$month_result .= '</select>';
|
$month_result .= '</select>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user