55c55d7ebbd080304c75a1f016230bf9112703b1
[atutor.git] / mods / photos / search.php
1 <?php
2 /***********************************************************************/
3 /* ATutor                                                                                                                          */
4 /***********************************************************************/
5 /* Copyright (c) 2002-2010                                                                                         */
6 /* Adaptive Technology Resource Centre / Inclusive Design Institute    */
7 /* http://atutor.ca                                                                                                        */
8 /*                                                                                                                                         */
9 /* This program is free software. You can redistribute it and/or           */
10 /* modify it under the terms of the GNU General Public License             */
11 /* as published by the Free Software Foundation.                                           */
12 /***********************************************************************/
13 // $Id$
14 define('AT_INCLUDE_PATH', '../../include/');
15 require (AT_INCLUDE_PATH.'vitals.inc.php');
16 include (AT_PA_INCLUDE.'lib.inc.php');
17 include (AT_PA_INCLUDE.'classes/PhotoAlbum.class.php');
18 $_custom_css = $_base_path . AT_PA_BASENAME . 'module.css'; // use a custom stylesheet
19
20 //instantiate obj
21 $pa = new PhotoAlbum();
22 $keywords = explode(' ', trim($_POST['pa_search']));
23 $search_results = $pa->search($keywords);
24 $album_count = sizeof($pa->getSharedAlbums(true));
25
26 //paginator settings
27 $page = intval($_GET['p']);
28 $last_page = ceil($album_count/AT_PA_ALBUMS_PER_PAGE);
29
30 if (!$page || $page < 0) {
31         $page = 1;
32 } elseif ($page > $last_page){
33         $page = $last_page;
34 }
35
36 $count  = (($page-1) * AT_PA_ALBUMS_PER_PAGE) + 1;
37 $offset = ($page-1) * AT_PA_ALBUMS_PER_PAGE;
38
39 $albums = $pa->getSharedAlbums(true, $offset);
40
41 include (AT_INCLUDE_PATH.'header.inc.php'); 
42 $savant->assign('search_input', htmlentities($_POST['pa_search'], ENT_QUOTES, 'UTF-8'));
43 $savant->assign('albums', $search_results[0]);
44 $savant->assign('photos', $search_results[1]);
45 //$savant->assign('page', $page);
46 //$savant->assign('num_rows', $album_count);
47 $savant->display('pa_search.tmpl.php');
48 include (AT_INCLUDE_PATH.'footer.inc.php'); 
49 ?>