| [ Index ] |
PHP Cross Reference of Web Application Component Toolkit |
[Summary view] [Print] [Text view]
1 <?php 2 //-------------------------------------------------------------------------------- 3 // Copyright 2003 Procata, Inc. 4 // Released under the LGPL license (http://www.gnu.org/copyleft/lesser.html) 5 //-------------------------------------------------------------------------------- 6 /** 7 * @package WACT_COMPONENT 8 * @version $Id: month.tag.php,v 1.18 2004/11/18 04:22:47 jeffmoore Exp $ 9 */ 10 //-------------------------------------------------------------------------------- 11 /** 12 * Include parent classes 13 */ 14 require_once WACT_ROOT . 'template/tags/core/block.tag.php'; 15 require_once WACT_ROOT . 'template/tags/html/table.tag.php'; 16 require_once WACT_ROOT . 'template/tags/html/tablecaption.tag.php'; 17 require_once WACT_ROOT . 'template/tags/html/tablerow.tag.php'; 18 require_once WACT_ROOT . 'template/tags/html/tablecell.tag.php'; 19 require_once WACT_ROOT . 'template/tags/html/anchor.tag.php'; 20 21 /** 22 * Register the tags in this file 23 */ 24 TagDictionary::registerTag(new TagInfo('calendar:MONTH', 'CalendarMonthTag'), __FILE__); 25 TagDictionary::registerTag(new TagInfo('calendar:TITLE', 'CalendarTitleStyleTag'), __FILE__); 26 TagDictionary::registerTag(new TagInfo('calendar:dayheader', 'CalendarDayHeaderStyleTag'), __FILE__); 27 TagDictionary::registerTag(new TagInfo('calendar:DAYSTYLE', 'CalendarDayStyleTag'), __FILE__); 28 TagDictionary::registerTag(new TagInfo('calendar:SELECTEDDAYSTYLE', 'CalendarSelectedDayStyleTag'), __FILE__); 29 TagDictionary::registerTag(new TagInfo('calendar:EMPTYDAYSTYLE', 'CalendarEmptyDayStyleTag'), __FILE__); 30 TagDictionary::registerTag(new TagInfo('calendar:NEXTPREV', 'CalendarNextPrevStyleTag'), __FILE__); 31 32 /** 33 * Compile time tag for generating monthly calendars 34 * @todo EXPERIMENTAL 35 * @see http://wact.sourceforge.net/index.php/CalendarMonthTag 36 * @access protected 37 * @package WACT_TAG 38 */ 39 class CalendarMonthTag extends CoreBlockTag { 40 /** 41 * File to include at runtime 42 * @var string path to runtime component relative to WACT_ROOT 43 * @access private 44 */ 45 var $runtimeIncludeFile = 'template/components/calendar/calendar_month.inc.php'; 46 /** 47 * Name of runtime component class 48 * @var string 49 * @access private 50 */ 51 var $runtimeComponentName = 'CalendarMonthComponent'; 52 /** 53 * @param CodeWriter 54 * @return void 55 * @access protected 56 */ 57 function preGenerate(&$code) { 58 parent::preGenerate($code); 59 if ( $yearUri = $this->getAttribute('yearuri') ) { 60 $code->writePHP($this->getComponentRefCode() . '->yearUri='); 61 $code->writePHPLiteral($yearUri); 62 $code->writePHP(';'); 63 } 64 if ( $monthUri = $this->getAttribute('monthuri') ) { 65 $code->writePHP($this->getComponentRefCode() . '->monthUri='); 66 $code->writePHPLiteral($monthUri); 67 $code->writePHP(';'); 68 } 69 if ( $dayUri = $this->getAttribute('dayuri') ) { 70 $code->writePHP($this->getComponentRefCode() . '->dayUri='); 71 $code->writePHPLiteral($dayUri); 72 $code->writePHP(';'); 73 } 74 $code->writePHP($this->getComponentRefCode() . '->prepare();'); 75 } 76 /** 77 * @param CodeWriter 78 * @return void 79 * @access protected 80 */ 81 function generateContents(&$code) { 82 $calMonthObjectRefCode = getNewServerId(); 83 $calDayObjectRefCode = getNewServerId(); 84 85 $Table = & new HtmlTableTag(); 86 87 foreach($this->getAttributesAsArray() as $AttributeName => $AttributeValue) { 88 $Table->setAttribute($AttributeName, $AttributeValue); 89 } 90 91 $this->addChild($Table); 92 93 if ( !$TitleStyle = & $this->findChildByClass('CalendarTitleStyleTag') ) { 94 $TitleStyle = & new CalendarTitleStyleTag(); 95 $this->addChild($TitleStyle); 96 } 97 $TitleStyle->calComponent = $this->getComponentRefCode(); 98 $TitleStyle->calMonthObjectRefCode = $calMonthObjectRefCode; 99 100 if ( !$NextPrevStyle = & $this->findChildByClass('CalendarNextPrevStyleTag') ) { 101 $NextPrevStyle = & new CalendarNextPrevStyleTag(); 102 $this->addChild($NextPrevStyle); 103 } 104 $NextPrevStyle->calMonthObjectRefCode = $calMonthObjectRefCode; 105 106 if ( !$DayStyle = & $this->findChildByClass('CalendarDayStyleTag') ) { 107 $DayStyle = & new CalendarDayStyleTag(); 108 $this->addChild($DayStyle); 109 } 110 $DayStyle->calDayObjectRefCode = $calDayObjectRefCode; 111 112 if ( !$SelectedDayStyle = & $this->findChildByClass('CalendarSelectedDayStyleTag') ) { 113 $SelectedDayStyle = & new CalendarSelectedDayStyleTag(); 114 $this->addChild($SelectedDayStyle); 115 } 116 $SelectedDayStyle->calDayObjectRefCode = $calDayObjectRefCode; 117 118 if ( !$EmptyDayStyle = & $this->findChildByClass('CalendarEmptyDayStyleTag') ) { 119 $EmptyDayStyle = & new CalendarEmptyDayStyleTag(); 120 $this->addChild($EmptyDayStyle); 121 } 122 $EmptyDayStyle->calDayObjectRefCode = $calDayObjectRefCode; 123 124 $code->writePHP('$'. $calMonthObjectRefCode . '='. 125 $this->getComponentRefCode() . '->getCalendar();'); 126 $weekCounterRefCode = getNewServerId(); 127 128 $Table->preGenerate($code); 129 $Table->generateContents($code); 130 131 if ( !$this->getAttribute('titleshow') ) { 132 $this->setAttribute('titleshow', 'true'); 133 } 134 if ( $this->getBoolAttribute('titleshow')) { 135 $code->writeHTML("<tr>\n<td colspan=\"7\">\n"); 136 $code->writeHTML("<table width=\"100%\" cellspacing=\"0\" border=\"0\">\n<tr>\n"); 137 138 if ( !$this->getAttribute('shownextprev') ) { 139 $this->setAttribute('shownextprev', 'true'); 140 } 141 if ( $this->getBoolAttribute('shownextprev')) { 142 $NextPrevStyle->preGenerate($code); 143 $NextPrevStyle->generateContents($code); 144 // This link should be a component 145 $code->writeHTML("<a href=\""); 146 $code->writePHP('echo ' . 147 $this->getComponentRefCode() . '->prevLink();'); 148 $code->writeHTML('"'); 149 150 $NextPrevStyle->generateAttributeList($code); 151 152 $code->writeHTML('>'); 153 if ( !$prev = $this->getAttribute('prevtext') ) { 154 $prev = '<'; 155 } 156 $code->writeHTML($prev); 157 $code->writeHTML('</a>'); 158 $NextPrevStyle->postGenerate($code); 159 } 160 161 $TitleStyle->preGenerate($code); 162 $TitleStyle->generateContents($code); 163 $TitleStyle->postGenerate($code); 164 165 if ( $this->getBoolAttribute('shownextprev')) { 166 $NextPrevStyle->preGenerate($code); 167 $NextPrevStyle->generateContents($code); 168 // This link should be a component 169 $code->writeHTML("<a href=\""); 170 $code->writePHP('echo ' . 171 $this->getComponentRefCode() . '->nextLink();'); 172 $code->writeHTML('"'); 173 174 $NextPrevStyle->generateAttributeList($code); 175 176 $code->writeHTML('>');; 177 if ( !$next = $this->getAttribute('nexttext') ) { 178 $next = '>'; 179 } 180 $code->writeHTML($next); 181 $code->writeHTML('</a>'); 182 $NextPrevStyle->postGenerate($code); 183 } 184 185 $code->writeHTML("<tr>\n</table>\n"); 186 $code->writeHTML("</td>\n</tr>\n"); 187 } 188 189 if ( !$this->getAttribute('dayheadershow') ) { 190 $this->setAttribute('dayheadershow', 'true'); 191 } 192 if ( $this->getBoolAttribute('dayheadershow')) { 193 $code->writeHTML('<tr'); 194 if ( $this->hasAttribute('dayheaderstyle') ) { 195 $code->writeHTML(' style="' . $this->getAttribute('dayheaderstyle') . '"'); 196 } 197 $code->writeHTML(">\n"); 198 // Not finding it - why? 199 if ( !$DayHeader = & $this->findChildByClass('CalendarDayHeaderStyleTag') ) { 200 $DayHeader = & new CalendarDayHeaderStyleTag(); 201 $this->addChild($DayHeader); 202 } 203 $DayHeader->calComponent = $this->getComponentRefCode(); 204 205 $DayHeader->preGenerate($code); 206 $DayHeader->generateContents($code); 207 $DayHeader->postGenerate($code); 208 $code->writeHTML("\n</tr>\n"); 209 } 210 211 $code->writePHP('while($'.$calDayObjectRefCode.'=$'. 212 $calMonthObjectRefCode.'->fetch(\'Calendar_Decorator_Uri\')){'); 213 $code->writePHP('$'.$calDayObjectRefCode.'->setFragments('. 214 $this->getComponentRefCode().'->yearUri,'. 215 $this->getComponentRefCode().'->monthUri,'. 216 $this->getComponentRefCode().'->dayUri);'); 217 $code->writePHP('if ($'.$calDayObjectRefCode.'->isFirst()) {'); 218 $code->writeHTML("<tr>\n"); 219 $code->writePHP('}'); 220 221 $code->writePHP('if ($'.$calDayObjectRefCode.'->isEmpty()) {'); 222 223 $EmptyDayStyle->preGenerate($code); 224 $EmptyDayStyle->generateContents($code); 225 $EmptyDayStyle->postGenerate($code); 226 227 $code->writePHP('} else if ($'.$calDayObjectRefCode.'->isSelected()) {'); 228 229 $SelectedDayStyle->preGenerate($code); 230 $SelectedDayStyle->generateContents($code); 231 $SelectedDayStyle->postGenerate($code); 232 233 $code->writePHP('} else {'); 234 235 $DayStyle->preGenerate($code); 236 $DayStyle->generateContents($code); 237 $DayStyle->postGenerate($code); 238 239 $code->writePHP('}'); 240 241 $code->writePHP('if ($'.$calDayObjectRefCode.'->isLast()) {'); 242 $code->writeHTML("</tr>\n"); 243 $code->writePHP('}'); 244 245 $code->writePHP('}'); 246 247 $Table->postGenerate($code); 248 } 249 } 250 /** 251 * Handles generation of the calendar title 252 * @todo EXPERIMENTAL 253 * @see http://wact.sourceforge.net/index.php/CalendarTitleStyleTag 254 * @access protected 255 * @package WACT_TAG 256 */ 257 class CalendarTitleStyleTag extends HtmlTableCellTag { 258 /** 259 * Name of the runtime calendar component reference 260 * @var string 261 * @access protected 262 */ 263 var $calComponent; 264 /** 265 * Used to refer to the runtime instance of PEAR::Calendar used to render 266 * the calendar 267 * @var string 268 * @access protected 269 */ 270 var $calMonthObjectRefCode; 271 /** 272 * @param CodeWriter 273 * @return void 274 * @access protected 275 */ 276 function generateContents(&$code) { 277 if ( !$align = $this->getAttribute('align') ) { 278 $this->setAttribute('align', 'center'); 279 } 280 parent::generateContents($code); 281 if ( !$monthformat = $this->getAttribute('monthformat') ) { 282 $monthformat = 'long'; 283 } 284 if ( !$yearformat = $this->getAttribute('yearformat') ) { 285 $yearformat = 'long'; 286 } 287 $code->writePHP('echo('.$this->calComponent.'->monthName('); 288 $code->writePHPLiteral($monthformat); 289 $code->writePHP(').\' \');'); 290 if ( !$this->getAttribute('hideyear') ) { 291 $code->writePHP('echo('.$this->calComponent.'->yearFormatted('); 292 $code->writePHPLiteral($yearformat); 293 $code->writePHP('));'); 294 } 295 } 296 } 297 /** 298 * Handles generation of the calendar day headers 299 * @todo EXPERIMENTAL 300 * @see http://wact.sourceforge.net/index.php/CalendarDayHeaderStyleTag 301 * @access protected 302 * @package WACT_TAG 303 */ 304 class CalendarDayHeaderStyleTag extends CoreBlockTag { 305 /** 306 * Name of the runtime calendar component reference 307 * @var string 308 * @access protected 309 */ 310 var $calComponent; 311 /** 312 * @param CodeWriter 313 * @return void 314 * @access protected 315 */ 316 function generateContents(&$code) { 317 $headers = getNewServerId(); 318 if ( !$format = $this->getAttribute('format') ) { 319 $format = 'long'; 320 } 321 $code->writePHP('$'.$headers.'='.$this->calComponent.'->dayHeaders('); 322 $code->writePHPLiteral($format); 323 $code->writePHP(');'); 324 for ( $i = 0; $i<7; $i++ ) { 325 $TH = & new HtmlTableHeaderTag(); 326 foreach($this->getAttributesAsArray() as $AttributeName => $AttributeValue) { 327 $TH->setAttribute($AttributeName, $AttributeValue); 328 } 329 $this->addChild($TH); 330 $TH->preGenerate($code); 331 $TH->generateContents($code); 332 $code->writePHP('echo ($'.$headers.'['.$i.']);'); 333 $TH->postGenerate($code); 334 } 335 } 336 } 337 /** 338 * Handles generation of the calendar days 339 * @todo EXPERIMENTAL 340 * @see http://wact.sourceforge.net/index.php/CalendarDayStyleTag 341 * @access protected 342 * @package WACT_TAG 343 */ 344 class CalendarDayStyleTag extends HtmlTableCellTag { 345 /** 346 * Used to refer to the runtime instance of PEAR::Calendar used to render 347 * the calendar 348 * @var string 349 * @access protected 350 */ 351 var $calDayObjectRefCode; 352 /** 353 * @param CodeWriter 354 * @return void 355 * @access protected 356 */ 357 function generateContents(&$code) { 358 parent::generateContents($code); 359 if ( !$links = $this->getAttribute('links') ) { 360 $links = 'show'; 361 } 362 if ( $links == 'show' ) { 363 $code->writeHTML('<a href="'); 364 $code->writePHP('echo ($_SERVER[\'PHP_SELF\'].\'?\'.$'. 365 $this->calDayObjectRefCode.'->this(\'day\'));'); 366 $code->writeHTML('">'); 367 } 368 $code->writePHP('echo ($'.$this->calDayObjectRefCode.'->thisDay());'); 369 if ( $links == 'show' ) { 370 $code->writeHTML('</a>'); 371 } 372 } 373 } 374 /** 375 * Handles generation of selected calendar days 376 * @todo EXPERIMENTAL 377 * @see http://wact.sourceforge.net/index.php/CalendarSelectedDayStyleTag 378 * @access protected 379 * @package WACT_TAG 380 */ 381 class CalendarSelectedDayStyleTag extends HtmlTableCellTag { 382 /** 383 * Used to refer to the runtime instance of PEAR::Calendar used to render 384 * the calendar 385 * @var string 386 * @access protected 387 */ 388 var $calDayObjectRefCode; 389 /** 390 * @param CodeWriter 391 * @return void 392 * @access protected 393 */ 394 function generateContents(&$code) { 395 parent::generateContents($code); 396 if ( !$links = $this->getAttribute('links') ) { 397 $links = 'show'; 398 } 399 if ( $links == 'show' ) { 400 $code->writeHTML('<a href="'); 401 $code->writePHP('echo ($_SERVER[\'PHP_SELF\'].\'?\'.$'. 402 $this->calDayObjectRefCode.'->this(\'day\'));'); 403 $code->writeHTML('">'); 404 } 405 $code->writePHP('echo ($'.$this->calDayObjectRefCode.'->thisDay());'); 406 if ( $links == 'show' ) { 407 $code->writeHTML('</a>'); 408 } 409 } 410 } 411 /** 412 * Handles generation of "empty" calendar days 413 * @todo EXPERIMENTAL 414 * @see http://wact.sourceforge.net/index.php/CalendarEmptyDayStyleTag 415 * @access protected 416 * @package WACT_TAG 417 */ 418 class CalendarEmptyDayStyleTag extends HtmlTableCellTag { 419 /** 420 * Used to refer to the runtime instance of PEAR::Calendar used to render 421 * the calendar 422 * @var string 423 * @access protected 424 */ 425 var $calDayObjectRefCode; 426 /** 427 * @param CodeWriter 428 * @return void 429 * @access protected 430 */ 431 function generateContents(&$code) { 432 parent::generateContents($code); 433 if ( $showDays = $this->getAttribute('showEmptyDays') ) { 434 $code->writePHP('echo ($'.$this->calDayObjectRefCode.'->thisDay());'); 435 } 436 if ( !$numbers = $this->getAttribute('numbers') ) { 437 $numbers = 'hide'; 438 } 439 if ( !$links = $this->getAttribute('links') ) { 440 $links = 'hide'; 441 } 442 if ( $links == 'show' ) { 443 $code->writeHTML('<a href="'); 444 $code->writePHP('echo ($_SERVER[\'PHP_SELF\'].\'?\'.$'.$this->calDayObjectRefCode.'->this(\'day\'));'); 445 $code->writeHTML('">'); 446 } 447 if ( $numbers == 'show' ) { 448 $code->writePHP('echo ($'.$this->calDayObjectRefCode.'->thisDay());'); 449 } 450 if ( $links == 'show' ) { 451 $code->writeHTML('</a>'); 452 } 453 } 454 } 455 456 /** 457 * Handles generation of next / prev links on the calendar 458 * @todo EXPERIMENTAL 459 * @see http://wact.sourceforge.net/index.php/CalendarNextPrevStyleTag 460 * @access protected 461 * @package WACT_TAG 462 */ 463 class CalendarNextPrevStyleTag extends HtmlTableCellTag { 464 /** 465 * @param CodeWriter 466 * @return void 467 * @access protected 468 */ 469 function generateContents(&$code) { 470 if ( !$align = $this->getAttribute('align') ) { 471 $this->setAttribute('align', 'center'); 472 } 473 parent::generateContents($code); 474 } 475 } 476 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sun Nov 28 19:36:09 2004 | Cross-referenced by PHPXref 0.5 |