OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / include / mos / mosFunc.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-2009 Magic3 Project.
12  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
13  * @version    SVN: $Id: mosFunc.php 3903 2010-12-21 07:49:58Z fishbone $
14  * @link       http://www.magic3.org
15  */
16 /**
17 * Cache some modules information
18 * @return array
19 */
20 function &initModules()
21 {
22         return true;
23 }
24 /**
25 * @param string THe template position
26 */
27 function mosCountModules($position = 'left')
28 {
29         global $gPageManager;
30         $count = $gPageManager->getWidgetsCount($position);
31         return $count;
32 }
33 /**
34 * @param string The position
35 * @param int The style.  0=normal, 1=horiz, -1=no wrapper
36 */
37 function mosLoadModules($position='left', $style=0)
38 {
39         global $gPageManager;
40         echo $gPageManager->getContents($position);
41 }
42 function mosShowHead()
43 {
44         global $gPageManager;
45         $gPageManager->getHeader();
46 }
47 /**
48 * Displays the capture output of the main element
49 */
50 function mosMainBody()
51 {
52         global $gPageManager;
53         echo $gPageManager->getContents('main');
54 }
55 /**
56 * BODYタグにスタイルを付加(Magic3専用)
57 */
58 function mosBodyStyle()
59 {
60         global $gPageManager;
61         
62         echo $gPageManager->getBodyStyle();
63 }
64 /**
65 * Utility functions and classes
66 */
67 function mosLoadComponent( $name ) {
68 }
69 /**
70 * Returns current date according to current local and time offset
71 * @param string format optional format for strftime
72 * @returns current date
73 */
74 function mosCurrentDate( $format="" ) {
75         global $mosConfig_offset;
76         if ($format=="") {
77                 $format = _DATE_FORMAT_LC;
78         }
79         $date = strftime( $format, time() + ($mosConfig_offset*60*60) );
80         return $date;
81 }
82 /**
83  * Utility function to return a value from a named array or a specified default
84  * @param array A named array
85  * @param string The key to search for
86  * @param mixed The default value to give if no key found
87  * @param int An options mask: _MOS_NOTRIM prevents trim, _MOS_ALLOWHTML allows safe html, _MOS_ALLOWRAW allows raw input
88  */
89 define( "_MOS_NOTRIM", 0x0001 );
90 define( "_MOS_ALLOWHTML", 0x0002 );
91 define( "_MOS_ALLOWRAW", 0x0004 );
92 function mosGetParam( &$arr, $name, $def=null, $mask=0 ) {
93         static $noHtmlFilter    = null;
94         static $safeHtmlFilter  = null;
95
96         $return = null;
97         if (isset( $arr[$name] )) {
98                 $return = $arr[$name];
99                 
100                 if (is_string( $return )) {
101                         // trim data
102                         if (!($mask&_MOS_NOTRIM)) {
103                                 $return = trim( $return );
104                         }
105                         
106                         if ($mask&_MOS_ALLOWRAW) {
107                                 // do nothing
108                         } else if ($mask&_MOS_ALLOWHTML) {
109                                 // do nothing - compatibility mode
110                                 /*
111                                 if (is_null( $safeHtmlFilter )) {
112                                         $safeHtmlFilter = new InputFilter( null, null, 1, 1 );
113                                 }
114                                 $arr[$name] = $safeHtmlFilter->process( $arr[$name] );
115                                 */
116                         } else {
117                                 // send to inputfilter
118                                 if (is_null( $noHtmlFilter )) {
119                                         $noHtmlFilter = new InputFilter( /* $tags, $attr, $tag_method, $attr_method, $xss_auto */ );
120                                 }
121                                 $return = $noHtmlFilter->process( $return );
122                         }
123                         
124                         // account for magic quotes setting
125                         if (!get_magic_quotes_gpc()) {
126                                 $return = addslashes( $return );
127                         }
128                 }
129                 
130                 return $return;
131         } else {
132                 return $def;
133         }
134 }
135 /*
136 * Includes pathway file
137 */
138 function mosPathWay() {
139 }
140 ?>