当前位置: 首页>>代码示例>>PHP>>正文


PHP StringUtil::deserialize方法代码示例

本文整理汇总了PHP中Contao\StringUtil::deserialize方法的典型用法代码示例。如果您正苦于以下问题:PHP StringUtil::deserialize方法的具体用法?PHP StringUtil::deserialize怎么用?PHP StringUtil::deserialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Contao\StringUtil的用法示例。


在下文中一共展示了StringUtil::deserialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generate

 /**
  * Display a wildcard in the back end
  *
  * @return string
  */
 public function generate()
 {
     if (TL_MODE == 'BE') {
         /** @var BackendTemplate|object $objTemplate */
         $objTemplate = new \BackendTemplate('be_wildcard');
         $objTemplate->wildcard = '### ' . Utf8::strtoupper($GLOBALS['TL_LANG']['FMD']['newsletterreader'][0]) . ' ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;
         return $objTemplate->parse();
     }
     // Set the item from the auto_item parameter
     if (!isset($_GET['items']) && \Config::get('useAutoItem') && isset($_GET['auto_item'])) {
         \Input::setGet('items', \Input::get('auto_item'));
     }
     // Do not index or cache the page if no news item has been specified
     if (!\Input::get('items')) {
         /** @var PageModel $objPage */
         global $objPage;
         $objPage->noSearch = 1;
         $objPage->cache = 0;
         return '';
     }
     $this->nl_channels = \StringUtil::deserialize($this->nl_channels);
     // Do not index or cache the page if there are no channels
     if (!is_array($this->nl_channels) || empty($this->nl_channels)) {
         /** @var PageModel $objPage */
         global $objPage;
         $objPage->noSearch = 1;
         $objPage->cache = 0;
         return '';
     }
     return parent::generate();
 }
开发者ID:contao,项目名称:newsletter-bundle,代码行数:40,代码来源:ModuleNewsletterReader.php

示例2: split_and_fix

 public function split_and_fix($size, $scss, $grid, $width, $paddingTop, $paddingBottom, $default)
 {
     if ($size == 'XS') {
         $grid = '90';
         $unitGrid = '%';
         $width = '90';
         $unitWidth = '%';
     } else {
         $gridvar = is_array($grid) ? $grid : \Contao\StringUtil::deserialize($grid);
         $widthvar = is_array($width) ? $width : \Contao\StringUtil::deserialize($width);
         $paddingTopvar = is_array($paddingTop) ? $paddingTop : \Contao\StringUtil::deserialize($paddingTop);
         $paddingBottomvar = is_array($paddingBottom) ? $paddingBottom : \Contao\StringUtil::deserialize($paddingBottom);
         $grid = empty($gridvar['value']) ? $default['Grid'][$size] : $gridvar['value'];
         $unitGrid = empty($gridvar['unit']) ? $default['GridUnit'][$size] : $gridvar['unit'];
         $width = empty($widthvar['value']) ? $default['Width'][$size] : $widthvar['value'];
         $unitWidth = empty($widthvar['unit']) ? $default['WidthUnit'][$size] : $widthvar['unit'];
     }
     $paddingTop = empty($paddingTopvar['value']) ? $default['PaddingTop'][$size] : $paddingTopvar['value'];
     $unitPadingTop = empty($paddingTopvar['unit']) ? $default['PaddingTopUnit'][$size] : $paddingTopvar['unit'];
     $paddingBottom = empty($paddingBottomvar['value']) ? $default['PaddingBottom'][$size] : $paddingBottomvar['value'];
     $unitPadingBottom = empty($paddingBottomvar['unit']) ? $default['PaddingBottomUnit'][$size] : $paddingBottomvar['unit'];
     $grid1 = (int) $grid - 1;
     $scss = str_replace('[[grid' . $size . ']]', $grid . $unitGrid, $scss);
     $scss = str_replace('[[grid' . $size . '1]]', $grid1 . $unitGrid, $scss);
     $scss = str_replace('[[width' . $size . ']]', $width . $unitWidth, $scss);
     $scss = str_replace('[[paddingTop' . $size . ']]', $paddingTop . $unitPadingTop, $scss);
     $scss = str_replace('[[paddingBottom' . $size . ']]', $paddingBottom . $unitPadingBottom, $scss);
     return $scss;
 }
开发者ID:christianromeni,项目名称:c-customarticles,代码行数:29,代码来源:SCSSGenerator.php

示例3: generate

 /**
  * Do not show the module if no calendar has been selected
  *
  * @return string
  */
 public function generate()
 {
     if (TL_MODE == 'BE') {
         /** @var BackendTemplate|object $objTemplate */
         $objTemplate = new \BackendTemplate('be_wildcard');
         $objTemplate->wildcard = '### ' . Utf8::strtoupper($GLOBALS['TL_LANG']['FMD']['calendar'][0]) . ' ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;
         return $objTemplate->parse();
     }
     $this->cal_calendar = $this->sortOutProtected(\StringUtil::deserialize($this->cal_calendar, true));
     // Return if there are no calendars
     if (!is_array($this->cal_calendar) || empty($this->cal_calendar)) {
         return '';
     }
     $this->strUrl = preg_replace('/\\?.*$/', '', \Environment::get('request'));
     $this->strLink = $this->strUrl;
     if ($this->jumpTo && ($objTarget = $this->objModel->getRelated('jumpTo')) instanceof PageModel) {
         /** @var PageModel $objTarget */
         $this->strLink = $objTarget->getFrontendUrl();
     }
     return parent::generate();
 }
开发者ID:contao,项目名称:calendar-bundle,代码行数:30,代码来源:ModuleCalendar.php

示例4: generate

 /**
  * Display a wildcard in the back end
  *
  * @return string
  */
 public function generate()
 {
     if (TL_MODE == 'BE') {
         /** @var BackendTemplate|object $objTemplate */
         $objTemplate = new \BackendTemplate('be_wildcard');
         $objTemplate->wildcard = '### ' . Utf8::strtoupper($GLOBALS['TL_LANG']['FMD']['newsarchive'][0]) . ' ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;
         return $objTemplate->parse();
     }
     $this->news_archives = $this->sortOutProtected(\StringUtil::deserialize($this->news_archives));
     // No news archives available
     if (!is_array($this->news_archives) || empty($this->news_archives)) {
         return '';
     }
     // Show the news reader if an item has been selected
     if ($this->news_readerModule > 0 && (isset($_GET['items']) || \Config::get('useAutoItem') && isset($_GET['auto_item']))) {
         return $this->getFrontendModule($this->news_readerModule, $this->strColumn);
     }
     // Hide the module if no period has been selected
     if ($this->news_jumpToCurrent == 'hide_module' && !isset($_GET['year']) && !isset($_GET['month']) && !isset($_GET['day'])) {
         return '';
     }
     return parent::generate();
 }
开发者ID:contao,项目名称:news-bundle,代码行数:32,代码来源:ModuleNewsArchive.php

示例5: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     /** @var PageModel $objPage */
     global $objPage;
     if (!strlen($this->inColumn)) {
         $this->inColumn = 'main';
     }
     $intCount = 0;
     $articles = array();
     $id = $objPage->id;
     $this->Template->request = \Environment::get('request');
     // Show the articles of a different page
     if ($this->defineRoot && $this->rootPage > 0) {
         if (($objTarget = $this->objModel->getRelated('rootPage')) instanceof PageModel) {
             $id = $objTarget->id;
             /** @var PageModel $objTarget */
             $this->Template->request = $objTarget->getFrontendUrl();
         }
     }
     // Get published articles
     $objArticles = \ArticleModel::findPublishedByPidAndColumn($id, $this->inColumn);
     if ($objArticles === null) {
         return;
     }
     while ($objArticles->next()) {
         // Skip first article
         if (++$intCount <= intval($this->skipFirst)) {
             continue;
         }
         $cssID = \StringUtil::deserialize($objArticles->cssID, true);
         $articles[] = array('link' => $objArticles->title, 'title' => \StringUtil::specialchars($objArticles->title), 'id' => $cssID[0] ?: 'article-' . $objArticles->id, 'articleId' => $objArticles->id);
     }
     $this->Template->articles = $articles;
 }
开发者ID:contao,项目名称:core-bundle,代码行数:37,代码来源:ModuleArticleList.php

示例6: getContaoFile

 private function getContaoFile($uuid)
 {
     $uuid = StringUtil::deserialize($uuid);
     if (is_array($uuid)) {
         return FilesModel::findMultipleByUuids($uuid);
     }
     return FilesModel::findByUuid($uuid);
 }
开发者ID:fuzzyma,项目名称:contao-eloquent-bundle,代码行数:8,代码来源:ContaoFilesModelTrait.php

示例7: __set

 /**
  * Add specific attributes
  *
  * @param string $strKey
  * @param mixed  $varValue
  */
 public function __set($strKey, $varValue)
 {
     switch ($strKey) {
         case 'options':
             $this->arrOptions = \StringUtil::deserialize($varValue);
             break;
         default:
             parent::__set($strKey, $varValue);
             break;
     }
 }
开发者ID:qzminski,项目名称:contao-core-bundle,代码行数:17,代码来源:CheckBox.php

示例8: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     // Get all active pages
     $objPages = \PageModel::findPublishedRegularWithoutGuestsByIds($this->pages);
     // Return if there are no pages
     if ($objPages === null) {
         return;
     }
     $arrPages = array();
     // Sort the array keys according to the given order
     if ($this->orderPages != '') {
         $tmp = \StringUtil::deserialize($this->orderPages);
         if (!empty($tmp) && is_array($tmp)) {
             $arrPages = array_map(function () {
             }, array_flip($tmp));
         }
     }
     // Add the items to the pre-sorted array
     while ($objPages->next()) {
         $arrPages[$objPages->id] = $objPages->current();
     }
     $items = array();
     $arrPages = array_values(array_filter($arrPages));
     /** @var PageModel[] $arrPages */
     foreach ($arrPages as $objPage) {
         $objPage->title = \StringUtil::stripInsertTags($objPage->title);
         $objPage->pageTitle = \StringUtil::stripInsertTags($objPage->pageTitle);
         // Get href
         switch ($objPage->type) {
             case 'redirect':
                 $href = $objPage->url;
                 break;
             case 'forward':
                 if (($objNext = $objPage->getRelated('jumpTo')) instanceof PageModel) {
                     /** @var PageModel $objNext */
                     $href = $objNext->getFrontendUrl();
                     break;
                 }
                 // DO NOT ADD A break; STATEMENT
             // DO NOT ADD A break; STATEMENT
             default:
                 $href = $objPage->getFrontendUrl();
                 break;
         }
         $items[] = array('href' => $href, 'title' => \StringUtil::specialchars($objPage->pageTitle ?: $objPage->title), 'link' => $objPage->title);
     }
     $this->Template->items = $items;
     $this->Template->formId = 'tl_quicklink_' . $this->id;
     $this->Template->request = ampersand(\Environment::get('request'), true);
     $this->Template->title = $this->customLabel ?: $GLOBALS['TL_LANG']['MSC']['quicklink'];
     $this->Template->button = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['go']);
 }
开发者ID:bytehead,项目名称:core-bundle,代码行数:55,代码来源:ModuleQuicklink.php

示例9: onGeneratePage

 /**
  * Adds the feeds to the page header.
  *
  * @param PageModel          $objPage
  * @param LayoutModel|object $objLayout
  */
 public function onGeneratePage(PageModel $objPage, LayoutModel $objLayout)
 {
     $newsfeeds = StringUtil::deserialize($objLayout->newsfeeds);
     if (empty($newsfeeds) || !is_array($newsfeeds)) {
         return;
     }
     $this->framework->initialize();
     /** @var NewsFeedModel $adapter */
     $adapter = $this->framework->getAdapter(NewsFeedModel::class);
     if (!($feeds = $adapter->findByIds($newsfeeds)) instanceof Collection) {
         return;
     }
     $this->addFeedMarkupToPageHeader($feeds);
 }
开发者ID:contao,项目名称:news-bundle,代码行数:20,代码来源:GeneratePageListener.php

示例10: generate

 /**
  * Display a wildcard in the back end
  *
  * @return string
  */
 public function generate()
 {
     if (TL_MODE == 'BE') {
         /** @var BackendTemplate|object $objTemplate */
         $objTemplate = new \BackendTemplate('be_wildcard');
         $objTemplate->wildcard = '### ' . Utf8::strtoupper($GLOBALS['TL_LANG']['FMD']['faqpage'][0]) . ' ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = 'contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id=' . $this->id;
         return $objTemplate->parse();
     }
     $this->faq_categories = \StringUtil::deserialize($this->faq_categories);
     // Return if there are no categories
     if (!is_array($this->faq_categories) || empty($this->faq_categories)) {
         return '';
     }
     return parent::generate();
 }
开发者ID:contao,项目名称:faq-bundle,代码行数:24,代码来源:ModuleFaqPage.php

示例11: generate

 /**
  * Return a wildcard in the back end
  *
  * @return string
  */
 public function generate()
 {
     if (TL_MODE == 'BE') {
         /** @var BackendTemplate|object $objTemplate */
         $objTemplate = new \BackendTemplate('be_wildcard');
         $objTemplate->wildcard = '### ' . Utf8::strtoupper($GLOBALS['TL_LANG']['FMD']['personalData'][0]) . ' ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = 'contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id=' . $this->id;
         return $objTemplate->parse();
     }
     $this->editable = \StringUtil::deserialize($this->editable);
     // Return if there are not editable fields or if there is no logged in user
     if (!is_array($this->editable) || empty($this->editable) || !FE_USER_LOGGED_IN) {
         return '';
     }
     if ($this->memberTpl != '') {
         $this->strTemplate = $this->memberTpl;
     }
     return parent::generate();
 }
开发者ID:contao,项目名称:core-bundle,代码行数:27,代码来源:ModulePersonalData.php

示例12: generate

 /**
  * Display a wildcard in the back end
  *
  * @return string
  */
 public function generate()
 {
     if (TL_MODE == 'BE') {
         /** @var BackendTemplate|object $objTemplate */
         $objTemplate = new \BackendTemplate('be_wildcard');
         $objTemplate->wildcard = '### ' . Utf8::strtoupper($GLOBALS['TL_LANG']['FMD']['faqlist'][0]) . ' ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = 'contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id=' . $this->id;
         return $objTemplate->parse();
     }
     $this->faq_categories = \StringUtil::deserialize($this->faq_categories);
     // Return if there are no categories
     if (!is_array($this->faq_categories) || empty($this->faq_categories)) {
         return '';
     }
     // Show the FAQ reader if an item has been selected
     if ($this->faq_readerModule > 0 && (isset($_GET['items']) || \Config::get('useAutoItem') && isset($_GET['auto_item']))) {
         return $this->getFrontendModule($this->faq_readerModule, $this->strColumn);
     }
     return parent::generate();
 }
开发者ID:contao,项目名称:faq-bundle,代码行数:28,代码来源:ModuleFaqList.php

示例13: getQuicknavPages

 /**
  * Recursively get all quicknav pages and return them as array
  *
  * @param integer $pid
  * @param integer $level
  * @param string  $host
  * @param string  $language
  *
  * @return array
  */
 protected function getQuicknavPages($pid, $level = 1, $host = null, $language = null)
 {
     /** @var PageModel $objPage */
     global $objPage;
     $groups = array();
     $arrPages = array();
     // Get all groups of the current front end user
     if (FE_USER_LOGGED_IN) {
         $this->import('FrontendUser', 'User');
         $groups = $this->User->groups;
     }
     // Get all active subpages
     $objSubpages = \PageModel::findPublishedRegularWithoutGuestsByPid($pid);
     if ($objSubpages === null) {
         return array();
     }
     ++$level;
     foreach ($objSubpages as $objSubpage) {
         $_groups = \StringUtil::deserialize($objSubpage->groups);
         // Override the domain (see #3765)
         if ($host !== null) {
             $objSubpage->domain = $host;
         }
         // Do not show protected pages unless a back end or front end user is logged in
         if (!$objSubpage->protected || !is_array($_groups) && FE_USER_LOGGED_IN || BE_USER_LOGGED_IN || is_array($_groups) && array_intersect($_groups, $groups) || $this->showProtected) {
             // Do not skip the current page here! (see #4523)
             // Check hidden pages
             if (!$objSubpage->hide || $this->showHidden) {
                 $arrPages[] = array('level' => $level - 2, 'title' => \StringUtil::specialchars(\StringUtil::stripInsertTags($objSubpage->pageTitle ?: $objSubpage->title)), 'href' => $objSubpage->getFrontendUrl(), 'link' => \StringUtil::stripInsertTags($objSubpage->title));
                 // Subpages
                 if (!$this->showLevel || $this->showLevel >= $level || !$this->hardLimit && ($objPage->id == $objSubpage->id || in_array($objPage->id, $this->Database->getChildRecords($objSubpage->id, 'tl_page')))) {
                     $subpages = $this->getQuicknavPages($objSubpage->id, $level);
                     if (is_array($subpages)) {
                         $arrPages = array_merge($arrPages, $subpages);
                     }
                 }
             }
         }
     }
     return $arrPages;
 }
开发者ID:qzminski,项目名称:contao-core-bundle,代码行数:51,代码来源:ModuleQuicknav.php

示例14: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     /** @var PageModel $objPage */
     global $objPage;
     $this->Template->event = '';
     $this->Template->referer = 'javascript:history.go(-1)';
     $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
     // Get the current event
     $objEvent = \CalendarEventsModel::findPublishedByParentAndIdOrAlias(\Input::get('events'), $this->cal_calendar);
     if (null === $objEvent) {
         throw new PageNotFoundException('Page not found: ' . \Environment::get('uri'));
     }
     // Overwrite the page title (see #2853 and #4955)
     if ($objEvent->title != '') {
         $objPage->pageTitle = strip_tags(\StringUtil::stripInsertTags($objEvent->title));
     }
     // Overwrite the page description
     if ($objEvent->teaser != '') {
         $objPage->description = $this->prepareMetaDescription($objEvent->teaser);
     }
     $intStartTime = $objEvent->startTime;
     $intEndTime = $objEvent->endTime;
     $span = \Calendar::calculateSpan($intStartTime, $intEndTime);
     // Do not show dates in the past if the event is recurring (see #923)
     if ($objEvent->recurring) {
         $arrRange = \StringUtil::deserialize($objEvent->repeatEach);
         if (is_array($arrRange) && isset($arrRange['unit']) && isset($arrRange['value'])) {
             while ($intStartTime < time() && $intEndTime < $objEvent->repeatEnd) {
                 $intStartTime = strtotime('+' . $arrRange['value'] . ' ' . $arrRange['unit'], $intStartTime);
                 $intEndTime = strtotime('+' . $arrRange['value'] . ' ' . $arrRange['unit'], $intEndTime);
             }
         }
     }
     $strDate = \Date::parse($objPage->dateFormat, $intStartTime);
     if ($span > 0) {
         $strDate = \Date::parse($objPage->dateFormat, $intStartTime) . ' – ' . \Date::parse($objPage->dateFormat, $intEndTime);
     }
     $strTime = '';
     if ($objEvent->addTime) {
         if ($span > 0) {
             $strDate = \Date::parse($objPage->datimFormat, $intStartTime) . ' – ' . \Date::parse($objPage->datimFormat, $intEndTime);
         } elseif ($intStartTime == $intEndTime) {
             $strTime = \Date::parse($objPage->timeFormat, $intStartTime);
         } else {
             $strTime = \Date::parse($objPage->timeFormat, $intStartTime) . ' – ' . \Date::parse($objPage->timeFormat, $intEndTime);
         }
     }
     $until = '';
     $recurring = '';
     // Recurring event
     if ($objEvent->recurring) {
         $arrRange = \StringUtil::deserialize($objEvent->repeatEach);
         if (is_array($arrRange) && isset($arrRange['unit']) && isset($arrRange['value'])) {
             $strKey = 'cal_' . $arrRange['unit'];
             $recurring = sprintf($GLOBALS['TL_LANG']['MSC'][$strKey], $arrRange['value']);
             if ($objEvent->recurrences > 0) {
                 $until = sprintf($GLOBALS['TL_LANG']['MSC']['cal_until'], \Date::parse($objPage->dateFormat, $objEvent->repeatEnd));
             }
         }
     }
     /** @var FrontendTemplate|object $objTemplate */
     $objTemplate = new \FrontendTemplate($this->cal_template);
     $objTemplate->setData($objEvent->row());
     $objTemplate->date = $strDate;
     $objTemplate->time = $strTime;
     $objTemplate->datetime = $objEvent->addTime ? date('Y-m-d\\TH:i:sP', $intStartTime) : date('Y-m-d', $intStartTime);
     $objTemplate->begin = $intStartTime;
     $objTemplate->end = $intEndTime;
     $objTemplate->class = $objEvent->cssClass != '' ? ' ' . $objEvent->cssClass : '';
     $objTemplate->recurring = $recurring;
     $objTemplate->until = $until;
     $objTemplate->locationLabel = $GLOBALS['TL_LANG']['MSC']['location'];
     $objTemplate->details = '';
     $objTemplate->hasDetails = false;
     $objTemplate->hasTeaser = false;
     // Clean the RTE output
     if ($objEvent->teaser != '') {
         $objTemplate->hasTeaser = true;
         $objTemplate->teaser = \StringUtil::toHtml5($objEvent->teaser);
         $objTemplate->teaser = \StringUtil::encodeEmail($objTemplate->teaser);
     }
     // Display the "read more" button for external/article links
     if ($objEvent->source != 'default') {
         $objTemplate->details = true;
         $objTemplate->hasDetails = true;
     } else {
         $id = $objEvent->id;
         $objTemplate->details = function () use($id) {
             $strDetails = '';
             $objElement = \ContentModel::findPublishedByPidAndTable($id, 'tl_calendar_events');
             if ($objElement !== null) {
                 while ($objElement->next()) {
                     $strDetails .= $this->getContentElement($objElement->current());
                 }
             }
             return $strDetails;
         };
//.........这里部分代码省略.........
开发者ID:contao,项目名称:calendar-bundle,代码行数:101,代码来源:ModuleEventReader.php

示例15: generate

 /**
  * Display a login form
  *
  * @return string
  */
 public function generate()
 {
     if (TL_MODE == 'BE') {
         /** @var BackendTemplate|object $objTemplate */
         $objTemplate = new \BackendTemplate('be_wildcard');
         $objTemplate->wildcard = '### ' . Utf8::strtoupper($GLOBALS['TL_LANG']['FMD']['login'][0]) . ' ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = 'contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id=' . $this->id;
         return $objTemplate->parse();
     }
     // Set the last page visited
     if (!$_POST && $this->redirectBack) {
         $_SESSION['LAST_PAGE_VISITED'] = $this->getReferer();
     }
     // Login
     if (\Input::post('FORM_SUBMIT') == 'tl_login_' . $this->id) {
         // Check whether username and password are set
         if (empty($_POST['username']) || empty($_POST['password'])) {
             \System::getContainer()->get('session')->getFlashBag()->set($this->strFlashType, $GLOBALS['TL_LANG']['MSC']['emptyField']);
             $this->reload();
         }
         $this->import('FrontendUser', 'User');
         $strRedirect = \Environment::get('request');
         // Redirect to the last page visited
         if ($this->redirectBack && $_SESSION['LAST_PAGE_VISITED'] != '') {
             $strRedirect = $_SESSION['LAST_PAGE_VISITED'];
         } else {
             // Redirect to the jumpTo page
             if ($this->jumpTo && ($objTarget = $this->objModel->getRelated('jumpTo')) instanceof PageModel) {
                 /** @var PageModel $objTarget */
                 $strRedirect = $objTarget->getFrontendUrl();
             }
             // Overwrite the jumpTo page with an individual group setting
             $objMember = \MemberModel::findByUsername(\Input::post('username'));
             if ($objMember !== null) {
                 $arrGroups = \StringUtil::deserialize($objMember->groups);
                 if (!empty($arrGroups) && is_array($arrGroups)) {
                     $objGroupPage = \PageModel::findFirstActiveByMemberGroups($arrGroups);
                     if ($objGroupPage !== null) {
                         $strRedirect = $objGroupPage->getFrontendUrl();
                     }
                 }
             }
         }
         // Auto login is not allowed
         if (isset($_POST['autologin']) && !$this->autologin) {
             unset($_POST['autologin']);
             \Input::setPost('autologin', null);
         }
         // Login and redirect
         if ($this->User->login()) {
             $this->redirect($strRedirect);
         }
         $this->reload();
     }
     // Logout and redirect to the website root if the current page is protected
     if (\Input::post('FORM_SUBMIT') == 'tl_logout_' . $this->id) {
         /** @var PageModel $objPage */
         global $objPage;
         $this->import('FrontendUser', 'User');
         $strRedirect = \Environment::get('request');
         // Redirect to last page visited
         if ($this->redirectBack && strlen($_SESSION['LAST_PAGE_VISITED'])) {
             $strRedirect = $_SESSION['LAST_PAGE_VISITED'];
         } elseif ($objPage->protected) {
             $strRedirect = \Environment::get('base');
         }
         // Logout and redirect
         if ($this->User->logout()) {
             $this->redirect($strRedirect);
         }
         $this->reload();
     }
     return parent::generate();
 }
开发者ID:contao,项目名称:core-bundle,代码行数:82,代码来源:ModuleLogin.php


注:本文中的Contao\StringUtil::deserialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。