c629994e535c870c28408ed0f9c2c4d06b3eb900
[atutor.git] / mods / photo_album / my_photo.php
1 <?php\r
2 /*==============================================================\r
3   Photo Album\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
8                                                                \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
13  */\r
14 // $Id:\r
15 \r
16 /**\r
17  * @desc        This file displays the my photo page\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
21  * @license GNU\r
22  */\r
23 \r
24 define('AT_INCLUDE_PATH', '../../include/');\r
25 require_once(AT_INCLUDE_PATH.'vitals.inc.php');\r
26 $_custom_css = $_base_path . 'mods/photo_album/module.css'; // use a custom stylesheet\r
27 require_once (AT_INCLUDE_PATH.'header.inc.php');\r
28 ?>\r
29 \r
30 <?php\r
31 require_once ('define.php');\r
32 require_once ('classes/pa_mypic.class.php');\r
33 require_once ('include/general_func.php');\r
34 require_once ('HTML/Template/ITX.php');\r
35 \r
36 if ($_SESSION['enroll']!=true){\r
37         $msg->addError('pa_var_unauthorized');\r
38         redirect('index.php');\r
39 }\r
40 $my=new Mypic();\r
41 if ($my->isError()!=true){      //no error is occured\r
42         $course_id=$_SESSION['pa']['course_id'];        //store course_id temporarily\r
43         unset($_SESSION['pa']);                                         //clear pa session variables\r
44         $_SESSION['pa']['course_id']=$course_id;\r
45         $_SESSION['pa']['my_pic_mode']=true;\r
46         \r
47         $template=new HTML_Template_ITX("./Template");\r
48         $template->loadTemplateFile("my_photo.tpl.php");\r
49         \r
50         switch ($my->getVariable('mode')){\r
51                 case POSTED_NEW:\r
52                         $template->setVariable("TITLE", _AT('pa_title_my_photo_new'));\r
53                 break;\r
54                 case APPROVED:\r
55                         $template->setVariable("TITLE", _AT('pa_title_my_photo_approved'));\r
56                 break;\r
57                 case DISAPPROVED:\r
58                         $template->setVariable("TITLE", _AT('pa_title_my_photo_disapproved'));\r
59                 break;\r
60         }\r
61         \r
62         $template->setVariable("MAIN_URL", BASE_PATH.'index.php');\r
63         $template->setVariable("MAIN_TITLE", _AT('pa_tag_course_photo_alt'));\r
64         \r
65         $template->setVariable("MY_PHOTO_URL", BASE_PATH.'my_photo.php');\r
66         $template->setVariable("MY_PHOTO_TITLE", _AT('pa_tag_my_photo_alt'));\r
67         \r
68         $template->setVariable("MY_COMMENT_URL", BASE_PATH.'my_comment.php');\r
69         $template->setVariable("MY_COMMENT_TITLE", _AT('pa_tag_my_comment_alt'));\r
70         \r
71         \r
72         $template->setCurrentBlock("SELECT_PART");\r
73         $template->setVariable("DESTINATION", BASE_PATH.'my_photo.php?mode='.POSTED_NEW.SEP.'current_page='.$my->getVariable('current_page'));\r
74         $template->setVariable("LINK_TEXT", _AT('pa_tag_new_pic').' | ');\r
75         $template->parseCurrentBlock("SELECT_PART");\r
76         \r
77         $template->setCurrentBlock("SELECT_PART");\r
78         $template->setVariable("DESTINATION", BASE_PATH.'my_photo.php?mode='.APPROVED.SEP.'current_page='.$my->getVariable('current_page'));\r
79         $template->setVariable("LINK_TEXT", _AT('pa_tag_approved_pic').' | ');\r
80         $template->parseCurrentBlock("SELECT_PART");\r
81         \r
82         $template->setCurrentBlock("SELECT_PART");\r
83         $template->setVariable("DESTINATION", BASE_PATH.'my_photo.php?mode='.DISAPPROVED.SEP.'current_page='.$my->getVariable('current_page'));\r
84         $template->setVariable("LINK_TEXT", _AT('pa_tag_disapproved_pic'));\r
85         $template->parseCurrentBlock("SELECT_PART");\r
86         \r
87         \r
88                 \r
89         /* start display images */\r
90         $image_array=$my->image_array;\r
91         for ($i=0; $i<count($image_array); $i++){\r
92                 $template->setCurrentBlock("IMAGE_DATA");\r
93                 $template->setVariable("CHECK_NAME", "imageId".$i);\r
94                 $template->setVariable("CHECK_VALUE", $image_array[$i]['image_id']);\r
95                 $img_src=$get_file.$image_array[$i]['location'].urlencode($image_array[$i]['thumb_image_name']);\r
96                 $template->setVariable("IMAGE_DATA1", $image_array[$i]['title']);\r
97                 $template->setVariable("IMAGE_DATA2", "<img src=\"".$img_src."\" alt=\"".$image_array[$i]['alt']."\"/>");\r
98                 $template->setVariable("IMAGE_DATA3", _AT('date').": ".$image_array[$i]['date']);\r
99         \r
100                 $template->setVariable("FORM_NAME", "edit_button");\r
101                 $template->setVariable("ACTION", UPLOAD_ACTION);\r
102                 $template->setVariable("CHOOSE_VALUE", IMAGE);\r
103                 $template->setVariable("IMAGE_ID", $image_array[$i]['image_id']);\r
104                 $template->setVariable("EDIT_VALUE", _AT('pa_button_edit_image'));\r
105                 $template->parseCurrentBlock("IMAGE_DATA");\r
106         }\r
107         \r
108         // Display page table \r
109         $page_array=$my->getVariable('page_array');\r
110         $current=$my->getVariable('current_page');\r
111         $template->setCurrentBlock("PAGE_TABLE_PART");\r
112         if ($my->getVariable('show_page_left_buttons')==true){\r
113                 $first_button=_AT('pa_tag_first_page_button');\r
114                 $previous_button=_AT('pa_tag_previous_page_button');\r
115                 $template->setCurrentBlock("B_DATA_PART");\r
116                 $template->setVariable("B_DATA", '<li><a href=\''.BASE_PATH.'my_photo.php?current_page=1&amp;mode='.$my->getVariable('mode').'\'><img src=\''.FIRST_PAGE_IMAGE.'\' alt=\''.$first_button.'\' width=\'30\' height=\'20\'/></a></li>');\r
117                 $template->parseCurrentBlock("B_DATA_PART");\r
118                 $template->setCurrentBlock("B_DATA_PART");\r
119                 $template->setVariable("B_DATA", '<li><a href=\''.BASE_PATH.'my_photo.php?current_page='.($current-1).SEP.'mode='.$my->getVariable('mode').'\'><img src=\''.PRE_IMAGE.'\' alt=\''.$previous_button.'\' width=\'30\' height=\'20\'/></a></li>');\r
120                 $template->parseCurrentBlock("B_DATA_PART");\r
121         }\r
122         \r
123         for ($i=$page_array['start']; $i<=$page_array['end']; $i++){\r
124                 if ($i==$current){\r
125                         $template->setCurrentBlock("B_DATA_PART");\r
126                         $template->setVariable("B_DATA", '<li class=\'current\'>'.$i.'</li>');\r
127                         $template->parseCurrentBlock("B_DATA_PART");\r
128                 } else {\r
129                         $template->setCurrentBlock("B_DATA_PART");\r
130                         $template->setVariable("B_DATA", '<li><a href=\''.BASE_PATH.'my_photo.php?current_page='.$i.SEP.'mode='.$my->getVariable('mode').'\'>'.$i.'</a></li>');\r
131                         $template->parseCurrentBlock("B_DATA_PART");\r
132                 }\r
133         }\r
134                 \r
135         if ($my->getVariable('show_page_right_buttons')==true){\r
136                 $next_button=_AT('pa_tag_next_page_button');\r
137                 $last_button=_AT('pa_tag_last_page_button');\r
138                 $template->setCurrentBlock("B_DATA_PART");\r
139                 $template->setVariable("B_DATA", '<li><a href=\''.BASE_PATH.'my_photo.php?current_page='.($current+1).SEP.'mode='.$my->getVariable('mode').'\'><img src=\''.NEXT_IMAGE.'\' alt=\''.$next_button.'\' width=\'30\' height=\'20\'/></a></li>');\r
140                 $template->parseCurrentBlock("B_DATA_PART");\r
141                 $template->setCurrentBlock("B_DATA_PART");\r
142                 $template->setVariable("B_DATA", '<li><a href=\''.BASE_PATH.'my_photo.php?current_page='.$page_array['last_page'].SEP.'mode='.$my->getVariable('mode').'\'><img src=\''.LAST_PAGE_IMAGE.'\' alt=\''.$last_button.'\' width=\'30\' height=\'20\'/></a></li>');\r
143                 $template->parseCurrentBlock("B_DATA_PART");\r
144         }\r
145                 \r
146         $template->parseCurrentBlock("PAGE_TABLE_PART");\r
147         $template->parseCurrentBlock();\r
148         $template->show();\r
149 } else {\r
150         $msg->addError('pa_obj_mypic');\r
151         redirect('index.php');\r
152 }\r
153 \r
154 ?>\r
155 \r
156 <?php require_once(AT_INCLUDE_PATH.'footer.inc.php'); ?>