Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

need help with installing Image Subdirectory


H_Nguyen

Recommended Posts

Posted

can anyone help me with installing the Image Subdirectory contribution module?

 

I have downloaded the Image Subdirectory contribution and have read the readme/install file but I am still in the dark as to what they are saying.

 

what I understand so far is that I have to add 3 simple script in the categories.php area but when I open the categories.php files none of the code that should be available there for me to location the percise area for the new code to be placed in are available in the categories.php file.

 

the contribution was taken from this area:

http://www.oscommerce.com/community/contri...+Subdirectories

 

the name of the contribution I've download was this:

Image Subdirectories 2.0 work with MoPics 6 TheExterminator 11 Dec 2006

 

this is the installation guideline that I am using.

 

Most people are using unmodified versions of categories.php so the installation may be as simple as renaming the existing files to categories.bak in both /admin and /admin/includes/languages/english.

 

There are three changes to admin/categories.php and three simple lines added to /admin/includes/languages/english/categories.php.

 

This contribution is based on the categories.php which is part of the osC 051113 distribution so line numbers reference that file.

 

For languages just open the included english/categories.php file and you'll see the three new lines, they're well commented.

 

define('TEXT_IMAGE_DIRECTORY', 'Image Subdirectory:'); // name of subdir field

define('TEXT_IMAGE_PATH_NOTE' , 'images/.../...'); // note under image subdir name

define('TEXT_IMAGE_PATH_CHECKBOX' , 'New?'); // checkbox next to image subdir name

 

********************************************************************************

***********

 

The changes in admin/categories.php follow...

 

Find immediately after the license (before require('includes/application_top.php');)

 

Insert:

 

// ---------- Configure Image Path Tool Features Below ---------- //

define('USE_REG_GLOBALS_PATCH', 'false'); // Use the register globals fix

define('USE_PHP5_MKDIR', 'false'); // Use the php5 mkdir function, set to false if you need to use chmod after creating directories

define('SHOW_DIR_CHECKBOX', 'true'); // Allow users to create new directories

define('USE_UNIX_SLASHES', 'true'); // Use / slashes for php4 mkdir. Set to false for Windows

// ----------------------- End Configure ----------------------- //

 

The guide for setting the above values is found in the Read_Me_First.txt file

 

*********** Find starting at line 313, ***********

 

// copy image only if modified

$products_image = new upload('products_image');

$products_image->set_destination(DIR_FS_CATALOG_IMAGES);

if ($products_image->parse() && $products_image->save()) {

$products_image_name = $products_image->filename;

} else {

$products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : '');

}

break;

}

}

 

// check if the catalog image directory exists

 

Replace with:

 

// copy image only if modified

$products_image = new upload('products_image');

// ************************* Image path modification starts below *************************

if (USE_REG_GLOBALS_PATCH == 'true') {

link_post_variable('image_subdirectory'); // function included in the Register Globals Patch - functions/general.php

link_post_variable('new_dir'); // function included in the Register Globals Patch - in functions/general.php

}

 

// Here we strip away any extra slashes the user may add to the subdirectory field and make sure there is a final /.

 

$image_subdirectory = preg_replace('/\\\/', '/', $image_subdirectory); // in case someone mistakenly uses backward slashes, flip 'em around

if ($image_subdirectory == '/') { ($image_subdirectory = ''); // in case the user mistakenly entered only a single /

}

if ($image_subdirectory != '') { // we want to add a path

$image_subdirectory = preg_replace('/\/\/+/', '/', $image_subdirectory); // change any multiple slashes to a single /

if (strpos($image_subdirectory, '/') === 0) { $image_subdirectory = substr($image_subdirectory, 1); // strip any leading slash

}

if (strrpos($image_subdirectory, '/') != (strlen($image_subdirectory) -1)) { $image_subdirectory = ($image_subdirectory . '/'); // add one slash at the end if there wasn't one.

}

} // End corrections of any user errors

 

// Create directory if requested (Box Checked, $new_dir == 'onÕ)

if ($new_dir == 'on') {

if (USE_UNIX_SLASHES == 'true') {

$working_directory = DIR_FS_CATALOG_IMAGES . $image_subdirectory;

if (USE_PHP5_MKDIR == 'true') {

if (!is_dir($working_directory)) {

mkdir($working_directory, 0777, 1);

// chmod($working_directory, 0777); // Change to suit server needs, depending on directory owner

}

 

} else { // php4 mkdir recursion

 

do {

$dir = $working_directory;

 

while (!@mkdir($dir,0777)) {

$dir = dirname($dir);

if ($dir == '/' || is_dir($dir))

break;

}

// chmod($dir, 0777); // Change to suit server needs, depending on directory owner

} while ($dir != $working_directory);

 

}

} else { // End unix mkdir routine

 

// Windows mkdir routine start

$working_directory = DIR_FS_CATALOG_IMAGES . preg_replace('/\//', '\\', $image_subdirectory); // replaces forward slashes with backwards ones

if (USE_PHP5_MKDIR == 'true') {

if (!is_dir($working_directory)) {

mkdir($working_directory, 0777, 1); // the 0777 chmod arg. has no effect under Windows, left in for consistency

}

 

} else { // php4 mkdir recursion

 

do {

$dir = $working_directory;

while (!@mkdir($dir)) {

$dir = dirname($dir);

if ($dir == '\\' || is_dir($dir))

break;

}

} while ($dir != $working_directory);

 

}

} // End Windows mkdir routine

}

 

$products_image->set_destination(DIR_FS_CATALOG_IMAGES . $image_subdirectory ); // ***** append server image subdirectory

if ($products_image->parse() && $products_image->save()) {

$products_image_name = $products_image->filename;

$products_image_name = $image_subdirectory . $products_image_name ; // ***** Prepend subdirectory to filename

} else {

$products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : '');

}

break;

}

}

 

// ********** Image path modification ends here **********

 

// check if the catalog image directory exists

 

*********** Find starting at line 506, ***********

 

<?php

}

?>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<td class="main"><?php echo TEXT_PRODUCTS_QUANTITY; ?></td>

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_quantity', $pInfo->products_quantity); ?></td>

</tr>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<td class="main"><?php echo TEXT_PRODUCTS_MODEL; ?></td>

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_model', $pInfo->products_model); ?></td>

</tr>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

 

Immediately following that last </tr> insert:

 

<!-- image subdirectory fields added here -->

<tr>

<td class="main"><?php echo TEXT_IMAGE_DIRECTORY . '<br><small>' . TEXT_IMAGE_PATH_NOTE . '</small>'; ?></td>

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('image_subdirectory', $image_subdirectory);

if (SHOW_DIR_CHECKBOX == 'true') { echo '   ' . TEXT_IMAGE_PATH_CHECKBOX . ' ' .

tep_draw_checkbox_field(new_dir , $value = $new_dir, $checked = false, $parameters = '');} ?>

</td>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '0'); ?></td>

</tr>

<!-- image subdirectory addition finished -->

 

I also tweaked the vertical spacing a little by changing three lines later (old line no. 564, new line no. 653 )

 

from:

 

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_file_field('products_image') . '<br>' . tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . $pInfo->products_image . tep_draw_hidden_field('products_previous_image', $pInfo->products_image); ?></td>

 

 

to:

 

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '10') . ' ' . tep_draw_file_field('products_image') . '<br>' . tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . $pInfo->products_image . tep_draw_hidden_field('products_previous_image', $pInfo->products_image); ?></td>

 

 

That's only changing the '15' to '10' in the first separator.

 

 

 

THANK YOU FOR ALL YOUR HELP.

Archived

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

×
×
  • Create New...