本文整理汇总了PHP中Skin::getTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP Skin::getTitle方法的具体用法?PHP Skin::getTitle怎么用?PHP Skin::getTitle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Skin
的用法示例。
在下文中一共展示了Skin::getTitle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onSkinAfterBottomScripts
public static function onSkinAfterBottomScripts(Skin $skin, &$text)
{
global $wgWRGoogleSearchEnableSitelinksSearch, $wgWRGoogleSearchCSEID;
if (!$wgWRGoogleSearchEnableSitelinksSearch || empty($wgWRGoogleSearchCSEID) || !$skin->getTitle()->isMainPage()) {
return true;
}
$mainPageUrl = Title::newFromText(wfMessage('mainpage')->plain())->getFullURL();
$searchUrl = SpecialPage::getTitleFor('WRGoogleSearch')->getFullURL();
$sitelinksSearch = <<<HTML
\t<script type="application/ld+json">
\t\t{
\t\t\t"@context": "http://schema.org",
\t \t\t"@type": "WebSite",
\t\t\t"url": "{$mainPageUrl}",
\t\t\t"potentialAction": {
\t\t\t\t"@type": "SearchAction",
\t\t\t "target": "{$searchUrl}?q={search_term_string}",
\t\t\t "query-input": "required name=search_term_string"
\t \t\t}
\t\t}
\t</script>
HTML;
$text .= $sitelinksSearch;
return true;
}
示例2: hookAnalyticsInsideHead
/**
* @param Skin $skin
* @param string $text
* @return bool
*/
public static function hookAnalyticsInsideHead(OutputPage &$out, Skin &$skin, &$text = '')
{
global $wgGoogleAnalyticsAccount, $wgGoogleAnalyticsAnonymizeIP, $wgGoogleAnalyticsOtherCode, $wgGoogleAnalyticsIgnoreNsIDs, $wgGoogleAnalyticsIgnorePages, $wgGoogleAnalyticsIgnoreSpecials;
if ($skin->getUser()->isAllowed('noanalytics')) {
$text .= "<!-- Web analytics code inclusion is disabled for this user. -->\r\n";
return true;
}
if (count(array_filter($wgGoogleAnalyticsIgnoreSpecials, function ($v) use($skin) {
return $skin->getTitle()->isSpecial($v);
})) > 0 || in_array($skin->getTitle()->getNamespace(), $wgGoogleAnalyticsIgnoreNsIDs, true) || in_array($skin->getTitle()->getPrefixedText(), $wgGoogleAnalyticsIgnorePages, true)) {
$text .= "<!-- Web analytics code inclusion is disabled for this page. -->\r\n";
return true;
}
$appended = false;
if ($wgGoogleAnalyticsAccount !== '') {
$text .= <<<EOD
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '
EOD
. $wgGoogleAnalyticsAccount . <<<EOD
', 'auto');
EOD
. ($wgGoogleAnalyticsAnonymizeIP ? " ga('set', 'anonymizeIp', true);\r\n" : "") . <<<EOD
ga('send', 'pageview');
</script>
EOD;
$appended = true;
}
if ($wgGoogleAnalyticsOtherCode !== '') {
$text .= $wgGoogleAnalyticsOtherCode . "\r\n";
$appended = true;
}
if (!$appended) {
$text .= "<!-- No web analytics configured. -->\r\n";
}
$out->addHeadItem("analytics script", $text);
return true;
}
示例3: fnSetOutput
public static function fnSetOutput(OutputPage &$out, Skin &$skin)
{
global $wpdBundle;
$page_path = explode('/', $skin->getTitle());
for ($pp = 1; count($page_path) >= $pp; $pp++) {
$path_part = implode('/', array_slice($page_path, 0, $pp));
self::$menuhtml .= '<li data-comment="Not removing underscore here"><a href="' . $wpdBundle['root_uri'] . str_replace(' ', '_', $path_part) . '">' . str_replace('_', ' ', $page_path[$pp - 1]) . '</a></li>';
}
return true;
}
示例4: onSkinAfterBottomScripts
public static function onSkinAfterBottomScripts(Skin $skin, &$text)
{
$title = $skin->getTitle();
if (TemplateDraftHelper::allowedForTitle($title)) {
$scripts = AssetsManager::getInstance()->getURL('template_draft');
foreach ($scripts as $script) {
$text .= Html::linkedScript($script);
}
}
return true;
}
示例5: onBeforePageDisplay
/**
* @param OutputPage $oOut
* @param Skin $oSkin
* @return boolean
*/
public function onBeforePageDisplay(&$oOut, &$oSkin)
{
$oTitle = $oSkin->getTitle();
$aNamespaces = MWNamespace::getCanonicalNamespaces();
$iCurrentNs = $oTitle->getNamespace();
if ($oTitle->isTalkPage()) {
$iCurrentNs--;
}
if (!isset($aNamespaces[$iCurrentNs])) {
return true;
}
$oStyleSheetTitle = Title::newFromText($aNamespaces[$iCurrentNs] . '_css', NS_MEDIAWIKI);
if ($oStyleSheetTitle->exists()) {
$oOut->addStyle($oStyleSheetTitle->getLocalUrl(array('action' => 'raw', 'ctype' => 'text/css')));
}
return true;
}
示例6: onBeforePageDisplay
/**
* BeforePageDisplay hook handler
* @see https://www.mediawiki.org/wiki/Manual:Hooks/BeforePageDisplay
*
* @param OutputPage $out
* @param Skin $sk
* @return bool
*/
public static function onBeforePageDisplay(&$out, &$sk)
{
global $wgWPBSkinBlacklist, $wgWPBEnableDefaultBanner;
$context = MobileContext::singleton();
$config = $context->getMFConfig();
$mfEnableXAnalyticsLogging = $config->get('MFEnableXAnalyticsLogging');
$mfAppPackageId = $config->get('MFAppPackageId');
$mfAppScheme = $config->get('MFAppScheme');
$mfNoIndexPages = $config->get('MFNoindexPages');
$mfMobileUrlTemplate = $context->getMobileUrlTemplate();
$tabletSize = $config->get('MFDeviceWidthTablet');
// show banners using WikidataPageBanner, if installed and all pre-conditions fulfilled
if (ExtensionRegistry::getInstance()->isLoaded('WikidataPageBanner') && $context->isBetaGroupMember()) {
// turn default banners on
$wgWPBEnableDefaultBanner = true;
// Turn on the banner experiment
$needle = array_search('minerva', $wgWPBSkinBlacklist);
if ($needle !== false) {
unset($wgWPBSkinBlacklist[$needle]);
}
}
$title = $sk->getTitle();
$request = $context->getRequest();
// Migrate prefixed disableImages cookie to unprefixed cookie.
if (isset($_COOKIE[$config->get('CookiePrefix') . 'disableImages'])) {
if ((bool) $request->getCookie('disableImages')) {
$context->setDisableImagesCookie(true);
}
$request->response()->clearCookie('disableImages');
}
# Add deep link to a mobile app specified by $wgMFAppScheme
if ($mfAppPackageId !== false && $title->isContentPage() && $request->getRawQueryString() === '') {
$fullUrl = $title->getFullURL();
$mobileUrl = $context->getMobileUrl($fullUrl);
$path = preg_replace("/^([a-z]+:)?(\\/)*/", '', $mobileUrl, 1);
$scheme = 'http';
if ($mfAppScheme !== false) {
$scheme = $mfAppScheme;
} else {
$protocol = $request->getProtocol();
if ($protocol != '') {
$scheme = $protocol;
}
}
$hreflink = 'android-app://' . $mfAppPackageId . '/' . $scheme . '/' . $path;
$out->addLink(array('rel' => 'alternate', 'href' => $hreflink));
}
// an canonical/alternate link is only useful, if the mobile and desktop URL are different
// and $wgMFNoindexPages needs to be true
if ($mfMobileUrlTemplate && $mfNoIndexPages) {
if (!$context->shouldDisplayMobileView()) {
// add alternate link to desktop sites - bug T91183
$desktopUrl = $title->getFullUrl();
$link = array('rel' => 'alternate', 'media' => 'only screen and (max-width: ' . $tabletSize . 'px)', 'href' => $context->getMobileUrl($desktopUrl));
} else {
// add canonical link to mobile pages, instead of noindex - bug T91183
$link = array('rel' => 'canonical', 'href' => $title->getFullUrl());
}
$out->addLink($link);
}
// Set X-Analytics HTTP response header if necessary
if ($context->shouldDisplayMobileView()) {
$analyticsHeader = $mfEnableXAnalyticsLogging ? $context->getXAnalyticsHeader() : false;
if ($analyticsHeader) {
$resp = $out->getRequest()->response();
$resp->header($analyticsHeader);
}
// in mobile view: always add vary header
$out->addVaryHeader('Cookie');
// Allow modifications in mobile only mode
Hooks::run('BeforePageDisplayMobile', array(&$out, &$sk));
}
return true;
}
示例7: setViewTabs
/**
* Modify an array of tab links to include flagged revs UI elements
* @param string $type ('flat' for SkinTemplateTabs, 'nav' for SkinTemplateNavigation)
*/
public function setViewTabs(Skin $skin, array &$views, $type)
{
$this->load();
if (!FlaggedRevs::inReviewNamespace($this->article->getTitle())) {
return true;
// short-circuit for non-reviewable pages
}
# Hack for bug 16734 (some actions update and view all at once)
if ($this->pageWriteOpRequested() && wfGetDB(DB_MASTER)->doneWrites()) {
# Tabs need to reflect the new stable version so users actually
# see the results of their action (i.e. "delete"/"rollback")
$this->article->loadPageData('fromdbmaster');
}
$srev = $this->article->getStableRev();
if (!$srev) {
return true;
// No stable revision exists
}
$synced = $this->article->stableVersionIsSynced();
$pendingEdits = !$synced && $this->article->isStableShownByDefault();
// Set the edit tab names as needed...
if ($pendingEdits) {
if (isset($views['edit'])) {
$views['edit']['text'] = wfMsg('revreview-edit');
if ($this->showingStable()) {
// bug 31489; direct user to current
$views['edit']['href'] = $skin->getTitle()->getFullURL('action=edit');
}
}
if (isset($views['viewsource'])) {
$views['viewsource']['text'] = wfMsg('revreview-source');
if ($this->showingStable()) {
// bug 31489; direct user to current
$views['viewsource']['href'] = $skin->getTitle()->getFullURL('action=edit');
}
}
}
# Add "pending changes" tab if the page is not synced
if (!$synced) {
$this->addDraftTab($views, $srev, $type);
}
return true;
}
示例8: prepareFooter
/**
* Prepares the footer for the skins serving the desktop and mobile sites.
* @param Skin $skin
* @param QuickTemplate $tpl
*/
public static function prepareFooter($skin, $tpl)
{
$title = $skin->getTitle();
$req = $skin->getRequest();
$ctx = MobileContext::singleton();
// Certain pages might be blacklisted and not have a mobile equivalent.
if (!$ctx->isBlacklistedPage()) {
if ($ctx->shouldDisplayMobileView()) {
MobileFrontendSkinHooks::mobileFooter($skin, $tpl, $ctx, $title, $req);
} else {
MobileFrontendSkinHooks::desktopFooter($skin, $tpl, $ctx, $title, $req);
}
}
}
示例9: onBeforePageDisplay
/**
* BeforePageDisplay hook handler
* @see https://www.mediawiki.org/wiki/Manual:Hooks/BeforePageDisplay
*
* @param OutputPage $out
* @param Skin $sk
* @return bool
*/
public static function onBeforePageDisplay(&$out, &$sk)
{
$context = MobileContext::singleton();
$config = $context->getMFConfig();
$mfEnableXAnalyticsLogging = $config->get('MFEnableXAnalyticsLogging');
$mfAppPackageId = $config->get('MFAppPackageId');
$mfAppScheme = $config->get('MFAppScheme');
$mfNoIndexPages = $config->get('MFNoindexPages');
$mfMobileUrlTemplate = $context->getMobileUrlTemplate();
$tabletSize = $config->get('MFDeviceWidthTablet');
$title = $sk->getTitle();
$request = $context->getRequest();
# Add deep link to a mobile app specified by $wgMFAppScheme
if ($mfAppPackageId !== false && $title->isContentPage() && $request->getRawQueryString() === '') {
$fullUrl = $title->getFullURL();
$mobileUrl = $context->getMobileUrl($fullUrl);
$path = preg_replace("/^([a-z]+:)?(\\/)*/", '', $mobileUrl, 1);
$scheme = 'http';
if ($mfAppScheme !== false) {
$scheme = $mfAppScheme;
} else {
$protocol = $request->getProtocol();
if ($protocol != '') {
$scheme = $protocol;
}
}
$hreflink = 'android-app://' . $mfAppPackageId . '/' . $scheme . '/' . $path;
$out->addLink(array('rel' => 'alternate', 'href' => $hreflink));
}
// an canonical/alternate link is only useful, if the mobile and desktop URL are different
// and $wgMFNoindexPages needs to be true
if ($mfMobileUrlTemplate && $mfNoIndexPages) {
if (!$context->shouldDisplayMobileView()) {
// add alternate link to desktop sites - bug T91183
$desktopUrl = $title->getFullUrl();
$link = array('rel' => 'alternate', 'media' => 'only screen and (max-width: ' . $tabletSize . 'px)', 'href' => $context->getMobileUrl($desktopUrl));
} else {
// add canonical link to mobile pages, instead of noindex - bug T91183
$link = array('rel' => 'canonical', 'href' => $title->getFullUrl());
}
$out->addLink($link);
}
// Set X-Analytics HTTP response header if necessary
if ($context->shouldDisplayMobileView()) {
$analyticsHeader = $mfEnableXAnalyticsLogging ? $context->getXAnalyticsHeader() : false;
if ($analyticsHeader) {
$resp = $out->getRequest()->response();
$resp->header($analyticsHeader);
}
// in mobile view: always add vary header
$out->addVaryHeader('Cookie');
}
return true;
}
示例10: tabify
/**
* Adds the task-based tabs on Special:Translate and few other special pages.
* Hook: SkinTemplateNavigation::SpecialPage
* @since 2012-02-10
*/
static function tabify(Skin $skin, array &$tabs)
{
$title = $skin->getTitle();
list($alias, $sub) = SpecialPageFactory::resolveAlias($title->getText());
$pagesInGroup = array('Translate', 'LanguageStats', 'MessageGroupStats');
if (!in_array($alias, $pagesInGroup, true)) {
return true;
}
$skin->getOutput()->addModuleStyles('ext.translate.tabgroup');
// Extract subpage syntax, otherwise the values are not passed forward
$params = array();
if (trim($sub) !== '') {
if ($alias === 'Translate' || $alias === 'MessageGroupStats') {
$params['group'] = $sub;
} elseif ($alias === 'LanguageStats') {
// Breaks if additional parameters besides language are code provided
$params['language'] = $sub;
}
}
$request = $skin->getRequest();
// However, query string params take precedence
$params['language'] = $request->getVal('language');
$params['group'] = $request->getVal('group');
$taction = $request->getVal('taction', 'translate');
$translate = SpecialPage::getTitleFor('Translate');
$languagestats = SpecialPage::getTitleFor('LanguageStats');
$messagegroupstats = SpecialPage::getTitleFor('MessageGroupStats');
// Clear the special page tab that might be there already
$tabs['namespaces'] = array();
$tabs['namespaces']['translate'] = array('text' => wfMessage('translate-taction-translate')->text(), 'href' => $translate->getLocalUrl($params), 'class' => 'tux-tab');
if ($alias === 'Translate' && $taction === 'translate') {
$tabs['namespaces']['translate']['class'] .= ' selected';
}
if (!self::isBeta($request)) {
$tabs['namespaces']['proofread'] = array('text' => wfMessage('translate-taction-proofread')->text(), 'href' => $translate->getLocalUrl(array('taction' => 'proofread') + $params), 'class' => 'tux-tab');
if ($alias === 'Translate' && $taction === 'proofread') {
$tabs['namespaces']['proofread']['class'] .= ' selected';
}
}
$tabs['views']['lstats'] = array('text' => wfMessage('translate-taction-lstats')->text(), 'href' => $languagestats->getLocalUrl($params), 'class' => 'tux-tab');
if ($alias === 'LanguageStats') {
$tabs['views']['lstats']['class'] .= ' selected';
}
$tabs['views']['mstats'] = array('text' => wfMessage('translate-taction-mstats')->text(), 'href' => $messagegroupstats->getLocalUrl($params), 'class' => 'tux-tab');
if ($alias === 'MessageGroupStats') {
$tabs['views']['mstats']['class'] .= ' selected';
}
// Kind of hackish, but works for now
global $wgTranslateTasks;
foreach (array_keys($wgTranslateTasks) as $taskname) {
if (!preg_match('/^export-/', $taskname)) {
continue;
}
$tabs['views']['export'] = array('text' => wfMessage('translate-taction-export')->text(), 'href' => $translate->getLocalUrl(array('taction' => 'export') + $params), 'class' => 'tux-tab');
if ($alias === 'Translate' && $taction === 'export') {
$tabs['views']['export']['class'] .= ' selected';
}
// We only need the tab to apper once ;)
break;
}
return true;
}
示例11: translateTab
/**
* Converts the edit tab (if exists) for translation pages to translate tab.
* Hook: SkinTemplateNavigation
* @since 2013.06
*/
static function translateTab(Skin $skin, array &$tabs)
{
$title = $skin->getTitle();
$handle = new MessageHandle($title);
$code = $handle->getCode();
$page = TranslatablePage::isTranslationPage($title);
if (!$page) {
return true;
}
// The source language has a subpage too, but cannot be translated
if ($page->getSourceLanguageCode() === $code) {
return true;
}
if (isset($tabs['views']['edit'])) {
$tabs['views']['edit']['text'] = $skin->msg('tpt-tab-translate')->text();
$tabs['views']['edit']['href'] = $page->getTranslationUrl($code);
}
return true;
}
示例12: addNavigationTabs
/**
* Adds Promoter specific navigation tabs to the UI.
* Implementation of SkinTemplateNavigation::SpecialPage hook.
*
* @param Skin $skin Reference to the Skin object
* @param array $tabs Any current skin tabs
*
* @return boolean
*/
public static function addNavigationTabs(Skin $skin, array &$tabs)
{
global $wgPromoterTabifyPages;
$title = $skin->getTitle();
list($alias, $sub) = SpecialPageFactory::resolveAlias($title->getText());
if (!array_key_exists($alias, $wgPromoterTabifyPages)) {
return true;
}
// Clear the special page tab that's there already
//$tabs['namespaces'] = array();
// Now add our own
foreach ($wgPromoterTabifyPages as $page => $keys) {
$tabs[$keys['type']][$page] = array('text' => wfMessage($keys['message']), 'href' => SpecialPage::getTitleFor($page)->getFullURL(), 'class' => $alias === $page ? 'selected' : '');
}
return true;
}
示例13: tabify
/**
* Adds the task-based tabs on Special:Translate and few other special pages.
* Hook: SkinTemplateNavigation::SpecialPage
* @since 2012-05-14
*/
static function tabify(Skin $skin, array &$tabs)
{
$title = $skin->getTitle();
list($alias, ) = SpecialPageFactory::resolveAlias($title->getText());
$pagesInGroup = array('ManageMessageGroups' => 'namespaces', 'AggregateGroups' => 'namespaces', 'SupportedLanguages' => 'views', 'TranslationStats' => 'views');
if (!isset($pagesInGroup[$alias])) {
return true;
}
$skin->getOutput()->addModuleStyles('ext.translate.tabgroup');
$tabs['namespaces'] = array();
foreach ($pagesInGroup as $spName => $section) {
$spClass = SpecialPageFactory::getPage($spName);
if ($spClass === null) {
continue;
// Page explicitly disabled
}
$spTitle = $spClass->getPageTitle();
$tabs[$section][strtolower($spName)] = array('text' => $spClass->getDescription(), 'href' => $spTitle->getLocalUrl(), 'class' => $alias === $spName ? 'selected' : '');
}
return true;
}
示例14: onBeforePageDisplay
/**
*
* @param OutputPage $oOutputPage
* @param Skin $oSkin
*/
public function onBeforePageDisplay(&$oOutputPage, &$oSkin)
{
if (!$oSkin->getTitle()->equals(SpecialPage::getTitleFor('AdminDashboard')) && !$oSkin->getTitle()->equals(SpecialPage::getTitleFor('WikiAdmin')) && !$oSkin->getTitle()->equals(SpecialPage::getTitleFor('UserDashboard'))) {
return true;
}
$oOutputPage->addModules('ext.bluespice.statisticsPortlets');
return true;
}
示例15: execute
/**
* Template filter callback for MonoBook skin.
* Takes an associative array of data set from a SkinTemplate-based
* class, and a wrapper for MediaWiki's localization database, and
* outputs a formatted page.
*
* @access private
*/
function execute()
{
//uncomment for a quick data dump, since there's no documentation I can find that covers this...
//echo '<pre>'; print_r($this->data); exit;
global $wgLang;
$this->skin = $this->data['skin'];
// Suppress warnings to prevent notices about missing indexes in $this->data
wfSuppressWarnings();
// Build additional attributes for navigation urls
//$nav = $this->skin->buildNavigationUrls();
$nav = $this->data['content_navigation'];
if ($wgVectorUseIconWatch) {
$mode = $this->skin->getTitle()->userIsWatching() ? 'unwatch' : 'watch';
if (isset($nav['actions'][$mode])) {
$nav['views'][$mode] = $nav['actions'][$mode];
$nav['views'][$mode]['class'] = rtrim('icon ' . $nav['views'][$mode]['class'], ' ');
$nav['views'][$mode]['primary'] = true;
unset($nav['actions'][$mode]);
}
}
$xmlID = '';
foreach ($nav as $section => $links) {
foreach ($links as $key => $link) {
if ($section == 'views' && !(isset($link['primary']) && $link['primary'])) {
$link['class'] = rtrim('collapsible ' . $link['class'], ' ');
}
$xmlID = isset($link['id']) ? $link['id'] : 'ca-' . $xmlID;
$nav[$section][$key]['attributes'] = ' id="' . Sanitizer::escapeId($xmlID) . '"';
if ($link['class']) {
$nav[$section][$key]['attributes'] .= ' class="' . htmlspecialchars($link['class']) . '"';
unset($nav[$section][$key]['class']);
}
if (isset($link['tooltiponly']) && $link['tooltiponly']) {
$nav[$section][$key]['key'] = Linker::tooltip($xmlID);
} else {
$nav[$section][$key]['key'] = Xml::expandAttributes(Linker::tooltipAndAccesskeyAttribs($xmlID));
}
}
}
$this->data['namespace_urls'] = $nav['namespaces'];
$this->data['view_urls'] = $nav['views'];
$this->data['action_urls'] = $nav['actions'];
$this->data['variant_urls'] = $nav['variants'];
foreach ($this->data['content_navigation']['namespaces'] as $ns) {
if ($ns['class'] == 'selected') {
$current_context = $ns['context'];
}
}
//print_r($this->data['content_navigation']); exit;
// Reverse horizontally rendered navigation elements
/*if ( $wgLang->isRTL() ) {
$this->data['view_urls'] =
array_reverse( $this->data['view_urls'] );
$this->data['namespace_urls'] =
array_reverse( $this->data['namespace_urls'] );
$this->data['personal_urls'] =
array_reverse( $this->data['personal_urls'] );
}*/
require_once realpath(__DIR__ . '/../../../library') . '/Masthead.php';
$masthead = new PracticalPlants_Masthead(array('active_tab' => 'wiki'));
?>
<!DOCTYPE html>
<!--
<?php
/*print_r($this->content);
print_r($_GET);
/*print_r($this->data);*/
?>
-->
<html lang="en" dir="ltr" class="client-nojs">
<head>
<title><?php
echo $this->data['pagetitle'];
?>
</title>
<meta charset="UTF-8" />
<?php
echo $this->data['headlinks'];
?>
<?php
echo $this->data['csslinks'];
?>
<?php
echo $this->data['pagecss'];
?>
<?php
echo $this->data['usercss'];
?>
<?php
echo $this->data['jsvarurl'];
?>
//.........这里部分代码省略.........