
Originally Posted by
dw08gm
I recall seeing one instance of -1, but was not aware there were three places to look. Will have to revisit.
The -1 is in 1 place, but there are 2 places (soon to be 3) that have added javascript to blank out the manufacturer selection when choosing a category or product.

Originally Posted by
dw08gm
ps. To make code changes easier to spot in the forum, may I suggest changing the color of relevent section of code to say red/blue = old/new.
I agree, should have thought of that, I'm thinking like I'm stuck in a coding editor...
Here's what I'll do:
Code:
gray = code that stayed the same, shown so you can reference/search
green = new code (including coded remarks)
red = code that was removed
blue = code that replaced removed code
purple = an additional file/script that is required
black bold italic = instructions, line references (not coded remarks)
For this message only I bolded in dark green those changes made yesterday.
I went back and compared your files to my latest, so line # references are actually from your ec_4_alpha.zip release.
Here's all the changes I have made (up to this moment) to admin/event_manager.php since downloading your alpha version:
(Additional Note: When testing the "upcoming products" javascript mod I came across a preexisting problem with the links not being created correctly. I traced it to line 355. There is an integer variable ($sep) that I could not find a reference to anywhere (that includes all files under the Zen Carts admin directory). I changed the code (in bold dark blue) so it works now.)
Code:
--BEGIN Changes starting at line 11
require('includes/application_top.php');
//** rus: start
//** rus: library/class to manipulate images (by Phil Brown: https://gist.github.com/philBrown/880506
require('includes/classes/image_manipulator.php');
define(EVENT_FILE_MAX_WIDTH, '600'); //** rus: for max image width in px, check on file uploads
$file_to_delete = ''; //** rus: no easy way to get rid of invalid file, so I delete this file (if set) at the end.
define(FILENAME_DEFAULT_CATALOG, 'index'); //** rus: corrected 3/23/2013
//** rus: stop
//** rus: removed: define(FILENAME_DEFAULT_CATALOG, 'index.php');
define(FILENAME_PRODUCT_INFO, 'product_info.php');
--END Changes starting at line 11
--BEGIN Changes starting at line 76
//** rus: start: check to see if file is an image and if too wide
$wf_parse = $working_file->parse();
//**rus: changed if($working_file->parse() != false)
//**rus: changed {
if($wf_parse != false) {
//** valid image extensions
$validext = array('.jpg', '.jpeg', '.gif', '.png');
$fileext = strtolower(strrchr($working_file->filename, "."));
if (!in_array($fileext, $validext)) {
$messageStack->add('Uploaded file ' . $working_file->filename . ' is not a jpg, jpeg, png, or gif.', 'error');
$event_error = true;
$success = false;
$file_to_delete = $working_file->destination . $working_file->filename;
$_POST['no_image'] = 'on';
} else {
$eman = new ImageManipulator($working_file->tmp_filename);
$ewid = $eman->getWidth();
$ehei = $eman->getHeight();
$nwid = 0;
if ($ewid > EVENT_FILE_MAX_WIDTH) {
$nwid = EVENT_FILE_MAX_WIDTH;
$nhei = intval($ehei * ($nwid / $ewid));
$enew = $eman->resample($nwid, $nhei);
}
$eufile = $working_file->destination . $working_file->filename;
//** rus: stop
// rename here if required
$working_file->set_filename($working_file->filename);
//** rus: start
//** in a situation where a file was uploaded and resized then possibly uploaded again...
//** code was overwriting resized file with newly uploaded (original) bigger image
//** instead of chasing down why, I took the easy way out and just delete the image/file if it exists
//** this worked in my scenario (12 to 20 events a year), user just uploads new image...
//** if any old events used the same image filename then they would all now show the new image
if (file_exists($eufile)) {
unlink($eufile);
}
//** rus: stop
if ( !$working_file->save(false) == false)
{
$upload_success = true;
//** rus: removed (redundant): $messageStack->add('File Uploaded', 'success');
//** rus: start: if we resized then delete original (that was just saved) and save new resized image
//** more time consuming I know, but upload() function was generating $messageStack...
//** errors when image changed before $working_file save.
if ($nwid > 0) {
unlink($eufile);
$messageStack->add('Image was resized from ' . $ewid . ' by ' . $ehei . ' to ' . $nwid . ' by ' . $nhei . '.', 'success');
$eman->save($eufile);
$working_file->file = $eman->file;
}
//** rus: stop
}else{
$messageStack->add('There was a problem saving your file - perhaps you need to rename it', 'error');
}
$uploaded_image = $working_file->filename;
} //** rus: end if from above
}
else
{
if($_POST['no_image'] == 'on' )
{
// remove image
$uploaded_image = '';
}
else
{
//** rus: start
$event_error = true;
$success = false;
if ($_FILES['event_image']['error']!=UPLOAD_ERR_NO_FILE) $messageStack->add('There was an error uploading your image file (may be too large)', 'error');
//** rus: stop
// set it to the previous image
$uploaded_image = $_POST['event_previous_image'];
}
}
//==============================
// eof deal with upload - Niccol
//==============================
--END Changes starting at line 76
--BEGIN Changes starting at line 335
<?php
// } // removed, see line 291
if($_POST['manufacturers_id']!= ''){
//** rus: start
if ($_POST['manufacturers_id']== '-1'){
$ZC_link = '';
$ZC_links = '';
} else {
//** rus: stop
$manufacturers = $db->Execute("select manufacturers_name from ". TABLE_MANUFACTURERS ." where manufacturers_id = '" . $_POST['manufacturers_id'] . "'");
if ($manufacturers) {
$manufacturers_name = $manufacturers->fields['manufacturers_name'];
}
$ZC_link = zen_catalog_href_link(FILENAME_DEFAULT_CATALOG , 'manufacturers_id='. $_POST['manufacturers_id'] );
$ZC_links = '<a href='. $ZC_link .' target=_blank>'. $manufacturers_name .'</a>';
} //** rus: end if *******************
} elseif ($_POST['cPath']!= 0){
$ZC_link = zen_catalog_href_link(FILENAME_DEFAULT_CATALOG , 'cPath='. $_POST['cPath'] );
$ZC_links = '<a href='. $ZC_link .' target=_blank>'. zen_get_category_name($_POST['cPath'], $_SESSION['languages_id']) .'</a>';
} elseif ($_POST['products_id'] != ''){
$ZC_link = zen_catalog_href_link(FILENAME_PRODUCT_INFO , 'products_id='. $_POST['products_id'] );
//** rus: changed: $ZC_links = '<a href='. $ZC_link .'>'. zen_get_products_name($_POST['products_id']) .'</a>';
$ZC_links = '<a href='. $ZC_link .' target=_blank>'. zen_get_products_name($_POST['products_id']) .'</a>';
} elseif ($_POST['upcoming'] != ''){
//** rus: changed: $ZC_link = zen_catalog_href_link(FILENAME_PRODUCT_INFO , 'products_id='. substr($_POST['upcoming'],0,$sep) );
$ZC_link = zen_catalog_href_link(FILENAME_PRODUCT_INFO , 'products_id='. $_POST['upcoming']);
//** rus: changed: $ZC_links = '<a href='. $ZC_link .'>'. zen_get_products_name($_POST['upcoming']) .'</a>';
$ZC_links = '<a href='. $ZC_link .' target=_blank>'. zen_get_products_name($_POST['upcoming']) .'</a>';
} else {
$ZC_links = (($_POST['ZC_link']) ? $_POST['ZC_link'] : $events->fields['ZC_link']);
}
?>
--END Changes starting at line 335
--BEGIN Changes starting at end of file(line 667)
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
<?php
//** rus: start
//** used this workaround to get rid of files that were not valid images since the...
//** original code writes files even when error variables are set
if ($file_to_delete != '') {
unlink($file_to_delete);
}
//** rus: stop
?>
--END Changes at end of file
Here's all the changes I have made (up to this moment) to admin/includes/events_manager_drop_dns.php since downloading your alpha version (including the new javascript changes for upcoming products):
Code:
--BEGIN Changes starting at line 18
<!-- bof manufacturers -->
<?php
$heading = array();
$heading[] = array('align' => 'left', 'text' => TEXT_CHOOSE_MANUFACTURER);
$manufacturers_values = $db->Execute("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name");
//**rus: changed $select_box = '<select name="manufacturers_id" onChange="submit();">';
$select_box = '<select name="manufacturers_id" id="manufacturers_id_sel" onChange="submit();">';
//** rus: removed: if (MAX_MANUFACTURERS_LIST < 2) {
//** rus: removed: $select_box .= '<option value="">Select</option>';
//** rus: removed: }
//** rus: start
$select_box .= '<option value="-1">No Manufacturer</option>';
$dum_pos = strpos($ZC_links,'manufacturers_id=');
$manz_id = '';
if ($dum_pos) {
$manz_id = substr($ZC_links,$dum_pos+17);
$manz_id = current(explode(" ", $manz_id));
}
if (isset($_POST['manufacturers_id']) && $_POST['manufacturers_id']>0) {
$man_cur = $_POST['manufacturers_id'];
} else {
if ($manufacturers) {
$man_cur = $manufacturers->fields['manufacturers_id'];
} else {
$man_cur = '';
}
}
if ($man_cur=='') $man_cur=$manz_id;
//** rus: stop
while (!$manufacturers_values->EOF) {
//** rus: removed: $select_box .= '<option value="' . $manufacturers_values->fields['manufacturers_id'] . '"';
// if ($_POST['manufacturers_id'] == $manufacturers_values['manufacturers_id']) $select_box .= ' SELECTED';
//** rus: start: try this another way
if ($manufacturers_values->fields['manufacturers_id'] == $man_cur) {
$select_box .= '<option selected value="' . $manufacturers_values->fields['manufacturers_id'] . '"';
} else {
$select_box .= '<option value="' . $manufacturers_values->fields['manufacturers_id'] . '"';
}
//** rus: stop
$select_box .= '>' . substr($manufacturers_values->fields['manufacturers_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '</option>';
$manufacturers_values->MoveNext();
}
$select_box .= "</select>";
--END Changes starting at line 18
--BEGIN Changes starting at line 46
!-- bof categories -->
<?php
$heading = array();
$heading[] = array('align' => 'left', 'text' => TEXT_CHOOSE_CATEGORY);
$info_box_contents = array();
//** rus: start
$dum_oc = "document.getElementById('manufacturers_id_sel').value = ''; submit();";
$info_box_contents[] = array('form' => '', 'align' => 'left', 'text' => zen_draw_pull_down_menu('cPath', zen_get_category_tree(), '', 'onChange="' . $dum_oc . '"'));
//** rus: replaced: $info_box_contents[] = array('form' => '', 'align' => 'left', 'text' => zen_draw_pull_down_menu('cPath', zen_get_category_tree(), '', 'onChange="submit();"'));
//** rus: stop
$box = new box;
echo $box->menuBox($heading, $info_box_contents);
?>
<!-- eof categories -->
--END Changes starting at line 46
--BEGIN Changes starting at line 78
$listing_products->MoveNext();
}
//** rus: start
$info_box_contents[] = array('form' => '', 'align' => 'left', 'text' => zen_draw_pull_down_menu('products_id', $products_array, '','onChange="' . $dum_oc . '"'));
//** rus: replaced: $info_box_contents[] = array('form' => '', 'align' => 'left', 'text' => zen_draw_pull_down_menu('products_id', $products_array, '','onChange="submit();"'));
//** rus: stop
$box = new box;
echo $box->menuBox($heading, $info_box_contents);
} else {
--END Changes starting at line 78
--This is the change you will need to make for "upcoming products".
--BEGIN Changes starting at line 109
//while ($upcoming_products = zen_db_fetch_array($upcoming_query))
while (!$upcoming_products->EOF) {
$upcoming_array[] = array('id' => $upcoming_products->fields['products_id'], 'text' => $upcoming_products->fields['products_name'] .' | expected: '. substr($upcoming_products->fields['products_date_available'],0,10));
$upcoming_products->MoveNext();
}
//** rus: start
$info_box_contents[] = array('form' => '', 'align' => 'left', 'text' => (zen_draw_pull_down_menu('upcoming', $upcoming_array, ' ','onChange="' . $dum_oc . '"')));
//** rus: replaced: $info_box_contents[] = array('form' => '', 'align' => 'left', 'text' => (zen_draw_pull_down_menu('upcoming', $upcoming_array, ' ','onChange="submit();"')));
//** rus: stop
$box = new box;
echo $box->menuBox($heading, $info_box_contents);
} else {
--END Changes starting at line 109
Here's all the changes I have made (up to this moment) to includes/templates/your_template/templates/tpl_events_calendar_default.php since downloading your alpha version:
Code:
--BEGIN Changes starting at line 172
<!-- bof event image - scales and fits images to outer div -->
<?php
//** rus: added php block to stop trying to show image when there isn't one in db
if ($event_array['image']!="") {
?>
<div class="event_image_outer">
<div class="event_image_inner">
<!-- Note: closing ' />' for <img> is located in function zen_image -->
<img class="c1" <?php echo zen_image(DIR_WS_IMAGES .'events_images/' . $event_array['image'], '', '', 'hspace="0" vspace="0"');?>
</div>
<div class="clearLeft"> </div>
</div>
<?php
//** rus: added php block
}
?>
<!-- eof event image -->
--END Changes starting at line 172
--BEGIN Changes starting at line 250
else if($_GET['view'] == 'all_events')
{ //Show all Events from current date.
//** rus: start
//** rus: changed $events_query_raw = "select *, DAYOFMONTH(start_date) AS event from ".TABLE_EVENTS_CALENDAR."
//** rus: changed where (start_date >= '" . date('Y-m-d H:i:s') . "' or end_date >= '" . date('Y-m-d H:i:s') . "')"
//** rus: changed . " and language_id = '" . $_SESSION['languages_id'] . "' order by start_date";
$events_query_raw = "select *, DAYOFMONTH(start_date) AS event from ".TABLE_EVENTS_CALENDAR."
where (start_date >= '" . date('Y-m-d') . "' or end_date >= '" . date('Y-m-d') . "')"
. " and language_id = '" . $_SESSION['languages_id'] . "' order by start_date";
//** rus: stop
$listingTitle = TEXT_FORTHCOMING_EVENTS;
$displayPagingSuffix = NULL; // NULL or $listingTitle
require(DIR_WS_MODULES . 'events_calendar_listing.php');
}
--END Changes starting at line 250
So, just to reiterate, these are all of the changes I have made to the events calendar I have running (and working) on my box. Anything that was changed yesterday or this morning (since I uploaded the ...rus_alpha zip) is in either bold dark green or bold dark blue.
Let me know if you need anything else on this.
Thanks again for your efforts,
Rus