7 * LICENSE: This source file is licensed under the terms of the GNU General Public License.
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
17 * Cache some modules information
20 function &initModules()
25 * @param string THe template position
27 function mosCountModules($position = 'left')
30 $count = $gPageManager->getWidgetsCount($position);
34 * @param string The position
35 * @param int The style. 0=normal, 1=horiz, -1=no wrapper
37 function mosLoadModules($position='left', $style=0)
40 echo $gPageManager->getContents($position);
42 function mosShowHead()
45 $gPageManager->getHeader();
48 * Displays the capture output of the main element
50 function mosMainBody()
53 echo $gPageManager->getContents('main');
56 * BODYタグにスタイルを付加(Magic3専用)
58 function mosBodyStyle()
62 echo $gPageManager->getBodyStyle();
65 * Utility functions and classes
67 function mosLoadComponent( $name ) {
70 * Returns current date according to current local and time offset
71 * @param string format optional format for strftime
72 * @returns current date
74 function mosCurrentDate( $format="" ) {
75 global $mosConfig_offset;
77 $format = _DATE_FORMAT_LC;
79 $date = strftime( $format, time() + ($mosConfig_offset*60*60) );
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
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;
97 if (isset( $arr[$name] )) {
98 $return = $arr[$name];
100 if (is_string( $return )) {
102 if (!($mask&_MOS_NOTRIM)) {
103 $return = trim( $return );
106 if ($mask&_MOS_ALLOWRAW) {
108 } else if ($mask&_MOS_ALLOWHTML) {
109 // do nothing - compatibility mode
111 if (is_null( $safeHtmlFilter )) {
112 $safeHtmlFilter = new InputFilter( null, null, 1, 1 );
114 $arr[$name] = $safeHtmlFilter->process( $arr[$name] );
117 // send to inputfilter
118 if (is_null( $noHtmlFilter )) {
119 $noHtmlFilter = new InputFilter( /* $tags, $attr, $tag_method, $attr_method, $xss_auto */ );
121 $return = $noHtmlFilter->process( $return );
124 // account for magic quotes setting
125 if (!get_magic_quotes_gpc()) {
126 $return = addslashes( $return );
136 * Includes pathway file
138 function mosPathWay() {