DotLibrary
[ class tree: DotLibrary ] [ index: DotLibrary ] [ all elements ]

Source for file Seo.php

Documentation is available at Seo.php

  1. <?php
  2. /**
  3. * DotBoost Technologies Inc.
  4. * DotKernel Application Framework
  5. *
  6. @category   DotKernel
  7. @package    DotLibrary
  8. @copyright  Copyright (c) 2009 DotBoost  Technologies (http://www.dotboost.com)
  9. @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  10. @version    $Id: Seo.php 156 2010-06-23 12:24:13Z teo $
  11. */
  12.  
  13. /**
  14. * SEO stuff. MetaKeyword, MetaDescription, Canonical URL, and other stuff related SEO.
  15. @category   DotKernel
  16. @package    DotLibrary
  17. @author     DotKernel Team <team@dotkernel.com>
  18. @todo          URL Rewrite
  19. */
  20.  
  21. class Dot_Seo
  22. {    
  23.     /**
  24.      * Option variable from dots/seo.xml file
  25.      * @access private
  26.      * @var Zend_Config 
  27.      */
  28.     private $option = NULL;
  29.     /**
  30.      * Constructor
  31.      * @access public
  32.      * @return Dot_Sessions 
  33.      */
  34.     public function __construct ()
  35.     {
  36.         //get the content of dots/seo.xml file into the option variable
  37.         $this->option = Dot_Settings::getOptionVariables('frontend''seo');
  38.         $this->config Zend_Registry::get('configuration');
  39.         $this->param Zend_Registry::get('param');
  40.     }
  41.     /**
  42.      * Create canonical URL
  43.      * This method will be changed when will add URL ReWrite alternative
  44.      * @todo improvement of canonical url's
  45.      * @access public
  46.      * @return string 
  47.      */
  48.     public function createCanonicalUrl()
  49.     {
  50.         $param $this->param;
  51.         $url $this->config->website->params->url;
  52.         if'/' != substr($url-11))
  53.         {
  54.             $url .= '/';
  55.         }
  56.         if('frontend' != $param['module'])
  57.         {
  58.             $url .=  $param['module''/';
  59.         }
  60.         if'' != $param['controller'])
  61.         {
  62.             $url .= $param['controller''/';
  63.         }
  64.         if'' != $param['action'])
  65.         {
  66.             $url .= $param['action''/';
  67.         }
  68.         //unset the request params: module, controller and action
  69.         unset($param['module']);
  70.         unset($param['controller']);
  71.         unset($param['action']);        
  72.         foreach ($param as $k => $v)
  73.         {
  74.             $url .= $k '/' $v '/';
  75.         }        
  76.         return $url;        
  77.     }
  78.     /**
  79.      * Get SEO options
  80.      * @access public
  81.      * @return array 
  82.      */
  83.     public function getOption()
  84.     {        
  85.         //remove 'option' xml atribute
  86.         $this->option->__unset('option');
  87.         if(isset($this->option->canonicalUrl))
  88.         {
  89.             // add canonical url to the array from dots/seo.xml file
  90.             $this->option->__set('canonicalUrl',$this->createCanonicalUrl());
  91.         }        
  92.         return $this->option;
  93.     }        
  94. }

Documentation generated on Wed, 21 Jul 2010 07:34:42 +0000 by phpDocumentor 1.4.3