Exemple #1
0
/**
 * Trigger specific event with a given parameters
 * 
 * $result is start value of result. It determines how data returned from 
 * callback functions will be handled. If $result is:
 * 
 * - array - values will be added as new elements
 * - integer or float - values will be added to the $result
 * - string - values will be appended to current value
 * - null - values returned from callback functions are ignored
 * 
 * If callback function returns FALSE executen is stopped and result made to 
 * that point is retuned
 * 
 * WARNING: $result is not passed by reference
 *
 * @param string $event
 * @param array $params
 * @param mixed $result
 * @return mixed
 */
function event_trigger($event, $params = array(), $result = null)
{
    static $instance = false;
    if ($instance === false) {
        $instance =& EventsManager::instance();
    }
    // if
    return $instance->trigger($event, $params, $result);
}
define('EVENT_REPLACE', 0);
define('EVENT_PRE', -1);
/**
 *  Constants to define scope of the includes
 */
define('INCLUDE_NO_GLOBALS', 0);
// include with local scope without global vars, all globals must be declared explicitly (recommended for development)
define('INCLUDE_R_GLOBALS', 1);
// include with extract($GLOBALS) - all global values are available in local scope
define('INCLUDE_RW_GLOBALS', 2);
// include with declared all global vars (default)
global $app_main_dir, $eventsManager, $includesManager;
require_once $app_main_dir . '/include/lib/events/EventsManager.class.php';
require_once $app_main_dir . '/include/lib/events/EventReturn.class.php';
require_once $app_main_dir . '/include/lib/events/IncludesManager.class.php';
$eventsManager =& EventsManager::instance();
$includesManager =& IncludesManager::instance();
/** EVENTS MECHANISM **/
/**
 * Subscribe $callback to an $event
 *
 * $events can be an array of events or single even name
 *
 * @param array $events
 * @param string $callback
 * @param integer $type
 * @return null
 */
function cw_event_listen($event, $callback, $type = EVENT_POST)
{
    global $eventsManager;
 /**
  * Construct Angie application instance
  *
  * @param void
  * @return AngieApplication
  */
 function __construct()
 {
     $this->router =& Router::instance();
     $this->events_manager =& EventsManager::instance();
     $this->smarty =& Smarty::instance();
 }