Program resource similar to web page

Re: Program resource similar to web page

by Henry Feldman -
Number of replies: 0

Always good to reply to yourself. If you are interested I altered the resource module to do this. There are 2 sections (copied code from the web page resource case above). The modifications are marked with "//MY HACK HERE" comments. I replaced the exiting section in view.php for the program resource with this: (note code that was not changed is in italics). I make no warranties on whether this works outside my examples that I have tested. If someone is interested in doing a cleaner job of this...


       case PROGRAM:   // Code provided by Mark Kimes <<em>hectorp@buckfoodsvc.com</em>>
            add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", $resource->id, $cm->id);
 
     //MY HACK HERE
     if ($frameset == "top") {
                print_header($pagetitle, "$course->fullname",
                  "$navigation <a target=\"{$CFG->framename}\" href=\"$resource->reference\"
                                title=\"$resource->reference\">$resource->name</a>", "", "", true,
                                update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm, "parent"));
     echo "<center><font size=-1>".text_to_html($resource->summary, true, false)."</font></center>";
   } else {
                if ($CFG->resource_filterexternalpages) {
                    $url = "fetch.php?id=$cm->id&url=$resource->reference";
              } else {
                    $url = "$resource->reference";
                }
   }
            //MY HACK END

            $temptime = gmdate("YmdHis",time());

            $temproot = $CFG->wwwroot . "/mod/resource/";

            // I tried to get around this.  I really did.  But here we
            // are, redefining the navigation resources specifically anyway.
            // On the plus side, you can change the format of the navigation
            // strings above without worrying what it'll do to this code.  On
            // the negative side, you'll have to update this code if you
            // change the structure of the navigation completely.  Bonus
            // is that now we can have a chain of cooperative sites, each
            // adding to the navigation string as it moves down the line,
            // which could be quite cool.  -- Mark

            if ($course->category) {
                $tempref = "<$course->shortname><" . $temproot . "../../course/view.php?id=$course->id>" .
                           "<$strresources><" . $temproot . "index.php?id=$course->id>";
            } else {
                $tempref = "<$strresources><index.php?id=$course->id>";
            }

            $tempurl = trim($resource->reference);

            if ($tempquerystring = strstr($tempurl,'?')) {
                $tempquerystring = substr($tempquerystring,1);
                $tempurl = substr($tempurl,0,strlen($tempurl) - strlen($tempquerystring));
            }
            if (!empty($tempquerystring)) {
                $tempquerystring = preg_replace("/(.*=)([^&]*)/e",
                                                "'\\1' . urlencode('\\2')",
                                                $tempquerystring);
            }
            $temp = $tempurl . $tempquerystring .
                    ((strstr($tempurl,'?')) ? "&amp;" : "?") .
                    "extern_nav=" . urlencode($tempref) .
                    "&amp;extern_usr=" .
                    urlencode($USER->username) .
                    "&amp;extern_nam=" . urlencode("$USER->firstname $USER->lastname") .
                    "&amp;extern_tim=" . urlencode($temptime) .
                    "&amp;extern_pwd=" .
                    urlencode(md5($temptime . $USER->password));


             //MY HACK HERE
                echo "<head><title>$course->shortname: $resource->name</title></head>\n";
                echo "<frameset rows=\"$CFG->resource_framesize,*\" border=\"2\">";
                echo "<frame src=\"view.php?id=$cm->id&frameset=top\">";
                echo "<frame src=\"$temp\">";
                echo "</frameset>";

             //CHIP HACK END
            break;