<?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_stay_connected {
    var $code = 'bm_add_footer_stay_connected';
    var $group = 'boxes';
    var $title;
    var $description;
    var $sort_order;
    var $enabled = false;
    var $pages;	

    function bm_add_footer_stay_connected() {
      $this->title = MODULE_BOXES_SOC_ICONS_TITLE;
      $this->description = MODULE_BOXES_SOC_ICONS_DESCRIPTION;

      if ( defined('MODULE_BOXES_SOC_ICONS_STATUS') ) {
        $this->sort_order = MODULE_BOXES_SOC_ICONS_SORT_ORDER;
        $this->enabled = (MODULE_BOXES_SOC_ICONS_STATUS == 'True');
        $this->pages = MODULE_BOXES_SOC_ICONS_DISPLAY_PAGES;
        $this->group = 'boxes_footer';
      }
    }

    function execute() {
      global $oscTemplate;

      $data = '<div class="Footer_BoxWrapper">' . 
              '  <h4 class="Footer_BoxHeading">' . MODULE_BOXES_SOC_ICONS_BOX_TITLE . '</h4>' .
			  			'  <ul class="footer_information footer_stay_connected">' .
              '    <li class="item_1">' . tep_draw_box_list_top() . '<a href="' . MODULE_BOXES_SOC_ICONS_BOX_FACEBOOK_LINK . '">' . MODULE_BOXES_SOC_ICONS_BOX_FACEBOOK . '</a>' . tep_draw_box_list_bottom() . '</li>' .
              '    <li class="item_2">' . tep_draw_box_list_top() . '<a href="' . MODULE_BOXES_SOC_ICONS_BOX_TWITTER_LINK . '">' . MODULE_BOXES_SOC_ICONS_BOX_TWITTER . '</a>' . tep_draw_box_list_bottom() . '</li>' .
              '    <li class="item_3">' . tep_draw_box_list_top() . '<a href="' . MODULE_BOXES_SOC_ICONS_BOX_RSS_LINK . '">' . MODULE_BOXES_SOC_ICONS_BOX_RSS . '</a>' . tep_draw_box_list_bottom() . '</li>' .
							'    <li class="item_4">' . tep_draw_box_list_top() . '<a href="' . MODULE_BOXES_SOC_ICONS_BOX_GOOGLE_LINK . '">' . MODULE_BOXES_SOC_ICONS_BOX_GOOGLE . '</a>' . tep_draw_box_list_bottom() . '</li>' .
							'    <li class="item_5">' . tep_draw_box_list_top() . '<a href="' . MODULE_BOXES_SOC_ICONS_BOX_PRINTEREST_LINK . '">' . MODULE_BOXES_SOC_ICONS_BOX_PRINTEREST . '</a>' . tep_draw_box_list_bottom() . '</li>' .
							'    <li class="item_6">' . tep_draw_box_list_top() . '<a href="' . MODULE_BOXES_SOC_ICONS_BOX_YOUTUBE_LINK . '">' . MODULE_BOXES_SOC_ICONS_BOX_YOUTUBE . '</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_SOC_ICONS_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_SOC_ICONS_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_SOC_ICONS_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_SOC_ICONS_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_SOC_ICONS_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_SOC_ICONS_STATUS', 'MODULE_BOXES_SOC_ICONS_CONTENT_PLACEMENT', 'MODULE_BOXES_SOC_ICONS_SORT_ORDER','MODULE_BOXES_SOC_ICONS_DISPLAY_PAGES');
    }
  }
?>
