本文整理汇总了PHP中get_separator函数的典型用法代码示例。如果您正苦于以下问题:PHP get_separator函数的具体用法?PHP get_separator怎么用?PHP get_separator使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_separator函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: navbar
public function navbar()
{
global $CFG;
$items = $this->page->navbar->get_items();
/* Added for subadmin */
$context = get_context_instance(CONTEXT_SYSTEM);
$roles = get_user_roles($context, $USER->id, false);
$role = key($roles);
$rolename = $roles[$role]->shortname;
$htmlblocks = array();
// Iterate the navarray and display each node
$itemcount = count($items);
$separator = get_separator();
for ($i = 0; $i < $itemcount; $i++) {
$item = $items[$i];
$item->hideicon = true;
if ($i === 0) {
if ($rolename == 'subadmin') {
$item->action = new moodle_url($CFG->wwwroot . '/my/');
}
$content = html_writer::tag('li', $this->render($item));
} else {
$content = html_writer::tag('li', $separator . $this->render($item));
}
$htmlblocks[] = $content;
}
//accessibility: heading for navbar list (MDL-20446)
$navbarcontent = html_writer::tag('span', get_string('pagepath'), array('class' => 'accesshide'));
$navbarcontent .= html_writer::tag('ul', join('', $htmlblocks), array('role' => 'navigation'));
// XHTML
return $navbarcontent;
}
示例2: __construct
/**
* Constructor.
*
* @param bool $showpasses Whether this reporter should output anything for passes.
*/
function __construct($showpasses)
{
parent::__construct('UTF-8');
$this->showpasses = $showpasses;
$this->strrunonlyfolder = $this->get_string('runonlyfolder');
$this->strrunonlyfile = $this->get_string('runonlyfile');
$this->strseparator = get_separator();
}
示例3: ExHtmlReporter
/**
* Constructor.
*
* @param bool $showpasses Whether this reporter should output anything for passes.
*/
function ExHtmlReporter($showpasses)
{
$this->HtmlReporter();
$this->showpasses = $showpasses;
$this->strrunonlyfolder = $this->get_string('runonlyfolder');
$this->strrunonlyfile = $this->get_string('runonlyfile');
$this->strseparator = get_separator();
}
示例4: navbar
public function navbar()
{
$items = $this->page->navbar->get_items();
$breadcrumbs = array();
foreach ($items as $item) {
$item->hideicon = true;
$breadcrumbs[] = $this->render($item);
}
$divider = '<span class="divider">' . get_separator() . '</span>';
$list_items = '<li>' . join(" {$divider}</li><li>", $breadcrumbs) . '</li>';
$title = '<span class="accesshide">' . get_string('pagepath') . '</span>';
return $title . "<ul class=\"breadcrumb\">{$list_items}</ul>";
}
示例5: progress_bar
/**
* Renderers a progress bar for the backup or restore given the items that
* make it up.
* @param array $items An array of items
* @return string
*/
public function progress_bar(array $items) {
foreach ($items as &$item) {
$text = $item['text'];
unset($item['text']);
if (array_key_exists('link', $item)) {
$link = $item['link'];
unset($item['link']);
$item = html_writer::link($link, $text, $item);
} else {
$item = html_writer::tag('span', $text, $item);
}
}
return html_writer::tag('div', join(get_separator(), $items), array('class'=>'backup_progress clearfix'));
}
示例6: navbar
public function navbar()
{
$items = $this->page->navbar->get_items();
if (empty($items)) {
return '';
}
$breadcrumbs = array();
foreach ($items as $item) {
$item->hideicon = true;
$breadcrumbs[] = $this->render($item);
}
$divider = '<span class="divider">' . get_separator() . '</span>';
$list_items = '<li>' . join(" {$divider}</li><li>", $breadcrumbs) . '</li>';
$title = '<span class="accesshide" id="navbar-label">' . get_string('pagepath') . '</span>';
return $title . '<nav aria-labelledby="navbar-label"><ul class="breadcrumb">' . $list_items . '</ul></nav>';
}
示例7: navbar
/**
* Return the navbar content so that it can be echoed out by the layout
*
* @return string XHTML navbar
*/
public function navbar() {
$items = $this->page->navbar->get_items();
$itemcount = count($items);
if ($itemcount === 0) {
return '';
}
$htmlblocks = array();
// Iterate the navarray and display each node
$separator = get_separator();
for ($i=0;$i < $itemcount;$i++) {
$item = $items[$i];
$item->hideicon = true;
if ($i===0) {
$content = html_writer::tag('li', $this->render($item));
} else {
$content = html_writer::tag('li', $separator.$this->render($item));
}
$htmlblocks[] = $content;
}
//accessibility: heading for navbar list (MDL-20446)
$navbarcontent = html_writer::tag('span', get_string('pagepath'), array('class'=>'accesshide'));
$navbarcontent .= html_writer::tag('nav', html_writer::tag('ul', join('', $htmlblocks)));
// XHTML
return $navbarcontent;
}
示例8: build_navigation
//.........这里部分代码省略.........
*
* @param mixed $extranavlinks - Normally an array of arrays, keys: name, link, type. If you
* only want one extra item with no link, you can pass a string instead. If you don't want
* any extra links, pass an empty string.
* @param mixed $cm - optionally the $cm object, if you want this function to generate the
* activity and activityinstance levels of navigation too.
*
* @return $navigation as an object so it can be differentiated from old style
* navigation strings.
*/
function build_navigation($extranavlinks, $cm = null)
{
global $CFG, $COURSE, $DB, $SITE;
if (is_string($extranavlinks)) {
if ($extranavlinks == '') {
$extranavlinks = array();
} else {
$extranavlinks = array(array('name' => $extranavlinks, 'link' => '', 'type' => 'title'));
}
}
$navlinks = array();
//Site name
if (!empty($SITE->shortname)) {
$navlinks[] = array('name' => format_string($SITE->shortname), 'link' => "{$CFG->wwwroot}/", 'type' => 'home');
}
// Course name, if appropriate.
if (isset($COURSE) && $COURSE->id != SITEID) {
$navlinks[] = array('name' => format_string($COURSE->shortname), 'link' => "{$CFG->wwwroot}/course/view.php?id={$COURSE->id}", 'type' => 'course');
}
// Activity type and instance, if appropriate.
if (is_object($cm)) {
if (!isset($cm->modname)) {
debugging('The field $cm->modname should be set if you call build_navigation with ' . 'a $cm parameter. If you get $cm using get_coursemodule_from_instance or ' . 'get_coursemodule_from_id, this will be done automatically.', DEBUG_DEVELOPER);
if (!($cm->modname = $DB->get_field('modules', 'name', array('id' => $cm->module)))) {
print_error('cannotmoduletype');
}
}
if (!isset($cm->name)) {
debugging('The field $cm->name should be set if you call build_navigation with ' . 'a $cm parameter. If you get $cm using get_coursemodule_from_instance or ' . 'get_coursemodule_from_id, this will be done automatically.', DEBUG_DEVELOPER);
if (!($cm->name = $DB->get_field($cm->modname, 'name', array('id' => $cm->instance)))) {
print_error('cannotmodulename');
}
}
$navlinks[] = array('name' => get_string('modulenameplural', $cm->modname), 'link' => $CFG->wwwroot . '/mod/' . $cm->modname . '/index.php?id=' . $cm->course, 'type' => 'activity');
$navlinks[] = array('name' => format_string($cm->name), 'link' => $CFG->wwwroot . '/mod/' . $cm->modname . '/view.php?id=' . $cm->id, 'type' => 'activityinstance');
}
//Merge in extra navigation links
$navlinks = array_merge($navlinks, $extranavlinks);
// Work out whether we should be showing the activity (e.g. Forums) link.
// Note: build_navigation() is called from many places --
// install & upgrade for example -- where we cannot count on the
// roles infrastructure to be defined. Hence the $CFG->rolesactive check.
if (!isset($CFG->hideactivitytypenavlink)) {
$CFG->hideactivitytypenavlink = 0;
}
if ($CFG->hideactivitytypenavlink == 2) {
$hideactivitylink = true;
} else {
if ($CFG->hideactivitytypenavlink == 1 && $CFG->rolesactive && !empty($COURSE->id) && $COURSE->id != SITEID) {
if (!isset($COURSE->context)) {
$COURSE->context = get_context_instance(CONTEXT_COURSE, $COURSE->id);
}
$hideactivitylink = !has_capability('moodle/course:manageactivities', $COURSE->context);
} else {
$hideactivitylink = false;
}
}
//Construct an unordered list from $navlinks
//Accessibility: heading hidden from visual browsers by default.
$navigation = get_accesshide(get_string('youarehere', 'access'), 'h2') . " <ul>\n";
$lastindex = count($navlinks) - 1;
$i = -1;
// Used to count the times, so we know when we get to the last item.
$first = true;
foreach ($navlinks as $navlink) {
$i++;
$last = $i == $lastindex;
if (!is_array($navlink)) {
continue;
}
if (!empty($navlink['type']) && $navlink['type'] == 'activity' && !$last && $hideactivitylink) {
continue;
}
$navigation .= '<li class="first">';
if (!$first) {
$navigation .= get_separator();
}
if (!empty($navlink['link']) && !$last) {
$navigation .= "<a onclick=\"this.target='{$CFG->framename}'\" href=\"{$navlink['link']}\">";
}
$navigation .= "{$navlink['name']}";
if (!empty($navlink['link']) && !$last) {
$navigation .= "</a>";
}
$navigation .= "</li>";
$first = false;
}
$navigation .= "</ul>";
return array('newnav' => true, 'navlinks' => $navigation);
}
示例9: print_navigation
/**
* Prints breadcrumb trail of links, called in theme/-/header.html
*
* @uses $CFG
* @param mixed $navigation The breadcrumb navigation string to be printed
* @param string $separator The breadcrumb trail separator. The default 0 leads to the use
* of $THEME->rarrow, themes could use '→', '/', or '' for a style-sheet solution.
* @param boolean $return False to echo the breadcrumb string (default), true to return it.
*/
function print_navigation($navigation, $separator = 0, $return = false)
{
global $CFG, $THEME;
$output = '';
if (0 === $separator) {
$separator = get_separator();
} else {
$separator = '<span class="sep">' . $separator . '</span>';
}
if ($navigation) {
if (!is_array($navigation)) {
$ar = explode('->', $navigation);
$navigation = array();
foreach ($ar as $a) {
if (strpos($a, '</a>') === false) {
$navigation[] = array('title' => $a, 'url' => '');
} else {
if (preg_match('/<a.*href="([^"]*)">(.*)<\\/a>/', $a, $matches)) {
$navigation[] = array('title' => $matches[2], 'url' => $matches[1]);
}
}
}
}
if (!($site = get_site())) {
$site = new object();
$site->shortname = get_string('home');
}
//Accessibility: breadcrumb links now in a list, » replaced with a 'silent' character.
$output .= get_accesshide(get_string('youarehere', 'access'), 'h2') . "<ul>\n";
$output .= '<li class="first">' . "\n" . '<a ' . $CFG->frametarget . ' onclick="this.target=\'' . $CFG->framename . '\'" href="' . $CFG->wwwroot . (!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)) && !empty($USER->id) && !empty($CFG->mymoodleredirect) && !isguest() ? '/my' : '') . '/">' . format_string($site->shortname) . "</a>\n</li>\n";
foreach ($navigation as $navitem) {
$title = trim(strip_tags(format_string($navitem['title'], false)));
$url = $navitem['url'];
if (empty($url)) {
$output .= '<li class="first">' . "{$separator} {$title}</li>\n";
} else {
$output .= '<li class="first">' . "{$separator}\n<a " . $CFG->frametarget . ' onclick="this.target=\'' . $CFG->framename . '\'" href="' . $url . '">' . "{$title}</a>\n</li>\n";
}
}
$output .= "</ul>\n";
}
if ($return) {
return $output;
} else {
echo $output;
}
}
示例10: build_navigation
/**
* This function will build the navigation string to be used by print_header
* and others
* @uses $CFG
* @uses $THEME
* @param $extranavlinks - array of associative arrays, keys: name, link, type
* @return $navigation as an object so it can be differentiated from old style
* navigation strings.
*/
function build_navigation($extranavlinks)
{
global $CFG, $COURSE;
$navigation = '';
$navlinks = array();
//Site name
if ($site = get_site()) {
$navlinks[] = array('name' => format_string($site->shortname), 'link' => "{$CFG->wwwroot}/", 'type' => 'home');
}
if ($COURSE) {
if ($COURSE->id != SITEID) {
//Course
$navlinks[] = array('name' => format_string($COURSE->shortname), 'link' => "{$CFG->wwwroot}/course/view.php?id={$COURSE->id}", 'type' => 'course');
}
}
//Merge in extra navigation links
$navlinks = array_merge($navlinks, $extranavlinks);
//Construct an unordered list from $navlinks
//Accessibility: heading hidden from visual browsers by default.
$navigation = '<h2 class="accesshide">' . get_string('youarehere', 'access') . "</h2> <ul>\n";
$countlinks = count($navlinks);
$i = 0;
foreach ($navlinks as $navlink) {
if ($i >= $countlinks || !is_array($navlink)) {
continue;
}
// Check the link type to see if this link should appear in the trail
//
// NOTE: we should move capchecks _out_ to the callers. build_navigation() is
// called from many places -- install & upgrade for example -- where we cannot
// count on the roles infrastructure to be defined.
//
$cap = 0;
if (!empty($COURSE->id) && $COURSE->id != SITEID) {
if (!isset($COURSE->context)) {
$COURSE->context = get_context_instance(CONTEXT_COURSE, $COURSE->id);
}
$cap = has_capability('moodle/course:manageactivities', $COURSE->context);
}
$hidetype_is2 = isset($CFG->hideactivitytypenavlink) && $CFG->hideactivitytypenavlink == 2;
$hidetype_is1 = isset($CFG->hideactivitytypenavlink) && $CFG->hideactivitytypenavlink == 1;
if ($navlink['type'] == 'activity' && $i + 1 < $countlinks && ($hidetype_is2 || $hidetype_is1 && !$cap)) {
continue;
}
$navigation .= '<li class="first">';
if ($i > 0) {
$navigation .= get_separator();
}
if (!empty($navlink['link']) && $i + 1 < $countlinks) {
$navigation .= "<a onclick=\"this.target='{$CFG->framename}'\" href=\"{$navlink['link']}\">";
}
$navigation .= "{$navlink['name']}";
if (!empty($navlink['link']) && $i + 1 < $countlinks) {
$navigation .= "</a>";
}
$navigation .= "</li>";
$i++;
}
$navigation .= "</ul>";
return array('newnav' => true, 'navlinks' => $navigation);
}
示例11: navbar
public function navbar()
{
$items = $this->page->navbar->get_items();
$breadcrumbs = array();
foreach ($items as $item) {
$item->hideicon = true;
/*
* Trying to replace the 'My home' breadcrumb
* not very elegant; another solution may be considered later
*/
$ismyhome = strcasecmp($item->text, get_string('myhome')) == 0;
if ($ismyhome) {
$breadcrumbs[] = '<a href="/" id="moo-home-button"> <i class="fa fa-home fa-lg"></i></a>';
continue;
// go to next element
}
/**/
$a = $this->render($item);
if (strpos($a, "/course/view.php") !== false) {
$breadcrumbs[] = html_writer::div($a, 'coursetitle');
} else {
$breadcrumbs[] = $a;
}
}
// ADD ELLIPSES ...
$new_breadcrumbs = array();
$counter = 0;
foreach ($breadcrumbs as $breadcrumb) {
//add ellipses in second position
if ($counter == 1) {
$new_breadcrumbs[] = "<span id='ellipses'>...</span>";
}
$new_breadcrumbs[] = $breadcrumb;
$counter++;
}
//
$divider = '<span class="divider">' . get_separator() . '</span>';
$list_items = '<li>' . join(" {$divider}</li><li>", $new_breadcrumbs) . '</li>';
$title = '<span class="accesshide">' . get_string('pagepath') . '</span>';
return $title . "<ul id=\"bc1\" class=\"breadcrumb\">{$list_items}</ul>";
}