[email protected] Posted February 1, 2014 Posted February 1, 2014 okay so step 4 it tells me to copy the tep_parse_search_string function definition in its entirety from catalog/includes/functions/general.php to catalog/admin/includes/functions/general.php so i copy this to it: //// // Output a raw date string in the selected locale date format // $raw_date needs to be in this format: YYYY-MM-DD HH:MM:SS // NOTE: Includes a workaround for dates before 01/01/1970 that fail on windows servers function tep_date_short($raw_date) { if ( ($raw_date == '0000-00-00 00:00:00') || empty($raw_date) ) return false; $year = substr($raw_date, 0, 4); $month = (int)substr($raw_date, 5, 2); $day = (int)substr($raw_date, 8, 2); $hour = (int)substr($raw_date, 11, 2); $minute = (int)substr($raw_date, 14, 2); $second = (int)substr($raw_date, 17, 2); if (@[member='date']('Y', mktime($hour, $minute, $second, $month, $day, $year)) == $year) { return date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, $year)); } else { return preg_replace('/2037$/', $year, date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, 2037))); } } //// // Parse search string into indivual objects function tep_parse_search_string($search_str = '', &$objects) { $search_str = trim(strtolower($search_str)); // Break up $search_str on whitespace; quoted string will be reconstructed later $pieces = preg_split('/[[:space:]]+/', $search_str); $objects = array(); $tmpstring = ''; $flag = ''; for ($k=0; $k<count($pieces); $k++) { while (substr($pieces[$k], 0, 1) == '(') { $objects[] = '('; if (strlen($pieces[$k]) > 1) { $pieces[$k] = substr($pieces[$k], 1); } else { $pieces[$k] = ''; } } $post_objects = array(); while (substr($pieces[$k], -1) == ')') { $post_objects[] = ')'; if (strlen($pieces[$k]) > 1) { $pieces[$k] = substr($pieces[$k], 0, -1); } else { $pieces[$k] = ''; } } // Check individual words 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(preg_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(preg_replace('/"/', ' ', $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(preg_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'; } } } } // add default logical operators if needed $temp = array(); for($i=0; $i<(count($objects)-1); $i++) { $temp[] = $objects[$i]; if ( ($objects[$i] != 'and') && ($objects[$i] != 'or') && ($objects[$i] != '(') && ($objects[$i+1] != 'and') && ($objects[$i+1] != 'or') && ($objects[$i+1] != ')') ) { $temp[] = ADVANCED_SEARCH_DEFAULT_OPERATOR; } } And i get a parse error: Fatal error: Cannot redeclare tep_date_short() (previously declared in /home/d2paradi/public_html/Jeff/includes/functions/general.php:152) in /home/d2paradi/public_html/Jeff/includes/functions/general.php on line 1494 Quote
♥joli1811 Posted February 1, 2014 Posted February 1, 2014 Maybe telling us what you are trying to do would help (w00t) some sort of addon ??? Quote To improve is to change; to be perfect is to change often.
[email protected] Posted February 1, 2014 Author Posted February 1, 2014 (edited) http://addons.oscommerce.com/info/7297 Multi-Product Copy Utility v1.1 by Kevin L. Shelton 7/28/2010 This utility allows you to quickly copy multiple products to another category at one time. This copy is the same as "Link Product" using the "Copy To" button during category / product maintenance. This utility does not create duplicate products. Choose the destination category from the list and search for products to copy by keyword, category, manufacturer or price. You will be presented with a list of products matching your search terms. Products that are already linked to the destination category will not be listed. Look over the list and check the boxes for any product that should be copied; or uncheck the boxes of products that should not be copied if you had the utility automatically check the boxes for you. Click the Confirm button and all of the checked products will be now linked to the destination category (as well as any other categories they already appeared in) and a list of products copied will be displayed. Clicking the "Return To Catalog Entry" button after the copy is done will place you in the category you chose as the destination for the copy so you can check your work. Version 1.1 corrects the queries so that products that are not assigned to a manufacturer can be found. It also adds the ability to find products in the subcategories of the category being searched when searching by category. Instructions: First upload the new files to the indicated places. Now proceed with the files that need to be manually modified. 1) In catalog/admin/includes/filenames.php ADD the following lines somewhere before the closing ?> // Multi-Product Copy Utility define('FILENAME_MULTI_COPY', 'multi_product_copy.php'); 2) In catalog/admin/includes/languages/english.php ADD the following lines somewhere before the closing ?> // Multi-Product Copy Utility define('BOX_CATALOG_MUTLI_COPY', 'Multi-Item Copy'); 3) In catalog/admin/includes/boxes/catalog.php Find the line that reads as follows: array( 'code' => FILENAME_CATEGORIES, 'title' => BOX_CATALOG_CATEGORIES_PRODUCTS, 'link' => tep_href_link(FILENAME_CATEGORIES) ), and immediately below it add the following line: array( 'code' => FILENAME_MULTI_COPY, 'title' => BOX_CATALOG_MUTLI_COPY, 'link' => tep_href_link(FILENAME_MULTI_COPY) ), 4) Copy the tep_parse_search_string function definition in its entirety from catalog/includes/functions/general.php to catalog/admin/includes/functions/general.php. The function should run from line 598 to line 746 unless you have made modifications to functions that appear before it or added additional functions before it. Warning: If you have installed the Multiple Sales Per Product With Named Sales, the Unexpected Overwrite Protected Images with Unlimited Product Images, or the Price Adjusting Utility contributions then you have already performed this step. Don't do it twice or you will create a PHP duplicate function error. Save your changes and you are done. Edited February 1, 2014 by [email protected] Quote
♥kymation Posted February 2, 2014 Posted February 2, 2014 You copied the required code, but you also copied the tep_date_short() function. Remove this code from the Admin file where you pasted it: //// // Output a raw date string in the selected locale date format // $raw_date needs to be in this format: YYYY-MM-DD HH:MM:SS // NOTE: Includes a workaround for dates before 01/01/1970 that fail on windows servers function tep_date_short($raw_date) { if ( ($raw_date == '0000-00-00 00:00:00') || empty($raw_date) ) return false; $year = substr($raw_date, 0, 4); $month = (int)substr($raw_date, 5, 2); $day = (int)substr($raw_date, 8, 2); $hour = (int)substr($raw_date, 11, 2); $minute = (int)substr($raw_date, 14, 2); $second = (int)substr($raw_date, 17, 2); if (@[member='date']('Y', mktime($hour, $minute, $second, $month, $day, $year)) == $year) { return date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, $year)); } else { return preg_replace('/2037$/', $year, date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, 2037))); } } Regards Jim Quote See my profile for a list of my addons and ways to get support.
[email protected] Posted February 2, 2014 Author Posted February 2, 2014 Okay so i paste this code on the bottom of catalog/admin/includes/functions/general.php and still get a parse error //// // Parse search string into indivual objects function tep_parse_search_string($search_str = '', &$objects) { $search_str = trim(strtolower($search_str)); // Break up $search_str on whitespace; quoted string will be reconstructed later $pieces = preg_split('/[[:space:]]+/', $search_str); $objects = array(); $tmpstring = ''; $flag = ''; for ($k=0; $k<count($pieces); $k++) { while (substr($pieces[$k], 0, 1) == '(') { $objects[] = '('; if (strlen($pieces[$k]) > 1) { $pieces[$k] = substr($pieces[$k], 1); } else { $pieces[$k] = ''; } } $post_objects = array(); while (substr($pieces[$k], -1) == ')') { $post_objects[] = ')'; if (strlen($pieces[$k]) > 1) { $pieces[$k] = substr($pieces[$k], 0, -1); } else { $pieces[$k] = ''; } } // Check individual words 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(preg_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(preg_replace('/"/', ' ', $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(preg_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'; } } } } // add default logical operators if needed $temp = array(); for($i=0; $i<(count($objects)-1); $i++) { $temp[] = $objects[$i]; if ( ($objects[$i] != 'and') && ($objects[$i] != 'or') && ($objects[$i] != '(') && ($objects[$i+1] != 'and') && ($objects[$i+1] != 'or') && ($objects[$i+1] != ')') ) { $temp[] = ADVANCED_SEARCH_DEFAULT_OPERATOR; } } Quote
♥14steve14 Posted February 2, 2014 Posted February 2, 2014 What was the error exactly. Quote REMEMBER BACKUP, BACKUP AND BACKUP
[email protected] Posted February 2, 2014 Author Posted February 2, 2014 What was the error exactly. it was a parse error all it did was say the line # and parse error Quote
♥14steve14 Posted February 2, 2014 Posted February 2, 2014 And even now from the information that you have given, are you expecting an answer to your problem. Your not being a lot of help. Post the whole error, and also the corresponding lines of code, plus say ten lines before and after, from what ever file the error is saying contains the error. Quote REMEMBER BACKUP, BACKUP AND BACKUP
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.