/**
  * Sets variable for view of "Default" page
  */
 public function renderDefault()
 {
     //sets Pagination
     $vp = new \VisualPaginator($this, 'vp');
     $vp->setTemplate('template-schoolyear.phtml');
     $vp->short = FALSE;
     //output the whole list
     $paginator = $vp->getPaginator();
     //get the data to paginate
     $params = $this->context->parameters;
     $folders = scandir($params['wwwDir'] . $params['hlasinekStorage']);
     $base = mb_substr($folders['2'], 0, 4);
     //starting folder, skipping "." & ".."
     //configuration
     $paginator->setBase($base);
     $paginator->setItemCount(count($folders) - 2);
     //substracts "." & ".."
     $paginator->setItemsPerPage(1);
     //default case
     $dir = end($folders);
     $page = $vp->page ? $vp->page : mb_substr($dir, 0, 4);
     $paginator->setPage($page);
     $template = $this->template;
     $template->title = "Hlásínek";
     $template->dir = $page . ((int) $page + 1);
 }
Ejemplo n.º 2
0
 public function renderDefault()
 {
     $form = $this->getComponent('search');
     $this->template->form = $form;
     $users_roles = array();
     // paginator
     $vp = new VisualPaginator($this, 'vp');
     $paginator = $vp->getPaginator();
     $paginator->itemsPerPage = 20;
     $sql = dibi::query('SELECT id, login FROM [' . TABLE_USERS . '] ' . (!empty($this->search) ? 'WHERE login LIKE %s ' : '') . 'ORDER BY login;', $this->search);
     $paginator->itemCount = count($sql);
     if (!empty($this->search)) {
         // disable paginator
         $paginator->itemsPerPage = $paginator->itemCount;
     }
     $users = $sql->fetchAll($paginator->offset, $paginator->itemsPerPage);
     foreach ($users as $user) {
         $users_roles[$user->id]['login'] = $user->login;
         $sql2 = dibi::query('SELECT r.id, r.name
                                 FROM [' . TABLE_ROLES . '] AS r
                                 JOIN [' . TABLE_USERS_ROLES . '] AS u ON r.id=u.role_id
                                 WHERE u.user_id=%i
                                 ORDER BY r.name;', $user->id);
         $roles = $sql2->fetchAll();
         $users_roles[$user->id]['roles'] = array();
         foreach ($roles as $role) {
             $users_roles[$user->id]['roles'][$role->id] = $role->name;
         }
     }
     $this->template->users = $users_roles;
 }
Ejemplo n.º 3
0
 function renderDefault($id)
 {
     if (!$id) {
         throw new NBadRequestException(_('Stranka neexistuje'));
     }
     $this->template->id_menu_item = $id;
     $this->template->page = $this->getService('Page')->findOne(array('id_menu_item' => $id));
     /* ak je to homepage */
     if ($this->template->page['home'] == 1) {
         $this->redirect(':Front:Homepage:default');
     }
     /*
      * META INFO
      */
     $this['header']->addTitle($this->template->page['meta_title']);
     $this['header']->setDescription($this->template->page['meta_description']);
     //		$this['header']->addKeywords( $this->template->page['meta_keywords'] );
     $node = $this->getService('Node');
     $query = $node->getAll($this->template->page['id_menu_item']);
     $query_count = clone $query;
     $vp = new VisualPaginator($this, 'paginator');
     $paginator = $vp->getPaginator();
     $paginator->itemsPerPage = 4;
     $paginator->itemCount = $query_count->select(false)->select('COUNT(id_node)')->fetchSingle();
     $this->template->node_list = $query->limit($paginator->itemsPerPage)->offset($paginator->offset)->fetchAll();
 }
Ejemplo n.º 4
0
 public function renderDefault()
 {
     //uvod
     $home = dibi::fetch("SELECT * FROM [menu_item] WHERE home = 1 AND lang = %s", $this->lang);
     if (!$home) {
         $home = dibi::fetch("SELECT * FROM [menu_item] WHERE lang = %s", $this->lang, "ORDER BY sequence LIMIT 1");
     }
     $this->template->id_menu_item = $home['id_menu_item'];
     /*
      * META INFO
      */
     $this['header']->addTitle($home['meta_title']);
     $this['header']->setDescription($home['meta_description']);
     $node = $this->getService('Node');
     $query = $node->getAll($this->template->id_menu_item);
     $this->template->node_list = $query->fetchAll();
     //produkty na uvode
     $list = dibi::select('id_product')->from('product')->where('home = 1');
     $count_list = clone $list;
     $count = $count_list->removeClause('select')->select('COUNT(id_product)')->fetchSingle();
     $vp = new VisualPaginator($this, 'paginator');
     $paginator = $vp->getPaginator();
     $paginator->itemsPerPage = 12;
     $paginator->itemCount = (int) $count;
     $this->template->products = $list->limit($paginator->offset . ',' . $paginator->itemsPerPage)->fetchAll();
     $this->template->paginator = $paginator;
     foreach ($this->template->products as $k => $p) {
         $this->template->products[$k] = ProductModel::getProductWithParams($p['id_product'], $this->id_lang, $this->user);
     }
     /* widget */
     $this['productNewsSaleAvaiableTable']->setIdLang($this->id_lang);
     $this['productNewsSaleAvaiableTable']->setUser($this->user);
 }
Ejemplo n.º 5
0
 function beforeRender()
 {
     parent::beforeRender();
     $this->template->id_category = $this->id;
     $this->template->category_parents = CategoryModel::getParents($this->template->id_category, $this->id_lang);
     //ak je iba jeden parent zobraz kategorie, inak zobraz produkty
     if (count($this->template->category_parents) == 1) {
         $id_parent = current($this->template->category_parents);
         $category_list = CategoryModel::getFluent('id_category')->where('id_parent = %i', $id_parent)->fetchAll();
         $this->template->categories = array();
         foreach ($category_list as $l) {
             $_tmp = CategoryModel::get($l->id_category, $this->id_lang);
             $_tmp['product_count'] = dibi::fetchSingle("SELECT COUNT(id_product) FROM [product] JOIN [category_product] USING(id_product) WHERE id_category = %i", $l->id_category);
             $this->template->categories[] = $_tmp;
         }
         $this->template->product_count = dibi::fetchSingle("SELECT COUNT(id_product) FROM [product] JOIN [category_product] USING(id_product) WHERE id_category = %i", $this->id);
     } else {
         $list = dibi::select('id_product')->from('product')->join('category_product')->using('(id_product)')->join('product_param')->using('(id_product)')->where('id_category = ', $this->id, 'AND product.active = 1');
         /*
          * Filter
          */
         $orderSession = $this['quickFilter']->getSession();
         //			dde($orderSession['order']);
         //			$orderSession['order'] = 'price';
         if ($orderSession['order']) {
             $list->orderBy($orderSession['order']);
         } else {
             $order_array = $this['quickFilter']->getOrderFilterArray();
             $list->orderBy(key($order_array));
         }
         $list->groupBy('id_product');
         //			dump($order);
         //		print_r($list);
         $count_list = clone $list;
         //			$count = $count_list->removeClause('select')->select('COUNT(id_product)')->fetchSingle();
         $count = count($count_list);
         $vp = new VisualPaginator($this, 'paginator');
         $paginator = $vp->getPaginator();
         $numOnPageSession = $this['quickFilter']->getSession();
         if ($numOnPageSession['num']) {
             $paginator->itemsPerPage = $numOnPageSession['num'];
         } else {
             $num_on_page_array = $this['quickFilter']->getNumOnPageFilterArray();
             $paginator->itemsPerPage = key($num_on_page_array);
         }
         $paginator->itemCount = (int) $count;
         $this->template->product_count = $count;
         $this->template->products = $list->limit($paginator->offset . ',' . $paginator->itemsPerPage)->fetchAll();
         //dump($this->template->products);
         $this->template->paginator = $paginator;
         foreach ($this->template->products as $k => $p) {
             $this->template->products[$k] = ProductModel::getProductWithParams($p['id_product'], $this->id_lang, $this->user);
         }
         //		};
     }
     //		print_r($this->template->products);exit;
 }
Ejemplo n.º 6
0
 public function startup()
 {
     parent::startup();
     $this->items = new \Model\Articles($this->ns);
     $vp = new \VisualPaginator($this, 'vp');
     $this->paginator = $vp->getPaginator();
     $this->paginator->itemsPerPage = 15;
     $this->template->items = $this->articles = $this->items->fetchAllEx($this->paginator->page, $this->paginator->itemsPerPage, 'published', 'DESC');
     $this->paginator->itemCount = $this->template->count = $this->items->getCount();
 }
 /**
  * Overwiev of posts
  *
  * @Privilege("default")
  */
 public function renderDefault()
 {
     $posts = $this->guestbook->getOrderedPosts();
     $vp = new \VisualPaginator($this, 'vp');
     $page = $vp->page;
     $paginator = $vp->getPaginator();
     $paginator->setItemCount($posts->count());
     $paginator->setItemsPerPage(25);
     $paginator->setPage($page);
     $this->template->posts = $posts->limit($paginator->getLength(), $paginator->getOffset());
 }
Ejemplo n.º 8
0
    function actionDefault($q = NULL, $sale = 0, $news = 0, $top = 0)
    {
        $this->q = str_replace('%', '', $q);
        $this->sale = $sale;
        $this->news = $news;
        $this->top = $top;
        $this->template->showForm = true;
        $list = self::getQuery();
        if ($this->sale == 1) {
            $list->where('product.sale = 1');
            $this->template->name = 'Akciový tovar';
            $this->template->showForm = false;
        }
        if ($this->news == 1) {
            $list->where('product.news = 1');
            $this->template->name = 'Novinky';
            $this->template->showForm = false;
        }
        if ($this->top == 1) {
            $list->where('product.our_tip = 1');
            $this->template->name = 'TOP Produkty';
            $this->template->showForm = false;
        }
        if ($this->q != '') {
            $list->where('
					(
					product_lang.name LIKE %s', '%' . $this->q . '%', '
					OR product_lang.description LIKE %s', '%' . $this->q . '%', '
					OR product_param.code LIKE %s', $this->q, '
					)
					');
            $this->template->name = 'Vyhľadávanie slova: ' . $this->q;
        }
        $list->groupBy('id_product');
        /*
         * breadcrumb
         */
        if (!isset($this->template->name)) {
            $this->template->name = 'Vyhľadávanie';
        }
        $this->template->breadcrumb = array();
        $this->template->breadcrumb[] = array('link' => $this->link('this'), 'name' => $this->template->name);
        //		$count_list = clone $list;
        $count = $this->template->count = count($list);
        $vp = new VisualPaginator($this, 'paginator');
        $paginator = $vp->getPaginator();
        $paginator->itemsPerPage = 70;
        $paginator->itemCount = (int) $count;
        $this->template->products = $list->limit($paginator->offset . ',' . $paginator->itemsPerPage)->fetchAll();
        $this->template->paginator = $paginator;
        foreach ($this->template->products as $k => $p) {
            $this->template->products[$k] = ProductModel::getProductWithParams($p['id_product'], $this->id_lang, $this->user);
        }
    }
Ejemplo n.º 9
0
 /**
  * Sets variables for view of "Archiv" page
  */
 public function renderArchive()
 {
     $news = $this->news->getAll();
     $vp = new \VisualPaginator($this, 'vp');
     $page = $vp->page;
     $paginator = $vp->getPaginator();
     $paginator->setItemCount($news->count());
     $paginator->setItemsPerPage(5);
     $paginator->setPage($page);
     $template = $this->template;
     $template->title = "Archiv aktualit";
     $template->news = $news->limit($paginator->getLength(), $paginator->getOffset());
 }
 /**
  * Sets variables for view of "Archive" page
  */
 public function renderArchive()
 {
     $template = $this->template;
     $template->title = "Archiv knihy návštěv";
     $posts = $this->guestbook->getAllViewable();
     $vp = new \VisualPaginator($this, 'vp');
     $page = $vp->page;
     $paginator = $vp->getPaginator();
     $paginator->setItemCount($posts->count());
     $paginator->setItemsPerPage(10);
     $paginator->setPage($page);
     $template->posts = $posts->limit($paginator->getLength(), $paginator->getOffset());
 }
Ejemplo n.º 11
0
 function renderDefault($query)
 {
     $this->template->query = $query;
     if ($query != '') {
         $vp = new VisualPaginator($this, 'vp');
         try {
             $datasource = ProductModel::searching($this->id_lang, $query);
             $paginator = $vp->getPaginator();
             $paginator->itemsPerPage = 2;
             $paginator->itemCount = $itemsCount = count($datasource);
             if ($itemsCount == 0) {
                 throw new ProductException(_('Hľadaný výraz sa nenašiel.'));
             }
             $this->template->searchingItems = $datasource->applyLimit($paginator->itemsPerPage, $paginator->offset)->fetchAll();
             //zisti pre kazdy clanok url_identifier
             foreach ($this->template->searchingItems as $k => $i) {
                 $this->template->searchingItems[$k]['url'] = $this->getPresenter()->link('Eshop:current', array('categories' => $i['category_link_rewrite'], 'url_identifier' => $i['link_rewrite']));
                 $image = FilesNode::getOneFirstFile('product', $i['id_product']);
                 if ($image) {
                     $image['thumbs'] = Files::gURL($image['src'], $image['ext'], 100, 70, 5);
                     $this->template->searchingItems[$k]['image'] = $image;
                 }
             }
         } catch (ProductException $e) {
             $this->flashMessage($e->getMessage());
         }
     } else {
         $this->redirect('Homepage');
     }
     //
     //		try{
     //
     //			$this->template->searching_list = ProductModel::searching($this->lang, $query)->fetchAll();
     //			if(empty($this->template->searching_list)){
     //				$this->flashMessage('Hľadaný výraz sa nenašiel.');
     //			}
     //			foreach($this->template->searching_list as $k=>$l){
     //
     //				$this->template->searching_list[$k]['url'] = $this->link('List:current',
     //					array('categories'=> MenuModel::getUrl($l['id_menu_item']) ,
     //					'url_identifier'=>$l['url_identifier']) );
     //
     //			}
     //
     //		}catch(ProductException $e){
     //			$this->flashMessage($e->getMessage());
     //		}
     //
 }
Ejemplo n.º 12
0
 public function renderDefault()
 {
     // paginator
     $vp = new VisualPaginator($this, 'vp');
     $paginator = $vp->getPaginator();
     $paginator->itemsPerPage = 20;
     $sql = dibi::query('SELECT a.id, a.access, ro.name AS role, re.name AS resource, p.name AS privilege
                             FROM [' . TABLE_ACL . '] AS a
                             LEFT JOIN [' . TABLE_ROLES . '] AS ro ON a.role_id=ro.id
                             LEFT JOIN [' . TABLE_RESOURCES . '] AS re ON a.resource_id=re.id
                             LEFT JOIN [' . TABLE_PRIVILEGES . '] AS p ON a.privilege_id=p.id
                             ORDER BY ro.name;');
     $sql->setType('access', Dibi::BOOL);
     $paginator->itemCount = count($sql);
     $acl = $sql->fetchAll($paginator->offset, $paginator->itemsPerPage);
     $this->template->acl = $acl;
 }
 /**
  * Sets variables for view of "Default" page
  */
 public function renderDefault()
 {
     $template = $this->template;
     $template->title = "Kronika";
     $vp = new \VisualPaginator($this, 'vp');
     $vp->short = FALSE;
     //output the whole list
     $vp->setTemplate('template-schoolyear.phtml');
     $paginator = $vp->getPaginator();
     $year = idate("m") < 8 ? idate("Y") - 1 : idate("Y");
     //school year start in August
     $paginator->setBase($this->context->parameters['baseChronicleYear']);
     $page = $vp->page ? $vp->page : $year;
     $paginator->setItemCount($year - $paginator->getBase() + 1);
     $paginator->setItemsPerPage(1);
     $paginator->setPage($page);
     $template->chronicles = $this->events->getEventsForChronicle($page);
 }
Ejemplo n.º 14
0
 /**
  * Overview of news
  *
  * @Privilege("default")
  */
 public function renderDefault()
 {
     $news = $this->news->getOrderedNews();
     $vp = new \VisualPaginator($this, 'vp');
     $page = $vp->page;
     $paginator = $vp->getPaginator();
     $paginator->setItemCount($news->count());
     $paginator->setItemsPerPage(50);
     $paginator->setPage($page);
     $this->template->news = $news->limit($paginator->getLength(), $paginator->getOffset());
 }
 /**
  * Overview of all chronicles
  *
  * @Privilege("default")
  */
 public function renderDefault()
 {
     $vp = new \VisualPaginator($this, 'vp');
     $vp->short = FALSE;
     //display full list
     $vp->setTemplate('template-schoolyear.phtml');
     $paginator = $vp->getPaginator();
     $year = idate("m") < 8 ? idate("Y") - 1 : idate("Y");
     $paginator->setBase($this->context->parameters["baseChronicleYear"]);
     $page = $vp->page ? $vp->page : $year;
     $paginator->setItemCount($year - $paginator->getBase() + 1);
     $paginator->setItemsPerPage(1);
     $paginator->setPage($page);
     $template = $this->template;
     $template->events = $this->events->getOrderedEventsFromYear($page);
 }
Ejemplo n.º 16
0
 /**
  * Calendar and Event invitation overview
  *
  * @Privilege("default")
  */
 public function renderDefault()
 {
     $vp = new \VisualPaginator($this, 'vp');
     $vp->short = FALSE;
     $vp->setTemplate('template-schoolyear.phtml');
     $paginator = $vp->getPaginator();
     $year = idate("m") < 8 ? idate("Y") - 1 : idate("Y");
     //school year starts in August
     $paginator->setBase($this->context->parameters['baseEventYear']);
     $page = $vp->page ? $vp->page : $year;
     $paginator->setItemCount($year - $paginator->getBase() + 1);
     $paginator->setItemsPerPage(1);
     $paginator->setPage($page);
     $template = $this->template;
     $template->events = $this->events->getMajorEventsFromYear($page)->order('dateend ASC');
     $template->calendars = $this->calendars->descendingOrder();
 }