예제 #1
0
 public function get_topic_data($instance)
 {
     $topic_data = '';
     $topic_file = $this->get_external_xml($instance['resource_indentifier']);
     if (!empty($topic_file)) {
         $topic_file_path = cc2moodle::$path_to_manifest_folder . DIRECTORY_SEPARATOR . $topic_file;
         $topic_file_dir = dirname($topic_file_path);
         $topic = $this->load_xml_resource($topic_file_path);
         if (!empty($topic)) {
             $xpath = cc2moodle::newx_path($topic, cc2moodle::getforumns());
             $topic_title = $xpath->query('/dt:topic/title');
             $topic_title = !empty($topic_title->item(0)->nodeValue) ? $topic_title->item(0)->nodeValue : 'Untitled Topic';
             $topic_text = $xpath->query('/dt:topic/text');
             $topic_text = !empty($topic_text->item(0)->nodeValue) ? $this->update_sources($topic_text->item(0)->nodeValue, dirname($topic_file)) : '';
             $topic_text = !empty($topic_text) ? str_replace("%24", "\$", $this->include_titles($topic_text)) : '';
             if (!empty($topic_title)) {
                 $topic_data['title'] = $topic_title;
                 $topic_data['description'] = $topic_text;
             }
         }
         $topic_attachments = $xpath->query('/dt:topic/attachments/attachment/@href');
         if ($topic_attachments->length > 0) {
             $attachment_html = '';
             foreach ($topic_attachments as $file) {
                 $attachment_html .= $this->generate_attachment_html($this->full_path($file->nodeValue, '/'));
             }
             $topic_data['description'] = !empty($attachment_html) ? $topic_text . '<p>Attachments:</p>' . $attachment_html : $topic_text;
         }
     }
     return $topic_data;
 }