本文整理汇总了PHP中action_menu::set_nowrap_on_items方法的典型用法代码示例。如果您正苦于以下问题:PHP action_menu::set_nowrap_on_items方法的具体用法?PHP action_menu::set_nowrap_on_items怎么用?PHP action_menu::set_nowrap_on_items使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类action_menu
的用法示例。
在下文中一共展示了action_menu::set_nowrap_on_items方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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
);
}
示例2: add_menu_actions
/**
* Returns the add menu that is output once per page.
* @param structure $structure object containing the structure of the quiz.
* @param int $page the page number that this menu will add to.
* @param \moodle_url $pageurl the canonical URL of this page.
* @param \question_edit_contexts $contexts the relevant question bank contexts.
* @param array $pagevars the variables from {@link \question_edit_setup()}.
* @return string HTML to output.
*/
public function add_menu_actions(structure $structure, $page, \moodle_url $pageurl, \question_edit_contexts $contexts, array $pagevars)
{
$actions = $this->edit_menu_actions($structure, $page, $pageurl, $pagevars);
if (empty($actions)) {
return '';
}
$menu = new \action_menu();
$menu->set_alignment(\action_menu::TR, \action_menu::BR);
$menu->set_constraint('.mod-quiz-edit-content');
$trigger = html_writer::tag('span', get_string('add', 'quiz'), array('class' => 'add-menu'));
$menu->set_menu_trigger($trigger);
// The menu appears within an absolutely positioned element causing width problems.
// Make sure no-wrap is set so that we don't get a squashed menu.
$menu->set_nowrap_on_items(true);
// Disable the link if quiz has attempts.
if (!$structure->can_be_edited()) {
return $this->render($menu);
}
foreach ($actions as $action) {
if ($action instanceof \action_menu_link) {
$action->add_class('add-menu');
}
$menu->add($action);
}
$menu->attributes['class'] .= ' page-add-actions commands';
// Prioritise the menu ahead of all other actions.
$menu->prioritise = true;
return $this->render($menu);
}