diff --git a/lang/en_utf8/portfolio.php b/lang/en_utf8/portfolio.php index d9341351a1c..df1d805fbce 100644 --- a/lang/en_utf8/portfolio.php +++ b/lang/en_utf8/portfolio.php @@ -33,6 +33,7 @@ $string['instanceismisconfigured'] = 'Portfolio instance is misconfigured, skipp $string['instancenotsaved'] = 'Failed to save portfolio'; $string['instancenotdelete'] = 'Failed to delete portfolio'; $string['instancesaved'] = 'Portfolio saved successfully'; +$string['invalidaddformat'] = 'Invalid add format passed to portfolio_add_button. ($a) Must be one of PORTFOLIO_ADD_XXX'; $string['invalidtempid'] = 'Invalid export id. maybe it has expired'; $string['invalidformat'] = 'Something is exporting an invalid format, $a'; $string['invalidinstance'] = 'Could not find that portfolio instance'; diff --git a/lib/portfoliolib.php b/lib/portfoliolib.php index 750278c70c2..b53bdc8ceea 100644 --- a/lib/portfoliolib.php +++ b/lib/portfoliolib.php @@ -113,6 +113,34 @@ define('PORTFOLIO_TIME_MODERATE', 'moderate'); */ define('PORTFOLIO_TIME_HIGH', 'high'); +// ************************************************** // +// available ways to add the portfolio export to a page +// ************************************************** // + +/** +* a whole form, containing a drop down menu (where necessary) +* and a submit button +*/ +define('PORTFOLIO_ADD_FULL_FORM', 1); + + +/** +* a whole form, containing a drop down menu (where necessary) +* but has an icon instead of a button to submit +*/ +define('PORTFOLIO_ADD_ICON_FORM', 2); + +/** +* just an icon with a link around it (yuk, as will result in a long url +* only use where necessary) +*/ +define('PORTFOLIO_ADD_ICON_LINK', 3); + +/** +* just some text with a link around it (yuk, as will result in a long url +* only use where necessary) +*/ +define('PORTFOLIO_ADD_TEXT_LINK', 4); /** * entry point to add an 'add to portfolio' button somewhere in moodle @@ -131,12 +159,14 @@ define('PORTFOLIO_TIME_HIGH', 'high'); * but more often, the caller is a script.php and the class in a lib.php * so you can pass it here if necessary. * this path should be relative (ie, not include) dirroot -* @param boolean $fullform either display the fullform with the dropmenu of available instances -* or just a small icon (which will trigger instance selection in a new screen) -* optional, defaults to true. +* @param int $format format to display the button or form or icon or link. +* See constants PORTFOLIO_ADD_XXX for more info. +* optional, defaults to PORTFOLI_ADD_FULL_FORM +* @param str $addstr string to use for the button or icon alt text or link text. +* this is whole string, not key. optional, defaults to 'Add to portfolio'; * @param boolean $return whether to echo or return content (optional defaults to false (echo) */ -function portfolio_add_button($callbackclass, $callbackargs, $callbackfile=null, $fullform=true, $return=false) { +function portfolio_add_button($callbackclass, $callbackargs, $callbackfile=null, $format=PORTFOLIO_ADD_FULL_FORM, $addstr=null, $return=false) { global $SESSION, $CFG, $COURSE, $USER; @@ -177,7 +207,8 @@ function portfolio_add_button($callbackclass, $callbackargs, $callbackfile=null, $callersupports = call_user_func(array($callbackclass, 'supported_formats')); - $output = '
'; - + if (empty($format)) { + $format = PORTFOLIO_ADD_FULL_FORM; + } + switch ($format) { + case PORTFOLIO_ADD_FULL_FORM: + $formoutput .= $selectoutput; + $formoutput .= "\n" . ''; + $formoutput .= "\n" . ''; + break; + case PORTFOLIO_ADD_ICON_FORM: + $formoutput .= $selectoutput; + $formoutput .= "\n" . ''; + $formoutput .= "\n" . ''; + break; + case PORTFOLIO_ADD_ICON_LINK: + $linkoutput .= '">
';
+ break;
+ case PORTFOLIO_ADD_TEXT_LINK:
+ $linkoutput .= '">' . $addstr .'';
+ break;
+ default:
+ debugging('asdfd');
+ print_error('invalidaddformat', 'portfolio', '', $format);
+ }
+ $output = (in_array($format, array(PORTFOLIO_ADD_FULL_FORM, PORTFOLIO_ADD_ICON_FORM)) ? $formoutput : $linkoutput);
if ($return) {
return $output;
} else {
diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php
index d256dd1227b..30ef3c3bf5b 100644
--- a/mod/assignment/lib.php
+++ b/mod/assignment/lib.php
@@ -1715,13 +1715,13 @@ class assignment_base {
$output .= '| ';
diff --git a/mod/forum/lib.php b/mod/forum/lib.php
index cedbd3026c9..3c88ccf74f7 100644
--- a/mod/forum/lib.php
+++ b/mod/forum/lib.php
@@ -3112,7 +3112,8 @@ function forum_print_post($post, $discussion, $forum, &$cm, $course, $ownpost=fa
$p = array(
'postid' => $post->id,
);
- //$commands[] = portfolio_add_button('forum_portfolio_caller', $p, '/mod/forum/lib.php', false, true);
+ // @todo penny check these arguments when uncommenting
+ //$commands[] = portfolio_add_button('forum_portfolio_caller', $p, '/mod/forum/lib.php', PORTFOLIO_ADD_TEXT_LINK, null, true);
}
echo ' ';
@@ -3880,7 +3881,8 @@ function forum_print_attachments($post, $return=NULL) {
'postid' => $post->id,
'attachment' => 1,
);
- //$output .= portfolio_add_button('forum_portfolio_caller', $p, '/mod/forum/lib.php', false, true);
+ // @todo penny check these arguments when uncommenting
+ //$output .= portfolio_add_button('forum_portfolio_caller', $p, '/mod/forum/lib.php', PORTFOLIO_ADD_ICON_FORM, null, true);
}
$output .= "
libdir . '/portfoliolib.php');
- $p = array(
- 'id' => $cm->id,
- );
- portfolio_add_button('glossary_csv_portfolio_caller', $p, '/mod/glossary/lib.php');
+ if ($DB->count_records('glossary_entries', array('glossaryid' => $glossary->id)) && true) { // @todo penny capability check
+ require_once($CFG->libdir . '/portfoliolib.php');
+ $p = array(
+ 'id' => $cm->id,
+ );
+ portfolio_add_button('glossary_csv_portfolio_caller', $p, '/mod/glossary/lib.php');
+ }
print_box_end();
print_footer($course);
?>
diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php
index 9408a8ac350..6e8b3a99339 100644
--- a/mod/glossary/lib.php
+++ b/mod/glossary/lib.php
@@ -866,7 +866,7 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode='',$h
'id' => $cm->id,
'entryid' => $entry->id,
);
- $return .= portfolio_add_button('glossary_entry_portfolio_caller', $p, false, false, true);
+ $return .= portfolio_add_button('glossary_entry_portfolio_caller', $p, null, PORTFOLIO_ADD_ICON_LINK, null, true);
}
$return .= " "; // just to make up a little the output in Mozilla ;)
diff --git a/mod/resource/lib.php b/mod/resource/lib.php
index 8bb207cade2..1d9964b3906 100644
--- a/mod/resource/lib.php
+++ b/mod/resource/lib.php
@@ -746,7 +746,7 @@ class resource_portfolio_caller extends portfolio_module_caller_base {
return has_capability('mod/resource:exportresource', get_context_instance(CONTEXT_MODULE, $this->cm->id));
}
- public static function add_button($resource, $fullform=true, $return=false) {
+ public static function add_button($resource, $format=null, $return=false) {
if (!has_capability('mod/resource:exportresource', get_context_instance(CONTEXT_MODULE, $resource->cm->id))) {
return;
}
@@ -754,7 +754,7 @@ class resource_portfolio_caller extends portfolio_module_caller_base {
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);
+ return portfolio_add_button('resource_portfolio_caller', array('id' => $resource->cm->instance), '/mod/resource/lib.php', $format, null, $return);
}
public function get_sha1() {
"; @@ -3899,7 +3901,8 @@ function forum_print_attachments($post, $return=NULL) { 'postid' => $post->id, 'attachment' => 1, ); - //portfolio_add_button('forum_portfolio_caller', $p, '/mod/forum/lib.php', false); + // @todo penny check these arguments when uncommenting + //portfolio_add_button('forum_portfolio_caller', $p, '/mod/forum/lib.php', PORTFOLIO_ADD_ICON_FORM); } echo ' '; } diff --git a/mod/glossary/export.php b/mod/glossary/export.php index 40df63eacae..d5f0d88707d 100644 --- a/mod/glossary/export.php +++ b/mod/glossary/export.php @@ -57,11 +57,13 @@ |