public function index()
 {
     $result['categories'] = $this->category->getCategories();
     $result['title'] = 'Shop';
     $result['isEditor'] = Auth::isUserInRole(array('editor', 'admin'));
     $result['isAdmin'] = Auth::isUserInRole(array('admin'));
     if ($result['isEditor']) {
         $result['products'] = $this->product->getProductsWitnUnavailable();
     } else {
         $result['products'] = $this->product->getProducts();
     }
     $all_promotion = $this->promotion->getHighestActivePromotion();
     foreach ($result['products'] as $k => $p) {
         $productPromotion = max($all_promotion['discount'], $p['discount'], $p['category_discount']);
         if (is_numeric($productPromotion)) {
             $result['products'][$k]['promotion_price'] = $p['price'] - $p['price'] * ($productPromotion / 100);
         }
     }
     //        $val=new Validation();
     //        $val->setRule('matches',3,4,'az');
     //        $val->setRule('different',6,6,'min');
     //        $val->setRule('afterDate','10/10/2010','10/10/2011','date');
     //        $val->setRule('required','',null,'username')->validate();
     //var_dump($val->getErrors());
     View::make('index', $result);
     if (Auth::isAuth()) {
         View::appendTemplateToLayout('topBar', 'top_bar.user');
     } else {
         View::appendTemplateToLayout('topBar', 'top_bar.guest');
     }
     View::appendTemplateToLayout('header', 'includes.header')->appendTemplateToLayout('footer', 'includes.footer')->appendTemplateToLayout('catMenu', 'side_bar.category_menu')->render();
 }