File: SpotNotificationTemplate.php

package info (click to toggle)
spotweb 20130826%2Bdfsg2-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,132 kB
  • ctags: 11,281
  • sloc: php: 31,367; xml: 1,009; sh: 148; makefile: 83
file content (49 lines) | stat: -rwxr-xr-x 1,457 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php

class SpotNotificationTemplate {
	protected $_db;
	protected $_settings;
	protected $_currentSession;
	protected $_spotSec;
	
	function __construct(SpotDb $db, SpotSettings $settings, $currentSession) {
		$this->_db = $db;
		$this->_settings = $settings;
		$this->_currentSession = $currentSession;
		$this->_spotSec = $currentSession['security'];
	} # ctor

	/*
	 * Vraagt de inhoud van de template op
	 */
	function template($tpl, $params = array()) {
		SpotTiming::start(__FUNCTION__ . ':notifications:' . $tpl);
		
		extract($params, EXTR_REFS);
		$settings = $this->_settings;
		
		# We maken een aantal variabelen / objecten standaard beschikbaar in de template.
		$currentSession = $this->_currentSession;
		$spotSec = $this->_currentSession['security'];

		# start output buffering
		ob_start(); 
		
		# en we spelen de template af
		require 'templates/notifications/' . $tpl . '.inc.php';
		
		# nu vraag de inhoud van de output buffer op
		$notificationContent = ob_get_contents();
        ob_end_clean();	
		
		# de eerste regel is het onderwerp, de tweede regel is een spatie, 
		# en de rest is daadwerkelijke buffer
		$notificationArray = explode("\n", $notificationContent);
		
		SpotTiming::stop(__FUNCTION__ . ':notifications:' . $tpl, array($params));
		
		return array('title' => $notificationArray[0],
					 'body' => array_slice($notificationArray, 2));
	} # template
	
} # class