['default' => 1]]); } else{ $publications_page = 1; } $_SESSION['publications_page'] = $publications_page; $publications_per_page = 30; try{ $sql = 'SELECT COUNT(*) as total FROM publications'; $result = $pdo->query($sql); if($result->rowCount() > 0){ while($row = $result->fetch()){ $max_page = ceil($row['total']/$publications_per_page); } // Free result set unset($result); } else{ unset($pdo); http_response_code(404); include('/pl/404.html'); die(); } } catch(PDOException $e){ die('ERROR: Could not able to execute $sql. ' . $e->getMessage()); } $pages = array('pages' => array( 'first' => max(1, $publications_page-2), 'last' => min($max_page, $publications_page+2), 'current' => $publications_page, 'base_link' => '/pl/publications_sort_added.html?page=' )); $publications = array('publications' => array()); // Attempt select query execution try{ $sql = 'SELECT id, authors, title, journal, year, doi, ministerial_pts, graphics, special_graphics, date_created, date_changed FROM publications ORDER BY date_created DESC LIMIT ' . ($publications_page-1)*$publications_per_page . ', ' . $publications_per_page; if($stmt = $pdo->prepare($sql)){ if($stmt->execute()){ if($stmt->rowCount() > 0){ $index_nr = ($publications_page-1)*$publications_per_page; while($row = $stmt->fetch()){ $index_nr += 1; $graphics = $row['graphics']; $special_graphics = $row['special_graphics']; if($special_graphics == ''){ $thumb = '/img/publications/'.pathinfo($graphics,PATHINFO_FILENAME).'_thumb.jpg'; $graphics = '/img/publications/'.$graphics; } else { $thumb = '/img/publications/'.pathinfo($special_graphics,PATHINFO_FILENAME).'_thumb.jpg'; $special_graphics = '/img/publications/'.$special_graphics; } $article_data = array( 'id' => $row['id'], 'authors' => $row['authors'], 'title' => $row['title'], 'journal' => $row['journal'], 'year' => $row['year'], 'doi' => $row['doi'], 'ministerial_pts' => $row['ministerial_pts'], 'graphics' => $graphics, 'special_graphics' => $special_graphics, 'thumb' => $thumb, 'can_edit' => $can_edit, 'index_nr' => $index_nr, 'date_created' => $row['date_created'], 'date_changed' => $row['date_changed'] ); array_push($publications['publications'], $article_data); } } } // Free result set unset($stmt); } else{ unset($pdo); http_response_code(404); include('/pl/404.html'); die(); } } catch(PDOException $e){ die('ERROR: Could not able to execute $sql. ' . $e->getMessage()); } #publication template $publication = $twig->load('publication_pl.html'); $pagination = $twig->load('pagination_pl.html'); ?>