예제 #1
0
 public function renderDefault()
 {
     $this->template->categories_count = mapper::categories()->countAll();
     $this->template->manufacturers_count = mapper::manufacturers()->countAll();
     $this->template->pages_count = mapper::pages()->countNotRef();
     $this->template->products_count = mapper::products()->countAll();
     $this->template->pictures_count = mapper::pictures()->countAll();
     $this->template->orders_count = mapper::orders()->countAll();
     $this->template->orders_initial_count = mapper::orders()->countWithInitialStatus();
 }
예제 #2
0
 public function beforeRender()
 {
     // curly brackets
     $this->template->registerFilter('Nette\\Templates\\CurlyBracketsFilter::invoke');
     // texy
     $texy = new Texy();
     $this->template->registerHelper('texy', array($texy, 'process'));
     // side
     $side = array();
     $side['categories'] = mapper::categories()->findMain();
     $side['manufacturers'] = mapper::manufacturers()->findAll();
     $side['pages'] = mapper::pages()->findNotRef();
     $side['cart'] = Environment::getSession(SESSION_ORDER_NS);
     $side['recent_products'] = Environment::getSession(SESSION_RECENTPRODUCTS_NS)->recent;
     $this->template->side = (object) $side;
 }
예제 #3
0
 public function actionDefault($path = '', $page_number = 0, $letter = NULL)
 {
     // get nice name
     $path = explode('/', rtrim($path, '/'));
     $last = array_pop($path);
     $rest = implode('/', $path);
     // what's with rest?
     if (!empty($rest)) {
         $this->redirect(301, 'this', $last);
         $this->terminate();
         return;
     }
     // default page?
     if (empty($last)) {
         $this->setView('default');
         $this->template->path = '';
         $this->template->page = NULL;
         return;
     }
     $this->template->path = $last;
     // try to find it in database
     $page = mapper::pages()->findByNiceName($last);
     $this->template->page = $page;
     if ($page === NULL) {
         $this->setView('notfound');
         Environment::getHttpResponse()->setCode(404);
     } else {
         if ($page->getRef() === NULL) {
             $this->setView('page');
         } else {
             $this->setView(get_class($page->getRef()));
             $this->template->{get_class($page->getRef())} = $page->getRef();
             $this->template->letter = $letter;
             $this->template->have_letter = TRUE;
         }
         $this->template->title = $page->getName();
     }
     $this->template->page_number = $page_number;
 }
예제 #4
0
 public function onPageEditSubmit(Form $form)
 {
     if (!$form->isValid()) {
         return;
     }
     mapper::pages()->updateOne($form->getValues());
     adminlog::log(__('Updated page "%s"'), $form['nice_name']->getValue());
     $this->redirect('pages');
     $this->terminate();
 }