### Eclipse Workspace Patch 1.0
#P moodle
Index: course/edit_form.php
===================================================================
RCS file: /cvsroot/moodle/moodle/course/edit_form.php,v
retrieving revision 1.25
diff -u -r1.25 edit_form.php
--- course/edit_form.php 21 Jan 2007 09:26:33 -0000 1.25
+++ course/edit_form.php 26 Feb 2007 07:26:04 -0000
@@ -349,6 +349,14 @@
$mform->addElement('hidden', 'students', get_string('defaultcoursestudents'));
}
+ function definition_after_data(){
+ $mform =& $this->_form;
+
+ $mform->applyFilter('fullname', 'tidy_title');
+ $mform->applyFilter('shortname', 'tidy_title');
+ $mform->applyFilter('summary', 'tidy_html');
+ }
+
/// perform some extra moodle validation
function validation($data){
Index: lib/weblib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/weblib.php,v
retrieving revision 1.822
diff -u -r1.822 weblib.php
--- lib/weblib.php 24 Feb 2007 10:19:15 -0000 1.822
+++ lib/weblib.php 26 Feb 2007 07:26:12 -0000
@@ -1363,39 +1363,31 @@
}
/**
- * Prepare title for course, activity, post, ...
- * This function is safe to use on untrusted content.
+ * Do same basic tidying of user submitted title
*
- * @since 1.8
- *
- * @param string $string The string to be filtered (without magic quotes).
- * @param boolean $plaintext Convert string to plaintext, otherwise keep fancy html tags
- * @param int $courseid Current course as filters can, potentially, use it
+ * @param string text
* @return string
*/
-function format_title($string, $plaintext=true, $courseid=null) {
- global $CFG;
+function tidy_title($string) {
- if ($plaintext) {
- /// use filters if required (mostly multilang) and convert to plain text
- return s(format_string($string, true, $courseid));
+ // Any lonely ampersands present, convert them using negative lookahead
+ return preg_replace("/\&(?![a-z]+;|#\d+;)([^&]*)/", "&$1", $string);
+}
+/**
+ * Do html cleanup using tidyhtml if present and allowed
+ *
+ * @param string text
+ * @return string
+ */
+function tidy_html($string) {
+ //TODO: add config option and configure htmltidy engine
+ //tidy 2.0 for now only (from PHP 5)
+ if (function_exists('tidy_repair_string') and !function_exists('tidy_save_config')) {
+ $config = array('new-inline-tags'=>'tex', 'new-blocklevel-tags'=>'nolink', 'show-body-only'=>'1');
+ return tidy_repair_string($string, $config, 'utf8');
} else {
- /// tidy up common html validity problems and format the text, keep safe html
-
- // Any lonely ampersands present, convert them using negative lookahead - xhtml strict cleanup
- $string = preg_replace("/\&(?![a-z]+;|#\d+;)([^&]*)/", "&$1", $string);
-
- // TODO: try to add some detection of lonely < and > and convert them to html entitites
-
- // use filters if needed and cleam text
- $options = new object();
- $options->smiley = false;
- $options->filter = !empty($CFG->filterall);
- $string = format_text($string, FORMAT_HTML, $options, $courseid);
-
- //filters often produce links, we do not want these in titles
- return preg_replace('/(]+?>)(.+?)(<\/a>)/is','$2', $string);
+ return $string;
}
}
@@ -2813,16 +2805,44 @@
}
if ($navigation) {
+
+ if (!is_array($navigation)) {
+ $ar = explode('->', $navigation);
+ $navigation = array();
+ foreach ($ar as $a) {
+ if (strpos($a, '') === false) {
+ $navigation[trim($a)] = '';
+ } else {
+ if (preg_match('/(.*)<\/a>/', $a, $matches)) {
+ $navigation[trim($matches[2])] = $matches[1];
+ }
+ }
+ }
+ }
+
+ if (! $site = get_site()) {
+ $site = new object();
+ $site->shortname = get_string('home');
+ }
+
//Accessibility: breadcrumb links now in a list, » replaced with a 'silent' character.
$nav_text = get_string('youarehere','access');
$output .= ''.$nav_text."
\n";
}