本文整理汇总了PHP中user_get_user_navigation_info函数的典型用法代码示例。如果您正苦于以下问题:PHP user_get_user_navigation_info函数的具体用法?PHP user_get_user_navigation_info怎么用?PHP user_get_user_navigation_info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了user_get_user_navigation_info函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: user_menu
/**
* Construct a user menu, returning HTML that can be echoed out by a
* layout file.
*
* @param stdClass $user A user object, usually $USER.
* @param bool $withlinks true if a dropdown should be built.
* @return string HTML fragment.
*/
public function user_menu($user = null, $withlinks = null) {
global $USER, $CFG;
require_once($CFG->dirroot . '/user/lib.php');
if (is_null($user)) {
$user = $USER;
}
// Note: this behaviour is intended to match that of core_renderer::login_info,
// but should not be considered to be good practice; layout options are
// intended to be theme-specific. Please don't copy this snippet anywhere else.
if (is_null($withlinks)) {
$withlinks = empty($this->page->layout_options['nologinlinks']);
}
// Add a class for when $withlinks is false.
$usermenuclasses = 'usermenu';
if (!$withlinks) {
$usermenuclasses .= ' withoutlinks';
}
$returnstr = "";
// If during initial install, return the empty return string.
if (during_initial_install()) {
return $returnstr;
}
$loginpage = $this->is_login_page();
$loginurl = get_login_url();
// If not logged in, show the typical not-logged-in string.
if (!isloggedin()) {
$returnstr = get_string('loggedinnot', 'moodle');
if (!$loginpage) {
$returnstr .= " (<a href=\"$loginurl\">" . get_string('login') . '</a>)';
}
return html_writer::div(
html_writer::span(
$returnstr,
'login'
),
$usermenuclasses
);
}
// If logged in as a guest user, show a string to that effect.
if (isguestuser()) {
$returnstr = get_string('loggedinasguest');
if (!$loginpage && $withlinks) {
$returnstr .= " (<a href=\"$loginurl\">".get_string('login').'</a>)';
}
return html_writer::div(
html_writer::span(
$returnstr,
'login'
),
$usermenuclasses
);
}
// Get some navigation opts.
$opts = user_get_user_navigation_info($user, $this->page);
$avatarclasses = "avatars";
$avatarcontents = html_writer::span($opts->metadata['useravatar'], 'avatar current');
$usertextcontents = $opts->metadata['userfullname'];
// Other user.
if (!empty($opts->metadata['asotheruser'])) {
$avatarcontents .= html_writer::span(
$opts->metadata['realuseravatar'],
'avatar realuser'
);
$usertextcontents = $opts->metadata['realuserfullname'];
$usertextcontents .= html_writer::tag(
'span',
get_string(
'loggedinas',
'moodle',
html_writer::span(
$opts->metadata['userfullname'],
'value'
)
),
array('class' => 'meta viewingas')
);
}
// Role.
if (!empty($opts->metadata['asotherrole'])) {
//.........这里部分代码省略.........
开发者ID:afgal,项目名称:moodle-1,代码行数:101,代码来源:outputrenderers.php
示例2: test_user_menu_custom_avatar_size
/**
* Test setting the user menu avatar size.
*/
public function test_user_menu_custom_avatar_size()
{
global $PAGE;
$this->resetAfterTest(true);
$testsize = 100;
$user = $this->getDataGenerator()->create_user();
$opts = user_get_user_navigation_info($user, $PAGE, array('avatarsize' => $testsize));
$avatarhtml = $opts->metadata['useravatar'];
$matches = [];
preg_match('/(?:.*width=")(\\d*)(?:" height=")(\\d*)(?:".*\\/>)/', $avatarhtml, $matches);
$this->assertCount(3, $matches);
$this->assertEquals(intval($matches[1]), $testsize);
$this->assertEquals(intval($matches[2]), $testsize);
}
开发者ID:reconnectmedia,项目名称:moodle,代码行数:17,代码来源:userlib_test.php
注:本文中的user_get_user_navigation_info函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论