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 the add image / comment 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
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
32 define('PATH', '../');
\r
33 require_once (PATH.'define.php');
\r
34 require_once (PATH.'include/data_func.php');
\r
35 require_once (PATH.'include/general_func.php');
\r
36 require_once (PATH.'classes/image_upload.class.php');
\r
37 require_once (PATH.'HTML/Template/ITX.php');
\r
39 $template= new HTML_Template_ITX("../Template");
\r
40 $template->loadTemplatefile("form.tpl.php");
\r
41 $template->setVariable("JAVA_SRC", BASE_PATH.'handler/fat.js');
\r
43 if (isset($_POST['cancel_image'])){
\r
44 if ($_SESSION['pa']['administrator_mode']==true){
\r
45 $action='admin_image_list.php';
\r
46 } else if ($_SESSION['pa']['instructor_mode']==true){
\r
47 $action='instructor_image.php';
\r
49 $action='index.php';
\r
52 } else if ((isset($_POST['upload_image']) || ($_SESSION['pa']['image_uploaded']==true)) && ($_SESSION['pa']['mode']=='add')){ /* mode add */
\r
53 if (isset($_POST['upload_image'])){ //initial add
\r
54 $temp_folder=make_temp_folder();
\r
55 $upload=new IMAGE_UPLOAD($_FILES['input_file'], $temp_folder);
\r
56 if ($upload->isError()){ //check fatal error is occured or not
\r
57 $msg->addError('pa_obj_image_upload');
\r
59 } else if ($upload->getVariable('user_input_error')!=0){ //user error is occured.
\r
60 $error_array=$upload->getVariable('user_input_array');
\r
61 $msg->addError('pa_user_'.$error_array[0]);
\r
62 redirect('handler/file_upload.php');
\r
63 } else { //no error is found
\r
64 $_SESSION['pa']['thumb_image_name']=$upload->getVariable('thumb_image_name');
\r
65 $_SESSION['pa']['view_image_name']=$upload->getVariable('view_image_name');
\r
66 $_SESSION['pa']['image_uploaded']=true;
\r
67 $_SESSION['pa']['temp_folder']=$temp_folder;
\r
71 if ($_SESSION['pa']['error']['title']==true){
\r
72 $title_fade="class=\"fade\"";
\r
73 unset($_SESSION['pa']['error']['title']);
\r
75 if ($_SESSION['pa']['error']['alt']==true){
\r
76 $alt_fade="class=\"fade\"";
\r
77 unset($_SESSION['pa']['error']['alt']);
\r
80 /* Now, display the form */
\r
82 $template->setCurrentBlock("IMAGE_DISPLAY");
\r
83 $template->setVariable("IMAGE_SRC", $get_file.$_SESSION['pa']['temp_folder'].urlencode($_SESSION['pa']['thumb_image_name']));
\r
84 $template->setVariable("ALT", _AT('pa_tag_image_add_alt'));
\r
86 $template->setCurrentBlock("INPUT_PART");
\r
87 $template->setVariable("MESSAGE", _AT('pa_note_image_info_add'));
\r
88 $template->setVariable("TEXT_FORM", "text_form");
\r
89 $template->setVariable("TEXT_ACTION", STORE_ACTION);
\r
90 $template->setVariable("TITLE_MESSAGE", _AT('pa_label_pic_title'));
\r
91 $template->setVariable("TITLE_FADE", $title_fade);
\r
92 $template->setVariable("TITLE_VALUE", $_SESSION['pa']['title']);
\r
93 $template->setVariable("DESC_MESSAGE", _AT('pa_label_pic_description'));
\r
94 $template->setVariable("DESC_VALUE", $_SESSION['pa']['description']);
\r
95 if (is_admin_for_course()){
\r
96 $template->setCurrentBlock("ALT_PART");
\r
97 $template->setVariable("ALT_MESSAGE", _AT('pa_label_pic_alt'));
\r
98 $template->setVariable("ALT_FADE", $alt_fade);
\r
99 $template->setVariable("ALT_VALUE", $_SESSION['pa']['alt']);
\r
100 $template->parseCurrentBlock("ALT_PART");
\r
102 $template->setVariable("SUBMIT_MESSAGE", _AT('pa_button_upload_image_info'));
\r
104 $template->setVariable("CANCEL_STRING", _AT('cancel'));
\r
106 $template->parseCurrentBlock("IMAGE_DISPLAY");
\r
107 $template->parseCurrentBlock();
\r
110 /* mode add for comment */
\r
111 } else if ((($_POST['mode']=='add') && ($_POST['choose']==COMMENT)) || (($_SESSION['pa']['mode']=='add') && ($_SESSION['pa']['choose']==COMMENT))){
\r
112 $template->setVariable("TITLE", _AT('pa_title_comment_add'));
\r
113 $_SESSION['pa']['choose']=COMMENT;
\r
114 $_SESSION['pa']['mode']='add';
\r
115 if ($_SESSION['pa']['error']['comment']==true){
\r
118 $template->setCurrentBlock("COMMENT");
\r
119 $template->setVariable("COMMENT_MESSAGE", _AT('pa_note_comment_add'));
\r
120 $template->setVariable("COMMENT_LABEL", _AT('pa_label_comment_textarea'));
\r
121 $template->setVariable("COMMENT_FORM", "comment_form");
\r
122 $template->setVariable("COMMENT_ACTION", STORE_ACTION);
\r
123 $template->setVariable("COMMENT_FADE", $fade);
\r
124 $template->setVariable("SUBMIT_VALUE", _AT('pa_button_upload_comment'));
\r
126 $template->setVariable("CANCEL_STRING", _AT('cancel'));
\r
128 $template->parseCurrentBlock("COMMENT");
\r
129 $template->parseCurrentBlock();
\r
131 } else { //invalid way of entrance
\r
132 $msg->addError('pa_var_unauthorized');
\r
138 <?php require_once(AT_INCLUDE_PATH.'footer.inc.php'); ?>