+++ /dev/null
-<?php\r
-/*==============================================================\r
- Photo Album\r
- ==============================================================\r
- Copyright (c) 2006 by Dylan Cheon & Kelvin Wong\r
- Institute for Assistive Technology / University of Victoria\r
- http://www.canassist.ca/ \r
- \r
- This program is free software. You can redistribute it and/or\r
- modify it under the terms of the GNU General Public License \r
- as published by the Free Software Foundation. \r
- ==============================================================\r
- */\r
-// $Id:\r
-\r
-/**\r
- * @desc This file generates thumbnail image data for the index page - thumbnail view\r
- * @author Dylan Cheon & Kelvin Wong\r
- * @copyright 2006, Institute for Assistive Technology / University of Victoria \r
- * @link http://www.canassist.ca/ \r
- * @license GNU\r
- */\r
- \r
-require_once ('pa.class.php');\r
-\r
-/** \r
- * @desc class Pa_index.\r
- * @see class Pa\r
- */\r
-class Pa_Index extends Pa {\r
- var $current_page=0;\r
- var $show_page_left_buttons=false;\r
- var $show_page_right_buttons=false;\r
- var $image_array=Array();\r
- var $page_array=Array();\r
- var $total=NOT_SET;\r
- var $last_page=NOT_SET;\r
- \r
- /** \r
- * @desc class constructor\r
- */\r
- function Pa_Index (){\r
- parent::init();\r
- $this->checkCurrentPage();\r
- $this->setImages();\r
- $this->setPages();\r
- }\r
- \r
- /**\r
- * @desc this function sets the image array to display the index page\r
- */\r
- function setImages(){\r
- $temp=get_image_array(STUDENT, $this->getVariable('course_id'), APPROVED, $this->getVariable('current_page'), THUMB_NUMBER_OF_IMAGE);\r
- $this->image_array=&$temp;\r
- }\r
- \r
- /**\r
- * @desc This function decides whether the left arrow and right arrow button should be displayed in the page table\r
- */\r
- function setPages(){\r
- $temp=get_page_array(THUMB_NUMBER_OF_IMAGE, THUMB_NUMBER_OF_IMAGE_PAGE, $this->getVariable('current_page'), $this->getVariable('last_page'));\r
- if ($temp['current'] >1 ){\r
- $this->setVariable('show_page_left_buttons', true);\r
- }\r
- if ($temp['current'] < $temp['last_page']){\r
- $this->setVariable('show_page_right_buttons', true);\r
- }\r
- $this->page_array=&$temp;\r
- }\r
- \r
- /**\r
- * @desc This function sets the given string value\r
- * @param String $string string name to be set up\r
- * @param mixed $value string value\r
- */\r
- function setVariable($string, $value){\r
- switch ($string){\r
- case 'current_page':\r
- case 'total':\r
- case 'last_page':\r
- if (is_int($value)){\r
- $this->{$string}=$value;\r
- } else {\r
- parent::storeError("variable ".$string." is not an positive int");\r
- }\r
- break;\r
- case 'show_page_left_buttons':\r
- case 'show_page_right_buttons':\r
- if (is_bool($value)){\r
- $this->{$string}=$value;\r
- } else {\r
- parent::storeError("variable ".$string." is not boolean");\r
- }\r
- break;\r
- }\r
- }\r
- \r
- /**\r
- * @desc This function checks whether the current page value is valid. Otherwise it sets 1 for the current page value\r
- */\r
- function checkCurrentPage(){\r
- $total=get_total_image_number(STUDENT, $this->getVariable('course_id'), APPROVED);\r
- $last_page=get_last_page(THUMB_NUMBER_OF_IMAGE, $total);\r
- $this->setVariable('total', $total);\r
- $this->setVariable('last_page', $last_page);\r
- \r
- if (!isset($_GET['current_page'])){\r
- $this->setVariable('current_page', FIRST_PAGE);\r
- } else {\r
- $current_page=to_pos_int($_GET['current_page']);\r
- if ($current_page > $last_page){\r
- $this->setVariable('current_page',$last_page);\r
- } else {\r
- $this->setVariable('current_page', $current_page);\r
- }\r
- }\r
- }\r
-}
\ No newline at end of file