<?php require_once 'config.php'; require_once DIR_TOOLS . 'connect_db.php'; require_once DIR_INCLUDES . 'pagination.php'; $pagination = new Pagination($pdo, IMAGES_PER_PAGE); $current_page = isset($_REQUEST['page']) ? (int) $_REQUEST['page'] : 1; $page_items = $pagination->getPage($current_page); $total_pages = $pagination->totalPages(); ?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Image Gallery</title> <link href="assets/css/main.css" rel="stylesheet" type="text/css" media="screen"> <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <script src="assets/javascript/main.js"></script> <script> console.log("Current Page: <?php echo $current_page; ?> "); </script> </head> <body>
FROM ' . implode(' ', $fromQuery) . ' ' . TABLE_PRODUCTS . ' p, ' . TABLE_PRODUCTS_DESCRIPTION . ' pd' . $tblCategories . ' WHERE ' . implode(' ', $whereQuery) . ' ' . ($show_products_by_status == 2 ? '' : "p.products_status='" . (int) $show_products_by_status . "' AND") . ' p.products_id = pd.products_id AND p.products_id = p2c.products_id and pd.language_id = ' . (int) $languages_id . ' ' . $searchSql . ' AND p.products_id IN (' . implode(',', array_keys($_SESSION['admin']['AAS']['parkedProducts'])) . ') ORDER BY ' . $orderBySql . ' ' . $ascDescSql . ' '); $parked_products_count = tep_db_num_rows($parked_products_query); } } //GET PRODUCTS QUERY $products_query = tep_db_query('SELECT SQL_CALC_FOUND_ROWS p2c.categories_id, p.*, pd.* ' . implode(' ', $selectQuery) . ' FROM ' . implode(' ', $fromQuery) . ' ' . TABLE_PRODUCTS . ' p, ' . TABLE_PRODUCTS_DESCRIPTION . ' pd' . $tblCategories . ' WHERE ' . implode(' ', $whereQuery) . ' ' . ($show_products_by_status == 2 ? '' : "p.products_status='" . (int) $show_products_by_status . "' AND") . ' p.products_id = pd.products_id and pd.language_id = ' . (int) $languages_id . $tblCategoriesWhere . ' ' . $searchSql . ' ORDER BY ' . $orderBySql . ' ' . $ascDescSql . ' ' . $limitation . ' '); $totalRowsArray = tep_db_fetch_array(tep_db_query("SELECT FOUND_ROWS();")); $totalRows = $totalRowsArray['FOUND_ROWS()']; $entriesPerPageCalc = $entriesPerPage != 'All' ? $entriesPerPage : $totalRows; $pagination = new Pagination(array('entriesPerPage' => $entriesPerPageCalc, 'currentPage' => $currentPage, 'queryString' => $cPathString, 'totalRows' => $totalRows, 'firstString' => AAS_PAGINATION_FIRST, 'lastString' => AAS_PAGINATION_LAST, 'nextString' => AAS_PAGINATION_NEXT, 'prevString' => AAS_PAGINATION_PREVIOUS, 'jumpString' => AAS_PAGINATION_JUMP, 'jumpToPageString' => AAS_PAGINATION_JUMP_TO_PAGE, 'file' => FILENAME_AAS)); $totalPages = $pagination->totalPages($totalRows); $entries = tep_db_num_rows($products_query); if ($currentPage > $totalPages && $totalPages != 0) { header('Location: ' . FILENAME_AAS . '?' . $cPathString . '&page=' . ($totalPages - 1 <= 0 ? 1 : $totalPages - 1)); die; } if (isset($_GET['search']) && !tep_not_null($_GET['search'])) { header('Location: ' . (isset($_SESSION['admin']['AAS']['preSearchUrl']) ? $_SESSION['admin']['AAS']['preSearchUrl'] : 'aas.php?' . $cPathString)); die; } //in order to remember where to return after pressing the x on search if (!isset($_GET['search'])) { $_SESSION['admin']['AAS']['preSearchUrl'] = tep_href_link(FILENAME_AAS, $cPathString . '&page=' . $currentPage); } //currencies is need when displaying gross so display it then if ($fieldsArray['products_price_gross']['visible']) {
function getSearchResultLoop($s, $max_pp = null) { if (!isset($this->p)) { $s = $this->conn->real_escape_string(urldecode($s)); $loop_first_search_query = "SELECT * FROM c_posts WHERE (post_content LIKE '%{$s}%' OR post_excerpt LIKE '%{$s}%' OR post_title LIKE '%{$s}%' OR post_description LIKE '%{$s}%' OR link_title LIKE '%{$s}%' OR tags LIKE '%{$s}%') AND post_status <> 'Initialized'"; $this->res = $this->conn->query($loop_first_search_query); dbQueryCheck($this->res, $this->conn); $this->search_res_count = $this->res->num_rows; // set search result count, should be accessed only after function call $this->p = 'set'; } if (!isset($loop_search_query)) { $s = $this->conn->real_escape_string(urldecode($s)); $pagination = new Pagination($max_pp, $this->search_res_count); $loop_search_query = "SELECT * FROM c_posts WHERE (post_content LIKE '%{$s}%' OR post_excerpt LIKE '%{$s}%' OR post_title LIKE '%{$s}%' OR post_description LIKE '%{$s}%' OR link_title LIKE '%{$s}%' OR tags LIKE '%{$s}%') AND post_status <> 'Initialized' "; $loop_search_query .= "LIMIT {$pagination->per_page} "; $loop_search_query .= "OFFSET {$pagination->offset()}"; } if (!isset($this->j)) { $this->res = $this->conn->query($loop_search_query); dbQueryCheck($this->res, $this->conn); $this->j = 'set'; } $this->total_pages = $pagination->totalPages(); $this->hasPreviousPage = $pagination->hasPreviousPage(); $this->hasNextPage = $pagination->hasNextPage(); $this->previousPage = $pagination->previousPage(); $this->nextPage = $pagination->nextPage(); return $this->res->fetch_assoc(); }
echo $photo->imagePath(); ?> " width="200"> </a> <p><?php echo $photo->caption; ?> </p> </div> <?php } ?> <div id="pagination" style="clear: both;"> <?php if ($pagination->totalPages() > 1) { if ($pagination->hasPreviousPage()) { echo " <a href=\"index.php?page="; echo $pagination->previousPage(); echo "\">« Previous</a> "; } for ($i = 1; $i <= $pagination->totalPages(); $i++) { if ($i == $page) { echo " <span class=\"selected\">{$i}</span> "; } else { echo " <a href=\"index.php?page={$i}\">{$i}</a> "; } } if ($pagination->hasNextPage()) { echo " <a href=\"index.php?page="; echo $pagination->nextPage();