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 image data for the my pictures 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 ('define.php');
\r
25 require_once ('classes/pa.class.php');
\r
26 require_once ('include/general_func.php');
\r
27 require_once ('include/data_func.php');
\r
33 class Mypic extends Pa{
\r
34 var $mode=POSTED_NEW;
\r
35 var $image_array=Array();
\r
36 var $page_array=Array();
\r
37 var $current_page=-1;
\r
38 var $show_page_left_buttons=false;
\r
39 var $show_page_right_buttons=false;
\r
41 var $last_page=NOT_SET;
\r
44 * @desc class constructor
\r
49 $this->checkCurrentPage();
\r
56 * @desc This function decides whether to display left arrow and right arrow buttons for the page table
\r
58 function setPages(){
\r
59 $temp=get_page_array(MYPIC_NUMBER_OF_IMAGE, MYPIC_NUMBER_OF_IMAGE_PAGE, $this->getVariable('current_page'), $this->getVariable('last_page'));
\r
60 $current=$this->getVariable('current_page');
\r
62 $this->setVariable('show_page_left_buttons', true);
\r
64 if ($current < $temp['last_page']){
\r
65 $this->setVariable('show_page_right_buttons', true);
\r
67 $this->page_array=&$temp;
\r
72 * @desc This function sets the mode value for the image display. The mode value can be one of POSTED_NEW, APPROVED, DISAPPROVED
\r
75 if (isset($_GET['mode'])){
\r
76 $this->setVariable('mode', intval($_GET['mode']));
\r
81 * @desc This function checks the current page is valid. Otherwise, the current page is set to 1
\r
83 function checkCurrentPage(){
\r
84 $total=get_total_image_number(MY_PIC, $this->getVariable('course_id'), $this->getVariable('mode'));
\r
85 $last_page=get_last_page(MYPIC_NUMBER_OF_IMAGE, $total);
\r
86 $this->setVariable('total', $total);
\r
87 $this->setVariable('last_page', $last_page);
\r
89 if (!isset($_GET['current_page'])){
\r
90 $this->setVariable('current_page', FIRST_PAGE);
\r
92 $current_page=to_pos_int($_GET['current_page']);
\r
93 if ($current_page > $last_page){
\r
94 $this->setVariable('current_page',$last_page);
\r
96 $this->setVariable('current_page', $current_page);
\r
102 * @desc This function sets the image array
\r
104 function setImages(){
\r
105 $array=get_image_array(MY_PIC, parent::getVariable('course_id'), $this->getVariable('mode'), $this->getVariable('current_page'), MYPIC_NUMBER_OF_IMAGE, $_SESSION['login']);
\r
106 $this->image_array=&$array;
\r
110 * @desc This function sets the given string to a value for the class object
\r
111 * @param String $string string name to set up
\r
112 * @param mixed $value string value
\r
114 function setVariable($string, $value){
\r
117 if ($value==APPROVED || $value==DISAPPROVED || $value==POSTED_NEW){
\r
118 $this->{$string}=$value;
\r
121 case 'current_page':
\r
124 if (is_int($value)){
\r
125 $this->{$string}=$value;
\r
127 parent::storeError("value ".$string." is not integer");
\r
130 case 'show_page_left_buttons':
\r
131 case 'show_page_right_buttons':
\r
132 if (is_bool($value)){
\r
133 $this->{$string}=$value;
\r
135 parent::storeError("value ".$string." is not boolean");
\r