cvs: smarty / Config_File.class.php RESOURCES /docs designers.sgml /plugins function.html_select_date.php
| From: | Monte Ohrt | Date: | Tue, 21 May 2002 19:41:37 +0000 |
| Subject: | cvs: smarty / Config_File.class.php RESOURCES /docs designers.sgml /plugins function.html_select_date.php | ||
| Groups: | php.smarty.cvs | ||
| Request: | Send a blank email to php-smarty-cvs+get-114@lists.php.net to get a copy of this message | ||
mohrt Tue May 21 15:41:37 2002 EDT
Modified files:
/smarty Config_File.class.php RESOURCES
/smarty/docs designers.sgml
/smarty/plugins function.html_select_date.php
Log:
update html_select_date with month_value_format attribute for controlling the format of the month
values.
Index: smarty/Config_File.class.php
diff -u smarty/Config_File.class.php:1.30 smarty/Config_File.class.php:1.31
--- smarty/Config_File.class.php:1.30 Wed Apr 3 09:45:03 2002
+++ smarty/Config_File.class.php Tue May 21 15:41:32 2002
@@ -3,7 +3,7 @@
/**
* Config_File class.
*
- * @version 2.0.1
+ * @version 2.1.1
* @author Andrei Zmievski <andrei@php.net>
* @access public
*
Index: smarty/RESOURCES
diff -u smarty/RESOURCES:1.5 smarty/RESOURCES:1.6
--- smarty/RESOURCES:1.5 Fri Mar 1 15:26:06 2002
+++ smarty/RESOURCES Tue May 21 15:41:33 2002
@@ -2,6 +2,7 @@
(if you have something to add, e-mail monte at ispi dot net)
Home Page:
+http://smarty.php.net
http://www.phpinsider.com/php/code/Smarty
Tutorials:
Index: smarty/docs/designers.sgml
diff -u smarty/docs/designers.sgml:1.29 smarty/docs/designers.sgml:1.30
--- smarty/docs/designers.sgml:1.29 Thu May 16 12:15:50 2002
+++ smarty/docs/designers.sgml Tue May 21 15:41:33 2002
@@ -131,7 +131,7 @@
{$Contacts[row].Phone}
-<body bgcolr="{#bgcolor#}"></programlisting>
+<body bgcolor="{#bgcolor#}"></programlisting>
</para>
<sect1 id="language.assigned.variables">
@@ -1253,8 +1253,8 @@
</para>
<caution>
<para>
- Be careful when capturing <command>{insert}</command> output. If
- you have caching turned on and you have <command>{insert}</command>
+ Be careful when capturing <command>insert</command> output. If
+ you have caching turned on and you have <command>insert</command>
commands that you expect to run within cached content, do not
capture this content.
</para>
@@ -3288,6 +3288,14 @@
<entry>No</entry>
<entry>\n</entry>
<entry>string printed between different fields</entry>
+ </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>
</tgroup>
Index: smarty/plugins/function.html_select_date.php
diff -u smarty/plugins/function.html_select_date.php:1.9
smarty/plugins/function.html_select_date.php:1.10
--- smarty/plugins/function.html_select_date.php:1.9 Mon Apr 15 10:56:38 2002
+++ smarty/plugins/function.html_select_date.php Tue May 21 15:41:34 2002
@@ -4,7 +4,7 @@
* -------------------------------------------------------------
* Type: function
* Name: html_select_date
- * Version: 1.2
+ * Version: 1.3
* Purpose: Prints the dropdowns for date selection.
* Author: Andrei Zmievski
*
@@ -13,6 +13,8 @@
* and end year values. (Monte)
* 1.2 added support for yyyy-mm-dd syntax for
* 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';
@@ -27,6 +29,8 @@
$display_months = true;
$display_years = true;
$month_format = "%B";
+ /* Write months as numbers by default GL */
+ $month_value_format = "%m";
$day_format = "%02d";
$year_as_text = false;
/* Display years in reverse order? Ie. 2000,1999,.... */
@@ -53,43 +57,47 @@
/* String printed between the different fields. */
$field_separator = "\n";
- extract($params);
- // If $time is not in format yyyy-mm-dd
- if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $time)) {
- // then $time is empty or unix timestamp or mysql timestamp
- // using smarty_make_timestamp to get an unix timestamp and
- // strftime to make yyyy-mm-dd
- $time = strftime('%Y-%m-%d', smarty_make_timestamp($time));
- }
- // Now split this in pieces, which later can be used to set the select
- $time = explode("-", $time);
-
- // make syntax "+N" or "-N" work with start_year and end_year
- if (preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match)) {
- if ($match[1] == '+') {
- $end_year = strftime('%Y') + $match[2];
- } else {
- $end_year = strftime('%Y') - $match[2];
- }
- }
- if (preg_match('!^(\+|\-)\s*(\d+)$!', $start_year, $match)) {
- if ($match[1] == '+') {
- $start_year = strftime('%Y') + $match[2];
- } else {
- $start_year = strftime('%Y') - $match[2];
- }
- }
+ extract($params);
+ // If $time is not in format yyyy-mm-dd
+ if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $time)) {
+ // then $time is empty or unix timestamp or mysql timestamp
+ // using smarty_make_timestamp to get an unix timestamp and
+ // strftime to make yyyy-mm-dd
+ $time = strftime('%Y-%m-%d', smarty_make_timestamp($time));
+ }
+ // Now split this in pieces, which later can be used to set the select
+ $time = explode("-", $time);
+
+ // make syntax "+N" or "-N" work with start_year and end_year
+ if (preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match)) {
+ if ($match[1] == '+') {
+ $end_year = strftime('%Y') + $match[2];
+ } else {
+ $end_year = strftime('%Y') - $match[2];
+ }
+ }
+ if (preg_match('!^(\+|\-)\s*(\d+)$!', $start_year, $match)) {
+ if ($match[1] == '+') {
+ $start_year = strftime('%Y') + $match[2];
+ } else {
+ $start_year = strftime('%Y') - $match[2];
+ }
+ }
+
$field_order = strtoupper($field_order);
$html_result = $month_result = $day_result = $year_result = "";
if ($display_months) {
$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_values[] = strftime($month_value_format, mktime(0, 0, 0, $i, 1, 2000));
+ }
$month_result .= '<select name=';
if (null !== $field_array){
@@ -107,11 +115,13 @@
$month_result .= ' ' . $all_extra;
}
$month_result .= '>'."\n";
+
$month_result .= smarty_function_html_options(array('output' =>
$month_names,
- 'values' => range(1,
12),
- 'selected' => $time[1],
+ 'values' =>
$month_values,
+ 'selected' =>
$month_values[$time[1]-1],
'print_result' => false),
$smarty);
+
$month_result .= '</select>';
}