PageRenderTime 46ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/demo/protected/extensions/seo/components/SeoFilter.php

https://bitbucket.org/horizons/yii-bootstrap
PHP | 33 lines | 16 code | 4 blank | 13 comment | 3 complexity | f22b76f777bf71dcc4a47ad10928945e MD5 | raw file
Possible License(s): GPL-3.0, LGPL-2.1, BSD-2-Clause, Apache-2.0, BSD-3-Clause
  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. class SeoFilter extends CFilter
  10. {
  11. /**
  12. * Performs the pre-action filtering.
  13. * @param CFilterChain $filterChain the filter chain that the filter is on.
  14. * @return boolean whether the filtering process should continue and the action
  15. * should be executed.
  16. */
  17. protected function preFilter($filterChain)
  18. {
  19. $controller = $filterChain->controller;
  20. if (isset($_GET['id']) && method_exists($controller, 'loadModel'))
  21. {
  22. $model = $controller->loadModel($_GET['id']);
  23. $url = $model->getUrl();
  24. if (strpos(Yii::app()->request->getRequestUri(), $url) === false)
  25. $controller->redirect($url, true, 301);
  26. }
  27. return parent::preFilter($filterChain);
  28. }
  29. }