Subversion-Projekte lars-tiefland.ci

Revision

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

Revision Autor Zeilennr. Zeile
46 lars 1
<?php
1 lars 2
 
46 lars 3
if (!defined('BASEPATH'))
4
{
5
	exit('No direct script access allowed');
6
}
1 lars 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
 */
46 lars 16
require_once (APPPATH.'/third_party/smarty/libs/Smarty.class.php');
1 lars 17
 
46 lars 18
class Smartie extends Smarty
19
{
1 lars 20
 
46 lars 21
	var $debug = false;
1 lars 22
 
46 lars 23
	function __construct()
24
	{
25
		parent::__construct();
1 lars 26
 
46 lars 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
		}
1 lars 34
 
46 lars 35
		// Uncomment these 2 lines to change Smarty's delimiters
36
		// $this->left_delimiter = '{{';
37
		// $this->right_delimiter = '}}';
1 lars 38
 
46 lars 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
320 lars 42
		$this->assign('ini', $GLOBALS['INI']);
261 lars 43
		if (USE_SMARTY_PAGINATE === true)
255 lars 44
		{
259 lars 45
			require_once "smarty/libs/SmartyPaginate.class.php";
258 lars 46
			if ($GLOBALS["INI"]["Paginate"]["limits"])
255 lars 47
			{
258 lars 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
			{
255 lars 70
				$limit = 20;
71
				if ($GLOBALS["INI"]["Paginate"]["default_limit"])
72
				{
73
					$limit = $GLOBALS["INI"]["Paginate"]["default_limit"];
74
				}
75
			}
258 lars 76
			if ($limit)
255 lars 77
			{
258 lars 78
				$_SESSION["Paginate"]["limit"] = $limit;
255 lars 79
			}
258 lars 80
			if (!$_GET["start"])
255 lars 81
			{
258 lars 82
				SmartyPaginate::reset();
255 lars 83
			}
84
		}
46 lars 85
		log_message('debug', "Smarty Class Initialized");
86
	}
1 lars 87
 
46 lars 88
	function setDebug($debug = true)
89
	{
90
		$this->debug = $debug;
91
	}
1 lars 92
 
46 lars 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;
1 lars 118
 
46 lars 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
	}
1 lars 142
}
143
// END Smartie Class