本文整理汇总了PHP中custom_menu_item::get_title方法的典型用法代码示例。如果您正苦于以下问题:PHP custom_menu_item::get_title方法的具体用法?PHP custom_menu_item::get_title怎么用?PHP custom_menu_item::get_title使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类custom_menu_item
的用法示例。
在下文中一共展示了custom_menu_item::get_title方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render_custom_menu_item
/**
* Renders a custom menu node as part of a submenu
*
* The custom menu this method override the render_custom_menu_item function
* in outputrenderers.php
*
* @see render_custom_menu()
*
* @staticvar int $submenucount
* @param custom_menu_item $menunode
* @return string
*/
protected function render_custom_menu_item(custom_menu_item $menunode)
{
// Required to ensure we get unique trackable id's
static $submenucount = 0;
$content = html_writer::start_tag('li');
if ($menunode->has_children()) {
// If the child has menus render it as a sub menu
$submenucount++;
if ($menunode->get_url() !== null) {
$url = $menunode->get_url();
} else {
$url = '#cm_submenu_' . $submenucount;
}
$content .= html_writer::start_tag('span', array('class' => 'customitem'));
$content .= html_writer::link($url, $menunode->get_text(), array('title' => $menunode->get_title()));
$content .= html_writer::end_tag('span');
$content .= html_writer::start_tag('ul');
foreach ($menunode->get_children() as $menunode) {
$content .= $this->render_custom_menu_item($menunode);
}
$content .= html_writer::end_tag('ul');
} else {
// The node doesn't have children so produce a final menuitem
if ($menunode->get_url() !== null) {
$url = $menunode->get_url();
} else {
$url = '#';
}
$content .= html_writer::link($url, $menunode->get_text(), array('title' => $menunode->get_title()));
}
$content .= html_writer::end_tag('li');
// Return the sub menu
return $content;
}
示例2: render_custom_menu_item
protected function render_custom_menu_item(custom_menu_item $menunode, $level = 0)
{
static $submenucount = 0;
if ($menunode->has_children()) {
if ($level == 1) {
$class = 'dropdown';
} else {
$class = 'dropdown-submenu';
}
if ($menunode === $this->language) {
$class .= ' langmenu';
}
$content = html_writer::start_tag('li', array('class' => $class));
// If the child has menus render it as a sub menu.
$submenucount++;
if ($menunode->get_url() !== null) {
$url = $menunode->get_url();
$richID = $menunode->get_text();
//************added by Richard to give custom IDs to menu itmes based on the title************
} else {
$url = '#cm_submenu_' . $submenucount;
}
$content .= html_writer::start_tag('a', array('href' => $url, 'class' => 'dropdown-toggle', 'id' => $richID, 'data-toggle' => 'dropdown', 'title' => $menunode->get_title()));
$content .= $menunode->get_text();
if ($level == 1) {
$content .= '<b class="caret"></b>';
}
$content .= '</a>';
$content .= '<ul class="dropdown-menu">';
foreach ($menunode->get_children() as $menunode) {
$content .= $this->render_custom_menu_item($menunode, 0);
}
$content .= '</ul>';
} else {
$content = '<li>';
// The node doesn't have children so produce a final menuitem.
if ($menunode->get_url() !== null) {
$url = $menunode->get_url();
$richID = $menunode->get_text();
//************added by Richard to give custom IDs to menu itmes based on the title************
} else {
$url = '#';
}
$content .= html_writer::link($url, $menunode->get_text(), array('id' => $richID, 'title' => $menunode->get_title()));
}
return $content;
}
示例3: render_custom_menu_item
protected function render_custom_menu_item(custom_menu_item $menunode, $level = 0, $direction = '' ) {
static $submenucount = 0;
if ($menunode->has_children()) {
if ($level == 1) {
$dropdowntype = 'dropdown';
} else {
$dropdowntype = 'dropdown-submenu';
}
$content = html_writer::start_tag('li', array('class' => $dropdowntype));
// If the child has menus render it as a sub menu.
$submenucount++;
if ($menunode->get_url() !== null) {
$url = $menunode->get_url();
} else {
$url = '#cm_submenu_'.$submenucount;
}
$linkattributes = array(
'href' => $url,
'class' => 'dropdown-toggle',
'data-toggle' => 'dropdown',
'title' => $menunode->get_title(),
);
$content .= html_writer::start_tag('a', $linkattributes);
$content .= $menunode->get_text();
if ($level == 1) {
$content .= '<b class="caret"></b>';
}
$content .= '</a>';
$content .= '<ul class="dropdown-menu '.$direction.'">';
foreach ($menunode->get_children() as $menunode) {
$content .= $this->render_custom_menu_item($menunode, 0);
}
$content .= '</ul>';
} else {
$content = '<li>';
// The node doesn't have children so produce a final menuitem.
$class = $menunode->get_title();
if (preg_match("/^#+$/", $menunode->get_text())) {
$content = '<li class="divider" role="presentation">';
} else {
$content = '<li>';
// The node doesn't have children so produce a final menuitem.
if ($menunode->get_url() !== null) {
$url = $menunode->get_url();
} else {
$url = '#';
}
$content .= html_writer::link($url, $menunode->get_text(), array('class' => $class, 'title' => $menunode->get_title()));
}
}
return $content;
}
示例4: render_custom_menu_item
protected function render_custom_menu_item(custom_menu_item $menunode, $level = 0)
{
global $COURSE, $USER, $CFG;
static $submenucount = 0;
if ($menunode->has_children()) {
if ($level == 1) {
$class = 'dropdown';
} else {
$class = 'dropdown-submenu';
}
if ($menunode->get_url() !== null) {
$url = $menunode->get_url();
} else {
$url = '#cm_submenu_' . $submenucount;
}
// allow protected menu items to only logged in
if (preg_match('/^!/', $url)) {
if (!isloggedin() || isguestuser()) {
return;
} else {
$url = preg_replace('/^!/', '', $url);
}
}
// Url context variables replacement if needed in menu (first catch escaped form).
$url = preg_replace('/%25WWWROOT%25/', $CFG->wwwroot, $url);
$url = preg_replace('/%WWWROOT%/', $CFG->wwwroot, $url);
$url = preg_replace('/%25COURSEID%25/', $COURSE->id, $url);
$url = preg_replace('/%COURSEID%/', $COURSE->id, $url);
$url = preg_replace('/%25USERID%25/', $USER->id, $url);
$url = preg_replace('/%USERID%/', $USER->id, $url);
if ($menunode === $this->language) {
$class .= ' langmenu';
}
$content = html_writer::start_tag('li', array('class' => $class));
// If the child has menus render it as a sub menu.
$submenucount++;
if ($menunode->get_url() !== null) {
$url = $menunode->get_url();
} else {
$url = '#cm_submenu_' . $submenucount;
}
$content .= html_writer::start_tag('a', array('href' => $url, 'class' => 'dropdown-toggle', 'data-toggle' => 'dropdown', 'title' => $menunode->get_title()));
$content .= $menunode->get_text();
if ($level == 1) {
$content .= '<b class="caret"></b>';
}
$content .= '</a>';
$content .= '<ul class="dropdown-menu">';
foreach ($menunode->get_children() as $menunode) {
$content .= $this->render_custom_menu_item($menunode, 0);
}
$content .= '</ul>';
} else {
$content = '<li>';
// The node doesn't have children so produce a final menuitem.
if ($menunode->get_url() !== null) {
$url = $menunode->get_url();
} else {
$url = '#';
}
$coursecontext = context_course::instance($COURSE->id);
// allow protected menu items to only logged in
if (preg_match('/^([^!]*)!(.*)$/', $url, $matches)) {
if (empty($matches[1])) {
if (!isloggedin() || isguestuser()) {
return;
} else {
$url = preg_replace('/^!/', '', $url);
}
} else {
if (has_capability($matches[1], $coursecontext)) {
$url = $matches[2];
} else {
return;
}
}
}
// Url context variables replacement if needed in menu (first catch escaped form).
$url = preg_replace('/%25WWWROOT%25/', $CFG->wwwroot, $url);
$url = preg_replace('/%WWWROOT%/', $CFG->wwwroot, $url);
$url = preg_replace('/%25COURSEID%25/', $COURSE->id, $url);
$url = preg_replace('/%COURSEID%/', $COURSE->id, $url);
$url = preg_replace('/%25USERID%25/', $USER->id, $url);
$url = preg_replace('/%USERID%/', $USER->id, $url);
$content .= html_writer::link($url, $menunode->get_text(), array('title' => $menunode->get_title()));
}
return $content;
}
示例5: render_custom_menu_item
/**
* Renders a custom menu node as part of a submenu
*
* The custom menu this method produces makes use of the YUI3 menunav widget
* and requires very specific html elements and classes.
*
* @see core:renderer::render_custom_menu()
*
* @staticvar int $submenucount
* @param custom_menu_item $menunode
* @return string
*/
protected function render_custom_menu_item(custom_menu_item $menunode) {
// Required to ensure we get unique trackable id's
static $submenucount = 0;
if ($menunode->has_children()) {
// If the child has menus render it as a sub menu
$submenucount++;
$content = html_writer::start_tag('li');
if ($menunode->get_url() !== null) {
$url = $menunode->get_url();
} else {
$url = '#cm_submenu_'.$submenucount;
}
$content .= html_writer::link($url, $menunode->get_text(), array('class'=>'yui3-menu-label', 'title'=>$menunode->get_title()));
$content .= html_writer::start_tag('div', array('id'=>'cm_submenu_'.$submenucount, 'class'=>'yui3-menu custom_menu_submenu'));
$content .= html_writer::start_tag('div', array('class'=>'yui3-menu-content'));
$content .= html_writer::start_tag('ul');
foreach ($menunode->get_children() as $menunode) {
$content .= $this->render_custom_menu_item($menunode);
}
$content .= html_writer::end_tag('ul');
$content .= html_writer::end_tag('div');
$content .= html_writer::end_tag('div');
$content .= html_writer::end_tag('li');
} else {
// The node doesn't have children so produce a final menuitem.
// Also, if the node's text matches '####', add a class so we can treat it as a divider.
$content = '';
if (preg_match("/^#+$/", $menunode->get_text())) {
// This is a divider.
$content = html_writer::start_tag('li', array('class' => 'yui3-menuitem divider'));
} else {
$content = html_writer::start_tag(
'li',
array(
'class' => 'yui3-menuitem'
)
);
if ($menunode->get_url() !== null) {
$url = $menunode->get_url();
} else {
$url = '#';
}
$content .= html_writer::link(
$url,
$menunode->get_text(),
array('class' => 'yui3-menuitem-content', 'title' => $menunode->get_title())
);
}
$content .= html_writer::end_tag('li');
}
// Return the sub menu
return $content;
}
示例6: __construct
public function __construct(custom_menu_item $menunode)
{
parent::__construct($menunode->get_text(), $menunode->get_url(), $menunode->get_title(), $menunode->get_sort_order(), $menunode->get_parent());
$this->children = $menunode->get_children();
$matches = array();
if (preg_match('/^\\[\\[([a-zA-Z0-9\\-\\_\\:]+)\\]\\]$/', $this->text, $matches)) {
try {
$this->text = get_string($matches[1], 'theme_rocket');
} catch (Exception $e) {
$this->text = $matches[1];
}
}
$matches = array();
if (preg_match('/^\\[\\[([a-zA-Z0-9\\-\\_\\:]+)\\]\\]$/', $this->title, $matches)) {
try {
$this->title = get_string($matches[1], 'theme_rocket');
} catch (Exception $e) {
$this->title = $matches[1];
}
}
}
示例7: render_custom_menu_item
protected function render_custom_menu_item(custom_menu_item $menunode, $level = 0)
{
static $submenucount = 0;
$content = '';
if ($menunode->has_children()) {
if ($level == 1) {
$class = 'dropdown';
} else {
$class = 'dropdown-submenu';
}
if ($menunode === $this->language) {
$class .= ' langmenu';
}
$content = html_writer::start_tag('li', array('class' => $class));
// If the child has menus render it as a sub menu.
$submenucount++;
if ($menunode->get_url() !== null) {
$url = $menunode->get_url();
} else {
$url = '#cm_submenu_' . $submenucount;
}
$content .= html_writer::start_tag('a', array('href' => $url, 'class' => 'dropdown-toggle', 'data-toggle' => 'dropdown', 'title' => $menunode->get_title()));
$content .= $menunode->get_text();
if ($level == 1) {
$content .= '<b class="caret"></b>';
}
$content .= '</a>';
$content .= '<ul class="dropdown-menu">';
foreach ($menunode->get_children() as $menunode) {
$content .= $this->render_custom_menu_item($menunode, 0);
}
$content .= '</ul>';
} else {
// The node doesn't have children so produce a final menuitem.
// Also, if the node's text matches '####', add a class so we can treat it as a divider.
if (preg_match("/^#+\$/", $menunode->get_text())) {
// This is a divider.
$content = '<li class="divider"> </li>';
} else {
$content = '<li>';
if ($menunode->get_url() !== null) {
$url = $menunode->get_url();
} else {
$url = '#';
}
$content .= html_writer::link($url, $menunode->get_text(), array('title' => $menunode->get_title()));
$content .= '</li>';
}
}
return $content;
}
示例8: render_custom_menu_leaf
private function render_custom_menu_leaf(custom_menu_item $menunode)
{
$icon = $menunode->get_title();
if (strpos($icon, 'icon-') === 0) {
$icon = substr($icon, 5);
} else {
$icon = '';
}
return bootstrap::li_icon_link($menunode->get_url(), $icon, $menunode->get_text());
}
示例9: render_custom_menu_item
/**
* Output custom menu items as flat list.
*
* @return string
*/
protected function render_custom_menu_item(\custom_menu_item $menunode)
{
$content = html_writer::start_tag('li');
if ($menunode->get_url() !== null) {
$url = $menunode->get_url();
$content .= html_writer::link($url, $menunode->get_text(), array('title' => $menunode->get_title()));
} else {
$content .= $menunode->get_text();
}
$content .= html_writer::end_tag('li');
if ($menunode->has_children()) {
foreach ($menunode->get_children() as $menunode) {
$content .= $this->render_custom_menu_item($menunode);
}
}
return $content;
}
示例10: custommenu_out
/**
* Support function that takes a custom_menu_item and converts it to a string.
*
* @param custom_menu_item $item
* @param int $depth
* @return string
*/
protected function custommenu_out(custom_menu_item $item, $depth = 0)
{
$str = str_repeat('-', $depth);
$str .= $item->get_text();
$str .= '|' . $item->get_url();
$str .= '|' . $item->get_title();
if ($item->has_children()) {
$str .= '|' . count($item->get_children());
foreach ($item->get_children() as $child) {
$str .= "\n" . $this->custommenu_out($child, $depth + 1);
}
}
return $str;
}
示例11: render_custom_menu_item
protected function render_custom_menu_item(custom_menu_item $menunode, $level = 0)
{
static $submenucount = 0;
if ($menunode->has_children()) {
$dropdowntype = $level == 1 ? 'parent dcjq-parent-li' : 'parent dcjq-parent-li';
$content = html_writer::start_tag('li', array('class' => $dropdowntype));
// If the child has menus, render it as a sub menu.
$submenucount++;
$url = $menunode->get_url() !== null ? $menunode->get_url() : '#cm_submenu_' . $submenucount;
$content .= html_writer::start_tag('a', array('href' => 'javascript:void(0)', 'class' => 'dcjq-parent'));
$content .= $menunode->get_title();
$content .= html_writer::tag('i', '');
$content .= html_writer::tag('span', '', array('class' => 'dcjq-icon'));
$content .= html_writer::tag('span', '', array('class' => 'dcjq-icon'));
$content .= html_writer::end_tag('a');
$content .= html_writer::start_tag('ul');
foreach ($menunode->get_children() as $menunode) {
$content .= $this->render_custom_menu_item($menunode, 0);
}
$content .= html_writer::end_tag('ul');
} else {
$content = html_writer::start_tag('li');
// The node doesn't have children so produce a final menuitem.
$url = $menunode->get_url() !== null ? $menunode->get_url() : '#';
$content .= html_writer::link($url, $menunode->get_text(), array('title' => $menunode->get_title()));
}
return $content;
}
示例12: render_custom_menu_item
/**
* Renders menu items for the custom_menu
* @param custom_menu_item $menunode
* @param int $level
* @return string $content
*/
protected function render_custom_menu_item(custom_menu_item $menunode, $level = 0)
{
static $submenucount = 0;
if ($menunode->has_children()) {
if ($level == 1) {
$class = 'dropdown';
} else {
$class = 'dropdown-submenu';
}
if ($menunode === $this->language) {
$class .= ' langmenu';
}
$content = html_writer::start_tag('li', array('class' => $class));
// If the child has menus render it as a sub menu.
$submenucount++;
if ($menunode->get_url() !== null) {
$url = $menunode->get_url();
} else {
$url = '#cm_submenu_' . $submenucount;
}
$content .= html_writer::start_tag('a', array('href' => $url, 'class' => 'dropdown-toggle', 'data-toggle' => 'dropdown', 'title' => $menunode->get_title()));
$content .= $menunode->get_text();
if ($level == 1) {
$content .= '<i class="fa fa-caret-right"></i>';
}
$content .= '</a>';
$content .= '<ul class="dropdown-menu">';
foreach ($menunode->get_children() as $menunode) {
$content .= $this->render_custom_menu_item($menunode, 0);
}
$content .= '</ul>';
} else {
$content = '<li>';
// The node doesn't have children so produce a final menuitem.
$class = '';
if ($menunode->get_url() !== null) {
$url = $menunode->get_url();
$class = $url->get_param('essentialcolours');
} else {
$url = '#';
}
$content .= html_writer::link($url, $menunode->get_text(), array('title' => $menunode->get_title(), 'class' => $class));
}
return $content;
}
示例13: render_custom_menu_item
/**
* Renders a custom menu node as part of a submenu
*
* The custom menu this method produces makes use of the foundation
* top-bar element and requires specific markup and classes
*
* @see core:renderer::render_custom_menu()
*
* @staticvar int $submenucount
* @param custom_menu_item $menunode
* @return string
*/
protected function render_custom_menu_item(custom_menu_item $menunode)
{
if (right_to_left()) {
$direction = array('left-side' => 'right', 'right-side' => 'left');
$dir = 'right';
} else {
$direction = array('left-side' => 'left', 'right-side' => 'right');
$dir = '';
}
if ($menunode->has_children()) {
// If the child has menus render it as a sub menu
$content = html_writer::start_tag('li', array('class' => 'has-dropdown ' . $dir));
if ($menunode->get_url() !== null) {
$url = $menunode->get_url();
} else {
$url = '#';
}
$content .= html_writer::link($url, $menunode->get_text(), array('title' => $menunode->get_title()));
$content .= html_writer::start_tag('ul', array('class' => 'dropdown'));
foreach ($menunode->get_children() as $menunode) {
// If the child has menus render it as a sub menu (it's a loop!)
$content .= $this->render_custom_menu_item($menunode);
}
$content .= html_writer::end_tag('ul');
$content .= html_writer::end_tag('li');
} else {
// The node doesn't have children so produce a menuitem
$content = html_writer::start_tag('li');
if ($menunode->get_url() !== null) {
$url = $menunode->get_url();
} else {
$url = '#';
}
$content .= html_writer::link($url, $menunode->get_text(), array('title' => $menunode->get_title()));
$content .= html_writer::end_tag('li');
}
// Return the sub menu
return $content;
}
示例14: render_custom_menu_item
protected function render_custom_menu_item(custom_menu_item $menunode, $level = 0)
{
static $submenucount = 0;
// Add additional class for custom envelope/messages selector.
$customclass = '';
if (preg_match('/fa-envelope/', $menunode->get_text())) {
$customclass = ' messages';
}
if ($menunode->has_children()) {
if ($level == 1) {
$dropdowntype = 'dropdown';
} else {
$dropdowntype = 'dropdown-submenu';
}
$content = html_writer::start_tag('li', array('class' => $dropdowntype . $customclass));
// If the child has menus render it as a sub menu.
$submenucount++;
if ($menunode->get_url() !== null) {
$url = $menunode->get_url();
} else {
$url = '#cm_submenu_' . $submenucount;
}
$linkattributes = array('href' => $url, 'class' => 'dropdown-toggle', 'data-toggle' => 'dropdown', 'title' => $menunode->get_title());
$content .= html_writer::start_tag('a', $linkattributes);
$content .= $menunode->get_text();
if ($level == 1) {
$content .= '<b class="caret"></b>';
}
$content .= '</a>';
$content .= '<ul class="dropdown-menu">';
foreach ($menunode->get_children() as $menunode) {
$content .= $this->render_custom_menu_item($menunode, 0);
}
$content .= '</ul>';
} else {
$content = '<li>';
// The node doesn't have children so produce a final menuitem.
if ($menunode->get_url() !== null) {
$url = $menunode->get_url();
} else {
$url = '#';
}
$content .= html_writer::link($url, $menunode->get_text(), array('title' => $menunode->get_title()));
}
return $content;
}