$string['parameters'] = 'Parameters';
$string['popupresource'] = 'This resource should appear in a popup window.';
$string['popupresourcelink'] = 'If it didn\'t, click here: $a';
+$string['portfolionotimplemented'] = 'You are trying to export content from a resource type that doesn\'t support it!';
$string['preview'] = 'Preview';
$string['previous'] = 'Previous';
$string['redeploy'] = 'Deploy again';
//override to add your own options
}
+ function portfolio_prepare_package_uploaded($tempdir) {
+ // @todo penny implement later - see MDL-15758
+
+ }
+
+ function portfolio_prepare_package_online($tempdir, $text=false) {
+ //@todo penny use the files api here
+ $status = $handle = fopen($tempdir . '/' . clean_filename($this->cm->name . '.' . (($text) ? 'txt' : 'html')), 'w');
+ $formatoptions = new object();
+ $formatoptions->noclean = true;
+ $format = (($text) ? FORMAT_MOODLE : FORMAT_HTML);
+ $content = format_text($this->resource->alltext, $format, $formatoptions, $this->course->id);
+ $status = $status && fwrite($handle, $content);
+ $status = $status && fclose($handle);
+ return $status;
+ }
+
} /// end of class definition
return array('moodle/site:accessallgroups');
}
+require_once($CFG->libdir . '/portfoliolib.php');
+class resource_portfolio_caller extends portfolio_module_caller_base {
+
+ private $resource;
+ private $resourcefile;
+
+ public function __construct($callbackargs) {
+ global $CFG;
+ global $DB;
+ if (!array_key_exists('id', $callbackargs) || !$this->cm = get_coursemodule_from_instance('resource', $callbackargs['id'])) {
+ print_error('invalidid');
+ }
+ $this->cm->type = $DB->get_field('resource', 'type', array('id' => $this->cm->instance));
+ $resourceclass = 'resource_'. $this->cm->type;
+ $this->resourcefile = $CFG->dirroot.'/mod/resource/type/'.$this->cm->type.'/resource.class.php';
+ require_once($this->resourcefile);
+ $this->resource= new $resourceclass($this->cm->id);
+ }
+
+ public function __wakeup() {
+ require_once($this->resourcefile);
+ $this->resource = unserialize(serialize($this->resource));
+ }
+
+ public function expected_time() {
+ // @todo penny check filesize if the type is uploadey
+ return PORTFOLIO_TIME_LOW;
+ }
+
+ public function prepare_package($tempdir) {
+ if (!is_callable(array($this->resource, 'portfolio_prepare_package'))) {
+ portfolio_exporter::raise_error('portfolionotimplemented', 'resource');
+ }
+ return $this->resource->portfolio_prepare_package($tempdir);
+ }
+
+ public static function supported_formats() {
+ return array(PORTFOLIO_FORMAT_FILE);
+ }
+
+ public function check_permissions() {
+ return true;
+ }
+
+ public static function add_button($resource, $fullform=true, $return=false) {
+ // @todo penny can we put the capability check in here?
+ if (!is_callable(array($resource, 'portfolio_prepare_package'))) {
+ debugging(get_string('portfolionotimplemented', 'resource'));
+ return false;
+ }
+ return portfolio_add_button('resource_portfolio_caller', array('id' => $resource->cm->instance), '/mod/resource/lib.php', $fullform, $return);
+ }
+}
+
?>
parent::display_course_blocks_start();
echo format_text($this->resource->alltext, FORMAT_HTML, $formatoptions, $this->course->id);
+ if (true) { //@todo penny replace later with capability check
+ resource_portfolio_caller::add_button($this);
+ }
parent::display_course_blocks_end();
print_header();
print_simple_box(format_text($resource->alltext, FORMAT_HTML, $formatoptions, $course->id),
"center clearfix", "", "", "20");
+ if (true) { //@todo penny replace later with capability check
+ resource_portfolio_caller::add_button($this);
+ }
print_footer($course);
} else { /// Make a page and a pop-up window
$navigation = build_navigation($this->navlinks, $cm);
navmenu($course, $cm));
print_simple_box(format_text($resource->alltext, FORMAT_HTML, $formatoptions, $course->id), "center clearfix", "", "", "20");
+ if (true) { //@todo penny replace later with capability check
+ resource_portfolio_caller::add_button($this);
+ }
$strlastmodified = get_string("lastmodified");
echo "<div class=\"modified\">$strlastmodified: ".userdate($resource->timemodified)."</div>";
}
}
+function portfolio_prepare_package($tempdir) {
+ return parent::portfolio_prepare_package_online($tempdir);
+}
+
}
if (trim(strip_tags($this->resource->alltext))) {
echo format_text($this->resource->alltext, FORMAT_MOODLE, $formatoptions, $this->course->id);
+ if (true) { //@todo penny replace later with capability check
+ resource_portfolio_caller::add_button($this);
+ }
}
parent::display_course_blocks_end();
print_simple_box(format_text($resource->alltext, $resource->reference, $formatoptions, $course->id),
"center", "", "", "20");
print_footer($course);
+ if (true) { //@todo penny replace later with capability check
+ resource_portfolio_caller::add_button($this);
+ }
} else { /// Make a page and a pop-up window
$navigation = build_navigation($this->navlinks, $cm);
print_simple_box(format_text($resource->alltext, $resource->reference, $formatoptions, $course->id),
"center", "", "", "20");
+ if (true) { //@todo penny replace later with capability check
+ resource_portfolio_caller::add_button($this);
+ }
$strlastmodified = get_string("lastmodified");
echo "<div class=\"modified\">$strlastmodified: ".userdate($resource->timemodified)."</div>";
}
+function portfolio_prepare_package($tempdir) {
+ return parent::portfolio_prepare_package_online($tempdir, true);
+}
}
?>