/** * Returns the page links line. * * @return string paginator view in the type of paginal references * @ finish the functions on this page */ function output($pag_name, $viewname, $cat_id = -1, $prod_id = -1) { global $application; $viewname = CURRENT_REQUEST_URL; #Define whether to output the view or not if ($this->NoView) { $application->outputTagErrors(true, "PaginatorLine", "Errors"); return ""; } $this->templateFiller =& $application->getInstance('TemplateFiller'); $this->template = $application->getBlockTemplate('PaginatorLine'); $this->templateFiller->setTemplate($this->template); $retval = ''; //Output a paginator view with the page number, //form the link of the type ?action=setpage&pgname=$pag_name&pgnum=$i $rows_per_page = modAPIFunc('Paginator', 'getPaginatorRowsPerPage', $pag_name); if (!$rows_per_page) { $rows_per_page = ROWS_PER_PAGE; } $pages = ceil(modAPIFunc('Paginator', 'getCurrentPaginatorTotalRows') / $rows_per_page); $lines = ceil($pages / PAGES_PER_LINE); $currentpage = modAPIFunc('Paginator', 'getPaginatorPage', $pag_name); $currentrows = modAPIFunc('Paginator', 'getPaginatorRowsPerPage', $pag_name); $currentline = ceil($currentpage / PAGES_PER_LINE); //$firstpageinline = ($currentline - 1)*PAGES_PER_LINE+1; $lastpageinline = $currentline * PAGES_PER_LINE; if ($lastpageinline > $pages) { $lastpageinline = $pages; } $firstpageinline = $lastpageinline - PAGES_PER_LINE + 1; if ($firstpageinline <= 0) { $firstpageinline = 1; } $this->_Data = array('Local_Items' => '', 'Local_From' => '', 'Local_To' => '', 'Local_Of' => '', 'Local_CurrentPage' => '', 'Local_PagesQty' => '', 'Local_ViewAll' => ''); $request = new Request(); $request->setView($viewname); $request->setAction('Paginator_SetPage'); $request->setKey('pgname', $pag_name); $request->setKey('pgnum', $currentpage - 1); $request->setCategoryID($cat_id); $request->setProductID($prod_id); $this->_Data = array_merge($this->_Data, array('Local_PageLink' => $request->getURL(), 'Local_PageNumber' => '')); $retval = ''; $paginator_line = ''; if ($currentpage != 1) { $application->registerAttributes($this->_Data); $paginator_line .= $this->templateFiller->fill("Prev"); } if ($firstpageinline != 1) { $paginator_line .= CZ_getMsg("PAGINATOR_DOTS"); } for ($i = $firstpageinline; $i <= $lastpageinline; $i++) { $request = new Request(); $request->setView($viewname); $request->setAction('Paginator_SetPage'); $request->setKey('pgname', $pag_name); $request->setKey('pgnum', $i); $request->setCategoryID($cat_id); $this->_Data = array_merge($this->_Data, array('Local_PageLink' => $request->getURL(), 'Local_PageNumber' => $i)); $application->registerAttributes($this->_Data); if ($i == $currentpage) { $paginator_line .= $this->templateFiller->fill("ItemSelected"); } else { $paginator_line .= $this->templateFiller->fill("Item"); } } if ($lastpageinline != $pages) { $paginator_line .= CZ_getMsg("PAGINATOR_DOTS"); } $request = new Request(); $request->setView($viewname); $request->setAction('Paginator_SetPage'); $request->setKey('pgname', $pag_name); $request->setKey('pgnum', $currentpage + 1); $request->setCategoryID($cat_id); $this->_Data = array_merge($this->_Data, array('Local_PageLink' => $request->getURL(), 'Local_PageNumber' => '')); if ($currentpage != $pages && $pages != 0) { $paginator_line .= $this->templateFiller->fill("Next"); } $request = new Request(); $request->setView($viewname); $request->setAction('Paginator_SetRowsPerPage'); $request->setKey('pgname', $pag_name); $request->setKey('rows', modAPIFunc('Paginator', 'getCurrentPaginatorTotalRows')); $request->setCategoryID($cat_id); $to = $currentpage * $rows_per_page; $total_rows = modAPIFunc('Paginator', 'getCurrentPaginatorTotalRows'); if ($to > $total_rows) { $to = $total_rows; } $this->_Data = array_merge($this->_Data, array('Local_Items' => $pages > 1 ? $paginator_line : "", 'Local_From' => ($currentpage - 1) * $rows_per_page + 1, 'Local_To' => $to, 'Local_Of' => $total_rows, 'Local_CurrentPage' => $currentpage, 'Local_PagesQty' => $pages, 'Local_ViewAll' => $request->getURL())); $application->registerAttributes($this->_Data); if ($pages > 1) { $retval = $this->templateFiller->fill("Container"); } else { $retval = $this->templateFiller->fill("Empty"); } // $retval = $this->templateFiller->fill("Container"); return $retval; }
/** * Returns the Select box view with possible variants of rows * per the page. * * @return Select box with possible page values outputted on the page. * @ finish the functions on this page */ function output($pag_name, $viewname, $items_name = 'products') { global $application; #Define whether to output the view or not if ($this->NoView) { $application->outputTagErrors(true, "PaginatorRows", "Errors"); return ""; } $this->templateFiller =& $application->getInstance('TemplateFiller'); $this->template = $application->getBlockTemplate('PaginatorDropdown'); $this->templateFiller->setTemplate($this->template); $retval = ''; $rows_per_page = modAPIFunc('Paginator', 'getPaginatorRowsPerPage', $pag_name); if (!$rows_per_page) { $rows_per_page = ROWS_PER_PAGE; } $currentrows = $rows_per_page; $rows_per_page = modApiFunc('Paginator', 'getRowsPerPage'); $_rows_per_page = array(); foreach ($rows_per_page as $value) { $_rows_per_page[$value] = $value; } $Row_Options = ''; $selected_flag = false; foreach ($_rows_per_page as $option_value => $option_text) { if ($option_value == $currentrows) { $Row_Options .= '<option selected="selected" value="' . $option_value . '">' . $option_text . '</option>'; $selected_flag = true; } else { $Row_Options .= '<option value="' . $option_value . '">' . $option_text . '</option>'; } } $Row_Options .= '<option ' . ($selected_flag ? '' : 'selected="selected"') . 'value="' . modAPIFunc('Paginator', 'getCurrentPaginatorTotalRows') . '">' . CZ_getMsg("PAGINATOR_VIEW_ALL") . '</option>'; $request = new Request(); $request->setView(CURRENT_REQUEST_URL); $url = $request->getURL(); $this->_Page = array('Local_FormAction' => $url, 'Local_FormId' => 'Paginator', 'Local_FormActionFieldName' => 'asc_action', 'Local_FormActionFieldValue' => 'Paginator_SetRowsPerPage', 'Local_FormPaginatorFieldName' => 'pgname', 'Local_FormPaginatorFieldValue' => $pag_name, 'Local_ItemsName' => $items_name, 'Local_FormSelectFieldName' => 'rows', 'Local_FormSelectOptions' => $Row_Options); $application->registerAttributes($this->_Page); if (modAPIFunc('Paginator', 'getCurrentPaginatorTotalRows') > MIN_ROWS_PER_PAGE) { $retval = $this->templateFiller->fill("Container"); } else { $retval = $this->templateFiller->fill("Empty"); } return $retval; }