* @uses $CFG
*/
function link_to_popup_window ($url, $name='popup', $linkname='click here',
- $height=400, $width=500, $title='Popup window', $options='none', $return=false) {
+ $height=400, $width=500, $title='Popup window',
+ $options='none', $return=false) {
global $CFG;
}
$output = print_header($course->shortname .': '. $title, $course->fullname .' '. $heading, $shortname .' '. $navigation, $focus, $meta,
- $cache, $button, $menu, $usexml, $bodytags, $return);
+ $cache, $button, $menu, $usexml, $bodytags, true);
if ($return) {
return $output;
* @uses $CFG
* @param string $navigation The breadcrumbs string to be printed
*/
-function print_navigation ($navigation) {
- global $CFG, $USER;
-
- if ($navigation) {
- //Accessibility: breadcrumb links now in a list, » replaced with image.
- $nav_text = get_string('youarehere','access');
- echo '<h2 class="accesshide">'.$nav_text.",</h2><ul>\n";
- if (! $site = get_site()) {
- $site->shortname = get_string('home');
- }
- $navigation = '<li title="'.$nav_text.'"><img src="'.$CFG->pixpath.'/a/r_breadcrumb.gif" class="resize" alt="" /> '
- .str_replace('->', '</li><li title="'.$nav_text.'"><img src="'.$CFG->pixpath.'/a/r_breadcrumb.gif" class="resize" alt="" /> ', $navigation)."</li>\n";
- echo '<li class="first"><a target="'. $CFG->framename .'" href="'. $CFG->wwwroot.((!isadmin() && !empty($USER->id) && !empty($CFG->mymoodleredirect) && !isguest())
+function print_navigation ($navigation, $return=false) {
+ global $CFG, $USER;
+
+ $output = '';
+
+ if ($navigation) {
+ //Accessibility: breadcrumb links now in a list, » replaced with image.
+ $nav_text = get_string('youarehere','access');
+ $output .= '<h2 class="accesshide">'.$nav_text.",</h2><ul>\n";
+ if (! $site = get_site()) {
+ $site->shortname = get_string('home');
+ }
+ $navigation = '<li title="'.$nav_text.'"><img src="'.$CFG->pixpath.'/a/r_breadcrumb.gif" class="resize" alt="" /> '
+ .str_replace('->', '</li><li title="'.$nav_text.'"><img src="'.$CFG->pixpath.'/a/r_breadcrumb.gif" class="resize" alt="" /> ', $navigation)."</li>\n";
+ $output .= '<li class="first"><a target="'. $CFG->framename .'" href="'. $CFG->wwwroot.((!isadmin() && !empty($USER->id) && !empty($CFG->mymoodleredirect) && !isguest())
? '/my' : '') .'/">'. $site->shortname ."</a></li>\n". $navigation;
- echo "</ul>\n";
- }
+ $output .= "</ul>\n";
+ }
+
+ if ($return) {
+ return $output;
+ } else {
+ echo $output;
+ }
}
/**
* @param string $text The text to be displayed
* @param int $size The size to set the font for text display.
*/
-function print_headline($text, $size=2) {
- print_heading($text, 'left', $size);
+function print_headline($text, $size=2, $return=false) {
+ $output = print_heading($text, 'left', $size, true);
+ if ($return) {
+ return $output;
+ } else {
+ echo $output;
+ }
}
/**
* @param string $align The alignment of the printed paragraph of text
* @param int $size The size to set the font for text display.
*/
-function print_heading($text, $align='', $size=2, $class='main') {
+function print_heading($text, $align='', $size=2, $class='main', $return=false) {
if ($align) {
$align = ' align="'.$align.'"';
}
if ($class) {
$class = ' class="'.$class.'"';
}
- echo "<h$size $align $class>".stripslashes_safe($text)."</h$size>";
+ $output = "<h$size $align $class>".stripslashes_safe($text)."</h$size>";
+
+ if ($return) {
+ return $output;
+ } else {
+ echo $output;
+ }
}
/**
* @param string $module The module whose help should be linked to
* @param string $icon Image to display if needed
*/
-function print_heading_with_help($text, $helppage, $module='moodle', $icon='') {
- echo '<h2 class="main help">'.$icon.stripslashes_safe($text);
- helpbutton($helppage, $text, $module);
- echo '</h2>';
+function print_heading_with_help($text, $helppage, $module='moodle', $icon='', $return=false) {
+ $output = '';
+ $output .= '<h2 class="main help">'.$icon.stripslashes_safe($text);
+ $output .= helpbutton($helppage, $text, $module, true, false, '', true);
+ $output .= '</h2>';
+
+ if ($return) {
+ return $output;
+ } else {
+ echo $output;
+ }
}
-function print_heading_block($heading, $class='') {
+function print_heading_block($heading, $class='', $return=false) {
//Accessibility: 'headingblock' is now H1, see theme/standard/styles_*.css: ??
- echo '<h2 class="headingblock header '.$class.'">'.stripslashes($heading).'</h2>';
+ $output = '<h2 class="headingblock header '.$class.'">'.stripslashes($heading).'</h2>';
+
+ if ($return) {
+ return $output;
+ } else {
+ echo $output;
+ }
}
* @uses $CFG
* @param string $link The url to create a link to.
*/
-function print_continue($link) {
+function print_continue($link, $return=false) {
global $CFG;
+ $output = '';
+
if (!$link) {
$link = $_SERVER['HTTP_REFERER'];
}
- echo '<div class="continuebutton">';
- print_single_button($link, NULL, get_string('continue'), 'post', $CFG->framename);
- echo '</div>'."\n";
+ $output .= '<div class="continuebutton">';
+ $output .= print_single_button($link, NULL, get_string('continue'), 'post', $CFG->framename, true);
+ $output .= '</div>'."\n";
+
+ if ($return) {
+ return $output;
+ } else {
+ echo $output;
+ }
}
/**
* @param string $class string, space-separated class names.
* @todo Finish documenting this function
*/
-function print_simple_box($message, $align='', $width='', $color='', $padding=5, $class='generalbox', $id='') {
- print_simple_box_start($align, $width, $color, $padding, $class, $id);
- echo stripslashes_safe($message);
- print_simple_box_end();
+function print_simple_box($message, $align='', $width='', $color='', $padding=5, $class='generalbox', $id='', $return=false) {
+ $output = '';
+ $output .= print_simple_box_start($align, $width, $color, $padding, $class, $id, true);
+ $output .= stripslashes_safe($message);
+ $output .= print_simple_box_end(true);
+
+ if ($return) {
+ return $output;
+ } else {
+ echo $output;
+ }
}
/**
* @param int $padding integer, padding in pixels, specified without units.
* @param string $class string, space-separated class names.
*/
-function print_simple_box_start($align='', $width='', $color='', $padding=5, $class='generalbox', $id='') {
+function print_simple_box_start($align='', $width='', $color='', $padding=5, $class='generalbox', $id='', $return=false) {
+
+ $output = '';
if ($color) {
$color = 'bgcolor="'. $color .'"';
if ($id) {
$id = 'id="'. $id .'"';
}
- echo "<table $align $width $id class=\"$class\" border=\"0\" cellpadding=\"$padding\" cellspacing=\"0\">".
+ $output .= "<table $align $width $id class=\"$class\" border=\"0\" cellpadding=\"$padding\" cellspacing=\"0\">".
"<tr><td $color class=\"$class"."content\">";
+
+ if ($return) {
+ return $output;
+ } else {
+ echo $output;
+ }
}
/**
* Print the end portion of a standard themed box.
*/
-function print_simple_box_end() {
- echo '</td></tr></table>';
+function print_simple_box_end($return=false) {
+ $output = '</td></tr></table>';
+ if ($return) {
+ return $output;
+ } else {
+ echo $output;
+ }
}
* @param string $method ?
* @todo Finish documenting this function
*/
-function print_single_button($link, $options, $label='OK', $method='get', $target='_self') {
- echo '<div class="singlebutton">';
- echo '<form action="'. $link .'" method="'. $method .'" target="'.$target.'">';
+function print_single_button($link, $options, $label='OK', $method='get', $target='_self', $return=false) {
+ $output = '';
+ $output .= '<div class="singlebutton">';
+ $output .= '<form action="'. $link .'" method="'. $method .'" target="'.$target.'">';
if ($options) {
foreach ($options as $name => $value) {
- echo '<input type="hidden" name="'. $name .'" value="'. $value .'" />';
+ $output .= '<input type="hidden" name="'. $name .'" value="'. $value .'" />';
}
}
- echo '<input type="submit" value="'. $label .'" /></form></div>';
+ $output .= '<input type="submit" value="'. $label .'" /></form></div>';
+
+ if ($return) {
+ return $output;
+ } else {
+ echo $output;
+ }
}
/**
* @param boolean $br ?
* @todo Finish documenting this function
*/
-function print_spacer($height=1, $width=1, $br=true) {
+function print_spacer($height=1, $width=1, $br=true, $return=false) {
global $CFG;
- echo '<img class="spacer" height="'. $height .'" width="'. $width .'" src="'. $CFG->wwwroot .'/pix/spacer.gif" alt="" />';
+ $output = '';
+
+ $output .= '<img class="spacer" height="'. $height .'" width="'. $width .'" src="'. $CFG->wwwroot .'/pix/spacer.gif" alt="" />';
if ($br) {
- echo '<br />'."\n";
+ $output .= '<br />'."\n";
+ }
+
+ if ($return) {
+ return $output;
+ } else {
+ echo $output;
}
}
* @param string $link ?
* @todo Finish documenting this function
*/
-function print_file_picture($path, $courseid=0, $height='', $width='', $link='') {
+function print_file_picture($path, $courseid=0, $height='', $width='', $link='', $return=false) {
global $CFG;
+ $output = '';
if ($height) {
$height = 'height="'. $height .'"';
$width = 'width="'. $width .'"';
}
if ($link) {
- echo '<a href="'. $link .'">';
+ $output .= '<a href="'. $link .'">';
}
if (substr(strtolower($path), 0, 7) == 'http://') {
- echo '<img border="0" '.$height . $width .' src="'. $path .'" />';
+ $output .= '<img border="0" '.$height . $width .' src="'. $path .'" />';
} else if ($courseid) {
- echo '<img border="0" '. $height . $width .' src="';
+ $output .= '<img border="0" '. $height . $width .' src="';
if ($CFG->slasharguments) { // Use this method if possible for better caching
- echo $CFG->wwwroot .'/file.php/'. $courseid .'/'. $path;
+ $output .= $CFG->wwwroot .'/file.php/'. $courseid .'/'. $path;
} else {
- echo $CFG->wwwroot .'/file.php?file=/'. $courseid .'/'. $path;
+ $output .= $CFG->wwwroot .'/file.php?file=/'. $courseid .'/'. $path;
}
- echo '" />';
+ $output .= '" />';
} else {
- echo 'Error: must pass URL or course';
+ $output .= 'Error: must pass URL or course';
}
if ($link) {
- echo '</a>';
+ $output .= '</a>';
+ }
+
+ if ($return) {
+ return $output;
+ } else {
+ echo $output;
}
}
* @param int $courseid ?
* @param boolean $picture Print the user picture?
* @param int $size Size in pixels. Special values are (true/1 = 100px) and (false/0 = 35px) for backward compatability
- * @param boolean $returnstring If false print picture to current page, otherwise return the output as string
+ * @param boolean $return If false print picture to current page, otherwise return the output as string
* @param boolean $link Enclose printed image in a link to view specified course?
* return string
* @todo Finish documenting this function
*/
-function print_user_picture($userid, $courseid, $picture, $size=0, $returnstring=false, $link=true, $target='') {
+function print_user_picture($userid, $courseid, $picture, $size=0, $return=false, $link=true, $target='') {
global $CFG;
if ($link) {
$output .= '</a>';
}
- if ($returnstring) {
+ if ($return) {
return $output;
} else {
echo $output;
* @param user $user A {@link $USER} object representing a user
* @param course $course A {@link $COURSE} object representing a course
*/
-function print_user($user, $course, $messageselect=false) {
+function print_user($user, $course, $messageselect=false, $return=false) {
global $CFG, $USER;
+ $output = '';
+
static $string;
static $datestring;
static $countries;
$hiddenfields = array_flip(explode(',', $CFG->hiddenuserfields));
}
- echo '<table class="userinfobox">';
- echo '<tr>';
- echo '<td class="left side">';
- print_user_picture($user->id, $course->id, $user->picture, true);
- echo '</td>';
- echo '<td class="content">';
- echo '<div class="username">'.fullname($user, $isteacher).'</div>';
- echo '<div class="info">';
+ $output .= '<table class="userinfobox">';
+ $output .= '<tr>';
+ $output .= '<td class="left side">';
+ $output .= print_user_picture($user->id, $course->id, $user->picture, true, true);
+ $output .= '</td>';
+ $output .= '<td class="content">';
+ $output .= '<div class="username">'.fullname($user, $isteacher).'</div>';
+ $output .= '<div class="info">';
if (!empty($user->role) and ($user->role <> $course->teacher)) {
- echo $string->role .': '. $user->role .'<br />';
+ $output .= $string->role .': '. $user->role .'<br />';
}
if ($user->maildisplay == 1 or ($user->maildisplay == 2 and $course->category and !isguest()) or $isteacher) {
- echo $string->email .': <a href="mailto:'. $user->email .'">'. $user->email .'</a><br />';
+ $output .= $string->email .': <a href="mailto:'. $user->email .'">'. $user->email .'</a><br />';
}
if (($user->city or $user->country) and (!isset($hiddenfields['city']) or !isset($hiddenfields['country']))) {
- echo $string->location .': ';
+ $output .= $string->location .': ';
if ($user->city && !isset($hiddenfields['city'])) {
- echo $user->city;
+ $output .= $user->city;
}
if (!empty($countries[$user->country]) && !isset($hiddenfields['country'])) {
if ($user->city && !isset($hiddenfields['city'])) {
- echo ', ';
+ $output .= ', ';
}
- echo $countries[$user->country];
+ $output .= $countries[$user->country];
}
- echo '<br />';
+ $output .= '<br />';
}
if (!isset($hiddenfields['lastaccess'])) {
if ($user->lastaccess) {
- echo $string->lastaccess .': '. userdate($user->lastaccess);
- echo '  ('. format_time(time() - $user->lastaccess, $datestring) .')';
+ $output .= $string->lastaccess .': '. userdate($user->lastaccess);
+ $output .= '  ('. format_time(time() - $user->lastaccess, $datestring) .')';
} else {
- echo $string->lastaccess .': '. $string->never;
+ $output .= $string->lastaccess .': '. $string->never;
}
}
- echo '</div></td><td class="links">';
+ $output .= '</div></td><td class="links">';
//link to blogs
if ($CFG->bloglevel > 0) {
- echo '<a href="'.$CFG->wwwroot.'/blog/index.php?userid='.$user->id.'">'.get_string('blogs','blog').'</a><br />';
+ $output .= '<a href="'.$CFG->wwwroot.'/blog/index.php?userid='.$user->id.'">'.get_string('blogs','blog').'</a><br />';
}
-
+
if ($isteacher) {
$timemidnight = usergetmidnight(time());
- echo '<a href="'. $CFG->wwwroot .'/course/user.php?id='. $course->id .'&user='. $user->id .'">'. $string->activity .'</a><br />';
+ $output .= '<a href="'. $CFG->wwwroot .'/course/user.php?id='. $course->id .'&user='. $user->id .'">'. $string->activity .'</a><br />';
if (!iscreator($user->id) or ($isadmin and !isadmin($user->id))) { // Includes admins
if ($course->category and isteacheredit($course->id) and isstudent($course->id, $user->id)) { // Includes admins
- echo '<a href="'. $CFG->wwwroot .'/course/unenrol.php?id='. $course->id .'&user='. $user->id .'">'. $string->unenrol .'</a><br />';
+ $output .= '<a href="'. $CFG->wwwroot .'/course/unenrol.php?id='. $course->id .'&user='. $user->id .'">'. $string->unenrol .'</a><br />';
}
if ($USER->id != $user->id) {
- echo '<a href="'. $CFG->wwwroot .'/course/loginas.php?id='. $course->id .'&user='. $user->id .'">'. $string->loginas .'</a><br />';
+ $output .= '<a href="'. $CFG->wwwroot .'/course/loginas.php?id='. $course->id .'&user='. $user->id .'">'. $string->loginas .'</a><br />';
}
}
}
- echo '<a href="'. $CFG->wwwroot .'/user/view.php?id='. $user->id .'&course='. $course->id .'">'. $string->fullprofile .'...</a>';
+ $output .= '<a href="'. $CFG->wwwroot .'/user/view.php?id='. $user->id .'&course='. $course->id .'">'. $string->fullprofile .'...</a>';
if (!empty($messageselect) && $isteacher) {
- echo '<br /><input type="checkbox" name="';
+ $output .= '<br /><input type="checkbox" name="';
if (isteacher($course->id, $user->id)) {
- echo 'teacher';
+ $output .= 'teacher';
} else {
- echo 'user';
+ $output .= 'user';
}
- echo $user->id.'" /> ';
+ $output .= $user->id.'" /> ';
}
- echo '</td></tr></table>';
+ $output .= '</td></tr></table>';
+
+ if ($return) {
+ return $output;
+ } else {
+ echo $output;
+ }
}
/**
* @param group $group A {@link group} object representing a group or array of groups
* @param int $courseid ?
* @param boolean $large ?
- * @param boolean $returnstring ?
+ * @param boolean $return ?
* @param boolean $link ?
* @return string
* @todo Finish documenting this function
*/
-function print_group_picture($group, $courseid, $large=false, $returnstring=false, $link=true) {
+function print_group_picture($group, $courseid, $large=false, $return=false, $link=true) {
global $CFG;
if (is_array($group)) {
foreach($group as $g) {
$output .= print_group_picture($g, $courseid, $large, true, $link);
}
- if ($returnstring) {
+ if ($return) {
return $output;
} else {
echo $output;
$output .= '</a>';
}
- if ($returnstring) {
+ if ($return) {
return $output;
} else {
echo $output;
* @param string $url ?
* @param int $sizex ?
* @param int $sizey ?
- * @param boolean $returnstring ?
+ * @param boolean $return ?
* @param string $parameters ?
* @todo Finish documenting this function
*/
-function print_png($url, $sizex, $sizey, $returnstring, $parameters='alt=""') {
+function print_png($url, $sizex, $sizey, $return, $parameters='alt=""') {
global $CFG;
static $recentIE;
' '. $parameters .' />';
}
- if ($returnstring) {
+ if ($return) {
return $output;
} else {
echo $output;
return $output;
}
-function print_recent_activity_note($time, $user, $isteacher, $text, $link) {
+function print_recent_activity_note($time, $user, $isteacher, $text, $link, $return=false) {
static $strftimerecent;
+ $output = '';
+
if (empty($strftimerecent)) {
$strftimerecent = get_string('strftimerecent');
}
$date = userdate($time, $strftimerecent);
$name = fullname($user, $isteacher);
- echo '<div class="head">';
- echo '<div class="date">'.$date.'</div> '.
+ $output .= '<div class="head">';
+ $output .= '<div class="date">'.$date.'</div> '.
'<div class="name">'.fullname($user, $isteacher).'</div>';
- echo '</div>';
- echo '<div class="info"><a href="'.$link.'">'.format_string($text,true).'</a></div>';
+ $output .= '</div>';
+ $output .= '<div class="info"><a href="'.$link.'">'.format_string($text,true).'</a></div>';
+
+ if ($return) {
+ return $output;
+ } else {
+ echo $output;
+ }
}
* @param boolean $showall: if set to 0, it is a student in separate groups, do not display all participants
* @todo Finish documenting this function
*/
-function print_group_menu($groups, $groupmode, $currentgroup, $urlroot, $showall=1) {
+function print_group_menu($groups, $groupmode, $currentgroup, $urlroot, $showall=1, $return=false) {
+
+ $output = '';
/// Add an "All groups" to the start of the menu
if ($showall){
$groupsmenu[$key] = $groupname;
}
- echo '<table><tr><td align="right">';
+ $output .= '<table><tr><td align="right">';
if ($groupmode == VISIBLEGROUPS) {
- print_string('groupsvisible');
+ $output .= get_string('groupsvisible');
} else {
- print_string('groupsseparate');
+ $output .= get_string('groupsseparate');
+ }
+ $output .= ':';
+ $output .= '</td><td nowrap="nowrap" align="left">';
+ $output .= popup_form($urlroot.'&group=', $groupsmenu, 'selectgroup', $currentgroup, '', '', '', true, 'self');
+ $output .= '</td></tr></table>';
+
+ if ($return) {
+ return $output;
+ } else {
+ echo $output;
}
- echo ':';
- echo '</td><td nowrap="nowrap" align="left">';
- popup_form($urlroot.'&group=', $groupsmenu, 'selectgroup', $currentgroup, '', '', '', false, 'self');
- echo '</td></tr></table>';
}
* @param boolean $includenograde ?
* @todo Finish documenting this function
*/
-function print_grade_menu($courseid, $name, $current, $includenograde=true) {
+function print_grade_menu($courseid, $name, $current, $includenograde=true, $return=false) {
global $CFG;
+ $output = '';
$strscale = get_string('scale');
$strscales = get_string('scales');
for ($i=100; $i>=1; $i--) {
$grades[$i] = $i;
}
- choose_from_menu($grades, $name, $current, '');
+ $output .= choose_from_menu($grades, $name, $current, '', '', 0, true);
$linkobject = '<span class="helplink"><img height="17" width="17" alt="'.$strscales.'" src="'.$CFG->pixpath .'/help.gif" /></span>';
- link_to_popup_window ('/course/scales.php?id='. $courseid .'&list=true', 'ratingscales',
- $linkobject, 400, 500, $strscales);
+ $output .= link_to_popup_window ('/course/scales.php?id='. $courseid .'&list=true', 'ratingscales',
+ $linkobject, 400, 500, $strscales, 'none', true);
+
+ if ($return) {
+ return $output;
+ } else {
+ echo $output;
+ }
}
/**
* @param string $current ?
* @todo Finish documenting this function
*/
-function print_scale_menu($courseid, $name, $current) {
+function print_scale_menu($courseid, $name, $current, $return=false) {
global $CFG;
+ $output = '';
$strscales = get_string('scales');
- choose_from_menu(get_scales_menu($courseid), $name, $current, '');
+ $output .= choose_from_menu(get_scales_menu($courseid), $name, $current, '', '', 0, true);
$linkobject = '<span class="helplink"><img height="17" width="17" alt="'.$strscales.'" src="'.$CFG->pixpath .'/help.gif" /></span>';
- link_to_popup_window ('/course/scales.php?id='. $courseid .'&list=true', 'ratingscales',
- $linkobject, 400, 500, $strscales);
+ $output .= link_to_popup_window ('/course/scales.php?id='. $courseid .'&list=true', 'ratingscales',
+ $linkobject, 400, 500, $strscales, 'none', true);
+ if ($return) {
+ return $output;
+ } else {
+ echo $output;
+ }
}
/**
* @param object $scale ?
* @todo Finish documenting this function
*/
-function print_scale_menu_helpbutton($courseid, $scale) {
+function print_scale_menu_helpbutton($courseid, $scale, $return=false) {
global $CFG;
+ $output = '';
$strscales = get_string('scales');
$linkobject = '<span class="helplink"><img height="17" width="17" alt="'.$scale->name.'" src="'.$CFG->pixpath .'/help.gif" /></span>';
- link_to_popup_window ('/course/scales.php?id='. $courseid .'&list=true&scaleid='. $scale->id, 'ratingscale',
- $linkobject, 400, 500, $scale->name);
+ $output .= link_to_popup_window ('/course/scales.php?id='. $courseid .'&list=true&scaleid='. $scale->id, 'ratingscale',
+ $linkobject, 400, 500, $scale->name, 'none', true);
+ if ($return) {
+ return $output;
+ } else {
+ echo $output;
+ }
}
/**