[TYPO3-german] Calendar Base Ext. (cal) und Datumsformatierung bei der Suche GELÖST

Philipp Eckelmann p.eckelmann at stylomat.com
Sun Sep 23 15:57:52 CEST 2007


Hallo zusammen,

es gibt zwar keinen Thread hierfür bisher, aber ich wollte Euch kurz
teilhaben lassen, falls Ihr Euch auch mal daran stören solltet, dass die
Suche nach einem Kalender Event eine eigenartige Datumseingabe YYYYMMDD
erfordert. Hier nun die Lösung:

In der Datei „/typoconf/ext/cal/controller/class.tx_cal_controller.php“ die
Funktion “searchEvent()” durch die folgende Funktion ersetzen:

	function searchEvent() {
		$type = $this->conf['type'];
		$pidList = $this->conf['pidList'];
		
		/* @todo drawSearchClass */
		$hookObjectsArr =
$this->getHookObjectsArray('drawsearchClass');
		
#		$start_day = intval($this->piVars['start_day']);
		$start_day =
strftime("%Y%m%d",intval(parseDate($this->piVars['start_day'],$this->conf['v
iew.']['search.']['rlmp_dateselectorlib_config.']['inputFieldDateTimeFormat'
])));
#		$end_day = intval($this->piVars['end_day']);
		$end_day =
strftime("%Y%m%d",intval(parseDate($this->piVars['end_day'],$this->conf['vie
w.']['search.']['rlmp_dateselectorlib_config.']['inputFieldDateTimeFormat'])
));
		$searchword = strip_tags($this->piVars['query']);

		if($start_day==0 && $end_day==0){
			//$searchword =
$this->cObj->stdWrap($this->conf['view.']['search.']['defaultValues.']['quer
y'],$this->conf['view.']['search.']['defaultValues.']['query.']);
			$start_day =
date('Ymd',$this->getListViewTime($this->conf['view.']['search.']['defaultVa
lues.']['start_day']));
			$end_day = date('Ymd',
$this->getListViewTime($this->conf['view.']['search.']['defaultValues.']['en
d_day']));
		}
#		$minStarttime =
intval($this->conf['view.']['search.']['startRange']);
		$minStarttime =
strftime("%Y%m%d",intval(parseDate($this->conf['view.']['search.']['startRan
ge'],$this->conf['view.']['search.']['rlmp_dateselectorlib_config.']['inputF
ieldDateTimeFormat'])));
        if($minStarttime<19700102) {
        	$minStarttime=19700102;
        }
        
#        $maxEndtime = intval($this->conf['view.']['search.']['endRange']);
        $maxEndtime =
strftime("%Y%m%d",intval(parseDate($this->conf['view.']['search.']['endRange
'],$this->conf['view.']['search.']['rlmp_dateselectorlib_config.']['inputFie
ldDateTimeFormat'])));

        if($maxEndtime>20300101) {
        	$maxEndtime=20300101;
        }
        if($maxEndtime<19700102) {
        	$maxEndtime=19700102;
        }
	
        if($start_day<$minStarttime) {
        	$start_day=$minStarttime;
        }
        if($start_day>$maxEndtime) {
        	$start_day=$maxEndtime;
        }
        
        if($end_day<$minStarttime) {
        	$end_day=$minStarttime;
        }
        if($end_day>$maxEndtime) {
        	$end_day=$maxEndtime;
        }
        if($end_day<$start_day) {
        	$end_day=$start_day;
        }

#		$starttime =
$start_day>0?parseDate($start_day,$this->conf['view.']['search.']['rlmp_date
selectorlib_config.']['inputFieldDateTimeFormat']):strtotime($this->conf['vi
ew.']['search.']['event.']['startRange']);
		$starttime =
$start_day>0?parseDate($start_day,"%Y%m%d"):strtotime($this->conf['view.']['
search.']['event.']['startRange']);
#		$endtime =
$end_day>0?parseDate($end_day,$this->conf['view.']['search.']['rlmp_datesele
ctorlib_config.']['inputFieldDateTimeFormat']):strtotime($this->conf['view.'
]['search.']['event.']['endRange']);
		$endtime =
$end_day>0?parseDate($end_day,"%Y%m%d"):parseDate($this->conf['view.']['sear
ch.']['event.']['endRange'],$this->conf['view.']['search.']['rlmp_dateselect
orlib_config.']['inputFieldDateTimeFormat']);
		$endtime += 86399;

		$locationIds =
strip_tags($this->convertLinkVarArrayToList($this->piVars['location_ids']));
		$modelObj =
&tx_cal_registry::Registry('basic','modelcontroller');
		$list = $modelObj->searchEvents($type, $pidList, $starttime,
$endtime, $searchword, $locationIds);
		// Hook: postSearchEventRendering
		foreach ($hookObjectsArr as $hookObj) {
			if (method_exists($hookObj,
'preSearchEventRendering')) {
				$hookObj->preSearchEventRendering($list,
$this);
			}
		}
		$viewObj =
&tx_cal_registry::Registry('basic','viewcontroller');
		$drawnList = $viewObj->drawSearchEventResult($list,
$starttime, $endtime, $searchword, $locationIds);

		// Hook: preSearchEventRendering
		foreach ($hookObjectsArr as $hookObj) {
			if (method_exists($hookObj,
'postSearchEventRendering')) {
	
$hookObj->postSearchEventRendering($drawnList, $list, $this);
			}
		}

		return $drawnList;
	}

Dann nur noch im Typoscript SETUP die folgenden Zeilen einfügen:

plugin.tx_cal_controller.view.search.rlmp_dateselectorlib_config.dateTimeFor
mat = %d.%m.%Y
plugin.tx_cal_controller.view.search.rlmp_dateselectorlib_config.inputFieldD
ateTimeFormat = %d.%m.%Y
plugin.tx_cal_controller.view.search.rlmp_dateselectorlib_config.toolTipDate
TimeFormat = %d.%m.%Y
plugin.tx_cal_controller.view.search.startRange = 01.02.1970
plugin.tx_cal_controller.view.search.endRange = 01.01.2029
plugin.tx_cal_controller.view.search.event.startRange = 01.02.1970
plugin.tx_cal_controller.view.search.event.endRange = 01.01.2029

Fertig!

Da bei der Code-Erweiterung nur interne Funktionen von cal zum Einsatz
gekommen sind, funktioniert das theoretisch auch mit jeder anderen
Datumsformatierung. Viel Spaß beim Ausprobieren. Ach ja, das ganze basiert
auf der cal-Version 0.15.4

Bin für Feedback immer dankbar.

Gruß
Philipp





More information about the TYPO3-german mailing list