$popupmenu .= $OUTPUT->single_select(new moodle_url($baseurl.'&course='.$courseid), 'status', $statusmenu, $status, null, 'statusmenu');
if ($canmanagepayments) {
$popupmenu .= '<br />';
- $id = html_writer::random_id('ea');
$PAGE->requires->js('/enrol/authorize/authorize.js');
- $OUTPUT->add_action_handler($id, new component_action('click', 'authorize_jump_to_mypayments', array('userid' => $USER->id, 'status' => $status)));
- $popupmenu .= html_writer::checkbox('enrol_authorize', 1, $userid == $USER->id, get_string('mypaymentsonly', 'enrol_authorize'), array('id'=>$id));
+ $aid = $OUTPUT->add_action_handler(new component_action('click', 'authorize_jump_to_mypayments', array('userid' => $USER->id, 'status' => $status)));
+ $popupmenu .= html_writer::checkbox('enrol_authorize', 1, $userid == $USER->id, get_string('mypaymentsonly', 'enrol_authorize'), array('id'=>$aid));
}
if (SITEID != $courseid) {
echo get_string('moveselectedto', 'grades') . ' ';
$attributes = array('id'=>'menumoveafter');
echo html_writer::select($grade_edit_tree->categories, 'moveafter', '', array(''=>'choosedots'), $attributes);
- $PAGE->add_action_handler('menumoveafter', new component_action('change', 'submit_bulk_move'));
+ $OUTPUT->add_action_handler(new component_action('change', 'submit_bulk_move'), 'menumoveafter');
echo '<div id="noscriptgradetreeform" class="hiddenifjs">
<input type="submit" value="'.get_string('go').'" />
</div>';
$attributes['id'] = 'aggregation_'.$category->id;
$aggregation = html_writer::select($options, 'aggregation_'.$category->id, $category->aggregation, null, $attributes);
$action = new component_action('change', 'update_category_aggregation', array('courseid' => $params['id'], 'category' => $category->id, 'sesskey' => sesskey()));
- $PAGE->add_action_handler('aggregation_'.$category->id, $action);
+ $OUTPUT->add_action_handler($action, 'aggregation_'.$category->id);
}
$categorycell = clone($this->categorycell);
* @param array $attributes html attributes
*/
public function __construct($pix, $alt, $component='moodle', array $attributes = null) {
- $this->icon = $pix;
- $this->compondent = $component;
+ $this->pix = $pix;
+ $this->component = $component;
$this->attributes = (array)$attributes;
$this->attributes['alt'] = $alt;
/**
* Adds JS handlers needed for event execution for one html element id
- * @param string $id
* @param component_action $actions
- * @return void
+ * @param string $id
+ * @return string id of element, either original submitted or random new if not supplied
*/
- public function add_action_handler($id, component_action $action) {
+ public function add_action_handler(component_action $action, $id=null) {
+ if (!$id) {
+ $id = html_writer::random_id($action->event);
+ }
$this->page->requires->event_handler("#$id", $action->event, $action->jsfunction, $action->jsfunctionargs);
+ return $id;
}
/**
$id = $attributes['id'];
}
foreach ($link->actions as $action) {
- $this->add_action_handler($id, $action);
+ $this->add_action_handler($action, $id);
}
}
$id = html_writer::random_id('single_button');
$attributes['id'] = $id;
foreach ($button->actions as $action) {
- $this->add_action_handler($id, $action);
+ $this->add_action_handler($action, $id);
}
}
$url = new moodle_url(get_docs_url($path));
- $link = new html_link($url, $icon.$text);
-
+ $attributes = array('href'=>$url);
if (!empty($CFG->doctonewwindow)) {
- $link->add_action(new popup_action('click', $url));
+ $attributes['id'] = $this->add_action_handler(new popup_action('click', $url));
}
-
- return $this->link($link);
+
+ return html_writer::tag('a', $attributes, $icon.$text);
}
/**
* @param pix_icon $icon
* @return string HTML fragment
*/
- public function render_icon(pix_icon $icon) {
+ public function render_pix_icon(pix_icon $icon) {
$attributes = $icon->attributes;
$attributes['src'] = $this->pix_url($icon->pix, $icon->component);
- return html_writer::empty_tag('img', $atrributes);
+ return html_writer::empty_tag('img', $attributes);
}
/**
$attributes = array('href'=>$url, 'title'=>$title);
$id = html_writer::random_id('helpicon');
$attributes['id'] = $id;
- $this->add_action_handler($id, new popup_action('click', $url));
+ $this->add_action_handler(new popup_action('click', $url), $id);
$output = html_writer::tag('a', $attributes, $output);
// and finally span
if ($userpicture->popup) {
$id = html_writer::random_id('userpicture');
$attributes['id'] = $id;
- $this->add_action_handler($id, new popup_action('click', $url));
+ $this->add_action_handler(new popup_action('click', $url), $id);
}
return html_writer::tag('a', $attributes, $output);
while(list($key,$val)=each($wiki_list)) {
$wiki_admin_list[$key."&action=$action"]=$val;
}
- $attributes = array('id'=>'changeid');
+ $aid = $OUTPUT->add_action_handler(new component_action('change', 'go_to_wiki'));
+ $attributes = array('id'=>$aid);
echo html_writer::select($wiki_admin_list, 'wikiselect', $selected, array(''=>'choose'), $attributes);
- $PAGE->add_action_handler('changeid', new component_action('change', 'go_to_wiki'));
echo '</td>';
echo '</tr></table>';
echo '</fieldset></form>';
echo '<td class="sideblockheading">'
.get_string('otherwikis', 'wiki').': ';
- $attributes = array('id'=>'changeid');
+ $aid = $OUTPUT->add_action_handler(new component_action('change', 'go_to_wiki'));
+ $attributes = array('id'=>$aid);
echo html_writer::select($wiki_list, 'wikiselect', $selected, array(''=>'choose'), $attributes);
- $PAGE->add_action_handler('changeid', new component_action('change', 'go_to_wiki'));
echo '</td>';
echo '</tr></table>';
echo '</form>';