本文整理汇总了PHP中action_menu::initialise_js方法的典型用法代码示例。如果您正苦于以下问题:PHP action_menu::initialise_js方法的具体用法?PHP action_menu::initialise_js怎么用?PHP action_menu::initialise_js使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类action_menu
的用法示例。
在下文中一共展示了action_menu::initialise_js方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build_html_tree
/**
* Recursive function for building the table holding the grade categories and items,
* with CSS indentation and styles.
*
* @param array $element The current tree element being rendered
* @param boolean $totals Whether or not to print category grade items (category totals)
* @param array $parents An array of parent categories for the current element (used for indentation and row classes)
*
* @return string HTML
*/
public function build_html_tree($element, $totals, $parents, $level, &$row_count)
{
global $CFG, $COURSE, $PAGE, $OUTPUT;
$object = $element['object'];
$eid = $element['eid'];
$object->name = $this->gtree->get_element_header($element, true, true, true, true);
$object->stripped_name = $this->gtree->get_element_header($element, false, false, false);
$is_category_item = false;
if ($element['type'] == 'categoryitem' || $element['type'] == 'courseitem') {
$is_category_item = true;
}
$rowclasses = array();
foreach ($parents as $parent_eid) {
$rowclasses[] = $parent_eid;
}
$moveaction = '';
$actionsmenu = new action_menu();
$actionsmenu->initialise_js($PAGE);
$actionsmenu->set_menu_trigger(get_string('edit'));
$actionsmenu->set_owner_selector('grade-item-' . $eid);
$actionsmenu->set_alignment(action_menu::TL, action_menu::BL);
if (!$is_category_item && ($icon = $this->gtree->get_edit_icon($element, $this->gpr, true))) {
$actionsmenu->add($icon);
}
if ($this->show_calculations && ($icon = $this->gtree->get_calculation_icon($element, $this->gpr, true))) {
$actionsmenu->add($icon);
}
if ($element['type'] == 'item' or $element['type'] == 'category' and $element['depth'] > 1) {
if ($this->element_deletable($element)) {
$aurl = new moodle_url('index.php', array('id' => $COURSE->id, 'action' => 'delete', 'eid' => $eid, 'sesskey' => sesskey()));
$icon = new action_menu_link_secondary($aurl, new pix_icon('t/delete', get_string('delete')), get_string('delete'));
$actionsmenu->add($icon);
}
$aurl = new moodle_url('index.php', array('id' => $COURSE->id, 'action' => 'moveselect', 'eid' => $eid, 'sesskey' => sesskey()));
$moveaction .= $OUTPUT->action_icon($aurl, new pix_icon('t/move', get_string('move')));
}
if ($icon = $this->gtree->get_hiding_icon($element, $this->gpr, true)) {
$actionsmenu->add($icon);
}
if ($icon = $this->gtree->get_reset_icon($element, $this->gpr, true)) {
$actionsmenu->add($icon);
}
$actions = $OUTPUT->render($actionsmenu);
$returnrows = array();
$root = false;
$id = required_param('id', PARAM_INT);
/// prepare move target if needed
$last = '';
/// print the list items now
if ($this->moving == $eid) {
// do not diplay children
$cell = new html_table_cell();
$cell->colspan = 12;
$cell->attributes['class'] = $element['type'] . ' moving column-name level' . ($level + 1) . ' level' . ($level % 2 ? 'even' : 'odd');
$cell->text = $object->name . ' (' . get_string('move') . ')';
return array(new html_table_row(array($cell)));
}
if ($element['type'] == 'category') {
$level++;
$this->categories[$object->id] = $object->stripped_name;
$category = grade_category::fetch(array('id' => $object->id));
$item = $category->get_grade_item();
// Add aggregation coef input if not a course item and if parent category has correct aggregation type
$dimmed = $item->is_hidden() ? 'dimmed_text' : '';
// Before we print the category's row, we must find out how many rows will appear below it (for the filler cell's rowspan)
$aggregation_position = grade_get_setting($COURSE->id, 'aggregationposition', $CFG->grade_aggregationposition);
$category_total_data = null;
// Used if aggregationposition is set to "last", so we can print it last
$html_children = array();
$row_count = 0;
foreach ($element['children'] as $child_el) {
$moveto = null;
if (empty($child_el['object']->itemtype)) {
$child_el['object']->itemtype = false;
}
if (($child_el['object']->itemtype == 'course' || $child_el['object']->itemtype == 'category') && !$totals) {
continue;
}
$child_eid = $child_el['eid'];
$first = '';
if ($child_el['object']->itemtype == 'course' || $child_el['object']->itemtype == 'category') {
$first = array('first' => 1);
$child_eid = $eid;
}
if ($this->moving && $this->moving != $child_eid) {
$strmove = get_string('move');
$strmovehere = get_string('movehere');
$actions = $moveaction = '';
// no action icons when moving
$aurl = new moodle_url('index.php', array('id' => $COURSE->id, 'action' => 'move', 'eid' => $this->moving, 'moveafter' => $child_eid, 'sesskey' => sesskey()));
//.........这里部分代码省略.........
示例2: user_menu
//.........这里部分代码省略.........
)
),
array('class' => 'meta viewingas')
);
}
// Role.
if (!empty($opts->metadata['asotherrole'])) {
$role = core_text::strtolower(preg_replace('#[ ]+#', '-', trim($opts->metadata['rolename'])));
$usertextcontents .= html_writer::span(
$opts->metadata['rolename'],
'meta role role-' . $role
);
}
// User login failures.
if (!empty($opts->metadata['userloginfail'])) {
$usertextcontents .= html_writer::span(
$opts->metadata['userloginfail'],
'meta loginfailures'
);
}
// MNet.
if (!empty($opts->metadata['asmnetuser'])) {
$mnet = strtolower(preg_replace('#[ ]+#', '-', trim($opts->metadata['mnetidprovidername'])));
$usertextcontents .= html_writer::span(
$opts->metadata['mnetidprovidername'],
'meta mnet mnet-' . $mnet
);
}
$returnstr .= html_writer::span(
html_writer::span($usertextcontents, 'usertext') .
html_writer::span($avatarcontents, $avatarclasses),
'userbutton'
);
// Create a divider (well, a filler).
$divider = new action_menu_filler();
$divider->primary = false;
$am = new action_menu();
$am->initialise_js($this->page);
$am->set_menu_trigger(
$returnstr
);
$am->set_alignment(action_menu::TR, action_menu::BR);
$am->set_nowrap_on_items();
if ($withlinks) {
$navitemcount = count($opts->navitems);
$idx = 0;
foreach ($opts->navitems as $key => $value) {
switch ($value->itemtype) {
case 'divider':
// If the nav item is a divider, add one and skip link processing.
$am->add($divider);
break;
case 'invalid':
// Silently skip invalid entries (should we post a notification?).
break;
case 'link':
// Process this as a link item.
$pix = null;
if (isset($value->pix) && !empty($value->pix)) {
$pix = new pix_icon($value->pix, $value->title, null, array('class' => 'iconsmall'));
} else if (isset($value->imgsrc) && !empty($value->imgsrc)) {
$value->title = html_writer::img(
$value->imgsrc,
$value->title,
array('class' => 'iconsmall')
) . $value->title;
}
$al = new action_menu_link_secondary(
$value->url,
$pix,
$value->title,
array('class' => 'icon')
);
$am->add($al);
break;
}
$idx++;
// Add dividers after the first item and before the last item.
if ($idx == 1 || $idx == $navitemcount - 1) {
$am->add($divider);
}
}
}
return html_writer::div(
$this->render($am),
$usermenuclasses
);
}
示例3: render_action_menu
/**
* Renders an action menu component.
*
* ARIA references:
* - http://www.w3.org/WAI/GL/wiki/Using_ARIA_menus
* - http://stackoverflow.com/questions/12279113/recommended-wai-aria-implementation-for-navigation-bar-menu
*
* @param action_menu $menu
* @return string HTML
*/
public function render_action_menu(action_menu $menu)
{
$menu->initialise_js($this->page);
$output = html_writer::start_tag('div', $menu->attributes);
$output .= html_writer::start_tag('ul', $menu->attributesprimary);
foreach ($menu->get_primary_actions($this) as $action) {
if ($action instanceof renderable) {
$content = $this->render($action);
} else {
$content = $action;
}
$output .= html_writer::tag('li', $content, array('role' => 'presentation'));
}
$output .= html_writer::end_tag('ul');
$output .= html_writer::start_tag('ul', $menu->attributessecondary);
foreach ($menu->get_secondary_actions() as $action) {
if ($action instanceof renderable) {
$content = $this->render($action);
} else {
$content = $action;
}
$output .= html_writer::tag('li', $content, array('role' => 'presentation'));
}
$output .= html_writer::end_tag('ul');
$output .= html_writer::end_tag('div');
return $output;
}