Subversion-Projekte lars-tiefland.ci

Revision

Revision 609 | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
71 lars 1
<?php
2
 
313 lars 3
/**
4
 * @author Lars Tiefland
5
 * @copyright 2016
6
 */
71 lars 7
 
519 lars 8
/**
9
 * Category_model
10
 *
11
 * Liest alle Infos für Kategorien
12
 *
527 lars 13
 * @package WebanOS CI
14
 * @author Lars Tiefland
15
 * @copyright 2016
16
 * @version $Id: Category_model.php 609 2016-09-17 17:52:57Z lars $
519 lars 17
 * @access public
18
 */
313 lars 19
class Category_model extends CI_Model
20
{
519 lars 21
	/**
22
	 * Category_model::__construct()
23
	 *
24
	 * @return
25
	 */
313 lars 26
	public function __construct()
27
	{
28
		parent::__construct();
29
		$this->load->model('artikel_model', 'artikel');
30
		$this->load->model('alias_model', 'alias');
31
		$this->load->model('preise_model', 'preise');
32
	}
71 lars 33
 
519 lars 34
	/**
35
	 * Category_model::get_dir_items()
36
	 *
37
	 * alle Artikel einer Kategorie
38
	 *
39
	 * @param mixed $father
40
	 * @return
41
	 */
591 lars 42
	public function get_dir_items($father, $start = 0, $limit = null)
313 lars 43
	{
44
		if (is_numeric($father) && $father > 0)
45
		{
46
			$link = $this->get_link($father);
47
			header("Location: ".$link);
48
		}
49
		elseif (!is_numeric($father))
50
		{
51
			$query = $this->db->get_where('alias', array(
52
				"alias" => $father.'.html',
53
				"type_id" => 2,
54
				));
55
			$row = $query->row_array();
56
			$father = $row["id"];
57
		}
58
		$d_res = $this->db->get_where('directory', array(
59
			'id' => $father,
60
			'language' => 'DE',
61
			'status' => 0,
62
			));
63
		$dir_info = $d_res->row_array();
64
		$this->db->select('templateValue');
65
		$this->db->join('templates t', 'td.templates_id=t.id');
66
		$res = $this->db->get_where('templates_to_directory td', array(
67
			'directory_id' => $father,
68
			'shops_id' => $GLOBALS['INI']['shops_ID'],
69
			'typ' => 'directory',
70
			));
71
		$t_row = $res->row_array();
72
		$folder = substr($t_row['templateValue'], 7);
73
		$dir_info['template_folder'] = $folder;
74
		$dir_info['KategoriebildTag'] = $dir_info['Name'];
75
		$dir_info["shopPosition"] = $this->shop_position->get_position($father);
597 lars 76
		$items = $this->artikel->list_artikel($father, false, $start, $limit);
77
		$dir_info['items'] = $items['artikel'];
609 lars 78
		$dir_info['item_anz'] = $items['count'];
313 lars 79
		$dir_info['subdirs'] = $this->list_directory($father);
80
		$dir_info['medien'] = $this->medien->get_category_medien($father);
81
		$dir_info['artstaemmeItems'] = $this->get_artstaemme_items($father);
587 lars 82
		$config{'base_url'} = $this->config->item('base_url').'/'.$this->get_link($father);
597 lars 83
		$config['total_rows'] = $items['count'];
592 lars 84
		$config['per_page'] = $limit;
588 lars 85
		$config['page_query_string'] = true;
592 lars 86
		//$config['use_page_numbers'] = true;
590 lars 87
		$config['cur_tag_open'] = '&nbsp;[&nbsp;<b>';
88
		$config['cur_tag_close'] = '</b>&nbsp;]';
89
		$config['num_tag_open'] = '&nbsp;[&nbsp;';
90
		$config['num_tag_close'] = '&nbsp;]';
91
		$config['first_tag_open'] = '&nbsp;[&nbsp;';
92
		$config['first_tag_close'] = '&nbsp;]';
93
		$config['last_tag_open'] = '&nbsp;[&nbsp;';
94
		$config['last_tag_close'] = '&nbsp;]';
95
		$config['next_tag_open'] = '&nbsp;[&nbsp;';
96
		$config['next_tag_close'] = '&nbsp;]';
97
		$config['prev_tag_open'] = '&nbsp;[&nbsp;';
98
		$config['prev_tag_close'] = '&nbsp;]';
581 lars 99
		$this->pagination->initialize($config);
100
		$this->smarty->assign('pagination', $this->pagination->create_links());
313 lars 101
		$medien = $dir_info['medien'];
102
		if (count($medien) > 1)
103
		{
104
			$dir_info['Kategoriebild'] = $medien[1]['bild_url_ba'];
105
			if ($medien[1]["beschreibung"] != '')
106
			{
107
				$dir_info['KategoriebildTag'] = $medien[1]['beschreibung'];
108
			}
109
		}
110
		elseif (count($medien))
111
		{
112
			$dir_info['Kategoriebild'] = $medien[0]['bild_url_ba'];
113
			if ($medien[0]["beschreibung"] != '')
114
			{
115
				$dir_info['KategoriebildTag'] = $medien[0]['beschreibung'];
116
			}
117
		}
118
		return $dir_info;
119
	}
71 lars 120
 
519 lars 121
	/**
122
	 * Category_model::list_directory()
123
	 *
124
	 * Unterkategorien
125
	 *
126
	 * @param mixed $father
127
	 * @param integer $artikelstamm
128
	 * @return
129
	 */
313 lars 130
	public function list_directory($father, $artikelstamm = 0)
131
	{
132
		$subdirs = array();
133
		$this->db->order_by('kennung', 'ASC');
134
		$query = $this->db->get_where('directory', array(
135
			"father" => $father,
136
			"language" => "DE",
137
			"status" => 0,
138
			'Artikelstamm' => $artikelstamm,
139
			));
140
		while ($row = $query->unbuffered_row('array'))
141
		{
142
			$row["dirLink"] = $this->get_link($row["ID"]);
143
			$row["medien"] = $this->medien->get_category_medien($row["ID"]);
144
			$subdirs[] = $row;
145
		}
146
		return $subdirs;
147
	}
519 lars 148
	/**
149
	 * Category_model::get_dir()
150
	 *
151
	 * Infos zu einer Kategorie
152
	 *
153
	 * @param mixed $id
154
	 * @return
155
	 */
313 lars 156
	public function get_dir($id)
157
	{
158
		if (is_numeric($id))
159
		{
160
			$link = $this->get_link($id);
161
			header("Location: ".$link);
162
		}
163
		else
164
		{
165
			$query = $this->db->get_where('alias', array(
166
				"alias" => $id.'.html',
167
				"type_id" => 2,
168
				));
169
			$row = $query->row_array();
170
			$id = $row["id"];
171
			$query = $this->db->get_where('directory', array(
172
				'id' => $id,
173
				"language" => "DE",
174
				));
175
			$row = $query->row_array();
176
			return $row;
177
		}
178
	}
71 lars 179
 
519 lars 180
	/**
181
	 * Category_model::get_link()
182
	 *
183
	 * Link
184
	 *
185
	 * @param mixed $id
186
	 * @return
187
	 */
313 lars 188
	public function get_link($id)
189
	{
190
		$link = $this->alias->get_link($id, 2);
580 lars 191
		return "/".$link;
313 lars 192
	}
193
 
519 lars 194
	/**
195
	 * Category_model::get_artstaemme_items()
196
	 *
197
	 * Artikel innerhalb von Artikelstämmen
198
	 *
199
	 * @param mixed $id
200
	 * @return
201
	 */
313 lars 202
	private function get_artstaemme_items($id)
203
	{
314 lars 204
		$artikelstaemme = $this->list_directory($id, 1);
313 lars 205
		foreach ($artikelstaemme as $as_id => $artikelstamm)
206
		{
369 lars 207
			$artikelstaemme[$as_id]['items'] = $this->artikel->list_artikel($artikelstamm['ID'], true);
313 lars 208
		}
315 lars 209
		return $artikelstaemme;
313 lars 210
	}
211
}
212
 
590 lars 213
?>