Skip to content

Commit

Permalink
MDL-20204 fixed html-writer::tag() parameter order to match the rest …
Browse files Browse the repository at this point in the history
…of the api
  • Loading branch information
skodak committed Feb 18, 2010
1 parent d896fd5 commit 26acc81
Show file tree
Hide file tree
Showing 18 changed files with 109 additions and 118 deletions.
2 changes: 1 addition & 1 deletion blocks/blog_menu/block_blog_menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function get_content() {

if (!empty($blogheaders['strview']) && $CFG->useblogassociations) {
if ($blogheaders['url']->compare($PAGE->url) == URL_MATCH_EXACT) {
$menulist[] = html_writer::tag('span', array('class'=>'current'), $blogheaders['strview']);
$menulist[] = html_writer::tag('span', $blogheaders['strview'], array('class'=>'current'));
} else {
$menulist[] = html_writer::link($blogheaders['url'], $blogheaders['strview']);
}
Expand Down
16 changes: 8 additions & 8 deletions grade/report/grader/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ public function get_right_rows() {
if (!$this->canviewhidden and $grade->is_hidden()) {
if (!empty($CFG->grade_hiddenasdate) and $grade->get_datesubmitted() and !$item->is_category_item() and !$item->is_course_item()) {
// the problem here is that we do not have the time when grade value was modified, 'timemodified' is general modification date for grade_grades records
$itemcell->text = html_writer::tag('span', array('class'=>'datesubmitted'), userdate($grade->get_datesubmitted(),get_string('strftimedatetimeshort')));
$itemcell->text = html_writer::tag('span', userdate($grade->get_datesubmitted(),get_string('strftimedatetimeshort')), array('class'=>'datesubmitted'));
} else {
$itemcell->text = '-';
}
Expand Down Expand Up @@ -858,7 +858,7 @@ public function get_right_rows() {
}

if ($grade->is_excluded()) {
$itemcell->text .= html_writer::tag('span', array('class'=>'excludedfloater'), get_string('excluded', 'grades'));
$itemcell->text .= html_writer::tag('span', get_string('excluded', 'grades'), array('class'=>'excludedfloater'));
}

// Do not show any icons if no grade (no record in DB to match)
Expand All @@ -882,7 +882,7 @@ public function get_right_rows() {
// or a drop down (for scales)
// grades in item of type grade category or course are not directly editable
if ($item->needsupdate) {
$itemcell->text .= html_writer::tag('span', array('class'=>"gradingerror$hidden"), get_string('error'));
$itemcell->text .= html_writer::tag('span', get_string('error'), array('class'=>"gradingerror$hidden"));

} else if ($USER->gradeediting[$this->courseid]) {

Expand Down Expand Up @@ -916,10 +916,10 @@ public function get_right_rows() {

// invalid grade if gradeval < 1
if ($gradeval < 1) {
$itemcell->text .= html_writer::tag('span', array('class'=>"gradevalue$hidden$gradepass"), '-');
$itemcell->text .= html_writer::tag('span', '-', array('class'=>"gradevalue$hidden$gradepass"));
} else {
$gradeval = $grade->grade_item->bounded_grade($gradeval); //just in case somebody changes scale
$itemcell->text .= html_writer::tag('span', array('class'=>"gradevalue$hidden$gradepass"), $scales[$gradeval-1]);
$itemcell->text .= html_writer::tag('span', $scales[$gradeval-1], array('class'=>"gradevalue$hidden$gradepass"));
}
} else {
// no such scale, throw error?
Expand All @@ -933,7 +933,7 @@ public function get_right_rows() {
. '" type="text" class="text" title="'. $strgrade .'" name="grade_'
.$userid.'_' .$item->id.'" id="grade_'.$userid.'_'.$item->id.'" value="'.$value.'" />';
} else {
$itemcell->text .= html_writer::tag('span', array('class'=>"gradevalue$hidden$gradepass"), format_float($gradeval, $decimalpoints));
$itemcell->text .= html_writer::tag('span', format_float($gradeval, $decimalpoints), array('class'=>"gradevalue$hidden$gradepass"));
}
}

Expand All @@ -956,9 +956,9 @@ public function get_right_rows() {
}

if ($item->needsupdate) {
$itemcell->text .= html_writer::tag('span', array('class'=>"gradingerror$hidden$gradepass"), get_string('error'));
$itemcell->text .= html_writer::tag('span', get_string('error'), array('class'=>"gradingerror$hidden$gradepass"));
} else {
$itemcell->text .= html_writer::tag('span', array('class'=>"gradevalue$hidden$gradepass"), grade_format_gradevalue($gradeval, $item, true, $gradedisplaytype, null));
$itemcell->text .= html_writer::tag('span', grade_format_gradevalue($gradeval, $item, true, $gradedisplaytype, null), array('class'=>"gradevalue$hidden$gradepass"));
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/filelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2102,7 +2102,7 @@ function file_modify_html_header($text) {
if (filter_is_enabled('filter/mediaplugin')) {
// this script is needed by most media filter plugins.
$attributes = array('type'=>'text/javascript', 'src'=>$CFG->httpswwwroot . '/lib/ufo.js');
$ufo = html_writer::tag('script', $attributes, '') . "\n";
$ufo = html_writer::tag('script', '', $attributes) . "\n";
}

preg_match('/\<head\>|\<HEAD\>/', $text, $matches);
Expand Down
8 changes: 4 additions & 4 deletions lib/navigationlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ public function content($shorttext=false) {
$icon = $OUTPUT->render($this->icon);
$content = $icon.$content; // use CSS for spacing of icons
} else if ($this->helpbutton !== null) {
$content = trim($this->helpbutton).html_writer::tag('span', array('class'=>'clearhelpbutton'), $content);
$content = trim($this->helpbutton).html_writer::tag('span', $content, array('class'=>'clearhelpbutton'));
}

if ($content === '') {
Expand Down Expand Up @@ -446,7 +446,7 @@ public function content($shorttext=false) {
if ($this->hidden) {
$attributes['class'] = 'dimmed_text';
}
$content = html_writer::tag('span', $attributes, $content);
$content = html_writer::tag('span', $content, $attributes);
}

return $content;
Expand Down Expand Up @@ -2350,7 +2350,7 @@ protected function parse_branch_to_html($navarray, $firstnode=true) {
if ($firstnode===true) {
// If this is the first node add the class first and display the
// navbar properties (normally sitename)
$output .= html_writer::tag('li', array('class'=>'first'), parent::content(true));
$output .= html_writer::tag('li', parent::content(true), array('class'=>'first'));
}
$count = 0;
if (!is_array($navarray)) {
Expand Down Expand Up @@ -2390,7 +2390,7 @@ protected function parse_branch_to_html($navarray, $firstnode=true) {
}
if ($child->type !== navigation_node::TYPE_CATEGORY || !isset($CFG->navshowcategories) || !empty($CFG->navshowcategories)) {
// Now display the node
$output .= html_writer::tag('li', null, $separator.' '.$child->content(true));
$output .= html_writer::tag('li', $separator.' '.$child->content(true));
}
if (isset($oldaction)) {
$child->action = $oldaction;
Expand Down
22 changes: 11 additions & 11 deletions lib/outputcomponents.php
Original file line number Diff line number Diff line change
Expand Up @@ -602,11 +602,11 @@ class html_writer {
/**
* Outputs a tag with attributes and contents
* @param string $tagname The name of tag ('a', 'img', 'span' etc.)
* @param array $attributes The tag attributes (array('src' => $url, 'class' => 'class1') etc.)
* @param string $contents What goes between the opening and closing tags
* @param array $attributes The tag attributes (array('src' => $url, 'class' => 'class1') etc.)
* @return string HTML fragment
*/
public static function tag($tagname, array $attributes = null, $contents) {
public static function tag($tagname, $contents, array $attributes = null) {
return self::start_tag($tagname, $attributes) . $contents . self::end_tag($tagname);
}

Expand Down Expand Up @@ -696,7 +696,7 @@ public static function random_id($base='random') {
public static function link($url, $text, array $attributes = null) {
$attributes = (array)$attributes;
$attributes['href'] = $url;
return self::tag('a', $attributes, $text);
return self::tag('a', $text, $attributes);
}

/**
Expand Down Expand Up @@ -725,7 +725,7 @@ public static function checkbox($name, $value, $checked = true, $label = '', arr
$output .= self::empty_tag('input', $attributes);

if ($label !== '' and !is_null($label)) {
$output .= self::tag('label', array('for'=>$attributes['id']), $label);
$output .= self::tag('label', $label, array('for'=>$attributes['id']));
}

return $output;
Expand Down Expand Up @@ -805,7 +805,7 @@ public static function select(array $options, $name, $selected = '', $nothing =
$output .= self::select_option($label, $value, $selected);
}
}
return self::tag('select', $attributes, $output);
return self::tag('select', $output, $attributes);
}

private static function select_option($label, $value, array $selected) {
Expand All @@ -815,7 +815,7 @@ private static function select_option($label, $value, array $selected) {
$attributes['selected'] = 'selected';
}
$attributes['value'] = $value;
return self::tag('option', $attributes, $label);
return self::tag('option', $label, $attributes);
}

private static function select_optgroup($groupname, $options, array $selected) {
Expand All @@ -827,7 +827,7 @@ private static function select_optgroup($groupname, $options, array $selected) {
foreach ($options as $value=>$label) {
$output .= self::select_option($label, $value, $selected);
}
return self::tag('optgroup', $attributes, $output);
return self::tag('optgroup', $output, $attributes);
}

/**
Expand Down Expand Up @@ -889,7 +889,7 @@ public static function select_time($type, $name, $currenttime=0, $step=5, array
$attributes['id'] = self::random_id('ts_');
}
$timerselector = self::select($timeunits, $name, $currentdate[$userdatetype], null, array('id'=>$attributes['id']));
$label = self::tag('label', array('for'=>$attributes['id'], 'class'=>'accesshide'), get_string(substr($type, 0, -1), 'form'));
$label = self::tag('label', get_string(substr($type, 0, -1), 'form'), array('for'=>$attributes['id'], 'class'=>'accesshide'));

return $label.$timerselector;
}
Expand All @@ -912,7 +912,7 @@ public static function alist(array $items, array $attributes = null, $tag = 'ul'
$output .= html_writer::end_tag('li') . "\n";
}

return html_writer::tag($tag, $attributes, $output);
return html_writer::tag($tag, $output, $attributes);
}

/**
Expand Down Expand Up @@ -946,11 +946,11 @@ public static function input_hidden_params(moodle_url $url, array $exclude = nul
public static function script($jscode, $url=null) {
if ($jscode) {
$attributes = array('type'=>'text/javascript');
return self::tag('script', $attributes, "\n//<![CDATA[\n$jscode\n//]]>\n") . "\n";
return self::tag('script', "\n//<![CDATA[\n$jscode\n//]]>\n", $attributes) . "\n";

} else if ($url) {
$attributes = array('type'=>'text/javascript', 'src'=>$url);
return self::tag('script', $attributes, '') . "\n";
return self::tag('script', '', $attributes) . "\n";

} else {
return '';
Expand Down
Loading

0 comments on commit 26acc81

Please sign in to comment.