function require_variable($var) {
/// Variable must be present
if (! isset($var)) {
- error("A required parameter was missing");
+ error('A required parameter was missing');
}
}
$CFG->$name = $value; // So it's defined for this invocation at least
- if (get_field("config", "name", "name", $name)) {
- return set_field("config", "value", $value, "name", $name);
+ if (get_field('config', 'name', 'name', $name)) {
+ return set_field('config', 'value', $value, 'name', $name);
} else {
$config->name = $name;
$config->value = $value;
- return insert_record("config", $config);
+ return insert_record('config', $config);
}
}
}
if ($preference = get_record('user_preferences', 'userid', $user->id, 'name', $name)) {
- if (set_field("user_preferences", "value", $value, "id", $preference->id)) {
+ if (set_field('user_preferences', 'value', $value, 'id', $preference->id)) {
$user->preference[$name] = $value;
return true;
} else {
$totalsecs = abs($totalsecs);
if (!$str) { // Create the str structure the slow way
- $str->day = get_string("day");
- $str->days = get_string("days");
- $str->hour = get_string("hour");
- $str->hours = get_string("hours");
- $str->min = get_string("min");
- $str->mins = get_string("mins");
- $str->sec = get_string("sec");
- $str->secs = get_string("secs");
+ $str->day = get_string('day');
+ $str->days = get_string('days');
+ $str->hour = get_string('hour');
+ $str->hours = get_string('hours');
+ $str->min = get_string('min');
+ $str->mins = get_string('mins');
+ $str->sec = get_string('sec');
+ $str->secs = get_string('secs');
}
$days = floor($totalsecs/86400);
$sh = ($hours == 1) ? $str->hour : $str->hours;
$sd = ($days == 1) ? $str->day : $str->days;
- $odays = "";
- $ohours = "";
- $omins = "";
- $osecs = "";
+ $odays = '';
+ $ohours = '';
+ $omins = '';
+ $osecs = '';
- if ($days) $odays = "$days $sd";
- if ($hours) $ohours = "$hours $sh";
- if ($mins) $omins = "$mins $sm";
- if ($secs) $osecs = "$secs $ss";
+ if ($days) $odays = $days .' '. $sd;
+ if ($hours) $ohours = $hours .' '. $sh;
+ if ($mins) $omins = $mins .' '. $sm;
+ if ($secs) $osecs = $secs .' '. $ss;
- if ($days) return "$odays $ohours";
- if ($hours) return "$ohours $omins";
- if ($mins) return "$omins $osecs";
- if ($secs) return "$osecs";
- return get_string("now");
+ if ($days) return $odays .' '. $ohours;
+ if ($hours) return $ohours .' '. $omins;
+ if ($mins) return $omins .' '. $osecs;
+ if ($secs) return $osecs;
+ return get_string('now');
}
-function userdate($date, $format="", $timezone=99, $fixday = true) {
+function userdate($date, $format='', $timezone=99, $fixday = true) {
/// Returns a formatted string that represents a date in user time
/// WARNING: note that the format is for strftime(), not date().
/// Because of a bug in most Windows time libraries, we can't use
/// If parammeter fixday = true (default), then take off leading
/// zero from %d, else mantain it.
- if ($format == "") {
- $format = get_string("strftimedaydatetime");
+ if ($format == '') {
+ $format = get_string('strftimedaydatetime');
}
- $formatnoday = str_replace("%d", "DD", $format);
+ $formatnoday = str_replace('%d', 'DD', $format);
if ($fixday) {
$fixday = ($formatnoday != $format);
}
if (abs($timezone) > 13) {
if ($fixday) {
$datestring = strftime($formatnoday, $date);
- $daystring = str_replace(" 0", "", strftime(" %d", $date));
- $datestring = str_replace("DD", $daystring, $datestring);
+ $daystring = str_replace(' 0', '', strftime(" %d", $date));
+ $datestring = str_replace('DD', $daystring, $datestring);
} else {
$datestring = strftime($format, $date);
}
$date = $date + (int)($timezone * 3600);
if ($fixday) {
$datestring = gmstrftime($formatnoday, $date);
- $daystring = str_replace(" 0", "", gmstrftime(" %d", $date));
- $datestring = str_replace("DD", $daystring, $datestring);
+ $daystring = str_replace(' 0', '', gmstrftime(" %d", $date));
+ $datestring = str_replace('DD', $daystring, $datestring);
} else {
$datestring = gmstrftime($format, $date);
}
}
//There is no gmgetdate so I have to fake it...
$date = $date + (int)($timezone * 3600);
- $getdate["seconds"] = gmstrftime("%S", $date);
- $getdate["minutes"] = gmstrftime("%M", $date);
- $getdate["hours"] = gmstrftime("%H", $date);
- $getdate["mday"] = gmstrftime("%d", $date);
- $getdate["wday"] = gmstrftime("%u", $date);
- $getdate["mon"] = gmstrftime("%m", $date);
- $getdate["year"] = gmstrftime("%Y", $date);
- $getdate["yday"] = gmstrftime("%j", $date);
- $getdate["weekday"] = gmstrftime("%A", $date);
- $getdate["month"] = gmstrftime("%B", $date);
+ $getdate['seconds'] = gmstrftime("%S", $date);
+ $getdate['minutes'] = gmstrftime("%M", $date);
+ $getdate['hours'] = gmstrftime("%H", $date);
+ $getdate['mday'] = gmstrftime("%d", $date);
+ $getdate['wday'] = gmstrftime("%u", $date);
+ $getdate['mon'] = gmstrftime("%m", $date);
+ $getdate['year'] = gmstrftime("%Y", $date);
+ $getdate['yday'] = gmstrftime("%j", $date);
+ $getdate['weekday'] = gmstrftime("%A", $date);
+ $getdate['month'] = gmstrftime("%B", $date);
return $getdate;
}
$userdate = usergetdate($date, $timezone);
if (abs($timezone) > 13) {
- return mktime(0, 0, 0, $userdate["mon"], $userdate["mday"], $userdate["year"]);
+ return mktime(0, 0, 0, $userdate['mon'], $userdate['mday'], $userdate['year']);
}
- $timemidnight = gmmktime (0, 0, 0, $userdate["mon"], $userdate["mday"], $userdate["year"]);
+ $timemidnight = gmmktime (0, 0, 0, $userdate['mon'], $userdate['mday'], $userdate['year']);
return usertime($timemidnight, $timezone); // Time of midnight of this user's day, in GMT
}
$timezone = get_user_timezone($timezone);
if (abs($timezone) > 13) {
- return "server time";
+ return 'server time';
}
if (abs($timezone) < 0.5) {
- return "GMT";
+ return 'GMT';
}
if ($timezone > 0) {
- return "GMT+$timezone";
+ return 'GMT+'. $timezone;
} else {
- return "GMT$timezone";
+ return 'GMT'. $timezone;
}
}
// First check that the user is logged in to the site.
if (! (isset($USER->loggedin) and $USER->confirmed and ($USER->site == $CFG->wwwroot)) ) { // They're not
$SESSION->wantsurl = $FULLME;
- if (!empty($_SERVER["HTTP_REFERER"])) {
- $SESSION->fromurl = $_SERVER["HTTP_REFERER"];
+ if (!empty($_SERVER['HTTP_REFERER'])) {
+ $SESSION->fromurl = $_SERVER['HTTP_REFERER'];
}
$USER = NULL;
if ($autologinguest and $CFG->autologinguests and $courseid and get_field('course','guest','id',$courseid)) {
$loginguest = '';
}
if (empty($CFG->loginhttps)) {
- redirect("$CFG->wwwroot/login/index.php$loginguest");
+ redirect($CFG->wwwroot .'/login/index.php'. $loginguest);
} else {
- $wwwroot = str_replace('http','https',$CFG->wwwroot);
- redirect("$wwwroot/login/index.php$loginguest");
+ $wwwroot = str_replace('http','https', $CFG->wwwroot);
+ redirect($wwwroot .'/login/index.php'. $loginguest);
}
die;
}
reload_user_preferences();
if (isset($USER->preference['auth_forcepasswordchange'])){
if (is_internal_auth() || $CFG->{'auth_'.$USER->auth.'_stdchangepassword'}){
- redirect("$CFG->wwwroot/login/change_password.php");
+ redirect($CFG->wwwroot .'/login/change_password.php');
} elseif($CFG->changepassword) {
redirect($CFG->changepassword);
} else {
- error("You cannot proceed without changing your password.
+ error('You cannot proceed without changing your password.
However there is no available page for changing it.
- Please contact your Moodle Administrator.");
+ Please contact your Moodle Administrator.');
}
}
// Check that the user account is properly set up
if (user_not_fully_set_up($USER)) {
- redirect("$CFG->wwwroot/user/edit.php?id=$USER->id&course=".SITEID);
+ redirect($CFG->wwwroot .'/user/edit.php?id='. $USER->id .'&course='. SITEID);
die;
}
if (isset($USER->realuser)) { // Make sure the REAL person can also access this course
if (!isteacher($courseid, $USER->realuser)) {
print_header();
- notice(get_string("studentnotallowed", "", fullname($USER, true)), "$CFG->wwwroot/");
+ notice(get_string('studentnotallowed', '', fullname($USER, true)), $CFG->wwwroot .'/');
}
}
return; // user is a member of this course.
}
- if (! $course = get_record("course", "id", $courseid)) {
- error("That course doesn't exist");
+ if (! $course = get_record('course', 'id', $courseid)) {
+ error('That course doesn\'t exist');
}
if (!$course->visible) {
print_header();
- notice(get_string("studentnotallowed", "", fullname($USER, true)), "$CFG->wwwroot/");
+ notice(get_string('studentnotallowed', '', fullname($USER, true)), $CFG->wwwroot .'/');
}
- if ($USER->username == "guest") {
+ if ($USER->username == 'guest') {
switch ($course->guest) {
case 0: // Guests not allowed
print_header();
- notice(get_string("guestsnotallowed", "", $course->fullname));
+ notice(get_string('guestsnotallowed', '', $course->fullname));
break;
case 1: // Guests allowed
return;
// Currently not enrolled in the course, so see if they want to enrol
$SESSION->wantsurl = $FULLME;
- redirect("$CFG->wwwroot/course/enrol.php?id=$courseid");
+ redirect($CFG->wwwroot .'/course/enrol.php?id='. $courseid);
die;
}
}
$user->id = $USER->id;
- return update_record("user", $user);
+ return update_record('user', $user);
}
function user_not_fully_set_up($user) {
- return ($user->username != "guest" and (empty($user->firstname) or empty($user->lastname) or empty($user->email)));
+ return ($user->username != 'guest' and (empty($user->firstname) or empty($user->lastname) or empty($user->email)));
}
function update_login_count() {
if ($SESSION->logincount > $max_logins) {
unset($SESSION->wantsurl);
- error(get_string("errortoomanylogins"));
+ error(get_string('errortoomanylogins'));
}
}
$SESSION->logincount = 0;
}
-function check_for_restricted_user($username=NULL, $redirect="") {
+function check_for_restricted_user($username=NULL, $redirect='') {
global $CFG, $USER;
if (!$username) {
if (!empty($CFG->restrictusers)) {
$names = explode(',', $CFG->restrictusers);
if (in_array($username, $names)) {
- error(get_string("restricteduser", "error", fullname($USER)), $redirect);
+ error(get_string('restricteduser', 'error', fullname($USER)), $redirect);
}
}
}
return true;
} else if (in_array($userid, $nonadmins)) {
return false;
- } else if (record_exists("user_admins", "userid", $userid)){
+ } else if (record_exists('user_admins', 'userid', $userid)){
$admins[] = $userid;
return true;
} else {
}
if (!$courseid) {
- return record_exists("user_teachers","userid",$userid);
+ return record_exists('user_teachers', 'userid', $userid);
}
- return record_exists("user_teachers", "userid", $userid, "course", $courseid);
+ return record_exists('user_teachers', 'userid', $userid, 'course', $courseid);
}
function isteacheredit($courseid, $userid=0) {
return !empty($USER->teacheredit[$courseid]);
}
- return get_field("user_teachers", "editall", "userid", $userid, "course", $courseid);
+ return get_field('user_teachers', 'editall', 'userid', $userid, 'course', $courseid);
}
function iscreator ($userid=0) {
return true;
}
if (empty($userid)) {
- return record_exists("user_coursecreators", "userid", $USER->id);
+ return record_exists('user_coursecreators', 'userid', $USER->id);
}
- return record_exists("user_coursecreators", "userid", $userid);
+ return record_exists('user_coursecreators', 'userid', $userid);
}
function isstudent($courseid, $userid=0) {
// $timenow = time(); // todo: add time check below
- return record_exists("user_students", "userid", $userid, "course", $courseid);
+ return record_exists('user_students', 'userid', $userid, 'course', $courseid);
}
function isguest($userid=0) {
if (empty($USER->username)) {
return false;
}
- return ($USER->username == "guest");
+ return ($USER->username == 'guest');
}
- return record_exists("user", "id", $userid, "username", "guest");
+ return record_exists('user', 'id', $userid, 'username', 'guest');
}
}
if ($CFG->fullnamedisplay == 'firstname lastname') {
- return "$user->firstname $user->lastname";
+ return $user->firstname .' '. $user->lastname;
} else if ($CFG->fullnamedisplay == 'lastname firstname') {
- return "$user->lastname $user->firstname";
+ return $user->lastname .' '. $user->firstname;
} else if ($CFG->fullnamedisplay == 'firstname') {
if ($override) {
$days = 60;
$seconds = 60*60*24*$days;
- setCookie($cookiename, "", time() - 3600, "/");
- setCookie($cookiename, rc4encrypt($thing), time()+$seconds, "/");
+ setCookie($cookiename, '', time() - 3600, '/');
+ setCookie($cookiename, rc4encrypt($thing), time()+$seconds, '/');
}
$cookiename = 'MOODLEID_'.$CFG->sessioncookie;
if (empty($_COOKIE[$cookiename])) {
- return "";
+ return '';
} else {
return rc4decrypt($_COOKIE[$cookiename]);
}
$method = $auth;
}
- return ($method == "email" || $method == "none" || $method == "manual");
+ return ($method == 'email' || $method == 'none' || $method == 'manual');
}
function create_user_record($username, $password, $auth='') {
$newuser->lastIP = getremoteaddr();
$newuser->timemodified = time();
- if (insert_record("user", $newuser)) {
- $user = get_user_info_from_db("username", $newuser->username);
+ if (insert_record('user', $newuser)) {
+ $user = get_user_info_from_db('username', $newuser->username);
if($CFG->{'auth_'.$newuser->auth.'_forcechangepassword'}){
set_user_preference('auth_forcepasswordchange', 1, $user);
}
}
}
}
- return get_user_info_from_db("username", $username);
+ return get_user_info_from_db('username', $username);
}
function guest_user() {
global $CFG;
- if ($newuser = get_record("user", "username", "guest")) {
+ if ($newuser = get_record('user', 'username', 'guest')) {
$newuser->loggedin = true;
$newuser->confirmed = 1;
$newuser->site = $CFG->wwwroot;
// First try to find the user in the database
- $user = get_user_info_from_db("username", $username);
+ $user = get_user_info_from_db('username', $username);
// Sort out the authentication method we are using.
if (empty($CFG->auth)) {
- $CFG->auth = "manual"; // Default authentication module
+ $CFG->auth = 'manual'; // Default authentication module
}
if (empty($user->auth)) { // For some reason it isn't set yet
$auth = $user->auth;
}
- if (!file_exists("$CFG->dirroot/auth/$auth/lib.php")) {
- $auth = "manual"; // Can't find auth module, default to internal
+ if (!file_exists($CFG->dirroot .'/auth/'. $auth .'/lib.php')) {
+ $auth = 'manual'; // Can't find auth module, default to internal
}
- require_once("$CFG->dirroot/auth/$auth/lib.php");
+ require_once($CFG->dirroot .'/auth/'. $auth .'/lib.php');
if (auth_user_login($username, $password)) { // Successful authentication
if ($user) { // User already exists in database
if (function_exists('auth_iscreator')) { // Check if the user is a creator
if (auth_iscreator($username)) {
- if (! record_exists("user_coursecreators", "userid", $user->id)) {
+ if (! record_exists('user_coursecreators', 'userid', $user->id)) {
$cdata->userid = $user->id;
- if (! insert_record("user_coursecreators", $cdata)) {
- error("Cannot add user to course creators.");
+ if (! insert_record('user_coursecreators', $cdata)) {
+ error('Cannot add user to course creators.');
}
}
} else {
- if ( record_exists("user_coursecreators", "userid", $user->id)) {
- if (! delete_records("user_coursecreators", "userid", $user->id)) {
- error("Cannot remove user from course creators.");
+ if ( record_exists('user_coursecreators', 'userid', $user->id)) {
+ if (! delete_records('user_coursecreators', 'userid', $user->id)) {
+ error('Cannot remove user from course creators.');
}
}
}
return $user;
} else {
- add_to_log(0, "login", "error", $_SERVER['HTTP_REFERER'], $username);
+ add_to_log(0, 'login', 'error', $_SERVER['HTTP_REFERER'], $username);
$date = date('Y-m-d H:i:s');
- error_log("$date\tfailed login\t".getremoteaddr()."\t".$_SERVER['HTTP_USER_AGENT']."\t$username");
+ error_log($date ."\tfailed login\t". getremoteaddr() ."\t". $_SERVER['HTTP_USER_AGENT'] ."\t". $username);
return false;
}
}
function enrol_student($userid, $courseid, $timestart=0, $timeend=0) {
/// Enrols (or re-enrols) a student in a given course
- if (!$course = get_record("course", "id", $courseid)) { // Check course
+ if (!$course = get_record('course', 'id', $courseid)) { // Check course
return false;
}
- if (!$user = get_record("user", "id", $userid)) { // Check user
+ if (!$user = get_record('user', 'id', $userid)) { // Check user
return false;
}
- if ($student = get_record("user_students", "userid", $userid, "course", $courseid)) {
+ if ($student = get_record('user_students', 'userid', $userid, 'course', $courseid)) {
$student->timestart = $timestart;
$student->timeend = $timeend;
$student->time = time();
- return update_record("user_students", $student);
+ return update_record('user_students', $student);
} else {
$student->userid = $userid;
$student->timestart = $timestart;
$student->timeend = $timeend;
$student->time = time();
- return insert_record("user_students", $student);
+ return insert_record('user_students', $student);
}
}
if ($courseid) {
/// First delete any crucial stuff that might still send mail
- if ($forums = get_records("forum", "course", $courseid)) {
+ if ($forums = get_records('forum', 'course', $courseid)) {
foreach ($forums as $forum) {
- delete_records("forum_subscriptions", "forum", $forum->id, "userid", $userid);
+ delete_records('forum_subscriptions', 'forum', $forum->id, 'userid', $userid);
}
}
if ($groups = get_groups($courseid, $userid)) {
foreach ($groups as $group) {
- delete_records("groups_members", "groupid", $group->id, "userid", $userid);
+ delete_records('groups_members', 'groupid', $group->id, 'userid', $userid);
}
}
- return delete_records("user_students", "userid", $userid, "course", $courseid);
+ return delete_records('user_students', 'userid', $userid, 'course', $courseid);
} else {
- delete_records("forum_subscriptions", "userid", $userid);
- delete_records("groups_members", "userid", $userid);
- return delete_records("user_students", "userid", $userid);
+ delete_records('forum_subscriptions', 'userid', $userid);
+ delete_records('groups_members', 'userid', $userid);
+ return delete_records('user_students', 'userid', $userid);
}
}
-function add_teacher($userid, $courseid, $editall=1, $role="", $timestart=0, $timeend=0) {
+function add_teacher($userid, $courseid, $editall=1, $role='', $timestart=0, $timeend=0) {
/// Add a teacher to a given course
global $CFG;
return update_record('user_teachers', $newteacher);
}
- if (!record_exists("user", "id", $userid)) {
+ if (!record_exists('user', 'id', $userid)) {
return false; // no such user
}
- if (!record_exists("course", "id", $courseid)) {
+ if (!record_exists('course', 'id', $courseid)) {
return false; // no such course
}
$teacher->timemodified = time();
$newteacher->timestart = $timestart;
$newteacher->timeend = $timeend;
- if ($student = get_record("user_students", "userid", $userid, "course", $courseid)) {
+ if ($student = get_record('user_students', 'userid', $userid, 'course', $courseid)) {
$teacher->timestart = $student->timestart;
$teacher->timeend = $student->timeend;
$teacher->timeaccess = $student->timeaccess;
}
- if (record_exists("user_teachers", "course", $courseid)) {
+ if (record_exists('user_teachers', 'course', $courseid)) {
$teacher->authority = 2;
} else {
$teacher->authority = 1;
}
- delete_records("user_students", "userid", $userid, "course", $courseid); // Unenrol as student
+ delete_records('user_students', 'userid', $userid, 'course', $courseid); // Unenrol as student
/// Add forum subscriptions for new users
require_once('../mod/forum/lib.php');
forum_add_user($userid, $courseid);
- return insert_record("user_teachers", $teacher);
+ return insert_record('user_teachers', $teacher);
}
/// Does not delete the user account
if ($courseid) {
/// First delete any crucial stuff that might still send mail
- if ($forums = get_records("forum", "course", $courseid)) {
+ if ($forums = get_records('forum', 'course', $courseid)) {
foreach ($forums as $forum) {
- delete_records("forum_subscriptions", "forum", $forum->id, "userid", $userid);
+ delete_records('forum_subscriptions', 'forum', $forum->id, 'userid', $userid);
}
}
if (!isstudent($courseid, $userid)) {
if ($groups = get_groups($courseid, $userid)) {
foreach ($groups as $group) {
- delete_records("groups_members", "groupid", $group->id, "userid", $userid);
+ delete_records('groups_members', 'groupid', $group->id, 'userid', $userid);
}
}
}
- return delete_records("user_teachers", "userid", $userid, "course", $courseid);
+ return delete_records('user_teachers', 'userid', $userid, 'course', $courseid);
} else {
- delete_records("forum_subscriptions", "userid", $userid);
- return delete_records("user_teachers", "userid", $userid);
+ delete_records('forum_subscriptions', 'userid', $userid);
+ return delete_records('user_teachers', 'userid', $userid);
}
}
function add_creator($userid) {
/// Add a creator to the site
- if (!record_exists("user_admins", "userid", $userid)) {
- if (record_exists("user", "id", $userid)) {
+ if (!record_exists('user_admins', 'userid', $userid)) {
+ if (record_exists('user', 'id', $userid)) {
$creator->userid = $userid;
- return insert_record("user_coursecreators", $creator);
+ return insert_record('user_coursecreators', $creator);
}
return false;
}
/// Removes a creator from a site
global $db;
- return delete_records("user_coursecreators", "userid", $userid);
+ return delete_records('user_coursecreators', 'userid', $userid);
}
function add_admin($userid) {
/// Add an admin to the site
- if (!record_exists("user_admins", "userid", $userid)) {
- if (record_exists("user", "id", $userid)) {
+ if (!record_exists('user_admins', 'userid', $userid)) {
+ if (record_exists('user', 'id', $userid)) {
$admin->userid = $userid;
// any admin is also a teacher on the site course
}
}
- return insert_record("user_admins", $admin);
+ return insert_record('user_admins', $admin);
}
return false;
}
// remove also from the list of site teachers
remove_teacher($userid, SITEID);
- return delete_records("user_admins", "userid", $userid);
+ return delete_records('user_admins', 'userid', $userid);
}
$result = true;
- if (! $course = get_record("course", "id", $courseid)) {
- error("Course ID was incorrect (can't find it)");
+ if (! $course = get_record('course', 'id', $courseid)) {
+ error('Course ID was incorrect (can\'t find it)');
}
- $strdeleted = get_string("deleted");
+ $strdeleted = get_string('deleted');
// First delete every instance of every module
- if ($allmods = get_records("modules") ) {
+ if ($allmods = get_records('modules') ) {
foreach ($allmods as $mod) {
$modname = $mod->name;
- $modfile = "$CFG->dirroot/mod/$modname/lib.php";
- $moddelete = $modname."_delete_instance"; // Delete everything connected to an instance
- $moddeletecourse = $modname."_delete_course"; // Delete other stray stuff (uncommon)
+ $modfile = $CFG->dirroot .'/mod/'. $modname .'/lib.php';
+ $moddelete = $modname .'_delete_instance'; // Delete everything connected to an instance
+ $moddeletecourse = $modname .'_delete_course'; // Delete other stray stuff (uncommon)
$count=0;
if (file_exists($modfile)) {
include_once($modfile);
if (function_exists($moddelete)) {
- if ($instances = get_records($modname, "course", $course->id)) {
+ if ($instances = get_records($modname, 'course', $course->id)) {
foreach ($instances as $instance) {
if ($moddelete($instance->id)) {
$count++;
} else {
- notify("Could not delete $modname instance $instance->id ($instance->name)");
+ notify('Could not delete '. $modname .' instance '. $instance->id .' ('. $instance->name .')');
$result = false;
}
}
}
} else {
- notify("Function $moddelete() doesn't exist!");
+ notify('Function '. $moddelete() .'doesn\'t exist!');
$result = false;
}
}
}
if ($showfeedback) {
- notify("$strdeleted $count x $modname");
+ notify($strdeleted .' '. $count .' x '. $modname);
}
}
} else {
- error("No modules are installed!");
+ error('No modules are installed!');
}
// Delete any user stuff
- if (delete_records("user_students", "course", $course->id)) {
+ if (delete_records('user_students', 'course', $course->id)) {
if ($showfeedback) {
- notify("$strdeleted user_students");
+ notify($strdeleted .' user_students');
}
} else {
$result = false;
}
- if (delete_records("user_teachers", "course", $course->id)) {
+ if (delete_records('user_teachers', 'course', $course->id)) {
if ($showfeedback) {
- notify("$strdeleted user_teachers");
+ notify($strdeleted .' user_teachers');
}
} else {
$result = false;
// Delete any groups
- if ($groups = get_records("groups", "courseid", $course->id)) {
+ if ($groups = get_records('groups', 'courseid', $course->id)) {
foreach ($groups as $group) {
- if (delete_records("groups_members", "groupid", $group->id)) {
+ if (delete_records('groups_members', 'groupid', $group->id)) {
if ($showfeedback) {
- notify("$strdeleted groups_members");
+ notify($strdeleted .' groups_members');
}
} else {
$result = false;
}
- if (delete_records("groups", "id", $group->id)) {
+ if (delete_records('groups', 'id', $group->id)) {
if ($showfeedback) {
- notify("$strdeleted groups");
+ notify($strdeleted .' groups');
}
} else {
$result = false;
// Delete events
- if (delete_records("event", "courseid", $course->id)) {
+ if (delete_records('event', 'courseid', $course->id)) {
if ($showfeedback) {
- notify("$strdeleted event");
+ notify($strdeleted .' event');
}
} else {
$result = false;
// Delete logs
- if (delete_records("log", "course", $course->id)) {
+ if (delete_records('log', 'course', $course->id)) {
if ($showfeedback) {
- notify("$strdeleted log");
+ notify($strdeleted .' log');
}
} else {
$result = false;
// Delete any course stuff
- if (delete_records("course_sections", "course", $course->id)) {
+ if (delete_records('course_sections', 'course', $course->id)) {
if ($showfeedback) {
- notify("$strdeleted course_sections");
+ notify($strdeleted .' course_sections');
}
} else {
$result = false;
}
- if (delete_records("course_modules", "course", $course->id)) {
+ if (delete_records('course_modules', 'course', $course->id)) {
if ($showfeedback) {
- notify("$strdeleted course_modules");
+ notify($strdeleted .' course_modules');
}
} else {
$result = false;
$result = true;
- if (! $course = get_record("course", "id", $courseid)) {
- error("Course ID was incorrect (can't find it)");
+ if (! $course = get_record('course', 'id', $courseid)) {
+ error('Course ID was incorrect (can\'t find it)');
}
- $strdeleted = get_string("deleted");
+ $strdeleted = get_string('deleted');
// Look in every instance of every module for data to delete
- if ($allmods = get_records("modules") ) {
+ if ($allmods = get_records('modules') ) {
foreach ($allmods as $mod) {
$modname = $mod->name;
- $modfile = "$CFG->dirroot/mod/$modname/lib.php";
- $moddeleteuserdata = $modname."_delete_userdata"; // Function to delete user data
+ $modfile = $CFG->dirroot .'/mod/'. $modname .'/lib.php';
+ $moddeleteuserdata = $modname .'_delete_userdata'; // Function to delete user data
$count=0;
if (file_exists($modfile)) {
@include_once($modfile);
}
}
} else {
- error("No modules are installed!");
+ error('No modules are installed!');
}
// Delete other stuff
if ($removestudents) {
/// Delete student enrolments
- if (delete_records("user_students", "course", $course->id)) {
+ if (delete_records('user_students', 'course', $course->id)) {
if ($showfeedback) {
- notify("$strdeleted user_students");
+ notify($strdeleted .' user_students');
}
} else {
$result = false;
}
/// Delete group members (but keep the groups)
- if ($groups = get_records("groups", "courseid", $course->id)) {
+ if ($groups = get_records('groups', 'courseid', $course->id)) {
foreach ($groups as $group) {
- if (delete_records("groups_members", "groupid", $group->id)) {
+ if (delete_records('groups_members', 'groupid', $group->id)) {
if ($showfeedback) {
- notify("$strdeleted groups_members");
+ notify($strdeleted .' groups_members');
}
} else {
$result = false;
}
if ($removeteachers) {
- if (delete_records("user_teachers", "course", $course->id)) {
+ if (delete_records('user_teachers', 'course', $course->id)) {
if ($showfeedback) {
- notify("$strdeleted user_teachers");
+ notify($strdeleted .' user_teachers');
}
} else {
$result = false;
}
if ($removegroups) {
- if ($groups = get_records("groups", "courseid", $course->id)) {
+ if ($groups = get_records('groups', 'courseid', $course->id)) {
foreach ($groups as $group) {
- if (delete_records("groups", "id", $group->id)) {
+ if (delete_records('groups', 'id', $group->id)) {
if ($showfeedback) {
- notify("$strdeleted groups");
+ notify($strdeleted .' groups');
}
} else {
$result = false;
}
if ($removeevents) {
- if (delete_records("event", "courseid", $course->id)) {
+ if (delete_records('event', 'courseid', $course->id)) {
if ($showfeedback) {
- notify("$strdeleted event");
+ notify($strdeleted .' event');
}
} else {
$result = false;
}
if ($removelogs) {
- if (delete_records("log", "course", $course->id)) {
+ if (delete_records('log', 'course', $course->id)) {
if ($showfeedback) {
- notify("$strdeleted log");
+ notify($strdeleted .' log');
}
} else {
$result = false;
return false;
}
- return record_exists("groups_members", "groupid", $groupid, "userid", $userid);
+ return record_exists('groups_members', 'groupid', $groupid, 'userid', $userid);
}
/**
}
if ($groupmode == VISIBLEGROUPS or ($groupmode and isteacheredit($course->id))) {
- if ($groups = get_records_menu("groups", "courseid", $course->id, "name ASC", "id,name")) {
+ if ($groups = get_records_menu('groups', 'courseid', $course->id, 'name ASC', 'id,name')) {
echo '<div align="center">';
print_group_menu($groups, $groupmode, $currentgroup, $urlroot);
echo '</div>';
/// CORRESPONDENCE ////////////////////////////////////////////////
-function email_to_user($user, $from, $subject, $messagetext, $messagehtml="", $attachment="", $attachname="", $usetrueaddress=true) {
+function email_to_user($user, $from, $subject, $messagetext, $messagehtml='', $attachment='', $attachname='', $usetrueaddress=true) {
/// user - a user record as an object
/// from - a user record as an object
/// subject - plain text subject line of the email
$CFG->courselang = $course->lang;
}
- include_once("$CFG->libdir/phpmailer/class.phpmailer.php");
+ include_once($CFG->libdir .'/phpmailer/class.phpmailer.php');
if (empty($user)) {
return false;
$mail = new phpmailer;
- $mail->Version = "Moodle $CFG->version"; // mailer version
- $mail->PluginDir = "$CFG->libdir/phpmailer/"; // plugin directory (eg smtp plugin)
+ $mail->Version = 'Moodle '. $CFG->version; // mailer version
+ $mail->PluginDir = $CFG->libdir .'/phpmailer/'; // plugin directory (eg smtp plugin)
- if (current_language() != "en") {
- $mail->CharSet = get_string("thischarset");
+ if (current_language() != 'en') {
+ $mail->CharSet = get_string('thischarset');
}
- if ($CFG->smtphosts == "qmail") {
+ if ($CFG->smtphosts == 'qmail') {
$mail->IsQmail(); // use Qmail system
} else if (empty($CFG->smtphosts)) {
} else {
$mail->IsSMTP(); // use SMTP directly
if ($CFG->debug > 7) {
- echo "<pre>\n";
+ echo '<pre>' . "\n";
$mail->SMTPDebug = true;
}
- $mail->Host = "$CFG->smtphosts"; // specify main and backup servers
+ $mail->Host = $CFG->smtphosts; // specify main and backup servers
if ($CFG->smtpuser) { // Use SMTP authentication
$mail->SMTPAuth = true;
$adminuser = get_admin();
- $mail->Sender = "$adminuser->email";
+ $mail->Sender = $adminuser->email;
if (is_string($from)) { // So we can pass whatever we want if there is need
$mail->From = $CFG->noreplyaddress;
$mail->FromName = $from;
} else if ($usetrueaddress and $from->maildisplay) {
- $mail->From = "$from->email";
+ $mail->From = $from->email;
$mail->FromName = fullname($from);
} else {
- $mail->From = "$CFG->noreplyaddress";
+ $mail->From = $CFG->noreplyaddress;
$mail->FromName = fullname($from);
}
$mail->Subject = stripslashes($subject);
- $mail->AddAddress("$user->email", fullname($user) );
+ $mail->AddAddress($user->email, fullname($user) );
$mail->WordWrap = 79; // set word wrap
if ($messagehtml) {
$mail->IsHTML(true);
- $mail->Encoding = "quoted-printable"; // Encoding to use
+ $mail->Encoding = 'quoted-printable'; // Encoding to use
$mail->Body = $messagehtml;
$mail->AltBody = "\n$messagetext\n";
} else {
if ($attachment && $attachname) {
if (ereg( "\\.\\." ,$attachment )) { // Security check for ".." in dir path
- $mail->AddAddress("$adminuser->email", fullname($adminuser) );
- $mail->AddStringAttachment("Error in attachment. User attempted to attach a filename with a unsafe name.", "error.txt", "8bit", "text/plain");
+ $mail->AddAddress($adminuser->email, fullname($adminuser) );
+ $mail->AddStringAttachment('Error in attachment. User attempted to attach a filename with a unsafe name.', 'error.txt', '8bit', 'text/plain');
} else {
- include_once("$CFG->dirroot/files/mimetypes.php");
- $mimetype = mimeinfo("type", $attachname);
- $mail->AddAttachment("$CFG->dataroot/$attachment", "$attachname", "base64", "$mimetype");
+ include_once($CFG->dirroot .'/files/mimetypes.php');
+ $mimetype = mimeinfo('type', $attachname);
+ $mail->AddAttachment($CFG->dataroot .'/'. $attachment, $attachname, 'base64', $mimetype);
}
}
if ($mail->Send()) {
return true;
} else {
- mtrace("ERROR: $mail->ErrorInfo");
- add_to_log(SITEID, "library", "mailer", $_SERVER["REQUEST_URI"], "ERROR: $mail->ErrorInfo");
+ mtrace('ERROR: '. $mail->ErrorInfo);
+ add_to_log(SITEID, 'library', 'mailer', $_SERVER['REQUEST_URI'], 'ERROR: '. $mail->ErrorInfo);
return false;
}
}
$newpassword = generate_password();
- if (! set_field("user", "password", md5($newpassword), "id", $user->id) ) {
- error("Could not set user password!");
+ if (! set_field('user', 'password', md5($newpassword), 'id', $user->id) ) {
+ error('Could not set user password!');
}
$a->firstname = $user->firstname;
$a->sitename = $site->fullname;
$a->username = $user->username;
$a->newpassword = $newpassword;
- $a->link = "$CFG->wwwroot/login/change_password.php";
- $a->signoff = fullname($from, true)." ($from->email)";
+ $a->link = $CFG->wwwroot .'/login/change_password.php';
+ $a->signoff = fullname($from, true).' ('. $from->email .')';
- $message = get_string("newpasswordtext", "", $a);
+ $message = get_string('newpasswordtext', '', $a);
- $subject = "$site->fullname: ".get_string("changedpassword");
+ $subject = $site->fullname .': '. get_string('changedpassword');
return email_to_user($user, $from, $subject, $message);
$data->firstname = $user->firstname;
$data->sitename = $site->fullname;
- $data->link = "$CFG->wwwroot/login/confirm.php?p=$user->secret&s=$user->username";
- $data->admin = fullname($from)." ($from->email)";
+ $data->link = $CFG->wwwroot .'/login/confirm.php?p='. $user->secret .'&s='. $user->username;
+ $data->admin = fullname($from) .' ('. $from->email .')';
- $message = get_string("emailconfirmation", "", $data);
- $subject = get_string("emailconfirmationsubject", "", $site->fullname);
+ $message = get_string('emailconfirmation', '', $data);
+ $subject = get_string('emailconfirmationsubject', '', $site->fullname);
$messagehtml = text_to_html($message, false, false, true);
$data->firstname = $user->firstname;
$data->sitename = $site->fullname;
- $data->link = "$CFG->wwwroot/login/forgot_password.php?p=$user->secret&s=$user->username";
- $data->admin = fullname($from)." ($from->email)";
+ $data->link = $CFG->wwwroot .'/login/forgot_password.php?p='. $user->secret .'&s='. $user->username;
+ $data->admin = fullname($from).' ('. $from->email .')';
- $message = get_string("emailpasswordconfirmation", "", $data);
- $subject = get_string("emailpasswordconfirmationsubject", "", $site->fullname);
+ $message = get_string('emailpasswordconfirmation', '', $data);
+ $subject = get_string('emailpasswordconfirmationsubject', '', $site->fullname);
return email_to_user($user, $from, $subject, $message);
return false;
}
}
- return get_string("emailonlyallowed", '', $CFG->allowemailaddresses);
+ return get_string('emailonlyallowed', '', $CFG->allowemailaddresses);
} else if (!empty($CFG->denyemailaddresses)) {
$denied = explode(' ', $CFG->denyemailaddresses);
continue;
}
if (strpos($email, $deniedpattern) !== false) { // Match!
- return get_string("emailnotallowed", '', $CFG->denyemailaddresses);
+ return get_string('emailnotallowed', '', $CFG->denyemailaddresses);
}
}
}
if (!file_exists($currdir)) {
if (! mkdir($currdir, $CFG->directorypermissions)) {
if ($shownotices) {
- notify("ERROR: You need to create the directory $currdir with web server write access");
+ notify('ERROR: You need to create the directory '. $currdir .' with web server write access');
}
return false;
}
}
- $dirarray = explode("/", $directory);
+ $dirarray = explode('/', $directory);
foreach ($dirarray as $dir) {
- $currdir = "$currdir/$dir";
+ $currdir = $currdir .'/'. $dir;
if (! file_exists($currdir)) {
if (! mkdir($currdir, $CFG->directorypermissions)) {
if ($shownotices) {
- notify("ERROR: Could not find or create a directory ($currdir)");
+ notify('ERROR: Could not find or create a directory ('. $currdir .')');
}
return false;
}
/// Makes an upload directory for a particular module
global $CFG;
- if (! $moddata = make_upload_directory("$courseid/$CFG->moddata")) {
+ if (! $moddata = make_upload_directory($courseid .'/'. $CFG->moddata)) {
return false;
}
- $strreadme = get_string("readme");
+ $strreadme = get_string('readme');
- if (file_exists("$CFG->dirroot/lang/$CFG->lang/docs/module_files.txt")) {
- copy("$CFG->dirroot/lang/$CFG->lang/docs/module_files.txt", "$moddata/$strreadme.txt");
+ if (file_exists($CFG->dirroot .'/lang/'. $CFG->lang .'/docs/module_files.txt')) {
+ copy($CFG->dirroot .'/lang/'. $CFG->lang .'/docs/module_files.txt', $moddata .'/'. $strreadme .'.txt');
} else {
- copy("$CFG->dirroot/lang/en/docs/module_files.txt", "$moddata/$strreadme.txt");
+ copy($CFG->dirroot .'/lang/en/docs/module_files.txt', $moddata .'/'. $strreadme .'.txt');
}
return $moddata;
}
function valid_uploaded_file($newfile) {
/// Returns current name of file on disk if true
if (empty($newfile)) {
- return "";
+ return '';
}
if (is_uploaded_file($newfile['tmp_name']) and $newfile['size'] > 0) {
return $newfile['tmp_name'];
} else {
- return "";
+ return '';
}
}
/// Anything defined as 0 is ignored.
/// The smallest of all the non-zero numbers is returned.
- if (! $filesize = ini_get("upload_max_filesize")) {
- $filesize = "5M";
+ if (! $filesize = ini_get('upload_max_filesize')) {
+ $filesize = '5M';
}
$minimumsize = get_real_size($filesize);
- if ($postsize = ini_get("post_max_size")) {
+ if ($postsize = ini_get('post_max_size')) {
$postsize = get_real_size($postsize);
if ($postsize < $minimumsize) {
$minimumsize = $postsize;
}
-
-
-
-function get_directory_list($rootdir, $excludefile="", $descend=true, $getdirs=false, $getfiles=true) {
+function get_directory_list($rootdir, $excludefile='', $descend=true, $getdirs=false, $getfiles=true) {
/// Returns an array with all the filenames in
/// all subdirectories, relative to the given rootdir.
/// If excludefile is defined, then that file/directory is ignored
while (false !== ($file = readdir($dir))) {
$firstchar = substr($file, 0, 1);
- if ($firstchar == "." or $file == "CVS" or $file == $excludefile) {
+ if ($firstchar == '.' or $file == 'CVS' or $file == $excludefile) {
continue;
}
- $fullfile = "$rootdir/$file";
- if (filetype($fullfile) == "dir") {
+ $fullfile = $rootdir .'/'. $file;
+ if (filetype($fullfile) == 'dir') {
if ($getdirs) {
$dirs[] = $file;
}
if ($descend) {
$subdirs = get_directory_list($fullfile, $excludefile, $descend, $getdirs, $getfiles);
foreach ($subdirs as $subdir) {
- $dirs[] = "$file/$subdir";
+ $dirs[] = $file .'/'. $subdir;
}
}
} else if ($getfiles) {
return $dirs;
}
-function get_directory_size($rootdir, $excludefile="") {
+function get_directory_size($rootdir, $excludefile='') {
/// Adds up all the files in a directory and works out the size
$size = 0;
while (false !== ($file = readdir($dir))) {
$firstchar = substr($file, 0, 1);
- if ($firstchar == "." or $file == "CVS" or $file == $excludefile) {
+ if ($firstchar == '.' or $file == 'CVS' or $file == $excludefile) {
continue;
}
- $fullfile = "$rootdir/$file";
- if (filetype($fullfile) == "dir") {
+ $fullfile = $rootdir .'/'. $file;
+ if (filetype($fullfile) == 'dir') {
$size += get_directory_size($fullfile, $excludefile);
} else {
$size += filesize($fullfile);
} else if ($size >= 1024) {
$size = round($size / 1024 * 10) / 10 . $kb;
} else {
- $size = $size ." $b";
+ $size = $size .' '. $b;
}
return $size;
}
/// Only these are allowed:
/// alphanumeric _ - .
- $string = eregi_replace("\.\.+", "", $string);
+ $string = eregi_replace("\.\.+", '', $string);
$string = preg_replace('/[^\.a-zA-Z\d\_-]/','_', $string ); // only allowed chars
- $string = eregi_replace("_+", "_", $string);
+ $string = eregi_replace("_+", '_', $string);
return $string;
}
}
}
-function print_string($identifier, $module="", $a=NULL) {
+function print_string($identifier, $module='', $a=NULL) {
/// Given a string to translate - prints it out.
echo get_string($identifier, $module, $a);
}
-function get_string($identifier, $module="", $a=NULL) {
+function get_string($identifier, $module='', $a=NULL) {
/// Return the translated string specified by $identifier as
/// for $module. Uses the same format files as STphp.
/// $a is an object, string or number that can be used
$lang = current_language();
- if ($module == "") {
- $module = "moodle";
+ if ($module == '') {
+ $module = 'moodle';
}
- $langpath = "$CFG->dirroot/lang";
- $langfile = "$langpath/$lang/$module.php";
+ $langpath = $CFG->dirroot .'/lang';
+ $langfile = $langpath .'/'. $lang .'/'. $module .'.php'.;
// Look for the string - if found then return it
// If it's a module, then look within the module pack itself mod/xxxx/lang/en/module.php
- if ($module != "moodle") {
- $modlangpath = "$CFG->dirroot/mod/$module/lang";
- $langfile = "$modlangpath/$lang/$module.php";
+ if ($module != 'moodle') {
+ $modlangpath = $CFG->dirroot .'/mod/'. $module .'/lang';
+ $langfile = $modlangpath .'/'. $lang .'/'. $module .'.php';
if (file_exists($langfile)) {
if ($result = get_string_from_file($identifier, $langfile, "\$resultstring")) {
eval($result);
}
// If the preferred language was English we can abort now
- if ($lang == "en") {
- return "[[$identifier]]";
+ if ($lang == 'en') {
+ return '[['. $identifier .']]';
}
// Is a parent language defined? If so, try it.
- if ($result = get_string_from_file("parentlanguage", "$langpath/$lang/moodle.php", "\$parentlang")) {
+ if ($result = get_string_from_file('parentlanguage', $langpath .'/'. $lang .'/moodle.php', "\$parentlang")) {
eval($result);
if (!empty($parentlang)) {
- $langfile = "$langpath/$parentlang/$module.php";
+ $langfile = $langpath .'/'. $parentlang .'/'. $module .'.php';
if (file_exists($langfile)) {
if ($result = get_string_from_file($identifier, $langfile, "\$resultstring")) {
eval($result);
// Our only remaining option is to try English
- $langfile = "$langpath/en/$module.php";
+ $langfile = $langpath .'/en/'. $module .'.php';
if (!file_exists($langfile)) {
- return "ERROR: No lang file ($langpath/en/$module.php)!";
+ return 'ERROR: No lang file ('. $langpath .'/en/'. $module .'.php)!';
}
if ($result = get_string_from_file($identifier, $langfile, "\$resultstring")) {
eval($result);
// If it's a module, then look within the module pack itself mod/xxxx/lang/en/module.php
- if ($module != "moodle") {
- $langfile = "$modlangpath/en/$module.php";
+ if ($module != 'moodle') {
+ $langfile = $modlangpath .'/en/'. $module .'.php';
if (file_exists($langfile)) {
if ($result = get_string_from_file($identifier, $langfile, "\$resultstring")) {
eval($result);
}
}
- return "[[$identifier]]"; // Last resort
+ return '[['. $identifier .']]'; // Last resort
}
return false;
}
- return "$destination = sprintf(\"".$string[$identifier]."\");";
+ return $destination .'= sprintf("'. $string[$identifier] .'");';
}
function get_strings($array, $module='') {
if (!empty($CFG->langlist)) { // use admin's list of languages
$langlist = explode(',', $CFG->langlist);
foreach ($langlist as $lang) {
- if (file_exists("$CFG->dirroot/lang/$lang/moodle.php")) {
- include("$CFG->dirroot/lang/$lang/moodle.php");
- $languages[$lang] = $string["thislanguage"]." ($lang)";
+ if (file_exists($CFG->dirroot .'/lang/'. $lang .'/moodle.php')) {
+ include($CFG->dirroot .'/lang/'. $lang .'/moodle.php');
+ $languages[$lang] = $string['thislanguage'].' ('. $lang .')';
unset($string);
}
}
} else {
- if (!$langdirs = get_list_of_plugins("lang")) {
+ if (!$langdirs = get_list_of_plugins('lang')) {
return false;
}
foreach ($langdirs as $lang) {
- include("$CFG->dirroot/lang/$lang/moodle.php");
- $languages[$lang] = $string["thislanguage"]." ($lang)";
+ include($CFG->dirroot .'/lang/'. $lang .'/moodle.php');
+ $languages[$lang] = $string['thislanguage'] .' ('. $lang .')';
unset($string);
}
}
$lang = current_language();
- if (!file_exists("$CFG->dirroot/lang/$lang/countries.php")) {
- if ($parentlang = get_string("parentlanguage")) {
- if (file_exists("$CFG->dirroot/lang/$parentlang/countries.php")) {
+ if (!file_exists($CFG->dirroot .'/lang/'. $lang .'/countries.php')) {
+ if ($parentlang = get_string('parentlanguage')) {
+ if (file_exists($CFG->dirroot .'/lang/'. $parentlang .'/countries.php')) {
$lang = $parentlang;
} else {
- $lang = "en"; // countries.php must exist in this pack
+ $lang = 'en'; // countries.php must exist in this pack
}
} else {
- $lang = "en"; // countries.php must exist in this pack
+ $lang = 'en'; // countries.php must exist in this pack
}
}
- include("$CFG->dirroot/lang/$lang/countries.php");
+ include($CFG->dirroot .'/lang/'. $lang .'/countries.php');
if (!empty($string)) {
asort($string);
$lang = current_language();
- if (!file_exists("$CFG->dirroot/lang/$lang/pix.php")) {
- if ($parentlang = get_string("parentlanguage")) {
- if (file_exists("$CFG->dirroot/lang/$parentlang/pix.php")) {
+ if (!file_exists($CFG->dirroot .'/lang/'. $lang .'/pix.php')) {
+ if ($parentlang = get_string('parentlanguage')) {
+ if (file_exists($CFG->dirroot .'/lang/'. $parentlang .'/pix.php')) {
$lang = $parentlang;
} else {
- $lang = "en"; // countries.php must exist in this pack
+ $lang = 'en'; // countries.php must exist in this pack
}
} else {
- $lang = "en"; // countries.php must exist in this pack
+ $lang = 'en'; // countries.php must exist in this pack
}
}
- include_once("$CFG->dirroot/lang/$lang/pix.php");
+ include_once($CFG->dirroot .'/lang/'. $lang .'/pix.php');
return $string;
}
return false;
}
- $langs = array(current_language(), get_string("parentlanguage"), "en");
+ $langs = array(current_language(), get_string('parentlanguage'), 'en');
foreach ($langs as $lang) {
- $info->filepath = "$CFG->dirroot/lang/$lang/docs/$file";
- $info->urlpath = "$CFG->wwwroot/lang/$lang/docs/$file";
+ $info->filepath = $CFG->dirroot .'/lang/'. $lang .'/docs/'. $file;
+ $info->urlpath = $CFG->wwwroot .'/lang/'. $lang .'/docs/'. $file;
if (file_exists($info->filepath)) {
if ($include) {
/// ENCRYPTION ////////////////////////////////////////////////
function rc4encrypt($data) {
- $password = "nfgjeingjk";
- return endecrypt($password, $data, "");
+ $password = 'nfgjeingjk';
+ return endecrypt($password, $data, '');
}
function rc4decrypt($data) {
- $password = "nfgjeingjk";
- return endecrypt($password, $data, "de");
+ $password = 'nfgjeingjk';
+ return endecrypt($password, $data, 'de');
}
function endecrypt ($pwd, $data, $case) {
$data = urldecode($data);
}
- $key[] = "";
- $box[] = "";
- $temp_swap = "";
+ $key[] = '';
+ $box[] = '';
+ $temp_swap = '';
$pwd_length = 0;
$pwd_length = strlen($pwd);
$box[$x] = $temp_swap;
}
- $temp = "";
- $k = "";
+ $temp = '';
+ $k = '';
- $cipherby = "";
- $cipher = "";
+ $cipherby = '';
+ $cipher = '';
$a = 0;
$j = 0;
$event->timemodified = time();
- if (!$event->id = insert_record("event", $event)) {
+ if (!$event->id = insert_record('event', $event)) {
return false;
}
if (!empty($CFG->calendar)) { // call the add_event function of the selected calendar
- if (file_exists("$CFG->dirroot/calendar/$CFG->calendar/lib.php")) {
- include_once("$CFG->dirroot/calendar/$CFG->calendar/lib.php");
+ if (file_exists($CFG->dirroot .'/calendar/'. $CFG->calendar .'/lib.php')) {
+ include_once($CFG->dirroot .'/calendar/'. $CFG->calendar .'/lib.php');
$calendar_add_event = $CFG->calendar.'_add_event';
if (function_exists($calendar_add_event)) {
$calendar_add_event($event);
$event->timemodified = time();
if (!empty($CFG->calendar)) { // call the update_event function of the selected calendar
- if (file_exists("$CFG->dirroot/calendar/$CFG->calendar/lib.php")) {
- include_once("$CFG->dirroot/calendar/$CFG->calendar/lib.php");
+ if (file_exists($CFG->dirroot .'/calendar/'. $CFG->calendar .'/lib.php')) {
+ include_once($CFG->dirroot .'/calendar/'. $CFG->calendar .'/lib.php');
$calendar_update_event = $CFG->calendar.'_update_event';
if (function_exists($calendar_update_event)) {
$calendar_update_event($event);
}
}
}
- return update_record("event", $event);
+ return update_record('event', $event);
}
global $CFG;
if (!empty($CFG->calendar)) { // call the delete_event function of the selected calendar
- if (file_exists("$CFG->dirroot/calendar/$CFG->calendar/lib.php")) {
- include_once("$CFG->dirroot/calendar/$CFG->calendar/lib.php");
+ if (file_exists($CFG->dirroot .'/calendar/'. $CFG->calendar .'/lib.php')) {
+ include_once($CFG->dirroot .'/calendar/'. $CFG->calendar .'/lib.php');
$calendar_delete_event = $CFG->calendar.'_delete_event';
if (function_exists($calendar_delete_event)) {
$calendar_delete_event($id);
}
}
}
- return delete_records("event", 'id', $id);
+ return delete_records('event', 'id', $id);
}
global $CFG;
if (!empty($CFG->calendar)) { // call the update_event function of the selected calendar
- if (file_exists("$CFG->dirroot/calendar/$CFG->calendar/lib.php")) {
- include_once("$CFG->dirroot/calendar/$CFG->calendar/lib.php");
+ if (file_exists($CFG->dirroot .'/calendar/'. $CFG->calendar .'/lib.php')) {
+ include_once($CFG->dirroot .'/calendar/'. $CFG->calendar .'/lib.php');
$calendar_hide_event = $CFG->calendar.'_hide_event';
if (function_exists($calendar_hide_event)) {
$calendar_hide_event($event);
global $CFG;
if (!empty($CFG->calendar)) { // call the update_event function of the selected calendar
- if (file_exists("$CFG->dirroot/calendar/$CFG->calendar/lib.php")) {
- include_once("$CFG->dirroot/calendar/$CFG->calendar/lib.php");
+ if (file_exists($CFG->dirroot .'/calendar/'. $CFG->calendar .'/lib.php')) {
+ include_once($CFG->dirroot .'/calendar/'. $CFG->calendar .'/lib.php');
$calendar_show_event = $CFG->calendar.'_show_event';
if (function_exists($calendar_show_event)) {
$calendar_show_event($event);
/// ENVIRONMENT CHECKING ////////////////////////////////////////////////////////////
-function get_list_of_plugins($plugin="mod", $exclude="") {
+function get_list_of_plugins($plugin='mod', $exclude='') {
/// Lists plugin directories within some directory
global $CFG;
- $basedir = opendir("$CFG->dirroot/$plugin");
+ $basedir = opendir($CFG->dirroot .'/'. $plugin);
while ($dir = readdir($basedir)) {
$firstchar = substr($dir, 0, 1);
- if ($firstchar == "." or $dir == "CVS" or $dir == "_vti_cnf" or $dir == $exclude) {
+ if ($firstchar == '.' or $dir == 'CVS' or $dir == '_vti_cnf' or $dir == $exclude) {
continue;
}
- if (filetype("$CFG->dirroot/$plugin/$dir") != "dir") {
+ if (filetype($CFG->dirroot .'/'. $plugin .'/'. $dir) != 'dir') {
continue;
}
$plugins[] = $dir;
return $plugins;
}
-function check_php_version($version="4.1.0") {
+function check_php_version($version='4.1.0') {
/// Returns true is the current version of PHP is greater that the specified one
- $minversion = intval(str_replace(".", "", $version));
- $curversion = intval(str_replace(".", "", phpversion()));
+ $minversion = intval(str_replace('.', '', $version));
+ $curversion = intval(str_replace('.', '', phpversion()));
return ($curversion >= $minversion);
}
-function check_browser_version($brand="MSIE", $version=5.5) {
+function check_browser_version($brand='MSIE', $version=5.5) {
/// Checks to see if is a browser matches the specified
/// brand and is equal or better version.
- $agent = $_SERVER["HTTP_USER_AGENT"];
+ $agent = $_SERVER['HTTP_USER_AGENT'];
if (empty($agent)) {
return false;
switch ($brand) {
- case "Gecko": /// Gecko based browsers
+ case 'Gecko': /// Gecko based browsers
- if (substr_count($agent, "Camino")) { // MacOS X Camino not supported.
+ if (substr_count($agent, 'Camino')) { // MacOS X Camino not supported.
return false;
}
break;
- case "MSIE": /// Internet Explorer
+ case 'MSIE': /// Internet Explorer
if (strpos($agent, 'Opera')) { // Reject Opera
return false;
}
- $string = explode(";", $agent);
+ $string = explode(';', $agent);
if (!isset($string[1])) {
return false;
}
- $string = explode(" ", trim($string[1]));
+ $string = explode(' ', trim($string[1]));
if (!isset($string[0]) and !isset($string[1])) {
return false;
}
$temp = ini_get($ini_get_arg);
- if ($temp == "1" or strtolower($temp) == "on") {
+ if ($temp == '1' or strtolower($temp) == 'on') {
return true;
}
return false;
global $USER, $CFG;
if (!empty($USER->htmleditor) and !empty($CFG->htmleditor)) {
- if (check_browser_version("MSIE", 5.5)) {
- return "MSIE";
- } else if (check_browser_version("Gecko", 20030516)) {
- return "Gecko";
+ if (check_browser_version('MSIE', 5.5)) {
+ return 'MSIE';
+ } else if (check_browser_version('Gecko', 20030516)) {
+ return 'Gecko';
}
}
return false;
if (function_exists('gd_info')){
$gd_info = gd_info();
- if (substr_count($gd_info['GD Version'], "2.")) {
+ if (substr_count($gd_info['GD Version'], '2.')) {
$gdversion = 2;
- } else if (substr_count($gd_info['GD Version'], "1.")) {
+ } else if (substr_count($gd_info['GD Version'], '1.')) {
$gdversion = 1;
}
foreach ($parts as $key => $val) {
$parts[$key] = trim(strip_tags($val));
}
- if ($parts[0] == "GD Version") {
- if (substr_count($parts[1], "2.0")) {
- $parts[1] = "2.0";
+ if ($parts[0] == 'GD Version') {
+ if (substr_count($parts[1], '2.0')) {
+ $parts[1] = '2.0';
}
$gdversion = intval($parts[1]);
}
/// if there are any mismatches ... returns true or false
global $CFG;
- include_once("$CFG->dirroot/version.php"); # defines $version and upgrades
+ include_once($CFG->dirroot .'/version.php'); # defines $version and upgrades
if ($CFG->version) {
if ($version > $CFG->version) {
return true;
}
- if ($mods = get_list_of_plugins("mod")) {
+ if ($mods = get_list_of_plugins('mod')) {
foreach ($mods as $mod) {
- $fullmod = "$CFG->dirroot/mod/$mod";
+ $fullmod = $CFG->dirroot .'/mod/'. $mod;
unset($module);
- if (!is_readable("$fullmod/version.php")) {
- notify("Module '$mod' is not readable - check permissions");
+ if (!is_readable($fullmod .'/version.php')) {
+ notify('Module "'. $mod .'" is not readable - check permissions');
continue;
}
- include_once("$fullmod/version.php"); # defines $module with version etc
- if ($currmodule = get_record("modules", "name", $mod)) {
+ include_once($fullmod .'/version.php'); # defines $module with version etc
+ if ($currmodule = get_record('modules', 'name', $mod)) {
if ($module->version > $currmodule->version) {
return true;
}
$CFG->notifyloginthreshold = 10; // default to something sensible.
}
- $notifyipsrs = $db->Execute("SELECT ip FROM {$CFG->prefix}log WHERE time > {$CFG->lastnotifyfailure}
- AND module='login' AND action='error' GROUP BY ip HAVING count(*) > $CFG->notifyloginthreshold");
+ $notifyipsrs = $db->Execute('SELECT ip FROM '. $CFG->prefix .'log WHERE time > '. $CFG->lastnotifyfailure .'
+ AND module=\'login\' AND action=\'error\' GROUP BY ip HAVING count(*) > '. $CFG->notifyloginthreshold);
- $notifyusersrs = $db->Execute("SELECT info FROM {$CFG->prefix}log WHERE time > {$CFG->lastnotifyfailure}
- AND module='login' AND action='error' GROUP BY info HAVING count(*) > $CFG->notifyloginthreshold");
+ $notifyusersrs = $db->Execute('SELECT info FROM '. $CFG->prefix .'log WHERE time > '. $CFG->lastnotifyfailure .'
+ AND module=\'login\' AND action=\'error\' GROUP BY info HAVING count(*) > '. $CFG->notifyloginthreshold);
if ($notifyipsrs) {
$ipstr = '';
while ($row = $notifyipsrs->FetchRow()) {
- $ipstr .= "'".$row['ip']."',";
+ $ipstr .= "'". $row['ip'] ."',";
}
$ipstr = substr($ipstr,0,strlen($ipstr)-1);
}
if ($notifyusersrs) {
$userstr = '';
while ($row = $notifyusersrs->FetchRow()) {
- $userstr .= "'".$row['info']."',";
+ $userstr .= "'". $row['info'] ."',";
}
$userstr = substr($userstr,0,strlen($userstr)-1);
}
if (strlen($userstr) > 0 || strlen($ipstr) > 0) {
$count = 0;
- $logs = get_logs("time > {$CFG->lastnotifyfailure} AND module='login' AND action='error' "
- .((strlen($ipstr) > 0 && strlen($userstr) > 0) ? " AND ( ip IN ($ipstr) OR info IN ($userstr) ) "
- : ((strlen($ipstr) != 0) ? " AND ip IN ($ipstr) " : " AND info IN ($userstr) ")),"l.time DESC","","",$count);
+ $logs = get_logs('time > '. $CFG->lastnotifyfailure .' AND module=\'login\' AND action=\'error\' '
+ .((strlen($ipstr) > 0 && strlen($userstr) > 0) ? ' AND ( ip IN ('. $ipstr .') OR info IN ('. $userstr .') ) '
+ : ((strlen($ipstr) != 0) ? ' AND ip IN ('. $ipstr .') ' : ' AND info IN ('. $userstr .') ')), 'l.time DESC', '', '', $count);
// if we haven't run in the last hour and we have something useful to report and we are actually supposed to be reporting to somebody
if (is_array($recip) and count($recip) > 0 and ((time() - (60 * 60)) > $CFG->lastnotifyfailure)
$message = '';
$site = get_site();
- $subject = get_string('notifyloginfailuressubject','',$site->fullname);
- $message .= get_string('notifyloginfailuresmessagestart','',$CFG->wwwroot)
+ $subject = get_string('notifyloginfailuressubject', '', $site->fullname);
+ $message .= get_string('notifyloginfailuresmessagestart', '', $CFG->wwwroot)
.(($CFG->lastnotifyfailure != 0) ? '('.userdate($CFG->lastnotifyfailure).')' : '')."\n\n";
foreach ($logs as $log) {
$log->time = userdate($log->time);
}
$message .= "\n\n".get_string('notifyloginfailuresmessageend','',$CFG->wwwroot)."\n\n";
foreach ($recip as $admin) {
- mtrace("Emailing $admin->username about ".count($logs)." failed login attempts");
+ mtrace('Emailing '. $admin->username .' about '. count($logs) .' failed login attempts');
email_to_user($admin,get_admin(),$subject,$message);
}
- $conf->name = "lastnotifyfailure";
+ $conf->name = 'lastnotifyfailure';
$conf->value = time();
- if ($current = get_record("config", "name", "lastnotifyfailure")) {
+ if ($current = get_record('config', 'name', 'lastnotifyfailure')) {
$conf->id = $current->id;
- if (! update_record("config", $conf)) {
- mtrace("Could not update last notify time");
+ if (! update_record('config', $conf)) {
+ mtrace('Could not update last notify time');
}
- } else if (! insert_record("config", $conf)) {
- mtrace("Could not set last notify time");
+ } else if (! insert_record('config', $conf)) {
+ mtrace('Could not set last notify time');
}
}
}
}
function random_string ($length=15) {
- $pool = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- $pool .= "abcdefghijklmnopqrstuvwxyz";
- $pool .= "0123456789";
+ $pool = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
+ $pool .= 'abcdefghijklmnopqrstuvwxyz';
+ $pool .= '0123456789';
$poollen = strlen($pool);
mt_srand ((double) microtime() * 1000000);
- $string = "";
+ $string = '';
for ($i = 0; $i < $length; $i++) {
$string .= substr($pool, (mt_rand()%($poollen)), 1);
}
global $CFG;
- $fillers = "1234567890!$-+";
+ $fillers = '1234567890!$-+';
$wordlist = file($CFG->wordlist);
srand((double) microtime() * 1000000);
}
function microtime_diff($a, $b) {
- list($a_dec, $a_sec) = explode(" ", $a);
- list($b_dec, $b_sec) = explode(" ", $b);
+ list($a_dec, $a_sec) = explode(' ', $a);
+ list($b_dec, $b_sec) = explode(' ', $b);
return $b_sec - $a_sec + $b_dec - $a_dec;
}
-function make_menu_from_list($list, $separator=",") {
+function make_menu_from_list($list, $separator=',') {
/// Given a list (eg a,b,c,d,e) this function returns
/// an array of 1->a, 2->b, 3->c etc
$grades = array();
if ($gradingtype < 0) {
- if ($scale = get_record("scale", "id", - $gradingtype)) {
+ if ($scale = get_record('scale', 'id', - $gradingtype)) {
return make_menu_from_list($scale->scale);
}
} else if ($gradingtype > 0) {
for ($i=$gradingtype; $i>=0; $i--) {
- $grades[$i] = "$i / $gradingtype";
+ $grades[$i] = $i .' / '. $gradingtype;
}
return $grades;
}
return $return;
}
-function make_unique_id_code($extra="") {
+function make_unique_id_code($extra='') {
- $hostname = "unknownhost";
- if (!empty($_SERVER["HTTP_HOST"])) {
- $hostname = $_SERVER["HTTP_HOST"];
- } else if (!empty($_ENV["HTTP_HOST"])) {
- $hostname = $_ENV["HTTP_HOST"];
- } else if (!empty($_SERVER["SERVER_NAME"])) {
- $hostname = $_SERVER["SERVER_NAME"];
- } else if (!empty($_ENV["SERVER_NAME"])) {
- $hostname = $_ENV["SERVER_NAME"];
+ $hostname = 'unknownhost';
+ if (!empty($_SERVER['HTTP_HOST'])) {
+ $hostname = $_SERVER['HTTP_HOST'];
+ } else if (!empty($_ENV['HTTP_HOST'])) {
+ $hostname = $_ENV['HTTP_HOST'];
+ } else if (!empty($_SERVER['SERVER_NAME'])) {
+ $hostname = $_SERVER['SERVER_NAME'];
+ } else if (!empty($_ENV['SERVER_NAME'])) {
+ $hostname = $_ENV['SERVER_NAME'];
}
$date = gmdate("ymdHis");
$random = random_string(6);
if ($extra) {
- return "$hostname+$date+$random+$extra";
+ return $hostname .'+'. $date .'+'. $random .'+'. $extra;
} else {
- return "$hostname+$date+$random";
+ return $hostname .'+'. $date .'+'. $random;
}
}
function address_in_subnet($addr, $subnetstr) {
- $subnets = explode(",", $subnetstr);
+ $subnets = explode(',', $subnetstr);
$found = false;
$addr = trim($addr);
foreach ($subnets as $subnet) {
$subnet = trim($subnet);
- if (strpos($subnet, "/") !== false) { /// type 1
+ if (strpos($subnet, '/') !== false) { /// type 1
list($ip, $mask) = explode('/', $subnet);
$mask = 0xffffffff << (32 - $mask);
if (defined('STDOUT')) {
fwrite(STDOUT, $string.$eol);
} else {
- echo "$string$eol";
+ echo $string . $eol;
}
flush();
function getremoteaddr() {
//Returns most reliable client address
- if (getenv("HTTP_CLIENT_IP")) $ip = getenv("HTTP_CLIENT_IP");
- else if(getenv("HTTP_X_FORWARDED_FOR")) $ip = getenv("HTTP_X_FORWARDED_FOR");
- else if(getenv("REMOTE_ADDR")) $ip = getenv("REMOTE_ADDR");
+ if (getenv('HTTP_CLIENT_IP')) $ip = getenv('HTTP_CLIENT_IP');
+ else if(getenv('HTTP_X_FORWARDED_FOR')) $ip = getenv('HTTP_X_FORWARDED_FOR');
+ else if(getenv('REMOTE_ADDR')) $ip = getenv('REMOTE_ADDR');
else $ip = false; //just in case
return $ip;
}
/// Constants
/// Define text formatting types ... eventually we can add Wiki, BBcode etc
-define("FORMAT_MOODLE", "0"); // Does all sorts of transformations and filtering
-define("FORMAT_HTML", "1"); // Plain HTML (with some tags stripped)
-define("FORMAT_PLAIN", "2"); // Plain text (even tags are printed in full)
-define("FORMAT_WIKI", "3"); // Wiki-formatted text
-define("FORMAT_MARKDOWN", "4"); // Markdown-formatted text http://daringfireball.net/projects/markdown/
+define('FORMAT_MOODLE', '0'); // Does all sorts of transformations and filtering
+define('FORMAT_HTML', '1'); // Plain HTML (with some tags stripped)
+define('FORMAT_PLAIN', '2'); // Plain text (even tags are printed in full)
+define('FORMAT_WIKI', '3'); // Wiki-formatted text
+define('FORMAT_MARKDOWN', '4'); // Markdown-formatted text http://daringfireball.net/projects/markdown/
$ALLOWED_TAGS =
-"<p><br /><b><i><u><font><table><tbody><span><div><tr><td><th><ol><ul><dl><li><dt><dd><h1><h2><h3><h4><h5><h6><hr><img><a><strong><emphasis><em><sup><sub><address><cite><blockquote><pre><strike><embed><object><param><acronym><nolink><style><lang><tex><algebra><math><mi><mn><mo><mtext><mspace><ms><mrow><mfrac><msqrt><mroot><mstyle><merror><mpadded><mphantom><mfenced><msub><msup><msubsup><munder><mover><munderover><mmultiscripts><mtable><mtr><mtd><maligngroup><malignmark><maction><cn><ci><apply><reln><fn><interval><inverse><sep><condition><declare><lambda><compose><ident><quotient><exp><factorial><divide><max><min><minus><plus><power><rem><times><root><gcd><and><or><xor><not><implies><forall><exists><abs><conjugate><eq><neq><gt><lt><geq><leq><ln><log><int><diff><partialdiff><lowlimit><uplimit><bvar><degree><set><list><union><intersect><in><notin><subset><prsubset><notsubset><notprsubset><setdiff><sum><product><limit><tendsto><mean><sdev><variance><median><mode><moment><vector><matrix><matrixrow><determinant><transpose><selector><annotation><semantics><annotation-xml><tt><code>";
+'<p><br /><b><i><u><font><table><tbody><span><div><tr><td><th><ol><ul><dl><li><dt><dd><h1><h2><h3><h4><h5><h6><hr><img><a><strong><emphasis><em><sup><sub><address><cite><blockquote><pre><strike><embed><object><param><acronym><nolink><style><lang><tex><algebra><math><mi><mn><mo><mtext><mspace><ms><mrow><mfrac><msqrt><mroot><mstyle><merror><mpadded><mphantom><mfenced><msub><msup><msubsup><munder><mover><munderover><mmultiscripts><mtable><mtr><mtd><maligngroup><malignmark><maction><cn><ci><apply><reln><fn><interval><inverse><sep><condition><declare><lambda><compose><ident><quotient><exp><factorial><divide><max><min><minus><plus><power><rem><times><root><gcd><and><or><xor><not><implies><forall><exists><abs><conjugate><eq><neq><gt><lt><geq><leq><ln><log><int><diff><partialdiff><lowlimit><uplimit><bvar><degree><set><list><union><intersect><in><notin><subset><prsubset><notsubset><notprsubset><setdiff><sum><product><limit><tendsto><mean><sdev><variance><median><mode><moment><vector><matrix><matrixrow><determinant><transpose><selector><annotation><semantics><annotation-xml><tt><code>';
/// Functions
/// returns $var with HTML characters (like "<", ">", etc.) properly quoted,
if (empty($var)) {
- return "";
+ return '';
}
return htmlSpecialChars(stripslashes_safe($var));
}
/// prints $var with HTML characters (like "<", ">", etc.) properly quoted,
if (empty($var)) {
- echo "";
+ echo '';
}
echo htmlSpecialChars(stripslashes_safe($var));
}
-function nvl(&$var, $default="") {
+function nvl(&$var, $default='') {
/// if $var is undefined, return $default, otherwise return $var
return isset($var) ? $var : $default;
function get_referer() {
/// returns the URL of the HTTP_REFERER, less the querystring portion
- return strip_querystring(nvl($_SERVER["HTTP_REFERER"]));
+ return strip_querystring(nvl($_SERVER['HTTP_REFERER']));
}
/// return different things depending on a lot of things like your OS, Web
/// server, and the way PHP is compiled (ie. as a CGI, module, ISAPI, etc.)
- if (!empty($_SERVER["REQUEST_URI"])) {
- return $_SERVER["REQUEST_URI"];
+ if (!empty($_SERVER['REQUEST_URI'])) {
+ return $_SERVER['REQUEST_URI'];
- } else if (!empty($_SERVER["PHP_SELF"])) {
- if (!empty($_SERVER["QUERY_STRING"])) {
- return $_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"];
+ } else if (!empty($_SERVER['PHP_SELF'])) {
+ if (!empty($_SERVER['QUERY_STRING'])) {
+ return $_SERVER['PHP_SELF'] .'?'. $_SERVER['QUERY_STRING'];
}
- return $_SERVER["PHP_SELF"];
+ return $_SERVER['PHP_SELF'];
- } else if (!empty($_SERVER["SCRIPT_NAME"])) {
- if (!empty($_SERVER["QUERY_STRING"])) {
- return $_SERVER["SCRIPT_NAME"]."?".$_SERVER["QUERY_STRING"];
+ } else if (!empty($_SERVER['SCRIPT_NAME'])) {
+ if (!empty($_SERVER['QUERY_STRING'])) {
+ return $_SERVER['SCRIPT_NAME'] .'?'. $_SERVER['QUERY_STRING'];
}
- return $_SERVER["SCRIPT_NAME"];
+ return $_SERVER['SCRIPT_NAME'];
- } else if (!empty($_SERVER["URL"])) { // May help IIS (not well tested)
- if (!empty($_SERVER["QUERY_STRING"])) {
- return $_SERVER["URL"]."?".$_SERVER["QUERY_STRING"];
+ } else if (!empty($_SERVER['URL'])) { // May help IIS (not well tested)
+ if (!empty($_SERVER['QUERY_STRING'])) {
+ return $_SERVER['URL'] .'?'. $_SERVER['QUERY_STRING'];
}
- return $_SERVER["URL"];
+ return $_SERVER['URL'];
} else {
- notify("Warning: Could not find any of these web server variables: \$REQUEST_URI, \$PHP_SELF, \$SCRIPT_NAME or \$URL");
+ notify('Warning: Could not find any of these web server variables: $REQUEST_URI, $PHP_SELF, $SCRIPT_NAME or $URL');
return false;
}
}
function qualified_me() {
/// like me() but returns a full URL
- if (!empty($_SERVER["SERVER_NAME"])) {
- $hostname = $_SERVER["SERVER_NAME"];
- } else if (!empty($_ENV["SERVER_NAME"])) {
- $hostname = $_ENV["SERVER_NAME"];
- } else if (!empty($_SERVER["HTTP_HOST"])) {
- $hostname = $_SERVER["HTTP_HOST"];
- } else if (!empty($_ENV["HTTP_HOST"])) {
- $hostname = $_ENV["HTTP_HOST"];
+ if (!empty($_SERVER['SERVER_NAME'])) {
+ $hostname = $_SERVER['SERVER_NAME'];
+ } else if (!empty($_ENV['SERVER_NAME'])) {
+ $hostname = $_ENV['SERVER_NAME'];
+ } else if (!empty($_SERVER['HTTP_HOST'])) {
+ $hostname = $_SERVER['HTTP_HOST'];
+ } else if (!empty($_ENV['HTTP_HOST'])) {
+ $hostname = $_ENV['HTTP_HOST'];
} else {
- notify("Warning: could not find the name of this server!");
+ notify('Warning: could not find the name of this server!');
return false;
}
if (isset($_SERVER['HTTPS'])) {
}
-function match_referer($goodreferer = "") {
+function match_referer($goodreferer = '') {
/// returns true if the referer is the same as the goodreferer. If
/// goodreferer is not specified, use qualified_me as the goodreferer
global $CFG;
return true;
}
- if ($goodreferer == "nomatch") { // Don't bother checking referer
+ if ($goodreferer == 'nomatch') { // Don't bother checking referer
return true;
}
$referer = get_referer();
- return (($referer == $goodreferer) or ($referer == "$CFG->wwwroot/"));
+ return (($referer == $goodreferer) or ($referer == $CFG->wwwroot .'/'));
}
-function data_submitted($url="") {
+function data_submitted($url='') {
/// Used on most forms in Moodle to check for data
/// Returns the data as an object, if it's found.
/// This object can be used in foreach loops without
return (object)$_POST;
} else {
if ($CFG->debug > 10) {
- notice("The form did not come from this page! (referer = ".get_referer().")");
+ notice('The form did not come from this page! (referer = '. get_referer() .')');
}
return false;
}
///
/// WARNING: do not use this on big files!!
- $temp = str_replace("\\", "\\\\", implode(file($filename), ""));
+ $temp = str_replace("\\", "\\\\", implode(file($filename), ''));
$temp = str_replace('"', '\"', $temp);
eval("\$template = \"$temp\";");
return $template;
}
}
-function frmchecked(&$var, $true_value = "checked", $false_value = "") {
+function frmchecked(&$var, $true_value = 'checked', $false_value = '') {
/// prints the word "checked" if a variable is true, otherwise prints nothing,
/// used for printing the word "checked" in a checkbox form input
}
-function link_to_popup_window ($url, $name="popup", $linkname="click here",
- $height=400, $width=500, $title="Popup window", $options="none", $return=false) {
+function link_to_popup_window ($url, $name='popup', $linkname='click here',
+ $height=400, $width=500, $title='Popup window', $options='none', $return=false) {
/// This will create a HTML link that will work on both
/// Javascript and non-javascript browsers.
/// Relies on the Javascript function openpopup in javascript.php
global $CFG;
- if ($options == "none") {
- $options = "menubar=0,location=0,scrollbars,resizable,width=$width,height=$height";
+ if ($options == 'none') {
+ $options = 'menubar=0,location=0,scrollbars,resizable,width='. $width .',height='. $height;
}
$fullscreen = 0;
$url = substr($url,strlen($CFG->wwwroot)+1);
}
- $link = "<a target=\"$name\" title=\"$title\" href=\"$CFG->wwwroot$url\" ".
+ $link = '<a target="'. $name .'" title="'. $title .'" href="'. $CFG->wwwroot . $url .'" '.
"onclick=\"return openpopup('$url', '$name', '$options', $fullscreen);\">$linkname</a>\n";
if ($return) {
return $link;
}
-function button_to_popup_window ($url, $name="popup", $linkname="click here",
- $height=400, $width=500, $title="Popup window", $options="none") {
+function button_to_popup_window ($url, $name='popup', $linkname='click here',
+ $height=400, $width=500, $title='Popup window', $options='none') {
/// This will create a HTML link that will work on both
/// Javascript and non-javascript browsers.
/// Relies on the Javascript function openpopup in javascript.php
global $CFG;
- if ($options == "none") {
- $options = "menubar=0,location=0,scrollbars,resizable,width=$width,height=$height";
+ if ($options == 'none') {
+ $options = 'menubar=0,location=0,scrollbars,resizable,width='. $width .',height='. $height;
}
$fullscreen = 0;
- echo "<input type=\"button\" name=\"popupwindow\" title=\"$title\" value=\"$linkname ...\" ".
+ echo '<input type="button" name="popupwindow" title="'. $title .'" value="'. $linkname .' ..." '.
"onClick=\"return openpopup('$url', '$name', '$options', $fullscreen);\" />\n";
}
function close_window_button() {
/// Prints a simple button to close a window
- echo "<center>\n";
- echo "<script type=\"text/javascript\">\n";
- echo "<!--\n";
+ echo '<center>' . "\n";
+ echo '<script type="text/javascript">' . "\n";
+ echo '<!--' . "\n";
echo "document.write('<form>');\n";
echo "document.write('<input type=\"button\" onClick=\"self.close();\" value=\"".get_string("closewindow")."\" />');\n";
echo "document.write('</form>');\n";
- echo "-->\n";
- echo "</script>\n";
- echo "<noscript>\n";
- echo "<a href=\"".$_SERVER['HTTP_REFERER']."\"><---</a>\n";
- echo "</noscript>\n";
- echo "</center>\n";
+ echo '-->' . "\n";
+ echo '</script>' . "\n";
+ echo '<noscript>' . "\n";
+ echo '<a href="'. $_SERVER['HTTP_REFERER'] .'"><---</a>' . "\n";
+ echo '</noscript>' . "\n";
+ echo '</center>' . "\n";
}
-function choose_from_menu ($options, $name, $selected="", $nothing="choose", $script="", $nothingvalue="0", $return=false) {
+function choose_from_menu ($options, $name, $selected='', $nothing='choose', $script='', $nothingvalue='0', $return=false) {
/// Given an array of value, creates a popup menu to be part of a form
/// $options["value"]["label"]
- if ($nothing == "choose") {
- $nothing = get_string("choose")."...";
+ if ($nothing == 'choose') {
+ $nothing = get_string('choose') .'...';
}
if ($script) {
- $javascript = "onchange=\"$script\"";
+ $javascript = 'onchange="'. $script .'"';
} else {
- $javascript = "";
+ $javascript = '';
}
- $output = "<select name=\"$name\" $javascript>\n";
+ $output = '<select name="'. $name .'" '. $javascript .'>' . "\n";
if ($nothing) {
- $output .= " <option value=\"$nothingvalue\"\n";
+ $output .= ' <option value="'. $nothingvalue .'"'. "\n";
if ($nothingvalue === $selected) {
- $output .= " selected=\"selected\"";
+ $output .= ' selected="selected"';
}
- $output .= ">$nothing</option>\n";
+ $output .= '>'. $nothing .'</option>' . "\n";
}
if (!empty($options)) {
foreach ($options as $value => $label) {
- $output .= " <option value=\"$value\"";
+ $output .= ' <option value="'. $value .'"';
if ($value == $selected) {
- $output .= " selected=\"selected\"";
+ $output .= ' selected="selected"';
}
- if ($label === "") {
- $output .= ">$value</option>\n";
+ if ($label === '') {
+ $output .= '>'. $value .'</option>' . "\n";
} else {
- $output .= ">$label</option>\n";
+ $output .= '>'. $label .'</option>' . "\n";
}
}
}
- $output .= "</select>\n";
+ $output .= '</select>' . "\n";
if ($return) {
return $output;
}
}
-function popup_form ($common, $options, $formname, $selected="", $nothing="choose", $help="", $helptext="", $return=false, $targetwindow="self") {
+function popup_form ($common, $options, $formname, $selected='', $nothing='choose', $help='', $helptext='', $return=false, $targetwindow='self') {
/// Implements a complete little popup form
/// $common = the URL up to the point of the variable that changes
/// $options = A list of value-label pairs for the popup list
return '';
}
- if ($nothing == "choose") {
- $nothing = get_string("choose")."...";
+ if ($nothing == 'choose') {
+ $nothing = get_string('choose') .'...';
}
$startoutput = '<form action="" method="get" target="'.$CFG->framename.'" name="'.$formname.'">';
$output = "<select name=\"popup\" onchange=\"$targetwindow.location=document.$formname.popup.options[document.$formname.popup.selectedIndex].value;\">\n";
- if ($nothing != "") {
+ if ($nothing != '') {
$output .= " <option value=\"javascript:void(0)\">$nothing</option>\n";
}
foreach ($options as $value => $label) {
- if (substr($label,0,2) == "--") {
- $output .= " <optgroup label=\"$label\"></optgroup>"; // Plain labels
+ if (substr($label,0,2) == '--') {
+ $output .= ' <optgroup label="'. $label .'"></optgroup>'; // Plain labels
continue;
} else {
- $output .= " <option value=\"$common$value\"";
+ $output .= ' <option value="'. $common . $value .'"';
if ($value == $selected) {
$output .= ' selected="selected"';
}
}
if ($label) {
- $output .= ">$label</option>\n";
+ $output .= '>'. $label .'</option>' . "\n";
} else {
- $output .= ">$value</option>\n";
+ $output .= '>'. $value .'</option>' . "\n";
}
}
- $output .= "</select>";
- $output .= "</form>\n";
+ $output .= '</select>';
+ $output .= '</form>' . "\n";
if ($help) {
$button = helpbutton($help, $helptext, 'moodle', true, false, '', true);
function formerr($error) {
/// Prints some red text
if (!empty($error)) {
- echo "<font color=\"#ff0000\">$error</font>";
+ echo '<font color="#ff0000">'. $error .'</font>';
}
}
return false;
}
-function get_slash_arguments($file="file.php") {
+function get_slash_arguments($file='file.php') {
/// Searches the current environment variables for some slash arguments
if (!$string = me()) {
if (detect_munged_arguments($string)) {
return false;
}
- $args = explode("/", $string);
+ $args = explode('/', $string);
if ($i) { // return just the required argument
return $args[$i];
function format_text_menu() {
/// Just returns an array of formats suitable for a popup menu
- return array (FORMAT_MOODLE => get_string("formattext"),
- FORMAT_HTML => get_string("formathtml"),
- FORMAT_PLAIN => get_string("formatplain"),
- FORMAT_WIKI => get_string("formatwiki"),
- FORMAT_MARKDOWN => get_string("formatmarkdown"));
+ return array (FORMAT_MOODLE => get_string('formattext'),
+ FORMAT_HTML => get_string('formathtml'),
+ FORMAT_PLAIN => get_string('formatplain'),
+ FORMAT_WIKI => get_string('formatwiki'),
+ FORMAT_MARKDOWN => get_string('formatmarkdown'));
}
function format_text($text, $format=FORMAT_MOODLE, $options=NULL, $courseid=NULL ) {
case FORMAT_PLAIN:
$text = htmlentities($text);
$text = rebuildnolinktag($text);
- $text = str_replace(" ", " ", $text);
+ $text = str_replace(' ', ' ', $text);
$text = nl2br($text);
break;
if (!empty($CFG->textfilters)) {
$textfilters = explode(',', $CFG->textfilters);
foreach ($textfilters as $textfilter) {
- if (is_readable("$CFG->dirroot/$textfilter/filter.php")) {
- include_once("$CFG->dirroot/$textfilter/filter.php");
+ if (is_readable($CFG->dirroot .'/'. $textfilter .'/filter.php')) {
+ include_once($CFG->dirroot .'/'. $textfilter .'/filter.php');
$functionname = basename($textfilter).'_filter';
if (function_exists($functionname)) {
$text = $functionname($courseid, $text);
/// 17/08/2004 :: Eamon DOT Costello AT dcu DOT ie
global $CFG;
- require_once("$CFG->libdir/kses.php");
+ require_once($CFG->libdir .'/kses.php');
$htmlTag = kses_stripslashes($htmlTag);
if (substr($htmlTag, 0, 1) != '<'){
if (preg_match('%/\s*$%', $attrlist)){
$xhtml_slash = ' /';
}
- return "<$slash$elem$attStr$xhtml_slash>";
+ return '<'. $slash . $elem . $attStr . $xhtml_slash .'>';
}
$alttext = get_string($image, 'pix');
$e[] = $emoticon;
- $img[] = "<img alt=\"$alttext\" width=\"15\" height=\"15\" src=\"$CFG->pixpath/s/$image.gif\" />";
+ $img[] = '<img alt="'. $alttext .'" width="15" height="15" src="'. $CFG->pixpath .'/s/'. $image.gif .'" />';
}
$runonce = true;
}
/// Wrap the whole thing in a paragraph tag if required
if ($para) {
- return "<p>".$text."</p>";
+ return '<p>'.$text.'</p>';
} else {
return $text;
}
/// Given Wiki formatted text, make it into XHTML using external function
global $CFG;
- require_once("$CFG->libdir/wiki.php");
+ require_once($CFG->libdir .'/wiki.php');
$wiki = new Wiki;
return $wiki->format($text,$courseid);
/// Given Markdown formatted text, make it into XHTML using external function
global $CFG;
- require_once("$CFG->libdir/markdown.php");
+ require_once($CFG->libdir .'/markdown.php');
return Markdown($text);
}
/// Given HTML text, make it into plain text using external function
global $CFG;
- require_once("$CFG->libdir/html2text.php");
+ require_once($CFG->libdir .'/html2text.php');
return html2text($html);
}
}
function highlight($needle, $haystack, $case=0,
- $left_string="<span class=\"highlight\">", $right_string="</span>") {
+ $left_string='<span class="highlight">', $right_string='</span>') {
/// This function will highlight search words in a given string
/// It cares about HTML and will not ruin links. It's best to use
/// this function after performing any conversions to HTML.
}
$list_of_words = eregi_replace("[^-a-zA-Z0-9&']", " ", $needle);
- $list_array = explode(" ", $list_of_words);
+ $list_array = explode(' ', $list_of_words);
for ($i=0; $i<sizeof($list_array); $i++) {
if (strlen($list_array[$i]) == 1) {
- $list_array[$i] = "";
+ $list_array[$i] = '';
}
}
- $list_of_words = implode(" ", $list_array);
+ $list_of_words = implode(' ', $list_array);
$list_of_words_cp = $list_of_words;
$final = array();
preg_match_all('/<(.+?)>/is',$haystack,$list_of_words);
}
$haystack = str_replace($final,array_keys($final),$haystack);
- $list_of_words_cp = eregi_replace(" +", "|", $list_of_words_cp);
+ $list_of_words_cp = eregi_replace(' +', '|', $list_of_words_cp);
- if ($list_of_words_cp{0}=="|") {
- $list_of_words_cp{0} = "";
+ if ($list_of_words_cp{0}=='|') {
+ $list_of_words_cp{0} = '';
}
- if ($list_of_words_cp{strlen($list_of_words_cp)-1}=="|") {
- $list_of_words_cp{strlen($list_of_words_cp)-1}="";
+ if ($list_of_words_cp{strlen($list_of_words_cp)-1}=='|') {
+ $list_of_words_cp{strlen($list_of_words_cp)-1}='';
}
- $list_of_words_cp = "(".trim($list_of_words_cp).")";
+ $list_of_words_cp = '('. trim($list_of_words_cp) .')';
if (!$case){
- $haystack = eregi_replace("$list_of_words_cp", "$left_string"."\\1"."$right_string", $haystack);
+ $haystack = eregi_replace($list_of_words_cp, $left_string ."\\1". $right_string, $haystack);
} else {
- $haystack = ereg_replace("$list_of_words_cp", "$left_string"."\\1"."$right_string", $haystack);
+ $haystack = ereg_replace($list_of_words_cp, $left_string ."\\1". $right_string, $haystack);
}
$haystack = str_replace(array_keys($final),$final,$haystack);
$parts[$key] = substr($haystack, $pos, strlen($part));
$pos += strlen($part);
- $parts[$key] .= "<span class=\"highlight\">".substr($haystack, $pos, strlen($needle))."</span>";
+ $parts[$key] .= '<span class="highlight">'.substr($haystack, $pos, strlen($needle)).'</span>';
$pos += strlen($needle);
}
/// STANDARD WEB PAGE PARTS ///////////////////////////////////////////////////
-function print_header ($title="", $heading="", $navigation="", $focus="", $meta="",
- $cache=true, $button=" ", $menu="", $usexml=false, $bodytags="") {
+function print_header ($title='', $heading='', $navigation='', $focus='', $meta='',
+ $cache=true, $button=' ', $menu='', $usexml=false, $bodytags='') {
// $title - appears top of window
// $heading - appears top of page
// $navigation - premade navigation string
$CFG->courselang = $course->lang;
}
- if (file_exists("$CFG->dirroot/theme/$CFG->theme/styles.php")) {
+ if (file_exists($CFG->dirroot .'/theme/'. $CFG->theme .'/styles.php')) {
$styles = $CFG->stylesheet;
} else {
- $styles = "$CFG->wwwroot/theme/standard/styles.php";
+ $styles = $CFG->wwwroot .'/theme/standard/styles.php';
}
- if ($navigation == "home") {
+ if ($navigation == 'home') {
$home = true;
- $navigation = "";
+ $navigation = '';
} else {
$home = false;
}
- if ($button == "") {
- $button = " ";
+ if ($button == '') {
+ $button = ' ';
}
if (!$menu and $navigation) {
$wwwroot = str_replace('http','https',$CFG->wwwroot);
}
if (isset($USER->id)) {
- $menu = "<font size=\"2\"><a target=\"$CFG->framename\" href=\"$wwwroot/login/logout.php\">".get_string("logout")."</a></font>";
+ $menu = '<font size="2"><a target="'. $CFG->framename .'" href="'. $wwwroot .'/login/logout.php">'. get_string('logout') .'</a></font>';
} else {
- $menu = "<font size=\"2\"><a target=\"$CFG->framename\" href=\"$wwwroot/login/index.php\">".get_string("login")."</a></font>";
+ $menu = '<font size="2"><a target="'. $CFG->framename .'" href="'. $wwwroot .'/login/index.php">'. get_string('login') .'</a></font>';
}
}
$meta = "<style type=\"text/css\">@import url($CFG->wwwroot/lib/editor/htmlarea.css);</style>\n$meta\n";
if (!empty($CFG->unicode)) {
- $encoding = "utf-8";
+ $encoding = 'utf-8';
} else if (!empty($CFG->courselang)) {
- $encoding = get_string("thischarset");
+ $encoding = get_string('thischarset');
moodle_setlocale();
} else {
if (!empty($SESSION->encoding)) {
$encoding = $SESSION->encoding;
} else {
- $SESSION->encoding = $encoding = get_string("thischarset");
+ $SESSION->encoding = $encoding = get_string('thischarset');
}
}
- $meta = "<meta http-equiv=\"content-type\" content=\"text/html; charset=$encoding\" />\n$meta\n";
+ $meta = '<meta http-equiv="content-type" content="text/html; charset='. $encoding .'" />'. "\n". $meta ."\n";
if (!$usexml) {
@header('Content-type: text/html; charset='.$encoding);
}
- if ( get_string("thisdirection") == "rtl" ) {
- $direction = " dir=\"rtl\"";
+ if ( get_string('thisdirection') == 'rtl' ) {
+ $direction = ' dir="rtl"';
} else {
- $direction = " dir=\"ltr\"";
+ $direction = ' dir="ltr"';
}
if (!$cache) { // Do everything we can to prevent clients and proxies caching
@header('Cache-Control: post-check=0, pre-check=0', false);
@header('Pragma: no-cache');
- $meta .= "\n<meta http-equiv=\"pragma\" content=\"no-cache\" />";
- $meta .= "\n<meta http-equiv=\"expires\" content=\"0\" />";
+ $meta .= "\n".'<meta http-equiv="pragma" content="no-cache" />';
+ $meta .= "\n".'<meta http-equiv="expires" content="0" />';
}
if ($usexml) { // Added by Gustav Delius / Mad Alex for MathML output
if(!$mathplayer) {
header('Content-Type: application/xhtml+xml');
}
- echo "<?xml version=\"1.0\" ?>\n";
+ echo '<?xml version="1.0" ?>'."\n";
if (!empty($CFG->xml_stylesheets)) {
- $stylesheets = explode(";", $CFG->xml_stylesheets);
+ $stylesheets = explode(';', $CFG->xml_stylesheets);
foreach ($stylesheets as $stylesheet) {
- echo "<?xml-stylesheet type=\"text/xsl\" href=\"$CFG->wwwroot/$stylesheet\" ?>\n";
+ echo '<?xml-stylesheet type="text/xsl" href="'. $CFG->wwwroot .'/'. $stylesheet .'" ?>' . "\n";
}
}
- echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1";
+ echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1';
if (!empty($CFG->xml_doctype_extra)) {
- echo " plus $CFG->xml_doctype_extra";
+ echo ' plus '. $CFG->xml_doctype_extra;
}
- echo "//" . strtoupper($currentlanguage) . "\" \"$CFG->xml_dtd\">\n";
+ echo '//' . strtoupper($currentlanguage) . '" "'. $CFG->xml_dtd .'">'."\n";
$direction = " xmlns=\"http://www.w3.org/1999/xhtml\"
xmlns:math=\"http://www.w3.org/1998/Math/MathML\"
xml:lang=\"en\"
$direction";
if($mathplayer) {
$meta .= '<object id="mathplayer" classid="clsid:32F66A20-7614-11D4-BD11-00104BD3F987">' . "\n";
- $meta .= "<!--comment required to prevent this becoming an empty tag-->\n";
- $meta .= "</object>\n";
+ $meta .= '<!--comment required to prevent this becoming an empty tag-->'."\n";
+ $meta .= '</object>'."\n";
$meta .= '<?import namespace="math" implementation="#mathplayer" ?>' . "\n";
}
}
$title = str_replace('"', '"', $title);
$title = strip_tags($title);
- include ("$CFG->dirroot/theme/$CFG->theme/header.html");
+ include ($CFG->dirroot .'/theme/'. $CFG->theme .'/header.html');
}
-function print_header_simple($title="", $heading="", $navigation="", $focus="", $meta="",
- $cache=true, $button=" ", $menu="", $usexml=false, $bodytags="") {
+function print_header_simple($title='', $heading='', $navigation='', $focus='', $meta='',
+ $cache=true, $button=' ', $menu='', $usexml=false, $bodytags='') {
/// This version of print_header is simpler because the course name does not have to be
/// provided explicitly in the strings. It can be used on the site page as in courses
/// Eventually all print_header could be replaced by print_header_simple
$shortname ='';
if ($course->category) {
- $shortname = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
+ $shortname = '<a href="../../course/view.php?id='. $course->id .'">'. $course->shortname .'</a> ->';
}
- print_header("$course->shortname: $title", "$course->fullname $heading", "$shortname $navigation", $focus, $meta,
+ print_header($course->shortname .': '. $title, $course->fullname .' '. $heading, $shortname .' '. $navigation, $focus, $meta,
$cache, $button, $menu, $usexml, $bodytags);
}
/// Course links
if ($course) {
- if ($course == "home") { // special case for site home page - please do not remove
- $homelink = "<p align=\"center\"><a title=\"moodle $CFG->release ($CFG->version)\" href=\"http://moodle.org/\" target=\"_blank\">";
- $homelink .= "<br /><img width=\"100\" height=\"30\" src=\"pix/moodlelogo.gif\" border=\"0\" /></a></p>";
+ if ($course == 'home') { // special case for site home page - please do not remove
+ $homelink = '<p align="center"><a title="moodle '. $CFG->release .' ('. $CFG->version .')" href="http://moodle.org/" target="_blank">';
+ $homelink .= '<br /><img width="100" height="30" src="pix/moodlelogo.gif" border="0" /></a></p>';
$course = get_site();
$homepage = true;
} else {
$homelink = "<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>";
}
} else {
- $homelink = "<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/\">".get_string("home")."</a>";
+ $homelink = "<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/\">".get_string('home').'</a>';
$course = get_site();
}
/// User links
$loggedinas = user_login_string($usercourse, $USER);
- include ("$CFG->dirroot/theme/$CFG->theme/footer.html");
+ include ($CFG->dirroot .'/theme/'. $CFG->theme .'/footer.html');
}
-function style_sheet_setup($lastmodified=0, $lifetime=300, $themename="") {
+function style_sheet_setup($lastmodified=0, $lifetime=300, $themename='') {
/// This function is called by stylesheets to set up the header
/// approriately as well as the current path
global $CFG;
- header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastmodified) . " GMT");
- header("Expires: " . gmdate("D, d M Y H:i:s", time() + $lifetime) . " GMT");
- header("Cache-control: max_age = $lifetime");
- header("Pragma: ");
- header("Content-type: text/css"); // Correct MIME type
+ header('Last-Modified: ' . gmdate("D, d M Y H:i:s", $lastmodified) . ' GMT');
+ header('Expires: ' . gmdate("D, d M Y H:i:s", time() + $lifetime) . ' GMT');
+ header('Cache-control: max_age = '. $lifetime);
+ header('Pragma: ');
+ header('Content-type: text/css'); // Correct MIME type
if (!empty($themename)) {
$CFG->theme = $themename;
}
- return "$CFG->wwwroot/theme/$CFG->theme";
+ return $CFG->wwwroot .'/theme/'. $CFG->theme;
}
}
if (isset($user->realuser)) {
- if ($realuser = get_record("user", "id", $user->realuser)) {
+ if ($realuser = get_record('user', 'id', $user->realuser)) {
$fullname = fullname($realuser, true);
$realuserinfo = " [<a target=\"{$CFG->framename}\"
href=\"$CFG->wwwroot/course/loginas.php?id=$course->id&return=$realuser->id\">$fullname</a>] ";
}
} else {
- $realuserinfo = "";
+ $realuserinfo = '';
}
if (empty($CFG->loginhttps)) {
$fullname = fullname($user, true);
$username = "<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id\">$fullname</a>";
if (isguest($user->id)) {
- $loggedinas = $realuserinfo.get_string("loggedinas", "moodle", "$username").
- " (<a target=\"{$CFG->framename}\" href=\"$wwwroot/login/index.php\">".get_string("login")."</a>)";
+ $loggedinas = $realuserinfo.get_string('loggedinas', 'moodle', $username).
+ " (<a target=\"{$CFG->framename}\" href=\"$wwwroot/login/index.php\">".get_string('login').'</a>)';
} else {
- $loggedinas = $realuserinfo.get_string("loggedinas", "moodle", "$username").
- " (<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/login/logout.php\">".get_string("logout")."</a>)";
+ $loggedinas = $realuserinfo.get_string('loggedinas', 'moodle', $username).
+ " (<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/login/logout.php\">".get_string('logout').'</a>)';
}
} else {
- $loggedinas = get_string("loggedinnot", "moodle").
- " (<a target=\"{$CFG->framename}\" href=\"$wwwroot/login/index.php\">".get_string("login")."</a>)";
+ $loggedinas = get_string('loggedinnot', 'moodle').
+ " (<a target=\"{$CFG->framename}\" href=\"$wwwroot/login/index.php\">".get_string('login').'</a>)';
}
return $loggedinas;
}
if ($navigation) {
if (! $site = get_site()) {
- $site->shortname = get_string("home");;
+ $site->shortname = get_string('home');;
}
$navigation = str_replace('->', '»', $navigation);
echo "<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/\">$site->shortname</a> » $navigation";
}
function print_headline($text, $size=2) {
- echo "<b><font size=\"$size\">$text</font></b><br />\n";
+ echo '<b><font size="'. $size .'">'. $text .'</font></b><br />'."\n";
}
-function print_heading($text, $align="center", $size=3) {
- echo "<p align=\"$align\"><font size=\"$size\"><b>".stripslashes_safe($text)."</b></font></p>";
+function print_heading($text, $align='center', $size=3) {
+ echo '<p align="'. $align .'"><font size="'. $size .'"><b>'. stripslashes_safe($text) .'</b></font></p>';
}
-function print_heading_with_help($text, $helppage, $module="moodle", $icon="") {
+function print_heading_with_help($text, $helppage, $module='moodle', $icon='') {
// Centered heading with attached help button (same title text)
// and optional icon attached
- echo "<p align=\"center\"><font size=\"3\">$icon<b>".stripslashes_safe($text);
+ echo '<p align="center"><font size="3">'. $icon .'<b>'. stripslashes_safe($text);
helpbutton($helppage, $text, $module);
- echo "</b></font></p>";
+ echo '</b></font></p>';
}
function print_continue($link) {
global $CFG;
if (!$link) {
- $link = $_SERVER["HTTP_REFERER"];
+ $link = $_SERVER['HTTP_REFERER'];
}
- print_heading("<a target=\"{$CFG->framename}\" href=\"$link\">".get_string("continue")."</a>");
+ print_heading('<a target="'. $CFG->framename .'" href="'. $link .'">'. get_string('continue').'</a>');
}
-function print_simple_box($message, $align="", $width="", $color="#FFFFFF", $padding=5, $class="generalbox") {
+function print_simple_box($message, $align='', $width='', $color='#FFFFFF', $padding=5, $class='generalbox') {
print_simple_box_start($align, $width, $color, $padding, $class);
echo stripslashes_safe($message);
print_simple_box_end();
}
-function print_simple_box_start($align="", $width="", $color="#FFFFFF", $padding=5, $class="generalbox") {
+function print_simple_box_start($align='', $width='', $color='#FFFFFF', $padding=5, $class='generalbox') {
global $THEME;
if ($align) {
- $align = "align=\"$align\"";
+ $align = 'align="'. $align .'"';
}
if ($width) {
- $width = "width=\"$width\"";
+ $width = 'width="'. $width .'"';
}
echo "<table $align $width class=\"$class\" border=\"0\" cellpadding=\"$padding\" cellspacing=\"0\"><tr><td bgcolor=\"$color\" class=\"$class"."content\">";
}
function print_simple_box_end() {
- echo "</td></tr></table>";
+ echo '</td></tr></table>';
}
-function print_single_button($link, $options, $label="OK", $method="get") {
- echo "<form action=\"$link\" method=\"$method\">";
+function print_single_button($link, $options, $label='OK', $method='get') {
+ echo '<form action="'. $link .'" method="'. $method .'">';
if ($options) {
foreach ($options as $name => $value) {
- echo "<input type=\"hidden\" name=\"$name\" value=\"$value\" />";
+ echo '<input type="hidden" name="'. $name .'" value="'. $value .'" />';
}
}
- echo "<input type=\"submit\" value=\"$label\" /></form>";
+ echo '<input type="submit" value="'. $label .'" /></form>';
}
function print_spacer($height=1, $width=1, $br=true) {
global $CFG;
- echo "<img height=\"$height\" width=\"$width\" src=\"$CFG->wwwroot/pix/spacer.gif\" alt=\"\" />";
+ echo '<img height="'. $height .'" width="'. $width .'" src="'. $CFG->wwwroot .'/pix/spacer.gif" alt="" />';
if ($br) {
- echo "<br />\n";
+ echo '<br />'."\n";
}
}
-function print_file_picture($path, $courseid=0, $height="", $width="", $link="") {
+function print_file_picture($path, $courseid=0, $height='', $width='', $link='') {
// Given the path to a picture file in a course, or a URL,
// this function includes the picture in the page.
global $CFG;
if ($height) {
- $height = "height=\"$height\"";
+ $height = 'height="'. $height .'"';
}
if ($width) {
- $width = "width=\"$width\"";
+ $width = 'width="'. $width .'"';
}
if ($link) {
- echo "<a href=\"$link\">";
+ echo '<a href="'. $link .'">';
}
- if (substr(strtolower($path), 0, 7) == "http://") {
- echo "<img border=\"0\" $height $width src=\"$path\" />";
+ if (substr(strtolower($path), 0, 7) == 'http://') {
+ echo '<img border="0" '.$height . $width .' src="'. $path .'" />';
} else if ($courseid) {
- echo "<img border=\"0\" $height $width src=\"";
+ echo '<img border="0" '. $height . $width .' src="';
if ($CFG->slasharguments) { // Use this method if possible for better caching
- echo "$CFG->wwwroot/file.php/$courseid/$path";
+ echo $CFG->wwwroot .'/file.php/'. $courseid .'/'. $path;
} else {
- echo "$CFG->wwwroot/file.php?file=/$courseid/$path";
+ echo $CFG->wwwroot .'/file.php?file=/'. $courseid .'/'. $path;
}
- echo "\" />";
+ echo '" />';
} else {
- echo "Error: must pass URL or course";
+ echo 'Error: must pass URL or course';
}
if ($link) {
- echo "</a>";
+ echo '</a>';
}
}
global $CFG;
if ($link) {
- $output = "<a href=\"$CFG->wwwroot/user/view.php?id=$userid&course=$courseid\">";
+ $output = '<a href="'. $CFG->wwwroot .'/user/view.php?id='. $userid .'&course='. $courseid .'">';
} else {
- $output = "";
+ $output = '';
}
if ($large) {
- $file = "f1";
+ $file = 'f1';
$size = 100;
} else {
- $file = "f2";
+ $file = 'f2';
$size = 35;
}
if ($picture) { // Print custom user picture
if ($CFG->slasharguments) { // Use this method if possible for better caching
- $output .= "<img align=\"middle\" src=\"$CFG->wwwroot/user/pix.php/$userid/$file.jpg\"".
- " border=\"0\" width=\"$size\" height=\"$size\" alt=\"\" />";
+ $output .= '<img align="middle" src="'. $CFG->wwwroot .'/user/pix.php/'. $userid .'/'. $file.jpg .'"'.
+ ' border="0" width="'. $size .'" height="'. $size .'" alt="" />';
} else {
- $output .= "<img align=\"middle\" src=\"$CFG->wwwroot/user/pix.php?file=/$userid/$file.jpg\"".
- " border=\"0\" width=\"$size\" height=\"$size\" alt=\"\" />";
+ $output .= '<img align="middle" src="'. $CFG->wwwroot .'/user/pix.php?file=/'. $userid .'/'. $file.jpg .'"'.
+ ' border="0" width="'. $size .'" height="'. $size .'" alt="" />';
}
} else { // Print default user pictures (use theme version if available)
$output .= "<img align=\"middle\" src=\"$CFG->pixpath/u/$file.png\"".
" border=\"0\" width=\"$size\" height=\"$size\" alt=\"\" />";
}
if ($link) {
- $output .= "</a>";
+ $output .= '</a>';
}
if ($returnstring) {
if (empty($string)) { // Cache all the strings for the rest of the page
- $string->email = get_string("email");
- $string->location = get_string("location");
- $string->lastaccess = get_string("lastaccess");
- $string->activity = get_string("activity");
- $string->unenrol = get_string("unenrol");
- $string->loginas = get_string("loginas");
- $string->fullprofile = get_string("fullprofile");
- $string->role = get_string("role");
- $string->name = get_string("name");
- $string->never = get_string("never");
-
- $datestring->day = get_string("day");
- $datestring->days = get_string("days");
- $datestring->hour = get_string("hour");
- $datestring->hours = get_string("hours");
- $datestring->min = get_string("min");
- $datestring->mins = get_string("mins");
- $datestring->sec = get_string("sec");
- $datestring->secs = get_string("secs");
+ $string->email = get_string('email');
+ $string->location = get_string('location');
+ $string->lastaccess = get_string('lastaccess');
+ $string->activity = get_string('activity');
+ $string->unenrol = get_string('unenrol');
+ $string->loginas = get_string('loginas');
+ $string->fullprofile = get_string('fullprofile');
+ $string->role = get_string('role');
+ $string->name = get_string('name');
+ $string->never = get_string('never');
+
+ $datestring->day = get_string('day');
+ $datestring->days = get_string('days');
+ $datestring->hour = get_string('hour');
+ $datestring->hours = get_string('hours');
+ $datestring->min = get_string('min');
+ $datestring->mins = get_string('mins');
+ $datestring->sec = get_string('sec');
+ $datestring->secs = get_string('secs');
$countries = get_list_of_countries();
echo '<font size="3"><b>'.fullname($user, $isteacher).'</b></font>';
echo '<p>';
if (!empty($user->role) and ($user->role <> $course->teacher)) {
- echo "$string->role: $user->role<br />";
+ echo $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 />";
+ echo $string->email .': <a href="mailto:'. $user->email .'">'. $user->email .'</a><br />';
}
if ($user->city or $user->country) {
- echo "$string->location: ";
+ echo $string->location .': ';
if ($user->city) {
echo $user->city;
}
}
echo $countries[$user->country];
}
- echo "<br />";
+ echo '<br />';
}
if ($user->lastaccess) {
- echo "$string->lastaccess: ".userdate($user->lastaccess);
- echo "  (".format_time(time() - $user->lastaccess, $datestring).")";
+ echo $string->lastaccess .': '. userdate($user->lastaccess);
+ echo '  ('. format_time(time() - $user->lastaccess, $datestring) .')';
} else {
- echo "$string->lastaccess: $string->never";
+ echo $string->lastaccess .': '. $string->never;
}
echo '</td><td valign="bottom" bgcolor="#ffffff" nowrap="nowrap" class="userinfoboxlinkcontent">';
echo '<font size="1">';
if ($isteacher) {
$timemidnight = usergetmidnight(time());
- echo "<a href=\"$CFG->wwwroot/course/user.php?id=$course->id&user=$user->id\">$string->activity</a><br />";
+ echo '<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 />";
+ echo '<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 />";
+ echo '<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>";
+ echo '<a href="'. $CFG->wwwroot .'/user/view.php?id='. $user->id .'&course='. $course->id .'">'. $string->fullprofile .'...</a>';
echo '</font>';
echo '</td></tr></table>';
}
if ($link or $isteacheredit) {
- $output = "<a href=\"$CFG->wwwroot/course/group.php?id=$courseid&group=$group->id\">";
+ $output = '<a href="'. $CFG->wwwroot .'/course/group.php?id='. $courseid .'&group='. $group->id .'">';
} else {
$output = '';
}
if ($large) {
- $file = "f1";
+ $file = 'f1';
$size = 100;
} else {
- $file = "f2";
+ $file = 'f2';
$size = 35;
}
if ($group->picture) { // Print custom group picture
}
}
if ($link or $isteacheredit) {
- $output .= "</a>";
+ $output .= '</a>';
}
if ($returnstring) {
if (isset($table->align)) {
foreach ($table->align as $key => $aa) {
if ($aa) {
- $align[$key] = " align=\"$aa\"";
+ $align[$key] = ' align="'. $aa .'"';
} else {
- $align[$key] = "";
+ $align[$key] = '';
}
}
}
if (isset($table->size)) {
foreach ($table->size as $key => $ss) {
if ($ss) {
- $size[$key] = " width=\"$ss\"";
+ $size[$key] = ' width="'. $ss .'"';
} else {
- $size[$key] = "";
+ $size[$key] = '';
}
}
}
if (isset($table->wrap)) {
foreach ($table->wrap as $key => $ww) {
if ($ww) {
- $wrap[$key] = " nowrap=\"nowrap\" ";
+ $wrap[$key] = ' nowrap="nowrap" ';
} else {
- $wrap[$key] = "";
+ $wrap[$key] = '';
}
}
}
if (empty($table->width)) {
- $table->width = "80%";
+ $table->width = '80%';
}
if (empty($table->cellpadding)) {
- $table->cellpadding = "5";
+ $table->cellpadding = '5';
}
if (empty($table->cellspacing)) {
- $table->cellspacing = "1";
+ $table->cellspacing = '1';
}
- print_simple_box_start("center", "$table->width", "#ffffff", 0);
- echo "<table width=\"100%\" border=\"0\" align=\"center\" ";
+ print_simple_box_start('center', $table->width, '#ffffff', 0);
+ echo '<table width="100%" border="0" align="center" ';
echo " cellpadding=\"$table->cellpadding\" cellspacing=\"$table->cellspacing\" class=\"generaltable\">\n";
$countcols = 0;
if (!empty($table->head)) {
$countcols = count($table->head);;
- echo "<tr>";
+ echo '<tr>';
foreach ($table->head as $key => $heading) {
if (!isset($size[$key])) {
- $size[$key] = "";
+ $size[$key] = '';
}
if (!isset($align[$key])) {
- $align[$key] = "";
+ $align[$key] = '';
}
- echo "<th valign=\"top\" ".$align[$key].$size[$key]." nowrap=\"nowrap\" class=\"generaltableheader\">$heading</th>";
+ echo '<th valign="top" '. $align[$key].$size[$key] .' nowrap="nowrap" class="generaltableheader">'. $heading .'</th>';
}
- echo "</tr>\n";
+ echo '</tr>'."\n";
}
if (!empty($table->data)) {
foreach ($table->data as $row) {
- echo "<tr valign=\"top\">";
- if ($row == "hr" and $countcols) {
- echo "<td colspan=\"$countcols\"><div class=\"tabledivider\"></div></td>";
+ echo '<tr valign="top">';
+ if ($row == 'hr' and $countcols) {
+ echo '<td colspan="'. $countcols .'"><div class="tabledivider"></div></td>';
} else { /// it's a normal row of data
foreach ($row as $key => $item) {
if (!isset($size[$key])) {
- $size[$key] = "";
+ $size[$key] = '';
}
if (!isset($align[$key])) {
- $align[$key] = "";
+ $align[$key] = '';
}
if (!isset($wrap[$key])) {
- $wrap[$key] = "";
+ $wrap[$key] = '';
}
- echo "<td ".$align[$key].$size[$key].$wrap[$key]." class=\"generaltablecell\">$item</td>";
+ echo '<td '. $align[$key].$size[$key].$wrap[$key] .' class="generaltablecell">'. $item .'</td>';
}
}
- echo "</tr>\n";
+ echo '</tr>'."\n";
}
}
- echo "</table>\n";
+ echo '</table>'."\n";
print_simple_box_end();
return true;
if (isset($table->align)) {
foreach ($table->align as $key => $aa) {
if ($aa) {
- $align[$key] = " align=\"$aa\"";
+ $align[$key] = ' align="'. $aa .'"';
} else {
- $align[$key] = "";
+ $align[$key] = '';
}
}
}
if (isset($table->size)) {
foreach ($table->size as $key => $ss) {
if ($ss) {
- $size[$key] = " width=\"$ss\"";
+ $size[$key] = ' width="'. $ss .'"';
} else {
- $size[$key] = "";
+ $size[$key] = '';
}
}
}
if (isset($table->wrap)) {
foreach ($table->wrap as $key => $ww) {
if ($ww) {
- $wrap[$key] = " nowrap=\"nowrap\" ";
+ $wrap[$key] = ' nowrap="nowrap" ';
} else {
- $wrap[$key] = "";
+ $wrap[$key] = '';
}
}
}
if (empty($table->width)) {
- $table->width = "80%";
+ $table->width = '80%';
}
if (empty($table->tablealign)) {
- $table->tablealign = "center";
+ $table->tablealign = 'center';
}
if (empty($table->cellpadding)) {
- $table->cellpadding = "5";
+ $table->cellpadding = '5';
}
if (empty($table->cellspacing)) {
- $table->cellspacing = "1";
+ $table->cellspacing = '1';
}
if (empty($table->class)) {
- $table->class = "generaltable";
+ $table->class = 'generaltable';
}
if (empty($table->fontsize)) {
- $fontsize = "";
+ $fontsize = '';
} else {
- $fontsize = "<font size=\"$table->fontsize\">";
+ $fontsize = '<font size="'. $table->fontsize .'">';
}
- $output = "<table width=\"$table->width\" valign=\"top\" align=\"$table->tablealign\" ";
- $output .= " cellpadding=\"$table->cellpadding\" cellspacing=\"$table->cellspacing\" class=\"$table->class\">\n";
+ $output = '<table width="'. $table->width .'" valign="top" align="'. $table->tablealign .'" ';
+ $output .= ' cellpadding="'. $table->cellpadding .'" cellspacing="'. $table->cellspacing .'" class="'. $table->class .'">'."\n";
if (!empty($table->head)) {
- $output .= "<tr>";
+ $output .= '<tr>';
foreach ($table->head as $key => $heading) {
if (!isset($size[$key])) {
- $size[$key] = "";
+ $size[$key] = '';
}
if (!isset($align[$key])) {
- $align[$key] = "";
+ $align[$key] = '';
}
- $output .= "<th valign=\"top\" ".$align[$key].$size[$key]." nowrap=\"nowrap\" class=\"{$table->class}header\">$fontsize$heading</th>";
+ $output .= '<th valign="top" '. $align[$key].$size[$key] .' nowrap="nowrap" class="'. $table->class .'header">'.$fontsize.$heading.'</th>';
}
- $output .= "</tr>\n";
+ $output .= '</tr>'."\n";
}
foreach ($table->data as $row) {
- $output .= "<tr valign=\"top\">";
+ $output .= '<tr valign="top">';
foreach ($row as $key => $item) {
if (!isset($size[$key])) {
- $size[$key] = "";
+ $size[$key] = '';
}
if (!isset($align[$key])) {
- $align[$key] = "";
+ $align[$key] = '';
}
if (!isset($wrap[$key])) {
- $wrap[$key] = "";
+ $wrap[$key] = '';
}
- $output .= "<td ".$align[$key].$size[$key].$wrap[$key]." class=\"{$table->class}cell\">$fontsize$item</td>";
+ $output .= '<td '. $align[$key].$size[$key].$wrap[$key] .' class="'. $table->class .'cell">'. $fontsize . $item .'</td>';
}
- $output .= "</tr>\n";
+ $output .= '</tr>'."\n";
}
- $output .= "</table>\n";
+ $output .= '</table>'."\n";
return $output;
}
-function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value="", $courseid=0) {
+function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value='', $courseid=0) {
/// Prints a basic textarea field
/// $width and height are legacy fields and no longer used
if ($usehtmleditor) {
if (!empty($courseid) and isteacher($courseid)) {
- echo "<script type=\"text/javascript\" src=\"$CFG->wwwroot/lib/editor/htmlarea.php?id=$courseid\"></script>\n";
+ echo '<script type="text/javascript" src="'. $CFG->wwwroot .'/lib/editor/htmlarea.php?id='. $courseid .'"></script>'."\n";
} else {
- echo "<script type=\"text/javascript\" src=\"$CFG->wwwroot/lib/editor/htmlarea.php\"></script>\n";
+ echo '<script type="text/javascript" src="'. $CFG->wwwroot .'/lib/editor/htmlarea.php"></script>'."\n";
}
- echo "<script type=\"text/javascript\" src=\"$CFG->wwwroot/lib/editor/dialog.js\"></script>\n";
- echo "<script type=\"text/javascript\" src=\"$CFG->wwwroot/lib/editor/lang/en.php\"></script>\n";
- echo "<script type=\"text/javascript\" src=\"$CFG->wwwroot/lib/editor/popupwin.js\"></script>\n";
+ echo '<script type="text/javascript" src="'. $CFG->wwwroot .'/lib/editor/dialog.js"></script>'."\n";
+ echo '<script type="text/javascript" src="'. $CFG->wwwroot .'/lib/editor/lang/en.php"></script>'."\n";
+ echo '<script type="text/javascript" src="'. $CFG->wwwroot .'/lib/editor/popupwin.js"></script>'."\n";
if ($rows < 10) {
$rows = 10;
echo "<textarea id=\"$name\" name=\"$name\" rows=\"$rows\" cols=\"$cols\">";
p($value);
- echo "</textarea>\n";
+ echo '</textarea>'."\n";
}
-function print_richedit_javascript($form, $name, $source="no") {
+function print_richedit_javascript($form, $name, $source='no') {
/// Legacy function, provided for backward compatability
use_html_editor($name);
}
-function use_html_editor($name="") {
+function use_html_editor($name='') {
/// Sets up the HTML editor on textareas in the current page.
/// If a field name is provided, then it will only be
/// applied to that field - otherwise it will be used
///
/// In most cases no arguments need to be supplied
- echo "<script language=\"javascript\" type=\"text/javascript\" defer=\"defer\">\n";
+ echo '<script language="javascript" type="text/javascript" defer="defer">'."\n";
print_editor_config();
if (empty($name)) {
- echo "\nHTMLArea.replaceAll(config);\n";
+ echo "\n".'HTMLArea.replaceAll(config);'."\n";
} else {
echo "\nHTMLArea.replace('$name', config);\n";
}
- echo "</script>\n";
+ echo '</script>'."\n";
}
if (isteacheredit($courseid)) {
if (!empty($USER->editing)) {
- $string = get_string("turneditingoff");
- $edit = "off";
+ $string = get_string('turneditingoff');
+ $edit = 'off';
} else {
- $string = get_string("turneditingon");
- $edit = "on";
+ $string = get_string('turneditingon');
+ $edit = 'on';
}
return "<form target=\"$CFG->framename\" method=\"get\" action=\"$CFG->wwwroot/course/view.php\">".
"<input type=\"hidden\" name=\"id\" value=\"$courseid\" />".
global $CFG;
if (isteacheredit($courseid)) {
- $string = get_string("updatethis", "", $string);
+ $string = get_string('updatethis', '', $string);
return "<form target=\"$CFG->framename\" method=\"get\" action=\"$CFG->wwwroot/course/mod.php\">".
"<input type=\"hidden\" name=\"update\" value=\"$moduleid\" />".
"<input type=\"hidden\" name=\"return\" value=\"true\" />".
"<input type=\"submit\" value=\"$string\" /></form>";
} else {
- return "";
+ return '';
}
}
if (iscreator()) {
if (!empty($USER->categoryediting)) {
- $string = get_string("turneditingoff");
- $edit = "off";
+ $string = get_string('turneditingoff');
+ $edit = 'off';
} else {
- $string = get_string("turneditingon");
- $edit = "on";
+ $string = get_string('turneditingon');
+ $edit = 'on';
}
return "<form target=\"$CFG->framename\" method=\"get\" action=\"$CFG->wwwroot/course/category.php\">".
"<input type=\"hidden\" name=\"id\" value=\"$categoryid\" />".
if (isadmin()) {
if (!empty($USER->categoriesediting)) {
- $string = get_string("turneditingoff");
- $edit = "off";
+ $string = get_string('turneditingoff');
+ $edit = 'off';
} else {
- $string = get_string("turneditingon");
- $edit = "on";
+ $string = get_string('turneditingon');
+ $edit = 'on';
}
return "<form target=\"$CFG->framename\" method=\"get\" action=\"$CFG->wwwroot/course/index.php\">".
"<input type=\"hidden\" name=\"edit\" value=\"$edit\" />".
if (isteacheredit($courseid)) {
if (!empty($USER->groupsediting)) {
- $string = get_string("turneditingoff");
- $edit = "off";
+ $string = get_string('turneditingoff');
+ $edit = 'off';
} else {
- $string = get_string("turneditingon");
- $edit = "on";
+ $string = get_string('turneditingon');
+ $edit = 'on';
}
return "<form target=\"$CFG->framename\" method=\"get\" action=\"$CFG->wwwroot/course/groups.php\">".
"<input type=\"hidden\" name=\"id\" value=\"$courseid\" />".
/// Prints an appropriate group selection menu
/// Add an "All groups" to the start of the menu
- $groupsmenu[0] = get_string("allparticipants");
+ $groupsmenu[0] = get_string('allparticipants');
foreach ($groups as $key => $groupname) {
$groupsmenu[$key] = $groupname;
}
}
echo ':';
echo '</td><td nowrap="nowrap" align="left">';
- popup_form($urlroot.'&group=', $groupsmenu, 'selectgroup', $currentgroup, "", "", "", false, "self");
+ popup_form($urlroot.'&group=', $groupsmenu, 'selectgroup', $currentgroup, '', '', '', false, 'self');
echo '</tr></table>';
}
-function navmenu($course, $cm=NULL, $targetwindow="self") {
+function navmenu($course, $cm=NULL, $targetwindow='self') {
// Given a course and a (current) coursemodule
// This function returns a small popup menu with all the
// course activity modules in it, as a navigation menu
}
if ($course->format == 'weeks') {
- $strsection = get_string("week");
+ $strsection = get_string('week');
} else {
- $strsection = get_string("topic");
+ $strsection = get_string('topic');
}
if (!$modinfo = unserialize($course->modinfo)) {
- return "";
+ return '';
}
$isteacher = isteacher($course->id);
$section = -1;
- $selected = "";
- $url = "";
+ $selected = '';
+ $url = '';
$previousmod = NULL;
$backmod = NULL;
$nextmod = NULL;
$menu = array();
$strjumpto = get_string('jumpto');
- $sections = get_records('course_sections','course',$course->id,'section',"section,visible,summary");
+ $sections = get_records('course_sections','course',$course->id,'section','section,visible,summary');
foreach ($modinfo as $mod) {
- if ($mod->mod == "label") {
+ if ($mod->mod == 'label') {
continue;
}
if ($thissection->visible or !$course->hiddensections or $isteacher) {
$thissection->summary = strip_tags($thissection->summary);
if ($course->format == 'weeks' or empty($thissection->summary)) {
- $menu[] = "-------------- $strsection $mod->section --------------";
+ $menu[] = '-------------- '. $strsection ." ". $mod->section .' --------------';
} else {
if (strlen($thissection->summary) < 47) {
$menu[] = '-- '.$thissection->summary;
//Only add visible or teacher mods to jumpmenu
if ($mod->visible or $isteacher) {
- $url = "$mod->mod/view.php?id=$mod->cm";
+ $url = $mod->mod .'/view.php?id='. $mod->cm;
if ($flag) { // the current mod is the "next" mod
$nextmod = $mod;
$flag = false;
} else {
$mod->name = strip_tags(urldecode($mod->name));
if (strlen($mod->name) > 55) {
- $mod->name = substr($mod->name, 0, 50)."...";
+ $mod->name = substr($mod->name, 0, 50).'...';
}
if (!$mod->visible) {
- $mod->name = "(".$mod->name.")";
+ $mod->name = '('.$mod->name.')';
}
}
$menu[$url] = $mod->name;
"<input type=\"hidden\" name=\"id\" value=\"$nextmod->cm\" />".
"<input type=\"submit\" value=\">\" /></form>";
}
- return "<table><tr>$logslink<td>$backmod</td><td>" .
- popup_form("$CFG->wwwroot/mod/", $menu, "navmenu", $selected, $strjumpto,
- "", "", true, $targetwindow).
- "</td><td>$nextmod</td></tr></table>";
+ return '<table><tr>'.$logslink .'<td>'. $backmod .'</td><td>' .
+ popup_form($CFG->wwwroot .'/mod/', $menu, 'navmenu', $selected, $strjumpto,
+ '', '', true, $targetwindow).
+ '</td><td>'. $nextmod .'</td></tr></table>';
}
$currentdate = usergetdate($currenttime);
for ($i=1; $i<=31; $i++) {
- $days[$i] = "$i";
+ $days[$i] = $i;
}
for ($i=1; $i<=12; $i++) {
$months[$i] = userdate(gmmktime(12,0,0,$i,1,2000), "%B");
for ($i=2000; $i<=2010; $i++) {
$years[$i] = $i;
}
- choose_from_menu($days, $day, $currentdate['mday'], "");
- choose_from_menu($months, $month, $currentdate['mon'], "");
- choose_from_menu($years, $year, $currentdate['year'], "");
+ choose_from_menu($days, $day, $currentdate['mday'], '');
+ choose_from_menu($months, $month, $currentdate['mon'], '');
+ choose_from_menu($years, $year, $currentdate['year'], '');
}
function print_time_selector($hour, $minute, $currenttime=0, $step=5) {
for ($i=0; $i<=59; $i+=$step) {
$minutes[$i] = sprintf("%02d",$i);
}
- choose_from_menu($hours, $hour, $currentdate['hours'], "");
- choose_from_menu($minutes, $minute, $currentdate['minutes'], "");
+ choose_from_menu($hours, $hour, $currentdate['hours'], '');
+ choose_from_menu($minutes, $minute, $currentdate['minutes'], '');
}
-function print_timer_selector($timelimit = 0, $unit = "") {
+function print_timer_selector($timelimit = 0, $unit = '') {
/// Prints time limit value selector
global $CFG;
for ($i=1; $i<=$maxvalue; $i++) {
$minutes[$i] = $i.$unit;
}
- choose_from_menu($minutes, "timelimit", $timelimit, get_string("none"));
+ choose_from_menu($minutes, 'timelimit', $timelimit, get_string('none'));
}
function print_grade_menu($courseid, $name, $current, $includenograde=true) {
global $CFG;
- $strscale = get_string("scale");
- $strscales = get_string("scales");
+ $strscale = get_string('scale');
+ $strscales = get_string('scales');
$scales = get_scales_menu($courseid);
foreach ($scales as $i => $scalename) {
- $grades[-$i] = "$strscale: $scalename";
+ $grades[-$i] = $strscale .': '. $scalename;
}
if ($includenograde) {
- $grades[0] = get_string("nograde");
+ $grades[0] = get_string('nograde');
}
for ($i=100; $i>=1; $i--) {
$grades[$i] = $i;
}
- choose_from_menu($grades, "$name", "$current", "");
+ choose_from_menu($grades, $name, $current, '');
- $helpicon = "$CFG->pixpath/help.gif";
+ $helpicon = $CFG->pixpath .'/help.gif';
$linkobject = "<img align=\"middle\" border=\"0\" height=\"17\" width=\"22\" alt=\"$strscales\" src=\"$helpicon\" />";
- link_to_popup_window ("/course/scales.php?id=$courseid&list=true", "ratingscales",
+ link_to_popup_window ('/course/scales.php?id='. $courseid .'&list=true', 'ratingscales',
$linkobject, 400, 500, $strscales);
}
global $CFG;
- $strscales = get_string("scales");
- choose_from_menu(get_scales_menu($courseid), "$name", $current, "");
- $helpicon = "$CFG->pixpath/help.gif";
+ $strscales = get_string('scales');
+ choose_from_menu(get_scales_menu($courseid), $name, $current, '');
+ $helpicon = $CFG->pixpath .'/help.gif';
$linkobject = "<img align=\"middle\" border=\"0\" height=\"17\" width=\"22\" alt=\"$strscales\" src=\"$helpicon\" />";
- link_to_popup_window ("/course/scales.php?id=$courseid&list=true", "ratingscales",
+ link_to_popup_window ('/course/scales.php?id='. $courseid .'&list=true', 'ratingscales',
$linkobject, 400, 500, $strscales);
}
global $CFG;
- $strscales = get_string("scales");
- $helpicon = "$CFG->pixpath/help.gif";
+ $strscales = get_string('scales');
+ $helpicon = $CFG->pixpath .'/help.gif';
$linkobject = "<img align=\"middle\" border=\"0\" height=\"17\" width=\"22\" alt=\"$scale->name\" src=\"$helpicon\" />";
- link_to_popup_window ("/course/scales.php?id=$courseid&list=true&scale=$scale->id", "ratingscale",
+ link_to_popup_window ('/course/scales.php?id='. $courseid .'&list=true&scale='. $scale->id, 'ratingscale',
$linkobject, 400, 500, $scale->name);
}
-function error ($message, $link="") {
+function error ($message, $link='') {
global $CFG, $SESSION;
- print_header(get_string("error"));
- echo "<br />";
- print_simple_box($message, "center", "", "#FFBBBB");
+ print_header(get_string('error'));
+ echo '<br />';
+ print_simple_box($message, 'center', '', '#FFBBBB');
if (!$link) {
if ( !empty($SESSION->fromurl) ) {
- $link = "$SESSION->fromurl";
+ $link = $SESSION->fromurl;
unset($SESSION->fromurl);
} else {
- $link = "$CFG->wwwroot/";
+ $link = $CFG->wwwroot .'/';
}
}
print_continue($link);
die;
}
-function helpbutton ($page, $title="", $module="moodle", $image=true, $linktext=false, $text="", $return=false) {
+function helpbutton ($page, $title='', $module='moodle', $image=true, $linktext=false, $text='', $return=false) {
// $page = the keyword that defines a help page
// $title = the title of links, rollover tips, alt tags etc
// $module = which module is the page defined in
// the $page variable is ignored.
global $CFG, $THEME;
- if ($module == "") {
- $module = "moodle";
+ if ($module == '') {
+ $module = 'moodle';
}
if ($image) {
- $icon = "$CFG->pixpath/help.gif";
+ $icon = $CFG->pixpath .'/help.gif';
if ($linktext) {
$linkobject = "<span style=\"cursor:help;\">$title<img align=\"middle\" border=\"0\" ".
" height=\"17\" width=\"22\" alt=\"\" src=\"$icon\" /></span>";
" alt=\"$title\" style=\"cursor:help;\" src=\"$icon\" />";
}
} else {
- $linkobject = "<span style=\"cursor:help;\">$title</span>";
+ $linkobject = '<span style="cursor:help;">'. $title .'</span>';
}
if ($text) {
- $url = "/help.php?module=$module&text=".htmlentities(urlencode($text));
+ $url = '/help.php?module='. $module .'&text='. htmlentities(urlencode($text));
} else {
- $url = "/help.php?module=$module&file=$page.html";
+ $url = '/help.php?module='. $module .'&file='. $page .'.html';
}
- $link = link_to_popup_window ($url, "popup", $linkobject, 400, 500, $title, 'none', true);
+ $link = link_to_popup_window ($url, 'popup', $linkobject, 400, 500, $title, 'none', true);
if ($return) {
return $link;
$SESSION->inserttextform = $form;
$SESSION->inserttextfield = $field;
- helpbutton("emoticons", get_string("helpemoticons"), "moodle", false, true);
- echo " ";
- link_to_popup_window ("/help.php?module=moodle&file=emoticons.html", "popup",
+ helpbutton('emoticons', get_string('helpemoticons'), 'moodle', false, true);
+ echo ' ';
+ link_to_popup_window ('/help.php?module=moodle&file=emoticons.html', 'popup',
"<img src=\"$CFG->pixpath/s/smiley.gif\" border=\"0\" align=\"middle\" width=\"15\" height=\"15\" alt=\"\" />",
- 400, 500, get_string("helpemoticons"));
- echo "<br />";
+ 400, 500, get_string('helpemoticons'));
+ echo '<br />';
}
-function notice ($message, $link="") {
+function notice ($message, $link='') {
global $CFG, $THEME;
if (!$link) {
- if (!empty($_SERVER["HTTP_REFERER"])) {
- $link = $_SERVER["HTTP_REFERER"];
+ if (!empty($_SERVER['HTTP_REFERER'])) {
+ $link = $_SERVER['HTTP_REFERER'];
} else {
- $link = "$CFG->wwwroot/";
+ $link = $CFG->wwwroot .'/';
}
}
- echo "<br />";
- print_simple_box($message, "center", "50%", "$THEME->cellheading", "20", "noticebox");
- print_heading("<a href=\"$link\">".get_string("continue")."</a>");
+ echo '<br />';
+ print_simple_box($message, 'center', '50%', $THEME->cellheading, '20', 'noticebox');
+ print_heading('<a href="'. $link .'">'. get_string('continue') .'</a>');
print_footer(get_site());
die;
}
function notice_yesno ($message, $linkyes, $linkno) {
global $THEME;
- print_simple_box_start("center", "60%", "$THEME->cellheading");
- echo "<p align=\"center\"><font size=\"3\">$message</font></p>";
- echo "<p align=\"center\"><font size=\"3\"><b>";
- echo "<a href=\"$linkyes\">".get_string("yes")."</a>";
- echo " ";
- echo "<a href=\"$linkno\">".get_string("no")."</a>";
- echo "</b></font></p>";
+ print_simple_box_start('center', '60%', $THEME->cellheading);
+ echo '<p align="center"><font size="3">'. $message .'</font></p>';
+ echo '<p align="center"><font size="3"><b>';
+ echo '<a href="'. $linkyes .'">'. get_string('yes') .'</a>';
+ echo ' ';
+ echo '<a href="'. $linkno .'">'. get_string('no') .'</a>';
+ echo '</b></font></p>';
print_simple_box_end();
}
-function redirect($url, $message="", $delay="0") {
+function redirect($url, $message='', $delay='0') {
// Redirects the user to another page, after printing a notice
// '&' needs to be encoded into '&' for XHTML compliance,
$url = html_entity_decode($url); // for php < 4.3.0 this is defined in moodlelib.php
$encodedurl = htmlentities($url);
if (empty($message)) {
- echo "<meta http-equiv=\"refresh\" content=\"$delay; url=$encodedurl\" />";
- echo "<script type=\"text/javascript\">\n<!--\nlocation.replace('$url');\n//-->\n</script>"; // To cope with Mozilla bug
+ echo '<meta http-equiv="refresh" content="'. $delay .'; url='. $encodedurl .'" />';
+ echo '<script type="text/javascript">'. "\n" .'<!--'. "\n". 'location.replace(\'$url\');'. "\n". '//-->'. "\n". '</script>'; // To cope with Mozilla bug
} else {
if (empty($delay)) {
$delay = 3; // There's no point having a message with no delay
}
- print_header("", "", "", "", "<meta http-equiv=\"refresh\" content=\"$delay; url=$encodedurl\" />");
- echo "<center>";
- echo "<p>$message</p>";
- echo "<p>( <a href=\"$encodedurl\">".get_string("continue")."</a> )</p>";
- echo "</center>";
+ print_header('', '', '', '', '<meta http-equiv="refresh" content="'. $delay .'; url='. $encodedurl .'" />');
+ echo '<center>';
+ echo '<p>'. $message .'</p>';
+ echo '<p>( <a href="'. $encodedurl .'">'. get_string('continue') .'</a> )</p>';
+ echo '</center>';
flush();
sleep($delay);
- echo "<script type=\"text/javascript\">\n<!--\nlocation.replace('$url');\n//-->\n</script>"; // To cope with Mozilla bug
+ echo '<script type="text/javascript">'."\n".'<!--'."\n".'location.replace(\'$url\');'."\n".'//-->'."\n".'</script>'; // To cope with Mozilla bug
}
die;
}
-function notify ($message, $color="red", $align="center") {
- echo "<p align=\"$align\"><b><font color=\"$color\">$message</font></b></p>\n";
+function notify ($message, $color='red', $align='center') {
+ echo '<p align="'. $align .'"><b><font color="'. $color .'">'. $message .'</font></b></p>' . "\n";
}
function obfuscate_email($email) {
/// Given an email address, this function will return an obfuscated version of it
$i = 0;
$length = strlen($email);
- $obfuscated = "";
+ $obfuscated = '';
while ($i < $length) {
if (rand(0,2)) {
$obfuscated.='%'.dechex(ord($email{$i}));
/// with HTML entity equivalents. Return string is obviously longer.
$i=0;
$length = strlen($plaintext);
- $obfuscated="";
+ $obfuscated='';
$prev_obfuscated = false;
while ($i < $length) {
$c = ord($plaintext{$i});
return $obfuscated;
}
-function obfuscate_mailto($email, $label="", $dimmed=false) {
+function obfuscate_mailto($email, $label='', $dimmed=false) {
/// This function uses the above two functions to generate a fully
/// obfuscated email link, ready to use.
$maxdisplay = 18;
if ($totalcount > $perpage) {
- echo "<center>";
- echo "<p>".get_string("page").":";
+ echo '<center>';
+ echo '<p>'.get_string('page').':';
if ($page > 0) {
$pagenum=$page-1;
- echo " (<a href=\"{$baseurl}page=$pagenum\">".get_string("previous")."</a>) ";
+ echo ' (<a href="'. $baseurl .'page='. $pagenum .'">'. get_string('previous') .'</a>) ';
}
$lastpage = ceil($totalcount / $perpage);
if ($page > 15) {
$startpage = $page - 10;
- echo " <a href=\"{$baseurl}page=0\">1</a> ...";
+ echo ' <a href="'. $baseurl .'page=0">1</a> ...';
} else {
$startpage = 0;
}
while ($displaycount < $maxdisplay and $currpage < $lastpage) {
$displaypage = $currpage+1;
if ($page == $currpage) {
- echo " $displaypage";
+ echo ' '. $displaypage;
} else {
- echo " <a href=\"{$baseurl}page=$currpage\">$displaypage</a>";
+ echo ' <a href="'. $baseurl .'page='. $currpage .'">'. $displaypage .'</a>';
}
$displaycount++;
$currpage++;
}
if ($currpage < $lastpage) {
$lastpageactual = $lastpage - 1;
- echo " ...<a href=\"{$baseurl}page=$lastpageactual\">$lastpage</a> ";
+ echo ' ...<a href="'. $baseurl .'page='. $lastpageactual .'">'. $lastpage .'</a> ';
}
$pagenum = $page + 1;
if ($pagenum != $displaypage) {
- echo " (<a href=\"{$baseurl}page=$pagenum\">".get_string("next")."</a>)";
+ echo ' (<a href="'. $baseurl .'page='. $pagenum .'">'. get_string('next') .'</a>)';
}
- echo "</p>";
- echo "</center>";
+ echo '</p>';
+ echo '</center>';
}
}
if ($content) {
echo $content;
if ($footer) {
- echo "<center><font size=\"-2\">$footer</font></center>";
+ echo '<center><font size="-2">'. $footer .'</font></center>';
}
} else {
- echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">";
+ echo '<table width="100%" border="0" cellspacing="0" cellpadding="2">';
if ($list) {
foreach ($list as $key => $string) {
- echo "<tr bgcolor=\"$THEME->cellcontent2\">";
+ echo '<tr bgcolor="'. $THEME->cellcontent2 .'">';
if ($icons) {
- echo "<td class=\"sideblocklinks\" valign=\"top\" width=\"16\">".$icons[$key]."</td>";
+ echo '<td class="sideblocklinks" valign="top" width="16">'. $icons[$key] .'</td>';
}
- echo "<td class=\"sideblocklinks\" valign=\"top\" width=\"*\"><font size=\"-1\">$string</font></td>";
- echo "</tr>";
+ echo '<td class="sideblocklinks" valign="top" width="*"><font size="-1">'. $string .'</font></td>';
+ echo '</tr>';
}
}
if ($footer) {
- echo "<tr bgcolor=\"$THEME->cellcontent2\">";
- echo "<td class=\"sideblocklinks\" ";
+ echo '<tr bgcolor="'. $THEME->cellcontent2 .'">';
+ echo '<td class="sideblocklinks" ';
if ($icons) {
echo ' colspan="2" ';
}
echo '>';
- echo "<center><font size=\"-2\">$footer</font></center>";
- echo "</td></tr>";
+ echo '<center><font size="-2">'. $footer .'</font></center>';
+ echo '</td></tr>';
}
- echo "</table>";
+ echo '</table>';
}
print_side_block_end();
global $CFG;
// print new config
- echo "var config = new HTMLArea.Config();\n";
+ echo 'var config = new HTMLArea.Config();'."\n";
echo "config.pageStyle = \"body {";
if(!(empty($CFG->editorbackgroundcolor))) {
echo " background-color: $CFG->editorbackgroundcolor;";
echo " }\";\n";
echo "config.killWordOnPaste = ";
echo(empty($CFG->editorkillword)) ? "false":"true";
- echo ";\n";
- echo "config.fontname = {\n";
+ echo ';'."\n";
+ echo 'config.fontname = {'."\n";
$fontlist = isset($CFG->editorfontlist) ? explode(';', $CFG->editorfontlist) : array();
$i = 1; // Counter is used to get rid of the last comma.
foreach($fontlist as $fontline) {
if(!empty($fontline)) {
- list($fontkey, $fontvalue) = split(":", $fontline);
- echo "\"". $fontkey ."\":\t'". $fontvalue ."'";
+ list($fontkey, $fontvalue) = split(':', $fontline);
+ echo '"'. $fontkey ."\":\t'". $fontvalue ."'";
if($i < $count) {
- echo ",\n";
+ echo ','."\n";
}
}
$i++;
}
- echo "};";
+ echo '};';
if(!empty($CFG->editorspelling) && !empty($CFG->aspellpath)) {
print_speller_code($usehtmleditor=true);
}
global $CFG;
if(!$usehtmleditor) {
- echo "\n<script language=\"javascript\" type=\"text/javascript\">\n";
- echo "function openSpellChecker() {\n";
+ echo "\n".'<script language="javascript" type="text/javascript">'."\n";
+ echo 'function openSpellChecker() {'."\n";
echo "\tvar speller = new spellChecker();\n";
echo "\tspeller.popUpUrl = \"" . $CFG->wwwroot ."/lib/speller/spellchecker.html\";\n";
echo "\tspeller.spellCheckScript = \"". $CFG->wwwroot ."/lib/speller/server-scripts/spellchecker.php\";\n";
echo "\tspeller.spellCheckAll();\n";
- echo "}\n";
- echo "</script>\n";
+ echo '}'."\n";
+ echo '</script>'."\n";
} else {
echo "\nfunction spellClickHandler(editor, buttonId) {\n";
echo "\teditor._textArea.value = editor.getHTML();\n";
echo "\tspeller._moogle_edit=1;\n";
echo "\tspeller._editor=editor;\n";
echo "\tspeller.openChecker();\n";
- echo "}\n";
+ echo '}'."\n";
}
}
function print_speller_button () {
// print button for spellchecking
// when editor is disabled
- echo "<input type=\"button\" value=\"Check spelling\" onclick=\"openSpellChecker();\" />\n";
+ echo '<input type="button" value="Check spelling" onclick="openSpellChecker();" />'."\n";
}
// vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140:
-?>
+?>
\ No newline at end of file