MDL-20204 converting html_span to html_writer
authorPetr Skoda <skodak@moodle.org>
Wed, 17 Feb 2010 17:17:45 +0000 (17:17 +0000)
committerPetr Skoda <skodak@moodle.org>
Wed, 17 Feb 2010 17:17:45 +0000 (17:17 +0000)
calendar/delete.php
grade/edit/tree/lib.php
grade/report/grader/lib.php
lib/outputcomponents.php
lib/outputrenderers.php
mod/lesson/renderer.php

index 63bb9e7..98a900c 100644 (file)
@@ -108,7 +108,7 @@ $repeatspan = '';
 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
index 2573cb1..e408857 100755 (executable)
@@ -1132,18 +1132,13 @@ class grade_edit_tree_column_select extends grade_edit_tree_column {
         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;
     }
 
index b072beb..a4091ab 100644 (file)
@@ -826,7 +826,7 @@ class grade_report_grader extends grade_report {
                 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 = '-';
                     }
@@ -858,7 +858,7 @@ class grade_report_grader extends grade_report {
                 }
 
                 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)
@@ -882,7 +882,7 @@ class grade_report_grader extends grade_report {
                 // 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]) {
 
@@ -916,10 +916,10 @@ class grade_report_grader extends grade_report {
 
                             // 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?
@@ -933,7 +933,7 @@ class grade_report_grader extends grade_report {
                                           . '" 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));
                         }
                     }
 
@@ -956,9 +956,9 @@ class grade_report_grader extends grade_report {
                     }
 
                     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));
                     }
                 }
 
index c388f80..df4b123 100644 (file)
@@ -1681,29 +1681,6 @@ class html_list_item extends html_component {
     }
 }
 
-
-/**
- * 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
 
 
index 558f9b4..723cc52 100644 (file)
@@ -1583,32 +1583,6 @@ class core_renderer extends renderer_base {
         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
      *
index 8d13993..362d88b 100644 (file)
@@ -162,10 +162,10 @@ class mod_lesson_renderer extends plugin_renderer_base {
         $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;