Location: PHPKode > projects > PHPfaces - User Interface Framework > demo/event_calendar/CalendarEvents.class.php
<?php

class CalendarEvent1 extends PActionEvent {

	function actionPerformed($ui, $form, $component) {
		$txtEvent = $form->getComponent('txtEvent');
		$txtDate = $form->getComponent('txtDate');
		$txtTime = $form->getComponent('txtTime');
		$txtCity = $form->getComponent('txtCity');
		$txtLocation = $form->getComponent('txtLocation');
		$txtInfos = $form->getComponent('txtInfos');
		$txtLink = $form->getComponent('txtLink');
		$txtAuthor = $form->getComponent('txtAuthor');
		
		$table = $form->getComponent('eventTable');
		
		$lblEventErr = $form->getComponent('lblEventErr');
		$lblDateTimeErr = $form->getComponent('lblDateTimeErr');
		$lblCityErr = $form->getComponent('lblCityErr');
		$error = FALSE;
				
		if (strlen($txtEvent->getText()) < 2) {
			$lblEventErr->setVisible(TRUE); $error = TRUE;
		} else
			$lblEventErr->setVisible(FALSE);
		
		if (!DateFormat::formatDMY($txtDate->getText(), 'd.m.Y')) {
			$lblDateTimeErr->setVisible(TRUE); $error = TRUE;
		} else
			$lblDateTimeErr->setVisible(FALSE);	
		
		if (strlen($txtCity->getText()) < 2) {
			$lblCityErr->setVisible(TRUE); $error = TRUE;
		} else
			$lblCityErr->setVisible(FALSE);
		
		if ($error)
			return;
		
		$cityloc = $txtCity->getText();
		
		if ($txtLocation->getText() != '')
			$cityloc.= ' / '.$txtLocation->getText();
		
		$link = $txtLink->getText();
		
		if (strpos($link, 'http://') === FALSE)
			$link = 'http://'.$link;
		
		if ($txtLink->getText() != '')
			$event = '<a href="'.htmlspecialchars($link).'">'.htmlspecialchars($txtEvent->getText()).'</a>';
		else
			$event = $txtEvent->getText();
				
		$table->addRow(array($event,
							DateFormat::formatDMY($txtDate->getText(), 'd.m.Y'),
							htmlspecialchars($txtTime->getText()),
							htmlspecialchars($cityloc),
							htmlspecialchars($txtInfos->getText()),
							htmlspecialchars($txtAuthor->getText())));
							
		$table->sort(1);
	}

	function getFile() {
		return __FILE__;
	}

}

?>
Return current item: PHPfaces - User Interface Framework