Permalink
Browse files

Added a check for isset($this->resource->reference) to prevent warnin…

…gs in resource_ims

Added a check for is_object($item) to prevent warnings in ims_generate_toc
Restored use of textlib in ims_generate_toc
  • Loading branch information...
wildgirl
wildgirl committed Apr 20, 2006
1 parent 8c9814f commit 676fb87edccc35ec4292538998680e38041be955
Showing with 17 additions and 9 deletions.
  1. +17 −9 mod/resource/type/ims/resource.class.php
@@ -64,14 +64,19 @@ function resource_ims($cmid=0) {
$this->parameters->skipsubmenus = 1;
}
+ //echo "<pre>"; print_r($this->resource); echo "</pre>";
+
/// Is it in the repository material or not?
- $file = $this->resource->reference;
- if ($file[0] == '#') {
- $this->isrepository = true;
- $file = ltrim($file, '#');
- $this->resource->reference = $file;
- }
- else {
+ if (isset($this->resource->reference)) {
+ $file = $this->resource->reference;
+ if ($file[0] == '#') {
+ $this->isrepository = true;
+ $file = ltrim($file, '#');
+ $this->resource->reference = $file;
+ } else {
+ $this->isrepository = false;
+ }
+ } else {
$this->isrepository = false;
}
}
@@ -803,10 +808,13 @@ function ims_generate_toc($items, $resource, $page=0, $selected_page = -1) {
$currorder = 0;
$endlevel = 0;
foreach ($items as $item) {
+ if (!is_object($item)) {
+ continue;
+ }
/// Convert text from UTF-8 to current charset if needed
if (empty($CFG->unicodedb)) {
-//// $textlib = textlib_get_instance();
-//// $item->title = $textlib->convert($item->title, 'UTF-8', current_charset());
+ $textlib = textlib_get_instance();
+ $item->title = $textlib->convert($item->title, 'UTF-8', current_charset());
}
/// Skip pages until we arrive to $page
if ($item->id < $page) {

0 comments on commit 676fb87

Please sign in to comment.