2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /****************************************************************/
13 // $Id: filemanager.php 5078 2005-07-06 14:16:53Z joel $
15 if (!defined('AT_INCLUDE_PATH')) { exit; }
17 function get_file_extension($file_name) {
18 $ext = pathinfo($file_name);
19 return $ext['extension'];
22 function get_file_type_icon($file_name) {
25 $ext = get_file_extension($file_name);
28 require(AT_INCLUDE_PATH .'lib/mime.inc.php');
31 if (isset($mime[$ext]) && $mime[$ext][1]) {
32 return $mime[$ext][1];
37 function get_relative_path($src, $dest) {
40 } else if (substr($dest, 0, strlen($src)) == $src) {
41 $path = substr($dest, strlen($src) + 1);
43 $depth = substr_count($src, '/');
44 for ($i = 0; $i < $depth + 1; $i++) // $depth+1 because the last '/' is not recorded in content.content_path
52 // get the course total in Bytes
53 $course_total = dirsize($current_path);
55 $framed = intval($_GET['framed']);
56 $popup = intval($_GET['popup']);
58 $cid = intval($_GET['cid']); // content id, used at "adapted content" page, => add/edit alternatives
59 $pid = intval($_GET['pid']); // primary resource id, used at "adapted content" page, => add/edit alternatives
60 $a_type = intval($_GET['a_type']); // alternative_type, used at "adapted content" page, => add/edit alternatives
62 if (defined('AT_FORCE_GET_FILE') && AT_FORCE_GET_FILE) {
63 $get_file = 'get.php/';
65 $get_file = 'content/' . $_SESSION['course_id'] . '/';
69 global $pathext, $framed, $popup, $cp, $cid, $pid, $a_type;
70 echo '<p>'._AT('current_path').' ';
72 if (isset($pathext) && $pathext != '') {
73 echo '<a href="'.$_SERVER['PHP_SELF'].'?popup=' . $popup . SEP . 'framed=' . $framed.SEP . 'cp=' . $cp.SEP . 'cid=' . $cid.SEP . 'pid=' . $pid.SEP . 'a_type=' . $a_type.'">'._AT('home').'</a> ';
81 if ($pathext == '' && isset($_POST['pathext'])) {
83 $pathext = urlencode($_POST['pathext']);
87 $bits = explode('/', $pathext);
89 foreach ($bits as $bit) {
91 $bit_path .= $bit . '/';
94 if ($bit_path == $pathext) {
97 echo '<a href="'.$_SERVER['PHP_SELF'].'?pathext=' . urlencode($bit_path) . SEP . 'popup=' . $popup . SEP . 'framed=' . $framed . SEP.'cp='.$_GET['cp'].SEP.'pid='.$_GET['pid'].SEP.'cid='.$cid.SEP.'a_type='.$a_type.'">' . $bit . '</a>';
108 if ($popup == TRUE) {
115 if (TRUE || $framed != TRUE) {
117 if ($_GET['overwrite'] != '') {
118 // get file name, out of the full path
119 $path_parts = pathinfo($current_path.$_GET['overwrite']);
121 if (!file_exists($path_parts['dirname'].'/'.$pathext.$path_parts['basename'])
122 || !file_exists($path_parts['dirname'].'/'.$pathext.substr($path_parts['basename'], 5))) {
123 /* source and/or destination does not exist */
124 $msg->addErrors('CANNOT_OVERWRITE_FILE');
126 @unlink($path_parts['dirname'].'/'.$pathext.substr($path_parts['basename'], 5));
127 $result = @rename($path_parts['dirname'].'/'.$pathext.$path_parts['basename'], $path_parts['dirname'].'/'.$pathext.substr($path_parts['basename'], 5));
130 $msg->addFeedback('FILE_OVERWRITE');
132 $msg->addErrors('CANNOT_OVERWRITE_FILE');
137 // filemanager listing table
138 // make new directory
139 echo '<div class="input-form"><fieldset class="group_form"><legend class="group_form">'._AT('add_file_folder').'</legend>'."\n";
140 echo ' <div class="row">'."\n";
141 echo ' <form name="form1" method="post" action="'.$_SERVER['PHP_SELF'].'?'.(($pathext != '') ? 'pathext='.urlencode($pathext).SEP : ''). 'popup='.$popup.SEP.'cp='.SEP.$_GET['cp'].SEP.'pid='.$_GET['pid'].SEP.'cid='.$cid.SEP.'a_type='.$a_type.'">'."\n";
143 if ($depth < $MaxDirDepth) {
144 echo ' <label for="dirname">'._AT('create_folder_here').'</label><br />'."\n";
145 echo ' <small class="spacer">'._AT('keep_it_short').'</small><br />'."\n";
146 echo ' <input type="text" name="dirname" id="dirname" size="20" /> '."\n";
147 echo ' <input type="hidden" name="mkdir_value" value="true" /> '."\n";
148 echo ' <input type="submit" name="mkdir" value="'._AT('create_folder').'" class="button" />'."\n";
150 echo _AT('depth_reached')."\n";
153 echo ' <input type="hidden" name="pathext" value="'.$pathext.'" />'."\n";
154 echo ' </form>'."\n";
157 echo ' <div class="row"><hr /></div>'."\n";
160 // If flash is available, provide the option of using Fluid's uploader or the basic uploader
161 if (isset($_SESSION['flash']) && $_SESSION['flash'] == "yes") {
162 echo '<div class="row">'."\n";
163 if (isset($_COOKIE["fluid_on"]) && $_COOKIE["fluid_on"]=="yes")
164 $fluid_on = 'checked="checked"';
165 echo '(<input type="checkbox" id="fluid_on" name="fluid_on" onclick="toggleform(\'simple-container\', \'fluid-container\'); setCheckboxCookie(this, \'fluid_on=yes\', \'fluid_on=no\',\'December 31, 2099\');" value="yes" '.$fluid_on.' /> '."\n";
166 echo '<label for="fluid_on" >'._AT('enable_uploader').'</label>)'."\n";
172 echo ' <div class="row" style="float: left;"><input type="button" class="button" name="new_file" value="' . _AT('file_manager_new') . '" onclick="window.location.href=\''.AT_BASE_HREF.'mods/_core/file_manager/new.php?pathext=' . urlencode($pathext) . SEP . 'framed=' . $framed . SEP . 'popup=' . $popup . '\'"/></div>'."\n";
174 $my_MaxCourseSize = $system_courses[$_SESSION['course_id']]['max_quota'];
177 if (($my_MaxCourseSize == AT_COURSESIZE_UNLIMITED)
178 || (($my_MaxCourseSize == AT_COURSESIZE_DEFAULT) && ($course_total < $MaxCourseSize))
179 || ($my_MaxCourseSize-$course_total > 0)) {
180 echo ' <div class="row" style="float: left;">'._AT('OR').'</div>'."\n".' <div class="row" style="float: left;">'."\n";
181 if (isset($_SESSION['flash']) && $_SESSION['flash'] == "yes") {
183 <div id="fluid-container" <?php echo (isset($_COOKIE["fluid_on"]) && $_COOKIE["fluid_on"]=="yes") ? '' : 'style="display:none;"'; ?>>
184 <input type="button" id="uploader_link" class="button" name="upload_file" value="<?php echo _AT('upload_files'); ?>" onclick="toggleform('uploader', 'uploader_link');" />
185 <div id="uploader" style="display: none;">
186 <form id="flc-uploader" class="flc-uploader fl-uploader fl-progEnhance-enhanced" method="get" enctype="multipart/form-data" action="" style="margin: 0px; padding: 0px;">
188 <div class="fl-uploader-queue-wrapper">
189 <div class="fl-uploader-queue-header">
190 <table cellspacing="0" cellpadding="0">
192 <th scope="col" class="fileName"><?php echo _AT('file_name'); ?></th>
193 <th scope="col" class="fileSize"><?php echo _AT('size'); ?> </th>
194 <th scope="col" class="fileRemove"> </th>
199 <div class="flc-scroller fl-scroller">
200 <div class="fl-scroller-inner">
201 <table cellspacing="0" class="flc-uploader-queue fl-uploader-queue" summary="Queue of files to upload.">
203 <!-- Rows will be rendered in here. -->
205 <!-- Template markup for the file queue rows -->
206 <tr class="flc-uploader-file-tmplt flc-uploader-file fl-uploader-hidden-templates">
207 <th class="flc-uploader-file-name fl-uploader-file-name" scope="row"><?php echo _AT('file_placeholder'); ?></th>
208 <td class="flc-uploader-file-size fl-uploader-file-size">0 <?php echo _AT('kb'); ?></td>
209 <td class="fl-uploader-file-actions">
210 <button type="button" class="flc-uploader-file-action fl-uploader-file-action" title="<?php echo _AT('remove_queued_file'); ?>" tabindex="-1">
211 <span class="fl-uploader-button-text fl-uploader-hidden"><?php echo _AT('remove_queued_file'); ?></span>
216 <!-- Template for the file error info rows -->
217 <tr class="flc-uploader-file-error-tmplt fl-uploader-file-error fl-uploader-hidden-templates">
218 <td colspan="3" class="flc-uploader-file-error"></td>
222 <div class="flc-uploader-file-progressor-tmplt fl-uploader-file-progress"><span class="fl-uploader-file-progress-text fl-uploader-hidden">76%</span></div>
226 <div class="flc-uploader-browse-instructions fl-uploader-browse-instructions"> <?php echo _AT('click_browse_files'); ?> </div>
228 <div class="flc-uploader-queue-footer fl-uploader-queue-footer">
229 <table cellspacing="0" cellpadding="0">
231 <td class="flc-uploader-total-progress-text"><?php echo _AT('total'); ?>: <span class="fluid-uploader-totalFiles">0</span> <?php echo _AT('files'); ?> (<span class="fluid-uploader-totalBytes">0 <?php echo _AT('kb'); ?></span>)</td>
232 <td class="fl-uploader-footer-buttons" align="right" ><a class="flc-uploader-button-browse fl-uploader-browse" tabindex="0" ><?php echo _AT('browse_files'); ?></a></td>
235 <div class="flc-uploader-total-progress fl-uploader-total-progress-okay"> </div>
239 <div class="fl-uploader-btns">
240 <button type="button" class="flc-uploader-button-pause fl-uploader-pause fl-uploader-hidden" onclick="toggleform('uploader', 'uploader_link');"><?php echo _AT('cancel'); ?></button>
241 <button type="button" class="flc-uploader-button-upload fl-uploader-upload fl-uploader-button-default fl-uploader-dim" ><?php echo _AT('upload'); ?></button>
250 if (isset($_COOKIE["fluid_on"]) && $_COOKIE["fluid_on"]=="yes")
251 echo '<div id="simple-container" style="display: none;">';
253 echo '<div id="simple-container">';
255 // Display as regular if there's no Flash detected
256 echo '<div id="simple-container">'."\n";
259 // Simple single file uploader
260 echo '<form onsubmit="openWindow(\''.AT_BASE_HREF.'tools/prog.php\');" class="fl-ProgEnhance-basic" name="form1" method="post" action="mods/_core/file_manager/upload.php?popup='.$popup.SEP. 'framed='.$framed.SEP.'cp='.$_GET['cp'].SEP.'pid='.$_GET['pid'].SEP.'cid='.$cid.SEP.'a_type='.$a_type.'" enctype="multipart/form-data">';
261 echo '<input type="hidden" name="MAX_FILE_SIZE" value="'.$my_MaxFileSize.'" />';
262 echo '<label for="uploadedfile">'._AT('upload_files').'</label><br />'."\n";
263 echo '<input type="file" name="uploadedfile" id="uploadedfile" class="formfield" size="20" /> ';
264 echo '<input type="submit" name="submit" value="'._AT('upload').'" class="button" />';
265 echo '<input type="hidden" name="pathext" value="'.$pathext.'" /> ';
267 if ($popup == TRUE) {
268 echo '<input type="hidden" name="popup" value="1" />';
273 echo ' </div>'."\n".' </fieldset></div>';
276 echo ' </fieldset></div>'."\n";
277 $msg->printInfos('OVER_QUOTA');
281 // Directory and File listing
282 echo '<form name="checkform" action="'.$_SERVER['PHP_SELF'].'?'.(($pathext!='') ? 'pathext='.urlencode($pathext).SEP : '').'popup='.$popup .SEP. 'framed='.$framed.SEP.'cp='.$_GET['cp'].SEP.'pid='.$_GET['pid'].SEP.'cid='.$cid.SEP.'a_type='.$a_type.'" method="post">';
283 echo '<input type="hidden" name="pathext" value ="'.$pathext.'" />';
285 // display the section to use a remote URL as an alternative
288 <div class="input-form" style="min-height:10px">
289 <fieldset class="group_form" style="min-height: 0px;"><legend class="group_form"><?php echo _AT('use_url_as_alternative'); ?></legend>
291 <input name="remote_alternative" id="remote_alternative" value="http://" size="60" />
292 <input class="button" type="button" name="alternative" value="<?php echo _AT('use_as_alternative'); ?>" onclick="javascript: setURLAlternative();" />
298 <table class="data static" summary="" border="0" rules="groups" style="width: 90%">
306 <th scope="col"><input type="checkbox" name="checkall" onclick="Checkall(checkform);" id="selectall" title="<?php echo _AT('select_all'); ?>" /></th>
308 <th scope="col"><?php echo _AT('name'); ?></th>
309 <th scope="col"><?php echo _AT('date'); ?></th>
310 <th scope="col"><?php echo _AT('size'); ?></th>
315 <td colspan="5"><input type="submit" name="rename" value="<?php echo _AT('rename'); ?>" />
316 <input type="submit" name="delete" value="<?php echo _AT('delete'); ?>" />
317 <input type="submit" name="move" value="<?php echo _AT('move'); ?>" /></td>
321 <td colspan="4" align="right"><strong><?php echo _AT('directory_total'); ?>:</strong></td>
322 <td align="right"> <strong><?php echo get_human_size(dirsize($current_path.$pathext.$file.'/')); ?></strong> </td>
326 <td colspan="4" align="right"><strong><?php echo _AT('course_total'); ?>:</strong></td>
327 <td align="right"> <strong><?php echo get_human_size($course_total); ?></strong> </td>
330 <td colspan="4" align="right"><strong><?php echo _AT('course_available'); ?>:</strong></td>
331 <td align="right"><strong><?php
332 if ($my_MaxCourseSize == AT_COURSESIZE_UNLIMITED) {
333 echo _AT('unlimited');
334 } else if ($my_MaxCourseSize == AT_COURSESIZE_DEFAULT) {
335 echo get_human_size($MaxCourseSize-$course_total);
337 echo get_human_size($my_MaxCourseSize-$course_total);
338 } ?></strong> </td>
346 <td colspan="5"><a href="<?php echo $_SERVER['PHP_SELF'].'?back=1'.SEP.'pathext='.$pathext.SEP. 'popup=' . $popup .SEP. 'framed=' . $framed .SEP.'cp='.$_GET['cp'].SEP.'pid='.$_GET['pid'].SEP.'cid='.$cid.SEP.'a_type='.$a_type; ?>"><img src="images/arrowicon.gif" border="0" height="11" width="10" alt="" /> <?php echo _AT('back'); ?></a></td>
353 $dir=opendir($current_path);
355 // loop through folder to get files and directory listing
356 while (false !== ($file = readdir($dir)) ) {
358 // if the name is not a directory
359 if( ($file == '.') || ($file == '..') ) {
363 // get some info about the file
364 $filedata = stat($current_path.$pathext.$file);
365 $path_parts = pathinfo($file);
366 $ext = strtolower($path_parts['extension']);
370 // if it is a directory change the file name to a directory link
371 if(is_dir($current_path.$pathext.$file)) {
372 $size = dirsize($current_path.$pathext.$file.'/');
373 $totalBytes += $size;
374 $filename = '<a href="'.$_SERVER['PHP_SELF'].'?pathext='.urlencode($pathext.$file.'/'). SEP . 'popup=' . $popup . SEP . 'framed='. $framed . SEP.'cp='.$_GET['cp'].SEP.'pid='.$_GET['pid'].SEP.'cid='.$cid.SEP.'a_type='.$a_type.'">'.$file.'</a>';
375 $fileicon = ' ';
376 $fileicon .= '<img src="images/folder.gif" alt="'._AT('folder').':'.$file.'" height="18" width="20" class="img-size-fm1" />';
377 $fileicon .= ' ';
383 } else if ($ext == 'zip') {
385 $totalBytes += $filedata[7];
387 $fileicon = ' <img src="images/icon-zip.gif" alt="'._AT('zip_archive').':'.$file.'" height="16" width="16" border="0" class="img-size-fm2" /> ';
390 $totalBytes += $filedata[7];
392 $fileicon = ' <img src="images/file_types/'.get_file_type_icon($filename).'.gif" height="16" width="16" alt="" title="" class="img-size-fm2" /> ';
394 $file1 = strtolower($file);
395 // create listing for dirctor or file
398 $dirs[$file1] .= '<tr><td align="center" width="0%">';
399 $dirs[$file1] .= '<input type="checkbox" id="'.$file.'" value="'.$file.'" name="check[]"/></td>';
400 $dirs[$file1] .= '<td align="center"><label for="'.$file.'" >'.$fileicon.'</label></td>';
401 $dirs[$file1] .= '<td > ';
402 $dirs[$file1] .= $filename.'</td>';
403 $dirs[$file1] .= '<td align="right"> ';
404 $dirs[$file1] .= AT_date(_AT('filemanager_date_format'), $filedata[10], AT_DATE_UNIX_TIMESTAMP);
405 $dirs[$file1] .= ' </td>';
406 $dirs[$file1] .= '<td align="right">';
407 $dirs[$file1] .= get_human_size($size).'</td></tr>';
411 $files[$file1] .= '<tr> <td align="center">';
412 $files[$file1] .= '<input type="checkbox" id="'.$file.'" value="'.$file.'" name="check[]"/> </td>';
413 $files[$file1] .= '<td align="center"><label for="'.$file.'">'.$fileicon.'</label></td>';
414 $files[$file1] .= '<td > ';
417 $files[$file1] .= '<a href="'.$get_file.$pathext.urlencode($filename).'">'.$filename.'</a>';
419 $files[$file1] .= '<a href="mods/_core/file_manager/preview.php?file='.$pathext.$filename.SEP.'pathext='.urlencode($pathext).SEP.'popup='.$popup.'">'.$filename.'</a>';
423 $files[$file1] .= ' <a href="mods/_core/file_manager/zip.php?'.(($pathext!='') ? 'pathext='.urlencode($pathext).SEP : ''). 'file=' . urlencode($file) . SEP . 'popup=' . $popup . SEP . 'framed=' . $framed .'">';
424 $files[$file1] .= '<img src="images/archive.gif" border="0" alt="'._AT('extract_archive').'" title="'._AT('extract_archive').'"height="16" width="11" class="img-size-fm3" />';
425 $files[$file1] .= '</a>';
428 if (in_array($ext, $editable_file_types)) {
429 $files[$file1] .= ' <a href="mods/_core/file_manager/edit.php?'.(($pathext!='') ? 'pathext='.urlencode($pathext).SEP : ''). 'popup=' . $popup . SEP . 'framed=' . $framed . SEP . 'file=' . $file . '">';
430 $files[$file1] .= '<img src="images/edit.gif" border="0" alt="'._AT('extract_archive').'" title="'._AT('edit').'" height="15" width="18" class="img-size-fm4" />';
431 $files[$file1] .= '</a>';
434 $files[$file1] .= ' </td>';
436 $files[$file1] .= '<td align="right" style="white-space:nowrap">';
438 if ($popup == TRUE) {
439 if ($a_type > 0) // define content alternative
441 $files[$file1] .= '<input class="button" type="button" name="alternative" value="' ._AT('use_as_alternative') . '" onclick="javascript: setAlternative(\''.get_relative_path($_GET['cp'], $pathext).$file.'\', \''.AT_BASE_HREF.$get_file.$pathext.urlencode($file).'\', \''.$cid.'\', \''.$pid.'\', \''.$a_type.'\');" /> ';
444 $files[$file1] .= '<input class="button" type="button" name="insert" value="' ._AT('insert') . '" onclick="javascript:insertFile(\'' . $file . '\', \'' . get_relative_path($_GET['cp'], $pathext) . '\', \'' . $ext . '\', \'' .$_SESSION['prefs']['PREF_CONTENT_EDITOR']. '\');" /> ';
447 $files[$file1] .= AT_date(_AT('filemanager_date_format'), $filedata[10], AT_DATE_UNIX_TIMESTAMP);
448 $files[$file1] .= ' </td>';
450 $files[$file1] .= '<td align="right" style="white-space:nowrap">';
451 $files[$file1] .= get_human_size($filedata[7]).'</td></tr>';
455 // sort listing and output directories
456 if (is_array($dirs)) {
457 ksort($dirs, SORT_STRING);
458 foreach($dirs as $x => $y) {
463 //sort listing and output files
464 if (is_array($files)) {
465 ksort($files, SORT_STRING);
466 foreach($files as $x => $y) {
472 echo '</table></form>';
478 <script type="text/javascript">
480 function insertFile(fileName, pathTo, ext, ed_pref) {
481 // pathTo + fileName should be relative to current path (specified by the Content Package Path)
483 if (ext == "gif" || ext == "jpg" || ext == "jpeg" || ext == "png") {
484 var info = "<?php echo _AT('alternate_text'); ?>";
485 var html = '<img src="' + pathTo+fileName + '" border="0" alt="' + info + '" />';
487 insertLink(html, ed_pref);
488 } else if (ext == "mpg" || ext == "avi" || ext == "wmv" || ext == "mov" || ext == "swf" || ext == "mp3" || ext == "wav" || ext == "ogg" || ext == "mid" ||ext == "flv"|| ext == "mp4") {
489 var html = '[media]'+ pathTo + fileName + '[/media]';
491 insertLink(html, ed_pref);
493 var info = "<?php echo _AT('put_link'); ?>";
494 var html = '<a href="' + pathTo+fileName + '">' + info + '</a>';
496 insertLink(html, ed_pref);
500 function insertLink(html, ed_pref)
503 var isNotVisual = (jQuery('#html:checked').val() !== null) && (ed_pref === '1');
506 if (!window.opener || !isNotVisual) {
507 if (!window.opener && window.parent.tinyMCE)
508 window.parent.tinyMCE.execCommand('mceInsertContent', false, html);
510 if (window.opener && window.opener.tinyMCE)
511 window.opener.tinyMCE.execCommand('mceInsertContent', false, html);
513 insertAtCursor(window.opener.document.form.body_text, html);
517 function insertAtCursor(myField, myValue) {
519 if (window.opener.document.selection) {
521 sel = window.opener.document.selection.createRange();
524 //MOZILLA/NETSCAPE support
525 else if (myField.selectionStart || myField.selectionStart == '0') {
526 var startPos = myField.selectionStart;
527 var endPos = myField.selectionEnd;
528 myField.value = myField.value.substring(0, startPos)
530 + myField.value.substring(endPos, myField.value.length);
533 myField.value += myValue;
538 // This function does:
539 // 1. save into db via ajax
540 // 2. set the according field in opener window to the selected file
541 // 3. close file manager itself
542 function setAlternative(file, file_preview_link, cid, pid, a_type) {
543 jQuery.post("<?php echo AT_BASE_HREF; ?>mods/_core/editor/save_alternative.php",
544 {"pid":pid, "a_type":a_type, "alternative":file},
548 <a href="'+file_preview_link+'" title="<?php echo _AT('new_window'); ?>" target="_new">'+file+'</a><br /> \
549 <a href="#" onclick="ATutor.poptastic(\\\'<?php echo AT_BASE_HREF; ?>mods/_core/file_manager/index.php?framed=1<?php echo SEP; ?>popup=1<?php echo SEP; ?>cp=<?php echo $cp.SEP; ?>cid='+cid+'<?php echo SEP; ?>pid='+pid+'<?php echo SEP; ?>a_type='+a_type+'\\\');return false;" title="<?php echo _AT('new_window'); ?>"> \
550 <img src="<?php echo AT_BASE_HREF; ?>images/home-tests_sm.png" border="0" title="<?php echo _AT('alter'); ?>" alt="<?php echo _AT('alter'); ?>" /> \
552 <a href="#" onclick="removeAlternative(\\\'<?php echo $cp; ?>\\\', '+cid+','+pid+','+a_type+');return false;"> \
553 <img src="<?php echo AT_BASE_HREF; ?>images/icon_delete.gif" border="0" title="<?php echo _AT('remove'); ?>" alt="<?php echo _AT('remove'); ?>" /> \
557 eval("window.opener.document.getElementById(\""+pid+"_"+a_type+"\").innerHTML = '"+link_html+"'");
562 // This function validates the url then call setAlternative()
563 function setURLAlternative() {
564 remote_url = jQuery('#remote_alternative').val();
565 if (remote_url == '' || remote_url == 'http://') {
566 alert("<?php echo _AT('empty_url'); ?>");
569 setAlternative(remote_url, remote_url, '<?php echo $cid; ?>.', '<?php echo $pid; ?>', '<?php echo $a_type; ?>');
572 <?php if (isset($_SESSION['flash']) && $_SESSION['flash'] == "yes") { ?>
573 // toggle the view between div object and button
574 function toggleform(id, link) {
575 var obj = document.getElementById(id);
576 var btn = document.getElementById(link);
578 if (obj.style.display == "none") {
580 obj.style.display='';
583 btn.style.display = 'none';
588 obj.style.display='none';
589 btn.style.display = '';
594 function setCheckboxCookie(obj, value1, value2, date)
596 var today = new Date();
597 var the_date = new Date(date);
598 var the_cookie_date = the_date.toGMTString();
599 if (obj.checked==true)
600 var the_cookie = value1 + ";expires=" + the_cookie_date;
602 var the_cookie = value2 + ";expires=" + the_cookie_date;
603 document.cookie = the_cookie;
608 // When uploading a file as an alternative content, set the alternative field in the opener window
609 // and close "file manager" once the upload is successful
610 if ($a_type > 0 && isset($_GET['uploadfile']) && $_GET['uploadfile'] <> '') { ?>
611 function setAlternativeAndClose() {
612 setAlternative('<?php echo get_relative_path($_GET['cp'], $pathext).$_GET['uploadfile']; ?>', '<?php echo AT_BASE_HREF.$get_file.$pathext.urlencode($_GET['uploadfile']); ?>', '<?php echo $cid; ?>', '<?php echo $pid; ?>', '<?php echo $a_type; ?>');
616 window.onload=setAlternativeAndClose;