Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

tep_parse_search_string OSC 2.2


texmaxx

Recommended Posts

Posted

For my understanding, a search for "osCommerce T-Shirt" using quotes should give only matches with the full phrase.

Version is OSC 2.2 but even 3.0 Vanillekipferl should at least find the Shirt but it does not give me any matches.

 

The function tep_parse_search_string in functions/general.php does not support quoted strings for me...

Does it work for you?

 

In the function it says that "quoted string will be reconstructed later" and its done here!

      if ( (substr($pieces[$k], -1) != '"') && (substr($pieces[$k], 0, 1) != '"') ) {
       $objects[] = trim($pieces[$k]);

       for ($j=0; $j<count($post_objects); $j++) {
         $objects[] = $post_objects[$j];
       }
     } else {
/* This means that the $piece is either the beginning or the end of a string.
  So, we'll slurp up the $pieces and stick them together until we get to the
  end of the string or run out of pieces.
*/

// Add this word to the $tmpstring, starting the $tmpstring
       $tmpstring = trim(ereg_replace('"', ' ', $pieces[$k]));

// Check for one possible exception to the rule. That there is a single quoted word.
       if (substr($pieces[$k], -1 ) == '"') {
// Turn the flag off for future iterations
         $flag = 'off';

         $objects[] = trim($pieces[$k]);

         for ($j=0; $j<count($post_objects); $j++) {
           $objects[] = $post_objects[$j];
         }

         unset($tmpstring);

// Stop looking for the end of the string and move onto the next word.
         continue;
       }

// Otherwise, turn on the flag to indicate no quotes have been found attached to this word in the string.
       $flag = 'on';

// Move on to the next word
       $k++;

// Keep reading until the end of the string as long as the $flag is on

       while ( ($flag == 'on') && ($k < count($pieces)) ) {
         while (substr($pieces[$k], -1) == ')') {
           $post_objects[] = ')';
           if (strlen($pieces[$k]) > 1) {
             $pieces[$k] = substr($pieces[$k], 0, -1);
           } else {
             $pieces[$k] = '';
           }
         }

// If the word doesn't end in double quotes, append it to the $tmpstring.
         if (substr($pieces[$k], -1) != '"') {
// Tack this word onto the current string entity
           $tmpstring .= ' ' . $pieces[$k];

// Move on to the next word
           $k++;
           continue;
         } else {
/* If the $piece ends in double quotes, strip the double quotes, tack the
  $piece onto the tail of the string, push the $tmpstring onto the $haves,
  kill the $tmpstring, turn the $flag "off", and return.
*/
           $tmpstring .= ' ' . trim(ereg_replace('"', ' ', $pieces[$k]));

// Push the $tmpstring onto the array of stuff to search for
           $objects[] = trim($tmpstring);

           for ($j=0; $j<count($post_objects); $j++) {
             $objects[] = $post_objects[$j];
           }

           unset($tmpstring);

// Turn off the flag to exit the loop
           $flag = 'off';
         }
       }
     }

 

Does anybody have a clue?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...