components.class.php 3.33 KB
Newer Older
Яков's avatar
first  
Яков committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
class mainComponents extends sfComponents
{
    public function executeMenu(sfWebRequest $request)
    {
        Cat::menuInit();
        $this->type = (!isset($this->type) ? 'top' : $this->type);
        $this->menus = array(
            'catalog' => array('url' => '@catalog', 'title' => __('Каталог'), 'sub' => Cat::$menu),
            'video' => array('url' => '@video', 'title' => __('Смотреть')),
            'article' => array('url' => '@article', 'title' => __('Читать')),
            'review' => array('url' => '@review', 'title' => __('Отзывы')),
            'page' => array('url' => '@page_show?alias=delivery', 'title' => __('Доставка'))
        );
        if($this->type == 'bottom'){
            unset($this->menus['catalog']);
        }
    }
    public function executeTag(sfWebRequest $request)
    {
        $this->culture = $this->getUser()->getCulture();
        $this->tags = Doctrine_Query::create()
            ->select("t.id,  tr.*")
            ->from("Tag t")
            ->innerJoin("t.Translation tr")
            ->where("tr.lang = ?", $this->culture)
            ->orderBy("tr.title ASC")
            ->fetchArray();
    }
    public function executeBreadcrumbs(sfWebRequest $request)
    {
        $culture = $this->getUser()->getCulture();
        if (isset($this->cat)) {
            $parent_id = $this->cat->getParentId();
            $namesCats = array();
            $i = 0;
            while ($parent_id != null)
            {
                $parentCat = Doctrine_Query::create()
                    ->select()
                    ->from('Cat c')
                    ->where('c.id = ?', $parent_id)
                    ->leftJoin('c.Translation ct WITH ct.lang = ?', $culture)
                    ->fetchArray();
                $namesCats[$i]['title'] = $parentCat[0]['Translation'][$culture]['title'];
                $namesCats[$i]['alias'] = $parentCat[0]['alias'];
                $parent_id = $parentCat[0]['parent_id'];
                $i++;
            }
            $this->namesCats = array_reverse($namesCats);
        }
        if (isset($this->product_id)) {
            $cat_id = Doctrine::getTable('CatProduct')->findOneByProductId($this->product_id)->getCatId();
            $cat = Doctrine_Query::create()
                ->select()
                ->from('Cat c')
                ->where('c.id = ?', $cat_id)
                ->leftJoin('c.Translation ct WITH ct.lang = ?', $culture)
                ->fetchArray();
            $parent_id = $cat[0]['parent_id'];
            $namesCats = array();
            $namesCats[0]['title'] = $cat[0]['Translation'][$culture]['title'];
            $namesCats[0]['alias'] = $cat[0]['alias'];
            $i = 1;
            while ($parent_id != null)
            {
                $parentCat = Doctrine_Query::create()
                    ->select()
                    ->from('Cat c')
                    ->where('c.id = ?', $parent_id)
                    ->leftJoin('c.Translation ct WITH ct.lang = ?', $culture)
                    ->fetchArray();
                $namesCats[$i]['title'] = $parentCat[0]['Translation'][$culture]['title'];
                $namesCats[$i]['alias'] = $parentCat[0]['alias'];
                $parent_id = $parentCat[0]['parent_id'];
                $i++;
            }

            $this->namesCats = array_reverse($namesCats);
        }
    }
}