本文整理汇总了PHP中KunenaTemplate类的典型用法代码示例。如果您正苦于以下问题:PHP KunenaTemplate类的具体用法?PHP KunenaTemplate怎么用?PHP KunenaTemplate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KunenaTemplate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: displayEdit
function displayEdit()
{
$this->setToolBarEdit();
// FIXME: enable template parameters
$this->form = $this->get('Form');
$this->params = $this->get('editparams');
$this->details = $this->get('templatedetails');
$this->templatename = $this->app->getUserState('kunena.edit.template');
$template = KunenaTemplate::getInstance($this->templatename);
$template->initializeBackend();
$this->templatefile = KPATH_SITE . '/template/' . $this->templatename . '/params.ini';
if (!JFile::exists($this->templatefile))
{
$ourFileHandle = @fopen($this->templatefile, 'w');
if ($ourFileHandle)
{
fclose($ourFileHandle);
}
}
$this->display();
}
示例2: loadFormData
/**
* @see JModelForm::loadFormData()
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = JFactory::getApplication()->getUserState('com_kunena.edit.template.data', array());
if (empty($data)) {
$template = $this->getState('template');
$data = KunenaTemplate::getInstance($template)->params->toArray();
}
return $data;
}
示例3: displayEdit
function displayEdit()
{
$this->setToolBarEdit();
$this->params = $this->get('editparams');
$this->details = $this->get('templatedetails');
$this->templatename = $this->app->getUserState('kunena.edit.template');
$template = KunenaTemplate::getInstance($this->templatename);
$template->initializeBackend();
$this->display();
}
示例4: before
/**
* Prepare topic moderate display.
*
* @return void
*
* @throws KunenaExceptionAuthorise
*/
protected function before()
{
parent::before();
$catid = $this->input->getInt('catid');
$id = $this->input->getInt('id');
$mesid = $this->input->getInt('mesid');
if (!$mesid) {
$this->topic = KunenaForumTopicHelper::get($id);
$this->topic->tryAuthorise('move');
} else {
$this->message = KunenaForumMessageHelper::get($mesid);
$this->message->tryAuthorise('move');
$this->topic = $this->message->getTopic();
}
$this->category = $this->topic->getCategory();
$this->uri = "index.php?option=com_kunena&view=topic&layout=moderate" . "&catid={$this->category->id}&id={$this->topic->id}" . ($this->message ? "&mesid={$this->message->id}" : '');
$this->title = !$this->message ? JText::_('COM_KUNENA_TITLE_MODERATE_TOPIC') : JText::_('COM_KUNENA_TITLE_MODERATE_MESSAGE');
// Load topic icons if available.
if ($this->config->topicicons) {
$this->template = KunenaTemplate::getInstance();
$this->template->setCategoryIconset();
$this->topicIcons = $this->template->getTopicIcons(false);
}
// Have a link to moderate user as well.
if (isset($this->message)) {
$user = $this->message->getAuthor();
if ($user->exists()) {
$username = $user->getName();
$this->userLink = $this->message->userid ? JHtml::_('kunenaforum.link', 'index.php?option=com_kunena&view=user&layout=moderate&userid=' . $this->message->userid, $username . ' (' . $this->message->userid . ')', $username . ' (' . $this->message->userid . ')') : null;
}
}
if ($this->message) {
$this->banHistory = KunenaUserBan::getUserHistory($this->message->userid);
$this->me = KunenaFactory::getUser();
// Get thread and reply count from current message:
$db = JFactory::getDbo();
$query = "SELECT COUNT(mm.id) AS replies FROM #__kunena_messages AS m\r\n\t\t\t\tINNER JOIN #__kunena_messages AS t ON m.thread=t.id\r\n\t\t\t\tLEFT JOIN #__kunena_messages AS mm ON mm.thread=m.thread AND mm.time > m.time\r\n\t\t\t\tWHERE m.id={$db->Quote($this->message->id)}";
$db->setQuery($query, 0, 1);
$this->replies = $db->loadResult();
if (KunenaError::checkDatabaseError()) {
return;
}
}
$this->banInfo = KunenaUserBan::getInstanceByUserid(JFactory::getUser()->id, true);
}
示例5: initialize
public function initialize($identifier ='class') {
$js = "window.addEvent('domready', function() {
kbbcode = new kbbcode('kbbcode-message', 'kbbcode-toolbar', {
dispatchChangeEvent: true,
changeEventDelay: 1000,
interceptTab: true
});\n";
$editor = simplexml_load_file(dirname(__FILE__).'/editor.xml');
foreach ($editor as $item) {
if ($item['disabled'] == 'disabled') continue;
switch ($item->getName()) {
case 'button':
// <button tag="i" name="italic" title="COM_KUNENA_EDITOR_ITALIC" alt="COM_KUNENA_EDITOR_HELPLINE_ITALIC">
if ($item['config']) {
$cfgVariable = (string) $item['config'];
$cfgValue = intval($cfgVariable[0] != '!');
if (!$cfgValue) $cfgVariable = substr($cfgVariable, 1);
if (KunenaFactory::getConfig()->$cfgVariable != $cfgValue) continue;
}
$name = $item['name'] ? $item['name'] : ($item['tag'] ? $item['tag'] : '#');
$class = $item['class'] ? $item['class'] : "kbbcode-{$name}-button";
$js .= "\nkbbcode.addFunction('{$name}', function() {";
$js .= $this->editorAction($name, $item);
$js .= "\n}, {";
foreach (array('title', 'alt') as $type) {
if (isset($item[$type])) {
$value = JText::_($item[$type], true);
$js .= "\n '{$type}': '{$value}',";
}
}
if ($item['class']) {
$js .= "\n 'class': '{$class}'";
} else {
$js .= "\n '{$identifier}': '{$class}'";
}
$js .= "\n});\n";
break;
}
}
$js .= "});\n";
$template = KunenaTemplate::getInstance();
$template->addScript('js/editor.js');
JFactory::getDocument()->addScriptDeclaration( "// <![CDATA[\n{$js}\n// ]]>");
}
示例6: displayDefault
function displayDefault($tpl = null) {
$this->config = KunenaFactory::getConfig();
if (!$this->config->enablerss) {
JError::raiseError ( 404, JText::_ ( 'COM_KUNENA_RSS_DISABLED' ) );
}
$this->assignRef ( 'category', $this->get ( 'Category' ) );
if (! $this->category->authorise('read')) {
JError::raiseError ( 404, $this->category->getError() );
}
$this->template = KunenaTemplate::getInstance();
$this->assignRef ( 'topics', $this->get ( 'Topics' ) );
$title = JText::_('COM_KUNENA_THREADS_IN_FORUM').': '. $this->category->name;
$this->setTitle ( $title );
$metaDesc = $this->document->get ( 'description' ) . '. ' . $this->escape ( "{$this->category->name} - {$this->config->board_title}" );
$this->document->setDescription ( $metaDesc );
// Create image for feed
$image = new JFeedImage();
$image->title = $this->document->getTitle();
$image->url = $this->template->getImagePath('icons/rss.png');
$image->description = $this->document->getDescription();
$this->document->image = $image;
foreach ( $this->topics as $topic ) {
$id = $topic->last_post_id;
$page = ceil ( $topic->posts / $this->config->messages_per_page );
$description = $topic->last_post_message;
$date = new JDate($topic->last_post_time);
$userid = $topic->last_post_userid;
$username = KunenaFactory::getUser($userid)->getName($topic->last_post_guest_name);
$title = $topic->subject;
$url = CKunenaLink::GetThreadPageURL('view', $topic->category_id, $topic->id, $page, $this->config->messages_per_page, $id, true );
$category = $topic->getCategory()->name;
$this->createItem($title, $url, $description, $category, $date, $userid, $username);
}
}
示例7: getRank
//.........这里部分代码省略.........
self::$_ranks = $this->_db->loadObjectList('rank_id');
KunenaError::checkDatabaseError();
}
$userType = $special !== false ? $this->getType($catid, true) : 'count';
if (isset(self::$_ranks[$this->rank]) && !in_array($userType, array('guest', 'blocked', 'banned', 'count'))) {
// Use rank specified to the user.
$rank = self::$_ranks[$this->rank];
} else {
// Generate user rank.
$rank = new stdClass();
$rank->rank_id = 0;
$rank->rank_title = JText::_('COM_KUNENA_RANK_USER');
$rank->rank_min = 0;
$rank->rank_special = 0;
$rank->rank_image = 'rank0.gif';
switch ($userType) {
case 'guest':
$rank->rank_title = JText::_('COM_KUNENA_RANK_VISITOR');
$rank->rank_special = 1;
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 1 && strstr($cur->rank_image, 'guest')) {
$rank = $cur;
break;
}
}
break;
case 'blocked':
$rank->rank_title = JText::_('COM_KUNENA_RANK_BLOCKED');
$rank->rank_special = 1;
$rank->rank_image = 'rankdisabled.gif';
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 1 && strstr($cur->rank_image, 'disabled')) {
$rank = $cur;
break;
}
}
break;
case 'banned':
$rank->rank_title = JText::_('COM_KUNENA_RANK_BANNED');
$rank->rank_special = 1;
$rank->rank_image = 'rankbanned.gif';
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 1 && strstr($cur->rank_image, 'banned')) {
$rank = $cur;
break;
}
}
break;
case 'admin':
case 'localadmin':
$rank->rank_title = JText::_('COM_KUNENA_RANK_ADMINISTRATOR');
$rank->rank_special = 1;
$rank->rank_image = 'rankadmin.gif';
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 1 && strstr($cur->rank_image, 'admin')) {
$rank = $cur;
break;
}
}
break;
case 'globalmod':
case 'moderator':
$rank->rank_title = JText::_('COM_KUNENA_RANK_MODERATOR');
$rank->rank_special = 1;
$rank->rank_image = 'rankmod.gif';
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 1 && (strstr($cur->rank_image, 'rankmod') || strstr($cur->rank_image, 'moderator'))) {
$rank = $cur;
break;
}
}
break;
case 'user':
case 'count':
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 0 && $cur->rank_min <= $this->posts && $cur->rank_min >= $rank->rank_min) {
$rank = $cur;
}
}
break;
}
}
if ($special === true && !$rank->rank_special) {
return null;
}
if ($type == 'title') {
return $rank->rank_title;
}
if (!$config->rankimages) {
$rank->rank_image = null;
}
if ($type == 'image') {
if (!$rank->rank_image) {
return null;
}
$url = KunenaTemplate::getInstance()->getRankPath($rank->rank_image, true);
return '<img src="' . $url . '" alt="" />';
}
return $rank;
}
示例8: getTemplate
/**
* Get a Kunena template object
*
* Returns the global {@link KunenaTemplate} object, only creating it if it doesn't already exist.
*
* @param string $name
* @return KunenaTemplate
*/
public static function getTemplate($name = null) {
return KunenaTemplate::getInstance($name);
}
示例9: getUserRank
/**
* @param UserTable $user
* @param bool $showTitle
* @param bool $showImage
* @return string|null
*/
public static function getUserRank($user, $showTitle = true, $showImage = true)
{
global $_CB_framework;
if (!class_exists('KunenaUser')) {
return null;
}
$value = null;
if ($user->get('id')) {
$forumUser = KunenaUser::getInstance((int) $user->get('id'));
if ($forumUser) {
$userRank = $forumUser->getRank();
if (!$userRank) {
return null;
}
$title = $userRank->rank_title;
if ($showTitle) {
$value .= '<div>' . $title . '</div>';
}
if ($showImage && class_exists('KunenaTemplate')) {
$template = KunenaTemplate::getInstance();
$value .= '<div><img src="' . $_CB_framework->getCfg('live_site') . '/' . $template->getRankPath($userRank->rank_image) . '" alt="' . htmlspecialchars($title) . '" border="0" /></div>';
}
if (!$value) {
$value = $forumUser->rank;
}
}
}
return $value;
}
示例10: displayPosts
function displayPosts($tpl = null) {
$this->config = KunenaFactory::getConfig();
if (!$this->config->enablerss) {
JError::raiseError ( 404, JText::_ ( 'COM_KUNENA_RSS_DISABLED' ) );
}
$this->layout = 'posts';
$this->assignRef ( 'messages', $this->get ( 'Messages' ) );
$this->assignRef ( 'topics', $this->get ( 'Topics' ) );
$this->assignRef ( 'total', $this->get ( 'Total' ) );
$this->me = KunenaUserHelper::getMyself();
$this->template = KunenaTemplate::getInstance();
// TODO: if start != 0, add information from it into description
$title = JText::_('COM_KUNENA_ALL_DISCUSSIONS');
$this->document->setGenerator('Kunena Forum (Joomla)');
switch ($this->state->get ( 'list.mode' )) {
case 'unapproved':
$title = JText::_('COM_KUNENA_VIEW_TOPICS_POSTS_MODE_UNAPPROVED');
break;
case 'deleted':
$title = JText::_('COM_KUNENA_VIEW_TOPICS_POSTS_MODE_DELETED');
break;
case 'mythanks':
$title = JText::_('COM_KUNENA_VIEW_TOPICS_POSTS_MODE_MYTHANKS');
break;
case 'thankyou':
$title = JText::_('COM_KUNENA_VIEW_TOPICS_POSTS_MODE_THANKYOU');
break;
case 'recent':
default:
$title = JText::_('COM_KUNENA_VIEW_TOPICS_POSTS_MODE_DEFAULT');
}
$this->setTitle ( $title );
// Create image for feed
$image = new JFeedImage();
$image->title = $this->document->getTitle();
$image->url = $this->template->getImagePath('icons/rss.png');
$image->description = $this->document->getDescription();
$this->document->image = $image;
$this->displayPostRows();
}
示例11: initialize
/**
* @param string $identifier
*/
public function initialize($identifier = 'class')
{
$js = "window.addEvent('domready', function() {\n\tkbbcode = new kbbcode('kbbcode-message', 'kbbcode-toolbar', {\n\t\tdispatchChangeEvent: true,\n\t\tchangeEventDelay: 1000,\n\t\tinterceptTab: true\n});\n";
$xml_file = simplexml_load_file(dirname(__FILE__) . '/editor.xml');
$this->editor_elements = self::parseXML($xml_file);
//Hook to manipulate the Editor XML like adding buttons
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('kunena');
$dispatcher->trigger('onKunenaBbcodeEditorInit', array($this));
foreach ($this->editor_elements as $item) {
$js .= $item->generateJs($identifier);
}
$js .= "});\n";
$template = KunenaTemplate::getInstance();
$template->addScript('js/editor.js');
JFactory::getDocument()->addScriptDeclaration("// <![CDATA[\n{$js}\n// ]]>");
}
示例12: getTemplate
/**
* Get a Kunena template object
*
* Returns the global {@link KunenaTemplate} object, only creating it if it doesn't already exist.
*
* @return object KunenaTemplate
*/
public static function getTemplate($name = null)
{
kimport('kunena.template');
return KunenaTemplate::getInstance($name);
}
示例13: behavior
static function behavior() {
static $loaded = false;
if (!$loaded)
{
JHTML::_('behavior.tooltip');
KunenaTemplate::getInstance()->addScript ( 'js/grid.js' );
// Build the behavior script.
$js = '
window.addEvent(\'domready\', function(){
actions = $$(\'a.move_up\');
actions.combine($$(\'a.move_down\'));
actions.combine($$(\'a.grid_true\'));
actions.combine($$(\'a.grid_false\'));
actions.combine($$(\'a.grid_trash\'));
actions.combine($$(\'a.grid_action\'));
actions.each(function(a){
a.addEvent(\'click\', function(){
args = JSON.decode(this.rel);
listItemTask(args.id, args.task);
});
});
$$(\'input.check-all-toggle\').each(function(el){
el.addEvent(\'click\', function(){
if (el.checked) {
document.id(this.form).getElements(\'input[type=checkbox]\').each(function(i){
i.checked = true;
})
}
else {
document.id(this.form).getElements(\'input[type=checkbox]\').each(function(i){
i.checked = false;
})
}
});
});
});';
// Add the behavior to the document head.
$document = JFactory::getDocument();
$document->addScriptDeclaration($js);
$loaded = true;
}
}
示例14: getRank
/**
* @param int $catid
* @param bool $type
*
* @return stdClass|string
*/
public function getRank($catid = 0, $type = false)
{
// Default rank
$rank = new stdClass();
$rank->rank_id = false;
$rank->rank_title = null;
$rank->rank_min = 0;
$rank->rank_special = 0;
$rank->rank_image = null;
$config = KunenaFactory::getConfig();
$category = KunenaForumCategoryHelper::get($catid);
if (!$config->showranking) {
return;
}
if (self::$_ranks === null) {
$this->_db->setQuery("SELECT * FROM #__kunena_ranks");
self::$_ranks = $this->_db->loadObjectList('rank_id');
KunenaError::checkDatabaseError();
}
$rank->rank_title = JText::_('COM_KUNENA_RANK_USER');
$rank->rank_image = 'rank0.gif';
if ($this->userid == 0) {
$rank->rank_id = 0;
$rank->rank_title = JText::_('COM_KUNENA_RANK_VISITOR');
$rank->rank_special = 1;
} else {
if ($this->isBanned()) {
$rank->rank_id = 0;
$rank->rank_title = JText::_('COM_KUNENA_RANK_BANNED');
$rank->rank_special = 1;
$rank->rank_image = 'rankbanned.gif';
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 1 && JFile::stripExt($cur->rank_image) == 'rankbanned') {
$rank = $cur;
break;
}
}
} else {
if ($this->rank != 0 && isset(self::$_ranks[$this->rank])) {
$rank = self::$_ranks[$this->rank];
} else {
if ($this->rank == 0 && $this->isAdmin($category)) {
$rank->rank_id = 0;
$rank->rank_title = JText::_('COM_KUNENA_RANK_ADMINISTRATOR');
$rank->rank_special = 1;
$rank->rank_image = 'rankadmin.gif';
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 1 && JFile::stripExt($cur->rank_image) == 'rankadmin') {
$rank = $cur;
break;
}
}
} else {
if ($this->rank == 0 && $this->isModerator($category)) {
$rank->rank_id = 0;
$rank->rank_title = JText::_('COM_KUNENA_RANK_MODERATOR');
$rank->rank_special = 1;
$rank->rank_image = 'rankmod.gif';
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 1 && JFile::stripExt($cur->rank_image) == 'rankmod') {
$rank = $cur;
break;
}
}
}
}
}
}
}
if ($rank->rank_id === false) {
//post count rank
$rank->rank_id = 0;
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 0 && $cur->rank_min <= $this->posts && $cur->rank_min >= $rank->rank_min) {
$rank = $cur;
}
}
}
if ($type == 'title') {
return $rank->rank_title;
}
if ($type == 'image') {
$template = KunenaTemplate::getInstance();
if (!$config->rankimages) {
return;
}
$iconurl = $template->getRankPath($rank->rank_image, true);
return '<img src="' . $iconurl . '" alt="" />';
}
if (!$config->rankimages) {
$rank->rank_image = null;
}
return $rank;
}
示例15: report
function report()
{
if (!JSession::checkToken('post')) {
$this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
$this->setRedirectBack();
return;
}
if (!$this->me->exists() || $this->config->reportmsg == 0) {
// Deny access if report feature has been disabled or user is guest
$this->app->enqueueMessage(JText::_('COM_KUNENA_NO_ACCESS'), 'notice');
$this->setRedirectBack();
return;
}
if (!$this->config->get('send_emails')) {
// Emails have been disabled
$this->app->enqueueMessage(JText::_('COM_KUNENA_EMAIL_DISABLED'), 'notice');
$this->setRedirectBack();
return;
}
if (!$this->config->getEmail() || !JMailHelper::isEmailAddress($this->config->getEmail())) {
// Error: email address is invalid
$this->app->enqueueMessage(JText::_('COM_KUNENA_EMAIL_INVALID'), 'error');
$this->setRedirectBack();
return;
}
// Get target object for the report
if ($this->mesid) {
$message = $target = KunenaForumMessageHelper::get($this->mesid);
$topic = $target->getTopic();
} else {
$topic = $target = KunenaForumTopicHelper::get($this->id);
$message = KunenaForumMessageHelper::get($topic->first_post_id);
}
$messagetext = $message->message;
$baduser = KunenaFactory::getUser($message->userid);
if (!$target->authorise('read')) {
// Deny access if user cannot read target
$this->app->enqueueMessage($target->getError(), 'notice');
$this->setRedirectBack();
return;
}
$reason = JRequest::getString('reason');
$text = JRequest::getString('text');
$template = KunenaTemplate::getInstance();
if (method_exists($template, 'reportMessage')) {
$template->reportMessage($message, $reason, $text);
}
// Load language file from the template.
KunenaFactory::getTemplate()->loadLanguage();
if (empty($reason) && empty($text)) {
// Do nothing: empty subject or reason is empty
$this->app->enqueueMessage(JText::_('COM_KUNENA_REPORT_FORG0T_SUB_MES'));
$this->setRedirectBack();
return;
} else {
$acl = KunenaAccess::getInstance();
$emailToList = $acl->getSubscribers($topic->category_id, $topic->id, false, true, false);
if (!empty($emailToList)) {
$mailsender = JMailHelper::cleanAddress($this->config->board_title . ' ' . JText::_('COM_KUNENA_FORUM') . ': ' . $this->me->getName());
$mailsubject = "[" . $this->config->board_title . " " . JText::_('COM_KUNENA_FORUM') . "] " . JText::_('COM_KUNENA_REPORT_MSG') . ": ";
if ($reason) {
$mailsubject .= $reason;
} else {
$mailsubject .= $topic->subject;
}
jimport('joomla.environment.uri');
$msglink = JUri::getInstance()->toString(array('scheme', 'host', 'port')) . $target->getPermaUrl(null, false);
$mail = JFactory::getMailer();
$mail->setSender(array($this->me->username, $this->me->email));
$mail->setSubject($mailsubject);
// Render the email.
$layout = KunenaLayout::factory('Email/Report')->debug(false)->set('mail', $mail)->set('message', $message)->set('me', $this->me)->set('title', $reason)->set('content', $text)->set('messageLink', $msglink);
try {
$body = trim($layout->render());
$mail->setBody($body);
} catch (Exception $e) {
// TODO: Deprecated in K4.0, remove in K5.0
$mailmessage = "" . JText::_('COM_KUNENA_REPORT_RSENDER') . " {$this->me->username} ({$this->me->name})";
$mailmessage .= "\n";
$mailmessage .= "" . JText::_('COM_KUNENA_REPORT_RREASON') . " " . $reason;
$mailmessage .= "\n";
$mailmessage .= "" . JText::_('COM_KUNENA_REPORT_RMESSAGE') . " " . $text;
$mailmessage .= "\n\n";
$mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_POSTER') . " {$baduser->username} ({$baduser->name})";
$mailmessage .= "\n";
$mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_SUBJECT') . ": " . $topic->subject;
$mailmessage .= "\n";
$mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_MESSAGE') . "\n-----\n" . KunenaHtmlParser::stripBBCode($messagetext, 0, false);
$mailmessage .= "\n-----\n\n";
$mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_LINK') . " " . $msglink;
$mailmessage = JMailHelper::cleanBody(strtr($mailmessage, array(' ' => '')));
$mail->setBody($mailmessage);
}
$receivers = array();
foreach ($emailToList as $emailTo) {
if (!$emailTo->email || !JMailHelper::isEmailAddress($emailTo->email)) {
continue;
}
$receivers[] = $emailTo->email;
}
//.........这里部分代码省略.........