<?php
/*
  www.oscGold.com (C) Kamelia-Net Jacek Krysiak
  modul oscGold wer 4.0
*/

$column_query = tep_db_query('select configuration_column as cfgcol, configuration_title as cfgtitle, configuration_value as cfgvalue, dodatkowe_info from ' . TABLE_THEME_CONFIGURATION . ' WHERE configuration_column = "right" AND configuration_value = "yes" order by location' );

while ($column = tep_db_fetch_array($column_query)) {

	$column['cfgtitle'] = str_replace(' ', '_', $column['cfgtitle']);
    $column['cfgtitle'] = str_replace("'", '', $column['cfgtitle']);

	if ( ($column['cfgvalue'] == 'yes') && ($column['cfgcol'] == 'right')) {

		$lewa_strona = "false";

		// Dynamiczne tworzenie boxow ze stron informacyjnych
		// Julek Krysiak (C) 2008 - www.oscgold.com
		if (substr($column['cfgtitle'],0,8) == 'infobox_') {
			$dlg = strlen($column['cfgtitle'])-8;
			$liczba = substr($column['cfgtitle'],8,$dlg);
			//
			$p_query = tep_db_query("select pages_id,pages_title,pages_html_text from " .TABLE_PAGES_DESCRIPTION . " where pages_id = '".(int)$liczba."' and language_id = '" .(int)$languages_id . "'");
			$pages = tep_db_fetch_array($p_query);
			//
			$boxHeading = $pages['pages_title'];
			$boxContent_attributes = '';
			$box_base_name = $column['cfgtitle'];
			
			if (strpos($pages['pages_html_text'],'<***>') > 0) {
				$boxContent = substr($pages['pages_html_text'],0,strpos($pages['pages_html_text'],'<***>')).'<br><a class="boxLink" href="' . tep_href_link(FILENAME_PAGES, 'pages_id=' . $pages['pages_id']) . '">&nbsp;['.TEXT_NEWSDESK_READMORE.']</a>';
			  } else {
				$boxContent = $pages['pages_html_text'];
			}	
			
			include (bts_select('boxes', $box_base_name));
		// koniec

		} else {

			if ( file_exists(DIR_WS_TEMPLATES . 'local_boxes/' . $column['cfgtitle'] . '.php') ) {

				if ((USE_CACHE == 'true') && empty($SID) && ($column['cfgtitle'] == 'categories') ) {
						 echo tep_cache_categories_box();
				} else if ((USE_CACHE == 'true') && empty($SID) && ($column['cfgtitle'] == 'best_sellers') ) {
						 echo tep_cache_best_sellers_box();
				} else if ((USE_CACHE == 'true') && empty($SID) && ($column['cfgtitle'] == 'manufacturers') ) {
						 echo tep_cache_manufacturers_box();
				} else if ((USE_CACHE == 'true') && empty($SID) && ($column['cfgtitle'] == 'manufacturers_std') ) {
						 echo tep_cache_manufacturers_std_box();
				} else {
							require(DIR_WS_TEMPLATES . 'local_boxes/' . $column['cfgtitle'] . '.php');
				}

			} else {
				if ( file_exists(DIR_WS_BOXES . $column['cfgtitle'] . '.php') ) {

					if ((USE_CACHE == 'true') && empty($SID) && ($column['cfgtitle'] == 'categories') ) {
							 echo tep_cache_categories_box();
					} else if ((USE_CACHE == 'true') && empty($SID) && ($column['cfgtitle'] == 'best_sellers') ) {
							 echo tep_cache_best_sellers_box();
					} else if ((USE_CACHE == 'true') && empty($SID) && ($column['cfgtitle'] == 'manufacturers') ) {
							 echo tep_cache_manufacturers_box();
					} else if ((USE_CACHE == 'true') && empty($SID) && ($column['cfgtitle'] == 'manufacturers_std') ) {
							 echo tep_cache_manufacturers_std_box();
					} else {
								require(DIR_WS_BOXES . $column['cfgtitle'] . '.php');
					}
				}
			}

		}
	}
}
?>