2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2010 */
6 /* Inclusive Design Institute */
8 /* This program is free software. You can redistribute it and/or */
9 /* modify it under the terms of the GNU General Public License */
10 /* as published by the Free Software Foundation. */
11 /************************************************************************/
13 if (!defined('TR_INCLUDE_PATH')) { exit; }
14 require_once(TR_INCLUDE_PATH.'classes/DAO/CoursesDAO.class.php');
16 global $_course_id, $MaxCourseSize, $_content_id;
18 $editable_file_types = array('txt', 'html', 'htm', 'xml', 'css', 'asc', 'csv', 'sql');
19 $_SESSION['prefs']['PREF_CONTENT_EDITOR'] = 1;
21 $coursesDAO = new CoursesDAO();
23 function get_file_extension($file_name) {
24 $ext = pathinfo($file_name);
25 return $ext['extension'];
28 function get_file_type_icon($file_name) {
31 $ext = get_file_extension($file_name);
34 require(TR_INCLUDE_PATH .'lib/mime.inc.php');
37 if (isset($mime[$ext]) && $mime[$ext][1]) {
38 return $mime[$ext][1];
43 function get_relative_path($src, $dest) {
46 } else if (substr($dest, 0, strlen($src)) == $src) {
47 $path = substr($dest, strlen($src) + 1);
49 $depth = substr_count($src, '/');
50 for ($i = 0; $i < $depth + 1; $i++) // $depth+1 because the last '/' is not recorded in content.content_path
58 // get the course total in Bytes
59 $course_total = FileUtility::dirsize($current_path);
61 $framed = intval($_GET['framed']);
62 $popup = intval($_GET['popup']);
64 $cid = $_content_id; // content id, used at "adapted content" page, => add/edit alternatives
65 $pid = intval($_GET['pid']); // primary resource id, used at "adapted content" page, => add/edit alternatives
66 $a_type = intval($_GET['a_type']); // alternative_type, used at "adapted content" page, => add/edit alternatives
68 if (defined('TR_FORCE_GET_FILE') && TR_FORCE_GET_FILE) {
69 $get_file = 'get.php/';
71 $get_file = 'content/' . $_course_id . '/';
75 global $pathext, $framed, $popup, $cp, $cid, $pid, $a_type, $_course_id;
76 echo '<p>'._AT('current_path').' ';
78 if (isset($pathext) && $pathext != '') {
79 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.SEP.'_course_id='.$_course_id.'">'._AT('home').'</a> ';
87 if ($pathext == '' && isset($_POST['pathext'])) {
89 $pathext = urlencode($_POST['pathext']);
93 $bits = explode('/', $pathext);
95 foreach ($bits as $bit) {
97 $bit_path .= $bit . '/';
100 if ($bit_path == $pathext) {
103 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.SEP.'_course_id='.$_course_id.'">' . $bit . '</a>';
114 if ($popup == TRUE) {
121 if (TRUE || $framed != TRUE) {
123 if ($_GET['overwrite'] != '') {
124 // get file name, out of the full path
125 $path_parts = pathinfo($current_path.$_GET['overwrite']);
127 if (!file_exists($path_parts['dirname'].'/'.$pathext.$path_parts['basename'])
128 || !file_exists($path_parts['dirname'].'/'.$pathext.substr($path_parts['basename'], 5))) {
129 /* source and/or destination does not exist */
130 $msg->addErrors('CANNOT_OVERWRITE_FILE');
132 @unlink($path_parts['dirname'].'/'.$pathext.substr($path_parts['basename'], 5));
133 $result = @rename($path_parts['dirname'].'/'.$pathext.$path_parts['basename'], $path_parts['dirname'].'/'.$pathext.substr($path_parts['basename'], 5));
136 $msg->addFeedback('FILE_OVERWRITE');
138 $msg->addErrors('CANNOT_OVERWRITE_FILE');
143 // filemanager listing table
144 // make new directory
145 echo '<div class="input-form"><fieldset class="group_form"><legend class="group_form">'._AT('add_file_folder').'</legend>'."\n";
146 echo ' <div class="row">'."\n";
147 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.SEP.'_course_id='.$_course_id.'">'."\n";
149 if ($depth < $MaxDirDepth) {
150 echo ' <label for="dirname">'._AT('create_folder_here').'</label><br />'."\n";
151 echo ' <small class="spacer">'._AT('keep_it_short').'</small><br />'."\n";
152 echo ' <input type="text" name="dirname" id="dirname" size="20" /> '."\n";
153 echo ' <input type="hidden" name="mkdir_value" value="true" /> '."\n";
154 echo ' <input type="hidden" name="_course_id" value="'.$_course_id.'" /> '."\n";
155 if ($cid > 0) echo ' <input type="hidden" name="_cid" value="'.$cid.'" /> '."\n";
156 echo ' <input type="submit" name="mkdir" value="'._AT('create_folder').'" class="button" />'."\n";
158 echo _AT('depth_reached')."\n";
161 echo ' <input type="hidden" name="pathext" value="'.$pathext.'" />'."\n";
162 echo ' </form>'."\n";
165 echo ' <div class="row"><hr /></div>'."\n";
168 // If flash is available, provide the option of using Fluid's uploader or the basic uploader
169 if (isset($_SESSION['flash']) && $_SESSION['flash'] == "yes") {
170 echo '<div class="row">'."\n";
171 if (isset($_COOKIE["fluid_on"]) && $_COOKIE["fluid_on"]=="yes")
172 $fluid_on = 'checked="checked"';
173 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";
174 echo '<label for="fluid_on" >'._AT('enable_uploader').'</label>)'."\n";
180 echo ' <div class="row" style="float: left;"><input type="button" class="button" name="new_file" value="' . _AT('file_manager_new') . '" onclick="window.location.href=\''.TR_BASE_HREF.'file_manager/new.php?pathext=' . urlencode($pathext) . SEP . 'framed=' . $framed . SEP . 'popup=' . $popup . SEP.'_course_id='.$_course_id. '\'"/></div>'."\n";
182 $course_row = $coursesDAO->get($_course_id);
183 if ($course_row['max_quota'] == '' || is_null($course_row['max_quota']))
184 $my_MaxCourseSize = $MaxCourseSize;
187 if ($course_row['max_quota'] == TR_COURSESIZE_UNLIMITED || $my_MaxCourseSize-$course_total > 0) {
188 echo ' <div class="row" style="float: left;">'._AT('OR').'</div>'."\n".' <div class="row" style="float: left;">'."\n";
189 if (isset($_SESSION['flash']) && $_SESSION['flash'] == "yes") {
191 <div id="fluid-container" <?php echo (isset($_COOKIE["fluid_on"]) && $_COOKIE["fluid_on"]=="yes") ? '' : 'style="display:none;"'; ?>>
192 <input type="button" id="uploader_link" class="button" name="upload_file" value="<?php echo _AT('upload_files'); ?>" onclick="toggleform('uploader', 'uploader_link');" />
193 <div id="uploader" style="display: none;">
194 <form id="flc-uploader" class="flc-uploader fl-uploader fl-progEnhance-enhanced" method="get" enctype="multipart/form-data" action="" style="margin: 0px; padding: 0px;">
196 <div class="fl-uploader-queue-wrapper">
197 <div class="fl-uploader-queue-header">
198 <table cellspacing="0" cellpadding="0">
200 <th scope="col" class="fileName"><?php echo _AT('file_name'); ?></th>
201 <th scope="col" class="fileSize"><?php echo _AT('size'); ?> </th>
202 <th scope="col" class="fileRemove"> </th>
207 <div class="flc-scroller fl-scroller">
208 <div class="fl-scroller-inner">
209 <table cellspacing="0" class="flc-uploader-queue fl-uploader-queue" summary="Queue of files to upload.">
211 <!-- Rows will be rendered in here. -->
213 <!-- Template markup for the file queue rows -->
214 <tr class="flc-uploader-file-tmplt flc-uploader-file fl-uploader-hidden-templates">
215 <th class="flc-uploader-file-name fl-uploader-file-name" scope="row"><?php echo _AT('file_placeholder'); ?></th>
216 <td class="flc-uploader-file-size fl-uploader-file-size">0 <?php echo _AT('kb'); ?></td>
217 <td class="fl-uploader-file-actions">
218 <button type="button" class="flc-uploader-file-action fl-uploader-file-action" title="<?php echo _AT('remove_queued_file'); ?>" tabindex="-1">
219 <span class="fl-uploader-button-text fl-uploader-hidden"><?php echo _AT('remove_queued_file'); ?></span>
224 <!-- Template for the file error info rows -->
225 <tr class="flc-uploader-file-error-tmplt fl-uploader-file-error fl-uploader-hidden-templates">
226 <td colspan="3" class="flc-uploader-file-error"></td>
230 <div class="flc-uploader-file-progressor-tmplt fl-uploader-file-progress"><span class="fl-uploader-file-progress-text fl-uploader-hidden">76%</span></div>
234 <div class="flc-uploader-browse-instructions fl-uploader-browse-instructions"> <?php echo _AT('click_browse_files'); ?> </div>
236 <div class="flc-uploader-queue-footer fl-uploader-queue-footer">
237 <table cellspacing="0" cellpadding="0">
239 <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>
240 <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>
243 <div class="flc-uploader-total-progress fl-uploader-total-progress-okay"> </div>
247 <div class="fl-uploader-btns">
248 <button type="button" class="flc-uploader-button-pause fl-uploader-pause fl-uploader-hidden" onclick="toggleform('uploader', 'uploader_link');"><?php echo _AT('cancel'); ?></button>
249 <button type="button" class="flc-uploader-button-upload fl-uploader-upload fl-uploader-button-default fl-uploader-dim" ><?php echo _AT('upload'); ?></button>
258 if (isset($_COOKIE["fluid_on"]) && $_COOKIE["fluid_on"]=="yes")
259 echo '<div id="simple-container" style="display: none;">';
261 echo '<div id="simple-container">';
263 // Display as regular if there's no Flash detected
264 echo '<div id="simple-container">'."\n";
267 // Simple single file uploader
268 echo '<form onsubmit="openWindow(\''.TR_BASE_HREF.'home/prog.php\');" class="fl-ProgEnhance-basic" name="form1" method="post" action="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.SEP.'_course_id='.$_course_id.'" enctype="multipart/form-data">';
269 echo '<input type="hidden" name="MAX_FILE_SIZE" value="'.$my_MaxFileSize.'" />';
270 echo '<label for="uploadedfile">'._AT('upload_files').'</label>'."\n";
271 echo '<input type="file" name="uploadedfile" id="uploadedfile" class="formfield" size="20" /> ';
272 echo '<input type="submit" name="submit" value="'._AT('upload').'" class="button" />';
273 echo '<input type="hidden" name="pathext" value="'.$pathext.'" /> ';
275 if ($popup == TRUE) {
276 echo '<input type="hidden" name="popup" value="1" />';
281 echo ' </div>'."\n".' </fieldset></div>';
284 echo ' </fieldset></div>'."\n";
285 $msg->printInfos('OVER_QUOTA');
289 // Directory and File listing
290 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">';
291 echo '<input type="hidden" name="pathext" value ="'.$pathext.'" />';
292 echo '<input type="hidden" name="_course_id" value ="'.$_course_id.'" />';
293 if ($cid > 0) echo '<input type="hidden" name="_cid" value ="'.$cid.'" />';
295 // display the section to use a remote URL as an alternative
298 <div class="input-form" style="min-height:10px">
299 <fieldset class="group_form" style="min-height: 0px;"><legend class="group_form"><?php echo _AT('use_url_as_alternative'); ?></legend>
301 <input name="remote_alternative" id="remote_alternative" value="http://" size="60" />
302 <input class="button" type="button" name="alternative" value="<?php echo _AT('use_as_alternative'); ?>" onclick="javascript: setURLAlternative();" />
308 <table class="data static" summary="" border="0" rules="groups" style="width: 90%">
316 <th scope="col"><input type="checkbox" name="checkall" onclick="Checkall(checkform);" id="selectall" title="<?php echo _AT('select_all'); ?>" /></th>
318 <th scope="col"><?php echo _AT('name'); ?></th>
319 <th scope="col"><?php echo _AT('date'); ?></th>
320 <th scope="col"><?php echo _AT('size'); ?></th>
325 <td colspan="5"><input type="submit" name="rename" value="<?php echo _AT('rename'); ?>" />
326 <input type="submit" name="delete" value="<?php echo _AT('delete'); ?>" />
327 <input type="submit" name="move" value="<?php echo _AT('move'); ?>" /></td>
331 <td colspan="4" align="right"><strong><?php echo _AT('directory_total'); ?>:</strong></td>
332 <td align="right"> <strong><?php echo FileUtility::get_human_size(FileUtility::dirsize($current_path.$pathext.$file.'/')); ?></strong> </td>
336 <td colspan="4" align="right"><strong><?php echo _AT('course_total'); ?>:</strong></td>
337 <td align="right"> <strong><?php echo FileUtility::get_human_size($course_total); ?></strong> </td>
340 <td colspan="4" align="right"><strong><?php echo _AT('course_available'); ?>:</strong></td>
341 <td align="right"><strong><?php
342 if ($my_MaxCourseSize == TR_COURSESIZE_UNLIMITED) {
343 echo _AT('unlimited');
344 } else if ($my_MaxCourseSize == TR_COURSESIZE_DEFAULT) {
345 echo FileUtility::get_human_size($MaxCourseSize-$course_total);
347 echo FileUtility::get_human_size($my_MaxCourseSize-$course_total);
348 } ?></strong> </td>
356 <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.SEP.'_course_id='.$_course_id; ?>"><img src="images/arrowicon.gif" border="0" height="11" width="10" alt="" /> <?php echo _AT('back'); ?></a></td>
363 $dir=opendir($current_path);
365 // loop through folder to get files and directory listing
366 while (false !== ($file = readdir($dir)) ) {
368 // if the name is not a directory
369 if( ($file == '.') || ($file == '..') ) {
373 // get some info about the file
374 $filedata = stat($current_path.$pathext.$file);
375 $path_parts = pathinfo($file);
376 $ext = strtolower($path_parts['extension']);
380 // if it is a directory change the file name to a directory link
381 if(is_dir($current_path.$pathext.$file)) {
382 $size = FileUtility::dirsize($current_path.$pathext.$file.'/');
383 $totalBytes += $size;
384 $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.SEP.'_course_id='.$_course_id.'">'.$file.'</a>';
385 $fileicon = ' ';
386 $fileicon .= '<img src="images/folder.gif" alt="'._AT('folder').':'.$file.'" height="18" width="20" class="img-size-fm1" />';
387 $fileicon .= ' ';
393 } else if ($ext == 'zip') {
395 $totalBytes += $filedata[7];
397 $fileicon = ' <img src="images/icon-zip.gif" alt="'._AT('zip_archive').':'.$file.'" height="16" width="16" border="0" class="img-size-fm2" /> ';
400 $totalBytes += $filedata[7];
402 $fileicon = ' <img src="images/file_types/'.get_file_type_icon($filename).'.gif" height="16" width="16" alt="" title="" class="img-size-fm2" /> ';
404 $file1 = strtolower($file);
405 // create listing for dirctor or file
408 $dirs[$file1] .= '<tr><td align="center" width="0%">';
409 $dirs[$file1] .= '<input type="checkbox" id="'.$file.'" value="'.$file.'" name="check[]"/></td>';
410 $dirs[$file1] .= '<td align="center"><label for="'.$file.'" >'.$fileicon.'</label></td>';
411 $dirs[$file1] .= '<td > ';
412 $dirs[$file1] .= $filename.'</td>';
413 $dirs[$file1] .= '<td align="right"> ';
414 $dirs[$file1] .= AT_date(_AT('filemanager_date_format'), $filedata[10], TR_DATE_UNIX_TIMESTAMP);
415 $dirs[$file1] .= ' </td>';
416 $dirs[$file1] .= '<td align="right">';
417 $dirs[$file1] .= FileUtility::get_human_size($size).'</td></tr>';
421 $files[$file1] .= '<tr> <td align="center">';
422 $files[$file1] .= '<input type="checkbox" id="'.$file.'" value="'.$file.'" name="check[]"/> </td>';
423 $files[$file1] .= '<td align="center"><label for="'.$file.'">'.$fileicon.'</label></td>';
424 $files[$file1] .= '<td > ';
427 $files[$file1] .= '<a href="'.$get_file.$pathext.urlencode($filename).'">'.$filename.'</a>';
429 $files[$file1] .= '<a href="file_manager/preview.php?file='.$pathext.$filename.SEP.'pathext='.urlencode($pathext).SEP.'popup='.$popup.SEP.'_course_id='.$_course_id.'">'.$filename.'</a>';
433 $files[$file1] .= ' <a href="file_manager/zip.php?'.(($pathext!='') ? 'pathext='.urlencode($pathext).SEP : ''). 'file=' . urlencode($file) . SEP . 'popup=' . $popup . SEP . 'framed=' . $framed .SEP.'_course_id='.$_course_id.'">';
434 $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" />';
435 $files[$file1] .= '</a>';
438 if (in_array($ext, $editable_file_types)) {
439 $files[$file1] .= ' <a href="file_manager/edit.php?'.(($pathext!='') ? 'pathext='.urlencode($pathext).SEP : ''). 'popup=' . $popup . SEP . 'framed=' . $framed . SEP.'_course_id='.$_course_id. SEP . 'file=' . urlencode($file) . '">';
440 $files[$file1] .= '<img src="images/edit.gif" border="0" alt="'._AT('edit').'" title="'._AT('edit').'" height="15" width="18" class="img-size-fm4" />';
441 $files[$file1] .= '</a>';
444 $files[$file1] .= ' </td>';
446 $files[$file1] .= '<td align="right" style="white-space:nowrap">';
448 if ($popup == TRUE) {
449 if ($a_type > 0) // define content alternative
451 $files[$file1] .= '<input class="button" type="button" name="alternative" value="' ._AT('use_as_alternative') . '" onclick="javascript: setAlternative(\''.get_relative_path($_GET['cp'], $pathext).$file.'\', \''.TR_BASE_HREF.$get_file.$pathext.urlencode($file).'\', \''.$cid.'\', \''.$pid.'\', \''.$a_type.'\');" /> ';
454 $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']. '\');" /> ';
457 $files[$file1] .= AT_date(_AT('filemanager_date_format'), $filedata[10], TR_DATE_UNIX_TIMESTAMP);
458 $files[$file1] .= ' </td>';
460 $files[$file1] .= '<td align="right" style="white-space:nowrap">';
461 $files[$file1] .= FileUtility::get_human_size($filedata[7]).'</td></tr>';
465 // sort listing and output directories
466 if (is_array($dirs)) {
467 ksort($dirs, SORT_STRING);
468 foreach($dirs as $x => $y) {
473 //sort listing and output files
474 if (is_array($files)) {
475 ksort($files, SORT_STRING);
476 foreach($files as $x => $y) {
481 echo '</table></form>';
484 <script type="text/javascript">
486 function insertFile(fileName, pathTo, ext, ed_pref) {
487 // pathTo + fileName should be relative to current path (specified by the Content Package Path)
488 if (ext == "gif" || ext == "jpg" || ext == "jpeg" || ext == "png") {
489 var info = "<?php echo _AT('alternate_text'); ?>";
490 var html = '<img src="' + pathTo+fileName + '" border="0" alt="' + info + '" />';
491 } else if (ext == "mpg" || ext == "avi" || ext == "wmv" || ext == "mov" || ext == "swf" || ext == "mp3" || ext == "wav" || ext == "ogg" || ext == "mid" ||ext == "flv"|| ext == "mp4") {
492 var html = '[media]'+ pathTo + fileName + '[/media]';
494 var info = "<?php echo _AT('put_link'); ?>";
495 var html = '<a href="' + pathTo+fileName + '">' + info + '</a>';
498 // insertLink(html, ed_pref);
501 //function insertLink(html, ed_pref)
502 function insertLink(html)
504 // if (window.opener) {
505 // var isNotVisual = window.opener.document.form.html.checked;
508 if (!window.opener || $('#html:checked').val() !== null) {
509 if (!window.opener && window.parent.tinyMCE)
510 window.parent.tinyMCE.execCommand('mceInsertContent', false, html);
512 if (window.opener && window.opener.tinyMCE)
513 window.opener.tinyMCE.execCommand('mceInsertContent', false, html);
515 insertAtCursor(window.opener.document.form.body_text, html);
519 function insertAtCursor(myField, myValue) {
521 if (window.opener.document.selection) {
523 sel = window.opener.document.selection.createRange();
526 //MOZILLA/NETSCAPE support
527 else if (myField.selectionStart || myField.selectionStart == '0') {
528 var startPos = myField.selectionStart;
529 var endPos = myField.selectionEnd;
530 myField.value = myField.value.substring(0, startPos)
532 + myField.value.substring(endPos, myField.value.length);
535 myField.value += myValue;
540 // This function does:
541 // 1. save into db via ajax
542 // 2. set the according field in opener window to the selected file
543 // 3. close file manager itself
544 function setAlternative(file, file_preview_link, cid, pid, a_type) {
545 jQuery.post("<?php echo TR_BASE_HREF; ?>home/editor/save_alternative.php",
546 {"pid":pid, "a_type":a_type, "alternative":file},
550 <a href="'+file_preview_link+'" title="<?php echo _AT('new_window'); ?>" target="_new">'+file+'</a><br /> \
551 <a href="#" onclick="trans.utility.poptastic(\\\'<?php echo TR_BASE_HREF; ?>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'); ?>"> \
552 <img src="<?php echo TR_BASE_HREF; ?>images/alter.png" border="0" title="<?php echo _AT('alter'); ?>" alt="<?php echo _AT('alter'); ?>" /> \
554 <a href="#" onclick="removeAlternative(\\\'<?php echo $cp; ?>\\\', '+cid+','+pid+','+a_type+');return false;"> \
555 <img src="<?php echo TR_BASE_HREF; ?>images/remove.gif" border="0" title="<?php echo _AT('remove'); ?>" alt="<?php echo _AT('remove'); ?>" /> \
559 eval("window.opener.document.getElementById(\""+pid+"_"+a_type+"\").innerHTML = '"+link_html+"'");
564 // This function validates the url then call setAlternative()
565 function setURLAlternative() {
566 remote_url = jQuery('#remote_alternative').val();
567 if (remote_url == '' || remote_url == 'http://') {
568 alert("<?php echo _AT('empty_url'); ?>");
571 setAlternative(remote_url, remote_url, '<?php echo $cid; ?>.', '<?php echo $pid; ?>', '<?php echo $a_type; ?>');
574 <?php if (isset($_SESSION['flash']) && $_SESSION['flash'] == "yes") { ?>
575 // toggle the view between div object and button
576 function toggleform(id, link) {
577 var obj = document.getElementById(id);
578 var btn = document.getElementById(link);
580 if (obj.style.display == "none") {
582 obj.style.display='';
585 btn.style.display = 'none';
590 obj.style.display='none';
591 btn.style.display = '';
596 function setCheckboxCookie(obj, value1, value2, date)
598 var today = new Date();
599 var the_date = new Date(date);
600 var the_cookie_date = the_date.toGMTString();
601 if (obj.checked==true)
602 var the_cookie = value1 + ";expires=" + the_cookie_date;
604 var the_cookie = value2 + ";expires=" + the_cookie_date;
605 document.cookie = the_cookie;
610 // When uploading a file as an alternative content, set the alternative field in the opener window
611 // and close "file manager" once the upload is successful
612 if ($a_type > 0 && isset($_GET['uploadfile']) && $_GET['uploadfile'] <> '') { ?>
613 function setAlternativeAndClose() {
614 setAlternative('<?php echo get_relative_path($_GET['cp'], $pathext).$_GET['uploadfile']; ?>', '<?php echo TR_BASE_HREF.$get_file.$pathext.urlencode($_GET['uploadfile']); ?>', '<?php echo $_content_id; ?>', '<?php echo $pid; ?>', '<?php echo $a_type; ?>');
618 window.onload=setAlternativeAndClose;