<?php
/*
 * Copyright (c) 2012, webvariants GbR, http://www.webvariants.de
 *
 * This file is released under the terms of the MIT license. You can find the
 * complete text in the attached LICENSE file or online at:
 *
 * http://www.opensource.org/licenses/mit-license.php
 */

if (defined('_WV24_PATH')) return;
define('_WV24_PATH', dirname(__FILE__).'/');

// Autoloader initialisieren
sly_Loader::addLoadPath(_WV24_PATH.'lib');

// Events initialisieren
$listenerClass = '_WV24_Extensions';
$listeners     = array();

$useInFrontend = sly_Core::config()->get('realurl2/frontend_events', false);

if (sly_Core::isBackend() || $useInFrontend) {
	$listeners = array(
		// Artikel

		'SLY_ART_ADDED'        => 'artAdded',
		'SLY_ART_COPIED'       => 'artAdded',
		'SLY_ART_UPDATED'      => 'artUpdated',
		'SLY_ART_DELETED'      => 'artDeleted',
		'SLY_ART_META_UPDATED' => 'artMetaUpdated',
		'SLY_ART_TO_STARTPAGE' => 'artToStartpage',
		'SLY_ART_MOVED'        => 'artMoved',

		'SLY_ART_META_FORM_FIELDSET' => 'artMetaFormSection',

		// Kategorien

		'SLY_CAT_ADDED'   => 'catAdded',
		'SLY_CAT_UPDATED' => 'catUpdated',
		'SLY_CAT_DELETED' => 'catDeleted',
		'CAT_FORM_EDIT'   => 'catFormEdit',
		'SLY_CAT_MOVED'   => 'catMoved',

		// Sprachen

		'CLANG_ADDED'   => 'clangAdded',
		'CLANG_DELETED' => 'clangDeleted',

		// Auf Änderungen an den Sprach-Fragmenten reagieren

		'WV8_SETTINGS_UPDATED' => 'settingsUpdated',

		// Auf Änderungen an der Systemkonfiguration reagieren

		'SLY_SETTINGS_UPDATED' => 'slySettingsUpdated',
		'SLY_SYSTEM_CACHES'    => 'systemCacheList'
	);
}

if (!sly_Core::isBackend()) {
	$listeners['SLY_RESOLVE_ARTICLE'] = 'resolveArticle';
	$listeners['OUTPUT_FILTER']       = 'outputFilter';
	$listeners['SLY_ARTICLE_OUTPUT']  = 'outputFilter'; // 0.8+
}

$listeners['URL_REWRITE']                    = 'urlRewrite';
$listeners['SLY_CACHE_CLEARED']              = 'cacheCleared';
$listeners['SLY_MODEL_ARTICLE_ISSKIPPED']    = 'articleIsSkipped';
$listeners['SLY_MODEL_ARTICLE_GETFRAGMENT']  = 'articleGetFragment';
$listeners['SLY_BOOTCACHE_CLASSES_FRONTEND'] = 'bootcache';
$listeners['SLY_BOOTCACHE_CLASSES_BACKEND']  = 'bootcache';

$dispatcher = sly_Core::dispatcher();

foreach ($listeners as $event => $listener) {
	$dispatcher->register($event, array($listenerClass, $listener));
}
