Exemple #1
0
/**
 * Print a message along with "Ok" link for the user to continue and "Cancel" link to close window.
 *
 * @param string $message The text to display
 * @param string $linkok The link to take the user to if they choose "Ok"
 * TODO Document remaining arguments
 */
function notice_okcancel($message, $linkok, $optionsok = NULL, $methodok = 'post')
{
    global $CFG;
    $message = clean_text($message);
    $linkok = clean_text($linkok);
    print_box_start('generalbox', 'notice');
    echo '<p>' . $message . '</p>';
    echo '<div class="buttons">';
    print_single_button($linkok, $optionsok, get_string('ok'), $methodok, $CFG->framename);
    close_window_button('cancel');
    echo '</div>';
    print_box_end();
}
Exemple #2
0
function iplookup_display($ip, $user = 0)
{
    print_header();
    if ($user) {
        if ($user = get_record('user', 'id', $user)) {
            print_heading(fullname($user) . ", {$user->city}, {$user->country}", 'center', '4');
        }
    }
    echo 'Search results: <iframe src="http://www.hostip.info/api/get.html?ip=' . $ip . '" height="60" width="300"></iframe>';
    echo '<object data="http://www.hostip.info/map/frame.html?ip=' . $ip . '" ' . 'type="text/html" border="0" width="610" height="330"></object>';
    close_window_button();
    print_footer('none');
}
Exemple #3
0
    }
    print_box_end();
}
print_box_start('generalbox info');
echo filter_text(text_to_html($course->summary), $course->id);
if ($managerroles = get_config('', 'coursemanager')) {
    $coursemanagerroles = split(',', $managerroles);
    foreach ($coursemanagerroles as $roleid) {
        $role = get_record('role', 'id', $roleid);
        $canseehidden = has_capability('moodle/role:viewhiddenassigns', $context);
        $roleid = (int) $roleid;
        if ($users = get_role_users($roleid, $context, true, '', 'u.lastname ASC', $canseehidden)) {
            foreach ($users as $teacher) {
                $fullname = fullname($teacher, has_capability('moodle/site:viewfullnames', $context));
                $namesarray[] = format_string($role->name) . ': <a href="' . $CFG->wwwroot . '/user/view.php?id=' . $teacher->id . '&amp;course=' . SITEID . '">' . $fullname . '</a>';
            }
        }
    }
    if (!empty($namesarray)) {
        echo "<ul class=\"teachers\">\n<li>";
        echo implode('</li><li>', $namesarray);
        echo "</li></ul>";
    }
}
require_once "{$CFG->dirroot}/enrol/enrol.class.php";
$enrol = enrolment_factory::factory($course->enrol);
echo $enrol->get_access_icons($course);
print_box_end();
echo "<br />";
close_window_button();
print_footer();
 /**
  * Display the file resource
  *
  * Displays a file resource embedded, in a frame, or in a popup.
  * Output depends on type of file resource.
  *
  * @param    CFG     global object
  */
 function display()
 {
     global $CFG, $THEME, $USER;
     /// Set up generic stuff first, including checking for access
     parent::display();
     /// Set up some shorthand variables
     $cm = $this->cm;
     $course = $this->course;
     $resource = $this->resource;
     $this->set_parameters();
     // set the parameters array
     ///////////////////////////////////////////////
     /// Possible display modes are:
     /// File displayed in a frame in a normal window
     /// File displayed embedded in a normal page
     /// File displayed in a popup window
     /// File displayed emebedded in a popup window
     /// First, find out what sort of file we are dealing with.
     require_once $CFG->libdir . '/filelib.php';
     $querystring = '';
     $resourcetype = '';
     $embedded = false;
     $mimetype = mimeinfo("type", $resource->reference);
     $pagetitle = strip_tags($course->shortname . ': ' . format_string($resource->name));
     $formatoptions = new object();
     $formatoptions->noclean = true;
     if ($resource->options != "bogusoption_usedtobe_frame") {
         // TODO nicolasconnault 14-03-07: This option should be renamed "embed"
         if (in_array($mimetype, array('image/gif', 'image/jpeg', 'image/png'))) {
             // It's an image
             $resourcetype = "image";
             $embedded = true;
         } else {
             if ($mimetype == "audio/mp3") {
                 // It's an MP3 audio file
                 $resourcetype = "mp3";
                 $embedded = true;
             } else {
                 if ($mimetype == "video/x-flv") {
                     // It's a Flash video file
                     $resourcetype = "flv";
                     $embedded = true;
                 } else {
                     if (substr($mimetype, 0, 10) == "video/x-ms") {
                         // It's a Media Player file
                         $resourcetype = "mediaplayer";
                         $embedded = true;
                     } else {
                         if ($mimetype == "video/quicktime") {
                             // It's a Quicktime file
                             $resourcetype = "quicktime";
                             $embedded = true;
                         } else {
                             if ($mimetype == "application/x-shockwave-flash") {
                                 // It's a Flash file
                                 $resourcetype = "flash";
                                 $embedded = true;
                             } else {
                                 if ($mimetype == "video/mpeg") {
                                     // It's a Mpeg file
                                     $resourcetype = "mpeg";
                                     $embedded = true;
                                 } else {
                                     if ($mimetype == "text/html") {
                                         // It's a web page
                                         $resourcetype = "html";
                                     } else {
                                         if ($mimetype == "application/zip") {
                                             // It's a zip archive
                                             $resourcetype = "zip";
                                             $embedded = true;
                                         } else {
                                             if ($mimetype == 'application/pdf' || $mimetype == 'application/x-pdf') {
                                                 $resourcetype = "pdf";
                                                 $embedded = true;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $isteamspeak = stripos($resource->reference, 'teamspeak://') === 0;
     /// Form the parse string
     if (!empty($resource->alltext)) {
         $querys = array();
         $parray = explode(',', $resource->alltext);
         foreach ($parray as $fieldstring) {
             $field = explode('=', $fieldstring);
             $querys[] = urlencode($field[1]) . '=' . urlencode($this->parameters[$field[0]]['value']);
         }
         if ($isteamspeak) {
             $querystring = implode('?', $querys);
         } else {
             $querystring = implode('&amp;', $querys);
         }
     }
     /// Set up some variables
     $inpopup = optional_param('inpopup', 0, PARAM_BOOL);
     if (resource_is_url($resource->reference)) {
         $fullurl = $resource->reference;
         if (!empty($querystring)) {
             $urlpieces = parse_url($resource->reference);
             if (empty($urlpieces['query']) or $isteamspeak) {
                 $fullurl .= '?' . $querystring;
             } else {
                 $fullurl .= '&amp;' . $querystring;
             }
         }
     } else {
         if ($CFG->resource_allowlocalfiles and strpos($resource->reference, RESOURCE_LOCALPATH) === 0) {
             // Localpath
             $localpath = get_user_preferences('resource_localpath', 'D:');
             $relativeurl = str_replace(RESOURCE_LOCALPATH, $localpath, $resource->reference);
             if ($querystring) {
                 $relativeurl .= '?' . $querystring;
             }
             $relativeurl = str_replace('\\', '/', $relativeurl);
             $relativeurl = str_replace(' ', '%20', $relativeurl);
             $fullurl = 'file:///' . htmlentities($relativeurl);
             $localpath = true;
         } else {
             // Normal uploaded file
             if ($CFG->slasharguments) {
                 $relativeurl = "/file.php/{$course->id}/{$resource->reference}";
                 if ($querystring) {
                     $relativeurl .= '?' . $querystring;
                 }
             } else {
                 $relativeurl = "/file.php?file=/{$course->id}/{$resource->reference}";
                 if ($querystring) {
                     $relativeurl .= '&amp;' . $querystring;
                 }
             }
             $fullurl = "{$CFG->wwwroot}{$relativeurl}";
         }
     }
     /// Print a notice and redirect if we are trying to access a file on a local file system
     /// and the config setting has been disabled
     if (!$CFG->resource_allowlocalfiles and strpos($resource->reference, RESOURCE_LOCALPATH) === 0) {
         if ($inpopup) {
             print_header($pagetitle, $course->fullname);
         } else {
             $this->navlinks[] = array('name' => format_string($resource->name), 'link' => null, 'type' => 'misc');
             $this->navigation = build_navigation($this->navlinks);
             print_header($pagetitle, $course->fullname, $this->navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));
         }
         notify(get_string('notallowedlocalfileaccess', 'resource', ''));
         if ($inpopup) {
             close_window_button();
         }
         print_footer('none');
         die;
     }
     /// Check whether this is supposed to be a popup, but was called directly
     if ($resource->popup and !$inpopup) {
         /// Make a page and a pop-up window
         $this->navlinks[] = array('name' => format_string($resource->name), 'link' => null, 'type' => 'misc');
         $this->navigation = build_navigation($this->navlinks);
         print_header($pagetitle, $course->fullname, $this->navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));
         echo "\n<script type=\"text/javascript\">";
         echo "\n<!--\n";
         echo "openpopup('/mod/resource/view.php?inpopup=true&id={$cm->id}','resource{$resource->id}','{$resource->popup}');\n";
         echo "\n-->\n";
         echo '</script>';
         if (trim(strip_tags($resource->summary))) {
             print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions), "center");
         }
         $link = "<a href=\"{$CFG->wwwroot}/mod/resource/view.php?inpopup=true&amp;id={$cm->id}\" " . "onclick=\"this.target='resource{$resource->id}'; return openpopup('/mod/resource/view.php?inpopup=true&amp;id={$cm->id}', " . "'resource{$resource->id}','{$resource->popup}');\">" . format_string($resource->name, true) . "</a>";
         echo '<div class="popupnotice">';
         print_string('popupresource', 'resource');
         echo '<br />';
         print_string('popupresourcelink', 'resource', $link);
         echo '</div>';
         print_footer($course);
         exit;
     }
     /// Now check whether we need to display a frameset
     $frameset = optional_param('frameset', '', PARAM_ALPHA);
     if (empty($frameset) and !$embedded and !$inpopup and $resource->options == "frame" and empty($USER->screenreader)) {
         @header('Content-Type: text/html; charset=utf-8');
         echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n";
         echo "<html dir=\"ltr\">\n";
         echo '<head>';
         echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
         echo "<title>" . format_string($course->shortname) . ": " . strip_tags(format_string($resource->name, true)) . "</title></head>\n";
         echo "<frameset rows=\"{$CFG->resource_framesize},*\">";
         echo "<frame src=\"view.php?id={$cm->id}&amp;type={$resource->type}&amp;frameset=top\" title=\"" . get_string('modulename', 'resource') . "\"/>";
         if (!empty($localpath)) {
             // Show it like this so we interpose some HTML
             echo "<frame src=\"view.php?id={$cm->id}&amp;type={$resource->type}&amp;inpopup=true\" title=\"" . get_string('modulename', 'resource') . "\"/>";
         } else {
             echo "<frame src=\"{$fullurl}\" title=\"" . get_string('modulename', 'resource') . "\"/>";
         }
         echo "</frameset>";
         echo "</html>";
         exit;
     }
     /// We can only get here once per resource, so add an entry to the log
     add_to_log($course->id, "resource", "view", "view.php?id={$cm->id}", $resource->id, $cm->id);
     /// If we are in a frameset, just print the top of it
     if (!empty($frameset) and $frameset == "top") {
         $this->navlinks[] = array('name' => format_string($resource->name), 'link' => null, 'type' => 'misc');
         $this->navigation = build_navigation($this->navlinks);
         print_header($pagetitle, $course->fullname, $this->navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "parent"));
         $options = new object();
         $options->para = false;
         echo '<div class="summary">' . format_text($resource->summary, FORMAT_HTML, $options) . '</div>';
         if (!empty($localpath)) {
             // Show some help
             echo '<div align="right" class="helplink">';
             link_to_popup_window('/mod/resource/type/file/localpath.php', get_string('localfile', 'resource'), get_string('localfilehelp', 'resource'), 400, 500, get_string('localfilehelp', 'resource'));
             echo '</div>';
         }
         echo '</div></div></body></html>';
         exit;
     }
     /// Display the actual resource
     if ($embedded) {
         // Display resource embedded in page
         $strdirectlink = get_string("directlink", "resource");
         if ($inpopup) {
             print_header($pagetitle);
         } else {
             $this->navlinks[] = array('name' => format_string($resource->name, true), 'link' => $fullurl, 'type' => 'misc');
             $this->navigation = build_navigation($this->navlinks);
             print_header_simple($pagetitle, '', $this->navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "self"));
         }
         if ($resourcetype == "image") {
             echo '<div class="resourcecontent resourceimg">';
             echo "<img title=\"" . strip_tags(format_string($resource->name, true)) . "\" class=\"resourceimage\" src=\"{$fullurl}\" alt=\"\" />";
             echo '</div>';
         } else {
             if ($resourcetype == "mp3") {
                 if (!empty($THEME->resource_mp3player_colors)) {
                     $c = $THEME->resource_mp3player_colors;
                     // You can set this up in your theme/xxx/config.php
                 } else {
                     $c = 'bgColour=000000&btnColour=ffffff&btnBorderColour=cccccc&iconColour=000000&' . 'iconOverColour=00cc00&trackColour=cccccc&handleColour=ffffff&loaderColour=ffffff&' . 'font=Arial&fontColour=FF33FF&buffer=10&waitForPlay=no&autoPlay=yes';
                 }
                 $c .= '&volText=' . get_string('vol', 'resource') . '&panText=' . get_string('pan', 'resource');
                 $c = htmlentities($c);
                 $id = 'filter_mp3_' . time();
                 //we need something unique because it might be stored in text cache
                 $cleanurl = addslashes_js($fullurl);
                 // If we have Javascript, use UFO to embed the MP3 player, otherwise depend on plugins
                 echo '<div class="resourcecontent resourcemp3">';
                 echo '<span class="mediaplugin mediaplugin_mp3" id="' . $id . '"></span>' . '<script type="text/javascript">' . "\n" . '//<![CDATA[' . "\n" . 'var FO = { movie:"' . $CFG->wwwroot . '/lib/mp3player/mp3player.swf?src=' . $cleanurl . '",' . "\n" . 'width:"600", height:"70", majorversion:"6", build:"40", flashvars:"' . $c . '", quality: "high" };' . "\n" . 'UFO.create(FO, "' . $id . '");' . "\n" . '//]]>' . "\n" . '</script>' . "\n";
                 echo '<noscript>';
                 echo "<object type=\"audio/mpeg\" data=\"{$fullurl}\" width=\"600\" height=\"70\">";
                 echo "<param name=\"src\" value=\"{$fullurl}\" />";
                 echo '<param name="quality" value="high" />';
                 echo '<param name="autoplay" value="true" />';
                 echo '<param name="autostart" value="true" />';
                 echo '</object>';
                 echo '<p><a href="' . $fullurl . '">' . $fullurl . '</a></p>';
                 echo '</noscript>';
                 echo '</div>';
             } else {
                 if ($resourcetype == "flv") {
                     $id = 'filter_flv_' . time();
                     //we need something unique because it might be stored in text cache
                     $cleanurl = addslashes_js($fullurl);
                     // If we have Javascript, use UFO to embed the FLV player, otherwise depend on plugins
                     echo '<div class="resourcecontent resourceflv">';
                     echo '<span class="mediaplugin mediaplugin_flv" id="' . $id . '"></span>' . '<script type="text/javascript">' . "\n" . '//<![CDATA[' . "\n" . 'var FO = { movie:"' . $CFG->wwwroot . '/filter/mediaplugin/flvplayer.swf?file=' . $cleanurl . '",' . "\n" . 'width:"600", height:"400", majorversion:"6", build:"40", allowscriptaccess:"never", quality: "high" };' . "\n" . 'UFO.create(FO, "' . $id . '");' . "\n" . '//]]>' . "\n" . '</script>' . "\n";
                     echo '<noscript>';
                     echo "<object type=\"video/x-flv\" data=\"{$fullurl}\" width=\"600\" height=\"400\">";
                     echo "<param name=\"src\" value=\"{$fullurl}\" />";
                     echo '<param name="quality" value="high" />';
                     echo '<param name="autoplay" value="true" />';
                     echo '<param name="autostart" value="true" />';
                     echo '</object>';
                     echo '<p><a href="' . $fullurl . '">' . $fullurl . '</a></p>';
                     echo '</noscript>';
                     echo '</div>';
                 } else {
                     if ($resourcetype == "mediaplayer") {
                         echo '<div class="resourcecontent resourcewmv">';
                         echo '<object type="video/x-ms-wmv" data="' . $fullurl . '">';
                         echo '<param name="controller" value="true" />';
                         echo '<param name="autostart" value="true" />';
                         echo "<param name=\"src\" value=\"{$fullurl}\" />";
                         echo '<param name="scale" value="noScale" />';
                         echo "<a href=\"{$fullurl}\">{$fullurl}</a>";
                         echo '</object>';
                         echo '</div>';
                     } else {
                         if ($resourcetype == "mpeg") {
                             echo '<div class="resourcecontent resourcempeg">';
                             echo '<object classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
                           codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsm p2inf.cab#Version=5,1,52,701"
                           type="application/x-oleobject">';
                             echo "<param name=\"fileName\" value=\"{$fullurl}\" />";
                             echo '<param name="autoStart" value="true" />';
                             echo '<param name="animationatStart" value="true" />';
                             echo '<param name="transparentatStart" value="true" />';
                             echo '<param name="showControls" value="true" />';
                             echo '<param name="Volume" value="-450" />';
                             echo '<!--[if !IE]>-->';
                             echo '<object type="video/mpeg" data="' . $fullurl . '">';
                             echo '<param name="controller" value="true" />';
                             echo '<param name="autostart" value="true" />';
                             echo "<param name=\"src\" value=\"{$fullurl}\" />";
                             echo "<a href=\"{$fullurl}\">{$fullurl}</a>";
                             echo '<!--<![endif]-->';
                             echo '<a href="' . $fullurl . '">' . $fullurl . '</a>';
                             echo '<!--[if !IE]>-->';
                             echo '</object>';
                             echo '<!--<![endif]-->';
                             echo '</object>';
                             echo '</div>';
                         } else {
                             if ($resourcetype == "quicktime") {
                                 echo '<style type="text/css">';
                                 echo '/* class to hide nested objects in IE */';
                                 echo '/* hides the second object from all versions of IE */';
                                 echo '* html object.hiddenObjectForIE { display: none; }';
                                 echo '/* display the second object only for IE5 Mac */';
                                 echo '/* IE Mac \\*//*/';
                                 echo '* html object.hiddenObjectForIE { display: inline; }';
                                 echo '/**/';
                                 echo '</style>';
                                 echo '<div class="resourcecontent resourceqt">';
                                 echo '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"';
                                 echo '        codebase="http://www.apple.com/qtactivex/qtplugin.cab">';
                                 echo "<param name=\"src\" value=\"{$fullurl}\" />";
                                 echo '<param name="autoplay" value="true" />';
                                 echo '<param name="loop" value="true" />';
                                 echo '<param name="controller" value="true" />';
                                 echo '<param name="scale" value="aspect" />';
                                 echo "<object class=\"hiddenObjectForIE\" type=\"video/quicktime\" data=\"{$fullurl}\">";
                                 echo '<param name="controller" value="true" />';
                                 echo '<param name="autoplay" value="true" />';
                                 echo '<param name="loop" value="true" />';
                                 echo '<param name="scale" value="aspect" />';
                                 echo '</object>';
                                 echo '<a href="' . $fullurl . '">' . $fullurl . '</a>';
                                 echo '</object>';
                                 echo '</div>';
                             } else {
                                 if ($resourcetype == "flash") {
                                     echo '<div class="resourcecontent resourceswf">';
                                     echo '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">';
                                     echo "<param name=\"movie\" value=\"{$fullurl}\" />";
                                     echo '<param name="autoplay" value="true" />';
                                     echo '<param name="loop" value="true" />';
                                     echo '<param name="controller" value="true" />';
                                     echo '<param name="scale" value="aspect" />';
                                     echo '<!--[if !IE]>-->';
                                     echo "<object type=\"application/x-shockwave-flash\" data=\"{$fullurl}\">";
                                     echo '<param name="controller" value="true" />';
                                     echo '<param name="autoplay" value="true" />';
                                     echo '<param name="loop" value="true" />';
                                     echo '<param name="scale" value="aspect" />';
                                     echo '<!--<![endif]-->';
                                     echo '<a href="' . $fullurl . '">' . $fullurl . '</a>';
                                     echo '<!--[if !IE]>-->';
                                     echo '</object>';
                                     echo '<!--<![endif]-->';
                                     echo '</object>';
                                     echo '</div>';
                                 } elseif ($resourcetype == 'zip') {
                                     echo '<div class="resourcepdf">';
                                     echo get_string('clicktoopen', 'resource') . '<a href="' . $fullurl . '">' . format_string($resource->name) . '</a>';
                                     echo '</div>';
                                 } elseif ($resourcetype == 'pdf') {
                                     echo '<div class="resourcepdf">';
                                     echo '<object data="' . $fullurl . '" type="application/pdf">';
                                     echo get_string('clicktoopen', 'resource') . '<a href="' . $fullurl . '">' . format_string($resource->name) . '</a>';
                                     echo '</object>';
                                     echo '</div>';
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if (trim($resource->summary)) {
             print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center");
         }
         if ($inpopup) {
             echo "<div class=\"popupnotice\">(<a href=\"{$fullurl}\">{$strdirectlink}</a>)</div>";
         } else {
             print_spacer(20, 20);
             print_footer($course);
         }
     } else {
         // Display the resource on it's own
         if (!empty($localpath)) {
             // Show a link to help work around browser security
             echo '<div align="right" class="helplink">';
             link_to_popup_window('/mod/resource/type/file/localpath.php', get_string('localfile', 'resource'), get_string('localfilehelp', 'resource'), 400, 500, get_string('localfilehelp', 'resource'));
             echo '</div>';
             echo "<div class=\"popupnotice\">(<a href=\"{$fullurl}\">{$fullurl}</a>)</div>";
         }
         redirect($fullurl);
     }
 }
function install_print_help_page($help)
{
    global $CFG;
    @header('Content-Type: text/html; charset=UTF-8');
    @header('Cache-Control: no-store, no-cache, must-revalidate');
    @header('Cache-Control: post-check=0, pre-check=0', false);
    @header('Pragma: no-cache');
    @header('Expires: Mon, 20 Aug 1969 09:23:00 GMT');
    @header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
    echo '<html dir="' . (right_to_left() ? 'rtl' : 'ltr') . '">
          <head>
          <link rel="shortcut icon" href="theme/standard/favicon.ico" />
          <link rel="stylesheet" type="text/css" href="' . $CFG->wwwroot . '/install.php?css=1" />
          <title>' . get_string('installation', 'install') . '</title>
          <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
          <meta http-equiv="pragma" content="no-cache" />
          <meta http-equiv="expires" content="0" />';
    echo '</head><body>';
    switch ($help) {
        case 'phpversionhelp':
            print_string($help, 'install', phpversion());
            break;
        case 'memorylimithelp':
            print_string($help, 'install', get_memory_limit());
            break;
        default:
            print_string($help, 'install');
    }
    close_window_button();
    echo '</body></html>';
    die;
}
Exemple #6
0
 /**
  * Display the file resource
  *
  * Displays a file resource embedded, in a frame, or in a popup.
  * Output depends on type of file resource.
  *
  * @param    CFG     global object
  */
 function display()
 {
     global $CFG, $THEME, $USER;
     require_once $CFG->libdir . '/filelib.php';
     /// Set up generic stuff first, including checking for access
     parent::display();
     /// Set up some shorthand variables
     $cm = $this->cm;
     $course = $this->course;
     $resource = $this->resource;
     /// Fetch parameters
     $inpopup = optional_param('inpopup', 0, PARAM_BOOL);
     $page = optional_param('page', 0, PARAM_INT);
     $frameset = optional_param('frameset', '', PARAM_ALPHA);
     /// Init some variables
     $errorcode = 0;
     $buttontext = 0;
     $querystring = '';
     $resourcetype = '';
     $mimetype = mimeinfo("type", $resource->reference);
     $pagetitle = strip_tags($course->shortname . ': ' . format_string($resource->name));
     $formatoptions = new object();
     $formatoptions->noclean = true;
     /// Cache this per request
     static $items;
     /// Check for errors
     $errorcode = $this->check4errors($resource->reference, $course, $resource);
     /// If there are any error, show it instead of the resource page
     if ($errorcode) {
         if (!has_capability('moodle/course:activityvisibility', get_context_instance(CONTEXT_COURSE, $course->id))) {
             /// Resource not available page
             $errortext = get_string('resourcenotavailable', 'resource');
         } else {
             /// Depending of the error, show different messages and pages
             if ($errorcode == 1) {
                 $errortext = get_string('invalidfiletype', 'error', $resource->reference);
             } else {
                 if ($errorcode == 2) {
                     $errortext = get_string('filenotfound', 'error', $resource->reference);
                 } else {
                     if ($errorcode == 3) {
                         $errortext = get_string('packagenotdeplyed', 'resource');
                     } else {
                         if ($errorcode == 4) {
                             $errortext = get_string('packagechanged', 'resource');
                         } else {
                             if ($errorcode == 5) {
                                 $errortext = get_string('packagenotdeplyed', 'resource');
                                 // no button though since from repository.
                             }
                         }
                     }
                 }
             }
         }
         /// Display the error and exit
         if ($inpopup) {
             print_header($pagetitle, $course->fullname . ' : ' . $resource->name);
         } else {
             $navigation = build_navigation($this->navlinks, $cm);
             print_header($pagetitle, $course->fullname, $navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), user_login_string($course) . '<hr style="width:95%">' . navmenu($course, $cm));
         }
         print_simple_box_start('center', '60%');
         echo '<p align="center">' . $errortext . '</p>';
         /// If errors were 3 or 4 and isteacheredit(), show the deploy button
         if (has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $course->id)) && ($errorcode == 3 || $errorcode == 4)) {
             $link = 'type/ims/deploy.php';
             $options['courseid'] = $course->id;
             $options['cmid'] = $cm->id;
             $options['file'] = $resource->reference;
             $options['sesskey'] = $USER->sesskey;
             $options['inpopup'] = $inpopup;
             if ($errorcode == 3) {
                 $label = get_string('deploy', 'resource');
             } else {
                 if ($errorcode == 4) {
                     $label = get_string('redeploy', 'resource');
                 }
             }
             $method = 'post';
             /// Let's go with the button
             echo '<center>';
             print_single_button($link, $options, $label, $method);
             echo '</center>';
         }
         print_simple_box_end();
         /// Close button if inpopup
         if ($inpopup) {
             close_window_button();
         }
         print_footer();
         exit;
     }
     /// Load serialized IMS CP index to memory only once.
     if (empty($items)) {
         if (!$this->isrepository) {
             $resourcedir = $CFG->dataroot . '/' . $course->id . '/' . $CFG->moddata . '/resource/' . $resource->id;
         } else {
             $resourcedir = $CFG->repository . $resource->reference;
         }
         if (!($items = ims_load_serialized_file($resourcedir . '/moodle_inx.ser'))) {
             error(get_string('errorreadingfile', 'error', 'moodle_inx.ser'));
         }
     }
     /// Check whether this is supposed to be a popup, but was called directly
     if (empty($frameset) && $resource->popup && !$inpopup) {
         /// Make a page and a pop-up window
         $navigation = build_navigation($this->navlinks, $cm);
         print_header($pagetitle, $course->fullname, $navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), user_login_string($course) . '<hr style="width:95%">' . navmenu($course, $cm));
         echo "\n<script type=\"text/javascript\">";
         echo "\n<!--\n";
         echo "openpopup('/mod/resource/view.php?inpopup=true&id={$cm->id}','resource{$resource->id}','{$resource->popup}');\n";
         echo "\n-->\n";
         echo '</script>';
         if (trim(strip_tags($resource->summary))) {
             print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions), "center");
         }
         $link = "<a href=\"{$CFG->wwwroot}/mod/resource/view.php?inpopup=true&amp;id={$cm->id}\" target=\"resource{$resource->id}\" onclick=\"return openpopup('/mod/resource/view.php?inpopup=true&amp;id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">" . format_string($resource->name, true) . "</a>";
         echo "<p>&nbsp;</p>";
         echo '<p align="center">';
         print_string('popupresource', 'resource');
         echo '<br />';
         print_string('popupresourcelink', 'resource', $link);
         echo "</p>";
         print_footer($course);
         exit;
     }
     /// No frames or framesets anymore, except iframe. in print_ims, iframe filled.
     /// needs callback to this file to display table of contents in the iframe so
     /// $frameset = 'toc' leads to output of toc and blank or 'ims' produces the
     /// iframe.
     if (empty($frameset) || $frameset == 'ims') {
         /// Conditional argument to pass to IMS JavaScript. Need to be global to retrieve it from our custom javascript! :-(
         global $jsarg;
         $jsarg = 'false';
         if (!empty($this->parameters->navigationmenu)) {
             $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
         /// moodle header
         if ($resource->popup) {
             //print_header($pagetitle, $course->fullname.' : '.$resource->name);
             print_header();
         } else {
             $navigation = build_navigation($this->navlinks, $cm);
             print_header($pagetitle, $course->fullname, $navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), user_login_string($course) . '<hr style="width:95%">' . navmenu($course, $cm, "parent"));
         }
         /// content - this produces everything else
         $this->print_ims($cm, $course, $items, $resource, $page);
         print_footer('empty');
         /// log it.
         add_to_log($course->id, "resource", "view", "view.php?id={$cm->id}", $resource->id, $cm->id);
         exit;
     }
     if ($frameset == 'toc') {
         print_header();
         $this->print_toc($items, $resource, $page);
         echo '</div></div></body></html>';
         exit;
     }
 }
 /**
 * Display the repository resource
 *
 * Displays a repository resource embedded, in a frame, or in a popup.
 * Output depends on type of file resource.
 *
 * @param    CFG     global object
 */
 function display()
 {
     global $CFG, $THEME, $SESSION;
     /// Set up generic stuff first, including checking for access
     parent::display();
     /// Set up some shorthand variables
     $cm = $this->cm;
     $course = $this->course;
     $resource = $this->resource;
     $this->set_parameters();
     // set the parameters array
     ///////////////////////////////////////////////
     /// Possible display modes are:
     /// File displayed in a frame in a normal window
     /// File displayed embedded in a normal page
     /// File displayed in a popup window
     /// File displayed emebedded in a popup window
     /// First, find out what sort of file we are dealing with.
     require_once $CFG->libdir . '/filelib.php';
     $querystring = '';
     $resourcetype = '';
     $embedded = false;
     $mimetype = mimeinfo("type", $resource->reference);
     $pagetitle = strip_tags($course->shortname . ': ' . format_string($resource->name));
     $formatoptions = new object();
     $formatoptions->noclean = true;
     if ($resource->options != "frame") {
         if (in_array($mimetype, array('image/gif', 'image/jpeg', 'image/png'))) {
             // It's an image
             $resourcetype = "image";
             $embedded = true;
         } else {
             if ($mimetype == "audio/mp3") {
                 // It's an MP3 audio file
                 $resourcetype = "mp3";
                 $embedded = true;
             } else {
                 if (substr($mimetype, 0, 10) == "video/x-ms") {
                     // It's a Media Player file
                     $resourcetype = "mediaplayer";
                     $embedded = true;
                 } else {
                     if ($mimetype == "video/quicktime") {
                         // It's a Quicktime file
                         $resourcetype = "quicktime";
                         $embedded = true;
                     } else {
                         if ($mimetype == "text/html") {
                             // It's a web page
                             $resourcetype = "html";
                         }
                     }
                 }
             }
         }
     }
     $navigation = build_navigation($this->navlinks, $cm);
     /// Form the parse string
     if (!empty($resource->alltext)) {
         $querys = array();
         $parray = explode(',', $resource->alltext);
         foreach ($parray as $fieldstring) {
             $field = explode('=', $fieldstring);
             $querys[] = urlencode($field[1]) . '=' . urlencode($this->parameters[$field[0]]['value']);
         }
         $querystring = implode('&amp;', $querys);
     }
     /// Set up some variables
     $inpopup = optional_param('inpopup', 0, PARAM_BOOL);
     $fullurl = $resource->reference . '&amp;HIVE_SESSION=' . $SESSION->HIVE_SESSION;
     if (!empty($querystring)) {
         $urlpieces = parse_url($resource->reference);
         if (empty($urlpieces['query'])) {
             $fullurl .= '?' . $querystring;
         } else {
             $fullurl .= '&amp;' . $querystring;
         }
     }
     /// MW check that the HIVE_SESSION is there
     if (empty($SESSION->HIVE_SESSION)) {
         if ($inpopup) {
             print_header($pagetitle, $course->fullname);
         } else {
             print_header($pagetitle, $course->fullname, $navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));
         }
         notify('You do not have access to HarvestRoad Hive. This resource is unavailable.');
         if ($inpopup) {
             close_window_button();
         }
         print_footer('none');
         die;
     }
     /// MW END
     /// Check whether this is supposed to be a popup, but was called directly
     if ($resource->popup and !$inpopup) {
         /// Make a page and a pop-up window
         print_header($pagetitle, $course->fullname, $navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));
         echo "\n<script type=\"text/javascript\">";
         echo "\n<!--\n";
         echo "openpopup('/mod/resource/view.php?inpopup=true&id={$cm->id}','resource{$resource->id}','{$resource->popup}');\n";
         echo "\n-->\n";
         echo '</script>';
         if (trim(strip_tags($resource->summary))) {
             $formatoptions->noclean = true;
             print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions), "center");
         }
         $link = "<a href=\"{$CFG->wwwroot}/mod/resource/view.php?inpopup=true&amp;id={$cm->id}\" target=\"resource{$resource->id}\" onclick=\"return openpopup('/mod/resource/view.php?inpopup=true&amp;id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">" . format_string($resource->name, true) . "</a>";
         echo "<p>&nbsp;</p>";
         echo '<p align="center">';
         print_string('popupresource', 'resource');
         echo '<br />';
         print_string('popupresourcelink', 'resource', $link);
         echo "</p>";
         print_footer($course);
         exit;
     }
     /// Now check whether we need to display a frameset
     $frameset = optional_param('frameset', '', PARAM_ALPHA);
     if (empty($frameset) and !$embedded and !$inpopup and $resource->options == "frame" and empty($USER->screenreader)) {
         echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n";
         echo "<html dir=\"ltr\">\n";
         echo '<head>';
         echo '<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />';
         echo "<title>" . format_string($course->shortname) . ": " . strip_tags(format_string($resource->name, true)) . "</title></head>\n";
         echo "<frameset rows=\"{$CFG->resource_framesize},*\">";
         echo "<frame src=\"view.php?id={$cm->id}&amp;type={$resource->type}&amp;frameset=top\" title=\"" . get_string('modulename', 'resource') . "\"/>";
         echo "<frame src=\"{$fullurl}\" title=\"" . get_string('modulename', 'resource') . "\"/>";
         echo "</frameset>";
         echo "</html>";
         exit;
     }
     /// We can only get here once per resource, so add an entry to the log
     add_to_log($course->id, "resource", "view", "view.php?id={$cm->id}", $resource->id, $cm->id);
     /// If we are in a frameset, just print the top of it
     if (!empty($frameset) and $frameset == "top") {
         print_header($pagetitle, $course->fullname, $navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "parent"));
         echo '<div class="summary">' . format_text($resource->summary, FORMAT_HTML, $formatoptions) . '</div>';
         echo '</body></html>';
         exit;
     }
     /// Display the actual resource
     if ($embedded) {
         // Display resource embedded in page
         $strdirectlink = get_string("directlink", "resource");
         if ($inpopup) {
             print_header($pagetitle);
         } else {
             print_header($pagetitle, $course->fullname, $navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "self"));
         }
         if ($resourcetype == "image") {
             echo "<center><p>";
             echo "<img title=\"" . strip_tags(format_string($resource->name, true)) . "\" class=\"resourceimage\" src=\"{$fullurl}\" alt=\"\" />";
             echo "</p></center>";
         } else {
             if ($resourcetype == "mp3") {
                 if (!empty($THEME->resource_mp3player_colors)) {
                     $c = $THEME->resource_mp3player_colors;
                     // You can set this up in your theme/xxx/config.php
                 } else {
                     $c = 'bgColour=000000&btnColour=ffffff&btnBorderColour=cccccc&iconColour=000000&' . 'iconOverColour=00cc00&trackColour=cccccc&handleColour=ffffff&loaderColour=ffffff&' . 'font=Arial&fontColour=3333FF&buffer=10&waitForPlay=no&autoPlay=yes';
                 }
                 $c .= '&volText=' . get_string('vol', 'resource') . '&panText=' . get_string('pan', 'resource');
                 $c = htmlentities($c);
                 echo '<div class="mp3player" align="center">';
                 echo '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
                 echo '        codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ';
                 echo '        width="600" height="70" id="mp3player" align="">';
                 echo '<param name="movie" value="' . $CFG->wwwroot . '/lib/mp3player/mp3player.swf?src=' . $fullurl . '">';
                 echo '<param name="quality" value="high">';
                 echo '<param name="bgcolor" value="#333333">';
                 echo '<param name="flashvars" value="' . $c . '&amp;" />';
                 echo '<embed src="' . $CFG->wwwroot . '/lib/mp3player/mp3player.swf?src=' . $fullurl . '" ';
                 echo ' quality="high" bgcolor="#333333" width="600" height="70" name="mp3player" ';
                 echo ' type="application/x-shockwave-flash" ';
                 echo ' flashvars="' . $c . '&amp;" ';
                 echo ' pluginspage="http://www.macromedia.com/go/getflashplayer">';
                 echo '</embed>';
                 echo '</object>';
                 echo '</div>';
             } else {
                 if ($resourcetype == "mediaplayer") {
                     echo "<center><p>";
                     echo '<object classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95"';
                     echo '        codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" ';
                     echo '        standby="Loading Microsoft� Windows� Media Player components..." ';
                     echo '        id="msplayer" align="" type="application/x-oleobject">';
                     echo "<param name=\"Filename\" value=\"{$fullurl}\">";
                     echo '<param name="ShowControls" value="true" />';
                     echo '<param name="AutoRewind" value="true" />';
                     echo '<param name="AutoStart" value="true" />';
                     echo '<param name="Autosize" value="true" />';
                     echo '<param name="EnableContextMenu" value="true" />';
                     echo '<param name="TransparentAtStart" value="false" />';
                     echo '<param name="AnimationAtStart" value="false" />';
                     echo '<param name="ShowGotoBar" value="false" />';
                     echo '<param name="EnableFullScreenControls" value="true" />';
                     echo "\n<embed src=\"{$fullurl}\" name=\"msplayer\" type=\"{$mimetype}\" ";
                     echo ' ShowControls="1" AutoRewind="1" AutoStart="1" Autosize="0" EnableContextMenu="1"';
                     echo ' TransparentAtStart="0" AnimationAtStart="0" ShowGotoBar="0" EnableFullScreenControls="1"';
                     echo ' pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/">';
                     echo '</embed>';
                     echo '</object>';
                     echo "</p></center>";
                 } else {
                     if ($resourcetype == "quicktime") {
                         echo "<center><p>";
                         echo '<object classid="CLSID:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"';
                         echo '        codebase="http://www.apple.com/qtactivex/qtplugin.cab" ';
                         echo '        height="450" width="600"';
                         echo '        id="quicktime" align="" type="application/x-oleobject">';
                         echo "<param name=\"src\" value=\"{$fullurl}\" />";
                         echo '<param name="autoplay" value="true" />';
                         echo '<param name="loop" value="true" />';
                         echo '<param name="controller" value="true" />';
                         echo '<param name="scale" value="aspect" />';
                         echo "\n<embed src=\"{$fullurl}\" name=\"quicktime\" type=\"{$mimetype}\" ";
                         echo ' height="450" width="600" scale="aspect"';
                         echo ' autoplay="true" controller="true" loop="true" ';
                         echo ' pluginspage="http://quicktime.apple.com/">';
                         echo '</embed>';
                         echo '</object>';
                         echo "</p></center>";
                     }
                 }
             }
         }
         if (trim($resource->summary)) {
             $formatoptions->noclean = true;
             print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center");
         }
         if ($inpopup) {
             echo "<center><p>(<a href=\"{$fullurl}\">{$strdirectlink}</a>)</p></center>";
         } else {
             print_spacer(20, 20);
             print_footer($course);
         }
     } else {
         // Display the resource on it's own
         redirect($fullurl);
     }
 }
echo '<center>';
echo '<input type="submit" name="reset" value="' . get_string('resetcategories', 'repository_alfresco') . '" /><br />' . get_string('resetcategoriesdesc', 'repository_alfresco') . '<br /><br />';
if ($categories = $repo->category_get_children(0)) {
    echo '<input type="button" value="' . get_string('selectall') . '" onclick="checkall();" />';
    echo '&nbsp;<input type="button" value="' . get_string('deselectall') . '" onclick="checknone();" /><br />';
    echo '<input type="submit" value="' . get_string('savechanges') . '" />';
    echo '</center><br />';
    if ($nodes = repository_alfresco_make_category_select_tree_choose($categories, $catfilter)) {
        $menu = new HTML_TreeMenu();
        for ($i = 0; $i < count($nodes); $i++) {
            $menu->addItem($nodes[$i]);
        }
        $treemenu =& new HTML_TreeMenu_DHTML($menu, array('images' => $CFG->wwwroot . '/lib/HTML_TreeMenu-1.2.0/images'));
        echo '<script language="JavaScript" type="text/javascript">';
        echo "<!--\n";
        include $CFG->libdir . '/HTML_TreeMenu-1.2.0/TreeMenu.js';
        echo "\n// -->";
        echo '</script>';
        $treemenu->printMenu();
    }
    echo '<center><br />';
    echo '<input type="button" value="' . get_string('selectall') . '" onclick="checkall();" />';
    echo '&nbsp;<input type="button" value="' . get_string('deselectall') . '" onclick="checknone();" /><br />';
    echo '<input type="submit" value="' . get_string('savechanges') . '" /> ' . close_window_button('closewindow', true);
} else {
    print_heading(get_string('nocategoriesfound', 'repository_alfresco'));
}
echo '</center>';
echo '</form>';
print_simple_box_end();
print_footer('empty');
        echo '<div id="netpublish-rights' . $count . '" style="display: ' . $display . ';">';
        if (count($chunks) != 1) {
            // only show heading with multiple pages
            print_heading(get_string('page', 'netpublish') . " {$countplus}", 'center', 4);
        }
        print_table($table);
        echo '</div>';
        $display = "none";
        $count++;
    }
    echo '<div style="padding:10px;" align="center">';
    if (count($chunks) != 1) {
        // only show links on multiple pages
        echo implode(', ', $links);
    }
    echo '<p>' . close_window_button() . '</p></div>';
    // close window
    // this is where we generate hidden fields to keep track of students that
    // have been checked, but not already printed out
    foreach ($read as $readhidden) {
        echo '<input type="hidden" id="read" name="read[]" value="' . $readhidden . '" />';
    }
    foreach ($write as $writehidden) {
        echo '<input type="hidden" id="write" name="write[]" value="' . $writehidden . '" />';
    }
    echo '</form>';
} else {
    echo '<div align="center">';
    print_string('nostudentsfound', 'netpublish');
    echo '</div>';
}
function questionnaire_preview($questionnaire)
{
    global $CFG;
    /// Print the page header
    /// Templates may not have questionnaires yet...
    $tempsid = $questionnaire->survey->id;
    // this is needed for Preview cases later on
    if (!isset($questionnaire->name)) {
        $name = get_field('questionnaire_survey', 'name', 'id', $tempsid);
        $questionnaire->sid = $tempsid;
        $questionnaire->add_questions($tempsid);
    } else {
        $name = $questionnaire->name;
    }
    $qp = get_string('preview_questionnaire', 'questionnaire');
    $pq = get_string('previewing', 'questionnaire');
    $currentcss = '';
    if (!empty($questionnaire->survey->theme)) {
        $currentcss = '<link rel="stylesheet" type="text/css" href="' . $CFG->wwwroot . '/mod/questionnaire/css/' . $questionnaire->survey->theme . '" />';
    } else {
        $currentcss = '<link rel="stylesheet" type="text/css" href="' . $CFG->wwwroot . '/mod/questionnaire/css/default.css" />';
    }
    $course = $questionnaire->course;
    print_header($course->shortname . $qp, $course->fullname . $pq . $name, '', '', $currentcss, false);
    /// Print the main part of the page
    $SESSION->questionnaire_survey_id = $tempsid;
    if (isset($formdata->sid) && $formdata->sid != 0) {
        $sid = $SESSION->questionnaire_survey_id = $formdata->sid;
    } else {
        $sid = $SESSION->questionnaire_survey_id;
    }
    $questionnaire->survey = get_record('questionnaire_survey', 'id', $sid);
    $n = count_records('questionnaire_question', 'survey_id', $sid, 'type_id', '99', 'deleted', 'n');
    for ($i = 1; $i < $n + 2; $i++) {
        $questionnaire->survey_render($i, '', $formdata);
    }
    close_window_button();
    echo '</div></div></body></html>';
    break;
}
    ?>
    <script type="text/javascript">
    //<![CDATA[
    function set_value(txt) {
        opener.document.getElementById('<?php 
    echo $chooseparts[0];
    ?>
').value = txt;
        window.close();
    }
    //]]>
    </script>

<?php 
}
$icon = 'folder.gif';
$eicon = 'folder-expanded.gif';
$menu = new HTML_TreeMenu();
if ($nodes = $repo->make_root_folder_select_tree()) {
    for ($i = 0; $i < count($nodes); $i++) {
        $menu->addItem($nodes[$i]);
    }
}
$treemenu =& new HTML_TreeMenu_DHTML($menu, array('images' => $CFG->wwwroot . '/lib/HTML_TreeMenu-1.2.0/images'));
require_js($CFG->wwwroot . '/lib/HTML_TreeMenu-1.2.0/TreeMenu.js');
print_simple_box_start('center', '75%');
print_heading(get_string('chooserootfolder', 'repository_alfresco') . ':', 'center', '3');
$treemenu->printMenu();
print_simple_box_end();
echo '<br /><br /><center>' . close_window_button('closewindow', true) . '</center>';
print_footer('empty');
 /**
  * Displays the browsing page
  * 
  * @param int category course category id
  * @param int selected course id of previously selected course
  */
 function displayPage($category = 0, $selected = 0)
 {
     global $CFG;
     require_js($CFG->wwwroot . '/curriculum/js/moodlecourseurl.js');
     if (!($site = get_site())) {
         error('Site isn\'t defined!');
     }
     $strcourses = get_string('courses');
     $strcategories = get_string('categories');
     $navigation = array('newnav' => 1, 'navlinks' => '');
     // Build root breadcrumb
     $navigation['navlinks'] = '<li class="first"><a onclick="this.target=\'_top\'" href="' . $CFG->wwwroot . '/curriculum/coursetemplatepage.php?class=' . $this->_templateType . '&selected=' . $selected . '">Root</a></li><li class="first"> ';
     // Build breadcrumb of course subcategories
     $navigation['navlinks'] .= $this->buildNavLinks($category, '');
     print_header_simple($site->fullname, $site->shortname, $navigation, '', '', true, '', false, '', true);
     $categories = $this->getSubCategories($category);
     echo '<form name="moodlecourseurl">' . "\n";
     foreach ($categories as $key => $category) {
         echo $this->printCategories($category, true, $selected);
         $courses = $this->getCourses($category->id);
         $courses = !empty($courses) ? $courses : array();
         foreach ($courses as $key2 => $course) {
             echo $this->printCourses($course);
         }
         if (empty($courses)) {
             echo get_string('no_courses', 'block_curr_admin');
         }
     }
     // Add call to highlight previously selected course
     echo '<script language=javascript >';
     echo 'selectedCourse(' . $selected . ', \'old\');';
     echo '</script>';
     echo $this->addCss();
     echo '</form>' . "\n";
     echo '<br />';
     close_window_button();
 }