[TYPO3-english] cooluri cal configuration

Alexander Dorn debao84 at googlemail.com
Sat Aug 21 19:22:09 CEST 2010


Hi,

I found a solution using a userfunc but I don't.

CoolUriConf

<uriparts>
	<part>
		<parameter>tx_cal_controller[view]</parameter>
		<!-- creates the instance and sets the current view -->
		<userfunc>user_cooluriCal->createInstance</userfunc>
	</part>
	<part>
		<parameter>tx_cal_controller[uid]</parameter>
		<userfunc>user_cooluriCal->getCalTitleByUid</userfunc>
		<t3conv>1</t3conv>
		<translatetoif>
			<match>^[0-9]+$</match>
		</translatetoif>
	</part>
</uriparts>

The class handling the uris:

class user_cooluriCal	{
	var $view = '';
	static private $instance;
	static function createInstance($config, $value) {
		 if (null === self::$instance) {
			self::$instance = new self;
		}
		self::$instance->view = $value;
		// return false to make parameter tx_cal_controller[view] disappear
		switch($value) {
			case 'event' :
				return 'veranstaltung';
				break;
			case 'location' :
				return 'schulansicht';
				break;
			case 'week' :
				return 'wochenansicht';
				break;
		}
	}
	
	function getCalTitleByUid($config, $value) {
		switch(self::$instance->view) {
			case 'event' :
				return self::$instance->getEventTitle($value);
				break;
			case 'location' :
				return self::$instance->getLocationName($value);
				break;
			default:
				return '';
				break;
		}
	}
	
	function getEventTitle($uid) {
		$db = &$GLOBALS['TYPO3_DB'];
		$query = 'SELECT title FROM tx_cal_event WHERE uid = '.intval($uid);
		$res = $db->sql_query($query);
		if($res) {
			$row = $db->sql_fetch_assoc($res);
		}
		return self::$instance->prepareUrlString($uid.'-'.$row['title']);
	}
	
	function getLocationName($uid) {
		$db = &$GLOBALS['TYPO3_DB'];
		$query = 'SELECT name FROM tx_cal_location WHERE uid = '.intval($uid);
		$res = $db->sql_query($query);
		if($res) {
			$row = $db->sql_fetch_assoc($res);
		}
		return self::$instance->prepareUrlString($row['name']);
	}
	
	function prepareUrlString($string) {
		$search = array('ä','ö','ü', 'ß', ' ');
		$replace = array('ae', 'oe', 'ue', 'ss', '-');
		$string = str_replace($search, $replace, $string);
	
		$search2 = array('\'','"');
		$string= str_replace($search2, '', $string);
		
		return rawurlencode($string);
	}
}

Maybe there are t3-api functions for e.g. prepareUrlString(). please tell me if there are any.

This is probably no solution for high load environments, but maybe it helps someone who had the same problem with cal and cooluri.

Alexander


Am 20.08.2010 um 09:09 schrieb Jan Bednarik:

> Hi,
> 
>> When tx_cal_controller[view] = event, the uid refers to the entry in table tx_cal_event.
>> On the other hand when tx_cal_controller[view] = location the uid refers to table tx_cal_location.
> 
> that's not good. I don't think you can create a SQL query that would do that. The only way is to write your own userFunc for this parameter.
> 
> Regards
> 
> -- 
> Jan Bednarik
> www.bednarik.org - web about TYPO3 in czech
> _______________________________________________
> TYPO3-english mailing list
> TYPO3-english at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english



More information about the TYPO3-english mailing list