more progress on content editor
authorCindy Li <cli@ocad.ca>
Wed, 26 May 2010 21:02:35 +0000 (21:02 -0000)
committerCindy Li <cli@ocad.ca>
Wed, 26 May 2010 21:02:35 +0000 (21:02 -0000)
docs/file_manager/filemanager_display.inc.php
docs/get.php
docs/home/classes/ContentUtility.class.php
docs/home/course/content.php
docs/home/editor/editor_tabs/alternatives.inc.php
docs/home/ims/ims_export.php
docs/home/ims/ims_import.php
docs/home/index.php
docs/include/lib/resources_parser.inc.php

index 356a0a9..7f2a790 100644 (file)
@@ -479,16 +479,18 @@ function insertFile(fileName, pathTo, ext, ed_pref) {
                var info = "<?php echo _AT('put_link'); ?>";
                var html = '<a href="' + pathTo+fileName + '">' + info + '</a>';
        }
-       insertLink(html, ed_pref);
+       insertLink(html);
+//     insertLink(html, ed_pref);
 }
 
-function insertLink(html, ed_pref)
+//function insertLink(html, ed_pref)
+function insertLink(html)
 {
-    if (window.opener) {
-        var isNotVisual = window.opener.document.form.html.checked && (ed_pref === '1');
-    }
+//    if (window.opener) {
+//        var isNotVisual = window.opener.document.form.html.checked;
+//    }
 
-       if (!window.opener || !isNotVisual) {
+       if (!window.opener || $('#html:checked').val() !== null) {
                if (!window.opener && window.parent.tinyMCE)
                        window.parent.tinyMCE.execCommand('mceInsertContent', false, html);
                else
index fbd93e4..8fb77fa 100644 (file)
@@ -23,8 +23,6 @@ $in_get = TRUE;
 require(TR_INCLUDE_PATH . 'vitals.inc.php');
 require(TR_INCLUDE_PATH . 'lib/mime.inc.php');
 
-global $_course_id;
-
 $force_download = false;
 
 //get path to file
@@ -81,7 +79,7 @@ if (substr($file_name, 0, 4) == 'b64:') {
 }
 
 
-$file = TR_CONTENT_DIR . $_course_id . $current_file;
+$file = TR_CONTENT_DIR . $_SESSION['course_id'] . $current_file;
 
 //send header mime type
 $pathinfo = pathinfo($file);
index daea3b0..5f46eb9 100644 (file)
@@ -138,7 +138,7 @@ class ContentUtility {
        }\r
 \r
        private static function embedFLV($text) {\r
-               global $content_base_href, $_course_id;\r
+               global $content_base_href;\r
                \r
                // .flv - uses Flowplayer 3.0 from flowplayer.org (playing file via full URL)\r
                preg_match_all("#\[media[0-9a-z\|]*\]http://([\w\./-]+)\.flv\[/media\]#i",$text,$media_matches[0],PREG_SET_ORDER);\r
@@ -151,7 +151,7 @@ class ContentUtility {
                preg_match_all("#\[media[0-9a-z\|]*\]([\w\./-]+)\.flv\[/media\]#i",$text,$media_matches[1],PREG_SET_ORDER);\r
                $media_replace[1] ="<a class=\"flowplayerholder\"\r
                style=\"display:block;width:##WIDTH##px;height:##HEIGHT##px;\"\r
-               href=\"".TR_BASE_HREF."get.php/".$content_base_href."##MEDIA1##.flv?_course_id=".$_course_id."\">\r
+               href=\"".TR_BASE_HREF."get.php/".$content_base_href."##MEDIA1##.flv\">\r
                </a>";\r
                \r
                $has_flv = false;\r
index 6b06a9c..9af7c8e 100644 (file)
@@ -22,6 +22,10 @@ if ($cid == 0) {
        header('Location: '.$_base_href.'index.php');
        exit;
 }
+if (defined('TR_FORCE_GET_FILE') && TR_FORCE_GET_FILE) {
+       $_SESSION['course_id'] = $cid;  // used by get.php
+}
+
 /* show the content page */
 if (isset($contentManager)) $content_row = $contentManager->getContentPage($cid);
 
index 7b83734..605fbdd 100644 (file)
  */
 
 if (!defined('TR_INCLUDE_PATH')) { exit; }
+include_once(TR_INCLUDE_PATH.'classes/DAO/ResourceTypesDAO.class.php');
+include_once(TR_INCLUDE_PATH.'classes/DAO/DAO.class.php');
 
+$dao = new DAO();
+$resourceTypesDAO = new ResourceTypesDAO();
 /**
  * This function returns the preview link of the given file
  * @param  $file     the file location in "file manager"
@@ -42,7 +46,7 @@ function get_preview_link($file)
  *        $ps                 used to pass into file_manager/index.php
  * @return html of the table cell "<td>...</td>"
  */ 
-function display_alternative_cell($secondary_result, $alternative_type, $content_id, $pid, $td_header_id)
+function display_alternative_cell($secondary_resources, $alternative_type, $content_id, $pid, $td_header_id)
 {
        global $content_row;
        
@@ -50,10 +54,10 @@ function display_alternative_cell($secondary_result, $alternative_type, $content
        
        echo '    <td headers="'.$td_header_id.'">'."\n";
        
-       if (mysql_num_rows($secondary_result) > 0)
+       if (is_array($secondary_resources))
        {
-               mysql_data_seek($secondary_result, 0);  // move the mysql result cursor back to the first row
-               while ($secondary_resource = mysql_fetch_assoc($secondary_result))
+//             mysql_data_seek($secondary_result, 0);  // move the mysql result cursor back to the first row
+               foreach ($secondary_resources as $secondary_resource)
                {
                        if ($secondary_resource['type_id'] == $alternative_type)
                        {
@@ -92,8 +96,9 @@ else
 {
        $is_post_indicator_set = false;
        // get all resource types
-       $sql = "SELECT * FROM ".TABLE_PREFIX."resource_types";
-       $resource_types_result = mysql_query($sql, $db);
+//     $sql = "SELECT * FROM ".TABLE_PREFIX."resource_types";
+//     $resource_types_result = mysql_query($sql, $db);
+       $resource_types = $resourceTypesDAO->getAll();
        
        echo '<table class="data" rules="all" style="width:100%">'."\n";
        echo '  <thead>'."\n";
@@ -118,21 +123,25 @@ else
                         WHERE content_id = ".$cid."
                           AND language_code = '".$_SESSION['lang']."'
                           AND resource='".$primary_resource."'";
-               $primary_result = mysql_query($sql, $db);
+//             $primary_result = mysql_query($sql, $db);
+               $primary_resources = $dao->execute($sql);
                
+               if (is_array($primary_resources)) $num_of_primary_resources = count($primary_resources);
                // insert primary resource if it's not in db
-               if (mysql_num_rows($primary_result) == 0)
+               if ($num_of_primary_resources == 0)
+//             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);
+//                     $result = mysql_query($sql, $db);
+                       $dao->execute($sql);
                        $primary_resource_id = mysql_insert_id();
                }
                else
                {
                        // get primary resource id
-                       $primary_resource_row = mysql_fetch_assoc($primary_result);
-                       $primary_resource_id = $primary_resource_row['primary_resource_id'];
+//                     $primary_resource_row = mysql_fetch_assoc($primary_result);
+                       $primary_resource_id = $primary_resources['primary_resource_id'];
                }
                $sql = "SELECT prt.type_id, rt.type
                          FROM ".TABLE_PREFIX."primary_resources pr, ".
@@ -143,7 +152,8 @@ else
                           AND pr.resource='".$primary_resource."'
                           AND pr.primary_resource_id = prt.primary_resource_id
                           AND prt.type_id = rt.type_id";
-               $primary_type_result = mysql_query($sql, $db);
+//             $primary_type_result = mysql_query($sql, $db);
+               $primary_types = $dao->execute($sql);
                
                if (!$is_post_indicator_set)
                {
@@ -161,7 +171,8 @@ else
                           AND pr.resource='".$primary_resource."'
                           AND pr.primary_resource_id = sr.primary_resource_id
                           AND sr.secondary_resource_id = srt.secondary_resource_id";
-               $secondary_result = mysql_query($sql, $db);
+//             $secondary_result = mysql_query($sql, $db);
+               $secondary_resources = $dao->execute($sql);
                
                echo '  <tr>'."\n";
 
@@ -173,46 +184,49 @@ else
                // table cell "original resource type"
                echo '    <td headers="header2">'."\n";
                
-               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))
+//             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 ($resource_type['type'] == 'sign_language')
-                               continue;
-                       else 
-                       {
-                               echo '<input type="checkbox" name="alt_'.$primary_resource_id.'_'.$resource_type['type_id'].'" value="1" id="alt_'.$primary_resource_id.'_'.$resource_type['type_id'].'"';
-                               if ($_POST['use_post_for_alt'])
+                       foreach ($secondary_resources as $resource_type) {
+                               if ($resource_type['type'] == 'sign_language')
+                                       continue;
+                               else 
                                {
-                                       if (isset($_POST['alt_'.$primary_resource_id.'_'.$resource_type['type_id']])) {
-                                               echo 'checked="checked"';
-                                       }
-                               }
-                               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 '<input type="checkbox" name="alt_'.$primary_resource_id.'_'.$resource_type['type_id'].'" value="1" id="alt_'.$primary_resource_id.'_'.$resource_type['type_id'].'"';
+                                       if ($_POST['use_post_for_alt'])
+                                       {
+                                               if (isset($_POST['alt_'.$primary_resource_id.'_'.$resource_type['type_id']])) {
                                                        echo 'checked="checked"';
-                                                       break;
                                                }
                                        }
+                                       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;
+                                                       }
+                                               }
+                                       }
+                                       echo '/>'."\n";
+                                       echo '<label for="alt_'.$primary_resource_id.'_'.$resource_type['type_id'].'">'. _AT($resource_type['type']).'</label><br/>'."\n";      
                                }
-                               echo '/>'."\n";
-                               echo '<label for="alt_'.$primary_resource_id.'_'.$resource_type['type_id'].'">'. _AT($resource_type['type']).'</label><br/>'."\n";      
-                       }       
+                       }
                }
                echo '    </td>'."\n";
                
                // table cell "text alternative"
-               display_alternative_cell($secondary_result, 3, $cid, $primary_resource_id, "header3");
+               display_alternative_cell($secondary_resources, 3, $cid, $primary_resource_id, "header3");
                
                // table cell "audio"
-               display_alternative_cell($secondary_result, 1, $cid, $primary_resource_id, "header4");
+               display_alternative_cell($secondary_resources, 1, $cid, $primary_resource_id, "header4");
                
                // table cell "visual"
-               display_alternative_cell($secondary_result, 4, $cid, $primary_resource_id, "header5");
+               display_alternative_cell($secondary_resources, 4, $cid, $primary_resource_id, "header5");
                
                // table cell "sign language"
-               display_alternative_cell($secondary_result, 2, $cid, $primary_resource_id, "header6");
+               display_alternative_cell($secondary_resources, 2, $cid, $primary_resource_id, "header6");
                
                echo '  </tr>'."\n";
        }
index eca27e0..837dc30 100644 (file)
@@ -81,7 +81,7 @@ $course_language_code = $courseLanguage->getCode();
 require(TR_INCLUDE_PATH.'classes/zipfile.class.php');                          /* for zipfile */
 require(TR_INCLUDE_PATH.'classes/vcard.php');                                          /* for vcard */
 require(TR_INCLUDE_PATH.'classes/XML/XML_HTMLSax/XML_HTMLSax.php');    /* for XML_HTMLSax */
-require(TR_INCLUDE_PATH.'ims/ims_template.inc.php');                           /* for ims templates + print_organizations() */
+require(TR_INCLUDE_PATH.'imscc/ims_template.inc.php');                         /* for ims templates + print_organizations() */
 
 if (isset($_POST['cancel'])) {
        $msg->addFeedback('EXPORT_CANCELLED');
index 4bae4a3..5996d62 100644 (file)
@@ -1354,7 +1354,7 @@ foreach ($items as $item_id => $content_info)
        
        $items[$item_id]['real_content_id'] = $contentDAO->Create($_course_id, intval($content_parent_id), 
                            ($content_info['ordering'] + $my_offset - $lti_offset[$content_info['parent_content_id']] + 1),
-                           $last_modified, 0, $content_formatting, "", $content_info['new_path'], $content_info['title'],
+                           0, $content_formatting, "", $content_info['new_path'], $content_info['title'],
                            $content, $head, 1, $content_info['test_message'], 0, $content_folder_type);
 
 //     $sql= 'INSERT INTO '.TABLE_PREFIX.'content'
index 482e5b1..c398e96 100644 (file)
@@ -16,6 +16,9 @@ require_once(TR_INCLUDE_PATH.'classes/DAO/UserCoursesDAO.class.php');
 
 global $_current_user;
 
+// clean up the course level session vars
+unset($_SESSION['course_id']);
+
 $userCoursesDAO = new UserCoursesDAO();
 
 if (isset($_GET['action'], $_GET['cid']) && $_SESSION['user_id'] > 0)
index eec3c27..0131ab3 100644 (file)
@@ -22,7 +22,7 @@ $body_t               = html_entity_decode($body_text);
                
 
 require(TR_INCLUDE_PATH.'classes/XML/XML_HTMLSax/XML_HTMLSax.php');    /* for XML_HTMLSax */
-//require(TR_INCLUDE_PATH.'../mods/_core/imscp/include/ims_template.inc.php');                         /* for ims templates + print_organizations() */
+require(TR_INCLUDE_PATH.'imscc/ims_template.inc.php');                         /* for ims templates + print_organizations() */
 
 /*
 the following resources are to be identified: