1 <div id="uploader-contents">
2 <!-- Photo album options and page numbers -->
3 <?php if ($this->action_permission || $this->album_info['type_id']==AT_PA_TYPE_COURSE_ALBUM): ?>
4 <div class="add_photo">
5 <div class="toggle_uploader">
6 <input type="button" id="upload_manager" name="upload_manager" value="<?php echo _AT('pa_open_upload_manager'); ?>" onclick="toggleUploadManager()" class="button" />
7 <input type="hidden" id="upload_manager_toggle" value="1" />
10 <div class="input-form" id="ajax_uploader">
11 <div class="row" id="upload_button_div">
12 <p name="top"><?php echo _AT('pa_upload_blurb');?></p>
13 <p class="memory_usage"><?php echo _AT('pa_memory_usage').': '. number_format($this->memory_usage, 2) .'/ '. $this->allowable_memory_usage . ' ' . _AT('mb'); ?></p>
14 <label for="add_more_photos" id="upload_button"><?php echo _AT('pa_add_more_photos'); ?></label>
16 <div class="row" id="files_pending" style="display:none;">
17 <img src="<?php echo AT_PA_BASENAME; ?>images/loading.gif" alt="loading" title="loading"/>
21 <ul class="files"></ul>
24 <input id="files_done" disabled="disabled" type="button" value="<?php echo _AT("upload"); ?>" class="button" onClick="window.location.reload();" />
28 <?php endif; //action permission?>
30 <div class="album_panel">
32 <?php if($this->num_rows > AT_PA_PHOTOS_PER_PAGE): ?>
33 <div class="paginator">
34 <?php print_paginator($this->page, $this->num_rows, 'id='.$this->album_info['id'], AT_PA_PHOTOS_PER_PAGE, AT_PA_PAGE_WINDOW); ?>
38 <?php if(!empty($this->photos)): ?>
39 <!-- loop through this -->
40 <?php foreach($this->photos as $key=>$photo): ?>
41 <div class="photo_frame">
42 <a href="<?php echo AT_PA_BASENAME.'photo.php?pid='.$photo['id'].SEP.'aid='.$this->album_info['id'];?>"><img src="<?php echo AT_PA_BASENAME.'get_photo.php?aid='.$this->album_info['id'].SEP.'pid='.$photo['id'].SEP.'ph='.getPhotoFilePath($photo['id'], '', $photo['created_date']);?>" title="<?php echo htmlentities_utf82($photo['description'], false); ?>" alt="<?php echo htmlentities_utf82($photo['alt_text']);?>" /></a>
46 <div class="album_description">
47 <p><?php if($this->album_info['location']!='') echo _AT('location').': '.htmlentities_utf82($this->album_info['location']) .'<br/>';?>
48 <?php echo htmlentities_utf82($this->album_info['description']);?></p>
51 <div class="edit_photo_box">
52 <p><?php echo _AT('pa_no_photos'); ?></p>
57 <?php if($this->num_rows > AT_PA_PHOTOS_PER_PAGE): ?>
58 <div class="paginator">
59 <?php print_paginator($this->page, $this->num_rows, 'id='.$this->album_info['id'], AT_PA_PHOTOS_PER_PAGE, AT_PA_PAGE_WINDOW); ?>
66 <div class="comment_panel">
67 <div class="comment_feeds">
68 <?php if (!empty($this->comments)): ?>
69 <?php foreach($this->comments as $k=>$comment_array): ?>
70 <div class="comment_box" id="comment_box">
71 <!-- TODO: Profile link and img -->
72 <?php if ($this->action_permission || $comment_array['member_id']==$_SESSION['member_id']): ?>
73 <div class="flc-inlineEditable">
74 <a href="profile.php?id=<?php echo $comment_array['member_id'];?>"><strong><?php echo htmlentities_utf82(AT_print(get_display_name($comment_array['member_id']), 'members.full_name')); ?></a></strong>
75 <span class="flc-inlineEdit-text" id="<?php echo $comment_array['id'];?>" ><?php echo htmlentities_utf82($comment_array['comment']);?></span>
79 <a href="profile.php?id=<?php echo $comment_array['member_id'];?>"><strong><?php echo htmlentities_utf82(AT_print(get_display_name($comment_array['member_id']), 'members.full_name')); ?></a></strong>
80 <?php echo htmlentities_utf82($comment_array['comment'], true);?>
83 <div class="comment_actions">
84 <!-- TODO: if author, add in-line "edit" -->
85 <?php echo AT_date(_AT('forum_date_format'), $comment_array['created_date'], AT_DATE_MYSQL_DATETIME);?>
86 <?php if ($this->action_permission || $comment_array['member_id']==$_SESSION['member_id']): ?>
87 <a href="<?php echo AT_PA_BASENAME.'delete_comment.php?aid='.$this->album_info['id'].SEP.'comment_id='.$comment_array['id']?>"><?php echo _AT('delete');?></a>
91 <?php endforeach; endif;?>
92 <!-- TODO: Add script to check, comment cannot be empty. -->
94 <form action="<?php echo AT_PA_BASENAME;?>addComment.php" method="post" class="input-form">
95 <div class="row"><label for="comments"><?php echo _AT('comments');?></label></div>
96 <div class="row"><textarea name="comment" id="comment_template" onclick="jQuery(this).hide();c=jQuery('#comment');c.show();c.focus();" onkeyup="jQuery(this).hide();c=jQuery('#comment');c.show();c.focus();"><?php echo _AT('pa_write_a_comment'); ?></textarea></div>
97 <div class="row"><textarea name="comment" id="comment" style="display:none;"></textarea></div>
99 <input type="hidden" name="aid" value="<?php echo $this->album_info['id'];?>" />
100 <input type="submit" name="submit" value="<?php echo _AT('comment');?>" class="button"/>
106 <?php if($this->action_permission): ?>
107 <div class="photo_actions">
108 <a href="<?php echo AT_PA_BASENAME.'edit_album.php?id='.$this->album_info['id']; ?>"><?php echo _AT('pa_edit_album'); ?></a><br/>
115 <script type="text/javascript">
117 /* Fluid inline editor */
118 jQuery(document).ready(function () {
119 //the ATutor undo function
120 var undo = function (that, targetContainer) {
121 var markup = "<span class='flc-undo' aria-live='polite' aria-relevant='all'>" +
122 "<span class='flc-undo-undoContainer'>[<a href='#' class='flc-undo-undoControl'><?php echo _AT('pa_undo'); ?></a>]</span>" +
123 "<span class='flc-undo-redoContainer'>[<a href='#' class='flc-undo-redoControl'><?php echo _AT('pa_redo'); ?></a>]</span>" +
125 var markupNode = jQuery(markup);
126 targetContainer.append(markupNode);
129 var pa_click_here_to_edit = '<?php echo _AT("pa_click_here_to_edit"); ?>';
130 var pa_click_item_to_edit = '<?php echo _AT("pa_click_item_to_edit"); ?>';
132 fluid.inlineEdits(".comment_feeds", {
133 componentDecorators: {
134 type: "fluid.undoDecorator",
139 defaultViewText: pa_click_here_to_edit,
141 tooltipText: pa_click_item_to_edit,
143 modelChanged: function(model, oldModel, source){
144 /* for undo/redo model change */
145 if (model != oldModel && source != undefined){
146 viewNode = source.component.container.children('.flc-inlineEdit-text')[0];
147 rtn = jQuery.post("<?php echo $_base_path. AT_PA_BASENAME.'edit_comment.php';?>",
149 "aid":<?php echo $this->album_info['id'];?>,
151 "comment":model.value},
156 afterFinishEdit : function (newValue, oldValue, editNode, viewNode) {
157 if (newValue != oldValue){
158 rtn = jQuery.post("<?php echo $_base_path. AT_PA_BASENAME.'edit_comment.php';?>",
160 "aid":<?php echo $this->album_info['id'];?>,
172 <?php if ($this->action_permission || $this->album_info['type_id']==AT_PA_TYPE_COURSE_ALBUM): ?>
173 var upload_pending = 0; //counter for pending files
174 var ajax_upload = new AjaxUpload('upload_button', {
175 // Location of the server-side upload script
176 // NOTE: You are not allowed to upload files to another domain
177 action: '<?php echo $_base_path. AT_PA_BASENAME; ?>albums.php',
181 title: '<?php echo _AT("pa_add_more_photos"); ?>',
182 // Additional data to send
185 id : '<?php echo $this->album_info['id'];?>'
187 // Submit file after selection
189 // The type of data that you're expecting back from the server.
190 // HTML (text) and XML are detected automatically.
191 // Useful when you are using JSON data as a response, set to "json" in that case.
192 // Also set server response type to text/html, otherwise it will not work in IE6
194 // Fired after the file is selected
195 // Useful when autoSubmit is disabled
196 // You can return false to cancel upload
197 // @param file basename of uploaded file
198 // @param extension of that file
199 onChange: function(file, extension){},
200 // Fired before the file is uploaded
201 // You can return false to cancel upload
202 // @param file basename of uploaded file
203 // @param extension of that file
204 onSubmit: function(file, extension) {
206 if (upload_pending > 0){
207 jQuery('#files_pending').show();
208 jQuery('#files_done').attr('disabled', 'disabled');
210 jQuery('#files_pending').children('span').text('Loading... '+ (upload_pending)+' Remaining')
212 // Fired when file upload is completed
213 // WARNING! DO NOT USE "FALSE" STRING AS A RESPONSE!
214 // @param file basename of uploaded file
215 // @param response server response
216 onComplete: function(file, response) {
217 // console.debug(response);
218 // add file to the list
219 response_array = JSON.parse(response);
220 if (response_array.error==true){
221 //error, then refresh URL
222 // console.debug(response_array);
224 img = jQuery('<img>').attr('src', '<?php echo $_base_href . AT_PA_BASENAME . "images/no.png" ?>');
225 img.attr('alt', '<?php echo _AT("error"); ?>');
226 img.attr('title', file);
228 //update error log msg
229 file_msg = jQuery('<div>').text(response_array.msg);
230 file_msg.attr('style', 'float:left; width: 80%');
233 img = jQuery('<img>').attr('src', '<?php echo $_base_href . AT_PA_BASENAME; ?>get_photo.php?aid='+response_array.aid+'&pid='+response_array.pid+'&ph='+response_array.ph);
234 img.attr('alt', response_array.alt);
235 img.attr('title', file);
236 img.attr('class', 'tn');
238 //update error log msg
239 file_msg = jQuery('<div>').text('<?php echo _AT("pa_processed"); ?>: ' + file + ' (' + response_array.size );
240 file_kb = jQuery('<span>').html('<?php echo _AT("kb"); ?>)');
241 file_kb.appendTo(file_msg);
242 file_msg.attr('style', 'float:left; width: 80%;');
246 imgx = jQuery('<img>').attr('src', '<?php echo $_base_href . "images/x.gif" ?>');
247 imgx.attr('title', '<?php echo _AT("remove");?> ' + file);
248 imgx.attr('alt', '<?php echo _AT("remove");?> ' + file);
251 a_delete = jQuery('<a>');
252 a_delete.attr('href', '<?php echo $_SERVER["REQUEST_URI"]; ?>#top');
253 a_delete.attr('id', response_array.pid);
254 a_delete.click(function(){deletePhoto(response_array.aid, this)});
257 img_wrapper = jQuery('<div>');
258 img_wrapper.attr('style', 'float:left; ');
259 img.appendTo(img_wrapper);
260 a_delete.appendTo(img_wrapper);
261 imgx.appendTo(a_delete);
264 li = jQuery('<li></li>');
265 li.prependTo('#ajax_uploader .files');
266 file_msg.appendTo(li);
267 img_wrapper.appendTo(li);
269 jQuery('#files_pending').children('span').text('Loading... '+ (--upload_pending)+' Remaining')
270 if (upload_pending == 0){
271 jQuery('#files_pending').hide();
272 jQuery('#files_done').removeAttr('disabled');
278 function deletePhoto(aid, thisobj) {
279 var thisobj = thisobj;
282 //run iff it is a photo
283 if(aid > 0 && pid > 0){
284 xmlhttp=GetXmlHttpObject();
286 alert ("Your browser does not support AJAX!");
289 var url='<?php echo $_base_href . AT_PA_BASENAME; ?>remove_uploaded_photo.php?aid='+aid+'&pid='+pid;
290 xmlhttp.onreadystatechange=function(){
291 // console.debug(xmlhttp);
292 if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
293 jQuery(thisobj).parent().parent().remove(); //delete from DOM tree.
296 xmlhttp.open("GET",url,true);
299 //simply remove tihs node without running anything in the DB
300 jQuery(thisobj).parent().parent().remove(); //delete from DOM tree.
302 if(jQuery('#add_more_photos').length){
303 jQuery('#add_more_photos').focus();
307 function GetXmlHttpObject() {
308 if (window.XMLHttpRequest) {
309 // code for IE7+, Firefox, Chrome, Opera, Safari
310 return new XMLHttpRequest();
312 if (window.ActiveXObject){
314 return new ActiveXObject("Microsoft.XMLHTTP");
321 * Toggle add more photo display, and the value of the button
323 function toggleUploadManager(){
324 flag = jQuery('#upload_manager_toggle').val();
326 jQuery('#upload_manager').val('<?php echo _AT("pa_close_upload_manager"); ?>');
327 jQuery('#upload_manager_toggle').val(0);
329 jQuery('#upload_manager').val('<?php echo _AT("pa_open_upload_manager"); ?>');
330 jQuery('#upload_manager_toggle').val(1);
332 jQuery('#ajax_uploader').toggle();