XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
functions.ini.php
Go to the documentation of this file.
1 <?php
14 if (substr(XOOPS_VERSION, 0, 9) < "XOOPS 2.3") {
15  trigger_error( "The package only works for XOOPS 2.3+", E_USER_ERROR );
16 }
17 
18 if (!defined("FRAMEWORKS_ART_FUNCTIONS_INI")):
19 define("FRAMEWORKS_ART_FUNCTIONS_INI", true);
20 
21 define("FRAMEWORKS_ROOT_PATH", XOOPS_ROOT_PATH . "/Frameworks");
22 
30 function load_objectHandler($handler = "", $dirname = "art")
31 {
32  if (empty($handler)) {
33  $handlerClass = "ArtObject";
34  $fileName = "object.php";
35  } else {
36  $handlerClass = "ArtObject".ucfirst($handler)."Handler";
37  $fileName = "object.{$handler}.php";
38  }
39 
40  class_exists($handlerClass) || require_once FRAMEWORKS_ROOT_PATH . "/{$dirname}/{$fileName}";
41  return class_exists($handlerClass);
42 }
43 
44 
45 function load_object()
46 {
47  return load_objectHandler();
48 }
49 
56 function load_functions($group = "", $dirname = "art")
57 {
58  $dirname = ("" == $dirname ) ? "art" : $dirname;
59  $constant = strtoupper( "frameworks_{$dirname}_functions" . (($group) ? "_{$group}" : ""));
60  if (defined($constant)) return true;
61  return include_once FRAMEWORKS_ROOT_PATH . "/{$dirname}/functions.{$group}" . (empty($group) ? "" : "." ) . "php";
62 }
63 
64 
77 function mod_loadFunctions($group = "", $dirname = "")
78 {
79  $dirname = !empty($dirname) ? $dirname : $GLOBALS["xoopsModule"]->getVar("dirname", "n");
80  $constant = strtoupper( "{$dirname}_functions" . ( ($group) ? "_{$group}" : "" ) . "_loaded" );
81  if (defined($constant)) return true;
82  $filename = XOOPS_ROOT_PATH . "/modules/{$dirname}/include/functions.{$group}" . (empty($group) ? "" : "." ) . "php";
83  return include_once $filename;
84 }
85 
96 function mod_loadRenderer($class, $dirname = "")
97 {
98  $dirname = !empty($dirname) ? $dirname : $GLOBALS["xoopsModule"]->getVar("dirname", "n");
99  $renderer = ucfirst($dirname) . ucfirst($class) . "Renderer";
100  if (!class_exists($renderer)) {
101  require_once XOOPS_ROOT_PATH . "/modules/{$dirname}/class/{$class}.renderer.php";
102  }
103  $instance = eval("{$renderer}::instance()");
104  return $instance;
105 }
106 
112 if (!function_exists("mod_constant")) {
113 function mod_constant($name)
114 {
115  if (!empty($GLOBALS["VAR_PREFIXU"]) && @defined($GLOBALS["VAR_PREFIXU"] . "_" . strtoupper($name))) {
116  return CONSTANT($GLOBALS["VAR_PREFIXU"] . "_" . strtoupper($name));
117  } elseif (!empty($GLOBALS["xoopsModule"]) && @defined(strtoupper($GLOBALS["xoopsModule"]->getVar("dirname", "n") . "_" . $name))) {
118  return CONSTANT(strtoupper($GLOBALS["xoopsModule"]->getVar("dirname", "n") . "_" . $name));
119  } elseif (defined(strtoupper($name))) {
120  return CONSTANT(strtoupper($name));
121  } else {
122  return str_replace("_", " ", strtolower($name));
123  }
124 }
125 }
126 
133 if (!function_exists("mod_DB_prefix")) {
134 function mod_DB_prefix($name, $isRel = false)
135 {
136  $relative_name = $GLOBALS["MOD_DB_PREFIX"] . "_" . $name;
137  if ($isRel) return $relative_name;
138  return $GLOBALS["xoopsDB"]->prefix($relative_name);
139 }
140 }
141 
147 if (!function_exists("xoops_message")):
148 function xoops_message( $message, $userlevel = 0)
149 {
150  global $xoopsUser;
151 
152  if (!$xoopsUser) $level = 0;
153  elseif ($xoopsUser->isAdmin()) $level = 99;
154  else $level = 1;
155  if ($userlevel > $level) return;
156 
157  echo "<div style=\"clear:both\"> </div>";
158  if (is_array($message) || is_object($message)) {
159  echo "<div><pre>";
160  print_r($message);
161  echo "</pre></div>";
162  } else {
163  echo "<div>{$message}</div>";
164  }
165  echo "<div style=\"clear:both\"> </div>";
166 }
167 endif;
168 function mod_message( $message )
169 {
170  global $xoopsModuleConfig;
171  if (!empty($xoopsModuleConfig["do_debug"])) {
172  if (is_array($message) || is_object($message)) {
173  echo "<div><pre>";
174  print_r($message);
175  echo "</pre></div>";
176  } else {
177  echo "<div>$message</div>";
178  }
179  }
180  return true;
181 }
182 
190 {
191  if ( DIRECTORY_SEPARATOR != '/' ) $current_path = str_replace( strpos( $current_path, '\\\\', 2 ) ? '\\\\' : DIRECTORY_SEPARATOR, '/', $current_path);
192  $url_arr = explode('/', strstr($current_path, '/modules/'));
193  return $url_arr[2];
194 }
195 
205 function mod_isModuleAction($dirname = "system")
206 {
207  $ret = @(
208  // action module "system"
209  !empty($GLOBALS["xoopsModule"]) && "system" == $GLOBALS["xoopsModule"]->getVar("dirname", "n")
210  &&
211  // current dirname
212  ($dirname == $_POST["dirname"] || $dirname == $_POST["module"])
213  &&
214  // current op
215  ("update_ok" == $_POST["op"] || "install_ok" == $_POST["op"] || "uninstall_ok" == $_POST["op"])
216  &&
217  // current action
218  "modulesadmin" == $_POST["fct"]
219  );
220  return $ret;
221 }
222 
223 endif;
224 ?>