parser

Написать ответ на текущее сообщение

 

 
   команды управления поиском

И ещё!

nkostya 15.06.2004 21:03

#######
# Достаем информацию для отображения календаря
@getCalendar[lparams][params]
$params[^hash::create[$lparams]]
$result[^MAIN:pSQL.sql[table]{
	SELECT
		^MAIN:pSQL.month[dt] AS month,
		^MAIN:pSQL.year[dt] AS year
	FROM
		news
	WHERE
		is_published = 1 AND
		dt_published <= ^MAIN:pSQL.now[]
	GROUP BY
		year DESC,
		month DESC
}]
#end @getCalendar[]

@printCalendar[calendar][now;curr_year;curr_month;y_hash;ym_hash;i;m]
^if($calendar){
	$now[^date::now[]]
	$curr_year(^form:year.int(^dtf:format[%Y]))
	$curr_month(^form:month.int(^dtf:format[%m]))

	^calendar.offset(-1)
	$min_year($calendar.year)
	$min_month($calendar.month)

	$y_hash[^calendar.hash[year;year][$.distinct(1)]]
	$ym_hash[^calendar.hash{^calendar.year.format[%04d]=^calendar.month.format[%02d]}[month][$.distinct(1)]]
	$year[^y_hash._keys[]]
	^year.sort($year.key)[desc]

	<table border="1" align="right">
	<tr valign="top">
		<td>
			^year.menu{
				<b>^if($year.key == $curr_year){
					$year.key /&nbsp^;
				}{
					^rem{ *** если кликнем в год, по попадем на последний месяц года, 
						за который у нас есть новости *** }
					^if(^calendar.locate[year;$year.key]){}
					<a href="?year=$year.key&month=$calendar.month">$year.key</a>
				}
				</b><br />
			}
		</td>
		<td>
			^if(^year.locate[key;$curr_year]){}
#			^year.menu{
#				^if($year.key == $curr_year){
					^for[i](0;11){
						$m(12-$i)
						^if(def $form:month && $m == $curr_month){
							<b>$dtf:[ri-locale].month.$m</b><br />
						}{
							^if(!($now.year == $year.key && $m > $now.month) && !($year.key == $min_year && $m < $min_month)){
								^if($ym_hash.[^year.key.format[%04d]=^m.format[%02d]]){
									<a href="?year=$year.key&month=$m">$dtf:[ri-locale].month.$m</a>
								}{
									$dtf:[ri-locale].month.$m
								}
								<br />
							}
						}
					}
#				}
#			}
		</td>
	</tr>
	</table>
}
#end @printCalendar[]
Так будет правильнее?