PageRenderTime 240ms CodeModel.GetById 100ms app.highlight 2ms RepoModel.GetById 133ms app.codeStats 0ms

/app/extensions/seo/components/SeoFilter.php

https://bitbucket.org/Crisu83/webgames
PHP | 33 lines | 16 code | 4 blank | 13 comment | 3 complexity | f22b76f777bf71dcc4a47ad10928945e MD5 | raw file
 1<?php
 2/**
 3 * SeoFilter class file.
 4 * @author Christoffer Niska <ChristofferNiska@gmail.com>
 5 * @copyright Copyright &copy; Christoffer Niska 2011-
 6 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
 7 * @package seo.components
 8 */
 9
10class SeoFilter extends CFilter
11{
12	/**
13	 * Performs the pre-action filtering.
14	 * @param CFilterChain $filterChain the filter chain that the filter is on.
15	 * @return boolean whether the filtering process should continue and the action
16	 * should be executed.
17	 */
18	protected function preFilter($filterChain)
19	{
20		$controller = $filterChain->controller;
21
22		if (isset($_GET['id']) && method_exists($controller, 'loadModel'))
23		{
24			$model = $controller->loadModel($_GET['id']);
25			$url = $model->getUrl();
26
27			if (strpos(Yii::app()->request->getRequestUri(), $url) === false)
28				$controller->redirect($url, true, 301);
29		}
30
31		return parent::preFilter($filterChain);
32	}
33}