| 1: | <?php |
| 2: | /** |
| 3: | * XOOPS Utilities |
| 4: | * |
| 5: | * You may not change or alter any portion of this comment or credits |
| 6: | * of supporting developers from this source code or any supporting source code |
| 7: | * which is considered copyrighted (c) material of the original comment or credit authors. |
| 8: | * This program is distributed in the hope that it will be useful, |
| 9: | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10: | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 11: | * |
| 12: | * @copyright (c) 2000-2016 XOOPS Project (www.xoops.org) |
| 13: | * @license GNU GPL 2 (https://www.gnu.org/licenses/gpl-2.0.html) |
| 14: | * @package class |
| 15: | * @subpackage utility |
| 16: | * @since 2.3.0 |
| 17: | * @author Taiwen Jiang <phppp@users.sourceforge.net> |
| 18: | */ |
| 19: | defined('XOOPS_ROOT_PATH') || exit('Restricted access'); |
| 20: | |
| 21: | /** |
| 22: | * XoopsUtility |
| 23: | * |
| 24: | * @package |
| 25: | * @author John |
| 26: | * @copyright (c) 2000-2016 XOOPS Project (www.xoops.org) |
| 27: | * @access public |
| 28: | */ |
| 29: | class XoopsUtility |
| 30: | { |
| 31: | /** |
| 32: | * Constructor |
| 33: | */ |
| 34: | public function __construct() |
| 35: | { |
| 36: | } |
| 37: | |
| 38: | /** |
| 39: | * XoopsUtility::recursive() |
| 40: | * |
| 41: | * @param mixed $handler |
| 42: | * @param mixed $data |
| 43: | * |
| 44: | * @return array|mixed |
| 45: | */ |
| 46: | public static function recursive($handler, $data) |
| 47: | { |
| 48: | if (is_array($data)) { |
| 49: | $return = array_map(array( |
| 50: | 'XoopsUtility', |
| 51: | 'recursive'), $handler, $data); |
| 52: | |
| 53: | return $return; |
| 54: | } |
| 55: | // single function |
| 56: | if (is_string($handler)) { |
| 57: | return function_exists($handler) ? $handler($data) : $data; |
| 58: | } |
| 59: | // Method of a class |
| 60: | if (is_array($handler)) { |
| 61: | return call_user_func(array( |
| 62: | $handler[0], |
| 63: | $handler[1]), $data); |
| 64: | } |
| 65: | |
| 66: | return $data; |
| 67: | } |
| 68: | } |
| 69: |