actions.class.php 3.78 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
<?php

/**
 * main actions.
 *
 * @package    sf
 * @subpackage main
 * @author     Atma
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class mainActions extends sfActions
{
    /**
     * Executes index action
     *
     * @param sfRequest $request A request object
     */
    public function executeIndex(sfWebRequest $request)
    {
        $this->setLayout('layoutHome');
        $this->video = Doctrine_Query::create()
            ->select("v.*, t.*")
            ->from("Video v")
            ->innerJoin("v.Translation t")
            ->where("t.lang = ?", $this->getUser()->getCulture())
            ->andWhere("t.available = 1")
            ->orderBy("v.created_at DESC")
            ->fetchOne();
        $this->products = Doctrine_Query::create()
            ->select("p.id, p.alias, p.product_img, p.is_detail, p.offer_count, p.is_delete, pt.id, pt.lang, pt.title, o.id, o.product_id, o.price, o.quantity_type_select, ot.*")
            ->from("Product p")
            ->leftJoin("p.Translation pt")
            ->leftJoin("p.Offer o WITH o.is_wholesale = 0")
            ->leftJoin("o.Translation ot")
            ->where("p.offer_count > 0")
            ->andWhere("p.is_delete = 0")
            ->andWhere("CHAR_LENGTH(p.product_img) > 0")
            ->limit(10)
            ->orderBy("FIELD(p.show_main, '1') DESC, p.sort, RAND()")
            ->fetchArray();
        $this->group_offers = Doctrine_Query::create()
            ->select("p.id, p.alias, p.product_img, p.is_detail, p.offer_count, p.is_delete, pt.id, pt.lang, pt.title, o.id, o.product_id, o.price, o.quantity_type_select, ot.*, c.id, ct.title, ct.id, ct.lang")
            ->from("Product p")
            ->innerJoin("p.Translation pt")
            ->innerJoin("p.Offer o")
            ->innerJoin("o.Translation ot")
            ->innerJoin("p.Cats c")
            ->innerJoin("c.Translation ct WITH ct.title LIKE '%камень для бани%'")
            ->where("p.offer_count > 0")
            ->andWhere("p.is_delete = 0")
            ->andWhere("p.is_main = 1")
            ->andWhere("CHAR_LENGTH(p.product_img) > 0")
            ->limit(2)
            ->orderBy("RAND()")
            ->fetchArray();
        $this->group_cat = Doctrine_Query::create()
            ->select("c.*, t.*")
            ->from("Cat c")
            ->innerJoin("c.Translation t")
            ->where("CHAR_LENGTH(c.photo) > 0")
            ->andWhere("c.is_main = 1")
            ->orderBy("RAND()")
            ->fetchOne();
Яков's avatar
test    
Яков committed
64

Яков's avatar
first  
Яков committed
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
    }
    public function executeDl(sfWebRequest $request)
    {
        /*
        $type = $request->getParameter('type');
        $id = trim(strip_tags($request->getParameter('id')));
        if($type == 'certificate' && $id){
            $product = Doctrine::getTable("Product")->findOneByAlias($id);
            $this->forward404Unless($product && $product->getCertificate());
            $path = sfConfig::get('sf_upload_dir') . '/i/' . $product->getCertificate();
            if(file_exists($path) && !is_dir($path)){
                $exp = explode('.', $product->getCertificate());
                $this->getResponse()->setHttpHeader('Content-type', mime_content_type($path));
                $this->getResponse()->setHttpHeader('Content-Disposition', 'attachment; filename="certificate.' . ($exp[count($exp) - 1]) . '"');
                $this->getResponse()->setHttpHeader('X-Accel-Redirect', '/web/u/i/' . $product->getCertificate());
            }
        }
        */
        return sfView::NONE;
    }
    public function executeUploader(sfWebRequest $request)
    {
        $file = $request->getFiles('file');
        if(substr($file['type'], 0, 5) == 'image'){
            echo Page::uploader($file, 'file', true, array('key' => $request->getParameter('key')));
        }
        return sfView::NONE;
    }
}