Projekt

Allgemein

Profil

GX-Bug #24403 » ProductMediaContentView.inc.php

Till Tepelmann, 22.07.2014 14:46

 
1
<?php
2
/* --------------------------------------------------------------
3
   ProductMediaContentView.inc.php 2010-11-18 gambio
4
   Gambio GmbH
5
   http://www.gambio.de
6
   Copyright (c) 2010 Gambio GmbH
7
   Released under the GNU General Public License (Version 2)
8
   [http://www.gnu.org/licenses/gpl-2.0.html]
9
   --------------------------------------------------------------
10

    
11

    
12
   based on:
13
   (c) 2003	 nextcommerce (products_media.php,v 1.8 2003/08/25); www.nextcommerce.org
14
   (c) 2003 XT-Commerce - community made shopping http://www.xt-commerce.com ($Id: products_media.php 1259 2005-09-29 16:11:19Z mz $)
15

    
16
   Released under the GNU General Public License
17
   ---------------------------------------------------------------------------------------*/
18

    
19
require_once(DIR_FS_INC . 'xtc_filesize.inc.php');
20
require_once(DIR_FS_INC . 'xtc_in_array.inc.php');
21

    
22
class ProductMediaContentView extends ContentView
23
{
24
	function ProductMediaContentView()
25
	{
26
		$this->set_content_template('module/products_media.html');
27
		$this->set_flat_assigns(true);
28
	}
29
	
30
	function get_html($p_products_id, $p_languages_id)
31
	{
32
		$c_products_id = (int)$p_products_id;
33
		$c_languages_id = (int)$p_languages_id;
34
		$t_html_output = '';
35
				
36
		// check if allowed to see
37
		$t_check_result = xtDBquery("SELECT DISTINCT
38
											products_id
39
										FROM " . TABLE_PRODUCTS_CONTENT . "
40
										WHERE languages_id = '" . $c_languages_id . "'");
41

    
42
		$t_check_data_array = array();
43
		$i = 0;
44
		while($t_content_data_array = xtc_db_fetch_array($t_check_result,true))
45
		{
46
			$t_check_data_array[$i] = $t_content_data_array['products_id'];
47
			$i++;
48
		}
49
		
50
		if(xtc_in_array($c_products_id, $t_check_data_array))
51
		{
52
			$t_module_content_array = array ();
53

    
54
			// get content data
55
			if(GROUP_CHECK == 'true')
56
			{
57
				$t_group_check = "group_ids LIKE '%c_" . $_SESSION['customers_status']['customers_status_id'] . "_group%' AND";
58
			}
59
			
60
			//get download
61
			$t_content_result = xtDBquery("SELECT
62
												content_id,
63
												content_name,
64
												content_link,
65
												content_file,
66
												content_read,
67
												file_comment
68
											FROM " . TABLE_PRODUCTS_CONTENT . "
69
											WHERE
70
												products_id = '" . $c_products_id . "' AND
71
												" . $t_group_check . "
72
												languages_id = '" . $c_languages_id . "'");
73
			while($t_content_data_array = xtc_db_fetch_array($t_content_result, true))
74
			{
75
				$t_filename = '';
76

    
77
				if($t_content_data_array['content_link'] != '')
78
				{
79
					$t_icon = xtc_image(DIR_WS_CATALOG . 'admin/images/icons/icon_link.gif');
80
					$t_icon_url = DIR_WS_CATALOG . 'admin/images/icons/icon_link.gif';
81
				} 
82
				else
83
				{
84
					$t_icon = xtc_image(DIR_WS_CATALOG . 'admin/images/icons/icon_' . str_replace('.', '', strstr($t_content_data_array['content_file'], '.')) . '.gif');
85
					$t_icon_url = DIR_WS_CATALOG . 'admin/images/icons/icon_' . str_replace('.', '', strstr($t_content_data_array['content_file'], '.')) . '.gif';
86
				}
87

    
88
				$t_filename .= $t_content_data_array['content_name'];
89

    
90
				if($t_content_data_array['content_link'] != '')
91
				{
92
					//$t_filename = '<a href="' . $t_content_data_array['content_link'] . '" target="_blank">' . $t_filename . '</a>';
93
					$t_button_link = $t_content_data_array['content_link'];
94
				}
95
								
96
				$t_button = '';
97
				//$t_button_link = 'link';
98

    
99
				if($t_content_data_array['content_link'] == '')
100
				{
101
					if(
102
						strpos(strtolower($t_content_data_array['content_file']), '.htm') !== false ||
103
						strpos(strtolower($t_content_data_array['content_file']), '.txt') !== false ||
104
						strpos(strtolower($t_content_data_array['content_file']), '.bmp') !== false ||
105
						strpos(strtolower($t_content_data_array['content_file']), '.jpg') !== false ||
106
						strpos(strtolower($t_content_data_array['content_file']), '.gif') !== false ||
107
						strpos(strtolower($t_content_data_array['content_file']), '.png') !== false ||
108
						strpos(strtolower($t_content_data_array['content_file']), '.tif') !== false ||
109
						strpos(strtolower($t_content_data_array['content_file']), '.jpeg') !== false ||
110
						strpos(strtolower($t_content_data_array['content_file']), '.pjpeg') !== false
111
					)
112
					{
113
						$t_button = '<a style="cursor:hand" onClick="javascript:window.open(\'' . xtc_href_link(FILENAME_MEDIA_CONTENT, 'coID='.$t_content_data_array['content_id']) . '\', \'popup\', \'toolbar=0, width=640, height=600\')">' . xtc_image_button('button_view.gif', TEXT_VIEW) . '</a>';
114
						$t_button_link = 'popup';
115
						$t_button_link = xtc_href_link(FILENAME_MEDIA_CONTENT, 'coID='.$t_content_data_array['content_id']);
116
					}
117
					else
118
					{
119
						$t_button = '<a href="' . xtc_href_link('media/products/' . $t_content_data_array['content_file']) . '" target="_blank">' . xtc_image_button('button_download.gif', TEXT_DOWNLOAD) . '</a>';
120
						$t_button_link = 'download';
121
						$t_button_link = xtc_href_link('media/products/' . $t_content_data_array['content_file']);
122
					}
123
				}
124
	
125
				$t_module_content_array[] = array(	'ICON' => $t_icon,
126
													'ICON_URL' => $t_icon_url,
127
													'FILENAME' => $t_filename,
128
													'DESCRIPTION' => $t_content_data_array['file_comment'],
129
													'FILESIZE' => xtc_filesize($t_content_data_array['content_file']),
130
													'BUTTON' => $t_button,
131
													'BUTTON_URL' => $t_button_link,
132
													'BUTTON_TYPE' => $t_button_type,
133
													'CONTENT_NAME' => $t_content_data_array['content_name'],
134
													'HITS' => $t_content_data_array['content_read']);
135
			}
136

    
137
			$this->set_content_data('module_content', $t_module_content_array);
138
			
139
			$t_html_output = $this->build_html();
140
		}
141

    
142
		
143
		return $t_html_output;
144
	}
145
	
146
}
147
?>
    (1-1/1)