Skip to content

Commit

Permalink
MDL-20204 converting html_span to html_writer
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Feb 17, 2010
1 parent 929d7a8 commit 4ee753e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 68 deletions.
2 changes: 1 addition & 1 deletion calendar/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
if (!empty($event->eventrepeats) && $event->eventrepeats > 0) {
$url = new moodle_url(CALENDAR_URL.'delete.php', array('id'=>$event->repeatid, 'confirm'=>true, 'repeats'=>true));
$buttons .= $OUTPUT->single_button($url, get_string('deleteall'));
$repeatspan = '<br /><br />'.$OUTPUT->span(get_string('youcandeleteallrepeats', 'calendar'));
$repeatspan = '<br /><br /><span>'.get_string('youcandeleteallrepeats', 'calendar').'</span>';
}

// And add the cancel button
Expand Down
11 changes: 3 additions & 8 deletions grade/edit/tree/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1132,18 +1132,13 @@ public function get_category_cell($category, $levelclass, $params) {
if (empty($params['eid'])) {
throw new Exception('Array key (eid) missing from 3rd param of grade_edit_tree_column_select::get_category_cell($category, $levelclass, $params)');
}
$selectall = new html_span();
$selectall->add_class('actionlink');
$selectnone = clone($selectall);
$selectall->add_action('click', 'togglecheckboxes', array('eid' => $params['eid'], 'check' => true));
$selectall->contents = get_string('all');
$selectnone->add_action('click', 'togglecheckboxes', array('eid' => $params['eid'], 'check' => false));
$selectnone->contents = get_string('none');
$selectall = new action_link(new moodle_url('#'), get_string('all'), new component_action('click', 'togglecheckboxes', array('eid' => $params['eid'], 'check' => true)));
$selectnone = new action_link(new moodle_url('#'), get_string('none'), new component_action('click', 'togglecheckboxes', array('eid' => $params['eid'], 'check' => false)));

$categorycell = clone($this->categorycell);
$categorycell->add_classes(array('last', $levelclass));
$categorycell->style .= 'text-align: center;';
$categorycell->text = $OUTPUT->span($selectall) . '<br />' . $OUTPUT->span($selectnone);
$categorycell->text = $OUTPUT->render($selectall) . '<br />' . $OUTPUT->render($selectnone);
return $categorycell;
}

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 = $OUTPUT->span(userdate($grade->get_datesubmitted(),get_string('strftimedatetimeshort')), 'datesubmitted');
$itemcell->text = html_writer::tag('span', array('class'=>'datesubmitted'), userdate($grade->get_datesubmitted(),get_string('strftimedatetimeshort')));
} else {
$itemcell->text = '-';
}
Expand Down Expand Up @@ -858,7 +858,7 @@ public function get_right_rows() {
}

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

// 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 .= $OUTPUT->span(get_string('error'), "gradingerror$hidden");
$itemcell->text .= html_writer::tag('span', array('class'=>"gradingerror$hidden"), get_string('error'));

} 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 .= $OUTPUT->span('-', "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 .= $OUTPUT->span($scales[$gradeval-1], "gradevalue$hidden$gradepass");
$itemcell->text .= html_writer::tag('span', array('class'=>"gradevalue$hidden$gradepass"), $scales[$gradeval-1]);
}
} 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 .= $OUTPUT->span(format_float($gradeval, $decimalpoints), "gradevalue$hidden$gradepass");
$itemcell->text .= html_writer::tag('span', array('class'=>"gradevalue$hidden$gradepass"), format_float($gradeval, $decimalpoints));
}
}

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

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

Expand Down
23 changes: 0 additions & 23 deletions lib/outputcomponents.php
Original file line number Diff line number Diff line change
Expand Up @@ -1681,29 +1681,6 @@ public function prepare(renderer_base $output, moodle_page $page, $target) {
}
}


/**
* Component representing a span element. It has no special attributes, so
* it is very low-level and can be used for styling and JS actions.
*
* @copyright 2009 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since Moodle 2.0
*/
class html_span extends html_component {
/**
* @var string $text The contents of the span
*/
public $contents;
/**
* @see lib/html_component#prepare()
* @return void
*/
public function prepare(renderer_base $output, moodle_page $page, $target) {
parent::prepare($output, $page, $target);
}
}

/// Complex components aggregating simpler components


Expand Down
26 changes: 0 additions & 26 deletions lib/outputrenderers.php
Original file line number Diff line number Diff line change
Expand Up @@ -1583,32 +1583,6 @@ public function htmllist($list) {
return $output . html_writer::end_tag($tag);
}

/**
* Prints an inline span element with optional text contents.
*
* @param mixed $span A html_span object or some string content to wrap in a span
* @param mixed $classes A space-separated list or an array of classes. Only used if $span is a string
* @return string A HTML fragment
*/
public function span($span, $classes='') {
if (!($span instanceof html_span)) {
$text = $span;
$span = new html_span();
$span->contents = $text;
$span->add_classes($classes);
}

$span = clone($span);
$span->prepare($this, $this->page, $this->target);
$this->prepare_event_handlers($span);
$attributes = array('class' => $span->get_classes_string(),
'alt' => $span->alt,
'style' => $span->style,
'title' => $span->title,
'id' => $span->id);
return html_writer::tag('span', $attributes, $span->contents);
}

/**
* Prints a simple button to close a window
*
Expand Down
4 changes: 2 additions & 2 deletions mod/lesson/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@ public function continue_links(lesson $lesson, $lastpageseenid) {
$output .= $this->output->box_start('center');

$yeslink = html_writer::link(new moodle_url('/mod/lesson/view.php', array('id'=>$this->page->cm->id, 'pageid'=>$lastpageseenid, 'startlastseen'=>'yes')), get_string('yes'));
$output .= $this->output->span($yeslink, 'lessonbutton standardbutton');
$output .= html_writer::tag('span', array('class'=>'lessonbutton standardbutton'), $yeslink);

$nolink = html_writer::link(new moodle_url('/mod/lesson/view.php', array('id'=>$this->page->cm->id, 'pageid'=>$lesson->firstpageid, 'startlastseen'=>'no')), get_string('no'));
$output .= $this->output->span($nolink, 'lessonbutton standardbutton');
$output .= html_writer::tag('span', array('class'=>'lessonbutton standardbutton'), $nolink);

$output .= $this->output->box_end();
return $output;
Expand Down

0 comments on commit 4ee753e

Please sign in to comment.