2 /*==============================================================
\r
4 ==============================================================
\r
5 Copyright (c) 2006 by Dylan Cheon & Kelvin Wong
\r
6 Institute for Assistive Technology / University of Victoria
\r
7 http://www.canassist.ca/
\r
9 This program is free software. You can redistribute it and/or
\r
10 modify it under the terms of the GNU General Public License
\r
11 as published by the Free Software Foundation.
\r
12 ==============================================================
\r
17 * @desc This file generates thumbnail image data for the index page - thumbnail view
\r
18 * @author Dylan Cheon & Kelvin Wong
\r
19 * @copyright 2006, Institute for Assistive Technology / University of Victoria
\r
20 * @link http://www.canassist.ca/
\r
24 require_once ('pa.class.php');
\r
27 * @desc class Pa_index.
\r
30 class Pa_Index extends Pa {
\r
31 var $current_page=0;
\r
32 var $show_page_left_buttons=false;
\r
33 var $show_page_right_buttons=false;
\r
34 var $image_array=Array();
\r
35 var $page_array=Array();
\r
37 var $last_page=NOT_SET;
\r
40 * @desc class constructor
\r
42 function Pa_Index (){
\r
44 $this->checkCurrentPage();
\r
50 * @desc this function sets the image array to display the index page
\r
52 function setImages(){
\r
53 $temp=get_image_array(STUDENT, $this->getVariable('course_id'), APPROVED, $this->getVariable('current_page'), THUMB_NUMBER_OF_IMAGE);
\r
54 $this->image_array=&$temp;
\r
58 * @desc This function decides whether the left arrow and right arrow button should be displayed in the page table
\r
60 function setPages(){
\r
61 $temp=get_page_array(THUMB_NUMBER_OF_IMAGE, THUMB_NUMBER_OF_IMAGE_PAGE, $this->getVariable('current_page'), $this->getVariable('last_page'));
\r
62 if ($temp['current'] >1 ){
\r
63 $this->setVariable('show_page_left_buttons', true);
\r
65 if ($temp['current'] < $temp['last_page']){
\r
66 $this->setVariable('show_page_right_buttons', true);
\r
68 $this->page_array=&$temp;
\r
72 * @desc This function sets the given string value
\r
73 * @param String $string string name to be set up
\r
74 * @param mixed $value string value
\r
76 function setVariable($string, $value){
\r
78 case 'current_page':
\r
81 if (is_int($value)){
\r
82 $this->{$string}=$value;
\r
84 parent::storeError("variable ".$string." is not an positive int");
\r
87 case 'show_page_left_buttons':
\r
88 case 'show_page_right_buttons':
\r
89 if (is_bool($value)){
\r
90 $this->{$string}=$value;
\r
92 parent::storeError("variable ".$string." is not boolean");
\r
99 * @desc This function checks whether the current page value is valid. Otherwise it sets 1 for the current page value
\r
101 function checkCurrentPage(){
\r
102 $total=get_total_image_number(STUDENT, $this->getVariable('course_id'), APPROVED);
\r
103 $last_page=get_last_page(THUMB_NUMBER_OF_IMAGE, $total);
\r
104 $this->setVariable('total', $total);
\r
105 $this->setVariable('last_page', $last_page);
\r
107 if (!isset($_GET['current_page'])){
\r
108 $this->setVariable('current_page', FIRST_PAGE);
\r
110 $current_page=to_pos_int($_GET['current_page']);
\r
111 if ($current_page > $last_page){
\r
112 $this->setVariable('current_page',$last_page);
\r
114 $this->setVariable('current_page', $current_page);
\r