Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2 Adjust Generated SQL in Error Log #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// So far, no additional values have been inserted.
//
$zca_responsive_classic_config_changes = array();

// -----
// 1) Configuration->Layout Settings:
//
Expand Down Expand Up @@ -55,7 +55,7 @@
VALUES
('Responsive Mobile Full Site Version Width', 'SET_MAX_WIDTH', '1024', 'Set Width of Responsive Mobile Full Site Version<br />Default is <b>1024px</b>, To give mobile users same experience.', 19, NOW(), 203, NULL , NULL)"
);
}
}
// -----
// 2) Configuration->Product Listing
//
Expand Down Expand Up @@ -96,8 +96,8 @@
VALUES
('Listing Columns Per Row (Mobile)', 'PRODUCT_LISTING_COLUMNS_PER_ROW_MOBILE', '1', '<br /><br />Set the number of columns (products) to show in each row on product listing pages for mobile devices. The default setting is 1.', 8, NOW(), 203, NULL , NULL)"
);
}
}

// -----
// 3) Configuration->Product Info
//
Expand All @@ -110,7 +110,7 @@
VALUES
('Use Photoswipe Lightbox', 'ZCA_PHOTOSWIPE_STATUS', 'false', 'Default is <b>false</b>, Opens images in an individual modal, <b>true</b> opens images in a photoswipe lightbox.', 18, NOW(), 200, NULL, 'zen_cfg_select_option(array(''true'',''false''),')"
);
}
}
if (!defined('SHOW_PRODUCT_INFO_COLUMNS_ALSO_PURCHASED_PRODUCTS_TABLET')) {
$zca_responsive_classic_config_changes[] = $zca_which_group . 'Also Purchased Products Columns per Row (Tablet)';
$db->Execute(
Expand All @@ -119,7 +119,7 @@
VALUES
('Also Purchased Products Columns per Row (Tablet)', 'SHOW_PRODUCT_INFO_COLUMNS_ALSO_PURCHASED_PRODUCTS_TABLET', '2', 'Also Purchased Products Columns per row on (Tablet Devices). Default = 2', 18, NOW(), 202, NULL, 'zen_cfg_select_option(array(\'0\', \'1\', \'2\', \'3\', \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'10\', \'11\', \'12\'),')"
);
}
}
if (!defined('SHOW_PRODUCT_INFO_COLUMNS_ALSO_PURCHASED_PRODUCTS_MOBILE')) {
$zca_responsive_classic_config_changes[] = $zca_which_group . 'Also Purchased Products Columns per Row (Mobile)';
$db->Execute(
Expand All @@ -128,7 +128,7 @@
VALUES
('Also Purchased Products Columns per Row (Mobile)', 'SHOW_PRODUCT_INFO_COLUMNS_ALSO_PURCHASED_PRODUCTS_MOBILE', '1', 'Also Purchased Products Columns per row on (Mobile Devices). Default = 1', 18, NOW(), 203, NULL, 'zen_cfg_select_option(array(\'0\', \'1\', \'2\', \'3\', \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'10\', \'11\', \'12\'),')"
);
}
}
// -----
// 3) Configuration->Images
//
Expand All @@ -141,7 +141,7 @@
VALUES
('Product Info - Number of Additional Images per Row (Mobile)', 'IMAGES_AUTO_ADDED_MOBILE', '1', 'Product Info - Enter the number of additional images to display per row on (Mobile Devices). Default = 1', 4, NOW(), 200, NULL, 'zen_cfg_select_option(array(\'0\', \'1\', \'2\', \'3\', \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'10\', \'11\', \'12\'),')"
);
}
}
if (!defined('IMAGES_AUTO_ADDED_TABLET')) {
$zca_responsive_classic_config_changes[] = $zca_which_group . 'Product Info - Number of Additional Images per Row (Tablet)';
$db->Execute(
Expand All @@ -150,7 +150,7 @@
VALUES
('Product Info - Number of Additional Images per Row (Tablet)', 'IMAGES_AUTO_ADDED_TABLET', '2', 'Enter the number of additional images to display per row on (Tablet Devices). Default = 2', 4, NOW(), 201, NULL, 'zen_cfg_select_option(array(\'0\', \'1\', \'2\', \'3\', \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'10\', \'11\', \'12\'),')"
);
}
}
// -----
// 3) Configuration->Maximum Values
//
Expand All @@ -163,7 +163,7 @@
VALUES
('Categories To List Per Row (Mobile)', 'MAX_DISPLAY_CATEGORIES_PER_ROW_MOBILE', '1', 'How many categories to list per row on (Mobile Devices). Default = 1', 3, NOW(), 200, NULL, 'zen_cfg_select_option(array(\'0\', \'1\', \'2\', \'3\', \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'10\', \'11\', \'12\'),')"
);
}
}
if (!defined('MAX_DISPLAY_CATEGORIES_PER_ROW_TABLET')) {
$zca_responsive_classic_config_changes[] = $zca_which_group . 'Categories To List Per Row (Tablet)';
$db->Execute(
Expand All @@ -172,7 +172,7 @@
VALUES
('Categories To List Per Row (Tablet)', 'MAX_DISPLAY_CATEGORIES_PER_ROW_TABLET', '2', 'How many categories to list per row on (Tablet Devices). Default = 2', 3, NOW(), 201, NULL, 'zen_cfg_select_option(array(\'0\', \'1\', \'2\', \'3\', \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'10\', \'11\', \'12\'),')"
);
}
}
// -----
// 3) Configuration->Index Listing
//
Expand All @@ -185,7 +185,7 @@
VALUES
('Featured Products Columns per Row (Mobile)', 'SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS_MOBILE', '1', 'Featured Products Columns per row on (Mobile Devices). Default = 1', 24, NOW(), 200, NULL, 'zen_cfg_select_option(array(\'0\', \'1\', \'2\', \'3\', \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'10\', \'11\', \'12\'),')"
);
}
}
if (!defined('SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS_TABLET')) {
$zca_responsive_classic_config_changes[] = $zca_which_group . 'Featured Products Columns per Row (Tablet)';
$db->Execute(
Expand All @@ -203,7 +203,7 @@
VALUES
('New Products Columns per Row (Mobile)', 'SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS_MOBILE', '1', 'New Products Columns per row on (Mobile Devices). Default = 1', 24, NOW(), 200, NULL, 'zen_cfg_select_option(array(\'0\', \'1\', \'2\', \'3\', \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'10\', \'11\', \'12\'),')"
);
}
}
if (!defined('SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS_TABLET')) {
$zca_responsive_classic_config_changes[] = $zca_which_group . 'New Products Columns per Row (Tablet)';
$db->Execute(
Expand All @@ -221,7 +221,7 @@
VALUES
('Special Products Columns per Row (Mobile)', 'SHOW_PRODUCT_INFO_COLUMNS_SPECIALS_PRODUCTS_MOBILE', '1', 'Special Products Columns per row on (Mobile Devices). Default = 1', 24, NOW(), 200, NULL, 'zen_cfg_select_option(array(\'0\', \'1\', \'2\', \'3\', \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'10\', \'11\', \'12\'),')"
);
}
}
if (!defined('SHOW_PRODUCT_INFO_COLUMNS_SPECIALS_PRODUCTS_TABLET')) {
$zca_responsive_classic_config_changes[] = $zca_which_group . 'Special Products Columns per Row (Tablet)';
$db->Execute(
Expand All @@ -230,15 +230,15 @@
VALUES
('Special Products Columns per Row (Tablet)', 'SHOW_PRODUCT_INFO_COLUMNS_SPECIALS_PRODUCTS_TABLET', '2', 'Special Products Columns per row on (Tablet Devices). Default = 2', 24, NOW(), 201, NULL, 'zen_cfg_select_option(array(\'0\', \'1\', \'2\', \'3\', \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'10\', \'11\', \'12\'),')"
);
}
}
// -----
// If any insertions were performed above, let the admin know via message.
//
if (count($zca_responsive_classic_config_changes) != 0) {
$zca_responsive_classic_config_changes = '<ol><li>' . implode('</li><li>', $zca_responsive_classic_config_changes) . '</li></ol>';
$messageStack->add(sprintf(ZCA_DIY_SETTINGS_ADDED, $zca_responsive_classic_config_changes), 'warning');
}

// -----
// Next, update the description and title of a couple of the built-in settings to let the store owner know that
// they're not applicable/used when the ZCA DIY templates is active.
Expand Down Expand Up @@ -316,16 +316,16 @@

// $db->Execute(
// "ALTER TABLE " . TABLE_LAYOUT_BOXES . " DROP COLUMN layout_box_status_mobile");

// $db->Execute(
// "ALTER TABLE " . TABLE_LAYOUT_BOXES . " DROP COLUMN layout_box_status_tablet");
// "ALTER TABLE " . TABLE_LAYOUT_BOXES . " DROP COLUMN layout_box_status_tablet");

// $db->Execute(
// "ALTER TABLE " . TABLE_LAYOUT_BOXES . " ADD COLUMN layout_box_status_mobile TINYINT(1) NOT NULL default '1' after layout_box_status_single");

// $db->Execute(
// "ALTER TABLE " . TABLE_LAYOUT_BOXES . " ADD COLUMN layout_box_status_tablet TINYINT(1) NOT NULL default '1' after layout_box_status_mobile");

// -----
// If the current template has just been CHANGED to the ZCA Responsive Classic (or a clone), ensure that the
// Zen Cart configuration values required contain the recommended values for the template (if existing).
Expand All @@ -348,16 +348,17 @@
'PRODUCT_LISTING_MULTIPLE_ADD_TO_CART' => '0'
);
$sql_update = '';
$zca_table_configuration = preg_replace("/".DB_PREFIX."/", '', TABLE_CONFIGURATION, 1);
foreach ($zca_responsive_classic_configs as $key => $value) {
if (constant($key) != $value) {
$sql_update .= ("UPDATE " . TABLE_CONFIGURATION . " SET configuration_value = '$value', last_modified = now() WHERE configuration_key = '$key' LIMIT 1;" . PHP_EOL);
$sql_update .= ("UPDATE " . $zca_table_configuration . " SET configuration_value = '$value', last_modified = now() WHERE configuration_key = '$key' LIMIT 1;" . PHP_EOL);
}
}

if ($sql_update != '') {
$logfile_name = DIR_FS_LOGS . '/zca_responsive_classic_' . date('YmdHis') . '.log';
$messageStack->add(sprintf(ZCA_DIY_CONFIG_WARNING, $logfile_name), 'warning');

$logfile_data = 'The ZCA "Responsive Classic" template (or a clone) was activated on ' . date('Y-m-d H:i:s') . ' and some of its default settings are different than those currently set. You can copy and paste the following SQL into your admin\'s Tools->Install SQL Patches to change those defaults:' . PHP_EOL . PHP_EOL . $sql_update;
error_log($logfile_data, 3, $logfile_name);
}
Expand Down