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 photo album 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 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
28 // Save the order the images appear in GG
\r
30 // If you want to have the image order saved each time an image is moved
\r
31 // use the POST['submit'] line in place of the POST['save'] line below
\r
32 // Note that using the POST['submit'] has the potential to increase network traffic
\r
33 // where the photo album is being used by many at the same time.
\r
35 //if(isset($_POST['submit'])){
\r
37 if(isset($_POST['save']) && $_POST['save']!=''){
\r
38 if ($_REQUEST['current_page_num'] == ''){
\r
41 $current_page = intval($_REQUEST['current_page_num']);
\r
44 foreach($_POST as $image_id => $image_order){
\r
45 $image_order = intval($image_order);
\r
47 $image_id = intval($image_id);
\r
49 //calculate the new image_order associated w/ the page
\r
50 $image_order = ($current_page - 1) * 10 + $image_order; //+1 because value starts from 0.
\r
53 //If this is an image, update its order in the database
\r
54 if ($image_id > 0) {
\r
55 $sql = "UPDATE ".TABLE_PREFIX."pa_image set `order`=$image_order WHERE `image_id` = $image_id";
\r
56 if($result = mysql_query($sql, $db)){
\r
57 $msg->addFeedback('PA_IMAGE_ORDER_SAVED');
\r
58 if ($current_page > 0){
\r
59 $_GET['current_page'] = $current_page;
\r
65 require_once (AT_INCLUDE_PATH.'header.inc.php');
\r
67 // Set the path to Fluid, and call in the Fluid scripts. This path may change when/if the Fluid libraries become a part of the ATutor base code GG
\r
68 $FLUID_URL = 'mods/photo_album/fluid/component-templates'; ?>
\r
69 <script type="text/javascript" src="<?php echo $FLUID_URL; ?>/js/jquery/jquery-1.2.1.js"></script>
\r
70 <script type="text/javascript" src="<?php echo $FLUID_URL; ?>/js/jquery.tabindex/jquery.tabindex.js"></script>
\r
71 <script type="text/javascript" src="<?php echo $FLUID_URL; ?>/js/jquery.ui-1.0/ui.mouse.js"></script>
\r
72 <script type="text/javascript" src="<?php echo $FLUID_URL; ?>/js/jquery.ui-1.0/ui.draggable.js"></script>
\r
73 <script type="text/javascript" src="<?php echo $FLUID_URL; ?>/js/jquery.ui-1.0/ui.droppable.js"></script>
\r
74 <script type="text/javascript" src="<?php echo $FLUID_URL; ?>/js/fluid/Fluid.js"></script>
\r
75 <script type="text/javascript" src="<?php echo $FLUID_URL; ?>/js/fluid/Reorderer.js"></script>
\r
76 <script type="text/javascript" src="<?php echo $FLUID_URL; ?>/js/fluid/Lightbox.js"></script>
\r
78 <script type="text/javascript" language="javascript">
\r
79 jQuery.noConflict();
\r
83 /* This file is used to display the index page of photo album for everyone */
\r
84 require_once ('define.php');
\r
85 require_once ('classes/pa_index.class.php');
\r
86 require_once (PATH.'HTML/Template/ITX.php');
\r
87 clear_temp_folder();
\r
89 $index=new Pa_Index();
\r
90 unset($_SESSION['pa']);
\r
92 if ($index->isError()!=true){ //if there is no error in index object, display the index page
\r
93 $_SESSION['pa']['course_id']=$index->getVariable('course_id');
\r
95 /* display index page from here */
\r
96 $template=new HTML_Template_ITX(PATH."Template");
\r
97 $template->loadTemplatefile("index.tpl.php", true, true);
\r
99 /* display images */
\r
100 $template->setCurrentBlock("IMAGE_START");
\r
101 $template->setVariable("IMAGE_PAGE_TITLE", _AT('pa_title_index'));
\r
103 $template->setVariable("MAIN_URL", BASE_PATH.'index.php');
\r
104 $template->setVariable("MAIN_TITLE", _AT('pa_tag_course_photo_alt'));
\r
106 $template->setVariable("MY_PHOTO_URL", BASE_PATH.'my_photo.php');
\r
107 $template->setVariable("MY_PHOTO_TITLE", _AT('pa_tag_my_photo_alt'));
\r
109 $template->setVariable("MY_COMMENT_URL", BASE_PATH.'my_comment.php');
\r
110 $template->setVariable("MY_COMMENT_TITLE", _AT('pa_tag_my_comment_alt'));
\r
112 $template->setVariable("CURRENT_PAGE_NUM", $index->getVariable('current_page'));
\r
115 $image_array=$index->getVariable('image_array');
\r
116 for ($i=0; $i < count($image_array); $i++) {
\r
117 $template->setCurrentBlock("IMAGE_DISPLAY");
\r
118 $template->setVariable("IMAGE_ID",$image_array[$i]['image_id']);
\r
120 // the TABINDEX value is used to assign a unique value to each id when looping through each and rendering their presentation GG
\r
121 $template->setVariable("TABINDEX", $image_array[$i]['order']);
\r
122 $template->setVariable("LINK", $image_array[$i]['link']);
\r
123 $count=get_total_comment_number(STUDENT, $index->getVariable('course_id'), APPROVED, $image_array[$i]['image_id']);
\r
125 $template->setVariable("IMAGE_TITLE", $image_array[$i]['title']." [".$count."]");
\r
127 $template->setVariable("IMAGE_TITLE", $image_array[$i]['title']);
\r
129 $template->setVariable("IMAGE_SRC", $get_file.$image_array[$i]['location'].urlencode($image_array[$i]['thumb_image_name']));
\r
130 $template->setVariable("IMAGE_ALT", $image_array[$i]['alt']);
\r
131 $template->parseCurrentBlock("IMAGE_DISPLAY");
\r
134 if ($index->getVariable('show_modification_buttons')==true){
\r
135 $template->setCurrentBlock("IMAGE_ADD_BUTTON");
\r
136 $template->setVariable("FORM_NAME", "thumb_form");
\r
137 $template->setVariable("SAVE_FORM_NAME", "save_form");
\r
138 $template->setVariable("ACTION", UPLOAD_ACTION);
\r
139 $template->setVariable("SAVE_ACTION", $_SERVER['PHP_SELF']);
\r
140 $template->setVariable("ADD_STRING", _AT('pa_button_add_image'));
\r
141 //set the text for the save order button GG
\r
142 $template->setVariable("SAVE_STRING", _AT('pa_button_save_image_order'));
\r
143 $template->setVariable("CHOOSE_VALUE", IMAGE);
\r
144 $template->parseCurrentBlock("IMAGE_ADD_BUTTON");
\r
147 /* Display page table */
\r
148 $page_array=&$index->getVariable('page_array');
\r
149 $current=$index->getVariable('current_page');
\r
150 if ($index->getVariable('show_page_left_buttons')==true){
\r
151 $first_button=_AT('pa_tag_first_page_button');
\r
152 $previous_button=_AT('pa_tag_previous_page_button');
\r
153 $template->setCurrentBlock("B_DATA_PART");
\r
154 $template->setVariable("B_DATA", '<li><a href=\''.BASE_PATH.'index.php?current_page=1\'><img src=\''.FIRST_PAGE_IMAGE.'\' alt=\''.$first_button.'\' width=\'30\' height=\'20\'/></a></li>');
\r
155 $template->parseCurrentBlock("B_DATA_PART");
\r
156 $template->setCurrentBlock("B_DATA_PART");
\r
157 $template->setVariable("B_DATA", '<li><a href=\''.BASE_PATH.'index.php?current_page='.($current-1).'\'><img src=\''.PRE_IMAGE.'\' alt=\''.$previous_button.'\' width=\'30\' height=\'20\'/></a></li>');
\r
158 $template->parseCurrentBlock("B_DATA_PART");
\r
161 for ($i=$page_array['start']; $i<=$page_array['end']; $i++){
\r
163 $template->setCurrentBlock("B_DATA_PART");
\r
164 $template->setVariable("B_DATA", '<li class=\'current\'>'.$i.'</li>');
\r
165 $template->parseCurrentBlock("B_DATA_PART");
\r
167 $template->setCurrentBlock("B_DATA_PART");
\r
168 $template->setVariable("B_DATA", '<li><a href=\''.BASE_PATH.'index.php?current_page='.$i.'\'>'.$i.'</a></li>');
\r
169 $template->parseCurrentBlock("B_DATA_PART");
\r
173 if ($index->getVariable('show_page_right_buttons')==true){
\r
174 $next_button=_AT('pa_tag_next_page_button');
\r
175 $last_button=_AT('pa_tag_last_page_button');
\r
176 $template->setCurrentBlock("B_DATA_PART");
\r
177 $template->setVariable("B_DATA", '<li><a href=\''.BASE_PATH.'index.php?current_page='.($current+1).'\'><img src=\''.NEXT_IMAGE.'\' alt=\''.$next_button.'\' width=\'30\' height=\'20\'/></a></li>');
\r
178 $template->parseCurrentBlock("B_DATA_PART");
\r
179 $template->setCurrentBlock("B_DATA_PART");
\r
180 $template->setVariable("B_DATA", '<li><a href=\''.BASE_PATH.'index.php?current_page='.$page_array['last_page'].'\'><img src=\''.LAST_PAGE_IMAGE.'\' alt=\''.$last_button.'\' width=\'30\' height=\'20\'/></a></li>');
\r
181 $template->parseCurrentBlock("B_DATA_PART");
\r
184 $template->parseCurrentBlock("B_DATA_PART");
\r
185 $template->parseCurrentBlock("IMAGE_START");
\r
186 $template->parseCurrentBlock();
\r
189 $msg->addError('pa_obj_pa_index');
\r
190 redirect('../../index.php');
\r
194 <!-- Init the Fluid lightbox -->
\r
195 <script type="text/javascript">
\r
196 fluid.initLightbox ("gallery:::gallery-thumbs:::", "message-bundle:");
\r
200 <!-- HARRIS STARTS -->
\r
201 <script language="javascript" type="text/javascript">
\r
203 * We know the form, but things got reorganized, one thing we are certained is the DOM subtree ordering.
\r
204 * use that for our advantage.
\r
205 * @param the name of the form, that contains all these photos
\r
207 function reordering_pa(form_name){
\r
208 //Quit if form_name isn't specified
\r
209 if (form_name==""){
\r
214 var myForm = document.forms[form_name];
\r
216 //keep track of DOM order
\r
219 //loop through the new DOM tree and updates its associated values
\r
220 for (var i=0; i < myForm.elements.length; i++){
\r
221 // reassign values by DOM elements
\r
222 // TODO, maps the ID instead?
\r
223 var inputs = myForm.elements[i];
\r
224 if (inputs.id.indexOf('gallery:::gallery-thumbs:::lightbox-cell:') > -1){
\r
225 inputs.value = count;
\r
231 <!-- HARRIS ENDS -->
\r
235 require_once(AT_INCLUDE_PATH.'footer.inc.php'); ?>
\r