<?php
class Catalog_Controller extends Base {
protected $type = FALSE;
protected $id = FALSE;
protected $parent = FALSE;
protected $navigation;
protected $catalog;
protected $krohi;
protected function input($param = array()) {
parent::input();
$this->title .= "Каталог";
$this->need_right_side = FALSE;
if(isset($param['brand'])) {
$this->type = "brand";
$this->id = $this->clear_int($param['brand']);
}
elseif(isset($param['type'])) {
$this->type = "type";
$this->id = $this->clear_int($param['type']);
}
elseif(isset($param['parent'])) {
$this->parent = TRUE;
$this->id = $this->clear_int($param['parent']);
}
if(isset($param['page'])) {
$page = $this->clear_int($param['page']);
if($page == 0) {
$page = 1;
}
}
else {
$page = 1;
}
if($this->type) {
if(!$this->id) {
return;
}
$pager = new Pager(
$page,
'tovar',
array($this->type.'_id'=>$this->id,'publish'=>1),
'tovar_id',
'ASC',
QUANTITY,
QUANTITY_LINKS
);
$this->krohi = $this->ob_m->get_krohi($this->type,$this->id);
$this->keywords = $this->krohi[0][$this->type.'_name'].','.$this->krohi[1]['brand_name'];
$this->discription = $this->krohi[0][$this->type.'_name'].','.$this->krohi[1]['brand_name'];
}
elseif($this->parent) {
if(!$this->id) {
return;
}
$ids = $this->ob_m->get_child($this->id);
if(!$ids) {
return;
}
$pager = new Pager(
$page,
'tovar',
array('brand_id' => $ids,'publish'=>1),
'tovar_id',
'ASC',
QUANTITY,
QUANTITY_LINKS,
array("IN","=")
);
$this->type = "parent";
$this->krohi = $this->ob_m->get_krohi('brand',$this->id);
$this->keywords = $this->krohi[0]['brand_name'];
$this->discription = $this->krohi[0]['brand_name'];
}
elseif(!$this->type && !$this->parent) {
$pager = new Pager(
$page,
'tovar',
array('publish'=>1),
'tovar_id',
'ASC',
QUANTITY,
QUANTITY_LINKS
);
$this->krohi[0]['brand_name'] = "Каталог";
$this->keywords = "KinoClub, каталог товаров";
$this->discription = "KinoClub, каталог товаров";
}
if(is_object($pager)) {
$this->navigation = $pager->get_navigation();
$this->catalog = $pager->get_posts();
}
$this->need_left_side = FALSE;
$this->need_right_side = false;
}
protected function output() {
$previous = FALSE;
if($this->type && $this->id) {
$previous = "/".$this->type."/".$this->id;
}
$this->content = $this->render(VIEW.'catalog_page', array(
'catalog' => $this->catalog,
'navigation' =>$this->navigation,
'previous'=>$previous,
'krohi' => $this->krohi
));
$this->page = parent::output();
return $this->page;
}
}
?>
<div id="allblocks3">
<? if($catalog):?>
<? foreach($catalog as $key => $item) :?>
<div id="cat1">
<div id="cat1-1">
<a href="<?=SITE_URL;?>tovar/id/<?=$item['tovar_id'];?>">
<? if(!$item['img'] == '') :?>
<img src="<?=SITE_URL.UPLOAD_DIR.$item['img'];?>" width="185" height="265" />
<? else:?>
<img src="<?=SITE_URL;?>images/<?=NOIMAGE;?>" width="185" height="265" />
<? endif;?>
</a>
</div>
<div id="cat1-2">
<a href="<?=SITE_URL;?>tovar/id/<?=$item['tovar_id'];?>"><?=$item['title'];?></a>
</div>
<span></span>
</div>
<? endforeach;?>
<? if($navigation): ?>
<br />
<ul class="pager">
<? if($navigation['first']) :?>
<li class="first">
<a href="<?=SITE_URL;?>catalog/page/1<?=$previous?>">Первая</a>
</li>
<? endif;?>
<? if($navigation['last_page']) :?>
<li>
<a href="<?=SITE_URL;?>catalog/page/<?=$navigation['last_page']?><?=$previous?>"><</a>
</li>
<? endif;?>
<? if($navigation['previous']) :?>
<? foreach($navigation['previous'] as $val) :?>
<li>
<a href="<?=SITE_URL;?>catalog/page/<?=$val;?><?=$previous?>"><?=$val;?></a>
</li>
<? endforeach;?>
<? endif;?>
<? if($navigation['current']) :?>
<li>
<span><?=$navigation['current'];?></span>
</li>
<? endif;?>
<? if($navigation['next']) :?>
<? foreach($navigation['next'] as $v) :?>
<li>
<a href="<?=SITE_URL;?>catalog/page/<?=$v;?><?=$previous?>"><?=$v;?></a>
</li>
<? endforeach;?>
<? endif;?>
<? if($navigation['next_pages']) :?>
<li>
<a href="<?=SITE_URL;?>catalog/page/<?=$navigation['next_pages']?><?=$previous?>">></a>
</li>
<? endif;?>
<? if($navigation['end']) :?>
<li class="last">
<a href="<?=SITE_URL;?>catalog/page/<?=$navigation['end']?><?=$previous?>">Последняя</a>
</li>
<? endif;?>
</ul>
<? endif;?>
<? else:?>
<p>Данных для вывода нет</p>
<? endif;?>
</div>