Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #225 from gburton/ColorBox
Browse files Browse the repository at this point in the history
Re-introduce Gallery Layout
  • Loading branch information
gburton committed Oct 14, 2015
2 parents 04d1f14 + 403f084 commit f44fb02
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@

define('MODULE_HEADER_TAGS_PRODUCT_COLORBOX_TITLE', 'Colorbox Script');
define('MODULE_HEADER_TAGS_PRODUCT_COLORBOX_DESCRIPTION', 'Add Colorbox Script to specified pages');
?>

define('MODULE_HEADER_TAGS_PRODUCT_COLORBOX_THUMBNAIL_LAYOUT', '<em>%s</em> - maximum of %s thumbnails per product.');

7 changes: 6 additions & 1 deletion includes/modules/header_tags/ht_product_colorbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function check() {
function install() {
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Colorbox Script', 'MODULE_HEADER_TAGS_PRODUCT_COLORBOX_STATUS', 'True', 'Do you want to enable the Colorbox Scripts?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Pages', 'MODULE_HEADER_TAGS_PRODUCT_COLORBOX_PAGES', '" . implode(';', $this->get_default_pages()) . "', 'The pages to add the Colorbox Scripts to.', '6', '0', 'ht_product_colorbox_show_pages', 'ht_product_colorbox_edit_pages(', now())");
tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, date_added) values ('Thumbnail Layout', 'MODULE_HEADER_TAGS_PRODUCT_COLORBOX_LAYOUT', '155', 'Layout of Thumbnails', '6', '0', 'ht_product_colorbox_thumbnail_number', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_HEADER_TAGS_PRODUCT_COLORBOX_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
}

Expand All @@ -70,7 +71,7 @@ function remove() {
}

function keys() {
return array('MODULE_HEADER_TAGS_PRODUCT_COLORBOX_STATUS', 'MODULE_HEADER_TAGS_PRODUCT_COLORBOX_PAGES', 'MODULE_HEADER_TAGS_PRODUCT_COLORBOX_SORT_ORDER');
return array('MODULE_HEADER_TAGS_PRODUCT_COLORBOX_STATUS', 'MODULE_HEADER_TAGS_PRODUCT_COLORBOX_PAGES', 'MODULE_HEADER_TAGS_PRODUCT_COLORBOX_LAYOUT', 'MODULE_HEADER_TAGS_PRODUCT_COLORBOX_SORT_ORDER');
}

function get_default_pages() {
Expand All @@ -81,6 +82,10 @@ function get_default_pages() {
function ht_product_colorbox_show_pages($text) {
return nl2br(implode("\n", explode(';', $text)));
}

function ht_product_colorbox_thumbnail_number() {
return sprintf(MODULE_HEADER_TAGS_PRODUCT_COLORBOX_THUMBNAIL_LAYOUT, MODULE_HEADER_TAGS_PRODUCT_COLORBOX_LAYOUT, array_sum(str_split(MODULE_HEADER_TAGS_PRODUCT_COLORBOX_LAYOUT)));
}

function ht_product_colorbox_edit_pages($values, $key) {
global $PHP_SELF;
Expand Down
12 changes: 1 addition & 11 deletions product_info.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,12 @@

echo tep_image(DIR_WS_IMAGES . $product_info['products_image'], NULL, NULL, NULL, 'itemprop="image" style="display:none;"');

$photoset_layout = '1';
$photoset_layout = (int)MODULE_HEADER_TAGS_PRODUCT_COLORBOX_LAYOUT;

$pi_query = tep_db_query("select image, htmlcontent from " . TABLE_PRODUCTS_IMAGES . " where products_id = '" . (int)$product_info['products_id'] . "' order by sort_order");
$pi_total = tep_db_num_rows($pi_query);

if ($pi_total > 0) {
$pi_sub = $pi_total-1;

while ($pi_sub > 5) {
$photoset_layout .= 5;
$pi_sub = $pi_sub-5;
}

if ($pi_sub > 0) {
$photoset_layout .= ($pi_total > 5) ? 5 : $pi_sub;
}
?>

<div class="piGal pull-right" data-imgcount="<?php echo $photoset_layout; ?>">
Expand Down

0 comments on commit f44fb02

Please sign in to comment.