HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/PvdBoogaard/indoorski.nl/backup/oude-site/cms/api/class.event.php
<?php
/**
* This file contains the base / core event system functionality for IWP, including a full list of events which are registered by default.
*
* @package IWP
* @subpackage Event
*/

//	include the InterspireEvent library
IWP::GetLib('interspire_event/interspireevent');

/**
 * iwp_event_base class
 * IWP-specific extension of InterspireEventData
 * @see InterspireEventData
 * @package IWP
 * @subpackage Event
 */
class iwp_event_base extends InterspireEventData {
	/**
	 * __construct
	 * @see InterspireEventData::__construct()
	 */
	public function __construct ($cancelable = true) {
		parent::__construct($cancelable);
	}

	/**
	* Trigger the event associated with this event data class.
	*
	* @param boolean $removeListenerWhenLoadFailed
	* @return boolean
	*/
	public function trigger ($removeListenerWhenLoadFailed = false) {
		return iwp_event::trigger($this, $removeListenerWhenLoadFailed);
	}
}

/**
 * iwp_event_empty class
 * Generic event data class with no data
 * @package IWP
 * @subpackage Event
 */
class iwp_event_empty extends iwp_event_base { }

class iwp_event_init extends iwp_event_empty { }

/**
 * iwp_event class
 * IWP-specific extension of InterspireEvent
 * @see InterspireEvent
 * @package IWP
 * @subpackage Event
 */
class iwp_event extends InterspireEvent
{
	/**
	 * An instance of iwp_eventstash for storing event and listener information.
	 *
	 * @var iwp_eventstash
	 */
	private static $_stash;

	/**
	 * List of events that are published in IWP
	 */
	private static $eventList = array(
			'iwp_event_init' => array(),
			/* admin events */
			'iwp_event_admin_auth_showloginpage' => array(),
			'iwp_event_admin_auth_showforgotpasswordpage' => array(),
			'iwp_event_admin_auth_forgotpassworduserquery' => array(),
			'iwp_event_admin_auth_forgotpassworduserquerymd5' => array(),
			'iwp_event_admin_auth_loggingout' => array(),
			'iwp_event_admin_auth_loggedout' => array(),
			'iwp_event_admin_auth_loggingin' => array(),
			'iwp_event_admin_auth_loggedin' => array(),
			'iwp_event_admin_auth_loginfailed' => array(),
			'iwp_event_admin_index_beforetemplate' => array(),
			'iwp_event_admin_index_aftertemplate' => array(),
			'iwp_event_admin_navigation_textmenucreated' => array(),
			'iwp_event_admin_navigation_dropdownmenucreated' => array(),
			'iwp_event_admin_categories_beforedelete' => array(),
			'iwp_event_admin_categories_afterdelete' => array(),
			'iwp_event_admin_categories_view' => array(),
			'iwp_event_admin_categories_createform' => array(),
			'iwp_event_admin_categories_editform' => array(),
			'iwp_event_admin_categories_beforeeditsave' => array(),
			'iwp_event_admin_categories_aftereditsave' => array(),
			'iwp_event_admin_categories_afterorder' => array(),
			'iwp_event_admin_categories_getdisplayfields' => array(),
			'iwp_event_admin_categories_getviewlist' => array(),
			'iwp_event_admin_categories_generatesortingcache' => array(),
			'iwp_event_admin_content_view' => array(),
			'iwp_event_admin_content_createform' => array(),
			'iwp_event_admin_content_editform' => array(),
			'iwp_event_admin_content_urlbrowser' => array(),
			'iwp_event_admin_content_tinymceplugin' => array(),
			'iwp_event_admin_home_pendinglistcreated' => array(),
			'iwp_event_admin_home_ataglancelistcreated' => array(),

			/* front end events */
			'iwp_event_lists_dynamicoutput' => array(),
			'iwp_event_controller_showtemplate' => array(),
			'iwp_event_categories_beforeshowtemplate' => array(),
			'iwp_event_template_outputblockbeforeparsesection' => array(),
			'iwp_event_user_beforeprofiledisplay' => array(),

			/* api events */
			'iwp_event_content_afterdbload' => array(),
			'iwp_event_content_beforedisplay' => array(),
			'iwp_event_content_beforedelete' => array(),
			'iwp_event_content_afterdelete' => array(),

			/* lib events */
			'InterspireTemplate_BeforeTemplateIncluded' => array(),
			'InterspireTemplate_AfterTemplateIncluded' => array(),
			'InterspireTemplate_TemplateCaptured' => array(),
			'InterspireTemplate_BeforeUncachedTemplateParsed' => array(),
			'InterspireTemplate_AfterUncachedTemplateParsed' => array(),
			'InterspireTemplate_BeforeTemplateCached' => array(),
			'InterspireTemplate_AfterTemplateCached' => array(),
		);

	/**
	 * IWP-specific extension of InterspireEvent::init()
	 * @see InterspireEvent::init()
	 */
	public static function init ()
	{
		//	create our stash
		iwp_event::$_stash = iwp_eventstash::getInstance();

		//	initialise the event system
		parent::init(iwp_event::$_stash, false);

		//	fire an even to signal the event system has been initialised
		try
		{
			iwp_event::trigger(new iwp_event_init());
		}
		catch (InterspireEventException $e)
		{
			//	event system initiated but events not yet registered
			//	suppress this error so the init can continue, as the install procedure is probably about to run
		}
	}

	/**
	 * Removes all known listeners for a given event.
	 *
	 * @param string $eventName The name of the event to remove listeners for.
	 *
	 * @return void
	 */
	public static function removeAllListeners ($eventName)
	{
		$listeners = iwp_event::eventListenerList($eventName);
		foreach ($listeners as $listener) {
			iwp_event::listenerUnregister($eventName, $listener['function'], $listener['file'], $listener['priority']);
		}
	}

	/**
	 * trigger
	 * IWP-specific extension of trigger to force usage of the iwp_event_base class as event data
	 * @see InterspireEvent::trigger()
	 */
	static public function trigger (iwp_event_base $data = null, $removeListenerWhenLoadFailed = true)
	{
		$eventName = get_class($data);

		$return = false;

		try {
			$return = parent::trigger($eventName, $data, $removeListenerWhenLoadFailed);
		} catch (InterspireEventException $e) {

			if($e->getCode() == InterspireEventException::EVENT_NOT_EXISTS &&
			array_key_exists($eventName, self::$eventList)) {
				iwp_event::eventCreate($eventName);
				try {
					$return = parent::trigger($eventName, $data, $removeListenerWhenLoadFailed);
				} catch (InterspireEventException $e) {
					$return = false;
				}
			} else {
				$return = false;
			}
		}

		return $return;
	}

	/**
	 * Removes all registered events and associated listeners.
	 *
	 */
	public static function removeAllEvents ()
	{
		$events = iwp_event::eventList();
		foreach ($events as $eventName) {
			iwp_event::removeAllListeners($eventName);
			iwp_event::eventRemove($eventName);
		}
	}

	/**
	 * Creates all standard IWP events and default listeners.
	 *
	 * @return void
	 */
	public static function createEvents ()
	{
		//	list of standard events and listeners to create
		foreach (self::$eventList as $eventName => $listeners) {
			if (!iwp_event::eventExists($eventName)) {
				iwp_event::eventCreate($eventName);
			}

			foreach ($listeners as $listener) {
				$function = $listener[0];
				$file = $listener[1];
				$priority = $listener[2];

				if (!iwp_event::listenerExists($eventName, $function, $file, $priority)) {
					iwp_event::listenerRegister($eventName, $function, $file, $priority);
				}
			}
		}
	}
}