preventDuplicates Class Reference

class preventDuplicates More...

List of all members.

Public Member Functions

  • preventDuplicates ()
  • checkTarget ($meta)
    Sets $this->finalMeta (Final meta to be output based on the methods and properties below.
  • targetsExist ()
    Checks whether any $this->getValues exist in the $_GET array.
  • parseMeta ()
    Sets $this->addedMeta which is a string made up of matched $_GET key value pairs Key value pairs are seperated with _ (underscore) seperate $_GET are se[erated with - (hyphen).
  • performPCRE ()
    PCRE replace operations to inject added meta info based on matched $_GET variables.

Public Attributes


Detailed Description

class preventDuplicates

Parameters:
$getValues - array of $_GET variables which will action the added meta
$meta - contains the title/meta info prior to being altered by this class
$caught - Numerical array containing $_GET keys that were present in $getValues
$addedMeta - $_GET as a string containing key value pairs
$finalMeta - The modified (or not) meta that will be printed to screen
$IhaveDuplicateContent - Set to true or false dependent on whether Google webmaster tolls is showing duplicate content
$noIndex - meta shown when $IhaveDuplicateContent is set to false

Definition at line 30 of file preventDuplicates.php.


Member Function Documentation

preventDuplicates::checkTarget ( meta  ) 

Sets $this->finalMeta (Final meta to be output based on the methods and properties below.

Parameters:
mixed $meta - $meta - contains the buffered title/meta info prior to being altered by this class - $this->targetsExist() - Returns true or false based on whether $getValues was found in $_GET - $this->parseMeta() - Ultimately sets $this->finalMeta;

Definition at line 50 of file preventDuplicates.php.

00050                               {
00051 
00052     $this->meta = $meta;
00053     if( $this->targetsExist() && (false !== $this->turnServiceOn) ){
00054       if( false !== $this->IhaveDuplicateContent ){
00055       $this->parseMeta();
00056       } else {
00057         $this->finalMeta = $this->meta . "\n" . $this->noIndex;
00058       }
00059     } else {
00060       $this->finalMeta = $this->meta;
00061     }
00062   }

preventDuplicates::parseMeta (  ) 

Sets $this->addedMeta which is a string made up of matched $_GET key value pairs Key value pairs are seperated with _ (underscore) seperate $_GET are se[erated with - (hyphen).

Parameters:
$this->addedMeta - A string made up of matched $_GET key value pairs $this->performPCRE() - performs PCRE replace operations on the buffered $meta

Definition at line 91 of file preventDuplicates.php.

Referenced by checkTarget().

00091                       {
00092 
00093     $addedMeta = '';
00094     $count = count($this->caught);
00095     for( $i=0; $i<$count; $i++ ){
00096       $addedMeta .= $this->caught[$i] . '_' . tep_sanitize_string(tep_output_string_protected($_GET[$this->caught[$i]])) . '-';
00097     }
00098     $this->addedMeta = $addedMeta;
00099     $this->performPCRE();
00100   }

preventDuplicates::performPCRE (  ) 

PCRE replace operations to inject added meta info based on matched $_GET variables.

Parameters:
$this->finalMeta - Sets $this->finalMeta which contains the modified meat data

Definition at line 106 of file preventDuplicates.php.

Referenced by parseMeta().

00106                          {
00107 
00108     $pattern[]   = '@<title>\s*@i';
00109     $pattern[]   = '@<meta\s*name\s*=\s*"\s*description\s*"\s*content\s*=\s*"\s*@i';
00110     $pattern[]   = '@<meta\s*name\s*=\s*"\s*keywords\s*"\s*content\s*=\s*"\s*@i';
00111     $replace[]   = '<title>' . str_replace('-', ' | ', $this->addedMeta);
00112     $replace[]   = '<meta name="description" content="' . str_replace('-', ' ', $this->addedMeta);
00113     $replace[]   = '<meta name="keywords" content="' . str_replace('-', ', ', $this->addedMeta);
00114 
00115     $this->finalMeta = preg_replace($pattern, $replace, $this->meta);
00116   }

preventDuplicates::preventDuplicates (  ) 

Definition at line 41 of file preventDuplicates.php.

00041                               {
00042   }

preventDuplicates::targetsExist (  ) 

Checks whether any $this->getValues exist in the $_GET array.

Parameters:
- $this->caught - set as an array of keys found in $_GET
Returns:
- Returns true or false, if true $this->caught is also set as an array

Definition at line 69 of file preventDuplicates.php.

Referenced by checkTarget().

00069                          {
00070     $caught = array();
00071     foreach( $this->getValues as $value ){
00072       if( isset($_GET[$value]) ){
00073         $caught[] = tep_output_string_protected($value);
00074       }
00075   }
00076   if( !empty($caught)) {
00077     $this->caught = $caught;
00078     return true;
00079   } else{
00080     return false;
00081   }
00082   }


Member Data Documentation

preventDuplicates::$addedMeta

Definition at line 37 of file preventDuplicates.php.

Referenced by parseMeta().

preventDuplicates::$caught

Definition at line 36 of file preventDuplicates.php.

Referenced by targetsExist().

preventDuplicates::$finalMeta

Definition at line 38 of file preventDuplicates.php.

preventDuplicates::$getValues = array('sort', 'page', 'language', 'currency')

Definition at line 32 of file preventDuplicates.php.

preventDuplicates::$IhaveDuplicateContent = true

Definition at line 33 of file preventDuplicates.php.

preventDuplicates::$meta

Definition at line 35 of file preventDuplicates.php.

Referenced by checkTarget().

preventDuplicates::$noIndex = '<meta name="ROBOTS" content="NOINDEX, FOLLOW" />'

Definition at line 39 of file preventDuplicates.php.

preventDuplicates::$turnServiceOn = true

Definition at line 34 of file preventDuplicates.php.


The documentation for this class was generated from the following file: