first check-in of the complete content editor
authorCindy Li <cli@ocad.ca>
Fri, 28 May 2010 19:55:14 +0000 (19:55 -0000)
committerCindy Li <cli@ocad.ca>
Fri, 28 May 2010 19:55:14 +0000 (19:55 -0000)
18 files changed:
docs/file_manager/filemanager_display.inc.php
docs/home/classes/ContentUtility.class.php
docs/home/course/content.php
docs/home/editor/editor_tabs/alternatives.inc.php
docs/home/editor/remove_alternative.php
docs/home/editor/save_alternative.php
docs/images/alter.png [new file with mode: 0644]
docs/images/audio_alternative.png [new file with mode: 0644]
docs/images/pause.png [new file with mode: 0644]
docs/images/remove.gif [new file with mode: 0644]
docs/images/sign_lang_alternative.png [new file with mode: 0644]
docs/images/text_alternative.png [new file with mode: 0644]
docs/images/visual_alternative.png [new file with mode: 0644]
docs/include/lib/resources_parser.inc.php
docs/install/db/language_text_temp.sql
docs/themes/default/home/course/content.tmpl.php
docs/themes/default/include/header.tmpl.php
docs/themes/default/styles.css

index 7f2a790..1908b9a 100644 (file)
@@ -13,7 +13,8 @@
 if (!defined('TR_INCLUDE_PATH')) { exit; }
 require_once(TR_INCLUDE_PATH.'classes/DAO/CoursesDAO.class.php');
 
-global $_course_id, $MaxCourseSize;
+global $_course_id, $MaxCourseSize, $_content_id;
+
 $editable_file_types = array('txt', 'html', 'htm', 'xml', 'css', 'asc', 'csv', 'sql');
 $_SESSION['prefs']['PREF_CONTENT_EDITOR'] = 1;
 
@@ -60,7 +61,7 @@ $course_total = FileUtility::dirsize($current_path);
 $framed = intval($_GET['framed']);
 $popup = intval($_GET['popup']);
 $cp = $_GET['cp'];
-$cid = intval($_GET['cid']);        // content id, used at "adapted content" page, => add/edit alternatives
+$cid = $_content_id;        // content id, used at "adapted content" page, => add/edit alternatives
 $pid = intval($_GET['pid']);        // primary resource id, used at "adapted content" page, => add/edit alternatives
 $a_type = intval($_GET['a_type']);  // alternative_type, used at "adapted content" page, => add/edit alternatives
 
@@ -75,7 +76,7 @@ function fm_path(){
 echo '<p>'._AT('current_path').' ';
 
 if (isset($pathext) && $pathext != '') {
-       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> ';
+       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> ';
 }
 else {
        $pathext = '';
@@ -99,7 +100,7 @@ if ($pathext != '') {
                        if ($bit_path == $pathext) {
                                echo $bit;
                        } else {
-                               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>';
+                               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>';
                        }
                }
        }
@@ -143,7 +144,7 @@ if (TRUE || $framed != TRUE) {
        // make new directory 
        echo '<div class="input-form"><fieldset class="group_form"><legend class="group_form">'._AT('add_file_folder').'</legend>'."\n";
        echo '  <div class="row">'."\n";
-       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";
+       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";
        if( $MakeDirOn ) {
                if ($depth < $MaxDirDepth) {
                        echo '          <label for="dirname">'._AT('create_folder_here').'</label><br />'."\n";
@@ -151,6 +152,7 @@ if (TRUE || $framed != TRUE) {
                        echo '          <input type="text" name="dirname" id="dirname" size="20" /> '."\n";
                        echo '          <input type="hidden" name="mkdir_value" value="true" /> '."\n";
                        echo '          <input type="hidden" name="_course_id" value="'.$_course_id.'" /> '."\n";
+                       if ($cid > 0) echo '            <input type="hidden" name="_cid" value="'.$cid.'" /> '."\n";
                        echo '          <input type="submit" name="mkdir" value="'._AT('create_folder').'" class="button" />'."\n";
                } else {
                        echo _AT('depth_reached')."\n";
@@ -263,7 +265,7 @@ if (TRUE || $framed != TRUE) {
                }
 
                // Simple single file uploader
-               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">';
+               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">';
                echo '<input type="hidden" name="MAX_FILE_SIZE" value="'.$my_MaxFileSize.'" />';
                echo '<label for="uploadedfile">'._AT('upload_files').'</label>'."\n";
                echo '<input type="file" name="uploadedfile" id="uploadedfile" class="formfield" size="20" /> ';
@@ -286,9 +288,10 @@ if (TRUE || $framed != TRUE) {
 }
 
 // Directory and File listing 
-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">';
+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">';
 echo '<input type="hidden" name="pathext" value ="'.$pathext.'" />';
 echo '<input type="hidden" name="_course_id" value ="'.$_course_id.'" />';
+if ($cid > 0) echo '<input type="hidden" name="_cid" value ="'.$cid.'" />';
 ?>
 <table class="data static" summary="" border="0" rules="groups" style="width: 90%">
 <thead>
@@ -338,7 +341,7 @@ echo '<input type="hidden" name="_course_id" value ="'.$_course_id.'" />';
 
 if($pathext) : ?>
        <tr>
-               <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>
+               <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>
        </tr>
 <?php endif; ?>
 <?php
@@ -366,7 +369,7 @@ while (false !== ($file = readdir($dir)) ) {
        if(is_dir($current_path.$pathext.$file)) {
                $size = FileUtility::dirsize($current_path.$pathext.$file.'/');
                $totalBytes += $size;
-               $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>';
+               $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>';
                $fileicon = '&nbsp;';
                $fileicon .= '<img src="images/folder.gif" alt="'._AT('folder').':'.$file.'" height="18" width="20" class="img-size-fm1" />';
                $fileicon .= '&nbsp;';
@@ -473,7 +476,7 @@ function insertFile(fileName, pathTo, ext, ed_pref) {
        if (ext == "gif" || ext == "jpg" || ext == "jpeg" || ext == "png") {
                var info = "<?php echo _AT('alternate_text'); ?>";
                var html = '<img src="' + pathTo+fileName + '" border="0" alt="' + info + '" />';
-       } else if (ext == "mpg" || ext == "avi" || ext == "wmv" || ext == "mov" || ext == "swf" || ext == "mp3" || ext == "wav" || ext == "ogg" || ext == "mid") {
+       } else if (ext == "mpg" || ext == "avi" || ext == "wmv" || ext == "mov" || ext == "swf" || ext == "mp3" || ext == "wav" || ext == "ogg" || ext == "mid" ||ext == "flv"|| ext == "mp4") {
                var html = '[media]'+ pathTo + fileName + '[/media]';
        } else {
                var info = "<?php echo _AT('put_link'); ?>";
@@ -527,17 +530,17 @@ function insertAtCursor(myField, myValue) {
 // 2. set the according field in opener window to the selected file
 // 3. close file manager itself
 function setAlternative(file, file_preview_link, cid, pid, a_type) {
-       jQuery.post("<?php echo TR_BASE_HREF; ?>home/course/save_alternative.php", 
-                       {"pid":pid, "a_type":a_type, "alternative":file, "course_id":$_course_id}, 
+       jQuery.post("<?php echo TR_BASE_HREF; ?>home/editor/save_alternative.php", 
+                       {"pid":pid, "a_type":a_type, "alternative":file}, 
                        function(data) {});
 
        link_html = '\
       <a href="'+file_preview_link+'" title="<?php echo _AT('new_window'); ?>" target="_new">'+file+'</a><br /> \
-      <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+'<?php echo SEP; ?>_course_id=<?php echo $_course_id; ?>\\\');return false;" title="<?php echo _AT('new_window'); ?>"> \
-        <img src="<?php echo TR_BASE_HREF; ?>images/home-tests_sm.png" border="0" title="<?php echo _AT('alter'); ?>" alt="<?php echo _AT('alter'); ?>" /> \
+      <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'); ?>"> \
+        <img src="<?php echo TR_BASE_HREF; ?>images/alter.png" border="0" title="<?php echo _AT('alter'); ?>" alt="<?php echo _AT('alter'); ?>" /> \
       </a> \
       <a href="#" onclick="removeAlternative(\\\'<?php echo $cp; ?>\\\', '+cid+','+pid+','+a_type+');return false;"> \
-        <img src="<?php echo TR_BASE_HREF; ?>images/icon_delete.gif" border="0" title="<?php echo _AT('remove'); ?>" alt="<?php echo _AT('remove'); ?>" /> \
+        <img src="<?php echo TR_BASE_HREF; ?>images/remove.gif" border="0" title="<?php echo _AT('remove'); ?>" alt="<?php echo _AT('remove'); ?>" /> \
       </a> \
     </div> \
 ';
@@ -586,7 +589,7 @@ function setCheckboxCookie(obj, value1, value2, date)
 // and close "file manager" once the upload is successful
 if ($a_type > 0 && isset($_GET['uploadfile']) && $_GET['uploadfile'] <> '') { ?>
 function setAlternativeAndClose() {
-       setAlternative('<?php echo get_relative_path($_GET['cp'], $pathext).$_GET['uploadfile']; ?>', '<?php echo TR_BASE_HREF.$get_file.$pathext.urlencode($_GET['uploadfile']); ?>', '<?php echo $cid; ?>', '<?php echo $pid; ?>', '<?php echo $a_type; ?>');
+       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; ?>');
        window.close();
 }
 
index 5f46eb9..d5289e6 100644 (file)
@@ -657,23 +657,43 @@ class ContentUtility {
        * @access       public\r
        * @param        $cid:                           content id.\r
        * @param        $content:                       the original content page ($content_row['text'], from content.php).\r
+       * @param    $info_only:         when "true", return the array of info (has_text_alternative, has_audio_alternative, has_visual_alternative, has_sign_lang_alternative)\r
+       * @param    $only_on_secondary_type: \r
        * @return       string                          $content: the content page with the appropriated resources.\r
        * @see          $db                             from include/vitals.inc.php\r
        * @author       Cindy Qi Li\r
        */\r
-       public static function applyAlternatives($cid, $content){\r
+       public static function applyAlternatives($cid, $content, $info_only = false, $only_on_secondary_type = 0){\r
                global $db, $_course_id;\r
                \r
                include_once(TR_INCLUDE_PATH.'classes/DAO/DAO.class.php');\r
                $dao = new DAO();\r
                \r
-               $vidoe_exts = array("mpg", "avi", "wmv", "mov", "swf", "mp3", "wav", "ogg", "mid");\r
+               $video_exts = array("mpg", "avi", "wmv", "mov", "swf", "mp3", "wav", "ogg", "mid", "mp4", "flv");\r
                $txt_exts = array("txt", "html", "htm");\r
-               \r
-               if (($_SESSION['prefs']['PREF_USE_ALTERNATIVE_TO_TEXT']==0) && ($_SESSION['prefs']['PREF_USE_ALTERNATIVE_TO_AUDIO']==0) && ($_SESSION['prefs']['PREF_USE_ALTERNATIVE_TO_VISUAL']==0)) \r
+               $image_exts = array("gif", "bmp", "png", "jpg", "jpeg", "png", "tif");\r
+               $only_on_secondary_type = intval($only_on_secondary_type);\r
+                               \r
+               // intialize the 4 returned values when $info_only is on\r
+               if ($info_only)\r
+               {\r
+                       $has_text_alternative = false;\r
+                       $has_audio_alternative = false;\r
+                       $has_visual_alternative = false;\r
+                       $has_sign_lang_alternative = false;\r
+               }\r
+\r
+               if (!$info_only && !$only_on_secondary_type && \r
+                   ($_SESSION['prefs']['PREF_USE_ALTERNATIVE_TO_TEXT']==0) && \r
+                   ($_SESSION['prefs']['PREF_USE_ALTERNATIVE_TO_AUDIO']==0) && \r
+                   ($_SESSION['prefs']['PREF_USE_ALTERNATIVE_TO_VISUAL']==0)) \r
                {\r
                        //No user's preferences related to content format are declared\r
-                       return $content;\r
+                       if (!$info_only) {\r
+                               return $content;\r
+                       } else {\r
+                               return array($has_text_alternative, $has_audio_alternative, $has_visual_alternative, $has_sign_lang_alternative);\r
+                       }\r
                }\r
                \r
                // get all relations between primary resources and their alternatives\r
@@ -686,10 +706,13 @@ class ContentUtility {
                         WHERE pr.content_id=".$cid."\r
                               AND pr.primary_resource_id = prt.primary_resource_id\r
                               AND pr.primary_resource_id = sr.primary_resource_id\r
-                              AND sr.language_code='".$_SESSION['prefs']['PREF_ALT_AUDIO_PREFER_LANG']."'\r
+                              AND sr.language_code='".$_SESSION['lang']."'\r
                               AND sr.secondary_resource_id = srt.secondary_resource_id\r
-                          AND pr.content_id = c.content_id\r
-                            ORDER BY pr.primary_resource_id, prt.type_id";\r
+                          AND pr.content_id = c.content_id";\r
+               if ($only_on_secondary_type > 0) {\r
+                       $sql .= " AND srt.type_id=".$only_on_secondary_type;\r
+               }\r
+               $sql .= " ORDER BY pr.primary_resource_id, prt.type_id";\r
                \r
                $rows = $dao->execute($sql);\r
        \r
@@ -697,7 +720,8 @@ class ContentUtility {
                \r
                foreach ($rows as $row) \r
                {\r
-                       if (($_SESSION['prefs']['PREF_USE_ALTERNATIVE_TO_TEXT']==1 && $row['primary_type']==3 &&\r
+                       if ($info_only || $only_on_secondary_type ||\r
+                           ($_SESSION['prefs']['PREF_USE_ALTERNATIVE_TO_TEXT']==1 && $row['primary_type']==3 &&\r
                            ($_SESSION['prefs']['PREF_ALT_TO_TEXT']=="audio" && $row['secondary_type']==1 || \r
                             $_SESSION['prefs']['PREF_ALT_TO_TEXT']=="visual" && $row['secondary_type']==4 || \r
                             $_SESSION['prefs']['PREF_ALT_TO_TEXT']=="sign_lang" && $row['secondary_type']==2)) ||\r
@@ -716,24 +740,18 @@ class ContentUtility {
                                $ext = substr($row['secondary_resource'], strrpos($row['secondary_resource'], '.')+1);\r
                                \r
                                // alternative is video\r
-                               if (in_array($ext, $vidoe_exts))\r
+                               if (in_array($ext, $video_exts))\r
                                        $target = '[media]'.$row['secondary_resource'].'[/media]';\r
                                // a text primary to be replaced by a visual alternative \r
                                else if (in_array($ext, $txt_exts))\r
                                {\r
-                                       if (substr($row['secondary_resource'], 0, 2) == '..') \r
-                                               $file_location = substr($row['secondary_resource'], 3);\r
+                                       if ($row['content_path'] <> '') \r
+                                               $file_location = $row['content_path'].'/'.$row['secondary_resource'];\r
                                        else \r
                                                $file_location = $row['secondary_resource'];\r
-                                       $file .= $file_location;\r
                                        \r
-                                       if ($row['content_path'] <> '') {\r
-                                               $file = TR_CONTENT_DIR.$_course_id . '/'.$row['content_path'].'/'.$file_location;\r
-                                       }\r
-                                       else {\r
-                                               $file = TR_CONTENT_DIR.$_course_id . '/'.$file_location;\r
-                                       }\r
-                                       $target = file_get_contents($file);\r
+                                       $file = TR_CONTENT_DIR.$_SESSION['course_id'] . '/'.$file_location;\r
+                                       $target = '<br />'.file_get_contents($file);\r
                                        \r
                                        // check whether html file\r
                                        if (preg_match('/.*\<html.*\<\/html\>.*/s', $target))\r
@@ -742,7 +760,7 @@ class ContentUtility {
                                                if (defined('TR_FORCE_GET_FILE') && TR_FORCE_GET_FILE) {\r
                                                        $course_base_href = 'get.php/';\r
                                                } else {\r
-                                                       $course_base_href = 'content/' . $_course_id . '/';\r
+                                                       $course_base_href = 'content/' . $_SESSION['course_id'] . '/';\r
                                                }\r
                \r
                                                $file = TR_BASE_HREF . $course_base_href.$file_location;\r
@@ -754,13 +772,12 @@ class ContentUtility {
                                                $target = nl2br($target);\r
                                        }\r
                                } \r
-                               else if ($_SESSION['prefs']['PREF_USE_ALTERNATIVE_TO_TEXT']==1 \r
-                                        && $_SESSION['prefs']['PREF_ALT_TO_TEXT']=="visual")\r
-                                       $target = '<img border="0" alt="Alternate Text" src="'.$row['secondary_resource'].'"/>';\r
+                               else if (in_array($ext, $image_exts))\r
+                                       $target = '<img border="0" alt="'._AT('alternate_text').'" src="'.$row['secondary_resource'].'"/>';\r
                                // otherwise\r
                                else\r
                                        $target = '<p><a href="'.$row['secondary_resource'].'">'.$row['secondary_resource'].'</a></p>';\r
-                               \r
+       \r
                                // replace or append the target alternative to the source\r
                                if (($row['primary_type']==3 && $_SESSION['prefs']['PREF_ALT_TO_TEXT_APPEND_OR_REPLACE'] == 'replace') ||\r
                                        ($row['primary_type']==1 && $_SESSION['prefs']['PREF_ALT_TO_AUDIO_APPEND_OR_REPLACE']=='replace') ||\r
@@ -768,41 +785,92 @@ class ContentUtility {
                                        $pattern_replace_to = '${1}'.$target.'${3}';\r
                                else\r
                                        $pattern_replace_to = '${1}${2}'.$target.'${3}';\r
-                                       \r
+       \r
+                               // *** Alternative replace/append starts from here ***\r
+                               $img_processed = false;    // The indicator to tell the source image is found (or not) \r
+                                                          // and processed (or not) in an <img> tag. If found and processed, \r
+                                                          // SKIP the found/process for <a> tag because the source is a image\r
+                                                          // and <a> is very likely the tag wrapping around <img>\r
+\r
                                // append/replace target alternative to [media]source[/media]\r
-                               $content = preg_replace("/(.*)(".preg_quote("[media]".$row['resource']."[/media]", "/").")(.*)/s", \r
+                               if (preg_match("/".preg_quote("[media").".*".preg_quote("]".$row['resource']."[/media]", "/")."/sU", $content))\r
+                               {\r
+                                       if (!$info_only) {\r
+                                               $content = preg_replace("/(.*)(".preg_quote("[media").".*".preg_quote("]".$row['resource']."[/media]", "/").")(.*)/sU", \r
                                             $pattern_replace_to, $content);\r
+                                       } else {\r
+                                               if ($row['secondary_type'] == 1) $has_audio_alternative = true;\r
+                                               if ($row['secondary_type'] == 2) $has_sign_lang_alternative = true;\r
+                                               if ($row['secondary_type'] == 3) $has_text_alternative = true;\r
+                                               if ($row['secondary_type'] == 4) $has_visual_alternative = true;\r
+                                       }\r
+                               }\r
                                \r
-                               // append/replace target alternative to <a>...source...</a> or <a ...source...>...</a>\r
-                               if (preg_match("/\<a.*".preg_quote($row['resource'], "/").".*\<\/a\>/s", $content))\r
+                               // append/replace target alternative to <img ... src="source" ...></a>\r
+                               if (preg_match("/\<img.*src=\"".preg_quote($row['resource'], "/")."\".*\/\>/sU", $content))\r
                                {\r
-                                       $content = preg_replace("/(.*)(\<a.*".preg_quote($row['resource'], "/").".*\<\/a\>)(.*)/s", \r
+                                       $img_processed = true;\r
+                                       if (!$info_only) {\r
+                                               $content = preg_replace("/(.*)(\<img.*src=\"".preg_quote($row['resource'], "/")."\".*\/\>)(.*)/sU", \r
                                                        $pattern_replace_to, $content);\r
+                                       } else {\r
+                                               if ($row['secondary_type'] == 1) $has_audio_alternative = true;\r
+                                               if ($row['secondary_type'] == 2) $has_sign_lang_alternative = true;\r
+                                               if ($row['secondary_type'] == 3) $has_text_alternative = true;\r
+                                               if ($row['secondary_type'] == 4) $has_visual_alternative = true;\r
+                                       }\r
                                }\r
-       \r
-                               // append/replace target alternative to <img ... src="source" ...></a>\r
-                               if (preg_match("/\<img.*src=\"".preg_quote($row['resource'], "/")."\".*\/\>/s", $content))\r
+                               \r
+                               // append/replace target alternative to <a>...source...</a> or <a ...source...>...</a>\r
+                               // skip this "if" when the source object has been processed in aboved <img> tag\r
+                               if (!$img_processed && preg_match("/\<a.*".preg_quote($row['resource'], "/").".*\<\/a\>/sU", $content))\r
                                {\r
-                                       $content = preg_replace("/(.*)(\<img.*src=\"".preg_quote($row['resource'], "/")."\".*\/\>)(.*)/s", \r
+                                       if (!$info_only) {\r
+                                               $content = preg_replace("/(.*)(\<a.*".preg_quote($row['resource'], "/").".*\<\/a\>)(.*)/sU", \r
                                                        $pattern_replace_to, $content);\r
+                                       } else {\r
+                                               if ($row['secondary_type'] == 1) $has_audio_alternative = true;\r
+                                               if ($row['secondary_type'] == 2) $has_sign_lang_alternative = true;\r
+                                               if ($row['secondary_type'] == 3) $has_text_alternative = true;\r
+                                               if ($row['secondary_type'] == 4) $has_visual_alternative = true;\r
+                                       }\r
                                }\r
-                               \r
+       \r
                                // append/replace target alternative to <object ... source ...></object>\r
-                               if (preg_match("/\<object.*".preg_quote($row['resource'], "/").".*\<\/object\>/s", $content))\r
+                               if (preg_match("/\<object.*".preg_quote($row['resource'], "/").".*\<\/object\>/sU", $content))\r
                                {\r
-                                       $content = preg_replace("/(.*)(\<object.*".preg_quote($row['resource'], "/").".*\<\/object\>)(.*)/s", \r
+                                       if (!$info_only) {\r
+                                               $content = preg_replace("/(.*)(\<object.*".preg_quote($row['resource'], "/").".*\<\/object\>)(.*)/sU", \r
                                                        $pattern_replace_to, $content);\r
+                                       } else {\r
+                                               if ($row['secondary_type'] == 1) $has_audio_alternative = true;\r
+                                               if ($row['secondary_type'] == 2) $has_sign_lang_alternative = true;\r
+                                               if ($row['secondary_type'] == 3) $has_text_alternative = true;\r
+                                               if ($row['secondary_type'] == 4) $has_visual_alternative = true;\r
+                                       }\r
                                }\r
        \r
                                // append/replace target alternative to <embed ... source ...>\r
-                               if (preg_match("/\<embed.*".preg_quote($row['resource'], "/").".*\>/s", $content))\r
+                               if (preg_match("/\<embed.*".preg_quote($row['resource'], "/").".*\>/sU", $content))\r
                                {\r
-                                       $content = preg_replace("/(.*)(\<embed.*".preg_quote($row['resource'], "/").".*\>)(.*)/s", \r
+                                       if (!$info_only) {\r
+                                               $content = preg_replace("/(.*)(\<embed.*".preg_quote($row['resource'], "/").".*\>)(.*)/sU", \r
                                                        $pattern_replace_to, $content);\r
+                                       } else {\r
+                                               if ($row['secondary_type'] == 1) $has_audio_alternative = true;\r
+                                               if ($row['secondary_type'] == 2) $has_sign_lang_alternative = true;\r
+                                               if ($row['secondary_type'] == 3) $has_text_alternative = true;\r
+                                               if ($row['secondary_type'] == 4) $has_visual_alternative = true;\r
+                                       }\r
                                }\r
                        }\r
                }\r
-               return $content;\r
+               \r
+               if (!$info_only) {\r
+                       return $content;\r
+               } else {\r
+                       return array($has_text_alternative, $has_audio_alternative, $has_visual_alternative, $has_sign_lang_alternative);\r
+               }\r
        }       \r
                \r
        /**\r
index 9af7c8e..39e2162 100644 (file)
@@ -23,7 +23,7 @@ if ($cid == 0) {
        exit;
 }
 if (defined('TR_FORCE_GET_FILE') && TR_FORCE_GET_FILE) {
-       $_SESSION['course_id'] = $cid;  // used by get.php
+       $_SESSION['course_id'] = $_course_id;  // used by get.php
 }
 
 /* show the content page */
@@ -239,9 +239,16 @@ if ($content_row['text'] == '' && empty($content_test_ids)){
        $msg->addInfo('NO_PAGE_CONTENT');
        $savant->assign('body', '');
 } else {
+       // find whether the body has alternatives defined
+       list($has_text_alternative, $has_audio_alternative, $has_visual_alternative, $has_sign_lang_alternative)
+       = ContentUtility::applyAlternatives($cid, $content_row['text'], true);
 
-       //Silvia: to provide appropriated content on the basis of users' preferences
-       $content = ContentUtility::applyAlternatives($cid, $content_row['text']);
+       // apply alternatives
+       if (intval($_GET['alternative']) > 0) {
+               $content = ContentUtility::applyAlternatives($cid, $content_row['text'], false, intval($_GET['alternative']));
+       } else {
+               $content = ContentUtility::applyAlternatives($cid, $content_row['text']);
+       }
                 
        $content = ContentUtility::formatContent($content, $content_row['formatting']);
 
@@ -249,7 +256,12 @@ if ($content_row['text'] == '' && empty($content_test_ids)){
        
        $savant->assign('content_table', $content_array[0]);
        $savant->assign('body', $content_array[1]);
-
+       $savant->assign('has_text_alternative', $has_text_alternative);
+       $savant->assign('has_audio_alternative', $has_audio_alternative);
+       $savant->assign('has_visual_alternative', $has_visual_alternative);
+       $savant->assign('has_sign_lang_alternative', $has_sign_lang_alternative);
+       $savant->assign('cid', $cid);
+       
        //assign test pages if there are tests associated with this content page
        if (!empty($content_test_ids)){
                $savant->assign('test_message', $content_row['test_message']);
index 605fbdd..4d432f2 100644 (file)
@@ -20,6 +20,10 @@ include_once(TR_INCLUDE_PATH.'classes/DAO/DAO.class.php');
 
 $dao = new DAO();
 $resourceTypesDAO = new ResourceTypesDAO();
+
+global $_content_id;
+$cid = $_content_id;
+
 /**
  * This function returns the preview link of the given file
  * @param  $file     the file location in "file manager"
@@ -43,12 +47,13 @@ function get_preview_link($file)
  * @param $secondary_result   mysql result of all secondary alternatives
  *        $alternative type   the resource type of the alternative to display. Must be one of the values in resource_types.type_id
  *        $content_id         used to pass into file_manager/index.php
- *        $ps                 used to pass into file_manager/index.php
+ *        $pid                primary resource id
+ *        $td_header_id       the id of the table header cell, to comply with accessibility rule
  * @return html of the table cell "<td>...</td>"
  */ 
 function display_alternative_cell($secondary_resources, $alternative_type, $content_id, $pid, $td_header_id)
 {
-       global $content_row;
+       global $content_row, $_course_id;
        
        $found_alternative = false;
        
@@ -63,11 +68,11 @@ function display_alternative_cell($secondary_resources, $alternative_type, $cont
                        {
                                echo '    <div id="'.$pid.'_'.$alternative_type.'">'."\n";
                                echo '      <a href="'.get_preview_link($secondary_resource['secondary_resource']).'" title="'._AT('new_window').'" target="_new">'.$secondary_resource['secondary_resource'].'</a><br />'."\n";
-                               echo '      <a href="#" onclick="trans.utility.poptastic(\''.TR_BASE_HREF.'file_manager/index.php?framed=1'. SEP.'popup=1'. SEP.'cp='. $content_row['content_path'].SEP.'cid='.$content_id.SEP.'pid='.$pid.SEP.'a_type='.$alternative_type.'\');return false;" title="'._AT('new_window').'">'."\n";
-                               echo '        <img src="'.TR_BASE_HREF.'images/home-tests_sm.png" border="0" title="'._AT('alter').'" alt="'._AT('alter').'" />'."\n";
+                               echo '      <a href="#" onclick="trans.utility.poptastic(\''.TR_BASE_HREF.'file_manager/index.php?framed=1'. SEP.'popup=1'. SEP.'cp='. $content_row['content_path'].SEP.'_cid='.$content_id.SEP.'pid='.$pid.SEP.'a_type='.$alternative_type.'\');return false;" title="'._AT('new_window').'">'."\n";
+                               echo '        <img src="'.TR_BASE_HREF.'images/alter.png" border="0" title="'._AT('alter').'" alt="'._AT('alter').'" />'."\n";
                                echo '      </a>'."\n";
                                echo '      <a href="#" onclick="removeAlternative(\''.$content_row['content_path'].'\', '.$content_id.','.$pid.','.$alternative_type.');return false;">'."\n";
-                               echo '        <img src="'.TR_BASE_HREF.'images/icon_delete.gif" border="0" title="'._AT('remove').'" alt="'._AT('remove').'" />'."\n";
+                               echo '        <img src="'.TR_BASE_HREF.'images/remove.gif" border="0" title="'._AT('remove').'" alt="'._AT('remove').'" />'."\n";
                                echo '      </a>'."\n";
                                echo '    </div>'."\n";
                                $found_alternative = true;
@@ -78,7 +83,7 @@ function display_alternative_cell($secondary_resources, $alternative_type, $cont
        if (!$found_alternative)
        {
                echo '    <div id="'.$pid.'_'.$alternative_type.'">'."\n";
-               echo '      <input type="button" value="'._AT('add').'" title="'._AT('new_window').'" onclick="trans.utility.poptastic(\''.TR_BASE_HREF.'file_manager/index.php?framed=1'. SEP.'popup=1'. SEP.'cp='. $content_row['content_path'].SEP.'cid='.$content_id.SEP.'pid='.$pid.SEP.'a_type='.$alternative_type.'\');return false;" />'."\n";
+               echo '      <input type="button" value="'._AT('add').'" title="'._AT('new_window').'" onclick="trans.utility.poptastic(\''.TR_BASE_HREF.'file_manager/index.php?framed=1'. SEP.'popup=1'. SEP.'cp='. $content_row['content_path'].SEP.'_cid='.$content_id.SEP.'pid='.$pid.SEP.'a_type='.$alternative_type.'\');return false;" />'."\n";
                echo '    </div>'."\n";
        }
        echo '    </td>'."\n";
@@ -100,7 +105,7 @@ else
 //     $resource_types_result = mysql_query($sql, $db);
        $resource_types = $resourceTypesDAO->getAll();
        
-       echo '<table class="data" rules="all" style="width:100%">'."\n";
+       echo '<br /><table class="data" rules="all">'."\n";
        echo '  <thead>'."\n";
        echo '  <tr>'."\n";
        echo '    <th rowspan="2" id="header1">'._AT('original_resource').'</th>'."\n";
@@ -124,25 +129,24 @@ else
                           AND language_code = '".$_SESSION['lang']."'
                           AND resource='".$primary_resource."'";
 //             $primary_result = mysql_query($sql, $db);
-               $primary_resources = $dao->execute($sql);
-               
-               if (is_array($primary_resources)) $num_of_primary_resources = count($primary_resources);
+               $existing_primary_resource = $dao->execute($sql);
+
                // insert primary resource if it's not in db
-               if ($num_of_primary_resources == 0)
+               if (!is_array($existing_primary_resource))
 //             if (mysql_num_rows($primary_result) == 0)
                {
                        $sql = "INSERT INTO ".TABLE_PREFIX."primary_resources (content_id, resource, language_code) 
                                VALUES (".$cid.", '".$primary_resource."', '".$_SESSION['lang']."')";
 //                     $result = mysql_query($sql, $db);
-                       $dao->execute($sql);
-                       $primary_resource_id = mysql_insert_id();
+                       $primary_resource_id = $dao->execute($sql);
                }
                else
                {
                        // get primary resource id
 //                     $primary_resource_row = mysql_fetch_assoc($primary_result);
-                       $primary_resource_id = $primary_resources['primary_resource_id'];
+                       $primary_resource_id = $existing_primary_resource[0]['primary_resource_id'];
                }
+               
                $sql = "SELECT prt.type_id, rt.type
                          FROM ".TABLE_PREFIX."primary_resources pr, ".
                                 TABLE_PREFIX."primary_resources_types prt, ".
@@ -186,9 +190,9 @@ else
                
 //             mysql_data_seek($resource_types_result, 0);  // move the mysql result cursor back to the first row
 //             while ($resource_type = mysql_fetch_assoc($resource_types_result))
-               if (is_array($secondary_resources))
+               if (is_array($resource_types))
                {
-                       foreach ($secondary_resources as $resource_type) {
+                       foreach ($resource_types as $resource_type) {
                                if ($resource_type['type'] == 'sign_language')
                                        continue;
                                else 
@@ -201,11 +205,12 @@ else
                                                }
                                        }
                                        else {
-                                               if (mysql_num_rows($primary_type_result)> 0) mysql_data_seek($primary_type_result, 0);
-                                               while ($primary_resource_type = mysql_fetch_assoc($primary_type_result)) {
-                                                       if ($primary_resource_type['type_id'] == $resource_type['type_id']){
-                                                               echo 'checked="checked"';
-                                                               break;
+                                               if (is_array($primary_types)) {
+                                                       foreach ($primary_types as $primary_resource_type) {
+                                                               if ($primary_resource_type['type_id'] == $resource_type['type_id']){
+                                                                       echo 'checked="checked"';
+                                                                       break;
+                                                               }
                                                        }
                                                }
                                        }
@@ -231,7 +236,7 @@ else
                echo '  </tr>'."\n";
        }
        echo '  </tbody>'."\n";
-       echo '</table>'."\n";
+       echo '</table><br /><br />'."\n";
 }
 ?>
 
@@ -246,7 +251,7 @@ function removeAlternative(contentPath, cid, pid, a_type)
                        {"pid":pid, "a_type":a_type}, 
                        function(data) {});
 
-       var button_html = '      <input type="button" value="<?php echo _AT('add'); ?>" title="<?php echo _AT('new_window'); ?>" onclick="trans.utility.poptastic(\\\'<?php echo TR_BASE_HREF; ?>file_manager/index.php?framed=1<?php echo SEP; ?>popup=1<?php echo SEP; ?>cp='+contentPath+'<?php echo SEP; ?>cid='+cid+'<?php echo SEP; ?>pid='+pid+'<?php echo SEP; ?>a_type='+a_type+'\\\');return false;" />';
+       var button_html = '      <input type="button" value="<?php echo _AT('add'); ?>" title="<?php echo _AT('new_window'); ?>" onclick="trans.utility.poptastic(\\\'<?php echo TR_BASE_HREF; ?>file_manager/index.php?framed=1<?php echo SEP; ?>popup=1<?php echo SEP; ?>cp='+contentPath+'<?php echo SEP; ?>_cid='+cid+'<?php echo SEP; ?>pid='+pid+'<?php echo SEP; ?>a_type='+a_type+'\\\');return false;" />';
        eval("document.getElementById(\""+pid+"_"+a_type+"\").innerHTML = '"+button_html+"'");
 }
 //-->
index ba23646..6ad8489 100644 (file)
@@ -28,7 +28,9 @@ $type_id = intval($_POST['a_type']);
 // check post vars
 if ($pid == 0 || $type_id == 0) exit;
 
-global $db;
+require_once(TR_INCLUDE_PATH.'classes/DAO/DAO.class.php');
+$dao = new DAO();
+
 // delete the existing alternative for this (pid, a_type)
 $sql = "SELECT sr.secondary_resource_id 
           FROM ".TABLE_PREFIX."secondary_resources sr, ".TABLE_PREFIX."secondary_resources_types srt
@@ -36,18 +38,20 @@ $sql = "SELECT sr.secondary_resource_id
            AND sr.primary_resource_id = ".$pid."
            AND sr.language_code = '".$_SESSION['lang']."'
            AND srt.type_id=".$type_id;
-$existing_secondary_result = mysql_query($sql, $db);
-
-while ($existing_secondary = mysql_fetch_assoc($existing_secondary_result))
-{
-       $sql = "DELETE FROM ".TABLE_PREFIX."secondary_resources 
-                WHERE secondary_resource_id = ".$existing_secondary['secondary_resource_id'];
-       $result = mysql_query($sql, $db);
-
-       $sql = "DELETE FROM ".TABLE_PREFIX."secondary_resources_types 
-                WHERE secondary_resource_id = ".$existing_secondary['secondary_resource_id']."
-                  AND type_id=".$type_id;
-       $result = mysql_query($sql, $db);
+$existing_secondary_rows = $dao->execute($sql);
+
+if (is_array($existing_secondary_rows)) {
+       foreach ($existing_secondary_rows as $existing_secondary)
+       {
+               $sql = "DELETE FROM ".TABLE_PREFIX."secondary_resources 
+                        WHERE secondary_resource_id = ".$existing_secondary['secondary_resource_id'];
+               $dao->execute($sql);
+       
+               $sql = "DELETE FROM ".TABLE_PREFIX."secondary_resources_types 
+                        WHERE secondary_resource_id = ".$existing_secondary['secondary_resource_id']."
+                          AND type_id=".$type_id;
+               $dao->execute($sql);
+       }
 }
 
 exit;
index 0f63f1e..c540e82 100644 (file)
@@ -21,7 +21,7 @@
  */
 
 define('TR_INCLUDE_PATH', '../../include/');
-require (TR_INCLUDE_PATH.'vitals.inc.php');
+require_once(TR_INCLUDE_PATH.'vitals.inc.php');
 
 $pid = intval($_POST['pid']);
 $type_id = intval($_POST['a_type']);
@@ -30,7 +30,9 @@ $secondary_resource = trim($_POST['alternative']);
 // check post vars
 if ($pid == 0 || $type_id == 0 || $secondary_resource == '') exit;
 
-global $db;
+require_once(TR_INCLUDE_PATH.'classes/DAO/DAO.class.php');
+$dao = new DAO();
+
 // delete the existing alternative for this (pid, a_type)
 $sql = "SELECT sr.secondary_resource_id 
           FROM ".TABLE_PREFIX."secondary_resources sr, ".TABLE_PREFIX."secondary_resources_types srt
@@ -38,29 +40,32 @@ $sql = "SELECT sr.secondary_resource_id
            AND sr.primary_resource_id = ".$pid."
            AND sr.language_code = '".$_SESSION['lang']."'
            AND srt.type_id=".$type_id;
-$existing_secondary_result = mysql_query($sql, $db);
-
-while ($existing_secondary = mysql_fetch_assoc($existing_secondary_result))
-{
-       $sql = "DELETE FROM ".TABLE_PREFIX."secondary_resources 
-                WHERE secondary_resource_id = ".$existing_secondary['secondary_resource_id'];
-       $result = mysql_query($sql, $db);
+//$existing_secondary_result = mysql_query($sql, $db);
+$existing_secondary_rows = $dao->execute($sql);
 
-       $sql = "DELETE FROM ".TABLE_PREFIX."secondary_resources_types 
-                WHERE secondary_resource_id = ".$existing_secondary['secondary_resource_id']."
-                  AND type_id=".$type_id;
-       $result = mysql_query($sql, $db);
+if (is_array($existing_secondary_rows)) {
+       foreach ($existing_secondary_rows as $existing_secondary)
+       {
+               $sql = "DELETE FROM ".TABLE_PREFIX."secondary_resources 
+                        WHERE secondary_resource_id = ".$existing_secondary['secondary_resource_id'];
+               $dao->execute($sql);
+       
+               $sql = "DELETE FROM ".TABLE_PREFIX."secondary_resources_types 
+                        WHERE secondary_resource_id = ".$existing_secondary['secondary_resource_id']."
+                          AND type_id=".$type_id;
+               $dao->execute($sql);
+       }
 }
 
 // insert new alternative
 $sql = "INSERT INTO ".TABLE_PREFIX."secondary_resources (primary_resource_id, secondary_resource, language_code)
         VALUES (".$pid.", '".mysql_real_escape_string($secondary_resource)."', '".$_SESSION['lang']."')";
-$result = mysql_query($sql, $db);
+$dao->execute($sql);
 $secondary_resource_id = mysql_insert_id();
 
 $sql = "INSERT INTO ".TABLE_PREFIX."secondary_resources_types (secondary_resource_id, type_id)
         VALUES (".$secondary_resource_id.", ".$type_id.")";
-$result = mysql_query($sql, $db);
+$dao->execute($sql);
 
 exit;
 
diff --git a/docs/images/alter.png b/docs/images/alter.png
new file mode 100644 (file)
index 0000000..046811e
Binary files /dev/null and b/docs/images/alter.png differ
diff --git a/docs/images/audio_alternative.png b/docs/images/audio_alternative.png
new file mode 100644 (file)
index 0000000..ead0370
Binary files /dev/null and b/docs/images/audio_alternative.png differ
diff --git a/docs/images/pause.png b/docs/images/pause.png
new file mode 100644 (file)
index 0000000..df812fb
Binary files /dev/null and b/docs/images/pause.png differ
diff --git a/docs/images/remove.gif b/docs/images/remove.gif
new file mode 100644 (file)
index 0000000..1153ba5
Binary files /dev/null and b/docs/images/remove.gif differ
diff --git a/docs/images/sign_lang_alternative.png b/docs/images/sign_lang_alternative.png
new file mode 100644 (file)
index 0000000..7810880
Binary files /dev/null and b/docs/images/sign_lang_alternative.png differ
diff --git a/docs/images/text_alternative.png b/docs/images/text_alternative.png
new file mode 100644 (file)
index 0000000..e256494
Binary files /dev/null and b/docs/images/text_alternative.png differ
diff --git a/docs/images/visual_alternative.png b/docs/images/visual_alternative.png
new file mode 100644 (file)
index 0000000..25397f9
Binary files /dev/null and b/docs/images/visual_alternative.png differ
index 0131ab3..48dba28 100644 (file)
@@ -18,8 +18,7 @@ define('TR_INCLUDE_PATH', '../include/');
 include_once(TR_INCLUDE_PATH.'../home/classes/ContentUtility.class.php');
 
 $body_text     = htmlspecialchars($stripslashes($_POST['body_text']));
-$body_t                = html_entity_decode($body_text);
-               
+$body          = html_entity_decode($body_text);
 
 require(TR_INCLUDE_PATH.'classes/XML/XML_HTMLSax/XML_HTMLSax.php');    /* for XML_HTMLSax */
 require(TR_INCLUDE_PATH.'imscc/ims_template.inc.php');                         /* for ims templates + print_organizations() */
@@ -90,7 +89,7 @@ $parser->set_element_handler('openHandler','closeHandler');
 
 /* generate the resources and save the HTML files */
                        
-ob_start();
+//ob_start();
                                                         
 global $parser, $my_files;
 global $course_id;
@@ -100,19 +99,23 @@ $my_files          = array();
 $content_files         = "\n";
 
 //in order to control if some [media] is in the body_text
-$body = ContentUtility::embedMedia($body_t);
+//$body = ContentUtility::embedMedia($body_t);
 
 $parser->parse($body);
-               
+
+// find all [media] resources
+preg_match_all("/\[media[0-9a-z\|]*\](.*)\[\/media\]/i",$body,$media_matches);
+$my_files = array_merge($media_matches[1], $my_files);
+
 // add by Cindy Li. 
 // This resolves the problem introduced by [media] tag: when [media] is 
 // parsed into <object>, same resource appears a few times in <object> with different 
-// format to cater for different browsers or players. This way creates prolem that different
+// format to cater for different browsers or players. This way creates problem that different
 // formats in <object> are all parsed and considered as different resource. array_unique()
 // call solves this problem. But, it introduces the new problem that when a same resource
 // appears at different places in the content and users do want to have them with different
 // alternatives. With this solution, this same resource only shows up once at "adapt content"
-// and only can have one alternative associate with. Table and scripts need to re-design
+// and only can have one alternative associated with. Table and scripts need to be re-designed
 // to solve this problem, for example, include line number in table. 
 $my_files = array_unique($my_files);
 
@@ -126,7 +129,7 @@ $i=0;
 foreach ($my_files as $file) {
        /* filter out full urls */
        $url_parts = @parse_url($file);
-       if (isset($url_parts['scheme'])) {
+       if (isset($url_parts['scheme']) && substr($file, 0, strlen(TR_BASE_HREF)) != TR_BASE_HREF) {
                continue;
        }
 
index b21f779..8f40ddc 100644 (file)
@@ -427,11 +427,18 @@ INSERT INTO `TR_language_text` VALUES ('en', '_template', 'processing', 'Process
 INSERT INTO `TR_language_text` VALUES ('en', '_template', 'browse_for_upload', 'Browse for file to upload', now(), '');\r
 INSERT INTO `TR_language_text` VALUES ('en', '_template', 'the_follow_errors_occurred', 'The following errors occurred:', now(), '');\r
 INSERT INTO `TR_language_text` VALUES ('en', '_template', 'content_id', 'Content ID', now(), '');\r
+INSERT INTO `TR_language_text` VALUES ('en', '_template', 'put_link', 'put link name here', now(), '');\r
+INSERT INTO `TR_language_text` VALUES ('en', '_template', 'auditory', 'Auditory', now(), '');\r
+INSERT INTO `TR_language_text` VALUES ('en', '_template', 'textual', 'Textual', now(), '');\r
+INSERT INTO `TR_language_text` VALUES ('en', '_template', 'stop_apply_text_alternatives', 'Stop Applying Text Alternatives', now(), '');\r
+INSERT INTO `TR_language_text` VALUES ('en', '_template', 'apply_audio_alternatives', 'Apply Audio Alternatives', now(), '');\r
+INSERT INTO `TR_language_text` VALUES ('en', '_template', 'stop_apply_audio_alternatives', 'Stop Applying Audio Alternatives', now(), '');\r
+INSERT INTO `TR_language_text` VALUES ('en', '_template', 'apply_text_alternatives', 'Apply Text Alternatives', now(), '');\r
+INSERT INTO `TR_language_text` VALUES ('en', '_template', 'stop_apply_visual_alternatives', 'Stop Applying Visual Alternatives', now(), '');\r
+INSERT INTO `TR_language_text` VALUES ('en', '_template', 'apply_visual_alternatives', 'Apply Visual Alternatives', now(), '');\r
+INSERT INTO `TR_language_text` VALUES ('en', '_template', 'stop_apply_sign_lang_alternatives', 'Stop Applying Sign Language Alternatives', now(), '');\r
+INSERT INTO `TR_language_text` VALUES ('en', '_template', 'apply_sign_lang_alternatives', 'Apply Sign Language Alternatives', now(), '');\r
 \r
-INSERT INTO `TR_language_text` VALUES ('en', '_template', '', '', now(), '');\r
-INSERT INTO `TR_language_text` VALUES ('en', '_template', '', '', now(), '');\r
-INSERT INTO `TR_language_text` VALUES ('en', '_template', '', '', now(), '');\r
-INSERT INTO `TR_language_text` VALUES ('en', '_template', '', '', now(), '');\r
 INSERT INTO `TR_language_text` VALUES ('en', '_template', '', '', now(), '');\r
 INSERT INTO `TR_language_text` VALUES ('en', '_template', '', '', now(), '');\r
 INSERT INTO `TR_language_text` VALUES ('en', '_template', '', '', now(), '');\r
index efa12c9..df6f9f8 100644 (file)
 \r
 if (!defined('TR_INCLUDE_PATH')) { exit; } ?>\r
 \r
+<?php if ($this->has_text_alternative || $this->has_audio_alternative || $this->has_visual_alternative || $this->has_sign_lang_alternative): ?>\r
+<div id="alternatives_shortcuts">\r
+<?php if ($this->has_text_alternative) :?>\r
+  <a href="<?php echo $_SERVER['PHP_SELF'].'?_cid='.$this->cid.(($_GET['alternative'] == 3) ? '' : SEP.'alternative=3'); ?>">\r
+    <img src="<?php echo TR_BASE_HREF; ?>images/<?php echo (($_GET['alternative'] == 3) ? 'pause.png' : 'text_alternative.png'); ?>" \r
+      alt="<?php echo (($_GET['alternative'] == 3) ? _AT('stop_apply_text_alternatives') : _AT('apply_text_alternatives')); ?>" \r
+      title="<?php echo (($_GET['alternative'] == 3) ? _AT('stop_apply_text_alternatives') : _AT('apply_text_alternatives')); ?>" \r
+      border="0" />\r
+  </a>\r
+<?php endif; // END OF has text alternative?>\r
+<?php if ($this->has_audio_alternative) :?>\r
+  <a href="<?php echo $_SERVER['PHP_SELF'].'?_cid='.$this->cid.(($_GET['alternative'] == 1) ? '' : SEP.'alternative=1'); ?>">\r
+    <img src="<?php echo TR_BASE_HREF; ?>images/<?php echo (($_GET['alternative'] == 1) ? 'pause.png' : 'audio_alternative.png'); ?>" \r
+      alt="<?php echo (($_GET['alternative'] == 1) ? _AT('stop_apply_audio_alternatives') : _AT('apply_audio_alternatives')); ?>" \r
+      title="<?php echo (($_GET['alternative'] == 1) ? _AT('stop_apply_audio_alternatives') : _AT('apply_audio_alternatives')); ?>" \r
+      border="0" />\r
+  </a>\r
+<?php endif; // END OF has audio alternative?>\r
+<?php if ($this->has_visual_alternative) :?>\r
+  <a href="<?php echo $_SERVER['PHP_SELF'].'?_cid='.$this->cid.(($_GET['alternative'] == 4) ? '' : SEP.'alternative=4'); ?>">\r
+    <img src="<?php echo TR_BASE_HREF; ?>images/<?php echo (($_GET['alternative'] == 4) ? 'pause.png' : 'visual_alternative.png'); ?>" \r
+      alt="<?php echo (($_GET['alternative'] == 4) ? _AT('stop_apply_visual_alternatives') : _AT('apply_visual_alternatives')); ?>" \r
+      title="<?php echo (($_GET['alternative'] == 4) ? _AT('stop_apply_visual_alternatives') : _AT('apply_visual_alternatives')); ?>" \r
+      border="0" />\r
+  </a>\r
+<?php endif; // END OF has visual alternative?>\r
+<?php if ($this->has_sign_lang_alternative) :?>\r
+  <a href="<?php echo $_SERVER['PHP_SELF'].'?_cid='.$this->cid.(($_GET['alternative'] == 2) ? '' : SEP.'alternative=2'); ?>">\r
+    <img src="<?php echo TR_BASE_HREF; ?>images/<?php echo (($_GET['alternative'] == 2) ? 'pause.png' : 'sign_lang_alternative.png'); ?>" \r
+      alt="<?php echo (($_GET['alternative'] == 2) ? _AT('stop_apply_sign_lang_alternatives') : _AT('apply_sign_lang_alternatives')); ?>" \r
+      title="<?php echo (($_GET['alternative'] == 2) ? _AT('stop_apply_sign_lang_alternatives') : _AT('apply_sign_lang_alternatives')); ?>" \r
+      border="0" />\r
+  </a>\r
+<?php endif; // END OF has sign language alternative?>\r
+</div>\r
+<?php endif; // END OF displaying alternative shortcut icons?>\r
+\r
 <?php if ($this->shortcuts): ?>\r
 <input type="hidden" name="course_id" value="<?php echo $this->course_id; ?>" />\r
 \r
index a9e10a8..45166c2 100644 (file)
@@ -74,7 +74,7 @@ $starttime = $mtime;
        <meta name="keywords" content="Transformable,free, open source, accessibility checker, accessibility reviewer, accessibility evaluator, accessibility evaluation, WCAG evaluation, 508 evaluation, BITV evaluation, evaluate accessibility, test accessibility, review accessibility, ATRC, WCAG 2, STANCA, BITV, Section 508." />
        <meta name="description" content="Transformable is a Web accessibility evalution tool designed to help Web content developers and Web application developers ensure their Web content is accessible to everyone regardless to the technology they may be using, or their abilities or disabilities." />
        <base href="<?php echo $this->content_base_href; ?>" />
-       <link rel="shortcut icon" href="<?php echo $this->base_path; ?>/favicon.ico" type="image/x-icon" />
+       <link rel="shortcut icon" href="<?php echo $this->base_path; ?>favicon.ico" type="image/x-icon" />
        <link rel="stylesheet" href="<?php echo $this->base_path.'themes/'.$this->theme; ?>/forms.css" type="text/css" />
        <link rel="stylesheet" href="<?php echo $this->base_path.'themes/'.$this->theme; ?>/styles.css" type="text/css" />
        <!--[if IE]>
index e922e42..5f292e8 100644 (file)
@@ -1446,3 +1446,15 @@ ul#content-tool-links img{
 .nowrap {
     white-space: nowrap;
 }
+div#alternatives_shortcuts {
+       float: right;
+       margin: 0 2em;
+       border-radius: .5em .5em .5em .5em;;
+       -moz-border-radius: .5em .5em .5em .5em;
+       -moz-box-shadow:.2em .2em .2em #999999;
+        box-shadow: .2em .2em  .2em #999999;
+        border:1px solid #cccccc;
+        padding-top: .2em;
+        padding-left: .2em;
+        padding-right: .2em;
+}