seo_url Class Reference

Base sur la version 2.1 de Ultimate-SEO-URLs Ultimate SEO URLs offers search engine optimized URLS for osCommerce based applications. More...

List of all members.

Public Member Functions

  • href_link ($page= '', $parameters= '', $connection= 'SSL', $add_session_id=false)
    Function to return SEO URL link SEO'd with stock generattion for error fallback.
  • header_tags ($page= '', $parameters= '', $connection= 'NONSSL', $add_session_id=false)
    Recuperation des element pour le header_tag.

Static Public Member Functions

Public Attributes

Static Protected Attributes

Private Member Functions


Detailed Description

Base sur la version 2.1 de Ultimate-SEO-URLs Ultimate SEO URLs offers search engine optimized URLS for osCommerce based applications.

Other features include optimized performance and automatic redirect script.

Definition at line 18 of file seo_url.php.


Constructor & Destructor Documentation

seo_url::__construct ( languages_id  )  [private]

SEO_URL class constructor.

Author:
Bobby Easland
Version:
1.1
Parameters:
$languages_id integer

liaison header_tag

Conf

Prepa static var

Base tag defaut

Definition at line 152 of file seo_url.php.

00152                                              {
00153     global $session_started, $SID;
00154 
00155 
00156     $this->DB= Database::getInstance();
00157 
00158     $this->languages_id = (int)$languages_id;
00159 
00160     $this->data = array();
00161 
00163     $this->header_tag=array();
00164 
00165 //ojp FILENAME_LINKS
00166     $seo_pages=array(FILENAME_DEFAULT,FILENAME_ACCOUNT,FILENAME_POPUP_IMAGE,FILENAME_PRODUCT_INFO,FILENAME_CONTENT,FILENAME_CREATE_ACCOUNT,FILENAME_ADVANCED_SEARCH,FILENAME_PRODUCTS_NEW,FILENAME_SMALL_PRICE,FILENAME_SPECIALS,FILENAME_BEST_SELLERS,FILENAME_SITEMAP,FILENAME_TEMPLATE,FILENAME_CONTACT_US, FILENAME_SHOPPING_CART);
00167     if ( defined('FILENAME_LINKS') ) $seo_pages[] = FILENAME_LINKS;
00168 
00169 
00170     $this->attributes = array(
00171       'SESSION_STARTED' => $session_started,
00172       'SID' => $SID,
00173 
00174       'SEO_ADD_CPATH_TO_PRODUCT_URLS' => defined('SEO_ADD_CPATH_TO_PRODUCT_URLS') ? SEO_ADD_CPATH_TO_PRODUCT_URLS : 'false',
00175       'SEO_ADD_CAT_PARENT' => defined('SEO_ADD_CAT_PARENT') ? SEO_ADD_CAT_PARENT : 'true',
00176       'SEO_URLS_USE_W3C_VALID' => defined('SEO_URLS_USE_W3C_VALID') ? SEO_URLS_USE_W3C_VALID : 'true',
00177 //       'USE_SEO_CACHE_MANUFACTURERS' => defined('USE_SEO_CACHE_MANUFACTURERS') ? USE_SEO_CACHE_MANUFACTURERS : 'false',
00178 
00179       'SEO_URLS_FILTER_SHORT_WORDS' => defined('SEO_URLS_FILTER_SHORT_WORDS') ? SEO_URLS_FILTER_SHORT_WORDS : 'false',
00180       'SEO_CHAR_CONVERT_SET' => defined('SEO_CHAR_CONVERT_SET') ? $this->expand(SEO_CHAR_CONVERT_SET) : 'false',
00181       'SEO_REMOVE_ALL_SPEC_CHARS' => defined('SEO_REMOVE_ALL_SPEC_CHARS') ? SEO_REMOVE_ALL_SPEC_CHARS : 'false',
00182       'SEO_PAGES' => $seo_pages,
00183 
00184       );
00185 
00189     self::$SEO_REWRITE_TYPE=defined('SEO_REWRITE_TYPE') ? SEO_REWRITE_TYPE : 'false';
00190     self::$USE_SEO_REDIRECT= defined('USE_SEO_REDIRECT') ? USE_SEO_REDIRECT : 'false';
00191 
00192     self::$USE_SEO_CACHE_GLOBAL=defined('USE_SEO_CACHE_GLOBAL') ? USE_SEO_CACHE_GLOBAL : 'false';
00193     self::$USE_SEO_CACHE_LINKS=defined('USE_SEO_CACHE_LINKS') ? USE_SEO_CACHE_LINKS : 'false';
00194     self::$USE_SEO_CACHE_PRODUCTS=defined('USE_SEO_CACHE_PRODUCTS') ? USE_SEO_CACHE_PRODUCTS : 'false';
00195     self::$USE_SEO_CACHE_CATEGORIES=defined('USE_SEO_CACHE_CATEGORIES') ? USE_SEO_CACHE_CATEGORIES : 'false';
00196     self::$USE_SEO_CACHE_TOPICS=defined('USE_SEO_CACHE_TOPICS') ? USE_SEO_CACHE_TOPICS : 'false';
00197 
00198 
00199     $this->cache = array();
00200     $this->timestamp = 0;
00201 
00202     $this->reg_anchors['no-rewrite'] = array('products_id' => 'products_id=',
00203                                     'cPath' => 'cPath=',
00204                                     'manufacturers_id' => 'manufacturers_id=',
00205                                     'pID' => 'pID=',
00206                                     'content' => 'content=',
00207                                     'divers' => 'divers=',
00208                                     'lID' => 'lID=',
00209                                     'customers_id' => 'customers_id=',
00210                                     );
00211     $this->reg_anchors['Rewrite'] = array('products_id' => '-p-',
00212                                     'cPath' => '-c-',
00213                                     'manufacturers_id' => '-m-',
00214                                     'pID' => '-pi-',
00215                                     'content' => '-t-',
00216                                     'divers' => '-d-',
00217                                     'lID' => '-l-',
00218                                     'customers_id' => '-u-',
00219                                     );
00220     $this->reg_anchors['Rewrite-mode2'] = array('products_id' => 'p/',
00221                                         'cPath' => 'c/',
00222                                         'manufacturers_id' => 'm/',
00223                                         'pID' => 'pi/',
00224                                         'content' => 't/',
00225                                         'divers' => 'd/',
00226                                         'lID' => 'l/',
00227                                         'customers_id' => 'u/',
00228                                         );
00229 
00230     $this->reg_ext['no-rewrite']='html';
00231     $this->reg_ext['Rewrite']='html';
00232     $this->reg_ext['Rewrite-mode2']='html';
00233 
00234 
00235     $this->performance = array('NUMBER_URLS_GENERATED' => 0,
00236                                 'NUMBER_QUERIES' => 0,
00237                                 'CACHE_QUERY_SAVINGS' => 0,
00238                                 'NUMBER_STANDARD_URLS_GENERATED' => 0,
00239                                 'TOTAL_CACHED_PER_PAGE_RECORDS' => 0,
00240                                 'TOTAL_TIME' => 0,
00241                                 'TIME_PER_URL' => 0,
00242                                 'QUERIES' => array()
00243                                 );
00244     //ojp generate_link_cache
00245     if (_test_bool(self::$USE_SEO_CACHE_GLOBAL)){
00246       $this->cache_file = 'seo_urls_v2_';
00247       $this->cache_gc();
00248 
00249       if ( _test_bool(self::$USE_SEO_CACHE_PRODUCTS )) $this->generate_products_cache();
00250       if ( _test_bool(self::$USE_SEO_CACHE_CATEGORIES)) $this->generate_categories_cache();
00251   //       if ( _test_bool($this->attributes['USE_SEO_CACHE_MANUFACTURERS'] ) ) $this->generate_manufacturers_cache();
00252   //       if ( _test_bool($this->attributes['USE_SEO_CACHE_ARTICLES'] ) && defined('TABLE_ARTICLES_DESCRIPTION'))
00253   //  $this->generate_articles_cache();
00254       if ( _test_bool(self::$USE_SEO_CACHE_TOPICS) && defined('TABLE_CONTENT_DESCRIPTION')) $this->generate_topics_cache();
00255       $this->generate_divers_cache();
00256       if ( _test_bool(self::$USE_SEO_CACHE_LINKS) ) $this->generate_links_cache();
00257     }
00258 
00259     if (_test_bool( self::$USE_SEO_REDIRECT)) $this->check_redirect();
00260 
00261 
00262 
00263 
00267     self::$extention= (!empty($this->reg_ext[self::$SEO_REWRITE_TYPE]))? '.'.$this->reg_ext[self::$SEO_REWRITE_TYPE] : '';
00268 
00269     self::$base_url = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
00270     self::$base_url_ssl = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG;
00271     self::$origUrl = strip_tags($this->requested_page());
00272 
00273 
00277     $sql = "select head_title_tag , head_desc_tag, head_keywords_tag from " . TABLE_FULL_TAG . " ft, "  . TABLE_FULL_TAG_DESCRIPTION .  " ftd where ft.tag_id=ftd.tag_id and ft.page_type='generic' and  ft.page_id = 'generic' and ftd.language_id = '" . (int)$this->languages_id. "' Limit 1";
00278     $query=$this->DB->query( $sql );
00279     $res=$query->fetchAssoc();
00280     define('HEAD_TITLE_TAG_ALL', $res['head_title_tag']);
00281     define('HEAD_DESC_TAG_ALL', $res['head_desc_tag']);
00282     define('HEAD_KEY_TAG_ALL', $res['head_keywords_tag']);
00283   }


Member Function Documentation

seo_url::add_sid ( link,
add_session_id,
connection,
separator 
) [private]

Function to append session ID if needed.

Author:
Bobby Easland
Parameters:
$link string
$add_session_id boolean
$connection string
$separator string
Returns:
string

Definition at line 432 of file seo_url.php.

Referenced by ValidateName().

00432                                                                              {
00433     global $request_type, $kill_sid;
00434     if ( ($add_session_id) && ($this->attributes['SESSION_STARTED']) && !_cst_bool('SESSION_FORCE_COOKIE_USE') ) {
00435       if ($this->not_null($this->attributes['SID']))  $_sid = $this->attributes['SID'];
00436       elseif ( ( ($request_type == 'NONSSL') && ($connection == 'SSL') && (ENABLE_SSL == true) ) || ( ($request_type == 'SSL') && ($connection == 'NONSSL') ) ) {
00437         if (HTTP_COOKIE_DOMAIN != HTTPS_COOKIE_DOMAIN)  $_sid = $this->SessionName() . '=' . $this->SessionID();
00438       }
00439       else $_sid=tep_session_name().'='.tep_session_id();
00440     } else $_sid=tep_session_name().'='.tep_session_id();
00441 
00442     switch(true){
00443       case (!isset($_SESSION['customer_id']) && _cst_bool('ENABLE_PAGE_CACHE')  && class_exists('page_cache')):
00444         $return = $link . $separator . '<osCsid>';
00445       break;
00446       case (isset($_sid) && $this->not_null($_sid) && ( !$kill_sid )):
00447         $return = $link . $separator . tep_output_string($_sid);
00448         break;
00449       default:
00450         $return = $link;
00451       break;
00452     }
00453     return $return;
00454   }

seo_url::cache_gc (  )  [private]

Function to perform basic garbage collection for database cache system.

Author:
Bobby Easland

Definition at line 1342 of file seo_url.php.

Referenced by __construct().

01342                              {
01343     $this->DB->query("DELETE FROM ". TABLE_SEO_CACHE." WHERE cache_expires <= '" . date("Y-m-d H:i:s") . "'" );
01344   }

seo_url::calculate_performance (  )  [private]

Function used to calculate and output the performance metrics of the class.

Author:
Bobby Easland
Returns:
mixed Output of performance data wrapped in HTML pre tags

Definition at line 1056 of file seo_url.php.

Referenced by profile().

01056                                           {
01057     foreach ($this->cache as $type) $this->performance['TOTAL_CACHED_PER_PAGE_RECORDS'] += sizeof($type);
01058     $this->performance['TIME_PER_URL'] = $this->performance['TOTAL_TIME'] / $this->performance['NUMBER_URLS_GENERATED'];
01059     return $this->PrintArray($this->performance, 'Performance Data');
01060   }

seo_url::check_redirect (  )  [private]

Function to initialize the redirect logic.

Author:
Bobby Easland

Definition at line 1401 of file seo_url.php.

Referenced by __construct().

01401                                    {
01402     $this->need_redirect = false;
01403     $this->path_info = is_numeric(strpos(ltrim(getenv('PATH_INFO'), '/') , '/')) ? ltrim(getenv('PATH_INFO'), '/') : NULL;
01404     $this->uri = ltrim( basename($_SERVER['REQUEST_URI']), '/' );
01405     $this->real_uri = ltrim( basename($_SERVER['SCRIPT_NAME']) . '?' . $_SERVER['QUERY_STRING'], '/' );
01406     $this->uri_parsed = $this->not_null( $this->path_info )
01407                         ? parse_url(basename($_SERVER['SCRIPT_NAME']) . '?' . $this->parse_path($this->path_info) )
01408                         : parse_url(basename($_SERVER['REQUEST_URI']));
01409     $this->attributes['SEO_REDIRECT']['PATH_INFO'] = $this->path_info;
01410     $this->attributes['SEO_REDIRECT']['URI'] = $this->uri;
01411     $this->attributes['SEO_REDIRECT']['REAL_URI'] = $this->real_uri;
01412     $this->attributes['SEO_REDIRECT']['URI_PARSED'] = $this->uri_parsed;
01413     $this->need_redirect();
01414     $this->check_seo_page();
01415 
01416     if ( $this->need_redirect && $this->is_seopage &&  self::$USE_SEO_REDIRECT == 'true') $this->do_redirect();
01417   }

seo_url::check_seo_page (  )  [private]

Function to check if it's a valid redirect page.

Author:
Bobby Easland

Definition at line 1440 of file seo_url.php.

Referenced by check_redirect().

01440                                    {
01441     switch (true){
01442       case (isset($this->uri_parsed['path']) && in_array($this->uri_parsed['path'], $this->attributes['SEO_PAGES'])): $this->is_seopage = true; break;
01443       default: $this->is_seopage = false; break;
01444     }
01445     $this->attributes['SEO_REDIRECT']['IS_SEOPAGE'] = $this->is_seopage ? 'true' : 'false';
01446   }

seo_url::convert_time ( expires  )  [private]

Function to convert time for cache methods.

Author:
Bobby Easland
Parameters:
$expires string
Returns:
string

Definition at line 1352 of file seo_url.php.

Referenced by save_cache().

01352                                          { //expires date interval must be spelled out and NOT abbreviated !!
01353     $expires = explode('/', $expires);
01354     switch( strtolower($expires[1]) ){
01355       case 'seconds':
01356         $expires = mktime( date("H"), date("i"), date("s")+(int)$expires[0], date("m"), date("d"), date("Y") );
01357       break;
01358       case 'minutes':
01359         $expires = mktime( date("H"), date("i")+(int)$expires[0], date("s"), date("m"), date("d"), date("Y") );
01360       break;
01361       case 'hours':
01362         $expires = mktime( date("H")+(int)$expires[0], date("i"), date("s"), date("m"), date("d"), date("Y") );
01363       break;
01364       case 'days':
01365         $expires = mktime( date("H"), date("i"), date("s"), date("m"), date("d")+(int)$expires[0], date("Y") );
01366       break;
01367       case 'months':
01368         $expires = mktime( date("H"), date("i"), date("s"), date("m")+(int)$expires[0], date("d"), date("Y") );
01369       break;
01370       case 'years':
01371         $expires = mktime( date("H"), date("i"), date("s"), date("m"), date("d"), date("Y")+(int)$expires[0] );
01372       break;
01373       default: // if something fudged up then default to 1 month
01374         $expires = mktime( date("H"), date("i"), date("s"), date("m")+1, date("d"), date("Y") );
01375     }
01376     return date("Y-m-d H:i:s", $expires);
01377   }

seo_url::do_redirect (  )  [private]

Function to perform redirect.

Author:
Bobby Easland

Definition at line 1472 of file seo_url.php.

Referenced by check_redirect().

01472                                 {
01473     $rs=str_replace('&amp;','&',$this->uri_parsed['query']);
01474     $p = @explode('&', $rs);
01475     foreach( $p as $index => $value ){
01476       $tmp = @explode('=', $value);
01477       switch($tmp[0]){
01478         case 'products_id':
01479           if ( $this->is_attribute_string($tmp[1]) ){
01480             $pieces = @explode('{', $tmp[1]);
01481             $params[] = $tmp[0] . '=' . $pieces[0];
01482           } else {
01483             $params[] = $tmp[0] . '=' . $tmp[1];
01484           }
01485           break;
01486         case '_ID':
01487           $page_tmp=$tmp[1];
01488         break;
01489         default:
01490           $params[] = $tmp[0].'='.$tmp[1];
01491           break;
01492       }
01493     }
01494     switch($this->uri_parsed['path']){
01495       case 'content.php';
01496         if(isset($page_tmp))  $this->uri_parsed['path'] = $page_tmp;
01497       break;
01498     }
01499     $params = ( sizeof($params) > 1 ? implode('&amp;', $params) : $params[0] );
01500     $url = $this->href_link($this->uri_parsed['path'], $params, 'NONSSL', false);
01501 
01502     switch(true){
01503       case (_cst_bool(self::USE_SEO_REDIRECT_DEBUG)):
01504         $this->attributes['SEO_REDIRECT']['REDIRECT_URL'] = $url;
01505       break;
01506       case (_cst_bool( self::$USE_SEO_REDIRECT)):
01507         header("HTTP/1.0 301 Moved Permanently");
01508         header("Location: $url"); // redirect...bye bye
01509       break;
01510       default:
01511         $this->attributes['SEO_REDIRECT']['REDIRECT_URL'] = $url;
01512       break;
01513     }
01514   }

seo_url::expand ( set  )  [private]

Function to expand the SEO_CONVERT_SET group.

Author:
Bobby Easland
Parameters:
$set string
Returns:
mixed

Definition at line 1088 of file seo_url.php.

Referenced by __construct().

01088                                {
01089     if ( $this->not_null($set) ){
01090       if ( $data = @explode(',', $set) ){
01091         foreach ( $data as $index => $valuepair){
01092           $p = @explode('=>', $valuepair);
01093           $container[trim($p[0])] = trim($p[1]);
01094         }
01095         return $container;
01096       }
01097       else return 'false';
01098     }
01099     else return 'false';
01100   }

seo_url::generate_categories_cache (  )  [private]

Definition at line 847 of file seo_url.php.

Referenced by __construct().

00847                                               {
00848     $res =  $this->DB->query( "select ft.page_id as ID , head_title_tag as tName, head_desc_tag, head_keywords_tag from " . TABLE_FULL_TAG . " ft, "  . TABLE_FULL_TAG_DESCRIPTION .  " ftd where ft.tag_id=ftd.tag_id and ft.page_type='cat' and   ftd.language_id = '" . (int)$this->languages_id. "'" );
00849     while($result = $res->fetchAssoc()){
00850 //       if(!isset($this->cache['GET_CATEGORIES_P'][$result['ID']])) $this->cache['GET_CATEGORIES_P'][$result['ID']]=$result['parent_id'];
00851       $this->get_cache_id($result['ID'],$result,'CATEGORIES');
00852     }
00853   }

seo_url::generate_divers_cache (  )  [private]

Mise en cache de la table des type page, / table TABLE_FULL_TAG.

Returns:
array

Definition at line 691 of file seo_url.php.

Referenced by __construct().

00691                                           {
00692     $res=$this->DB->query( "select ft.page_id as ID, head_title_tag as tName, head_desc_tag, head_keywords_tag from " . TABLE_FULL_TAG . " ft, "  . TABLE_FULL_TAG_DESCRIPTION .  " ftd where ft.tag_id=ftd.tag_id and ft.page_type='page' and   ftd.language_id = '" . (int)$this->languages_id. "' " );
00693     while ($result =$res->fetchAssoc()){
00694       $this->get_cache_id($result['ID'],$result,'DIVERS');
00695     }
00696   }

seo_url::generate_links_cache (  )  [private]

Mise en cache de la table des type page, / table TABLE_FULL_TAG.

Returns:
array

Definition at line 732 of file seo_url.php.

Referenced by __construct().

00732                                          {
00733     $res=$this->DB->query( "select ft.page_id as ID, head_title_tag as tName, head_desc_tag, head_keywords_tag from " . TABLE_FULL_TAG . " ft, "  . TABLE_FULL_TAG_DESCRIPTION .  " ftd where ft.tag_id=ftd.tag_id and ft.page_type='link' and   ftd.language_id = '" . (int)$this->languages_id. "' " );
00734     while ($result =$res->fetchAssoc()){
00735       $this->get_cache_id($result['ID'],$result,'LINKS');
00736     }
00737   }

seo_url::generate_products_cache (  )  [private]

Mise en cache des element produits / table TABLE_FULL_TAG.

Returns:
array

Definition at line 786 of file seo_url.php.

Referenced by __construct().

00786                                             {
00787     $res=$this->DB->query( "select ft.page_id as ID , head_title_tag as tName, head_desc_tag, head_keywords_tag from " . TABLE_FULL_TAG . " ft, "  . TABLE_FULL_TAG_DESCRIPTION .  " ftd where ft.tag_id=ftd.tag_id and ft.page_type='product' and   ftd.language_id = '" . (int)$this->languages_id. "'" );
00788     while ($result =$res->fetchAssoc()){
00789       $this->get_cache_id($result['ID'],$result,'PRODUCTS');
00790     }
00791   }

seo_url::generate_topics_cache (  )  [private]
Version:
1
Author:
oscim <mail oscim@oscss.org> <www http://www.oscim.fr>
Returns:
array

Definition at line 922 of file seo_url.php.

Referenced by __construct().

00922                                           {
00923     $res=$this->DB->query( "select ft.page_id as ID, head_title_tag as tName, head_desc_tag, head_keywords_tag from " . TABLE_FULL_TAG . " ft, "  . TABLE_FULL_TAG_DESCRIPTION .  " ftd where ft.tag_id=ftd.tag_id and ft.page_type='content' and ftd.language_id = '" . (int)$this->languages_id. "'" );
00924     while ($result =$res->fetchAssoc()){
00925       $this->get_cache_id($result['ID'],$result,'TOPICS');
00926     }
00927   }

seo_url::get_cache ( name = 'GLOBAL',
local_memory = false 
) [private]

Function to get cache entry.

Author:
Bobby Easland
Parameters:
$name string
$local_memory boolean
Returns:
mixed

Definition at line 1255 of file seo_url.php.

01255                                                                      {
01256     $select_list = 'cache_id, cache_language_id, cache_name, cache_data, cache_global, cache_gzip, cache_method, cache_date, cache_expires';
01257     $global = ( $name == 'GLOBAL' ? true : false ); // was GLOBAL passed or is using the default?
01258     switch($name){
01259       case 'GLOBAL':
01260         $this->cache_query = $this->DB->query("SELECT ".$select_list." FROM ".TABLE_SEO_CACHE." WHERE cache_language_id='".(int)$this->languages_id."' AND cache_global='1'");
01261       break;
01262       default:
01263         $this->cache_query = $this->DB->query("SELECT ".$select_list." FROM ".TABLE_SEO_CACHE." WHERE cache_id='".md5($name)."' AND cache_language_id='".(int)$this->languages_id."'");
01264       break;
01265     }
01266     $num_rows = $this->cache_query->__get('numRows');
01267     if ( $num_rows ){
01268       $container = array();
01269       while($cache = $this->cache_query->fetchAssoc()){
01270         $cache_name = $cache['cache_name'];
01271         if ( $cache['cache_expires'] > date("Y-m-d H:i:s") ) {
01272           $cache_data = ( $cache['cache_gzip'] == 1 ? gzinflate(base64_decode($cache['cache_data'])) : stripslashes($cache['cache_data']) );
01273           switch($cache['cache_method']){
01274             case 'EVAL': // must be PHP code
01275               eval("$cache_data");
01276             break;
01277             case 'ARRAY':
01278               $cache_data = unserialize($cache_data);
01279             case 'RETURN':
01280             default:
01281           }
01282           if ($global) $container['GLOBAL'][$cache_name] = $cache_data;
01283           else $container[$cache_name] = $cache_data; // not global
01284         } else { // cache is expired
01285           if ($global) $container['GLOBAL'][$cache_name] = false;
01286           else $container[$cache_name] = false;
01287         }
01288         if (/* $this->keep_in_memory ||*/ $local_memory ) {
01289           if ($global) $this->data['GLOBAL'][$cache_name] = $container['GLOBAL'][$cache_name];
01290           else $this->data[$cache_name] = $container[$cache_name];
01291         }
01292       }
01293       unset($cache_data);
01294       $this->DB->Free($this->cache_query);
01295       switch (true) {
01296         case ($num_rows == 1):
01297           if ($global){
01298             if ($container['GLOBAL'][$cache_name] == false || !isset($container['GLOBAL'][$cache_name])) return false;
01299             else return $container['GLOBAL'][$cache_name];
01300           } else { // not global
01301             if ($container[$cache_name] == false || !isset($container[$cache_name])) return false;
01302             else return $container[$cache_name];
01303           }
01304         case ($num_rows > 1):
01305         default:
01306           return $container;
01307         break;
01308       }
01309     } else {
01310       return false;
01311     }
01312   }

seo_url::get_cache_id ( id,
result,
type 
) [private]

Ajout et/ou recup le cache.

Author:
oscim <mail oscim@oscss.org> <www http://www.oscim.fr>
Parameters:
$id 
$result 
$type 
Returns:
array

Definition at line 937 of file seo_url.php.

Referenced by generate_categories_cache(), generate_divers_cache(), generate_links_cache(), generate_products_cache(), generate_topics_cache(), get_category_name(), get_divers_name(), get_links_name(), and get_product_name().

00937                                                   {
00938     if(!isset($this->cache[$type][$id])) return $this->cache[$type][$id]= $result;
00939     elseif(is_array($result)) return $this->cache[$type][$id]= array_merge($this->cache[$type][$id], $result);
00940     else return $this->cache[$type][$id];
00941   }

seo_url::get_cache_memory ( name,
method = 'RETURN' 
) [private]

Function to get cache from memory.

Author:
Bobby Easland
Parameters:
$name string
$method string
Returns:
mixed

Definition at line 1321 of file seo_url.php.

01321                                                               {
01322     $data = ( isset($this->data['GLOBAL'][$name]) ? $this->data['GLOBAL'][$name] : $this->data[$name] );
01323     if ( isset($data) && !empty($data) && $data != false ){
01324       switch($method){
01325         case 'EVAL': // data must be PHP
01326           eval("$data");
01327           return true;
01328         break;
01329         case 'ARRAY':
01330         case 'RETURN':
01331         default:
01332           return $data;
01333       }
01334     }
01335     else  return false;
01336   }

seo_url::get_category_name ( &$  cID  )  [private]

Function to get the category name.

Use evaluated cache, per page cache, or database query in that order of precedent

Author:
Bobby Easland
Version:
1.1
Parameters:
$cID integer NOTE: passed by reference
Returns:
string Stripped anchor text

Definition at line 800 of file seo_url.php.

Referenced by parse_parameters().

00800                                            {
00801     $ID=substr(strrchr($cID, '_'),1);
00802     $ID=(is_numeric($ID) ?$ID : $this->get_full_cPath($cID, $single_cID));
00803     switch(true){
00804       case (_test_bool(self::$USE_SEO_CACHE_GLOBAL) && isset($this->cache['CATEGORIES'][$ID])  ):
00805         $this->performance['CACHE_QUERY_SAVINGS']++;
00806         $result = $this->get_cache_id($ID,'','CATEGORIES');;
00807         $return = (isset($result['tName'])? $this->strip($result['tName']): '');
00808         $this->transph_header_tag($result);
00809       break;
00810       default:
00811         $this->performance['NUMBER_QUERIES']++;
00812         switch(true){
00813           case (_test_bool($this->attributes['SEO_ADD_CAT_PARENT'])):
00814             $rsql = $this->DB->query("SELECT c.categories_id as ID, c.parent_id, cd.categories_name as tName, cd2.categories_name as pName
00815                             FROM ".TABLE_CATEGORIES." c
00816                             JOIN ".TABLE_CATEGORIES_DESCRIPTION." cd
00817                             ON c.categories_id = cd.categories_id AND cd.language_id='".(int)$this->languages_id."'
00818                             LEFT JOIN ".TABLE_CATEGORIES_DESCRIPTION." cd2
00819                             ON c.parent_id=cd2.categories_id AND cd2.language_id='".(int)$this->languages_id."'
00820                             WHERE c.categories_id='".(int)$ID."'
00821                             LIMIT 1");
00822             $result = $rsql->fetchAssoc();
00823             $result['tName']=$cName = $this->not_null($result['pName']) ? $this->strip($result['pName'] . ' ' . $result['tName']) : $this->strip($result['tName']);
00824             break;
00825           default:
00826              $rsql = $this->DB->query("SELECT categories_id as ID, categories_name as tName FROM ".TABLE_CATEGORIES_DESCRIPTION." WHERE categories_id='".(int)$ID."' AND language_id='".(int)$this->languages_id."' LIMIT 1");
00827             $result = $rsql->fetchAssoc();
00828             $cName = $result['tName'];
00829           break;
00830           $this->performance['QUERIES']['CATEGORIES'][] = $rsql;
00831         }
00832         $cName = $this->strip($cName);
00833         $this->get_cache_id($ID,$result,'CATEGORIES');
00834         $this->transph_header_tag($result);
00835         $return = $cName;
00836       break;
00837     }
00838     return $return;
00839   }

seo_url::get_divers_name ( pID  )  [private]

Function to get the product name.

Use evaluated cache, per page cache, or database query in that order of precedent

Parameters:
$pID integer
Returns:
string Stripped anchor text

Definition at line 664 of file seo_url.php.

Referenced by parse_parameters().

00664                                         {
00665     switch(true){
00666       case (_test_bool(self::$USE_SEO_CACHE_GLOBAL) && isset($this->cache['DIVERS'][$pID])):
00667         $this->performance['CACHE_QUERY_SAVINGS']++;
00668         $result = $this->get_cache_id($pID,'','DIVERS');
00669         $return = (isset($result['tName'])? $this->strip($result['tName']): $this->strip($pID));
00670         $this->transph_header_tag($result);
00671       break;
00672       default:
00673         $this->performance['NUMBER_QUERIES']++;
00674          $sql = "select head_title_tag as tName, head_desc_tag, head_keywords_tag from " . TABLE_FULL_TAG . " ft, "  . TABLE_FULL_TAG_DESCRIPTION .  " ftd where ft.tag_id=ftd.tag_id and ft.page_type='page' and  ft.page_id = '" . $pID. "' and ftd.language_id = '" . (int)$this->languages_id. "' Limit 1";
00675           $query=$this->DB->query( $sql );
00676           if ($query->__get('numRows')>0) $result =$query->fetchAssoc();
00677           else $result['tName'] = $this->strip($pID);
00678           $this->get_cache_id($pID,'','DIVERS');
00679           $this->performance['QUERIES']['DIVERS'][] = $sql;
00680           $this->transph_header_tag($result);
00681           $return = $result['tName'];
00682         break;
00683     }
00684     return $return;
00685   }

seo_url::get_full_cPath ( cID,
&$  original 
) [private]

Function to retrieve full cPath from category ID.

Author:
Bobby Easland
Version:
1.1
Parameters:
$cID mixed Could contain cPath or single category_id
$original integer Single category_id passed back by reference
Returns:
string Full cPath string

Definition at line 952 of file seo_url.php.

Referenced by get_category_name().

00952                                                    {
00953     if ( is_numeric(substr($cID,strpos($cID, '_'))) ){
00954       $temp = @explode('_', $cID);
00955       $original = $temp[sizeof($temp)-1];
00956       return $cID;
00957     } else {
00958       $c = array();
00959       $this->GetParentCategories($c, $cID);
00960       $c = array_reverse($c);
00961       $c[] = $cID;
00962       $original = $cID;
00963       $cID = sizeof($c) > 1 ? implode('_', $c) : $cID;
00964       return $cID;
00965     }
00966   }

seo_url::get_links_name ( pID  )  [private]

Function to get the product name.

Use evaluated cache, per page cache, or database query in that order of precedent

Author:
Bobby Easland
Version:
1.1
Parameters:
$pID integer
Returns:
string Stripped anchor text

Definition at line 705 of file seo_url.php.

Referenced by parse_parameters().

00705                                        {
00706     switch(true){
00707       case (_test_bool(self::$USE_SEO_CACHE_GLOBAL) && isset($this->cache['LINKS'][$pID]) ):
00708         $this->performance['CACHE_QUERY_SAVINGS']++;
00709         $result = $this->get_cache_id($pID,'','LINKS');
00710         $return = (isset($result['tName'])? $this->strip($result['tName']): $this->strip($pID));
00711         $this->transph_header_tag($result);
00712       break;
00713       default:
00714         $this->performance['NUMBER_QUERIES']++;
00715           $query=$this->DB->query( "select nav_name as tName, l.nav_link_id as ID from " . TABLE_NAVIGATION_LINKS . " l, "  . TABLE_NAVIGATION_LINKS_DESCRIPTION .  " ld where l.nav_link_id=ld.nav_link_id l.nav_link_id = '" . $pID. "' and ld.language_id = '" . (int)$this->languages_id. "' Limit 1" );
00716           if ($query->__get('numRows')>0) $result =$query->fetchAssoc();
00717           else $result['tName'] = $this->strip($pID);
00718           $this->get_cache_id($pID,'','LINKS');
00719           $this->performance['QUERIES']['LINKS'][] = $query;
00720           $this->transph_header_tag($result);
00721           $return = $result['tName'];
00722         break;
00723     }
00724     return $return;
00725   }

seo_url::get_manufacturer_name ( mID  )  [private]

Function to get the manufacturer name.

Use evaluated cache, per page cache, or database query in that order of precedent.

Author:
Bobby Easland
Parameters:
$mID integer
Returns:
string

Definition at line 861 of file seo_url.php.

Referenced by parse_parameters().

00861                                               {
00862     switch(true){
00863       case (_test_bool(self::$USE_SEO_CACHE_GLOBAL) && isset($this->cache['MANUFACTURERS'][$mID])):
00864         $this->performance['CACHE_QUERY_SAVINGS']++;
00865         $result = $this->cache['MANUFACTURERS'][$mID];
00866         $return = (isset($result['tName'])? $result['tName']: '');
00867         $this->transph_header_tag($result);
00868       break;
00869       default:
00870         $this->performance['NUMBER_QUERIES']++;
00871         $rsql = $this->DB->query("SELECT manufacturers_name as tName FROM ".TABLE_MANUFACTURERS." WHERE manufacturers_id='".(int)$mID."' LIMIT 1");
00872         $result = $rsql->fetchAssoc(); // $this->DB->FetchArray( $this->DB->Query( $sql ) );
00873         $mName = $this->strip( $result['tName'] );
00874         $this->cache['MANUFACTURERS'][$mID] = $result;
00875         $this->performance['QUERIES']['MANUFACTURERS'][] = $rsql;
00876         $this->transph_header_tag($result);
00877         $return = $mName;
00878       break;
00879     }
00880     return $return;
00881   }

seo_url::get_product_name ( pID  )  [private]

Function to get the product name.

Use evaluated cache, per page cache, or database query in that order of precedent

Author:
Bobby Easland
Version:
1.1
Parameters:
$pID integer
Returns:
string Stripped anchor text

Definition at line 746 of file seo_url.php.

Referenced by parse_parameters().

00746                                          {
00747     switch(true){
00748       case (_test_bool(self::$USE_SEO_CACHE_GLOBAL) && isset($this->cache['PRODUCTS'][$pID]) ):
00749         $this->performance['CACHE_QUERY_SAVINGS']++;
00750         $result = $this->get_cache_id($pID,'','PRODUCTS');
00751         $return = (isset($result['tName'])? $this->strip($result['tName']): '');
00752         $this->transph_header_tag($result);
00753       break;
00754       default:
00755         $this->performance['NUMBER_QUERIES']++;
00756         switch(true){
00757           case (_test_bool($this->attributes['SEO_ADD_CAT_PARENT'])):
00758             $rsql = $this->DB->query("SELECT products_name as tName, categories_name as cName FROM ".TABLE_PRODUCTS_DESCRIPTION." p LEFT JOIN ".TABLE_PRODUCTS_TO_CATEGORIES." cd2 ON p.products_id=cd2.products_id JOIN ".TABLE_CATEGORIES_DESCRIPTION." cd ON cd.categories_id = cd2.categories_id AND cd.language_id='".(int)$this->languages_id."'   WHERE p.products_id='".(int)$pID."' AND p.language_id='".(int)$this->languages_id."' LIMIT 1");
00759             $result = $rsql->fetchAssoc();
00760             $cName = $result['cName'];
00761 
00762             $result['tName']=$result['cName'].'/'.$result['tName'];
00763             break;
00764           default:
00765             $rsql = $this->DB->query("SELECT products_name as tName FROM ".TABLE_PRODUCTS_DESCRIPTION." WHERE products_id='".(int)$pID."' AND language_id='".(int)$this->languages_id."' LIMIT 1");
00766             $result = $rsql->fetchAssoc();
00767             $cName = $result['tName'];
00768             break;
00769         }
00770         /*if(!defined('TABLE_FULL_TAG'))*/
00771         //      else $sql = "select head_title_tag as tName, head_desc_tag, head_keywords_tag from " . TABLE_FULL_TAG . " ft, "  . TABLE_FULL_TAG_DESCRIPTION .  " ftd where ft.tag_id=ftd.tag_id and ft.page_type='product' and  ft.page_id = '" . (int)$pID. "' and ftd.language_id = '" . (int)$this->languages_id. "' Limit 1";
00772 //      $result = $this->DB->FetchArray( $this->DB->Query( $sql ) );
00773         $this->get_cache_id($pID,$result,'PRODUCTS');
00774         $this->performance['QUERIES']['PRODUCTS'][] = $rsql;
00775         $this->transph_header_tag($result);
00776         $return = $this->strip( $result['tName'] );
00777         break;
00778     }
00779     return $return;
00780   }

seo_url::get_topic_name ( tID  )  [private]

Function to get the topic name.

Use evaluated cache, per page cache, or database query in that order of precedent.

Author:
Bobby Easland
Version:
1.1
Parameters:
$tID integer
Returns:
string

Definition at line 891 of file seo_url.php.

Referenced by parse_parameters().

00891                                        {
00892     switch(true){
00893       case (_test_bool(self::$USE_SEO_CACHE_GLOBAL) && isset($this->cache['TOPICS'][$tID]) ):
00894         $this->performance['CACHE_QUERY_SAVINGS']++;
00895         $result = $this->cache['TOPICS'][$tID];
00896         $return = (isset($result['tName'])? $this->strip($result['tName']): '');
00897         $this->transph_header_tag($result);
00898         break;
00899       default:
00900         $this->performance['NUMBER_QUERIES']++;
00901         $sql = "select content_title as tName from " . TABLE_CONTENT . " c, "  . TABLE_CONTENT_DESCRIPTION .  " cd where c.content_status = '1' and c.content_id=cd.content_id and c.content_id='".(int)$tID."' and cd.language_id='".(int)$this->languages_id."' Limit 1";
00902         $rsql=$this->DB->query($sql);
00903 //      else $sql = "select head_title_tag as tName, head_desc_tag, head_keywords_tag from " . TABLE_FULL_TAG . " ft, "  . TABLE_FULL_TAG_DESCRIPTION .  " ftd where ft.tag_id=ftd.tag_id and ft.page_type='content' and  ft.page_id = '" . (int)$tID. "' and ftd.language_id = '" . (int)$this->languages_id. "' Limit 1";
00904         $result = $rsql->fetchAssoc(); //$this->DB->FetchArray( $this->DB->query( $sql ) );
00905         $tName = $this->strip( $result['tName'] );
00906         $this->cache['ARTICLES'][$tID] = $result;
00907         $this->performance['QUERIES']['TOPICS'][] = $sql;
00908         $this->transph_header_tag($result);
00909         $return = $tName;
00910         break;
00911     }
00912     return $return;
00913   }

static seo_url::getInstance ( languages_id = ''  )  [static]

Definition at line 285 of file seo_url.php.

Referenced by __construct(), resetInstance(), and tep_href_link().

00285                                                        {
00286     if(empty($languages_id)) global $languages_id;
00287     if(self::$_instance == null)  self::$_instance = new self($languages_id);
00288     return self::$_instance;
00289   }

seo_url::GetParentCategories ( &$  categories,
categories_id 
) [private]

Recursion function to retrieve parent categories from category ID.

Author:
Bobby Easland
Version:
1.0
Parameters:
$categories mixed Passed by reference
$categories_id integer

Definition at line 975 of file seo_url.php.

Referenced by get_full_cPath().

00975                                                                      {
00976     if(_test_bool(self::$USE_SEO_CACHE_GLOBAL) && isset($this->cache['GET_CATEGORIES_P'][$categories_id])) {
00977       $categories[sizeof($categories)] =$this->cache['GET_CATEGORIES_P'][$categories_id];
00978     } else {
00979       $sql = "SELECT parent_id FROM " . TABLE_CATEGORIES . " WHERE categories_id='" . (int)$categories_id . "'";
00980       $parent_categories_query = $this->DB->query($sql);
00981       while ($parent_categories = $parent_categories_query->fetchAssoc()) {
00982         $this->cache['GET_CATEGORIES_P'][$categories_id]=$parent_categories['parent_id'];
00983         if ($parent_categories['parent_id'] == 0) return true;
00984         $categories[sizeof($categories)] = $parent_categories['parent_id'];
00985         if ($parent_categories['parent_id'] != $categories_id)  $this->GetParentCategories($categories, $parent_categories['parent_id']);
00986       }
00987     }
00988   }

seo_url::header_tags ( page = '',
parameters = '',
connection = 'NONSSL',
add_session_id = false 
)

Recuperation des element pour le header_tag.

Parameters:
$page 
$parameters 
$connection 
$add_session_id 

Definition at line 339 of file seo_url.php.

00339                                                                                                             {
00340     $link = $connection == 'NONSSL' ? self::$base_url : self::$base_url_ssl;
00341     $separator = '?';
00342     $this->parse_parameters($page, $parameters ,$connection , $separator, true);
00343     if(!isset($this->header_tag['title'])) $this->transph_header_tag(array());
00344   }

seo_url::href_link ( page = '',
parameters = '',
connection = 'SSL',
add_session_id = false 
)

Function to return SEO URL link SEO'd with stock generattion for error fallback.

Author:
Bobby Easland
Parameters:
$page string Base script for URL
$parameters string URL parameters
$connection string $connection NONSSL/SSL
$add_session_id boolean $add_session_id Switch to add osCsid
Returns:
string Formed href link

Definition at line 306 of file seo_url.php.

Referenced by do_redirect().

00306                                                                                                        {
00307     $this->start($this->timestamp);
00308     $this->performance['NUMBER_URLS_GENERATED']++;
00309 
00310     if ( !in_array($page, $this->attributes['SEO_PAGES']) )  return $this->stock_href_link($page, $parameters, $connection, $add_session_id);
00311     $link = ($connection == 'NONSSL' || !(getenv('HTTPS') == 'on') )? self::$base_url : self::$base_url_ssl;
00312     $separator = '?';
00313 
00314     if ($this->not_null($parameters))  $link .= $this->parse_parameters($page, $parameters ,$connection , $separator);
00315     else  $link .= $this->parse_parameters($page, (!empty($parameters)?$parameters.'&':'') .'divers='.substr($page,0,strlen($page)-4) ,$connection , $separator); //$page;
00316 
00317     $this->stop($this->timestamp, $time);
00318     $this->performance['TOTAL_TIME'] += $time;
00319     switch($this->attributes['SEO_URLS_USE_W3C_VALID']){
00320       case ('true'):
00321         if (!isset($_SESSION['customer_id']) && _cst_bool('ENABLE_PAGE_CACHE') && class_exists('page_cache')) return $link;
00322           else {
00323           return htmlentities($link);
00324         }
00325       break;
00326       case ('false'):
00327         return $link;
00328       break;
00329     }
00330   }

seo_url::implode_assoc ( array,
inner_glue = '=',
outer_glue = '&' 
) [private]

Function to implode an associative array.

Author:
Bobby Easland
Parameters:
$array array Associative data array
$inner_glue string
$outer_glue string
Returns:
string

Definition at line 1131 of file seo_url.php.

Referenced by parse_parameters().

01131                                                                            {
01132     $output = array();
01133     foreach( $array as $key => $item )
01134       if ( $this->not_null($key) && $this->not_null($item) ) $output[] = $key . $inner_glue . $item;
01135 
01136     return @implode($outer_glue, $output);
01137   }

seo_url::is_attribute_string ( pID  )  [private]

Function to check if the products_id contains an attribute.

Author:
Bobby Easland
Parameters:
$pID integer
Returns:
boolean

Definition at line 1013 of file seo_url.php.

Referenced by do_redirect(), need_redirect(), and parse_parameters().

01013                                             {
01014     if ( is_numeric(strpos($pID, '{')) )return true;
01015     else return false;
01016   }

seo_url::is_cached ( name,
&$  is_cached,
&$  is_expired 
) [private]

Function to check if the cache is in the database and expired.

Author:
Bobby Easland
Parameters:
$name string
$is_cached boolean NOTE: passed by reference
$is_expired boolean NOTE: passed by reference

Definition at line 1386 of file seo_url.php.

Referenced by save_cache().

01386                                                               { // NOTE: $is_cached and $is_expired is passed by reference !!
01387     $this->cache_query = $this->DB->query("SELECT cache_expires FROM ". TABLE_SEO_CACHE." WHERE cache_id='".md5($name)."' AND cache_language_id='".(int)$this->languages_id."' LIMIT 1");
01388     $is_cached = ( $this->cache_query->__get('NumRows') > 0 ? true : false );
01389     if ($is_cached){
01390       $check = $this->cache_query->fetchAssoc($this->cache_query);
01391       $is_expired = ( $check['cache_expires'] <= date("Y-m-d H:i:s") ? true : false );
01392       unset($check);
01393     }
01394     $this->DB->Free($this->cache_query);
01395   }

seo_url::is_cPath_string ( params  )  [private]

Function to check if cPath is in the parameter string.

Author:
Bobby Easland
Parameters:
$params string
Returns:
boolean

Definition at line 1035 of file seo_url.php.

Referenced by parse_parameters().

01035                                            {
01036     if ( preg_match('#Path#i', $params) )return true;
01037     else return false;
01038   }

seo_url::is_product_string ( params  )  [private]

Function to check if the params contains a products_id.

Author:
Bobby Easland
Parameters:
$params string
Returns:
boolean

Definition at line 1024 of file seo_url.php.

Referenced by parse_parameters().

01024                                              {
01025     if ( is_numeric(strpos('products_id', $params)) ) return true;
01026     else  return false;
01027   }

seo_url::make_url ( page,
string,
anchor_type,
id,
&$  separator 
) [private]

Function to return the generated SEO URL.

Author:
Bobby Easland
Version:
1.0
Parameters:
$page string
$string string Stripped, formed anchor
$anchor_type string Parameter type (products_id, cPath, etc.)
$id integer
$separator string NOTE: passed by reference
Returns:
string

Definition at line 606 of file seo_url.php.

Referenced by parse_parameters().

00606                                                                             {
00607     switch ( self::$SEO_REWRITE_TYPE ){
00608       case 'Rewrite':
00609         return $string . $this->reg_anchors['Rewrite'][$anchor_type] . $id .self::$extention;
00610       break;
00611       case 'Rewrite-mode2':
00612         return  $this->reg_anchors['Rewrite-mode2'][$anchor_type] . $id .'/'.$string. self::$extention;
00613       break;
00614     }
00615   }

seo_url::need_redirect (  )  [private]

Function to check if the URL needs to be redirected.

Author:
Bobby Easland

Definition at line 1423 of file seo_url.php.

Referenced by check_redirect().

01423                                   {
01424     foreach( $this->reg_anchors as $param => $value){ $pattern[] = $param; }
01425     switch(true){
01426       case ($this->is_attribute_string($this->uri)): $this->need_redirect = false; break;
01427       case ($this->uri != $this->real_uri && !$this->not_null($this->path_info)): $this->need_redirect = false; break;
01428       case (is_numeric(strpos($this->uri, '.htm'))): $this->need_redirect = false; break;
01429       case (@preg_match("/(".@implode('|', $pattern).")/i", $this->uri)): $this->need_redirect = true; break;
01430       case (@preg_match("/(".@implode('|', $pattern).")/i", $this->path_info)): $this->need_redirect = true; break;
01431       default:
01432     }
01433     $this->attributes['SEO_REDIRECT']['NEED_REDIRECT'] = $this->need_redirect ? 'true' : 'false';
01434   }

seo_url::not_null ( value  )  [private]

Function to check if a value is NULL.

Author:
Bobby Easland as abstracted from osCommerce-MS2.2
Version:
1.0
Parameters:
$value mixed
Returns:
boolean

Definition at line 997 of file seo_url.php.

Referenced by add_sid(), check_redirect(), expand(), get_category_name(), href_link(), implode_assoc(), need_redirect(), and stock_href_link().

00997                                     {
00998     if (is_array($value)) {
00999       if (sizeof($value) > 0)   return true;
01000       else   return false;
01001     } else {
01002       if (($value != '') && (strtolower($value) != 'null') && (strlen(trim($value)) > 0)) return true;
01003       else  return false;
01004     }
01005   }

seo_url::output_string ( string,
translate = false,
protected = false 
) [private]

Function to output a translated or sanitized string.

Author:
Bobby Easland
Parameters:
$string string String to be output
$translate mixed Array of translation characters
$protected boolean Switch for htemlspecialchars processing
Returns:
string

Definition at line 1178 of file seo_url.php.

Referenced by parse_parameters(), and stock_href_link().

01178                                                                                   {
01179     if ($protected == true)  return htmlspecialchars($string);
01180     else {
01181       if ($translate == false) return $this->parse_input_field_data($string, array('"' => '&quot;'));
01182       else   return $this->parse_input_field_data($string, $translate);
01183     }
01184   }

seo_url::parse_input_field_data ( data,
parse 
) [private]

Function to translate a string.

Author:
Bobby Easland
Parameters:
$data string String to be translated
$parse array Array of tarnslation variables
Returns:
string

Definition at line 1166 of file seo_url.php.

Referenced by output_string().

01166                                                          {
01167     return strtr(trim($data), $parse);
01168   }

seo_url::parse_parameters ( page,
params,
connection,
&$  separator 
) [private]

Function to parse the parameters into an SEO URL.

Author:
Bobby Easland
Parameters:
$page string
$params string
$connection string
$separator string NOTE: passed by reference
Returns:
string

home by cms

home by page content

Definition at line 465 of file seo_url.php.

Referenced by header_tags(), and href_link().

00465                                                                               {
00466     $params=str_replace('&amp;','&',$params);
00467     $p = @explode('&', $params);
00468     krsort($p);
00469     $container = array();
00470 
00471     foreach ($p as $index => $valuepair){
00472       $p2 = @explode('=', $valuepair);
00473 
00474       switch ($p2[0]){
00475         case 'products_id':
00476           switch(true){
00477             default:
00478             case ( !$this->is_attribute_string($p2[1]) && in_array($page,array(FILENAME_PRODUCT_INFO, FILENAME_DEFAULT) ) ):
00479               $url = $this->make_url($page, $this->get_product_name($p2[1]), $p2[0], $p2[1],  $separator);
00480               $this->ValidateName($url, "p", $p2[1], $connection, $separator);
00481             break;
00482             default:
00483               $container[$p2[0]] = $p2[1];
00484             break;
00485           }
00486         break;
00487         case 'cPath':
00488           switch(true){
00489             case ($page == FILENAME_DEFAULT):
00490             default:
00491               $url = $this->make_url($page, $this->get_category_name($p2[1]), $p2[0], $p2[1],  $separator);
00492               $this->ValidateName($url, "c", $p2[1], $connection, $separator);
00493             break;
00494 //          case ( !$this->is_product_string($params) ):
00495 //            if ( _test_bool($this->attributes['SEO_ADD_CPATH_TO_PRODUCT_URLS'])){
00496 //              $container[$p2[0]] = $p2[1];
00497 //            }
00498 //          break;
00499 //          default:
00500 //            $container[$p2[0]] = $p2[1];
00501 //          break;
00502             }
00503         break;
00504         case 'manufacturers_id':
00505           switch(true){
00506             case ($page == FILENAME_DEFAULT && !$this->is_cPath_string($params) && !$this->is_product_string($params) ):
00507               $url = $this->make_url($page, $this->get_manufacturer_name($p2[1]), $p2[0], $p2[1],  $separator);
00508               $this->ValidateName($url, "m", $p2[1], $connection, $separator);
00509             break;
00510             case ($page == FILENAME_PRODUCT_INFO):
00511             break;
00512             default:
00513                     $container[$p2[0]] = $p2[1];
00514             break;
00515           }
00516         break;
00517         case 'pID':
00518           switch(true){
00519             case ($page == FILENAME_POPUP_IMAGE):
00520               $url = $this->make_url($page, $this->get_product_name($p2[1]), $p2[0], $p2[1],  $separator);
00521               $this->ValidateName($url, "pID", $p2[1], $connection, $separator);
00522             break;
00523             default:
00524               $container[$p2[0]] = $p2[1];
00525             break;
00526           }
00527         break;
00528         case 'lID':
00529           switch(true){
00530             default:
00531               $url = $this->make_url($page, $this->get_links_name($p2[1]), $p2[0], $p2[1],  $separator);
00532               $this->ValidateName($url, "lID", $p2[1], $connection, $separator);
00533             break;
00534           }
00535         break;
00536         case 'content':
00537           switch(true){
00538             case ($page == FILENAME_CONTENT):
00539               $url = $this->make_url($page, $this->get_topic_name($p2[1]), $p2[0], $p2[1],  $separator);
00540               $this->ValidateName($url, "t", $p2[1], $connection, $separator);
00541             break;
00542             default:
00543               $container[$p2[0]] = $p2[1];
00544             break;
00545           }
00546         break;
00547         case 'divers':
00548           switch(true){
00549             default:
00550               $url = $this->make_url($page, $this->get_divers_name($p2[1]), $p2[0], $p2[1], $separator);
00551               $this->ValidateName($url, "d", $p2[1], $connection, $separator);
00552             break;
00553           }
00554         break;
00555         case 'customers_id':
00556           switch(true){
00557             default:
00558               $url = $this->make_url($page, $this->get_divers_name($p2[1]), $p2[0], $p2[1], $separator);
00559               $this->ValidateName($url, "u", $p2[1], $connection, $separator);
00560             break;
00561           }
00562         break;
00563         default:
00564           $container[$p2[0]] = @$p2[1];
00565           switch(true){
00566             case ($page == '' || $page ==FILENAME_DEFAULT):
00567               $id=AbstractHeader_tags::get_prio_cms('home');
00569               if(is_int($id)) {
00570                 $url = $this->make_url($page, $this->get_topic_name($id), "content", $id,  $separator);
00571                 $this->ValidateName($url, "t", $id, $connection, $separator);
00572               }
00574               else {
00575                 $url = ''; // $this->make_url('home', $this->get_divers_name('home'), 'divers', 'home',  $separator);
00576                 //$this->ValidateName($url, "d", 'home', $connection, $separator);
00577               }
00578             break;
00579             default:
00580               if(is_array($p2)) $container[$p2[0]] = @$p2[1];
00581             break;
00582           }
00583       }
00584     }
00585     $url = isset($url) ? $url : $page;
00586     if ( sizeof($container) > 0 ){
00587       if ( $imploded_params = $this->implode_assoc($container) ){
00588         $url .= $separator . $this->output_string( $imploded_params );
00589         $separator = '&';
00590       }
00591     }
00592     return $url;
00593   }

seo_url::parse_path ( path_info  )  [private]

Function to parse the path for old SEF URLs.

Author:
Bobby Easland
Parameters:
$path_info string
Returns:
array

Definition at line 1454 of file seo_url.php.

Referenced by check_redirect().

01454                                          {
01455     $tmp = @explode('/', $path_info);
01456     if ( sizeof($tmp) > 2 ){
01457       $container = array();
01458       for ($i=0, $n=sizeof($tmp); $i<$n; $i++) {
01459         $container[] = $tmp[$i] . '=' . $tmp[$i+1];
01460         $i++;
01461       }
01462       return @implode('&amp;', $container);
01463     } else {
01464       return @implode('=', $tmp);
01465     }
01466   }

seo_url::profile (  )  [private]

Function used to output class profile.

Author:
Bobby Easland
Version:
1.0

Definition at line 1045 of file seo_url.php.

01045                             {
01046     $this->calculate_performance();
01047     $this->PrintArray($this->attributes, 'Class Attributes');
01048     $this->PrintArray($this->cache, 'Cached Data');
01049   }

seo_url::requested_page (  )  [private]

Definition at line 646 of file seo_url.php.

Referenced by __construct().

00646                                     {
00647     global $_SERVER;
00648     $protocol = ( (ENABLE_SSL == true) && (getenv('HTTPS') == 'on') )? 'https://' : 'http://';
00649     $current_page = $protocol . $_SERVER['HTTP_HOST'] . ((!empty($_SERVER['REQUEST_URI']))? $_SERVER['REQUEST_URI'] : '');
00650     $current_page = substr($current_page, strlen(HTTP_SERVER));
00651     if (($pos = strpos($current_page, "?osCsid")) !== FALSE)
00652       $current_page = substr($current_page, 0, $pos).'<br />';
00653     if ($current_page[0] == "/")
00654       $current_page = substr($current_page, 1);
00655 
00656     return $current_page;
00657   }

static seo_url::resetInstance ( languages_id = ''  )  [static]

Definition at line 291 of file seo_url.php.

00291                                                          {
00292     if(empty($languages_id)) global $languages_id;
00293     self::$_instance = null;
00294     return self::getInstance($languages_id);
00295   }

seo_url::save_cache ( name,
value,
method = 'RETURN',
gzip = 1,
global = 0,
expires = '30/days' 
) [private]

Function to save the cache to database.

Author:
Bobby Easland
Parameters:
$name string Cache name
$value mixed Can be array, string, PHP code, or just about anything
$method string RETURN, ARRAY, EVAL
$gzip integer Enables compression
$global integer Sets whether cache record is global is scope
$expires string Sets the expiration

Definition at line 1219 of file seo_url.php.

01219                                                                                                         {
01220     $expires = $this->convert_time($expires);
01221     if ($method == 'ARRAY' ) $value = serialize($value);
01222     $value = ( $gzip === 1 ? base64_encode(gzdeflate($value, 1)) : addslashes($value) );
01223     $sql_data_array = array('cache_id' => md5($name),
01224                             'cache_language_id' => (int)$this->languages_id,
01225                             'cache_name' => $name,
01226                             'cache_data' => $value,
01227                             'cache_global' => (int)$global,
01228                             'cache_gzip' => (int)$gzip,
01229                             'cache_method' => $method,
01230                             'cache_date' => date("Y-m-d H:i:s"),
01231                             'cache_expires' => $expires
01232                             );
01233     $this->is_cached($name, $is_cached, $is_expired);
01234     $cache_check = ( $is_cached ? 'true' : 'false' );
01235     switch ( $cache_check ) {
01236       case 'true':
01237         $this->DB->DBPerform(TABLE_SEO_CACHE, $sql_data_array, 'update', "cache_id='".md5($name)."'");
01238       break;
01239       case 'false':
01240         $this->DB->DBPerform(TABLE_SEO_CACHE, $sql_data_array, 'insert');
01241       break;
01242       default:
01243     }
01244     # unset the variables...clean as we go
01245     unset($value, $expires, $sql_data_array);
01246   }

seo_url::SessionID ( sessid = ''  )  [private]

Function to return the session ID.

Author:
Bobby Easland
Parameters:
$sessid string
Returns:
string

Definition at line 1192 of file seo_url.php.

Referenced by add_sid(), and stock_href_link().

01192                                            {
01193     if (!empty($sessid))  return session_id($sessid);
01194     else  return session_id();
01195   }

seo_url::SessionName ( name = ''  )  [private]

Function to return the session name.

Author:
Bobby Easland
Parameters:
$name string
Returns:
string

Definition at line 1203 of file seo_url.php.

Referenced by add_sid(), and stock_href_link().

01203                                            {
01204     if (!empty($name))  return session_name($name);
01205     else  return session_name();
01206   }

seo_url::short_name ( str,
limit = 3 
) [private]

Function to return the short word filtered string.

Author:
Bobby Easland
Parameters:
$str string
$limit integer
Returns:
string Short word filtered

Definition at line 1109 of file seo_url.php.

Referenced by strip().

01109                                              {
01110     $container=array();
01111     if ( $this->attributes['SEO_URLS_FILTER_SHORT_WORDS'] != 'false' ) $limit = (int)$this->attributes['SEO_URLS_FILTER_SHORT_WORDS'];
01112     $foo = @explode('-', $str);
01113     foreach($foo as $index => $value){
01114       switch (true){
01115         case ( strlen($value) <= $limit ): continue;
01116         default: $container[] = $value; break;
01117       }
01118     }
01119     $container = ( sizeof($container) > 1 ? implode('-', $container) : $str );
01120     return $container;
01121   }

seo_url::start ( &$  start_time  )  [private]

Function to start time for performance metric.

Author:
Bobby Easland
Parameters:
$start_time float

Definition at line 1144 of file seo_url.php.

Referenced by href_link().

01144                                       {
01145     $start_time = explode(' ', microtime());
01146   }

seo_url::stock_href_link ( page = '',
parameters = '',
connection = 'NONSSL',
add_session_id = false,
search_engine_safe = true 
) [private]

Stock function, fallback use.

Parameters:
$page 
$parameters 
$connection 
$add_session_id 
$search_engine_safe 

Definition at line 364 of file seo_url.php.

Referenced by href_link().

00364                                                                                                                                               {
00365     global $request_type, $session_started, $SID, $kill_sid; 
00366 //     if (!$this->not_null($page))  die('</td></tr></table></td></tr></table><br /><br /><font color="#ff0000"><strong>Error!</strong></font><br /><br /><strong>Unable to determine the page link!</strong><br /><br />');
00367     if ($page == '/') $page = '';
00368 
00369     if ($connection == 'NONSSL')  $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
00370     elseif ($connection == 'SSL') {
00371       if (_cst_bool('ENABLE_SSL'))  $link = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG;
00372       else  $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
00373     }
00374     else  die('</td></tr></table></td></tr></table><br /><br /><font color="#ff0000"><strong>Error!</strong></font><br /><br /><strong>Unable to determine connection method on a link!<br /><br />Known methods: NONSSL SSL</strong><br /><br />');
00375 
00376     if ($this->not_null($parameters)) {
00377       $link .= $page . '?' . $this->output_string($parameters);
00378       $separator = '&amp;';
00379     } else {
00380       $link .= $page;
00381       $separator = '?';
00382     }
00383     while ( (substr($link, -5) == '&amp;') || (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1);
00384     if ( ($add_session_id == true) && ($session_started == true) && _cst_bool('SESSION_FORCE_COOKIE_USE') ) {
00385       if ($this->not_null($SID)) {
00386         $_sid = $SID;
00387       } elseif ( ( ($request_type == 'NONSSL') && ($connection == 'SSL') && _cst_bool('ENABLE_SSL') ) || ( ($request_type == 'SSL') && ($connection == 'NONSSL') ) ) {
00388         if (HTTP_COOKIE_DOMAIN != HTTPS_COOKIE_DOMAIN) {
00389           $_sid = $this->SessionName() . '=' . $this->SessionID();
00390         }
00391       }
00392     }
00393 
00394     switch(true){
00395       case (!isset($_SESSION['customer_id']) && _cst_bool('ENABLE_PAGE_CACHE') && class_exists('page_cache')):
00396         $page_cache = true;
00397         $return = $link . $separator . '<osCsid>';
00398       break;
00399       case (isset($_sid) && ( !$kill_sid )): 
00400         $page_cache = false;
00401         $return = $link . $separator . tep_output_string($_sid);
00402       break;
00403       default:
00404         $page_cache = false;
00405         $return = $link;
00406       break;
00407     }
00408     $this->performance['NUMBER_STANDARD_URLS_GENERATED']++;
00409     $this->cache['STANDARD_URLS'][] = $link;
00410     $time = 0;
00411     $this->stop($this->timestamp, $time);
00412     $this->performance['TOTAL_TIME'] += $time;
00413     switch(true){
00414       case (_test_bool($this->attributes['SEO_URLS_USE_W3C_VALID']) && !$page_cache):
00415         return htmlentities(str_replace('&amp;','&',$return));
00416       break;
00417       default:
00418         return str_replace('&amp;','&',$return);
00419       break;
00420     }
00421   }

seo_url::stop ( start,
&$  time 
) [private]

Function to stop time for performance metric.

Author:
Bobby Easland
Parameters:
$start float
$time float NOTE: passed by reference

Definition at line 1154 of file seo_url.php.

Referenced by href_link(), and stock_href_link().

01154                                        {
01155     $end = explode(' ', microtime());
01156     $time = number_format( array_sum($end) - array_sum($start), 8, '.', '' );
01157   }

seo_url::strip ( string  )  [private]

Function to strip the string of punctuation and white space.

Author:
Bobby Easland
Parameters:
$string string
Returns:
string Stripped text. Removes all non-alphanumeric characters.

Definition at line 1068 of file seo_url.php.

Referenced by get_category_name(), get_divers_name(), get_links_name(), get_manufacturer_name(), get_product_name(), and get_topic_name().

01068                                  {
01069     if ( is_array($this->attributes['SEO_CHAR_CONVERT_SET']) ) $string = strtr($string, $this->attributes['SEO_CHAR_CONVERT_SET']);
01070     if(_test_bool($this->attributes['SEO_REMOVE_ALL_SPEC_CHARS'])){
01071       $pattern = $this->attributes['SEO_REMOVE_ALL_SPEC_CHARS'] == 'true'
01072                                       ? "([^[:alnum:]])+"
01073                                       : "([[:punct:]])+";
01074       $anchor = preg_replace('#'.$pattern.'#', '-', strtolower($string));
01075       $pattern = "([[:space:]]|[[:blank:]])+";
01076       $anchor = preg_replace('#'.$pattern.'#', '-', $anchor);
01077     }
01078     else $anchor=$string;
01079     return $this->short_name($anchor); // return the short filtered name
01080   }

seo_url::transph_header_tag ( result  )  [private]

constructor du header_tag

Parameters:
$result 

Definition at line 350 of file seo_url.php.

Referenced by get_category_name(), get_divers_name(), get_links_name(), get_manufacturer_name(), get_product_name(), get_topic_name(), and header_tags().

00350                                               {
00351     $this->header_tag['title']=(isset($result['tName']) && !empty($result['tName']))? $result['tName'] : @constant('HEAD_TITLE_TAG_ALL') ;
00352     $this->header_tag['desc']=(isset($result['head_desc_tag']) && !empty($result['head_desc_tag']))? $result['head_desc_tag']:@constant('HEAD_DESC_TAG_ALL') ;
00353     $this->header_tag['keywords']=(isset($result['head_keywords_tag']) && !empty($result['head_keywords_tag']))? $result['head_keywords_tag']: @constant('HEAD_KEY_TAG_ALL') ;
00354   }

seo_url::ValidateName ( url,
type,
realID,
connection,
separator 
) [private]

Ajout ext url.

Parameters:
$url 
$type 
$realID 
$connection 
$separator 

Definition at line 626 of file seo_url.php.

Referenced by parse_parameters().

00626                                                                                {
00627     $parts = explode("-", self::$origUrl);
00628 
00629     if (isset($parts[count($parts) - 2]) && $parts[count($parts) - 2] == $type){  //make sure it is the correct type for this link
00630       if (($pos = strpos($parts[count($parts) - 1], self::$extention)) !== FALSE) $id = substr($parts[count($parts) - 1], 0, $pos);       //strip .html
00631 
00632       $catalog = DIR_WS_HTTP_CATALOG;
00633       if ($catalog[0] == '/')  substr(DIR_WS_HTTP_CATALOG, 1);             //strip leading slash if present
00634 
00635       if (strpos(self::$origUrl, $catalog) !== FALSE) self::$origUrl = substr(self::$origUrl, strlen($catalog));         //remove the catalog from the url string
00636 
00637       if (!empty(self::$origUrl) && $id === $realID && self::$origUrl !== $url){ //ID's match but not the text
00638          $url = self::$base_url . $url;
00639          $link = $this->add_sid($url, true, $connection, $separator); //build the correct link with SID
00640           //header("HTTP/1.0 301 Moved Permanently");             //let the SE's know to not use this link
00641           //header("Location: $link");                            //redirect to the real page
00642       }
00643     }
00644   }


Member Data Documentation

seo_url::$_instance [static, protected]

Definition at line 143 of file seo_url.php.

seo_url::$attributes

Definition at line 39 of file seo_url.php.

seo_url::$base_url [static, protected]

Definition at line 44 of file seo_url.php.

seo_url::$base_url_ssl [static, protected]

Definition at line 49 of file seo_url.php.

seo_url::$cache

Definition at line 29 of file seo_url.php.

Referenced by get_cache().

seo_url::$cache_file

Definition at line 74 of file seo_url.php.

seo_url::$cache_query

Definition at line 69 of file seo_url.php.

seo_url::$data

Definition at line 79 of file seo_url.php.

Referenced by expand(), get_cache_memory(), and parse_input_field_data().

seo_url::$DB

Definition at line 114 of file seo_url.php.

seo_url::$extention [static, protected]

Interne static function.

Definition at line 126 of file seo_url.php.

seo_url::$header_tag

Definition at line 120 of file seo_url.php.

seo_url::$is_seopage

Definition at line 89 of file seo_url.php.

seo_url::$languages_id

Definition at line 34 of file seo_url.php.

Referenced by __construct(), getInstance(), and resetInstance().

seo_url::$need_redirect

Definition at line 84 of file seo_url.php.

seo_url::$origUrl [static, protected]

Definition at line 127 of file seo_url.php.

seo_url::$path_info

Definition at line 109 of file seo_url.php.

Referenced by parse_path().

seo_url::$performance

Definition at line 54 of file seo_url.php.

seo_url::$real_uri

Definition at line 99 of file seo_url.php.

seo_url::$reg_anchors

Definition at line 64 of file seo_url.php.

seo_url::$SEO_REWRITE_TYPE [static, protected]

Var conf.

Definition at line 134 of file seo_url.php.

seo_url::$timestamp

Definition at line 59 of file seo_url.php.

seo_url::$uri

Definition at line 94 of file seo_url.php.

seo_url::$uri_parsed

Definition at line 104 of file seo_url.php.

seo_url::$USE_SEO_CACHE_CATEGORIES [static, protected]

Definition at line 140 of file seo_url.php.

seo_url::$USE_SEO_CACHE_GLOBAL [static, protected]

Definition at line 137 of file seo_url.php.

seo_url::$USE_SEO_CACHE_LINKS [static, protected]

Definition at line 138 of file seo_url.php.

seo_url::$USE_SEO_CACHE_PRODUCTS [static, protected]

Definition at line 139 of file seo_url.php.

seo_url::$USE_SEO_CACHE_TOPICS [static, protected]

Definition at line 141 of file seo_url.php.

seo_url::$USE_SEO_REDIRECT [static, protected]

Definition at line 135 of file seo_url.php.

Constant de class debugg.

Definition at line 23 of file seo_url.php.


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