示例#1
0
Plugin::setInfos(array(
    'id'			=> 'redirector',
    'title'			=> 'Redirector', 
    'description'	=> 'Provides an interface to manage redirects.', 
    'version'		=> '0.2.5', 
    'website'		=> 'http://www.github.com/realslacker/Redirector-Plugin',
    'update_url'	=> 'http://www.brooksworks.com/plugin-versions.xml'
));

//	setup observers
Behavior::add('page_not_found', '');
Observer::observe('page_requested', 'redirector_catch_redirect');

//	allow Redirector to observe the "page_not_found" event before the "page_not_found" plugin
if (Plugin::isEnabled('page_not_found')) {
    Observer::stopObserving('page_not_found', 'behavior_page_not_found');
    Observer::observe('page_not_found', 'redirector_log_404');
    Observer::observe('page_not_found', 'behavior_page_not_found');
}
else {
    Observer::observe('page_not_found', 'redirector_log_404');
}

//	load plugin classes into the system
AutoLoader::addFolder(dirname(__FILE__) . '/models');

// add the plugin's tab and controller
Plugin::addController('redirector', __('Redirector'),'redirector_view,redirector_new,redirector_edit,redirector_delete,redirector_settings');

// redirect urls already configured
function redirector_catch_redirect(&$args) {