Skip to content
This repository
Newer
Older
100644 736 lines (623 sloc) 17.029 kb
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
1 <?php
2 /**
0a72863a » LouisLandry
2011-03-20 Fixing file headers for both unit test and library files.
3 * @package Joomla.Platform
4 *
5 * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
6 * @license GNU General Public License version 2 or later; see LICENSE
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
7 */
8
89e3d3a3 » LouisLandry
2011-02-08 Fixed up file headers.
9 defined('JPATH_PLATFORM') or die;
1d7b3af5 » eddieajau
2009-10-24 # Fixed [#18366] [patch] for tracker item [#18079] defined or die; m…
10
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
11 /**
12 * Joomla Framework Factory class
13 *
89e3d3a3 » LouisLandry
2011-02-08 Fixed up file headers.
14 * @package Joomla.Platform
77893649 » LouisLandry
2011-03-20 Fix up remaining @since tags referencing CMS versions to point to the…
15 * @since 11.1
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
16 */
17 abstract class JFactory
18 {
19 public static $application = null;
4e562e1f » Hackwar
2010-04-27 # Small performance improvements ot JRegistry, JFactory::getCache()
20 public static $cache = null;
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
21 public static $config = null;
22 public static $session = null;
23 public static $language = null;
24 public static $document = null;
25 public static $acl = null;
26 public static $database = null;
27 public static $mailer = null;
28
29 /**
30 * Get a application object
31 *
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
32 * Returns the global {@link JApplication} object, only creating it
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
33 * if it doesn't already exist.
34 *
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
35 * @param mixed $id A client identifier or name.
36 * @param array $config An optional associative array of configuration settings.
37 * @param string $prefix application prefix
4924fd25 » elinw
2011-04-20 user,utilities,base files, clean up places
38 *
39 * @see JApplication
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
40 *
41 * @return JApplication object
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
42 */
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
43 public static function getApplication($id = null, $config = array(), $prefix='J')
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
44 {
91ef3ea5 » chdemko
2010-06-02 Fixed issue [#12757] JDate override problem in Backend
45 if (!self::$application) {
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
46 jimport('joomla.application.application');
47
48 if (!$id) {
49 JError::raiseError(500, 'Application Instantiation Error');
50 }
51
91ef3ea5 » chdemko
2010-06-02 Fixed issue [#12757] JDate override problem in Backend
52 self::$application = JApplication::getInstance($id, $config, $prefix);
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
53 }
54
91ef3ea5 » chdemko
2010-06-02 Fixed issue [#12757] JDate override problem in Backend
55 return self::$application;
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
56 }
57
58 /**
59 * Get a configuration object
60 *
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
61 * Returns the global {@link JRegistry} object, only creating it
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
62 * if it doesn't already exist.
63 *
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
64 * @param string $file The path to the configuration file
65 * @param string $type The type of the configuration file
4924fd25 » elinw
2011-04-20 user,utilities,base files, clean up places
66 *
67 * @see JRegistry
68 *
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
69 * @return JRegistry object
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
70 */
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
71 public static function getConfig($file = null, $type = 'PHP')
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
72 {
91ef3ea5 » chdemko
2010-06-02 Fixed issue [#12757] JDate override problem in Backend
73 if (!self::$config) {
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
74 if ($file === null) {
a8606681 » LouisLandry
2011-02-13 Fix up some more @since tags as well as platform configuration file l…
75 $file = JPATH_PLATFORM.'/config.php';
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
76 }
77
91ef3ea5 » chdemko
2010-06-02 Fixed issue [#12757] JDate override problem in Backend
78 self::$config = self::_createConfig($file, $type);
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
79 }
80
91ef3ea5 » chdemko
2010-06-02 Fixed issue [#12757] JDate override problem in Backend
81 return self::$config;
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
82 }
83
84 /**
85 * Get a session object
86 *
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
87 * Returns the global {@link JSession} object, only creating it
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
88 * if it doesn't already exist.
89 *
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
90 * @param array $options An array containing session options
4924fd25 » elinw
2011-04-20 user,utilities,base files, clean up places
91 *
92 * @see JSession
91bc16d6 » eddieajau
2010-06-22 Partial fixes to [#20907] Making Joomla more compliant to PHP strict …
93 *
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
94 * @return JSession object
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
95 */
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
96 public static function getSession($options = array())
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
97 {
91ef3ea5 » chdemko
2010-06-02 Fixed issue [#12757] JDate override problem in Backend
98 if (!self::$session) {
99 self::$session = self::_createSession($options);
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
100 }
101
91ef3ea5 » chdemko
2010-06-02 Fixed issue [#12757] JDate override problem in Backend
102 return self::$session;
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
103 }
104
105 /**
106 * Get a language object
107 *
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
108 * Returns the global {@link JLanguage} object, only creating it
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
109 * if it doesn't already exist.
4924fd25 » elinw
2011-04-20 user,utilities,base files, clean up places
110 *
111 * @see JLanguage
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
112 *
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
113 * @return JLanguage object
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
114 */
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
115 public static function getLanguage()
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
116 {
91ef3ea5 » chdemko
2010-06-02 Fixed issue [#12757] JDate override problem in Backend
117 if (!self::$language) {
118 self::$language = self::_createLanguage();
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
119 }
120
91ef3ea5 » chdemko
2010-06-02 Fixed issue [#12757] JDate override problem in Backend
121 return self::$language;
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
122 }
123
124 /**
125 * Get a document object
126 *
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
127 * Returns the global {@link JDocument} object, only creating it
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
128 * if it doesn't already exist.
129 *
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
130 * @return JDocument object
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
131 */
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
132 public static function getDocument()
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
133 {
91ef3ea5 » chdemko
2010-06-02 Fixed issue [#12757] JDate override problem in Backend
134 if (!self::$document) {
135 self::$document = self::_createDocument();
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
136 }
137
91ef3ea5 » chdemko
2010-06-02 Fixed issue [#12757] JDate override problem in Backend
138 return self::$document;
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
139 }
140
141 /**
142 * Get an user object
143 *
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
144 * Returns the global {@link JUser} object, only creating it
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
145 * if it doesn't already exist.
146 *
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
147 * @param int $id The user to load - Can be an integer or string - If string, it is converted to ID automatically.
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
148 *
4924fd25 » elinw
2011-04-20 user,utilities,base files, clean up places
149 * @see JUser
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
150 * @return JUser object
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
151 */
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
152 public static function getUser($id = null)
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
153 {
154 jimport('joomla.user.user');
155
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
156 if (is_null($id)) {
91ef3ea5 » chdemko
2010-06-02 Fixed issue [#12757] JDate override problem in Backend
157 $instance = self::getSession()->get('user');
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
158 if (!($instance instanceof JUser)) {
aa5891a8 » eddieajau
2010-06-23 Fixed issue [#20907] Making Joomla more compliant to PHP strict standard
159 $instance = JUser::getInstance();
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
160 }
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
161 }
162 else {
aa5891a8 » eddieajau
2010-06-23 Fixed issue [#20907] Making Joomla more compliant to PHP strict standard
163 $instance = JUser::getInstance($id);
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
164 }
165
166 return $instance;
167 }
168
169 /**
170 * Get a cache object
171 *
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
172 * Returns the global {@link JCache} object
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
173 *
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
174 * @param string $group The cache group name
175 * @param string $handler The handler to use
176 * @param string $storage The storage method
4924fd25 » elinw
2011-04-20 user,utilities,base files, clean up places
177 *
178 * @see JCache
91bc16d6 » eddieajau
2010-06-22 Partial fixes to [#20907] Making Joomla more compliant to PHP strict …
179 *
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
180 * @return JCache object
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
181 */
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
182 public static function getCache($group = '', $handler = 'callback', $storage = null)
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
183 {
4e562e1f » Hackwar
2010-04-27 # Small performance improvements ot JRegistry, JFactory::getCache()
184 $hash = md5($group.$handler.$storage);
91ef3ea5 » chdemko
2010-06-02 Fixed issue [#12757] JDate override problem in Backend
185 if (isset(self::$cache[$hash])) {
186 return self::$cache[$hash];
4e562e1f » Hackwar
2010-04-27 # Small performance improvements ot JRegistry, JFactory::getCache()
187 }
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
188 $handler = ($handler == 'function') ? 'callback' : $handler;
189
91bc16d6 » eddieajau
2010-06-22 Partial fixes to [#20907] Making Joomla more compliant to PHP strict …
190 $conf = self::getConfig();
a83e1197 » LouisLandry
2010-04-21 Cleaning out trailing whitespace.
191
c9b95868 » Hackwar
2010-04-10 ^+# Implemented a new caching and implemented it in all frontendcompo…
192 $options = array('defaultgroup' => $group );
a83e1197 » LouisLandry
2010-04-21 Cleaning out trailing whitespace.
193
c9b95868 » Hackwar
2010-04-10 ^+# Implemented a new caching and implemented it in all frontendcompo…
194 if (isset($storage)) {
4a7b43ba » Jean-Marie Simonet
2010-07-03 # [#20796] Joomla! caches ALL HTML in 1 file. Thanks Klas.
195 $options['storage'] = $storage;
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
196 }
a83e1197 » LouisLandry
2010-04-21 Cleaning out trailing whitespace.
197
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
198 jimport('joomla.cache.cache');
199
91bc16d6 » eddieajau
2010-06-22 Partial fixes to [#20907] Making Joomla more compliant to PHP strict …
200 $cache = JCache::getInstance($handler, $options);
c6c4a014 » eddieajau
2010-05-04 Trim trailing white space.
201
91ef3ea5 » chdemko
2010-06-02 Fixed issue [#12757] JDate override problem in Backend
202 self::$cache[$hash] = $cache;
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
203
91ef3ea5 » chdemko
2010-06-02 Fixed issue [#12757] JDate override problem in Backend
204 return self::$cache[$hash];
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
205 }
206
207 /**
208 * Get an authorization object
209 *
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
210 * Returns the global {@link JACL} object, only creating it
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
211 * if it doesn't already exist.
212 *
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
213 * @return JACL object
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
214 */
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
215 public static function getACL()
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
216 {
91ef3ea5 » chdemko
2010-06-02 Fixed issue [#12757] JDate override problem in Backend
217 if (!self::$acl) {
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
218 jimport('joomla.access.access');
91ef3ea5 » chdemko
2010-06-02 Fixed issue [#12757] JDate override problem in Backend
219 self::$acl = new JAccess();
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
220 }
221
91ef3ea5 » chdemko
2010-06-02 Fixed issue [#12757] JDate override problem in Backend
222 return self::$acl;
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
223 }
224
225 /**
226 * Get a database object
227 *
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
228 * Returns the global {@link JDatabase} object, only creating it
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
229 * if it doesn't already exist.
230 *
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
231 * @return JDatabase object
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
232 */
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
233 public static function getDbo()
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
234 {
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
235 if (!self::$database) {
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
236 //get the debug configuration setting
91bc16d6 » eddieajau
2010-06-22 Partial fixes to [#20907] Making Joomla more compliant to PHP strict …
237 $conf = self::getConfig();
238 $debug = $conf->get('debug');
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
239
5fd474c1 » Gergo Erdosi
2009-09-13 Various E-Strict validation fixes.
240 self::$database = self::_createDbo();
241 self::$database->debug($debug);
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
242 }
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
243
5fd474c1 » Gergo Erdosi
2009-09-13 Various E-Strict validation fixes.
244 return self::$database;
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
245 }
246
247 /**
248 * Get a mailer object
249 *
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
250 * Returns the global {@link JMail} object, only creating it
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
251 * if it doesn't already exist
4924fd25 » elinw
2011-04-20 user,utilities,base files, clean up places
252 *
253 * @see JMail
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
254 *
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
255 * @return JMail object
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
256 */
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
257 public static function getMailer()
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
258 {
91ef3ea5 » chdemko
2010-06-02 Fixed issue [#12757] JDate override problem in Backend
259 if (!self::$mailer) {
260 self::$mailer = self::_createMailer();
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
261 }
91ef3ea5 » chdemko
2010-06-02 Fixed issue [#12757] JDate override problem in Backend
262 $copy = clone self::$mailer;
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
263
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
264 return $copy;
265 }
266
267 /**
268 * Get a parsed XML Feed Source
269 *
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
270 * @param string $url url for feed source
271 * @param int $cache_time time to cache feed for (using internal cache mechanism)
91bc16d6 » eddieajau
2010-06-22 Partial fixes to [#20907] Making Joomla more compliant to PHP strict …
272 *
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
273 * @return mixed SimplePie parsed object on success, false on failure
77893649 » LouisLandry
2011-03-20 Fix up remaining @since tags referencing CMS versions to point to the…
274 * @since: 11.1
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
275 */
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
276 public static function getFeedParser($url, $cache_time = 0)
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
277 {
278 jimport('simplepie.simplepie');
a83e1197 » LouisLandry
2010-04-21 Cleaning out trailing whitespace.
279
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
280 $cache = self::getCache('feed_parser', 'callback');
a83e1197 » LouisLandry
2010-04-21 Cleaning out trailing whitespace.
281
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
282 if ($cache_time > 0) {
283 $cache->setLifeTime($cache_time);
284 }
a83e1197 » LouisLandry
2010-04-21 Cleaning out trailing whitespace.
285
c9b95868 » Hackwar
2010-04-10 ^+# Implemented a new caching and implemented it in all frontendcompo…
286 $simplepie = new SimplePie(null, null, 0);
a83e1197 » LouisLandry
2010-04-21 Cleaning out trailing whitespace.
287
c9b95868 » Hackwar
2010-04-10 ^+# Implemented a new caching and implemented it in all frontendcompo…
288 $simplepie->enable_cache(false);
289 $simplepie->set_feed_url($url);
bb42c438 » Hackwar
2009-12-29 # refactored TinyMCE - thanks Jean-Marie
290 $simplepie->force_feed(true);
a83e1197 » LouisLandry
2010-04-21 Cleaning out trailing whitespace.
291
c9b95868 » Hackwar
2010-04-10 ^+# Implemented a new caching and implemented it in all frontendcompo…
292 $contents = $cache->get(array($simplepie, 'init'), null, false, false);
a83e1197 » LouisLandry
2010-04-21 Cleaning out trailing whitespace.
293
c9b95868 » Hackwar
2010-04-10 ^+# Implemented a new caching and implemented it in all frontendcompo…
294 if ($contents) {
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
295 return $simplepie;
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
296 }
297 else {
00c0cc95 » Jean-Marie Simonet
2010-04-25 $ Completed libraries/J ini/keys refactoring
298 JError::raiseWarning('SOME_ERROR_CODE', JText::_('JLIB_UTIL_ERROR_LOADING_FEED_DATA'));
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
299 }
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
300
301 return false;
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
302 }
303
304 /**
305 * Get an XML document
306 *
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
307 * @param string $type The type of xml parser needed 'DOM', 'RSS' or 'Simple'
308 * @param array $options ['rssUrl'] the rss url to parse when using "RSS", ['cache_time'] with 'RSS' - feed cache time. If not defined defaults to 3600 sec
309 *
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
310 * @return object Parsed XML document object
311 * @deprecated
312 */
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
313 public static function getXMLParser($type = '', $options = array())
9d3bd0a1 » Hackwar
2010-01-13 ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML fil…
314 {
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
315 $doc = null;
316
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
317 switch (strtolower($type))
318 {
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
319 case 'rss' :
320 case 'atom' :
416c722c » LouisLandry
2010-03-25 Merging JForm branch down to trunk.
321 $cache_time = isset($options['cache_time']) ? $options['cache_time'] : 0;
91ef3ea5 » chdemko
2010-06-02 Fixed issue [#12757] JDate override problem in Backend
322 $doc = self::getFeedParser($options['rssUrl'], $cache_time);
416c722c » LouisLandry
2010-03-25 Merging JForm branch down to trunk.
323 break;
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
324
325 case 'simple':
91ef3ea5 » chdemko
2010-06-02 Fixed issue [#12757] JDate override problem in Backend
326 // JError::raiseWarning('SOME_ERROR_CODE', 'JSimpleXML is deprecated. Use self::getXML instead');
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
327 jimport('joomla.utilities.simplexml');
328 $doc = new JSimpleXML();
329 break;
330
331 case 'dom':
00c0cc95 » Jean-Marie Simonet
2010-04-25 $ Completed libraries/J ini/keys refactoring
332 JError::raiseWarning('SOME_ERROR_CODE', JText::_('JLIB_UTIL_ERROR_DOMIT'));
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
333 $doc = null;
334 break;
335
336 default :
337 $doc = null;
338 }
339
340 return $doc;
341 }
342
343 /**
9d3bd0a1 » Hackwar
2010-01-13 ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML fil…
344 * Reads a XML file.
345 *
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
346 * @param string $data Full path and file name.
9d3bd0a1 » Hackwar
2010-01-13 ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML fil…
347 * @param boolean $isFile true to load a file | false to load a string.
348 *
349 * @return mixed JXMLElement on success | false on error.
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
350 * @todo This may go in a separate class - error reporting may be improved.
9d3bd0a1 » Hackwar
2010-01-13 ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML fil…
351 */
3082dc27 » LouisLandry
2010-01-26 Fixed [#19552] [patch] Error loading xml from string in JFactory::get…
352 public static function getXML($data, $isFile = true)
9d3bd0a1 » Hackwar
2010-01-13 ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML fil…
353 {
354 jimport('joomla.utilities.xmlelement');
355
356 // Disable libxml errors and allow to fetch error information as needed
357 libxml_use_internal_errors(true);
358
416c722c » LouisLandry
2010-03-25 Merging JForm branch down to trunk.
359 if ($isFile) {
9d3bd0a1 » Hackwar
2010-01-13 ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML fil…
360 // Try to load the xml file
3082dc27 » LouisLandry
2010-01-26 Fixed [#19552] [patch] Error loading xml from string in JFactory::get…
361 $xml = simplexml_load_file($data, 'JXMLElement');
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
362 }
363 else {
9d3bd0a1 » Hackwar
2010-01-13 ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML fil…
364 // Try to load the xml string
365 $xml = simplexml_load_string($data, 'JXMLElement');
366 }
367
416c722c » LouisLandry
2010-03-25 Merging JForm branch down to trunk.
368 if (empty($xml)) {
9d3bd0a1 » Hackwar
2010-01-13 ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML fil…
369 // There was an error
00c0cc95 » Jean-Marie Simonet
2010-04-25 $ Completed libraries/J ini/keys refactoring
370 JError::raiseWarning(100, JText::_('JLIB_UTIL_ERROR_XML_LOAD'));
9d3bd0a1 » Hackwar
2010-01-13 ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML fil…
371
416c722c » LouisLandry
2010-03-25 Merging JForm branch down to trunk.
372 if ($isFile) {
3082dc27 » LouisLandry
2010-01-26 Fixed [#19552] [patch] Error loading xml from string in JFactory::get…
373 JError::raiseWarning(100, $data);
9d3bd0a1 » Hackwar
2010-01-13 ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML fil…
374 }
375
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
376 foreach (libxml_get_errors() as $error)
377 {
9d3bd0a1 » Hackwar
2010-01-13 ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML fil…
378 JError::raiseWarning(100, 'XML: '.$error->message);
379 }
380 }
381
382 return $xml ;
383 }
384
385 /**
386 * Get an editor object
387 *
388 * @param string $editor The editor to load, depends on the editor plugins that are installed
91bc16d6 » eddieajau
2010-06-22 Partial fixes to [#20907] Making Joomla more compliant to PHP strict …
389 *
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
390 * @return JEditor object
9d3bd0a1 » Hackwar
2010-01-13 ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML fil…
391 */
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
392 public static function getEditor($editor = null)
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
393 {
394 jimport('joomla.html.editor');
395
396 //get the editor configuration setting
416c722c » LouisLandry
2010-03-25 Merging JForm branch down to trunk.
397 if (is_null($editor)) {
91bc16d6 » eddieajau
2010-06-22 Partial fixes to [#20907] Making Joomla more compliant to PHP strict …
398 $conf = self::getConfig();
399 $editor = $conf->get('editor');
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
400 }
401
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
402 return JEditor::getInstance($editor);
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
403 }
404
405 /**
406 * Return a reference to the {@link JURI} object
407 *
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
408 * @param string $uri uri name
4924fd25 » elinw
2011-04-20 user,utilities,base files, clean up places
409 *
410 * @see JURI
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
411 *
412 * @return JURI object
a8606681 » LouisLandry
2011-02-13 Fix up some more @since tags as well as platform configuration file l…
413 * @since 11.1
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
414 */
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
415 public static function getURI($uri = 'SERVER')
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
416 {
417 jimport('joomla.environment.uri');
418
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
419 return JURI::getInstance($uri);
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
420 }
421
422 /**
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
423 * Return the {@link JDate} object
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
424 *
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
425 * @param mixed $time The initial time for the JDate object
a8fb3f98 » LouisLandry
2009-10-28 Merge down from datetime branch. Improvements include new date class …
426 * @param mixed $tzOffset The timezone offset.
4924fd25 » elinw
2011-04-20 user,utilities,base files, clean up places
427 *
428 * @see JDate
91bc16d6 » eddieajau
2010-06-22 Partial fixes to [#20907] Making Joomla more compliant to PHP strict …
429 *
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
430 * @return JDate object
a8606681 » LouisLandry
2011-02-13 Fix up some more @since tags as well as platform configuration file l…
431 * @since 11.1
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
432 */
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
433 public static function getDate($time = 'now', $tzOffset = null)
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
434 {
435 jimport('joomla.utilities.date');
436 static $instances;
437 static $classname;
438 static $mainLocale;
439
440 if (!isset($instances)) {
441 $instances = array();
442 }
443
91bc16d6 » eddieajau
2010-06-22 Partial fixes to [#20907] Making Joomla more compliant to PHP strict …
444 $language = self::getLanguage();
445 $locale = $language->getTag();
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
446
447 if (!isset($classname) || $locale != $mainLocale) {
448 //Store the locale for future reference
449 $mainLocale = $locale;
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
450
91ef3ea5 » chdemko
2010-06-02 Fixed issue [#12757] JDate override problem in Backend
451 if ($mainLocale !== false) {
452 $classname = str_replace('-', '_', $mainLocale).'Date';
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
453
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
454 if (!class_exists($classname)) {
91ef3ea5 » chdemko
2010-06-02 Fixed issue [#12757] JDate override problem in Backend
455 //The class does not exist, default to JDate
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
456 $classname = 'JDate';
457 }
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
458 }
459 else {
91ef3ea5 » chdemko
2010-06-02 Fixed issue [#12757] JDate override problem in Backend
460 //No tag, so default to JDate
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
461 $classname = 'JDate';
462 }
463 }
464 $key = $time . '-' . $tzOffset;
465
9d3bd0a1 » Hackwar
2010-01-13 ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML fil…
466 // if (!isset($instances[$classname][$key])) {
467 $tmp = new $classname($time, $tzOffset);
468 //We need to serialize to break the reference
469 // $instances[$classname][$key] = serialize($tmp);
470 // unset($tmp);
471 // }
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
472
9d3bd0a1 » Hackwar
2010-01-13 ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML fil…
473 // $date = unserialize($instances[$classname][$key]);
474 // return $date;
a8fb3f98 » LouisLandry
2009-10-28 Merge down from datetime branch. Improvements include new date class …
475 return $tmp;
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
476 }
477
478
479
480 /**
481 * Create a configuration object
482 *
a8606681 » LouisLandry
2011-02-13 Fix up some more @since tags as well as platform configuration file l…
483 * @param string $file The path to the configuration file.
484 * @param string $type The type of the configuration file.
485 * @param string $namespace The namespace of the configuration file.
91bc16d6 » eddieajau
2010-06-22 Partial fixes to [#20907] Making Joomla more compliant to PHP strict …
486 *
a8606681 » LouisLandry
2011-02-13 Fix up some more @since tags as well as platform configuration file l…
487 * @return JRegistry
488 *
489 * @since 11.1
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
490 */
a8606681 » LouisLandry
2011-02-13 Fix up some more @since tags as well as platform configuration file l…
491 private static function _createConfig($file, $type = 'PHP', $namespace = '')
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
492 {
493 jimport('joomla.registry.registry');
494
67bf9c7a » LouisLandry
2011-02-13 Fixing up unit testing errors.
495 if (is_file($file)) {
496 include_once $file;
497 }
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
498
499 // Create the registry with a default namespace of config
4e562e1f » Hackwar
2010-04-27 # Small performance improvements ot JRegistry, JFactory::getCache()
500 $registry = new JRegistry();
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
501
a8606681 » LouisLandry
2011-02-13 Fix up some more @since tags as well as platform configuration file l…
502 // Sanitize the namespace.
503 $namespace = ucfirst((string) preg_replace('/[^A-Z_]/i', '', $namespace));
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
504
a8606681 » LouisLandry
2011-02-13 Fix up some more @since tags as well as platform configuration file l…
505 // Build the config name.
506 $name = 'JConfig'.$namespace;
507
508 // Handle the PHP configuration type.
509 if ($type == 'PHP' && class_exists($name)) {
510 // Create the JConfig object
511 $config = new $name();
512
513 // Load the configuration values into the registry
514 $registry->loadObject($config);
515 }
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
516
517 return $registry;
518 }
519
520 /**
521 * Create a session object
522 *
523 * @param array $options An array containing session options
91bc16d6 » eddieajau
2010-06-22 Partial fixes to [#20907] Making Joomla more compliant to PHP strict …
524 *
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
525 * @return JSession object
a8606681 » LouisLandry
2011-02-13 Fix up some more @since tags as well as platform configuration file l…
526 * @since 11.1
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
527 */
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
528 private static function _createSession($options = array())
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
529 {
530 jimport('joomla.session.session');
531
4924fd25 » elinw
2011-04-20 user,utilities,base files, clean up places
532 // Get the editor configuration setting
91bc16d6 » eddieajau
2010-06-22 Partial fixes to [#20907] Making Joomla more compliant to PHP strict …
533 $conf = self::getConfig();
534 $handler = $conf->get('session_handler', 'none');
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
535
4924fd25 » elinw
2011-04-20 user,utilities,base files, clean up places
536 // Config time is in minutes
416c722c » LouisLandry
2010-03-25 Merging JForm branch down to trunk.
537 $options['expire'] = ($conf->get('lifetime')) ? $conf->get('lifetime') * 60 : 900;
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
538
539 $session = JSession::getInstance($handler, $options);
540 if ($session->getState() == 'expired') {
541 $session->restart();
542 }
543
544 return $session;
545 }
546
547 /**
548 * Create an database object
549 *
4924fd25 » elinw
2011-04-20 user,utilities,base files, clean up places
550 * @see JDatabase
551 *
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
552 * @return JDatabase object
91bc16d6 » eddieajau
2010-06-22 Partial fixes to [#20907] Making Joomla more compliant to PHP strict …
553 *
a8606681 » LouisLandry
2011-02-13 Fix up some more @since tags as well as platform configuration file l…
554 * @since 11.1
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
555 */
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
556 private static function _createDbo()
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
557 {
558 jimport('joomla.database.database');
559 jimport('joomla.database.table');
560
91bc16d6 » eddieajau
2010-06-22 Partial fixes to [#20907] Making Joomla more compliant to PHP strict …
561 $conf = self::getConfig();
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
562
416c722c » LouisLandry
2010-03-25 Merging JForm branch down to trunk.
563 $host = $conf->get('host');
564 $user = $conf->get('user');
565 $password = $conf->get('password');
566 $database = $conf->get('db');
69ba2543 » eddieajau
2010-07-22 Fixed issue [#21436] Database Error should return "500 Internal Serve…
567 $prefix = $conf->get('dbprefix');
568 $driver = $conf->get('dbtype');
416c722c » LouisLandry
2010-03-25 Merging JForm branch down to trunk.
569 $debug = $conf->get('debug');
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
570
571 $options = array ('driver' => $driver, 'host' => $host, 'user' => $user, 'password' => $password, 'database' => $database, 'prefix' => $prefix);
572
91bc16d6 » eddieajau
2010-06-22 Partial fixes to [#20907] Making Joomla more compliant to PHP strict …
573 $db = JDatabase::getInstance($options);
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
574
575 if (JError::isError($db)) {
69ba2543 » eddieajau
2010-07-22 Fixed issue [#21436] Database Error should return "500 Internal Serve…
576 header('HTTP/1.1 500 Internal Server Error');
577 jexit('Database Error: ' . (string) $db);
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
578 }
579
580 if ($db->getErrorNum() > 0) {
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
581 JError::raiseError(500, JText::sprintf('JLIB_UTIL_ERROR_CONNECT_DATABASE', $db->getErrorNum(), $db->getErrorMsg()));
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
582 }
583
584 $db->debug($debug);
585 return $db;
586 }
587
588 /**
589 * Create a mailer object
590 *
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
591 * @return JMail object
77893649 » LouisLandry
2011-03-20 Fix up remaining @since tags referencing CMS versions to point to the…
592 * @since 11.1
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
593 */
8bf55190 » eddieajau
2011-01-10 Fixed issue [#24153] More PHP strict fixes (mostly backend) (Rouven W…
594 private static function _createMailer()
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
595 {
596 jimport('joomla.mail.mail');
597
91bc16d6 » eddieajau
2010-06-22 Partial fixes to [#20907] Making Joomla more compliant to PHP strict …
598 $conf = self::getConfig();
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
599
416c722c » LouisLandry
2010-03-25 Merging JForm branch down to trunk.
600 $sendmail = $conf->get('sendmail');
384ccad8 » Jean-Marie Simonet
2010-08-20 # [#21906] SMTP without authentication not working. Thanks Roland an…
601 $smtpauth = ($conf->get('smtpauth') == 0) ? null : 1;
416c722c » LouisLandry
2010-03-25 Merging JForm branch down to trunk.
602 $smtpuser = $conf->get('smtpuser');
603 $smtppass = $conf->get('smtppass');
604 $smtphost = $conf->get('smtphost');
605 $smtpsecure = $conf->get('smtpsecure');
606 $smtpport = $conf->get('smtpport');
607 $mailfrom = $conf->get('mailfrom');
608 $fromname = $conf->get('fromname');
609 $mailer = $conf->get('mailer');
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
610
611 // Create a JMail object
aa5891a8 » eddieajau
2010-06-23 Fixed issue [#20907] Making Joomla more compliant to PHP strict standard
612 $mail = JMail::getInstance();
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
613
614 // Set default sender
615 $mail->setSender(array ($mailfrom, $fromname));
616
617 // Default mailer is to use PHP's mail function
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
618 switch ($mailer)
619 {
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
620 case 'smtp' :
9b992baf » Hackwar
2009-09-08 Updated PHPMailer to version 2.3
621 $mail->useSMTP($smtpauth, $smtphost, $smtpuser, $smtppass, $smtpsecure, $smtpport);
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
622 break;
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
623
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
624 case 'sendmail' :
625 $mail->IsSendmail();
626 break;
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
627
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
628 default :
629 $mail->IsMail();
630 break;
631 }
632
633 return $mail;
634 }
635
636 /**
637 * Create a language object
638 *
4924fd25 » elinw
2011-04-20 user,utilities,base files, clean up places
639 * @see JLanguage
640 *
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
641 * @return JLanguage object
a8606681 » LouisLandry
2011-02-13 Fix up some more @since tags as well as platform configuration file l…
642 * @since 11.1
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
643 */
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
644 private static function _createLanguage()
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
645 {
646 jimport('joomla.language.language');
647
91bc16d6 » eddieajau
2010-06-22 Partial fixes to [#20907] Making Joomla more compliant to PHP strict …
648 $conf = self::getConfig();
416c722c » LouisLandry
2010-03-25 Merging JForm branch down to trunk.
649 $locale = $conf->get('language');
65a64b8b » Jean-Marie Simonet
2010-03-27 #$^ Enabling parsing language files errors in debug lang mode only (n…
650 $debug = $conf->get('debug_lang');
91bc16d6 » eddieajau
2010-06-22 Partial fixes to [#20907] Making Joomla more compliant to PHP strict …
651 $lang = JLanguage::getInstance($locale, $debug);
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
652
653 return $lang;
654 }
655
656 /**
657 * Create a document object
4924fd25 » elinw
2011-04-20 user,utilities,base files, clean up places
658 *
659 * @see JDocument
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
660 *
91bc16d6 » eddieajau
2010-06-22 Partial fixes to [#20907] Making Joomla more compliant to PHP strict …
661 * @return JDocument object
a8606681 » LouisLandry
2011-02-13 Fix up some more @since tags as well as platform configuration file l…
662 * @since 11.1
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
663 */
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
664 private static function _createDocument()
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
665 {
666 jimport('joomla.document.document');
667
91bc16d6 » eddieajau
2010-06-22 Partial fixes to [#20907] Making Joomla more compliant to PHP strict …
668 $lang = self::getLanguage();
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
669
4924fd25 » elinw
2011-04-20 user,utilities,base files, clean up places
670 // Keep backwards compatibility with Joomla! 1.0
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
671 $raw = JRequest::getBool('no_html');
672 $type = JRequest::getWord('format', $raw ? 'raw' : 'html');
673
674 $attributes = array (
675 'charset' => 'utf-8',
676 'lineend' => 'unix',
677 'tab' => ' ',
678 'language' => $lang->getTag(),
679 'direction' => $lang->isRTL() ? 'rtl' : 'ltr'
680 );
681
8699a0c0 » LouisLandry
2009-12-11 Clean up of reference operators as they aren't needed in PHP5
682 return JDocument::getInstance($type, $attributes);
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
683 }
052ac220 » eddieajau
2009-06-16 Trailing spaces removed
684
e8679fbb » pasamio
2009-06-02 + Added JFactory::getStream
685 /**
686 * Creates a new stream object with appropriate prefix
91bc16d6 » eddieajau
2010-06-22 Partial fixes to [#20907] Making Joomla more compliant to PHP strict …
687 *
688 * @param boolean $use_prefix Prefix the connections for writing
689 * @param boolean $use_network Use network if available for writing; use false to disable (e.g. FTP, SCP)
690 * @param string $ua UA User agent to use
691 * @param boolean $uamask User agent masking (prefix Mozilla)
692 *
4924fd25 » elinw
2011-04-20 user,utilities,base files, clean up places
693 * @see JStream
694 *
91bc16d6 » eddieajau
2010-06-22 Partial fixes to [#20907] Making Joomla more compliant to PHP strict …
695 * @return JStream
23343090 » LouisLandry
2011-02-13 Fixing up @since tags for the platform libraries.
696 * @since 11.1
e8679fbb » pasamio
2009-06-02 + Added JFactory::getStream
697 */
8bf55190 » eddieajau
2011-01-10 Fixed issue [#24153] More PHP strict fixes (mostly backend) (Rouven W…
698 public static function getStream($use_prefix=true, $use_network=true,$ua=null, $uamask=false)
416c722c » LouisLandry
2010-03-25 Merging JForm branch down to trunk.
699 {
e8679fbb » pasamio
2009-06-02 + Added JFactory::getStream
700 jimport('joomla.filesystem.stream');
91bc16d6 » eddieajau
2010-06-22 Partial fixes to [#20907] Making Joomla more compliant to PHP strict …
701
e8679fbb » pasamio
2009-06-02 + Added JFactory::getStream
702 // Setup the context; Joomla! UA and overwrite
8bf55190 » eddieajau
2011-01-10 Fixed issue [#24153] More PHP strict fixes (mostly backend) (Rouven W…
703 $context = array();
704 $version = new JVersion;
e8679fbb » pasamio
2009-06-02 + Added JFactory::getStream
705 // set the UA for HTTP and overwrite for FTP
706 $context['http']['user_agent'] = $version->getUserAgent($ua, $uamask);
052ac220 » eddieajau
2009-06-16 Trailing spaces removed
707 $context['ftp']['overwrite'] = true;
416c722c » LouisLandry
2010-03-25 Merging JForm branch down to trunk.
708
709 if ($use_prefix) {
e8679fbb » pasamio
2009-06-02 + Added JFactory::getStream
710 jimport('joomla.client.helper');
711 $FTPOptions = JClientHelper::getCredentials('ftp');
712 $SCPOptions = JClientHelper::getCredentials('scp');
91bc16d6 » eddieajau
2010-06-22 Partial fixes to [#20907] Making Joomla more compliant to PHP strict …
713
e8679fbb » pasamio
2009-06-02 + Added JFactory::getStream
714 if ($FTPOptions['enabled'] == 1 && $use_network) {
715 $prefix = 'ftp://'. $FTPOptions['user'] .':'. $FTPOptions['pass'] .'@'. $FTPOptions['host'];
716 $prefix .= $FTPOptions['port'] ? ':'. $FTPOptions['port'] : '';
717 $prefix .= $FTPOptions['root'];
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
718 }
719 else if ($SCPOptions['enabled'] == 1 && $use_network) {
e8679fbb » pasamio
2009-06-02 + Added JFactory::getStream
720 $prefix = 'ssh2.sftp://'. $SCPOptions['user'] .':'. $SCPOptions['pass'] .'@'. $SCPOptions['host'];
721 $prefix .= $SCPOptions['port'] ? ':'. $SCPOptions['port'] : '';
722 $prefix .= $SCPOptions['root'];
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
723 }
724 else {
3e5ccad6 » ianmacl
2010-08-26 # [!21949] Reverted systematic elimination of DS as directory separator
725 $prefix = JPATH_ROOT.DS;
e8679fbb » pasamio
2009-06-02 + Added JFactory::getStream
726 }
91bc16d6 » eddieajau
2010-06-22 Partial fixes to [#20907] Making Joomla more compliant to PHP strict …
727
e8679fbb » pasamio
2009-06-02 + Added JFactory::getStream
728 $retval = new JStream($prefix, JPATH_ROOT, $context);
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
729 }
730 else {
1ffd3c18 » ianmacl
2010-05-30 [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
731 $retval = new JStream('', '', $context);
e8679fbb » pasamio
2009-06-02 + Added JFactory::getStream
732 }
91bc16d6 » eddieajau
2010-06-22 Partial fixes to [#20907] Making Joomla more compliant to PHP strict …
733
e8679fbb » pasamio
2009-06-02 + Added JFactory::getStream
734 return $retval;
735 }
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
736 }
Something went wrong with that request. Please try again.