OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / include / mos / JParameter.php
1 <?php
2 /**
3  * Joomla!パラメータクラス
4  *
5  * PHP versions 5
6  *
7  * LICENSE: This source file is licensed under the terms of the GNU General Public License.
8  *
9  * @package    Magic3 Framework
10  * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
11  * @copyright  Copyright 2006-2013 Magic3 Project.
12  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
13  * @version    SVN: $Id: JParameter.php 5552 2013-01-14 12:37:43Z fishbone $
14  * @link       http://www.magic3.org
15  */
16 require_once($this->gEnv->getJoomlaRootPath() . '/class/error.php');
17 require_once($this->gEnv->getJoomlaRootPath() . '/class/exception.php');
18 require_once($this->gEnv->getJoomlaRootPath() . '/class/object.php');
19 require_once($this->gEnv->getJoomlaRootPath() . '/class/registry.php');
20
21 function jimport($path)
22 {
23         //return JLoader::import($path);
24         return true;
25 }
26 class JParameter
27 {
28         private $params = array();
29
30         /**
31          * コンストラクタ
32          *
33          * @param string $data          初期化データ
34          * @param string $path          初期設定ファイル
35          */
36         function __construct($data = '', $path = '')
37         {
38                 $data = trim($data);
39                 if (!empty($data)){
40                         $lines = explode("\n", $data);
41                         $count = count($lines);
42                         for ($i = 0; $i < $count; $i++){
43                                 list($key, $value) = explode("=", $lines[$i]);
44                                 $this->params[$key] = $value;
45                         }
46                 }
47         }
48         /**
49          * キーを指定して値を設定
50          *
51          * @param string $key           取得キー
52          * @param string                        設定値
53          * @return                                      設定値
54          */
55         public function set($key, $value)
56         {
57                 $this->params[$key] = $value;
58                 return $value;
59         }
60         /**
61          * キーを指定して値を取得
62          *
63          * @param string $key           取得キー
64          * @return string                       取得値
65          */
66         public function get($key)
67         {
68                 return isset($this->params[$key]) ? $this->params[$key] : '';
69         }
70         /**
71          * デフォルト値を設定して値を取得
72          *
73          * @param string $key           取得キー
74          * @param string $default       デフォルト値
75          * @return string                       取得値
76          */
77         public function def($key, $default = '')
78         {
79                 // 値が設定されていなければデフォルト値を設定
80                 $this->params[$key] = $default;
81                 
82                 $value = $this->get($key);
83                 return $value;
84         }
85 }
86 class JUser
87 {
88         /**
89          * 編集権限を返す
90          *
91          * @return bool                         編集権限
92          */
93         public function authorize()
94         {
95                 return false;
96         }
97 }
98 class JRoute
99 {
100         public static function _($url, $xhtml = true, $ssl = null)
101         {
102                 return $url;
103         }
104 }
105 abstract class ContentHelperRoute
106 {
107         public static function getArticleRoute($id, $catid = 0, $language = 0)
108         {
109                 return $id;
110         }
111         public static function getCategoryRoute($catid, $language = 0)
112         {
113                 return '';
114         }
115 }
116 class JText
117 {
118 /*      private static $_strings = array(       'DATE_FORMAT_LC'        => '%A, %d %B %Y',
119                                                                                 'DATE_FORMAT_LC1'       => '%A, %d %B %Y',
120                                                                                 'DATE_FORMAT_LC2'       => '%A, %d %B %Y %H:%M',
121                                                                                 'DATE_FORMAT_LC3'       => '%d %B %Y',
122                                                                                 'DATE_FORMAT_LC4'       => '%d.%m.%y',
123                                                                                 'DATE_FORMAT_JS1'       => 'y-m-d');*/
124         
125         public static function _($string, $jsSafe = false)
126         {
127                 global $gInstanceManager;
128                 
129 /*              $key = strtoupper($string);
130                 $key = substr($key, 0, 1) == '_' ? substr($key, 1) : $key;
131
132                 if (isset(self::$_strings[$key])) $string = self::$_strings[$key];*/
133
134                 $value = $gInstanceManager->getMessageManager()->getJoomlaText($string);
135                 if (!empty($value)) $string = $value;
136
137                 if ($jsSafe) $string = addslashes($string);
138                 return $string;
139         }
140         public static function sprintf($string)
141         {
142                 global $gInstanceManager;
143                 
144 //              $lang =& JFactory::getLanguage();
145                 $args = func_get_args();
146                 if (count($args) > 0) {
147 //                      $args[0] = $lang->_($args[0]);
148                         $value = $gInstanceManager->getMessageManager()->getJoomlaText($args[0]);
149                         if (!empty($value)) $args[0] = $value;
150                         return call_user_func_array('sprintf', $args);
151                 }
152                 return '';
153         }
154         public static function printf($string)
155         {
156                 $lang =& JFactory::getLanguage();
157                 $args = func_get_args();
158                 if (count($args) > 0) {
159                         $args[0] = $lang->_($args[0]);
160                         return call_user_func_array('printf', $args);
161                 }
162                 return '';
163         }
164 }
165 class JRequest
166 {
167         public static function getURI()
168         {
169                 global $gEnvManager;
170                 
171                 return $gEnvManager->getCurrentRequestUri();
172         }
173         public static function getMethod()
174         {
175                 $method = strtoupper($_SERVER['REQUEST_METHOD']);
176                 return $method;
177         }
178         public static function getVar($name, $default = null, $hash = 'default', $type = 'none', $mask = 0)
179         {
180                 global $gRequestManager;
181                 
182                 return $gRequestManager->trimValueOf($name);
183         }
184         public static function getInt($name, $default = 0, $hash = 'default')
185         {
186                 return intval(self::getVar($name, $default, $hash, 'int'));
187         }
188         public static function getFloat($name, $default = 0.0, $hash = 'default')
189         {
190                 return self::getVar($name, $default, $hash, 'float');
191         }
192         public static function getBool($name, $default = false, $hash = 'default')
193         {
194                 return self::getVar($name, $default, $hash, 'bool');
195         }
196         public static function getWord($name, $default = '', $hash = 'default')
197         {
198                 return self::getVar($name, $default, $hash, 'word');
199         }
200         public static function getCmd($name, $default = '', $hash = 'default')
201         {
202                 return self::getVar($name, $default, $hash, 'cmd');
203         }
204         public static function getString($name, $default = '', $hash = 'default', $mask = 0)
205         {
206                 return self::getVar($name, $default, $hash, 'string', $mask);
207         }
208 }
209 class JConfig {
210         /**
211         * -------------------------------------------------------------------------
212         * Site configuration section
213         * -------------------------------------------------------------------------
214         */
215         /* Site Settings */
216         var $offline = '0';
217         var $offline_message = 'This site is down for maintenance.<br /> Please check back again soon.';
218         var $sitename = 'Joomla!';                      // Name of Joomla site
219         var $editor = 'tinymce';
220         var $list_limit = '20';
221         var $legacy = '0';
222
223         /**
224         * -------------------------------------------------------------------------
225         * Database configuration section
226         * -------------------------------------------------------------------------
227         */
228         /* Database Settings */
229         var $dbtype = 'mysql';                                  // Normally mysql
230         var $host = 'localhost';                                // This is normally set to localhost
231         var $user = '';                                                 // MySQL username
232         var $password = '';                                             // MySQL password
233         var $db = '';                                                   // MySQL database name
234         var $dbprefix = 'jos_';                                 // Do not change unless you need to!
235
236         /* Server Settings */
237         var $secret = 'FBVtggIk5lAzEU9H';               //Change this to something more secure
238         var $gzip = '0';
239         var $error_reporting = '-1';
240         var $helpurl = 'http://help.joomla.org';
241         var $xmlrpc_server = '1';
242         var $ftp_host = '';
243         var $ftp_port = '';
244         var $ftp_user = '';
245         var $ftp_pass = '';
246         var $ftp_root = '';
247         var $ftp_enable = '';
248         var $tmp_path   = '/tmp';
249         var $log_path   = '/var/logs';
250         var $offset = '0';
251         var $live_site = '';                                    // Optional, Full url to Joomla install.
252         var $force_ssl = 0;             //Force areas of the site to be SSL ONLY.  0 = None, 1 = Administrator, 2 = Both Site and Administrator
253
254         /* Session settings */
255         var $lifetime = '15';                                   // Session time
256         var $session_handler = 'database';
257
258         /* Mail Settings */
259         var $mailer = 'mail';
260         var $mailfrom = '';
261         var $fromname = '';
262         var $sendmail = '/usr/sbin/sendmail';
263         var $smtpauth = '0';
264         var $smtpuser = '';
265         var $smtppass = '';
266         var $smtphost = 'localhost';
267
268         /* Cache Settings */
269         var $caching = '0';
270         var $cachetime = '15';
271         var $cache_handler = 'file';
272
273         /* Debug Settings */
274         var $debug      = '0';
275         var $debug_db   = '0';
276         var $debug_lang = '0';
277
278         /* Meta Settings */
279         var $MetaDesc = 'Joomla! - the dynamic portal engine and content management system';
280         var $MetaKeys = 'joomla, Joomla';
281         var $MetaTitle = '1';
282         var $MetaAuthor = '1';
283
284         /* SEO Settings */
285         var $sef = '0';
286         var $sef_rewrite = '0';
287         var $sef_suffix = '';
288
289         /* Feed Settings */
290         var $feed_limit   = 10;
291         var $feed_email   = 'author';
292         
293         /**
294          * コンストラクタ
295          */
296         function __construct()
297         {
298                 global $gEnvManager;
299                 
300                 $this->sitename = $gEnvManager->getSiteName();// サイト名称
301                 $this->tmp_path = $gEnvManager->getWorkDirPath();               // 一時ディレクトリ
302         }
303 }
304 /**
305  * Version information class for the Joomla CMS.
306  * テンプレートからは、RELEASE値以外はまず使用されない
307  *
308  * @package  Joomla.Site
309  * @since    1.0
310  */
311 final class JVersion
312 {
313         /** @var  string  Product name. */
314         public $PRODUCT = 'Joomla!';
315
316         /** @var  string  Release version. */
317 //      public $RELEASE = '1.7';
318 //      public $RELEASE = '1.5';
319         public $RELEASE = '3.0';
320         
321         /** @var  string  Maintenance version. */
322         public $DEV_LEVEL = '1';
323
324         /** @var  string  Development STATUS. */
325         public $DEV_STATUS = 'Stable';
326
327         /** @var  string  Build number. */
328         public $BUILD = '';
329
330         /** @var  string  Code name. */
331         public $CODENAME = 'Ember';
332
333         /** @var  string  Release date. */
334         public $RELDATE = '26-Sep-2011';
335
336         /** @var  string  Release time. */
337         public $RELTIME = '14:00';
338
339         /** @var  string  Release timezone. */
340         public $RELTZ = 'GMT';
341
342         /** @var  string  Copyright Notice. */
343         public $COPYRIGHT = 'Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.';
344
345         /** @var  string  Link text. */
346         public $URL = '<a href="http://www.joomla.org">Joomla!</a> is Free Software released under the GNU General Public License.';
347
348         /**
349          * Compares two a "PHP standardized" version number against the current Joomla version.
350          *
351          * @param   string  $minimum  The minimum version of the Joomla which is compatible.
352          *
353          * @return  bool    True if the version is compatible.
354          *
355          * @see     http://www.php.net/version_compare
356          * @since   1.0
357          */
358         public function isCompatible($minimum)
359         {
360                 return version_compare(JVERSION, $minimum, 'ge');
361         }
362
363         /**
364          * Method to get the help file version.
365          *
366          * @return  string  Version suffix for help files.
367          *
368          * @since   1.0
369          */
370         public function getHelpVersion()
371         {
372                 if ($this->RELEASE > '1.0') {
373                         return '.' . str_replace('.', '', $this->RELEASE);
374                 }
375                 else {
376                         return '';
377                 }
378         }
379
380         /**
381          * Gets a "PHP standardized" version string for the current Joomla.
382          *
383          * @return  string  Version string.
384          *
385          * @since   1.5
386          */
387         public function getShortVersion()
388         {
389                 return $this->RELEASE.'.'.$this->DEV_LEVEL;
390         }
391
392         /**
393          * Gets a version string for the current Joomla with all release information.
394          *
395          * @return  string  Complete version string.
396          *
397          * @since   1.5
398          */
399         public function getLongVersion()
400         {
401                 return $this->PRODUCT.' '. $this->RELEASE.'.'.$this->DEV_LEVEL.' '
402                                 . $this->DEV_STATUS.' [ '.$this->CODENAME.' ] '.$this->RELDATE.' '
403                                 .$this->RELTIME.' '.$this->RELTZ;
404         }
405
406         /**
407          * Returns the user agent.
408          *
409          * @param   string  $component    Name of the component.
410          * @param   bool    $mask         Mask as Mozilla/5.0 or not.
411          * @param   bool    $add_version  Add version afterwards to component.
412          *
413          * @return  string  User Agent.
414          *
415          * @since   1.0
416          */
417         public function getUserAgent($component = null, $mask = false, $add_version = true)
418         {
419                 if ($component === null) {
420                         $component = 'Framework';
421                 }
422
423                 if ($add_version) {
424                         $component .= '/'.$this->RELEASE;
425                 }
426
427                 // If masked pretend to look like Mozilla 5.0 but still identify ourselves.
428                 if ($mask) {
429                         return 'Mozilla/5.0 '. $this->PRODUCT .'/'. $this->RELEASE . '.'.$this->DEV_LEVEL . ($component ? ' '. $component : '');
430                 }
431                 else {
432                         return $this->PRODUCT .'/'. $this->RELEASE . '.'.$this->DEV_LEVEL . ($component ? ' '. $component : '');
433                 }
434         }
435 }
436
437 // Define the Joomla version if not already defined.
438 if (!defined('JVERSION')) {
439         $jversion = new JVersion;
440         define('JVERSION', $jversion->getShortVersion());
441 }
442
443 ?>