From: <tr...@us...> - 2012-12-10 21:22:16
|
Revision: 10352 http://sourceforge.net/p/xoops/svn/10352 Author: trabis Date: 2012-12-10 21:22:11 +0000 (Mon, 10 Dec 2012) Log Message: ----------- Creating Xoops_Utils to hold methods that dont deserve a specific class. Dropping Xoops_Debug Modified Paths: -------------- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/theme_blocks.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/codex/cache.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/codex/form.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/codex/pdf.php XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops.php Added Paths: ----------- XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Utils.php Removed Paths: ------------- XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Debug.php Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/theme_blocks.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/theme_blocks.php 2012-12-10 19:59:49 UTC (rev 10351) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/theme_blocks.php 2012-12-10 21:22:11 UTC (rev 10352) @@ -197,7 +197,7 @@ if ($this->theme && $bcachetime) { $metas = array(); foreach ($this->theme->metas as $type => $value) { - $dif = $xoops->arrayRecursiveDiff($this->theme->metas[$type], $old[$type]); + $dif = Xoops_Utils::arrayRecursiveDiff($this->theme->metas[$type], $old[$type]); if (count($dif)) { $metas[$type] = $dif; } Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/codex/cache.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/codex/cache.php 2012-12-10 19:59:49 UTC (rev 10351) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/codex/cache.php 2012-12-10 21:22:11 UTC (rev 10352) @@ -56,5 +56,5 @@ echo '<a href="?nodelete">Refresh</a> - <a href="?delete">Delete caches</a>'; -Xoops_Debug::dumpFile(__FILE__ ); +Xoops_Utils::dumpFile(__FILE__ ); $xoops->footer(); Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/codex/form.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/codex/form.php 2012-12-10 19:59:49 UTC (rev 10351) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/codex/form.php 2012-12-10 21:22:11 UTC (rev 10352) @@ -22,7 +22,7 @@ $xoops->header(); // Form Horizontal -$form = new XoopsThemeForm('Form Horizontal', 'form_horizontal', 'testform.php', 'post', true, 'horizontal'); +$form = new XoopsThemeForm('Form Horizontal', 'form_horizontal', 'form.php', 'post', true, 'horizontal'); $code = new XoopsFormText('Code', 'code', 2, 25, '','Code...'); $code->setDescription('Description code'); @@ -139,5 +139,5 @@ $form->display(); -Xoops_Debug::dumpFile(__FILE__ ); +Xoops_Utils::dumpFile(__FILE__ ); $xoops->footer(); \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/codex/pdf.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/codex/pdf.php 2012-12-10 19:59:49 UTC (rev 10351) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/codex/pdf.php 2012-12-10 21:22:11 UTC (rev 10352) @@ -21,7 +21,7 @@ $xoops = Xoops::getInstance(); if (isset($_GET['pdf'])) { - $content = Xoops_Debug::dump($xoops->getConfigs(), false); + $content = Xoops_Utils::dumpVar($xoops->getConfigs(), false); $tpl = new XoopsTpl(); $tpl->assign('dummy_content' , $content); @@ -34,13 +34,13 @@ } else { $xoops->header(); echo 'Oops, Please install pdf module!'; - Xoops_Debug::dumpFile(__FILE__ ); + Xoops_Utils::dumpFile(__FILE__ ); $xoops->footer(); } } else { $xoops->header(); echo '<a href="?pdf">Make Pdf</a>'; - Xoops_Debug::dumpFile(__FILE__ ); + Xoops_Utils::dumpFile(__FILE__ ); $xoops->footer(); } Deleted: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Debug.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Debug.php 2012-12-10 19:59:49 UTC (rev 10351) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Debug.php 2012-12-10 21:22:11 UTC (rev 10352) @@ -1,73 +0,0 @@ -<?php -/* - You may not change or alter any portion of this comment or credits - of supporting developers from this source code or any supporting source code - which is considered copyrighted (c) material of the original comment or credit authors. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - */ - -/** - * Debug - * - * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ - * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package class - * @since 2.6.0 - * @author trabis <lus...@gm...> - * @version $Id$ - */ - -defined('XOOPS_ROOT_PATH') or die('Restricted access'); - -class Xoops_Debug -{ - /** - * Output a dump of a variable - * - * @param mixed $var variable which will be dumped - * @param bool $echo - * @param bool $exit - * - * @return string - */ - static function dump($var, $echo = true, $exit = false) - { - $myts = MyTextSanitizer::getInstance(); - $msg = $myts->displayTarea(var_export($var, true)); - $msg = "<div style='padding: 5px; font-weight: bold'>{$msg}</div>"; - if (!$echo) { - return $msg; - } - echo $msg; - if ($exit) { - die(); - } - return $msg; - } - - /** - * Output a dump of a file - * - * @param mixed $file file which will be dumped - * @param bool $echo - * @param bool $exit - * - * @return string - */ - static function dumpFile($file, $echo = true, $exit = false) - { - $msg = highlight_file($file, true); - $msg = "<div style='padding: 5px; font-weight: bold'>{$msg}</div>"; - if (!$echo) { - return $msg; - } - echo $msg; - if ($exit) { - die(); - } - return $msg; - } -} \ No newline at end of file Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Utils.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Utils.php (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Utils.php 2012-12-10 21:22:11 UTC (rev 10352) @@ -0,0 +1,99 @@ +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ + +/** + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license http://www.fsf.org/copyleft/gpl.html GNU public license + * @author trabis <lus...@gm...> + * @version $Id$ + */ + +class Xoops_Utils +{ + /** + * Output a dump of a variable + * + * @param mixed $var variable which will be dumped + * @param bool $echo + * @param bool $exit + * + * @return string + */ + static function dumpVar($var, $echo = true, $exit = false) + { + $myts = MyTextSanitizer::getInstance(); + $msg = $myts->displayTarea(var_export($var, true)); + $msg = "<div style='padding: 5px; font-weight: bold'>{$msg}</div>"; + if (!$echo) { + return $msg; + } + echo $msg; + if ($exit) { + die(); + } + return $msg; + } + + /** + * Output a dump of a file + * + * @param mixed $file file which will be dumped + * @param bool $echo + * @param bool $exit + * + * @return string + */ + static function dumpFile($file, $echo = true, $exit = false) + { + $msg = highlight_file($file, true); + $msg = "<div style='padding: 5px; font-weight: bold'>{$msg}</div>"; + if (!$echo) { + return $msg; + } + echo $msg; + if ($exit) { + die(); + } + return $msg; + } + + /** + * Support for recursive array diff + * Needed for php 5.4.3 warning issues + * + * @param array $aArray1 + * @param array $aArray2 + * + * @return array + */ + static function arrayRecursiveDiff(array $aArray1, array $aArray2) + { + $aReturn = array(); + + foreach ($aArray1 as $mKey => $mValue) { + if (array_key_exists($mKey, $aArray2)) { + if (is_array($mValue)) { + $aRecursiveDiff = self::arrayRecursiveDiff($mValue, $aArray2[$mKey]); + if (count($aRecursiveDiff)) { + $aReturn[$mKey] = $aRecursiveDiff; + } + } else { + if ($mValue != $aArray2[$mKey]) { + $aReturn[$mKey] = $mValue; + } + } + } else { + $aReturn[$mKey] = $mValue; + } + } + return $aReturn; + } +} \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Utils.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Added: svn:eol-style + native Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops.php 2012-12-10 19:59:49 UTC (rev 10351) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops.php 2012-12-10 21:22:11 UTC (rev 10352) @@ -1778,40 +1778,6 @@ } /** - * Support for recursive array diff - * Needed for php 5.4.3 warning issues - * - * @todo move to a proper class - * - * @param array $aArray1 - * @param array $aArray2 - * - * @return array - */ - public function arrayRecursiveDiff(array $aArray1, array $aArray2) - { - $aReturn = array(); - - foreach ($aArray1 as $mKey => $mValue) { - if (array_key_exists($mKey, $aArray2)) { - if (is_array($mValue)) { - $aRecursiveDiff = $this->arrayRecursiveDiff($mValue, $aArray2[$mKey]); - if (count($aRecursiveDiff)) { - $aReturn[$mKey] = $aRecursiveDiff; - } - } else { - if ($mValue != $aArray2[$mKey]) { - $aReturn[$mKey] = $mValue; - } - } - } else { - $aReturn[$mKey] = $mValue; - } - } - return $aReturn; - } - - /** * Support for deprecated messages events * * @param $message |