<?php

Hook::call('lc_seo_before');

$obj=Factory::create('lc_seo_editor.list');
$list=$obj->get();
if (count($list)) {
	$target=$_SERVER['REQUEST_URI'];
	foreach ($list as $item) {
		$pattern=str_replace('\*', '.*', '/^'.preg_quote($item->pattern, '/').'$/i');
		if (preg_match($pattern, $target)) {
			config::set('core.title', sprintf($item->title, config::get('core.title')));
			config::set('core.description', sprintf($item->description, config::get('core.description')));
			config::set('core.keywords', sprintf($item->keywords, config::get('core.keywords')));
			if (!$item->walkthrough) break;
		}
	}
}

Hook::call('lc_seo_after');