示例#1
0
 /**
  * Builds the seo url
  * 
  * @param string $page - file name of the calling page e.g. index.php
  * @param array $valuepair - key => value pair array containing dependency(e.g. cPath) => value (e.g. 2_24_52)
  * @param string $url - $url passed by reference created by the method linkCreate() 
  * @param array $added_qs - passed by reference containing key value pairs for _GET
  * @param string $parameters - Currently unused
  */
 public function buildLink($page, $valuepair, &$url, &$added_qs, $parameters)
 {
     if ($valuepair[0] != self::DEPENDENCY || false === array_key_exists(1, $valuepair) || false === $this->installed || !tep_not_null($valuepair[1])) {
         return false;
         // Either this module is not installed or the value pair does not meet our requirements so abort
     }
     $base_path = $valuepair[1];
     // well it might be a single top level item
     if (false === $this->suppress_underscores) {
         if (false !== strpos($valuepair[1], '_')) {
             // It is a path with parents? ( has underscores )
             $base_path = ltrim(strrchr($valuepair[1], '_'), '_');
             // Grab the base path which is the number at the end of a path with parents ( e.g. 2_23_37_52 = 52 )
         }
     }
     // Sanity check - if the $base_path is not numeric then we dump it
     if (false === is_numeric(str_replace('_', '', $base_path))) {
         trigger_error(__CLASS__ . ' Incorrect ' . self::DEPENDENCY . ' presented: ' . $valuepair[1], E_USER_WARNING);
         return false;
     }
     // Get a full path with underscores from the database
     $full_path = $this->get_full_path($base_path);
     // If this item is not already in the registry we use the acquire() method to query for the data
     if (!isset(usu::$registry->vars[self::DEPENDENCY][$full_path])) {
         if (false === $this->acquire($base_path, $full_path)) {
             return false;
             // Looks like an invalid request so dump it
         }
     } else {
         usu::$performance['queries_saved']++;
         // Already in the registry so we saved one query
     }
     /**
      * About $reg_item
      * 
      * We grab the array of data from the registry and place it in $reg_item for convenience
      * The data stored in the registry was set in the method acquire as properties of this class
      * These are then set in the registry using the method getProperties()
      * the specific array keys like $reg_item['catname'] will be specific and differ in each module 
      */
     $reg_item = array();
     $reg_item = usu::$registry->vars[$valuepair[0]][$full_path];
     /**
      * Set the link text from reg_item
      * e.g. $link_text = $reg_item['parentname'] . '-' . $reg_item['catname'];
      */
     $link_text = $reg_item['information_title'];
     // the property added in the acquire function this would have been set in the acquire method like $this->xxxname
     switch (true) {
         case $page == self::FILENAME:
             $url = $this->linkCreate(self::FILENAME, $link_text, self::MARKER, $full_path);
             break;
         default:
             // Add leftovers to the querystring _GET
             $added_qs[filter_var($valuepair[0], FILTER_SANITIZE_STRING)] = usu::cleanse($valuepair[1]);
             break;
     }
     # end switch
 }
示例#2
0
 private function extractByDirSeparator()
 {
     global $_GET;
     $tmp = explode('/', $this->filestring);
     $count = count($tmp);
     for ($i = 0; $i < $count; $i = $i + 2) {
         $newget[filter_var($tmp[$i], FILTER_SANITIZE_STRING)] = usu::cleanse($tmp[$i + 1]);
         // assign cleansed key=>value pair to _GET
         $_GET[filter_var($tmp[$i], FILTER_SANITIZE_STRING)] = usu::cleanse($tmp[$i + 1]);
         $_GET[filter_var($tmp[$i], FILTER_SANITIZE_STRING)] = usu::cleanse($tmp[$i + 1]);
     }
     // Newly created _GET array added to the querystring and converted to _GET string
     $getstring = http_build_query($newget) . '&' . $this->querystring;
     $this->querystring = rtrim($getstring, '&');
 }
示例#3
0
 public function buildLink($page, $valuepair, &$url, &$added_qs, $parameters)
 {
     if (false === array_key_exists(1, $valuepair) || $valuepair[0] != $this->dependency || false !== strpos(urldecode($valuepair[1]), '{') || !tep_not_null($valuepair[1])) {
         return false;
     }
     if (!isset(usu::$registry->vars[$valuepair[0]][$valuepair[1]])) {
         if (false === $this->acquire($valuepair[1], $fullpath = false)) {
             return false;
         }
     } else {
         usu::$performance['queries_saved']++;
     }
     $reg_item = usu::$registry->vars[$valuepair[0]][$valuepair[1]];
     switch (true) {
         case $page == FILENAME_PRODUCT_INFO && false === strpos($valuepair[1], '{'):
             $url = $this->linkCreate(FILENAME_PRODUCT_INFO, $reg_item['link_text'], '-p-', $valuepair[1]);
             break;
         case $page == FILENAME_PRODUCT_REVIEWS:
             $url = $this->linkCreate(FILENAME_PRODUCT_REVIEWS, $reg_item['link_text'], '-pr-', $valuepair[1]);
             break;
         case $page == FILENAME_PRODUCT_REVIEWS_INFO:
             $url = $this->linkCreate(FILENAME_PRODUCT_REVIEWS_INFO, $reg_item['link_text'], '-pri-', $valuepair[1]);
             break;
         default:
             $added_qs[filter_var($valuepair[0], FILTER_SANITIZE_STRING)] = usu::cleanse($valuepair[1]);
             break;
     }
     # end switch
 }
示例#4
0
 /**
  * Builds the seo url
  * 
  * @param string $page - file name of the calling page e.g. index.php
  * @param array $valuepair - key => value pair array containing dependency(e.g. cPath) => value (e.g. 2_24_52)
  * @param string $url - $url passed by reference created by the method linkCreate() 
  * @param array $added_qs - passed by reference containing key value pairs for _GET
  * @param string $parameters - Currently unused
  */
 public function buildLink($page, $valuepair, &$url, &$added_qs, $parameters)
 {
     if ($valuepair[0] != self::DEPENDENCY || false === array_key_exists(1, $valuepair) || !tep_not_null($valuepair[1]) || false === $this->installed) {
         return false;
         // Either this module is not installed or the value pair does not meet our requirements so abort
     }
     $base_path = $valuepair[1];
     // well it might be a single top level item
     if (false !== strpos($valuepair[1], '_')) {
         // It is a path with parents? ( has underscores )
         $base_path = ltrim(strrchr($valuepair[1], '_'), '_');
         // Grab the base path which is the number at the end of a path with parents ( e.g. 2_23_37_52 = 52 )
     }
     // Sanity check - if the $base_path is not numeric then we dump it
     if (false === is_numeric($base_path)) {
         trigger_error(__CLASS__ . ' Incorrect ' . self::DEPENDENCY . ' presented: ' . $valuepair[1], E_USER_WARNING);
         return false;
     }
     // Check if the registry fullpaths array exists, if not then create it
     if (false === array_key_exists('fullpaths', usu::$registry->vars)) {
         usu::$registry->vars['fullpaths'] = array();
     }
     // If the $base_path is not in the registry let's add it
     if (false === array_key_exists($base_path, usu::$registry->vars['fullpaths'])) {
         $valuepair[1] = $this->get_full_path($valuepair[1]);
         // Get the full path including any parents
         usu::$registry->vars['fullpaths'][$base_path] = $valuepair[1];
         // Add to the registry - base_category => full path
     } else {
         // It is already in the registry so no need for queries
         $countpaths = 1;
         // Could be a single item with no parents so set it here
         // If multiple paths a query would be needed for each path
         if (false !== strpos(usu::$registry->vars['fullpaths'][$base_path], '_')) {
             // If it is a path with parents
             $countpaths = substr_count(usu::$registry->vars['fullpaths'][$base_path], '_') + 1;
             // Count the number of underscores and add one
         }
         usu::$performance['queries_saved'] += $countpaths;
         $valuepair[1] = usu::$registry->vars['fullpaths'][$base_path];
         // Set $valuepair[1] from the registry ( e.g. the value of cPath so could be like 4_21_54)
     }
     // If this item is not already in the registry we use the acquire() method to query for the data
     if (!isset(usu::$registry->vars[self::DEPENDENCY][$base_path])) {
         if (false === $this->acquire($base_path, $fullpath = false)) {
             return false;
             // Looks like an invalid request so dump it
         }
     } else {
         usu::$performance['queries_saved']++;
         // Already in the registry so we saved one query
     }
     /**
      * About $reg_item
      * 
      * We grab the array of data from the registry and place it in $reg_item for convenience
      * The data stored in the registry was set in the method acquire as properties of this class
      * These are then set in the registry using the method getProperties()
      * the specific array keys like $reg_item['catname'] will be specific and differ in each module 
      */
     $reg_item = array();
     $reg_item = usu::$registry->vars[$valuepair[0]][$base_path];
     /**
      * Set the link text from reg_item
      * e.g. $link_text = $reg_item['parentname'] . '-' . $reg_item['catname'];
      */
     if (defined('SEO_URLS_ADD_CAT_PARENT') && SEO_URLS_ADD_CAT_PARENT == 'true' && $reg_item['parentname'] != 'false') {
         $link_text = $reg_item['parentname'] . '-' . $reg_item['catname'];
     } else {
         $link_text = $reg_item['catname'];
     }
     switch (true) {
         case $page == self::FILENAME:
             $url = $this->linkCreate(self::FILENAME, $link_text, self::MARKER, $valuepair[1]);
             break;
         default:
             // Add leftovers to the querystring _GET
             $added_qs[filter_var($valuepair[0], FILTER_SANITIZE_STRING)] = usu::cleanse($valuepair[1]);
             break;
     }
     # end switch
 }