XOOPS  2.6.0
functions.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
32 function system_cleanVars(&$global, $key, $default = '', $type = 'int')
33 {
34  switch ($type) {
35  case 'array':
36  $ret = (isset($global[$key]) && is_array($global[$key])) ? $global[$key] : $default;
37  break;
38  case 'date':
39  $ret = (isset($global[$key])) ? strtotime($global[$key]) : $default;
40  break;
41  case 'string':
42  $ret = (isset($global[$key])) ? filter_var($global[$key], FILTER_SANITIZE_MAGIC_QUOTES) : $default;
43  break;
44  case 'int':
45  default:
46  $ret = (isset($global[$key])) ? filter_var($global[$key], FILTER_SANITIZE_NUMBER_INT) : $default;
47  break;
48  }
49  if ($ret === false) {
50  return $default;
51  }
52  return $ret;
53 }
54 
66 function system_loadLanguage($name, $domain = '', $language = null)
67 {
72  if (empty($name)) {
73  return false;
74  }
75  //for languages already moved into locale
76  $done = array('preferences', 'blocksadmin', 'extensions', 'modulesadmin', 'groups', 'tplsets', 'users');
77  if (in_array($name, $done)) {
78  return false;
79  }
80  $language = empty($language) ? $xoops->getConfig('language') : $language;
81  $path = 'modules/' . $domain . '/language/';
82  if (XoopsLoad::fileExists($file = $xoops->path($path . $language . '/admin/' . $name . '.php'))) {
83  $ret = include_once $file;
84  } else {
85  $ret = include_once $xoops->path($path . 'english/admin/' . $name . '.php');
86  }
87  return $ret;
88 }
89 
95 function system_adminVersion($version, $value = '')
96 {
97  static $tblVersion = array();
98  if (is_array($tblVersion) && array_key_exists($version . '.' . $value, $tblVersion)) {
99  return $tblVersion[$version . '.' . $value];
100  }
102  $path = $xoops->path('modules/system/admin/' . $version . '/xoops_version.php');
104  $modversion = array();
105  include $path;
106  $retvalue = $modversion[$value];
107  $tblVersion[$version . '.' . $value] = $retvalue;
108  return $retvalue;
109  }
110  return '';
111 }
112 
117 function system_AdminIcons($img)
118 {
120  $style = 'default';
121 
122  $url = $xoops->url('modules/system/images/icons/' . $style . '/' . $img);
123  return $url;
124 }
125 
131 {
133 
134  $path = $xoops->path('modules/' . $xoops->module->getVar('dirname', 'n') . '/templates/admin/' . $name . '.tpl');
136  echo $xoops->tpl()->fetch($path);
137  } else {
138  echo "Unable to read " . $name;
139  }
140 }
141 
148 function modify_chmod($value_chmod, $path_file, $id)
149 {
150  $chmod = '<div id="loading_' . $id . '" align="center" style="display:none;">' . '<img src="./images/mimetypes/spinner.gif" title="Loading" alt="Loading" width="12px"/></div>' . '<div id="chmod' . $id . '">' . '<select size="1" onChange="filemanager_modify_chmod(\'' . $path_file . '\', \'' . $id . '\')" name="chmod" id="chmod">';
151  if ($value_chmod == 777) {
152  $chmod .= '<option value="777" selected><span style="color:green">777</span></option>';
153  } else {
154  $chmod .= '<option value="777"><span style="color:green">777</span></option>';
155  }
156 
157  if ($value_chmod == 776) {
158  $chmod .= '<option value="776" selected>776</option>';
159  } else {
160  $chmod .= '<option value="776">776</option>';
161  }
162 
163  if ($value_chmod == 766) {
164  $chmod .= '<option value="766" selected>766</option>';
165  } else {
166  $chmod .= '<option value="766">766</option>';
167  }
168 
169  if ($value_chmod == 666) {
170  $chmod .= '<option value="666" selected>666</option>';
171  } else {
172  $chmod .= '<option value="666">666</option>';
173  }
174 
175  if ($value_chmod == 664) {
176  $chmod .= '<option value="664" selected>664</option>';
177  } else {
178  $chmod .= '<option value="664">664</option>';
179  }
180 
181  if ($value_chmod == 644) {
182  $chmod .= '<option value="644" selected>644</option>';
183  } else {
184  $chmod .= '<option value="644">644</option>';
185  }
186 
187  if ($value_chmod == 444) {
188  $chmod .= '<option value="444" selected><span style="color:red">444</span></option>';
189  } else {
190  $chmod .= '<option value="444">444</option>';
191  }
192 
193  if ($value_chmod == 440) {
194  $chmod .= '<option value="440" selected>440</option>';
195  } else {
196  $chmod .= '<option value="440">440</option>';
197  }
198 
199  if ($value_chmod == 400) {
200  $chmod .= '<option value="400" selected>400</option>';
201  } else {
202  $chmod .= '<option value="400">400</option>';
203  }
204  $chmod .= '</select>';
205 
206  return $chmod;
207 }
$path
Definition: execute.php:31
system_AdminIcons($img)
Definition: functions.php:117
system_loadTemplate($name)
Definition: functions.php:130
static getInstance()
Definition: Xoops.php:160
if(!isset($xoops->paths[$path_type])) if($path_type== 'var') $file
Definition: browse.php:55
system_adminVersion($version, $value= '')
Definition: functions.php:95
modify_chmod($value_chmod, $path_file, $id)
Definition: functions.php:148
$xoops
Definition: admin.php:25
$id
Definition: admin_menu.php:36
static fileExists($file)
Definition: xoopsload.php:506
$type
Definition: misc.php:33
$modversion
$url
Definition: register.php:72
system_cleanVars(&$global, $key, $default= '', $type= 'int')
Definition: functions.php:32
$language
system_loadLanguage($name, $domain= '', $language=null)
Definition: functions.php:66