Subversion-Projekte lars-tiefland.ci

Revision

Revision 755 | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1296 lars 1
<?php
2
 
3
if (!defined('BASEPATH'))
4
{
5
	exit('No direct script access allowed');
6
}
7
/**
8
 * Smartie Class
9
 *
10
 * @package        CodeIgniter
11
 * @subpackage     Libraries
12
 * @category       Smarty
13
 * @author         Kepler Gelotte
14
 * @link           http://www.coolphptools.com/codeigniter-smarty
15
 */
16
require_once (APPPATH.'/third_party/smarty/libs/Smarty.class.php');
17
 
18
class Smartie extends Smarty
19
{
20
 
21
	var $debug = false;
22
 
23
	function __construct()
24
	{
25
		parent::__construct();
26
 
27
		$this->template_dir = APPPATH."views/templates/default";
28
		$this->compile_dir = APPPATH."views/templates_c";
29
		if (!is_writable($this->compile_dir))
30
		{
31
			// make sure the compile directory can be written to
32
			@chmod($this->compile_dir, 0777);
33
		}
34
 
35
		// Uncomment these 2 lines to change Smarty's delimiters
36
		// $this->left_delimiter = '{{';
37
		// $this->right_delimiter = '}}';
38
 
39
		$this->assign('FCPATH', FCPATH); // path to website
40
		$this->assign('APPPATH', APPPATH); // path to application directory
41
		$this->assign('BASEPATH', BASEPATH); // path to system directory
42
		$this->assign('ini', $GLOBALS['INI']);
43
		if (USE_SMARTY_PAGINATE === true)
44
		{
45
			require_once "smarty/libs/SmartyPaginate.class.php";
46
			if ($GLOBALS["INI"]["Paginate"]["limits"])
47
			{
48
				$limits = explode(";", $GLOBALS["INI"]["Paginate"]["limits"]);
49
				$GLOBALS["ui"]->assign("limits", $limits);
50
				if (!$_SESSION["Paginate"]["limit"])
51
				{
52
					$limit = 20;
53
					if ($GLOBALS["INI"]["Paginate"]["default_limit"])
54
					{
55
						$limit = $GLOBALS["INI"]["Paginate"]["default_limit"];
56
					}
57
				}
58
				if ($_GET["limit"])
59
				{
60
					$g_limit = weban_utils::clean_get_input("limit", "int");
61
					if (is_int($g_limit) && in_array($g_limit, $limits))
62
					{
63
						$limit = $g_limit;
64
					}
65
				}
66
				$GLOBALS["ui"]->assign("sel_limit", $limit);
67
			}
68
			else
69
			{
70
				$limit = 20;
71
				if ($GLOBALS["INI"]["Paginate"]["default_limit"])
72
				{
73
					$limit = $GLOBALS["INI"]["Paginate"]["default_limit"];
74
				}
75
			}
76
			if ($limit)
77
			{
78
				$_SESSION["Paginate"]["limit"] = $limit;
79
			}
80
			if (!$_GET["start"])
81
			{
82
				SmartyPaginate::reset();
83
			}
84
		}
85
		log_message('debug', "Smarty Class Initialized");
86
	}
87
 
88
	function setDebug($debug = true)
89
	{
90
		$this->debug = $debug;
91
	}
92
 
93
	/**
94
	 *  Parse a template using the Smarty engine
95
	 *
96
	 * This is a convenience method that combines assign() and
97
	 * display() into one step.
98
	 *
99
	 * Values to assign are passed in an associative array of
100
	 * name => value pairs.
101
	 *
102
	 * If the output is to be returned as a string to the caller
103
	 * instead of being output, pass true as the third parameter.
104
	 *
105
	 * @access    public
106
	 * @param    string
107
	 * @param    array
108
	 * @param    bool
109
	 * @return    string
110
	 */
111
	function view($template, $data = array(), $return = false)
112
	{
113
		if (!$this->debug)
114
		{
115
			$this->error_reporting = false;
116
		}
117
		$this->error_unassigned = false;
118
 
119
		foreach ($data as $key => $val)
120
		{
121
			$this->assign($key, $val);
122
		}
123
 
124
		if ($return == false)
125
		{
126
			$CI = &get_instance();
127
			if (method_exists($CI->output, 'set_output'))
128
			{
129
				$CI->output->set_output($this->fetch($template));
130
			}
131
			else
132
			{
133
				$CI->output->final_output = $this->fetch($template);
134
			}
135
			return;
136
		}
137
		else
138
		{
139
			return $this->fetch($template);
140
		}
141
	}
142
}
143
// END Smartie Class