XOOPS  2.6.0
Utils.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 
20 {
30  static function dumpVar($var, $echo = true, $exit = false)
31  {
33  $msg = $myts->displayTarea(var_export($var, true));
34  $msg = "<div style='padding: 5px; font-weight: bold'>{$msg}</div>";
35  if (!$echo) {
36  return $msg;
37  }
38  echo $msg;
39  if ($exit) {
40  die();
41  }
42  return $msg;
43  }
44 
54  static function dumpFile($file, $echo = true, $exit = false)
55  {
56  $msg = highlight_file($file, true);
57  $msg = "<div style='padding: 5px; font-weight: bold'>{$msg}</div>";
58  if (!$echo) {
59  return $msg;
60  }
61  echo $msg;
62  if ($exit) {
63  die();
64  }
65  return $msg;
66  }
67 
77  static function arrayRecursiveDiff(array $aArray1, array $aArray2)
78  {
79  $aReturn = array();
80 
81  foreach ($aArray1 as $mKey => $mValue) {
82  if (array_key_exists($mKey, $aArray2)) {
83  if (is_array($mValue) AND is_array($aArray2[$mKey])) {
84  $aRecursiveDiff = self::arrayRecursiveDiff($mValue, $aArray2[$mKey]);
85  if (count($aRecursiveDiff)) {
86  $aReturn[$mKey] = $aRecursiveDiff;
87  }
88  } else {
89  if ($mValue != $aArray2[$mKey]) {
90  $aReturn[$mKey] = $mValue;
91  }
92  }
93  } else {
94  $aReturn[$mKey] = $mValue;
95  }
96  }
97  return $aReturn;
98  }
99 
113  static function arrayRecursiveMerge(array $data, $merge)
114  {
115  $args = func_get_args();
116  $return = current($args);
117 
118  while (($arg = next($args)) !== false) {
119  foreach ((array)$arg as $key => $val) {
120  if (!empty($return[$key]) && is_array($return[$key]) && is_array($val)) {
121  $return[$key] = self::arrayRecursiveMerge($return[$key], $val);
122  } elseif (is_int($key)) {
123  if (!in_array($val, $return)) $return[] = $val; // merge only once $val
124  } else {
125  $return[$key] = $val;
126  }
127  }
128  }
129  return $return;
130  }
131 }
static dumpFile($file, $echo=true, $exit=false)
Definition: Utils.php:54
if(!isset($xoops->paths[$path_type])) if($path_type== 'var') $file
Definition: browse.php:55
static dumpVar($var, $echo=true, $exit=false)
Definition: Utils.php:30
if(!is_object($module)||!$module->getVar('isactive')) $msg
Definition: groupperm.php:38
$var
Definition: userinfo.php:125
static arrayRecursiveMerge(array $data, $merge)
Definition: Utils.php:113
$myts
Definition: edituser.php:38
static arrayRecursiveDiff(array $aArray1, array $aArray2)
Definition: Utils.php:77