本文整理汇总了PHP中URL::home方法的典型用法代码示例。如果您正苦于以下问题:PHP URL::home方法的具体用法?PHP URL::home怎么用?PHP URL::home使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类URL
的用法示例。
在下文中一共展示了URL::home方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_rss
public function action_rss($input_format)
{
Log::info($input_format);
if ($input_format == "rss") {
$format = "rss20";
$content_type = "application/rss+xml; charset=ISO-8859-1";
} elseif ($input_format == "atom") {
$format = "atom";
$content_type = "application/atom+xml";
} else {
return Response::error('404');
}
$feed = Feed::make();
$feed->author('The RFP-EZ Team')->pubdate(time())->ttl(60)->title('Government Contracting Opportunities on RFP-EZ')->description('Government Contracting Opportunities on RFP-EZ')->permalink(route('project_rss', 'rss20'))->baseurl(URL::home());
foreach (Project::open_projects()->take(20)->order_by('posted_to_fbo_at', 'desc')->get() as $project) {
$feed->entry()->published($project->posted_to_fbo_at)->description()->add('html', $project->background)->up()->title($project->title)->permalink(route('project', $project->id));
}
Config::set("application.profiler", false);
return Response::make($feed->send($format), 200, array('Content-type' => $content_type));
}
示例2: loadBoard
//.........这里部分代码省略.........
// Set the current board.
if (!empty($row['id_board'])) {
$board = $row['id_board'];
}
// Basic operating information. (globals... :/)
$board_info = array('id' => $board, 'moderators' => array(), 'cat' => array('id' => $row['id_cat'], 'name' => $row['cname'], 'is_root' => $row['cname'][0] === '!' ? true : false), 'name' => $row['bname'], 'allow_topics' => $row['allow_topics'], 'description' => $row['description'], 'num_topics' => $row['num_topics'], 'unapproved_topics' => $row['unapproved_topics'], 'unapproved_posts' => $row['unapproved_posts'], 'unapproved_user_topics' => 0, 'parent_boards' => getBoardParents($row['id_parent']), 'parent' => $row['id_parent'], 'child_level' => $row['child_level'], 'theme' => $row['id_theme'], 'override_theme' => !empty($row['override_theme']), 'profile' => $row['id_profile'], 'redirect' => $row['redirect'], 'posts_count' => empty($row['count_posts']), 'cur_topic_approved' => empty($topic) || $row['approved'], 'cur_topic_starter' => empty($topic) ? 0 : $row['id_member_started']);
// Load the membergroups allowed, and check permissions.
$board_info['groups'] = $row['member_groups'] == '' ? array() : explode(',', $row['member_groups']);
do {
if (!empty($row['id_moderator'])) {
$board_info['moderators'][$row['id_moderator']] = array('id' => $row['id_moderator'], 'name' => $row['real_name'], 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>');
}
} while ($row = mysql_fetch_assoc($request));
// If the board only contains unapproved posts and the user isn't an approver then they can't see any topics.
// If that is the case do an additional check to see if they have any topics waiting to be approved.
if ($board_info['num_topics'] == 0 && $modSettings['postmod_active'] && !allowedTo('approve_posts')) {
mysql_free_result($request);
// Free the previous result
$request = smf_db_query('
SELECT COUNT(id_topic)
FROM {db_prefix}topics
WHERE id_member_started={int:id_member}
AND approved = {int:unapproved}
AND id_board = {int:board}', array('id_member' => $user_info['id'], 'unapproved' => 0, 'board' => $board));
list($board_info['unapproved_user_topics']) = mysql_fetch_row($request);
}
if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) {
// !!! SLOW?
if (!empty($topic)) {
CacheAPI::putCache('topic_board-' . $topic, $board_info, 120);
}
CacheAPI::putCache('board-' . $board, $board_info, 120);
}
} else {
// Otherwise the topic is invalid, there are no moderators, etc.
$board_info = array('moderators' => array(), 'error' => 'exist');
$topic = null;
$board = 0;
}
mysql_free_result($request);
}
if (!empty($topic)) {
$_GET['board'] = (int) $board;
}
/*
* if we are in topic view, set up the breadcrumb so that it
* gives a link back to the last active message index page instead of
* always pointing back to page one, but ignore the cookie when the board has changed.
* the cookie is set in MessageIndex.php
*/
$stored_topicstart = 0;
if (isset($_COOKIE['smf_topicstart']) && !empty($topic)) {
$topicstart_cookie = $_COOKIE['smf_topicstart'];
$_t = explode('_', $topicstart_cookie);
if (isset($_t[0]) && isset($_t[1]) && intval($_t[1]) > 0) {
if ($_t[0] == $board) {
$stored_topicstart = $_t[1];
}
$topics_per_page = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics'];
}
}
if (!empty($board)) {
// Now check if the user is a moderator.
$user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]);
if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) {
$board_info['error'] = 'access';
}
// Build up the linktree.
$context['linktree'] = array_merge($context['linktree'], $board_info['cat']['is_root'] ? array() : array(array('url' => $scripturl . '#c' . $board_info['cat']['id'], 'name' => $board_info['cat']['name'])), array_reverse($board_info['parent_boards']), array(array('url' => URL::board($board, $board_info['name'], $stored_topicstart > 0 ? $stored_topicstart : 0, false), 'name' => $board_info['name'] . ($stored_topicstart > 0 ? ' [' . ($stored_topicstart / $topics_per_page + 1) . ']' : ''))));
}
// Set the template contextual information.
$context['user']['is_mod'] =& $user_info['is_mod'];
$context['current_topic'] = $topic;
$context['current_board'] = $board;
// Hacker... you can't see this topic, I'll tell you that. (but moderators can!)
if (!empty($board_info['error']) && ($board_info['error'] != 'access' || !$user_info['is_mod'])) {
// The permissions and theme need loading, just to make sure everything goes smoothly.
loadPermissions();
loadTheme();
EoS_Smarty::init($db_show_debug);
$_GET['board'] = '';
$_GET['topic'] = '';
// The linktree should not give the game away mate!
$context['linktree'] = array(array('url' => URL::home(), 'name' => $context['forum_name_html_safe']));
// If it's a prefetching agent or we're requesting an attachment.
if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch' || !empty($_REQUEST['action']) && $_REQUEST['action'] === 'dlattach') {
ob_end_clean();
header('HTTP/1.1 403 Forbidden');
die;
} elseif ($user_info['is_guest']) {
loadLanguage('Errors');
is_not_guest($txt['topic_gone']);
} else {
fatal_lang_error('topic_gone', false);
}
}
if ($user_info['is_mod']) {
$user_info['groups'][] = 3;
}
}
示例3: function
if (Request::forged()) {
return Response::error('500');
}
});
Route::filter('auth', function () {
if (Auth::guest()) {
return Redirect::to('login');
}
});
Route::get('language/(:num)', function ($lang) {
//if (!Input::get('language') or !is_numeric(Input::get('language'))) Response::error('500');
//$lang = Input::get('language');
$langarray = array(0 => 'it', 1 => 'en');
$user_language = $langarray[$lang];
Config::set('application.language', $user_language);
Session::put('language', $user_language);
if (Auth::user() and Auth::user()->language) {
Auth::user()->language = $user_language;
Auth::user()->save();
}
return Redirect::home();
});
Route::any('logout', array('as' => 'logout', function () {
Auth::logout();
//echo URL::home(302);
return Redirect::to(URL::home(), 302);
}));
Route::any('/profile', 'profile@view');
Route::any('/profile/(:num)', 'profile@view');
Route::any('/profile/index/(:all?)', 'profile@view');
Route::controller(Controller::detect());
示例4: smf_main
function smf_main()
{
global $context, $modSettings, $settings, $user_info, $board, $topic, $board_info, $maintenance, $sourcedir, $backend_subdir, $db_show_debug;
// Special case: session keep-alive, output a transparent pixel.
if (isset($_GET['action']) && $_GET['action'] == 'keepalive') {
header('Content-Type: image/gif');
die("GIF89a€!ù,D;");
}
// Load the user's cookie (or set as guest) and load their settings.
loadUserSettings();
// Load the current board's information.
loadBoard();
// Load the current user's permissions.
loadPermissions();
$context['can_search'] = allowedTo('search_posts');
$context['additional_admin_errors'] .= CacheAPI::verifyFileCache();
// Attachments don't require the entire theme to be loaded.
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach' && (!empty($modSettings['allow_guestAccess']) && $user_info['is_guest'])) {
detectBrowser();
$context['forum_name_html_safe'] = '';
} else {
loadTheme();
EoS_Smarty::init($db_show_debug);
}
$user_info['notify_count'] += !empty($context['open_mod_reports']) ? 1 : 0;
URL::setSID();
array_unshift($context['linktree'], array('url' => URL::home(), 'name' => $context['forum_name_html_safe']));
// Check if the user should be disallowed access.
is_not_banned();
$context['can_see_hidden_level1'] = allowedTo('see_hidden1');
$context['can_see_hidden_level2'] = allowedTo('see_hidden2');
$context['can_see_hidden_level2'] = allowedTo('see_hidden2');
// If we are in a topic and don't have permission to approve it then duck out now.
if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) {
fatal_lang_error('not_a_topic', false);
}
// Do some logging, unless this is an attachment, avatar, toggle of editor buttons, theme option, XML feed etc.
if (empty($_REQUEST['action']) || !in_array($_REQUEST['action'], array('dlattach', 'findmember', 'jseditor', 'jsoption', 'requestmembers', 'smstats', '.xml', 'xmlhttp', 'verificationcode', 'viewquery', 'viewsmfile'))) {
// Log this user as online.
writeLog();
// Track forum statistics and hits...?
if (!empty($modSettings['hitStats'])) {
trackStats(array('hits' => '+'));
}
}
// Is the forum in maintenance mode? (doesn't apply to administrators.)
if (!empty($maintenance) && !allowedTo('admin_forum')) {
// You can only login.... otherwise, you're getting the "maintenance mode" display.
if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'login2' || $_REQUEST['action'] == 'logout')) {
require_once $sourcedir . '/LogInOut.php';
return $_REQUEST['action'] == 'login2' ? 'Login2' : 'Logout';
} else {
require_once $sourcedir . '/lib/Subs-Auth.php';
return 'InMaintenance';
}
} elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'register', 'register2', 'reminder', 'activate', 'help', 'smstats', 'mailq', 'verificationcode', 'openidreturn')))) {
require_once $sourcedir . '/lib/Subs-Auth.php';
return 'KickGuest';
} elseif (empty($_REQUEST['action'])) {
// Action and board are both empty... BoardIndex!
if (empty($board) && empty($topic)) {
require_once $sourcedir . '/BoardIndex.php';
return 'BoardIndex';
} elseif (empty($topic)) {
require_once $sourcedir . '/MessageIndex.php';
return 'MessageIndex';
} else {
require_once $sourcedir . '/Display.php';
return 'Display';
}
}
// Here's the monstrous $_REQUEST['action'] array - $_REQUEST['action'] => array($file, $function).
$actionArray = array('activate' => array('Register.php', 'Activate'), 'admin' => array($backend_subdir . '/Admin.php', 'AdminMain'), 'announce' => array('Post.php', 'AnnounceTopic'), 'attachapprove' => array('lib/Subs-ManageAttachments.php', 'ApproveAttach'), 'buddy' => array('lib/Subs-Members.php', 'BuddyListToggle'), 'calendar' => array('Calendar.php', 'CalendarMain'), 'clock' => array('Calendar.php', 'clock'), 'collapse' => array('BoardIndex.php', 'CollapseCategory'), 'coppa' => array('Register.php', 'CoppaForm'), 'credits' => array('Who.php', 'Credits'), 'deletemsg' => array('RemoveTopic.php', 'DeleteMessage'), 'display' => array('Display.php', 'Display'), 'dlattach' => array('Display.php', 'Download'), 'editpoll' => array('Poll.php', 'EditPoll'), 'editpoll2' => array('Poll.php', 'EditPoll2'), 'emailuser' => array('SendTopic.php', 'EmailUser'), 'findmember' => array('lib/Subs-Auth.php', 'JSMembers'), 'groups' => array('Groups.php', 'Groups'), 'help' => array('Help.php', 'ShowHelp'), 'helpadmin' => array('Help.php', 'ShowAdminHelp'), 'im' => array('PersonalMessage.php', 'MessageMain'), 'jseditor' => array('lib/Subs-Editor.php', 'EditorMain'), 'jsmodify' => array('Post.php', 'JavaScriptModify'), 'jsoption' => array($backend_subdir . '/Themes.php', 'SetJavaScript'), 'lock' => array('LockTopic.php', 'LockTopic'), 'lockvoting' => array('Poll.php', 'LockVoting'), 'login' => array('LogInOut.php', 'Login'), 'login2' => array('LogInOut.php', 'Login2'), 'logout' => array('LogInOut.php', 'Logout'), 'markasread' => array('lib/Subs-Boards.php', 'MarkRead'), 'mergetopics' => array('SplitTopics.php', 'MergeTopics'), 'mlist' => array('Memberlist.php', 'Memberlist'), 'moderate' => array('ModerationCenter.php', 'ModerationMain'), 'modifycat' => array('ManageBoards.php', 'ModifyCat'), 'movetopic' => array('MoveTopic.php', 'MoveTopic'), 'movetopic2' => array('MoveTopic.php', 'MoveTopic2'), 'notify' => array('Notify.php', 'Notify'), 'notifyboard' => array('Notify.php', 'BoardNotify'), 'openidreturn' => array('lib/Subs-OpenID.php', 'smf_openID_return'), 'pm' => array('PersonalMessage.php', 'MessageMain'), 'post' => array('Post.php', 'Post'), 'post2' => array('Post.php', 'Post2'), 'printpage' => array('Printpage.php', 'PrintTopic'), 'profile' => array('Profile.php', 'ModifyProfile'), 'quotefast' => array('Post.php', 'QuoteFast'), 'quickmod' => array('MessageIndex.php', 'QuickModeration'), 'quickmod2' => array('Display.php', 'QuickInTopicModeration'), 'recent' => array('Recent.php', 'RecentPosts'), 'register' => array('Register.php', 'Register'), 'register2' => array('Register.php', 'Register2'), 'reminder' => array('Reminder.php', 'RemindMe'), 'removepoll' => array('Poll.php', 'RemovePoll'), 'removetopic2' => array('RemoveTopic.php', 'RemoveTopic2'), 'reporttm' => array('SendTopic.php', 'ReportToModerator'), 'requestmembers' => array('lib/Subs-Auth.php', 'RequestMembers'), 'restoretopic' => array('RemoveTopic.php', 'RestoreTopic'), 'search' => array('Search.php', 'PlushSearch1'), 'search2' => array('Search.php', 'PlushSearch2'), 'sendtopic' => array('SendTopic.php', 'EmailUser'), 'smstats' => array('Stats.php', 'SMStats'), 'suggest' => array('lib/Subs-Editor.php', 'AutoSuggestHandler'), 'splittopics' => array('SplitTopics.php', 'SplitTopics'), 'stats' => array('Stats.php', 'DisplayStats'), 'sticky' => array('LockTopic.php', 'Sticky'), 'theme' => array($backend_subdir . '/Themes.php', 'ThemesMain'), 'trackip' => array('Profile-View.php', 'trackIP'), 'about:unknown' => array('Karma.php', 'BookOfUnknown'), 'unread' => array('Recent.php', 'UnreadTopics'), 'unreadreplies' => array('Recent.php', 'UnreadTopics'), 'verificationcode' => array('Register.php', 'VerificationCode'), 'viewprofile' => array('Profile.php', 'ModifyProfile'), 'vote' => array('Poll.php', 'Vote'), 'viewquery' => array('ViewQuery.php', 'ViewQuery'), 'who' => array('Who.php', 'Who'), '.xml' => array('News.php', 'ShowXmlFeed'), 'xmlhttp' => array('Xml.php', 'XMLhttpMain'), 'like' => array('Ratings.php', 'LikeDispatch'), 'tags' => array('Tagging.php', 'TagsMain'), 'astream' => array('Activities.php', 'aStreamDispatch'), 'dismissnews' => array('Profile-Actions.php', 'DismissNews'), 'whatsnew' => array('Recent.php', 'WhatsNew'));
// Allow modifying $actionArray easily.
HookAPI::callHook('integrate_actions', array(&$actionArray));
// Get the function and file to include - if it's not there, do the board index.
if (!isset($_REQUEST['action']) || !isset($actionArray[$_REQUEST['action']])) {
// Catch the action with the theme?
if (!empty($settings['catch_action'])) {
require_once $sourcedir . '/' . $backend_subdir . '/Themes.php';
return 'WrapAction';
}
// Fall through to the board index then...
require_once $sourcedir . '/BoardIndex.php';
return 'BoardIndex';
}
// Otherwise, it was set - so let's go to that action.
require_once $sourcedir . '/' . $actionArray[$_REQUEST['action']][0];
return $actionArray[$_REQUEST['action']][1];
}
示例5: function
});
Route::post('vote', function () {
// Lets say you have "vote" model, in that case you could be able to do something like
// $vote = new Vote()
// $vote->user_id = Auth::user()->id;
// $vote->save();
$data = array("html" => '<a href="#" class="btn disabled"><i class="icon icon-thumbs-up"></i> Voted!</a>');
return Response::json($data);
});
Route::post('redirect', function () {
// the user will be redirected to wherever the location variable in the JSON response is set
$data = array("location" => 'someredirectroute');
return Response::json($data);
});
Route::get('someredirectroute', function () {
echo 'Awesome! You have been redirected! Go ' . HTML::link(URL::home(), 'HOME');
});
Route::post('submit', function () {
// When the form is submitted, we can do some DB queries and let the user know that the form was submitted.
$name = e(Input::get('name'));
$checker = e(Input::get('checker'));
$data = array("html" => '
<a href="#" class="btn btn-large btn-success disabled"><i class="icon icon-thumbs-up"></i>Form Submitted! Thanks</a>
<h4>You have provided following values: </h4>
<p>Name : ' . $name . '</p>
<p>Checker : ' . ($checker ? 'true' : 'false') . '</p>
');
return Response::json($data);
});
/*
示例6: setupMenuContext
function setupMenuContext()
{
global $context, $modSettings, $user_info, $txt, $scripturl;
// Set up the menu privileges.
$context['allow_search'] = !empty($modSettings['allow_guestAccess']) ? allowedTo('search_posts') : !$user_info['is_guest'] && allowedTo('search_posts');
$context['allow_admin'] = allowedTo(array('admin_forum', 'manage_boards', 'manage_permissions', 'moderate_forum', 'manage_membergroups', 'manage_bans', 'send_mail', 'edit_news', 'manage_attachments', 'manage_smileys'));
$context['allow_edit_profile'] = !$user_info['is_guest'] && allowedTo(array('profile_view_own', 'profile_view_any', 'profile_identity_own', 'profile_identity_any', 'profile_extra_own', 'profile_extra_any', 'profile_remove_own', 'profile_remove_any', 'moderate_forum', 'manage_membergroups', 'profile_title_own', 'profile_title_any'));
$context['allow_memberlist'] = allowedTo('view_mlist');
$context['allow_calendar'] = allowedTo('calendar_view') && !empty($modSettings['cal_enabled']);
$context['allow_moderation_center'] = $context['user']['can_mod'];
$context['allow_pm'] = allowedTo('pm_read');
$cacheTime = $modSettings['lastActive'] * 60;
// All the buttons we can possible want and then some, try pulling the final list of buttons from cache first.
if (($menu_buttons = CacheAPI::getCache('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $cacheTime)) === null || time() - $cacheTime <= $modSettings['settings_updated'] || URL::haveSID()) {
$buttons = array('home' => array('title' => $txt['home'], 'href' => URL::home(), 'show' => true, 'is_last' => $context['right_to_left']), 'help' => array('title' => $txt['help'], 'href' => URL::parse('?action=help'), 'show' => true, 'sub_buttons' => array()), 'search' => array('title' => $txt['search'], 'href' => URL::parse('?action=search'), 'show' => $context['allow_search'], 'sub_buttons' => array()), 'admin' => array('title' => $txt['admin'], 'href' => $scripturl . '?action=admin', 'show' => $context['allow_admin'], 'sub_buttons' => array('featuresettings' => array('title' => $txt['modSettings_title'], 'href' => $scripturl . '?action=admin;area=featuresettings', 'show' => allowedTo('admin_forum')), 'packages' => array('title' => $txt['package'], 'href' => $scripturl . '?action=admin;area=packages', 'show' => allowedTo('admin_forum')), 'errorlog' => array('title' => $txt['errlog'], 'href' => $scripturl . '?action=admin;area=logs;sa=errorlog;desc', 'show' => allowedTo('admin_forum') && !empty($modSettings['enableErrorLogging'])), 'permissions' => array('title' => $txt['edit_permissions'], 'href' => $scripturl . '?action=admin;area=permissions', 'show' => allowedTo('manage_permissions'), 'is_last' => true))), 'moderate' => array('title' => $txt['moderate'], 'href' => $scripturl . '?action=moderate', 'show' => $context['allow_moderation_center'], 'sub_buttons' => array('modlog' => array('title' => $txt['modlog_view'], 'href' => $scripturl . '?action=moderate;area=modlog', 'show' => !empty($modSettings['modlog_enabled']) && !empty($user_info['mod_cache']) && $user_info['mod_cache']['bq'] != '0=1'), 'poststopics' => array('title' => $txt['mc_unapproved_poststopics'], 'href' => $scripturl . '?action=moderate;area=postmod;sa=posts', 'show' => $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap'])), 'attachments' => array('title' => $txt['mc_unapproved_attachments'], 'href' => $scripturl . '?action=moderate;area=attachmod;sa=attachments', 'show' => $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap'])), 'reports' => array('title' => $txt['mc_reported_posts'], 'href' => $scripturl . '?action=moderate;area=reports', 'show' => !empty($user_info['mod_cache']) && $user_info['mod_cache']['bq'] != '0=1', 'is_last' => true))), 'tags' => array('title' => $txt['smftags_menu'], 'href' => URL::parse('?action=tags'), 'show' => !empty($modSettings['tags_active']), 'sub_buttons' => array()), 'calendar' => array('title' => $txt['calendar'], 'href' => URL::parse('?action=calendar'), 'show' => $context['allow_calendar'], 'sub_buttons' => array('view' => array('title' => $txt['calendar_menu'], 'href' => URL::parse('?action=calendar'), 'show' => allowedTo('calendar_post')), 'post' => array('title' => $txt['calendar_post_event'], 'href' => URL::parse('?action=calendar;sa=post'), 'show' => allowedTo('calendar_post'), 'is_last' => true))), 'mlist' => array('title' => $txt['members_title'], 'href' => URL::parse('?action=mlist'), 'show' => $context['allow_memberlist'], 'sub_buttons' => array('mlist_view' => array('title' => $txt['mlist_menu_view'], 'href' => URL::parse('?action=mlist'), 'show' => true), 'mlist_search' => array('title' => $txt['mlist_search'], 'href' => URL::parse('?action=mlist;sa=search'), 'show' => true, 'is_last' => true))), 'login' => array('title' => $txt['login'], 'href' => $scripturl . '?action=login', 'show' => $user_info['is_guest'], 'sub_buttons' => array()), 'register' => array('title' => $txt['register'], 'href' => $scripturl . '?action=register', 'show' => $user_info['is_guest'] && !(!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3) ? true : false, 'sub_buttons' => array(), 'is_last' => !$context['right_to_left']));
// Now we put the buttons in the context so the theme can use them.
$menu_buttons = array();
foreach ($buttons as $act => $button) {
if (!empty($button['show'])) {
$button['active_button'] = false;
// Make sure the last button truely is the last button.
if (!empty($button['is_last'])) {
if (isset($last_button)) {
unset($menu_buttons[$last_button]['is_last']);
}
$last_button = $act;
}
// Go through the sub buttons if there are any.
if (!empty($button['sub_buttons'])) {
foreach ($button['sub_buttons'] as $key => $subbutton) {
if (empty($subbutton['show'])) {
unset($button['sub_buttons'][$key]);
}
// 2nd level sub buttons next...
if (!empty($subbutton['sub_buttons'])) {
foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2) {
if (empty($sub_button2['show'])) {
unset($button['sub_buttons'][$key]['sub_buttons'][$key2]);
}
}
}
}
}
$menu_buttons[$act] = $button;
}
}
if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && !URL::haveSID()) {
CacheAPI::putCache('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime);
}
}
if (isset($context['current_board'])) {
$astream_link = '<a onclick="getAStream($(this));return(false);" rel="nofollow" data-board="' . $context['current_board'] . '" href="' . $scripturl . '?action=astream;sa=get;all"><span>View recent activity</span></a>';
} else {
$astream_link = '<a onclick="getAStream($(this));return(false);" rel="nofollow" data-board="all" href="' . $scripturl . '?action=astream;sa=get;all"><span>View recent activity</span></a>';
}
if (($context['usermenu_buttons'] = CacheAPI::getCache('usermenu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $cacheTime)) === null || time() - $cacheTime <= $modSettings['settings_updated'] || URL::haveSID()) {
if (!$user_info['is_guest']) {
$context['usermenu_buttons']['profile'] = array('title' => $txt['your_profile'], 'href' => URL::parse('?action=profile'), 'sub_buttons' => array('forumprofile' => array('href' => URL::parse('?action=profile;area=forumprofile'), 'title' => $txt['forumprofile']), 'account' => array('href' => URL::parse('?action=profile;area=account'), 'title' => $txt['account'])));
$context['usermenu_buttons']['inbox'] = array('title' => $txt['inbox'], 'href' => URL::parse('?action=pm'), 'sub_buttons' => array('pm_send' => array('href' => URL::parse('?action=pm;sa=send'), 'title' => $txt['pm_menu_send'])));
}
$context['usermenu_buttons']['whatsnew'] = array('title' => $txt['whatsnew_menu'], 'href' => URL::parse('?action=whatsnew'));
if ($modSettings['astream_active']) {
$context['usermenu_buttons']['whatsnew']['sub_buttons']['getastream'] = array('title' => $txt['view_recent_activity'], 'link' => $astream_link);
}
if (!$user_info['is_guest']) {
$context['usermenu_buttons']['whatsnew']['sub_buttons']['unread'] = array('title' => $txt['unread_since_visit'], 'href' => URL::parse('?action=unread'));
$context['usermenu_buttons']['whatsnew']['sub_buttons']['unread_replies'] = array('title' => $txt['show_unread_replies'], 'href' => URL::parse('?action=unreadreplies'));
$context['usermenu_buttons']['whatsnew']['sub_buttons']['subscriptions'] = array('title' => $txt['show_my_subscriptions'], 'href' => URL::parse('?action=profile;area=notification'));
if ($modSettings['astream_active']) {
$context['usermenu_buttons']['notifications'] = array('title' => 'Your notifications', 'link' => '<a class="firstlevel compact" rel="nofollow" onclick="getNotifications($(this));return(false);" href="' . URL::parse($scripturl . '?action=astream;sa=notifications;view=all') . '">Your notifications</a>');
}
}
if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && !URL::haveSID()) {
CacheAPI::putCache('usermenu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $context['usermenu_buttons'], $cacheTime);
}
}
$context['menu_buttons'] = $menu_buttons;
if ($modSettings['astream_active']) {
$context['usermenu_buttons']['whatsnew']['sub_buttons']['getastream'] = array('title' => $txt['view_recent_activity'], 'link' => $astream_link);
}
// Allow editing menu buttons easily.
HookAPI::callHook('menu_buttons', array(&$context['menu_buttons'], &$context['usermenu_buttons']));
// Logging out requires the session id in the url.
if (isset($context['menu_buttons']['logout'])) {
$context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']);
}
// Figure out which action we are doing so we can set the active menu button in either the main or the user menu
// Default to home.
$current_action = 'home';
if (isset($context['menu_buttons'][$context['current_action']]) || isset($context['usermenu_buttons'][$context['current_action']])) {
$current_action = $context['current_action'];
} elseif ($context['current_action'] == 'search2') {
$current_action = 'search';
} elseif ($context['current_action'] == 'theme') {
$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';
} elseif ($context['current_action'] == 'register2') {
$current_action = 'register';
} elseif ($context['current_action'] == 'login2' || $user_info['is_guest'] && $context['current_action'] == 'reminder') {
$current_action = 'login';
} elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) {
//.........这里部分代码省略.........