<?php
/*
  $Id$

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2010 osCommerce

  Released under the GNU General Public License
*/

  class bm_add_footer_information {
    var $code = 'bm_add_footer_information';
    var $group = 'boxes';
    var $title;
    var $description;
    var $sort_order;
    var $enabled = false;
    var $pages;	

    function bm_add_footer_information() {
      $this->title = MODULE_BOXES_INFORMATION_FOOTER_TITLE;
      $this->description = MODULE_BOXES_INFORMATION_FOOTER_DESCRIPTION;

      if ( defined('MODULE_BOXES_INFORMATION_FOOTER_STATUS') ) {
        $this->sort_order = MODULE_BOXES_INFORMATION_FOOTER_SORT_ORDER;
        $this->enabled = (MODULE_BOXES_INFORMATION_FOOTER_STATUS == 'True');
				$this->pages = MODULE_BOXES_INFORMATION_FOOTER_DISPLAY_PAGES;
        $this->group = 'boxes_footer';
      }
    }

    function execute() {
      global $oscTemplate;
		if ($current_page == FILENAME_OURSTORE)	{
		$button_act1 = " act";
		$button_act2 = $button_act3 = $button_act4 = $button_act5 = $button_act6 = "";
		}
		if ($current_page == FILENAME_CONTACT_US)	{
		$button_act2 = " act";
		$button_act2 = $button_act3 = $button_act4 = $button_act5 = $button_act6 = "";
		}
		if ($current_page == FILENAME_PACKAGING)	{
		$button_act3 = " act";
		$button_act2 = $button_act1 = $button_act4 = $button_act5 = $button_act6 = "";
		}
		if ($current_page == FILENAME_SHIPPING)	{
		$button_act4 = " act";
		$button_act2 = $button_act3 = $button_act1 = $button_act5 = $button_act6 = "";
		}
		if ($current_page == FILENAME_PRIVACY)	{
		$button_act5 = " act";
		$button_act2 = $button_act3 = $button_act4 = $button_act1 = $button_act6 = "";
		}
		if ($current_page == FILENAME_CONDITIONS)	{
		$button_act6 = " act";
		$button_act2 = $button_act3 = $button_act4 = $button_act1 = $button_act5 = "";
		}
		
      $data = '<div class="Footer_BoxWrapper">' . 
              '  <h4 class="Footer_BoxHeading">' . MODULE_BOXES_INFORMATION_FOOTER_BOX_TITLE . '</h4>' .
							'  <ul class="footer_information">' .
										'    <li class="'.$button_act1.'">'. tep_draw_box_list_top() . '<a href="' . tep_href_link(FILENAME_OURSTORE) . '">' . MODULE_BOXES_INFORMATION_FOOTER_BOX_OURSTORE . '</a>' . tep_draw_box_list_bottom() . '</li>' .
										'    <li class="'.$button_act2.'">' . tep_draw_box_list_top() . '<a href="' . tep_href_link(FILENAME_CONTACT_US) . '">' . MODULE_BOXES_INFORMATION_FOOTER_BOX_CONTACT . '</a>' . tep_draw_box_list_bottom() . '</li>' .
										'    <li class="'.$button_act3.'">' . tep_draw_box_list_top() . '<a href="' . tep_href_link(FILENAME_PACKAGING) . '">' . MODULE_BOXES_INFORMATION_FOOTER_BOX_DELIVERY . '</a>' . tep_draw_box_list_bottom() . '</li>' .
										'    <li class="'.$button_act4.'">' . tep_draw_box_list_top() . '<a href="' . tep_href_link(FILENAME_SHIPPING) . '">' . MODULE_BOXES_INFORMATION_FOOTER_BOX_SHIPPING . '</a>' . tep_draw_box_list_bottom() . '</li>'.
										'    <li class="'.$button_act5.'">' . tep_draw_box_list_top() . '<a href="' . tep_href_link(FILENAME_PRIVACY) . '">' . MODULE_BOXES_INFORMATION_FOOTER_BOX_PRIVACY . '</a>' . tep_draw_box_list_bottom() . '</li>'.
										'    <li class="'.$button_act6.'">' . tep_draw_box_list_top() . '<a href="' . tep_href_link(FILENAME_CONDITIONS) . '">' . MODULE_BOXES_INFORMATION_FOOTER_BOX_CONDITIONS . '</a>' . tep_draw_box_list_bottom() . '</li>'.
							'  </ul>' .
              '</div>';

      $oscTemplate->addBlock($data, $this->group);
    }

    function isEnabled() {
      return $this->enabled;
    }

    function check() {
      return defined('MODULE_BOXES_INFORMATION_FOOTER_STATUS');
    }

    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 Information Module', 'MODULE_BOXES_INFORMATION_FOOTER_STATUS', 'True', 'Do you want to add the module to your shop?', '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, set_function, date_added) values ('Content Placement', 'MODULE_BOXES_INFORMATION_FOOTER_CONTENT_PLACEMENT', 'Footer Block', 'Should the module be loaded in the footer block only.', '6', '1', 'tep_cfg_select_option(array(\'Footer Block\'), ', 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_BOXES_INFORMATION_FOOTER_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
      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 ('Display in pages.', 'MODULE_BOXES_INFORMATION_FOOTER_DISPLAY_PAGES', 'all', 'select pages where this box should be displayed. ', '6', '0','tep_cfg_select_pages(' , now())");
    }

    function remove() {
      tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
    }

    function keys() {
      return array('MODULE_BOXES_INFORMATION_FOOTER_STATUS', 'MODULE_BOXES_INFORMATION_FOOTER_CONTENT_PLACEMENT', 'MODULE_BOXES_INFORMATION_FOOTER_SORT_ORDER', 'MODULE_BOXES_INFORMATION_FOOTER_DISPLAY_PAGES');
    }
  }
?>
