Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 737 lines (623 sloc) 17.029 kb
f73b659 Imported the new trunk.
Rob Schley authored
1 <?php
2 /**
0a72863 Louis Landry Fixing file headers for both unit test and library files.
LouisLandry authored
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
f73b659 Imported the new trunk.
Rob Schley authored
7 */
8
89e3d3a Louis Landry Fixed up file headers.
LouisLandry authored
9 defined('JPATH_PLATFORM') or die;
1d7b3af Andrew Eddie # Fixed [#18366] [patch] for tracker item [#18079] defined or die; miss...
eddieajau authored
10
f73b659 Imported the new trunk.
Rob Schley authored
11 /**
12 * Joomla Framework Factory class
13 *
89e3d3a Louis Landry Fixed up file headers.
LouisLandry authored
14 * @package Joomla.Platform
7789364 Louis Landry Fix up remaining @since tags referencing CMS versions to point to the 11...
LouisLandry authored
15 * @since 11.1
f73b659 Imported the new trunk.
Rob Schley authored
16 */
17 abstract class JFactory
18 {
19 public static $application = null;
4e562e1 Hannes Papenberg # Small performance improvements ot JRegistry, JFactory::getCache()
Hackwar authored
20 public static $cache = null;
f73b659 Imported the new trunk.
Rob Schley authored
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 *
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
32 * Returns the global {@link JApplication} object, only creating it
f73b659 Imported the new trunk.
Rob Schley authored
33 * if it doesn't already exist.
34 *
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
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
4924fd2 elinw user,utilities,base files, clean up places
elinw authored
38 *
39 * @see JApplication
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
40 *
41 * @return JApplication object
f73b659 Imported the new trunk.
Rob Schley authored
42 */
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
43 public static function getApplication($id = null, $config = array(), $prefix='J')
f73b659 Imported the new trunk.
Rob Schley authored
44 {
91ef3ea Christophe Demko Fixed issue [#12757] JDate override problem in Backend
chdemko authored
45 if (!self::$application) {
f73b659 Imported the new trunk.
Rob Schley authored
46 jimport('joomla.application.application');
47
48 if (!$id) {
49 JError::raiseError(500, 'Application Instantiation Error');
50 }
51
91ef3ea Christophe Demko Fixed issue [#12757] JDate override problem in Backend
chdemko authored
52 self::$application = JApplication::getInstance($id, $config, $prefix);
f73b659 Imported the new trunk.
Rob Schley authored
53 }
54
91ef3ea Christophe Demko Fixed issue [#12757] JDate override problem in Backend
chdemko authored
55 return self::$application;
f73b659 Imported the new trunk.
Rob Schley authored
56 }
57
58 /**
59 * Get a configuration object
60 *
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
61 * Returns the global {@link JRegistry} object, only creating it
f73b659 Imported the new trunk.
Rob Schley authored
62 * if it doesn't already exist.
63 *
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
64 * @param string $file The path to the configuration file
65 * @param string $type The type of the configuration file
4924fd2 elinw user,utilities,base files, clean up places
elinw authored
66 *
67 * @see JRegistry
68 *
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
69 * @return JRegistry object
f73b659 Imported the new trunk.
Rob Schley authored
70 */
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
71 public static function getConfig($file = null, $type = 'PHP')
f73b659 Imported the new trunk.
Rob Schley authored
72 {
91ef3ea Christophe Demko Fixed issue [#12757] JDate override problem in Backend
chdemko authored
73 if (!self::$config) {
f73b659 Imported the new trunk.
Rob Schley authored
74 if ($file === null) {
a860668 Louis Landry Fix up some more @since tags as well as platform configuration file load...
LouisLandry authored
75 $file = JPATH_PLATFORM.'/config.php';
f73b659 Imported the new trunk.
Rob Schley authored
76 }
77
91ef3ea Christophe Demko Fixed issue [#12757] JDate override problem in Backend
chdemko authored
78 self::$config = self::_createConfig($file, $type);
f73b659 Imported the new trunk.
Rob Schley authored
79 }
80
91ef3ea Christophe Demko Fixed issue [#12757] JDate override problem in Backend
chdemko authored
81 return self::$config;
f73b659 Imported the new trunk.
Rob Schley authored
82 }
83
84 /**
85 * Get a session object
86 *
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
87 * Returns the global {@link JSession} object, only creating it
f73b659 Imported the new trunk.
Rob Schley authored
88 * if it doesn't already exist.
89 *
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
90 * @param array $options An array containing session options
4924fd2 elinw user,utilities,base files, clean up places
elinw authored
91 *
92 * @see JSession
91bc16d Andrew Eddie Partial fixes to [#20907] Making Joomla more compliant to PHP strict sta...
eddieajau authored
93 *
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
94 * @return JSession object
f73b659 Imported the new trunk.
Rob Schley authored
95 */
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
96 public static function getSession($options = array())
f73b659 Imported the new trunk.
Rob Schley authored
97 {
91ef3ea Christophe Demko Fixed issue [#12757] JDate override problem in Backend
chdemko authored
98 if (!self::$session) {
99 self::$session = self::_createSession($options);
f73b659 Imported the new trunk.
Rob Schley authored
100 }
101
91ef3ea Christophe Demko Fixed issue [#12757] JDate override problem in Backend
chdemko authored
102 return self::$session;
f73b659 Imported the new trunk.
Rob Schley authored
103 }
104
105 /**
106 * Get a language object
107 *
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
108 * Returns the global {@link JLanguage} object, only creating it
f73b659 Imported the new trunk.
Rob Schley authored
109 * if it doesn't already exist.
4924fd2 elinw user,utilities,base files, clean up places
elinw authored
110 *
111 * @see JLanguage
f73b659 Imported the new trunk.
Rob Schley authored
112 *
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
113 * @return JLanguage object
f73b659 Imported the new trunk.
Rob Schley authored
114 */
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
115 public static function getLanguage()
f73b659 Imported the new trunk.
Rob Schley authored
116 {
91ef3ea Christophe Demko Fixed issue [#12757] JDate override problem in Backend
chdemko authored
117 if (!self::$language) {
118 self::$language = self::_createLanguage();
f73b659 Imported the new trunk.
Rob Schley authored
119 }
120
91ef3ea Christophe Demko Fixed issue [#12757] JDate override problem in Backend
chdemko authored
121 return self::$language;
f73b659 Imported the new trunk.
Rob Schley authored
122 }
123
124 /**
125 * Get a document object
126 *
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
127 * Returns the global {@link JDocument} object, only creating it
f73b659 Imported the new trunk.
Rob Schley authored
128 * if it doesn't already exist.
129 *
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
130 * @return JDocument object
f73b659 Imported the new trunk.
Rob Schley authored
131 */
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
132 public static function getDocument()
f73b659 Imported the new trunk.
Rob Schley authored
133 {
91ef3ea Christophe Demko Fixed issue [#12757] JDate override problem in Backend
chdemko authored
134 if (!self::$document) {
135 self::$document = self::_createDocument();
f73b659 Imported the new trunk.
Rob Schley authored
136 }
137
91ef3ea Christophe Demko Fixed issue [#12757] JDate override problem in Backend
chdemko authored
138 return self::$document;
f73b659 Imported the new trunk.
Rob Schley authored
139 }
140
141 /**
142 * Get an user object
143 *
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
144 * Returns the global {@link JUser} object, only creating it
f73b659 Imported the new trunk.
Rob Schley authored
145 * if it doesn't already exist.
146 *
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
147 * @param int $id The user to load - Can be an integer or string - If string, it is converted to ID automatically.
f73b659 Imported the new trunk.
Rob Schley authored
148 *
4924fd2 elinw user,utilities,base files, clean up places
elinw authored
149 * @see JUser
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
150 * @return JUser object
f73b659 Imported the new trunk.
Rob Schley authored
151 */
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
152 public static function getUser($id = null)
f73b659 Imported the new trunk.
Rob Schley authored
153 {
154 jimport('joomla.user.user');
155
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
156 if (is_null($id)) {
91ef3ea Christophe Demko Fixed issue [#12757] JDate override problem in Backend
chdemko authored
157 $instance = self::getSession()->get('user');
18c45a5 Andrew Eddie Fixed issue [#23041] Incorrect testing for variable is an instance of a ...
eddieajau authored
158 if (!($instance instanceof JUser)) {
aa5891a Andrew Eddie Fixed issue [#20907] Making Joomla more compliant to PHP strict standard
eddieajau authored
159 $instance = JUser::getInstance();
f73b659 Imported the new trunk.
Rob Schley authored
160 }
18c45a5 Andrew Eddie Fixed issue [#23041] Incorrect testing for variable is an instance of a ...
eddieajau authored
161 }
162 else {
aa5891a Andrew Eddie Fixed issue [#20907] Making Joomla more compliant to PHP strict standard
eddieajau authored
163 $instance = JUser::getInstance($id);
f73b659 Imported the new trunk.
Rob Schley authored
164 }
165
166 return $instance;
167 }
168
169 /**
170 * Get a cache object
171 *
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
172 * Returns the global {@link JCache} object
f73b659 Imported the new trunk.
Rob Schley authored
173 *
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
174 * @param string $group The cache group name
175 * @param string $handler The handler to use
176 * @param string $storage The storage method
4924fd2 elinw user,utilities,base files, clean up places
elinw authored
177 *
178 * @see JCache
91bc16d Andrew Eddie Partial fixes to [#20907] Making Joomla more compliant to PHP strict sta...
eddieajau authored
179 *
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
180 * @return JCache object
f73b659 Imported the new trunk.
Rob Schley authored
181 */
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
182 public static function getCache($group = '', $handler = 'callback', $storage = null)
f73b659 Imported the new trunk.
Rob Schley authored
183 {
4e562e1 Hannes Papenberg # Small performance improvements ot JRegistry, JFactory::getCache()
Hackwar authored
184 $hash = md5($group.$handler.$storage);
91ef3ea Christophe Demko Fixed issue [#12757] JDate override problem in Backend
chdemko authored
185 if (isset(self::$cache[$hash])) {
186 return self::$cache[$hash];
4e562e1 Hannes Papenberg # Small performance improvements ot JRegistry, JFactory::getCache()
Hackwar authored
187 }
f73b659 Imported the new trunk.
Rob Schley authored
188 $handler = ($handler == 'function') ? 'callback' : $handler;
189
91bc16d Andrew Eddie Partial fixes to [#20907] Making Joomla more compliant to PHP strict sta...
eddieajau authored
190 $conf = self::getConfig();
a83e119 Louis Landry Cleaning out trailing whitespace.
LouisLandry authored
191
c9b9586 Hannes Papenberg ^+# Implemented a new caching and implemented it in all frontendcomponen...
Hackwar authored
192 $options = array('defaultgroup' => $group );
a83e119 Louis Landry Cleaning out trailing whitespace.
LouisLandry authored
193
c9b9586 Hannes Papenberg ^+# Implemented a new caching and implemented it in all frontendcomponen...
Hackwar authored
194 if (isset($storage)) {
4a7b43b # [#20796] Joomla! caches ALL HTML in 1 file. Thanks Klas.
Jean-Marie Simonet authored
195 $options['storage'] = $storage;
f73b659 Imported the new trunk.
Rob Schley authored
196 }
a83e119 Louis Landry Cleaning out trailing whitespace.
LouisLandry authored
197
f73b659 Imported the new trunk.
Rob Schley authored
198 jimport('joomla.cache.cache');
199
91bc16d Andrew Eddie Partial fixes to [#20907] Making Joomla more compliant to PHP strict sta...
eddieajau authored
200 $cache = JCache::getInstance($handler, $options);
c6c4a01 Andrew Eddie Trim trailing white space.
eddieajau authored
201
91ef3ea Christophe Demko Fixed issue [#12757] JDate override problem in Backend
chdemko authored
202 self::$cache[$hash] = $cache;
18c45a5 Andrew Eddie Fixed issue [#23041] Incorrect testing for variable is an instance of a ...
eddieajau authored
203
91ef3ea Christophe Demko Fixed issue [#12757] JDate override problem in Backend
chdemko authored
204 return self::$cache[$hash];
f73b659 Imported the new trunk.
Rob Schley authored
205 }
206
207 /**
208 * Get an authorization object
209 *
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
210 * Returns the global {@link JACL} object, only creating it
f73b659 Imported the new trunk.
Rob Schley authored
211 * if it doesn't already exist.
212 *
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
213 * @return JACL object
f73b659 Imported the new trunk.
Rob Schley authored
214 */
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
215 public static function getACL()
f73b659 Imported the new trunk.
Rob Schley authored
216 {
91ef3ea Christophe Demko Fixed issue [#12757] JDate override problem in Backend
chdemko authored
217 if (!self::$acl) {
f73b659 Imported the new trunk.
Rob Schley authored
218 jimport('joomla.access.access');
91ef3ea Christophe Demko Fixed issue [#12757] JDate override problem in Backend
chdemko authored
219 self::$acl = new JAccess();
f73b659 Imported the new trunk.
Rob Schley authored
220 }
221
91ef3ea Christophe Demko Fixed issue [#12757] JDate override problem in Backend
chdemko authored
222 return self::$acl;
f73b659 Imported the new trunk.
Rob Schley authored
223 }
224
225 /**
226 * Get a database object
227 *
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
228 * Returns the global {@link JDatabase} object, only creating it
f73b659 Imported the new trunk.
Rob Schley authored
229 * if it doesn't already exist.
230 *
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
231 * @return JDatabase object
f73b659 Imported the new trunk.
Rob Schley authored
232 */
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
233 public static function getDbo()
f73b659 Imported the new trunk.
Rob Schley authored
234 {
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
235 if (!self::$database) {
f73b659 Imported the new trunk.
Rob Schley authored
236 //get the debug configuration setting
91bc16d Andrew Eddie Partial fixes to [#20907] Making Joomla more compliant to PHP strict sta...
eddieajau authored
237 $conf = self::getConfig();
238 $debug = $conf->get('debug');
f73b659 Imported the new trunk.
Rob Schley authored
239
5fd474c Various E-Strict validation fixes.
Gergo Erdosi authored
240 self::$database = self::_createDbo();
241 self::$database->debug($debug);
f73b659 Imported the new trunk.
Rob Schley authored
242 }
18c45a5 Andrew Eddie Fixed issue [#23041] Incorrect testing for variable is an instance of a ...
eddieajau authored
243
5fd474c Various E-Strict validation fixes.
Gergo Erdosi authored
244 return self::$database;
f73b659 Imported the new trunk.
Rob Schley authored
245 }
246
247 /**
248 * Get a mailer object
249 *
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
250 * Returns the global {@link JMail} object, only creating it
f73b659 Imported the new trunk.
Rob Schley authored
251 * if it doesn't already exist
4924fd2 elinw user,utilities,base files, clean up places
elinw authored
252 *
253 * @see JMail
f73b659 Imported the new trunk.
Rob Schley authored
254 *
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
255 * @return JMail object
f73b659 Imported the new trunk.
Rob Schley authored
256 */
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
257 public static function getMailer()
f73b659 Imported the new trunk.
Rob Schley authored
258 {
91ef3ea Christophe Demko Fixed issue [#12757] JDate override problem in Backend
chdemko authored
259 if (!self::$mailer) {
260 self::$mailer = self::_createMailer();
f73b659 Imported the new trunk.
Rob Schley authored
261 }
91ef3ea Christophe Demko Fixed issue [#12757] JDate override problem in Backend
chdemko authored
262 $copy = clone self::$mailer;
18c45a5 Andrew Eddie Fixed issue [#23041] Incorrect testing for variable is an instance of a ...
eddieajau authored
263
f73b659 Imported the new trunk.
Rob Schley authored
264 return $copy;
265 }
266
267 /**
268 * Get a parsed XML Feed Source
269 *
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
270 * @param string $url url for feed source
271 * @param int $cache_time time to cache feed for (using internal cache mechanism)
91bc16d Andrew Eddie Partial fixes to [#20907] Making Joomla more compliant to PHP strict sta...
eddieajau authored
272 *
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
273 * @return mixed SimplePie parsed object on success, false on failure
7789364 Louis Landry Fix up remaining @since tags referencing CMS versions to point to the 11...
LouisLandry authored
274 * @since: 11.1
f73b659 Imported the new trunk.
Rob Schley authored
275 */
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
276 public static function getFeedParser($url, $cache_time = 0)
f73b659 Imported the new trunk.
Rob Schley authored
277 {
278 jimport('simplepie.simplepie');
a83e119 Louis Landry Cleaning out trailing whitespace.
LouisLandry authored
279
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
280 $cache = self::getCache('feed_parser', 'callback');
a83e119 Louis Landry Cleaning out trailing whitespace.
LouisLandry authored
281
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
282 if ($cache_time > 0) {
283 $cache->setLifeTime($cache_time);
284 }
a83e119 Louis Landry Cleaning out trailing whitespace.
LouisLandry authored
285
c9b9586 Hannes Papenberg ^+# Implemented a new caching and implemented it in all frontendcomponen...
Hackwar authored
286 $simplepie = new SimplePie(null, null, 0);
a83e119 Louis Landry Cleaning out trailing whitespace.
LouisLandry authored
287
c9b9586 Hannes Papenberg ^+# Implemented a new caching and implemented it in all frontendcomponen...
Hackwar authored
288 $simplepie->enable_cache(false);
289 $simplepie->set_feed_url($url);
bb42c43 Hannes Papenberg # refactored TinyMCE - thanks Jean-Marie
Hackwar authored
290 $simplepie->force_feed(true);
a83e119 Louis Landry Cleaning out trailing whitespace.
LouisLandry authored
291
c9b9586 Hannes Papenberg ^+# Implemented a new caching and implemented it in all frontendcomponen...
Hackwar authored
292 $contents = $cache->get(array($simplepie, 'init'), null, false, false);
a83e119 Louis Landry Cleaning out trailing whitespace.
LouisLandry authored
293
c9b9586 Hannes Papenberg ^+# Implemented a new caching and implemented it in all frontendcomponen...
Hackwar authored
294 if ($contents) {
f73b659 Imported the new trunk.
Rob Schley authored
295 return $simplepie;
18c45a5 Andrew Eddie Fixed issue [#23041] Incorrect testing for variable is an instance of a ...
eddieajau authored
296 }
297 else {
00c0cc9 $ Completed libraries/J ini/keys refactoring
Jean-Marie Simonet authored
298 JError::raiseWarning('SOME_ERROR_CODE', JText::_('JLIB_UTIL_ERROR_LOADING_FEED_DATA'));
f73b659 Imported the new trunk.
Rob Schley authored
299 }
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
300
301 return false;
f73b659 Imported the new trunk.
Rob Schley authored
302 }
303
304 /**
305 * Get an XML document
306 *
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
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 *
f73b659 Imported the new trunk.
Rob Schley authored
310 * @return object Parsed XML document object
311 * @deprecated
312 */
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
313 public static function getXMLParser($type = '', $options = array())
9d3bd0a Hannes Papenberg ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML files....
Hackwar authored
314 {
f73b659 Imported the new trunk.
Rob Schley authored
315 $doc = null;
316
18c45a5 Andrew Eddie Fixed issue [#23041] Incorrect testing for variable is an instance of a ...
eddieajau authored
317 switch (strtolower($type))
318 {
f73b659 Imported the new trunk.
Rob Schley authored
319 case 'rss' :
320 case 'atom' :
416c722 Louis Landry Merging JForm branch down to trunk.
LouisLandry authored
321 $cache_time = isset($options['cache_time']) ? $options['cache_time'] : 0;
91ef3ea Christophe Demko Fixed issue [#12757] JDate override problem in Backend
chdemko authored
322 $doc = self::getFeedParser($options['rssUrl'], $cache_time);
416c722 Louis Landry Merging JForm branch down to trunk.
LouisLandry authored
323 break;
f73b659 Imported the new trunk.
Rob Schley authored
324
325 case 'simple':
91ef3ea Christophe Demko Fixed issue [#12757] JDate override problem in Backend
chdemko authored
326 // JError::raiseWarning('SOME_ERROR_CODE', 'JSimpleXML is deprecated. Use self::getXML instead');
f73b659 Imported the new trunk.
Rob Schley authored
327 jimport('joomla.utilities.simplexml');
328 $doc = new JSimpleXML();
329 break;
330
331 case 'dom':
00c0cc9 $ Completed libraries/J ini/keys refactoring
Jean-Marie Simonet authored
332 JError::raiseWarning('SOME_ERROR_CODE', JText::_('JLIB_UTIL_ERROR_DOMIT'));
f73b659 Imported the new trunk.
Rob Schley authored
333 $doc = null;
334 break;
335
336 default :
337 $doc = null;
338 }
339
340 return $doc;
341 }
342
343 /**
9d3bd0a Hannes Papenberg ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML files....
Hackwar authored
344 * Reads a XML file.
345 *
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
346 * @param string $data Full path and file name.
9d3bd0a Hannes Papenberg ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML files....
Hackwar authored
347 * @param boolean $isFile true to load a file | false to load a string.
348 *
349 * @return mixed JXMLElement on success | false on error.
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
350 * @todo This may go in a separate class - error reporting may be improved.
9d3bd0a Hannes Papenberg ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML files....
Hackwar authored
351 */
3082dc2 Louis Landry Fixed [#19552] [patch] Error loading xml from string in JFactory::getXML...
LouisLandry authored
352 public static function getXML($data, $isFile = true)
9d3bd0a Hannes Papenberg ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML files....
Hackwar authored
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
416c722 Louis Landry Merging JForm branch down to trunk.
LouisLandry authored
359 if ($isFile) {
9d3bd0a Hannes Papenberg ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML files....
Hackwar authored
360 // Try to load the xml file
3082dc2 Louis Landry Fixed [#19552] [patch] Error loading xml from string in JFactory::getXML...
LouisLandry authored
361 $xml = simplexml_load_file($data, 'JXMLElement');
18c45a5 Andrew Eddie Fixed issue [#23041] Incorrect testing for variable is an instance of a ...
eddieajau authored
362 }
363 else {
9d3bd0a Hannes Papenberg ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML files....
Hackwar authored
364 // Try to load the xml string
365 $xml = simplexml_load_string($data, 'JXMLElement');
366 }
367
416c722 Louis Landry Merging JForm branch down to trunk.
LouisLandry authored
368 if (empty($xml)) {
9d3bd0a Hannes Papenberg ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML files....
Hackwar authored
369 // There was an error
00c0cc9 $ Completed libraries/J ini/keys refactoring
Jean-Marie Simonet authored
370 JError::raiseWarning(100, JText::_('JLIB_UTIL_ERROR_XML_LOAD'));
9d3bd0a Hannes Papenberg ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML files....
Hackwar authored
371
416c722 Louis Landry Merging JForm branch down to trunk.
LouisLandry authored
372 if ($isFile) {
3082dc2 Louis Landry Fixed [#19552] [patch] Error loading xml from string in JFactory::getXML...
LouisLandry authored
373 JError::raiseWarning(100, $data);
9d3bd0a Hannes Papenberg ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML files....
Hackwar authored
374 }
375
18c45a5 Andrew Eddie Fixed issue [#23041] Incorrect testing for variable is an instance of a ...
eddieajau authored
376 foreach (libxml_get_errors() as $error)
377 {
9d3bd0a Hannes Papenberg ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML files....
Hackwar authored
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
91bc16d Andrew Eddie Partial fixes to [#20907] Making Joomla more compliant to PHP strict sta...
eddieajau authored
389 *
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
390 * @return JEditor object
9d3bd0a Hannes Papenberg ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML files....
Hackwar authored
391 */
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
392 public static function getEditor($editor = null)
f73b659 Imported the new trunk.
Rob Schley authored
393 {
394 jimport('joomla.html.editor');
395
396 //get the editor configuration setting
416c722 Louis Landry Merging JForm branch down to trunk.
LouisLandry authored
397 if (is_null($editor)) {
91bc16d Andrew Eddie Partial fixes to [#20907] Making Joomla more compliant to PHP strict sta...
eddieajau authored
398 $conf = self::getConfig();
399 $editor = $conf->get('editor');
f73b659 Imported the new trunk.
Rob Schley authored
400 }
401
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
402 return JEditor::getInstance($editor);
f73b659 Imported the new trunk.
Rob Schley authored
403 }
404
405 /**
406 * Return a reference to the {@link JURI} object
407 *
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
408 * @param string $uri uri name
4924fd2 elinw user,utilities,base files, clean up places
elinw authored
409 *
410 * @see JURI
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
411 *
412 * @return JURI object
a860668 Louis Landry Fix up some more @since tags as well as platform configuration file load...
LouisLandry authored
413 * @since 11.1
f73b659 Imported the new trunk.
Rob Schley authored
414 */
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
415 public static function getURI($uri = 'SERVER')
f73b659 Imported the new trunk.
Rob Schley authored
416 {
417 jimport('joomla.environment.uri');
418
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
419 return JURI::getInstance($uri);
f73b659 Imported the new trunk.
Rob Schley authored
420 }
421
422 /**
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
423 * Return the {@link JDate} object
f73b659 Imported the new trunk.
Rob Schley authored
424 *
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
425 * @param mixed $time The initial time for the JDate object
a8fb3f9 Louis Landry Merge down from datetime branch. Improvements include new date class wi...
LouisLandry authored
426 * @param mixed $tzOffset The timezone offset.
4924fd2 elinw user,utilities,base files, clean up places
elinw authored
427 *
428 * @see JDate
91bc16d Andrew Eddie Partial fixes to [#20907] Making Joomla more compliant to PHP strict sta...
eddieajau authored
429 *
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
430 * @return JDate object
a860668 Louis Landry Fix up some more @since tags as well as platform configuration file load...
LouisLandry authored
431 * @since 11.1
f73b659 Imported the new trunk.
Rob Schley authored
432 */
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
433 public static function getDate($time = 'now', $tzOffset = null)
f73b659 Imported the new trunk.
Rob Schley authored
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
91bc16d Andrew Eddie Partial fixes to [#20907] Making Joomla more compliant to PHP strict sta...
eddieajau authored
444 $language = self::getLanguage();
445 $locale = $language->getTag();
f73b659 Imported the new trunk.
Rob Schley authored
446
447 if (!isset($classname) || $locale != $mainLocale) {
448 //Store the locale for future reference
449 $mainLocale = $locale;
18c45a5 Andrew Eddie Fixed issue [#23041] Incorrect testing for variable is an instance of a ...
eddieajau authored
450
91ef3ea Christophe Demko Fixed issue [#12757] JDate override problem in Backend
chdemko authored
451 if ($mainLocale !== false) {
452 $classname = str_replace('-', '_', $mainLocale).'Date';
18c45a5 Andrew Eddie Fixed issue [#23041] Incorrect testing for variable is an instance of a ...
eddieajau authored
453
f73b659 Imported the new trunk.
Rob Schley authored
454 if (!class_exists($classname)) {
91ef3ea Christophe Demko Fixed issue [#12757] JDate override problem in Backend
chdemko authored
455 //The class does not exist, default to JDate
f73b659 Imported the new trunk.
Rob Schley authored
456 $classname = 'JDate';
457 }
18c45a5 Andrew Eddie Fixed issue [#23041] Incorrect testing for variable is an instance of a ...
eddieajau authored
458 }
459 else {
91ef3ea Christophe Demko Fixed issue [#12757] JDate override problem in Backend
chdemko authored
460 //No tag, so default to JDate
f73b659 Imported the new trunk.
Rob Schley authored
461 $classname = 'JDate';
462 }
463 }
464 $key = $time . '-' . $tzOffset;
465
9d3bd0a Hannes Papenberg ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML files....
Hackwar authored
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 // }
f73b659 Imported the new trunk.
Rob Schley authored
472
9d3bd0a Hannes Papenberg ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML files....
Hackwar authored
473 // $date = unserialize($instances[$classname][$key]);
474 // return $date;
a8fb3f9 Louis Landry Merge down from datetime branch. Improvements include new date class wi...
LouisLandry authored
475 return $tmp;
f73b659 Imported the new trunk.
Rob Schley authored
476 }
477
478
479
480 /**
481 * Create a configuration object
482 *
a860668 Louis Landry Fix up some more @since tags as well as platform configuration file load...
LouisLandry authored
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.
91bc16d Andrew Eddie Partial fixes to [#20907] Making Joomla more compliant to PHP strict sta...
eddieajau authored
486 *
a860668 Louis Landry Fix up some more @since tags as well as platform configuration file load...
LouisLandry authored
487 * @return JRegistry
488 *
489 * @since 11.1
f73b659 Imported the new trunk.
Rob Schley authored
490 */
a860668 Louis Landry Fix up some more @since tags as well as platform configuration file load...
LouisLandry authored
491 private static function _createConfig($file, $type = 'PHP', $namespace = '')
f73b659 Imported the new trunk.
Rob Schley authored
492 {
493 jimport('joomla.registry.registry');
494
67bf9c7 Louis Landry Fixing up unit testing errors.
LouisLandry authored
495 if (is_file($file)) {
496 include_once $file;
497 }
f73b659 Imported the new trunk.
Rob Schley authored
498
499 // Create the registry with a default namespace of config
4e562e1 Hannes Papenberg # Small performance improvements ot JRegistry, JFactory::getCache()
Hackwar authored
500 $registry = new JRegistry();
f73b659 Imported the new trunk.
Rob Schley authored
501
a860668 Louis Landry Fix up some more @since tags as well as platform configuration file load...
LouisLandry authored
502 // Sanitize the namespace.
503 $namespace = ucfirst((string) preg_replace('/[^A-Z_]/i', '', $namespace));
f73b659 Imported the new trunk.
Rob Schley authored
504
a860668 Louis Landry Fix up some more @since tags as well as platform configuration file load...
LouisLandry authored
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 }
f73b659 Imported the new trunk.
Rob Schley authored
516
517 return $registry;
518 }
519
520 /**
521 * Create a session object
522 *
523 * @param array $options An array containing session options
91bc16d Andrew Eddie Partial fixes to [#20907] Making Joomla more compliant to PHP strict sta...
eddieajau authored
524 *
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
525 * @return JSession object
a860668 Louis Landry Fix up some more @since tags as well as platform configuration file load...
LouisLandry authored
526 * @since 11.1
f73b659 Imported the new trunk.
Rob Schley authored
527 */
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
528 private static function _createSession($options = array())
f73b659 Imported the new trunk.
Rob Schley authored
529 {
530 jimport('joomla.session.session');
531
4924fd2 elinw user,utilities,base files, clean up places
elinw authored
532 // Get the editor configuration setting
91bc16d Andrew Eddie Partial fixes to [#20907] Making Joomla more compliant to PHP strict sta...
eddieajau authored
533 $conf = self::getConfig();
534 $handler = $conf->get('session_handler', 'none');
f73b659 Imported the new trunk.
Rob Schley authored
535
4924fd2 elinw user,utilities,base files, clean up places
elinw authored
536 // Config time is in minutes
416c722 Louis Landry Merging JForm branch down to trunk.
LouisLandry authored
537 $options['expire'] = ($conf->get('lifetime')) ? $conf->get('lifetime') * 60 : 900;
f73b659 Imported the new trunk.
Rob Schley authored
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 *
4924fd2 elinw user,utilities,base files, clean up places
elinw authored
550 * @see JDatabase
551 *
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
552 * @return JDatabase object
91bc16d Andrew Eddie Partial fixes to [#20907] Making Joomla more compliant to PHP strict sta...
eddieajau authored
553 *
a860668 Louis Landry Fix up some more @since tags as well as platform configuration file load...
LouisLandry authored
554 * @since 11.1
f73b659 Imported the new trunk.
Rob Schley authored
555 */
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
556 private static function _createDbo()
f73b659 Imported the new trunk.
Rob Schley authored
557 {
558 jimport('joomla.database.database');
559 jimport('joomla.database.table');
560
91bc16d Andrew Eddie Partial fixes to [#20907] Making Joomla more compliant to PHP strict sta...
eddieajau authored
561 $conf = self::getConfig();
f73b659 Imported the new trunk.
Rob Schley authored
562
416c722 Louis Landry Merging JForm branch down to trunk.
LouisLandry authored
563 $host = $conf->get('host');
564 $user = $conf->get('user');
565 $password = $conf->get('password');
566 $database = $conf->get('db');
69ba254 Andrew Eddie Fixed issue [#21436] Database Error should return "500 Internal Server E...
eddieajau authored
567 $prefix = $conf->get('dbprefix');
568 $driver = $conf->get('dbtype');
416c722 Louis Landry Merging JForm branch down to trunk.
LouisLandry authored
569 $debug = $conf->get('debug');
f73b659 Imported the new trunk.
Rob Schley authored
570
571 $options = array ('driver' => $driver, 'host' => $host, 'user' => $user, 'password' => $password, 'database' => $database, 'prefix' => $prefix);
572
91bc16d Andrew Eddie Partial fixes to [#20907] Making Joomla more compliant to PHP strict sta...
eddieajau authored
573 $db = JDatabase::getInstance($options);
f73b659 Imported the new trunk.
Rob Schley authored
574
575 if (JError::isError($db)) {
69ba254 Andrew Eddie Fixed issue [#21436] Database Error should return "500 Internal Server E...
eddieajau authored
576 header('HTTP/1.1 500 Internal Server Error');
577 jexit('Database Error: ' . (string) $db);
f73b659 Imported the new trunk.
Rob Schley authored
578 }
579
580 if ($db->getErrorNum() > 0) {
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
581 JError::raiseError(500, JText::sprintf('JLIB_UTIL_ERROR_CONNECT_DATABASE', $db->getErrorNum(), $db->getErrorMsg()));
f73b659 Imported the new trunk.
Rob Schley authored
582 }
583
584 $db->debug($debug);
585 return $db;
586 }
587
588 /**
589 * Create a mailer object
590 *
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
591 * @return JMail object
7789364 Louis Landry Fix up remaining @since tags referencing CMS versions to point to the 11...
LouisLandry authored
592 * @since 11.1
f73b659 Imported the new trunk.
Rob Schley authored
593 */
8bf5519 Andrew Eddie Fixed issue [#24153] More PHP strict fixes (mostly backend) (Rouven Weßl...
eddieajau authored
594 private static function _createMailer()
f73b659 Imported the new trunk.
Rob Schley authored
595 {
596 jimport('joomla.mail.mail');
597
91bc16d Andrew Eddie Partial fixes to [#20907] Making Joomla more compliant to PHP strict sta...
eddieajau authored
598 $conf = self::getConfig();
f73b659 Imported the new trunk.
Rob Schley authored
599
416c722 Louis Landry Merging JForm branch down to trunk.
LouisLandry authored
600 $sendmail = $conf->get('sendmail');
384ccad # [#21906] SMTP without authentication not working. Thanks Roland and I...
Jean-Marie Simonet authored
601 $smtpauth = ($conf->get('smtpauth') == 0) ? null : 1;
416c722 Louis Landry Merging JForm branch down to trunk.
LouisLandry authored
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');
f73b659 Imported the new trunk.
Rob Schley authored
610
611 // Create a JMail object
aa5891a Andrew Eddie Fixed issue [#20907] Making Joomla more compliant to PHP strict standard
eddieajau authored
612 $mail = JMail::getInstance();
f73b659 Imported the new trunk.
Rob Schley authored
613
614 // Set default sender
615 $mail->setSender(array ($mailfrom, $fromname));
616
617 // Default mailer is to use PHP's mail function
18c45a5 Andrew Eddie Fixed issue [#23041] Incorrect testing for variable is an instance of a ...
eddieajau authored
618 switch ($mailer)
619 {
f73b659 Imported the new trunk.
Rob Schley authored
620 case 'smtp' :
9b992ba Hannes Papenberg Updated PHPMailer to version 2.3
Hackwar authored
621 $mail->useSMTP($smtpauth, $smtphost, $smtpuser, $smtppass, $smtpsecure, $smtpport);
f73b659 Imported the new trunk.
Rob Schley authored
622 break;
18c45a5 Andrew Eddie Fixed issue [#23041] Incorrect testing for variable is an instance of a ...
eddieajau authored
623
f73b659 Imported the new trunk.
Rob Schley authored
624 case 'sendmail' :
625 $mail->IsSendmail();
626 break;
18c45a5 Andrew Eddie Fixed issue [#23041] Incorrect testing for variable is an instance of a ...
eddieajau authored
627
f73b659 Imported the new trunk.
Rob Schley authored
628 default :
629 $mail->IsMail();
630 break;
631 }
632
633 return $mail;
634 }
635
636 /**
637 * Create a language object
638 *
4924fd2 elinw user,utilities,base files, clean up places
elinw authored
639 * @see JLanguage
640 *
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
641 * @return JLanguage object
a860668 Louis Landry Fix up some more @since tags as well as platform configuration file load...
LouisLandry authored
642 * @since 11.1
f73b659 Imported the new trunk.
Rob Schley authored
643 */
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
644 private static function _createLanguage()
f73b659 Imported the new trunk.
Rob Schley authored
645 {
646 jimport('joomla.language.language');
647
91bc16d Andrew Eddie Partial fixes to [#20907] Making Joomla more compliant to PHP strict sta...
eddieajau authored
648 $conf = self::getConfig();
416c722 Louis Landry Merging JForm branch down to trunk.
LouisLandry authored
649 $locale = $conf->get('language');
65a64b8 #$^ Enabling parsing language files errors in debug lang mode only (new ...
Jean-Marie Simonet authored
650 $debug = $conf->get('debug_lang');
91bc16d Andrew Eddie Partial fixes to [#20907] Making Joomla more compliant to PHP strict sta...
eddieajau authored
651 $lang = JLanguage::getInstance($locale, $debug);
f73b659 Imported the new trunk.
Rob Schley authored
652
653 return $lang;
654 }
655
656 /**
657 * Create a document object
4924fd2 elinw user,utilities,base files, clean up places
elinw authored
658 *
659 * @see JDocument
f73b659 Imported the new trunk.
Rob Schley authored
660 *
91bc16d Andrew Eddie Partial fixes to [#20907] Making Joomla more compliant to PHP strict sta...
eddieajau authored
661 * @return JDocument object
a860668 Louis Landry Fix up some more @since tags as well as platform configuration file load...
LouisLandry authored
662 * @since 11.1
f73b659 Imported the new trunk.
Rob Schley authored
663 */
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
664 private static function _createDocument()
f73b659 Imported the new trunk.
Rob Schley authored
665 {
666 jimport('joomla.document.document');
667
91bc16d Andrew Eddie Partial fixes to [#20907] Making Joomla more compliant to PHP strict sta...
eddieajau authored
668 $lang = self::getLanguage();
f73b659 Imported the new trunk.
Rob Schley authored
669
4924fd2 elinw user,utilities,base files, clean up places
elinw authored
670 // Keep backwards compatibility with Joomla! 1.0
f73b659 Imported the new trunk.
Rob Schley authored
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
8699a0c Louis Landry Clean up of reference operators as they aren't needed in PHP5
LouisLandry authored
682 return JDocument::getInstance($type, $attributes);
f73b659 Imported the new trunk.
Rob Schley authored
683 }
052ac22 Andrew Eddie Trailing spaces removed
eddieajau authored
684
e8679fb Sam Moffatt + Added JFactory::getStream
pasamio authored
685 /**
686 * Creates a new stream object with appropriate prefix
91bc16d Andrew Eddie Partial fixes to [#20907] Making Joomla more compliant to PHP strict sta...
eddieajau authored
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 *
4924fd2 elinw user,utilities,base files, clean up places
elinw authored
693 * @see JStream
694 *
91bc16d Andrew Eddie Partial fixes to [#20907] Making Joomla more compliant to PHP strict sta...
eddieajau authored
695 * @return JStream
2334309 Louis Landry Fixing up @since tags for the platform libraries.
LouisLandry authored
696 * @since 11.1
e8679fb Sam Moffatt + Added JFactory::getStream
pasamio authored
697 */
8bf5519 Andrew Eddie Fixed issue [#24153] More PHP strict fixes (mostly backend) (Rouven Weßl...
eddieajau authored
698 public static function getStream($use_prefix=true, $use_network=true,$ua=null, $uamask=false)
416c722 Louis Landry Merging JForm branch down to trunk.
LouisLandry authored
699 {
e8679fb Sam Moffatt + Added JFactory::getStream
pasamio authored
700 jimport('joomla.filesystem.stream');
91bc16d Andrew Eddie Partial fixes to [#20907] Making Joomla more compliant to PHP strict sta...
eddieajau authored
701
e8679fb Sam Moffatt + Added JFactory::getStream
pasamio authored
702 // Setup the context; Joomla! UA and overwrite
8bf5519 Andrew Eddie Fixed issue [#24153] More PHP strict fixes (mostly backend) (Rouven Weßl...
eddieajau authored
703 $context = array();
704 $version = new JVersion;
e8679fb Sam Moffatt + Added JFactory::getStream
pasamio authored
705 // set the UA for HTTP and overwrite for FTP
706 $context['http']['user_agent'] = $version->getUserAgent($ua, $uamask);
052ac22 Andrew Eddie Trailing spaces removed
eddieajau authored
707 $context['ftp']['overwrite'] = true;
416c722 Louis Landry Merging JForm branch down to trunk.
LouisLandry authored
708
709 if ($use_prefix) {
e8679fb Sam Moffatt + Added JFactory::getStream
pasamio authored
710 jimport('joomla.client.helper');
711 $FTPOptions = JClientHelper::getCredentials('ftp');
712 $SCPOptions = JClientHelper::getCredentials('scp');
91bc16d Andrew Eddie Partial fixes to [#20907] Making Joomla more compliant to PHP strict sta...
eddieajau authored
713
e8679fb Sam Moffatt + Added JFactory::getStream
pasamio authored
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'];
18c45a5 Andrew Eddie Fixed issue [#23041] Incorrect testing for variable is an instance of a ...
eddieajau authored
718 }
719 else if ($SCPOptions['enabled'] == 1 && $use_network) {
e8679fb Sam Moffatt + Added JFactory::getStream
pasamio authored
720 $prefix = 'ssh2.sftp://'. $SCPOptions['user'] .':'. $SCPOptions['pass'] .'@'. $SCPOptions['host'];
721 $prefix .= $SCPOptions['port'] ? ':'. $SCPOptions['port'] : '';
722 $prefix .= $SCPOptions['root'];
18c45a5 Andrew Eddie Fixed issue [#23041] Incorrect testing for variable is an instance of a ...
eddieajau authored
723 }
724 else {
3e5ccad ianmacl # [!21949] Reverted systematic elimination of DS as directory separator
ianmacl authored
725 $prefix = JPATH_ROOT.DS;
e8679fb Sam Moffatt + Added JFactory::getStream
pasamio authored
726 }
91bc16d Andrew Eddie Partial fixes to [#20907] Making Joomla more compliant to PHP strict sta...
eddieajau authored
727
e8679fb Sam Moffatt + Added JFactory::getStream
pasamio authored
728 $retval = new JStream($prefix, JPATH_ROOT, $context);
18c45a5 Andrew Eddie Fixed issue [#23041] Incorrect testing for variable is an instance of a ...
eddieajau authored
729 }
730 else {
1ffd3c1 ianmacl [#20691] Doc Block and Code Formatting Fixes - Thanks Marius
ianmacl authored
731 $retval = new JStream('', '', $context);
e8679fb Sam Moffatt + Added JFactory::getStream
pasamio authored
732 }
91bc16d Andrew Eddie Partial fixes to [#20907] Making Joomla more compliant to PHP strict sta...
eddieajau authored
733
e8679fb Sam Moffatt + Added JFactory::getStream
pasamio authored
734 return $retval;
735 }
f73b659 Imported the new trunk.
Rob Schley authored
736 }
Something went wrong with that request. Please try again.