remove old readme
[atutor.git] / mods / _standard / photos / search.php
1 <?php
2 /***********************************************************************/
3 /* ATutor                                                                                                                          */
4 /***********************************************************************/
5 /* Copyright (c) 2002-2010                                             */
6 /* 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 $_user_location = 'public';
15
16 define('AT_INCLUDE_PATH', '../../../include/');
17 require (AT_INCLUDE_PATH.'vitals.inc.php');
18 include (AT_PA_INCLUDE.'lib.inc.php');
19 include (AT_PA_INCLUDE.'classes/PhotoAlbum.class.php');
20 //$_custom_css = $_base_path . AT_PA_BASENAME . 'module.css'; // use a custom stylesheet
21
22 //instantiate obj
23 $pa = new PhotoAlbum();
24 $keywords = explode(' ', trim($_POST['pa_search']));
25 $search_results = $pa->search($keywords);
26 $album_count = sizeof($pa->getSharedAlbums(true));
27
28 //paginator settings
29 $page = intval($_GET['p']);
30 $last_page = ceil($album_count/AT_PA_ALBUMS_PER_PAGE);
31
32 if (!$page || $page < 0) {
33         $page = 1;
34 } elseif ($page > $last_page){
35         $page = $last_page;
36 }
37
38 $count  = (($page-1) * AT_PA_ALBUMS_PER_PAGE) + 1;
39 $offset = ($page-1) * AT_PA_ALBUMS_PER_PAGE;
40
41 $albums = $pa->getSharedAlbums(true, $offset);
42
43 include (AT_INCLUDE_PATH.'header.inc.php'); 
44 $savant->assign('search_input', AT_print($_POST['pa_search'], 'input.text'));
45 $savant->assign('albums', $search_results[0]);
46 $savant->assign('photos', $search_results[1]);
47 //$savant->assign('page', $page);
48 //$savant->assign('num_rows', $album_count);
49 $savant->display('photos/pa_search.tmpl.php');
50 include (AT_INCLUDE_PATH.'footer.inc.php'); 
51 ?>