[ Index ] |
|
Code source de Plume CMS 1.2.2 |
1 <?php 2 /* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 3 /* 4 # ***** BEGIN LICENSE BLOCK ***** 5 # This file is part of Plume CMS, a website management application. 6 # Copyright (C) 2001-2005 Loic d'Anterroches and contributors. 7 # 8 # Plume CMS is free software; you can redistribute it and/or modify 9 # it under the terms of the GNU General Public License as published by 10 # the Free Software Foundation; either version 2 of the License, or 11 # (at your option) any later version. 12 # 13 # Plume CMS is distributed in the hope that it will be useful, 14 # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 # GNU General Public License for more details. 17 # 18 # You should have received a copy of the GNU General Public License 19 # along with this program; if not, write to the Free Software 20 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 # 22 # ***** END LICENSE BLOCK ***** */ 23 24 /** 25 * Hook. 26 */ 27 class Hook 28 { 29 30 /** 31 * Run a hook. 32 * 33 * @param string Hook to be run 34 * @param array Parameters 35 * @return bool Success 36 */ 37 function run($hook, $params=array()) 38 { 39 $success = true; 40 if (!empty($GLOBALS['_PX_hook'][$hook])) { 41 foreach ($GLOBALS['_PX_hook'][$hook] as $key => $val) { 42 $res = call_user_func(array($val[0], $val[1]), $hook, $params); 43 if ($res === false) { 44 $success = false; 45 } 46 } 47 } 48 return $success; 49 } 50 51 52 /** 53 * Register a hook. 54 * 55 * @param string Name of the hook 56 * @param string Plugin name 57 * @param string Method of the plugin 58 * @return bool Success 59 */ 60 function register($hook, $plugin, $method) 61 { 62 if (!isset($GLOBALS['_PX_hook'])) { 63 $GLOBALS['_PX_hook'] = array(); 64 } 65 if (!isset($GLOBALS['_PX_hook'][$hook])) { 66 $GLOBALS['_PX_hook'][$hook] = array(); 67 } 68 $GLOBALS['_PX_hook'][$hook][] = array($plugin, $method); 69 return true; 70 } 71 } 72 73 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 11:57:01 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |