]> git.mjollnir.org Git - moodle.git/commitdiff
Apply latest changes from resource type to repository
authorstronk7 <stronk7>
Mon, 24 Apr 2006 23:55:29 +0000 (23:55 +0000)
committerstronk7 <stronk7>
Mon, 24 Apr 2006 23:55:29 +0000 (23:55 +0000)
(double head out, cool resize javascript, XHTML and
navigation menu)

TODO: Fix the 'deploy all' button

mod/resource/type/ims/finder.php
mod/resource/type/ims/preview.php

index 125b160bc76fbcb8204b385b70b78c446ce33f56..d05b46210d021faa220a82d4b5d6b7f21f9bfa61 100644 (file)
@@ -74,7 +74,7 @@
         
         foreach ($items as $item) {
             if ($item->type == 'deployed') {
-                echo "<li><img src='images/ims.gif' /> $item->name (<a href=\"javascript:
+                echo "<li><img src=\"images/ims.gif\" alt=\"IMS CP Package\" /> $item->name (<a href=\"javascript:
                         opener.document.forms['form'].reference.value = '#$item->path'; 
                         opener.document.forms['form'].name.value = '$item->name'; 
                         window.close();
             else if ($item->type == 'not deployed') {
             /// Only displays non-deployed IMS CP's if admin user.
                 if (isadmin()) {
-                    echo "<li><img src='images/ims.gif' /> <em>$item->path - $strnotdeployed</em> (<a href=\"repository_deploy.php?file=$item->path\">$strdeploy</a>)</li>\n";
+                    echo "<li><img src=\"images/ims.gif\" alt=\"IMS CP Package\" /> <em>$item->path - $strnotdeployed</em> (<a href=\"repository_deploy.php?file=$item->path\">$strdeploy</a>)</li>\n";
                 }
             }
             else if ($item->type == 'directory') {
-                echo "<li><img src='images/dir.gif' /> <a href=\"?directory=$item->path\">$item->name</a></li>\n";
+                echo "<li><img src=\"images/dir.gif\" alt=\"IMS CP Package\" /> <a href=\"?directory=$item->path\">$item->name</a></li>\n";
             }
         }
     }
             return;
         }
         else {
-            $output = "<a href=\"?directory=\">$strrepository</a> » ";
+            $output = "<a href=\"?directory=\">$strrepository</a> &#187; ";
         }
         $itemdir = '';
         foreach ($arr as $item) {
             if ($item == '') continue;
             $itemdir .= '/'.$item;
-            $output .= "<a href=\"?directory=$itemdir\">$item</a> » ";
+            $output .= "<a href=\"?directory=$itemdir\">$item</a> &#187; ";
         }
         $output .= $last;
         echo $output;
index 7ba697177a74d2f42b104520167f8824bb4d9828..d3c67b1e85de789ce737feebd2a168c7c288c1cd 100644 (file)
         $direction = ' dir="ltr"';
     }
 
-/// The output here
-
-    echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n";
-    echo "<html$direction>\n";
-    echo '<head>';
-    echo '<meta http-equiv="content-type" content="text/html; charset='.$encoding.'" />';
-    echo "
-    <script type=\"text/javascript\" language=\"javascript\" src=\"dummy.js\"></script>
-    <script language=\"javascript\" type=\"text/javascript\">
-        function resizeiframe () {
-              var winWidth = 0, winHeight = 0;
-              if( typeof( window.innerWidth ) == 'number' ) {
-                //Non-IE
-                winWidth = window.innerWidth;
-                winHeight = window.innerHeight;
-              } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
-                //IE 6+ in 'standards compliant mode'
-                winWidth = document.documentElement.clientWidth;
-                winHeight = document.documentElement.clientHeight;
-              } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
-                //IE 4 compatible
-                winWidth = document.body.clientWidth;
-                winHeight = document.body.clientHeight;
-              }
+/// Conditional argument to pass to IMS JavaScript. Need to be global to retrieve it from our custom javascript! :-(
+    global $jsarg;
+    $jsarg = 'true';
+/// Define $CFG->javascript to use our custom javascript. Save the original one to add it from ours. Global too! :-(
+    global $standard_javascript;
+    $standard_javascript = $CFG->javascript;  // Save original javascript file
+    $CFG->javascript = $CFG->dirroot.'/mod/resource/type/ims/javascript.php';  //Use our custom IMS javascript code
 
-            document.getElementById('ims-preview-contentframe').style.width = (winWidth - 300)+'px';
-            document.getElementById('ims-preview-contentframe').style.height = (winHeight)+'px';
-            document.getElementById('ims-preview-menudiv').style.height = (winHeight)+'px';
-            
-        }
-        
-        window.onresize = resizeiframe;
-        window.onload = resizeiframe;
+/// The output here
 
-    </script>
-    <style type='text/css'>
-        #ims-preview-menudiv {
-            position:absolute;
-            top:0px;
-            left:0px;
-            width:300px;
-            height:100%;
-            overflow:auto;
-        }
-        
-        #ims-preview-contentframe {
-            position:absolute;
-            top:0px;
-            left:300px;
-            height:100%;
-            border:0;
-        }
-    </style>
-    ";
-    echo "<title>Preview</title></head>\n";
 /// moodle header
     print_header();
 /// content - this produces everything else
 
 /// adds side navigation bar if needed. must also adjust width of iframe to accomodate 
-    echo "<div id=\"ims-preview-menudiv\">";  preview_buttons($directory, $items['title']); echo preview_ims_generate_toc($items, $directory); echo "</div>";
+    echo "<div id=\"ims-menudiv\">";  preview_buttons($directory, $items['title']); echo preview_ims_generate_toc($items, $directory, 0, $page); echo "</div>";
     
     $fullurl = "$CFG->repositorywebroot/$directory/".$items[$page]->href;
 /// prints iframe filled with $fullurl ;width:".$iframewidth." missing also height=\"420px\"
-    echo "<iframe id=\"ims-preview-contentframe\" name=\"ims-preview-contentframe\" src=\"{$fullurl}\"></iframe>"; //Content frame 
+    echo "<iframe id=\"ims-contentframe\" name=\"ims-contentframe\" src=\"{$fullurl}\"></iframe>"; //Content frame 
 /// moodle footer
-    echo "</div></div></body></html>";
+    echo "</div></div><script type=\"text/javascript\">resizeiframe($jsarg);</script></body></html>";
     
     
     /*** This function will generate the TOC file for the package
      *   from an specified parent to be used in the view of the IMS
      */
-    function preview_ims_generate_toc($items, $directory, $page=0) {
+    function preview_ims_generate_toc($items, $directory, $page=0, $selected_page) {
         global $CFG;
 
         $contents = '';
 
     /// Configure links behaviour
-        $fullurl = '?directory='.$directory.'&page=';
+        $fullurl = '?directory='.$directory.'&amp;page=';
 
     /// Iterate over items to build the menu
         $currlevel = 0;
         $currorder = 0;
         $endlevel  = 0;
+        $openlielement = false;
         foreach ($items as $item) {
             if (!is_object($item)) {
                 continue;
             /// Start Level 
                 if ($item->level > $currlevel) {
                     $contents .= '<ol class="listlevel_'.$item->level.'">';
+                    $openlielement = false;
                 }
             /// End Level
                 if ($item->level < $currlevel) {
+                    $contents .= '</li>';
                     $contents .= '</ol>';
                 }
+            /// If we have some openlielement, just close it
+                if ($openlielement) {
+                    $contents .= '</li>';
+                }
             /// Add item
                 $contents .= '<li>';
                 if (!empty($item->href)) {
+                    if ($item->id == $selected_page) $contents .= '<div id="ims-toc-selected">';
                     $contents .= '<a href="'.$fullurl.$item->id.'" target="_parent">'.$item->title.'</a>';
+                    if ($item->id == $selected_page) $contents .= '</div>';
                 } else {
                     $contents .= $item->title;
                 }
-                $contents .= '</li>';
                 $currlevel = $item->level;
+                $openlielement = true;
                 continue;
             }
         /// We have reached endlevel, exit
                 break;
             }
         }
-        $contents .= '</ol>';
+    /// Close up to $endlevel
+        for ($i=$currlevel;$i>$endlevel;$i--) {
+            $contents .= '</li>';
+            $contents .= '</ol>';
+        }
 
         return $contents;
     }
               \">$strchoose</a>)</div>";
     }
     
-?>
\ No newline at end of file
+?>