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


PHP StringUtil::specialchars方法代码示例

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


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

示例1: run

 /**
  * Run the controller and parse the login template
  *
  * @return Response
  */
 public function run()
 {
     /** @var BackendTemplate|object $objTemplate */
     $objTemplate = new \BackendTemplate('be_login');
     $strHeadline = sprintf($GLOBALS['TL_LANG']['MSC']['loginTo'], \Config::get('websiteTitle'));
     $objTemplate->theme = \Backend::getTheme();
     $objTemplate->messages = \Message::generate();
     $objTemplate->base = \Environment::get('base');
     $objTemplate->language = $GLOBALS['TL_LANGUAGE'];
     $objTemplate->languages = \System::getLanguages(true);
     $objTemplate->title = \StringUtil::specialchars($strHeadline);
     $objTemplate->charset = \Config::get('characterSet');
     $objTemplate->action = ampersand(\Environment::get('request'));
     $objTemplate->userLanguage = $GLOBALS['TL_LANG']['tl_user']['language'][0];
     $objTemplate->headline = $strHeadline;
     $objTemplate->curLanguage = \Input::post('language') ?: str_replace('-', '_', $GLOBALS['TL_LANGUAGE']);
     $objTemplate->curUsername = \Input::post('username') ?: '';
     $objTemplate->uClass = $_POST && empty($_POST['username']) ? ' class="login_error"' : '';
     $objTemplate->pClass = $_POST && empty($_POST['password']) ? ' class="login_error"' : '';
     $objTemplate->loginButton = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['loginBT']);
     $objTemplate->username = $GLOBALS['TL_LANG']['tl_user']['username'][0];
     $objTemplate->password = $GLOBALS['TL_LANG']['MSC']['password'][0];
     $objTemplate->feLink = $GLOBALS['TL_LANG']['MSC']['feLink'];
     $objTemplate->default = $GLOBALS['TL_LANG']['MSC']['default'];
     $objTemplate->jsDisabled = $GLOBALS['TL_LANG']['MSC']['jsDisabled'];
     return $objTemplate->getResponse();
 }
开发者ID:contao,项目名称:core-bundle,代码行数:32,代码来源:BackendIndex.php

示例2: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     /** @var PageModel $objPage */
     global $objPage;
     // Set the trail and level
     if ($this->defineRoot && $this->rootPage > 0) {
         $trail = array($this->rootPage);
         $level = 0;
     } else {
         $trail = $objPage->trail;
         $level = $this->levelOffset > 0 ? $this->levelOffset : 0;
     }
     $lang = null;
     $host = null;
     // Overwrite the domain and language if the reference page belongs to a differnt root page (see #3765)
     if ($this->defineRoot && $this->rootPage > 0) {
         $objRootPage = \PageModel::findWithDetails($this->rootPage);
         // Set the language
         if (\Config::get('addLanguageToUrl') && $objRootPage->rootLanguage != $objPage->rootLanguage) {
             $lang = $objRootPage->rootLanguage;
         }
         // Set the domain
         if ($objRootPage->rootId != $objPage->rootId && $objRootPage->domain != '' && $objRootPage->domain != $objPage->domain) {
             $host = $objRootPage->domain;
         }
     }
     $this->Template->request = ampersand(\Environment::get('indexFreeRequest'));
     $this->Template->skipId = 'skipNavigation' . $this->id;
     $this->Template->skipNavigation = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['skipNavigation']);
     $this->Template->items = $this->renderNavigation($trail[$level], 1, $host, $lang);
 }
开发者ID:contao,项目名称:core-bundle,代码行数:34,代码来源:ModuleNavigation.php

示例3: 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

示例4: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     $objFaq = \FaqModel::findPublishedByPids($this->faq_categories);
     if ($objFaq === null) {
         $this->Template->faq = array();
         return;
     }
     $arrFaq = array_fill_keys($this->faq_categories, array());
     // Add FAQs
     while ($objFaq->next()) {
         $arrTemp = $objFaq->row();
         $arrTemp['title'] = \StringUtil::specialchars($objFaq->question, true);
         $arrTemp['href'] = $this->generateFaqLink($objFaq);
         /** @var FaqCategoryModel $objPid */
         $objPid = $objFaq->getRelated('pid');
         $arrFaq[$objFaq->pid]['items'][] = $arrTemp;
         $arrFaq[$objFaq->pid]['headline'] = $objPid->headline;
         $arrFaq[$objFaq->pid]['title'] = $objPid->title;
     }
     $arrFaq = array_values(array_filter($arrFaq));
     $cat_count = 0;
     $cat_limit = count($arrFaq);
     // Add classes
     foreach ($arrFaq as $k => $v) {
         $count = 0;
         $limit = count($v['items']);
         for ($i = 0; $i < $limit; $i++) {
             $arrFaq[$k]['items'][$i]['class'] = trim((++$count == 1 ? ' first' : '') . ($count >= $limit ? ' last' : '') . ($count % 2 == 0 ? ' odd' : ' even'));
         }
         $arrFaq[$k]['class'] = trim((++$cat_count == 1 ? ' first' : '') . ($cat_count >= $cat_limit ? ' last' : '') . ($cat_count % 2 == 0 ? ' odd' : ' even'));
     }
     $this->Template->faq = $arrFaq;
 }
开发者ID:contao,项目名称:faq-bundle,代码行数:36,代码来源:ModuleFaqList.php

示例5: write

 /**
  * {@inheritdoc}
  */
 protected function write(array $record)
 {
     $this->createStatement();
     /** @var \DateTime $date */
     $date = $record['datetime'];
     /** @var ContaoContext $context */
     $context = $record['extra']['contao'];
     $this->statement->execute(['tstamp' => $date->format('U'), 'text' => StringUtil::specialchars((string) $record['formatted']), 'source' => (string) $context->getSource(), 'action' => (string) $context->getAction(), 'username' => (string) $context->getUsername(), 'func' => (string) $context->getFunc(), 'ip' => (string) $context->getIp(), 'browser' => (string) $context->getBrowser()]);
 }
开发者ID:contao,项目名称:core-bundle,代码行数:12,代码来源:ContaoTableHandler.php

示例6: generate

 /**
  * Show the raw markdown code in the back end
  *
  * @return string
  */
 public function generate()
 {
     if (TL_MODE == 'BE') {
         $return = '<pre>' . \StringUtil::specialchars($this->code) . '</pre>';
         if ($this->headline != '') {
             $return = '<' . $this->hl . '>' . $this->headline . '</' . $this->hl . '>' . $return;
         }
         return $return;
     }
     return parent::generate();
 }
开发者ID:contao,项目名称:core-bundle,代码行数:16,代码来源:ContentMarkdown.php

示例7: run

 /**
  * Run the controller and parse the template
  *
  * @return Response
  */
 public function run()
 {
     /** @var BackendTemplate|object $objTemplate */
     $objTemplate = new \BackendTemplate('be_alerts');
     $objTemplate->theme = \Backend::getTheme();
     $objTemplate->base = \Environment::get('base');
     $objTemplate->language = $GLOBALS['TL_LANGUAGE'];
     $objTemplate->title = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['systemMessages']);
     $objTemplate->charset = \Config::get('characterSet');
     $objTemplate->messages = \Message::generateUnwrapped() . \Backend::getSystemMessages();
     return $objTemplate->getResponse();
 }
开发者ID:contao,项目名称:core-bundle,代码行数:17,代码来源:BackendAlerts.php

示例8: run

 /**
  * Run the controller and parse the template
  *
  * @return Response
  */
 public function run()
 {
     /** @var BackendTemplate|object $objTemplate */
     $objTemplate = new \BackendTemplate('be_preview');
     $objTemplate->base = \Environment::get('base');
     $objTemplate->language = $GLOBALS['TL_LANGUAGE'];
     $objTemplate->title = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['fePreview']);
     $objTemplate->charset = \Config::get('characterSet');
     $objTemplate->site = \Input::get('site', true);
     $objTemplate->switchHref = \System::getContainer()->get('router')->generate('contao_backend_switch');
     $strUrl = null;
     if (\Input::get('url')) {
         $strUrl = \Environment::get('base') . \Input::get('url');
     } elseif (\Input::get('page')) {
         $strUrl = $this->redirectToFrontendPage(\Input::get('page'), \Input::get('article'), true);
     } else {
         $event = new PreviewUrlConvertEvent();
         \System::getContainer()->get('event_dispatcher')->dispatch(ContaoCoreEvents::PREVIEW_URL_CONVERT, $event);
         $strUrl = $event->getUrl();
     }
     if ($strUrl === null) {
         $strUrl = \System::getContainer()->get('router')->generate('contao_root', [], UrlGeneratorInterface::ABSOLUTE_URL);
     }
     $objTemplate->url = $strUrl;
     // Switch to a particular member (see #6546)
     if (\Input::get('user') && $this->User->isAdmin) {
         $objUser = \MemberModel::findByUsername(\Input::get('user'));
         if ($objUser !== null) {
             $strHash = $this->getSessionHash('FE_USER_AUTH');
             // Remove old sessions
             $this->Database->prepare("DELETE FROM tl_session WHERE tstamp<? OR hash=?")->execute(time() - \Config::get('sessionTimeout'), $strHash);
             // Insert the new session
             $this->Database->prepare("INSERT INTO tl_session (pid, tstamp, name, sessionID, ip, hash) VALUES (?, ?, ?, ?, ?, ?)")->execute($objUser->id, time(), 'FE_USER_AUTH', \System::getContainer()->get('session')->getId(), \Environment::get('ip'), $strHash);
             // Set the cookie
             $this->setCookie('FE_USER_AUTH', $strHash, time() + \Config::get('sessionTimeout'), null, null, false, true);
             $objTemplate->user = \Input::post('user');
         }
     }
     return $objTemplate->getResponse();
 }
开发者ID:qzminski,项目名称:contao-core-bundle,代码行数:45,代码来源:BackendPreview.php

示例9: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     /** @var PageModel $objPage */
     global $objPage;
     $intActive = null;
     $articles = array();
     $intCount = 1;
     foreach ($this->objArticles as $objArticle) {
         $strAlias = $objArticle->alias ?: $objArticle->id;
         // Active article
         if (\Input::get('articles') == $strAlias) {
             $articles[] = array('isActive' => true, 'href' => $objPage->getFrontendUrl('/articles/' . $strAlias), 'title' => \StringUtil::specialchars($objArticle->title, true), 'link' => $intCount);
             $intActive = $intCount - 1;
         } else {
             $articles[] = array('isActive' => false, 'href' => $objPage->getFrontendUrl('/articles/' . $strAlias), 'title' => \StringUtil::specialchars($objArticle->title, true), 'link' => $intCount);
         }
         ++$intCount;
     }
     $this->Template->articles = $articles;
     $total = count($articles);
     // Link to first element
     if ($intActive > 1) {
         $this->Template->first = array('href' => $articles[0]['href'], 'title' => $articles[0]['title'], 'link' => $GLOBALS['TL_LANG']['MSC']['first']);
     }
     $key = $intActive - 1;
     // Link to previous element
     if ($intCount > 1 && $key >= 0) {
         $this->Template->previous = array('href' => $articles[$key]['href'], 'title' => $articles[$key]['title'], 'link' => $GLOBALS['TL_LANG']['MSC']['previous']);
     }
     $key = $intActive + 1;
     // Link to next element
     if ($intCount > 1 && $key < $total) {
         $this->Template->next = array('href' => $articles[$key]['href'], 'title' => $articles[$key]['title'], 'link' => $GLOBALS['TL_LANG']['MSC']['next']);
     }
     $key = $total - 1;
     // Link to last element
     if ($intCount > 1 && $intActive < $key - 1) {
         $this->Template->last = array('href' => $articles[$key]['href'], 'title' => $articles[$key]['title'], 'link' => $GLOBALS['TL_LANG']['MSC']['last']);
     }
 }
开发者ID:contao,项目名称:core-bundle,代码行数:43,代码来源:ModuleArticlenav.php

示例10: compile


//.........这里部分代码省略.........
     $arrFields['newPassword'] = $GLOBALS['TL_DCA']['tl_member']['fields']['password'];
     $arrFields['newPassword']['name'] = 'password';
     $arrFields['newPassword']['label'] =& $GLOBALS['TL_LANG']['MSC']['newPassword'];
     $row = 0;
     $strFields = '';
     $doNotSubmit = false;
     $objMember = \MemberModel::findByPk($this->User->id);
     $strFormId = 'tl_change_password_' . $this->id;
     $flashBag = \System::getContainer()->get('session')->getFlashBag();
     $strTable = $objMember->getTable();
     // Initialize the versioning (see #8301)
     $objVersions = new \Versions($strTable, $objMember->id);
     $objVersions->setUsername($objMember->username);
     $objVersions->setUserId(0);
     $objVersions->setEditUrl('contao/main.php?do=member&act=edit&id=%s&rt=1');
     $objVersions->initialize();
     /** @var FormTextField $objOldPassword */
     $objOldPassword = null;
     /** @var FormPassword $objNewPassword */
     $objNewPassword = null;
     // Initialize the widgets
     foreach ($arrFields as $strKey => $arrField) {
         /** @var Widget $strClass */
         $strClass = $GLOBALS['TL_FFL'][$arrField['inputType']];
         // Continue if the class is not defined
         if (!class_exists($strClass)) {
             continue;
         }
         $arrField['eval']['required'] = $arrField['eval']['mandatory'];
         /** @var Widget $objWidget */
         $objWidget = new $strClass($strClass::getAttributesFromDca($arrField, $arrField['name']));
         $objWidget->storeValues = true;
         $objWidget->rowClass = 'row_' . $row . ($row == 0 ? ' row_first' : '') . ($row % 2 == 0 ? ' even' : ' odd');
         // Increase the row count if it is a password field
         if ($objWidget instanceof FormPassword) {
             $objWidget->rowClassConfirm = 'row_' . ++$row . ($row % 2 == 0 ? ' even' : ' odd');
         }
         ++$row;
         // Store the widget objects
         $strVar = 'obj' . ucfirst($strKey);
         ${$strVar} = $objWidget;
         // Validate the widget
         if (\Input::post('FORM_SUBMIT') == $strFormId) {
             $objWidget->validate();
             // Validate the old password
             if ($strKey == 'oldPassword') {
                 if (\Encryption::test($objMember->password)) {
                     $blnAuthenticated = \Encryption::verify($objWidget->value, $objMember->password);
                 } else {
                     list($strPassword, $strSalt) = explode(':', $objMember->password);
                     $blnAuthenticated = $strSalt == '' ? $strPassword === sha1($objWidget->value) : $strPassword === sha1($strSalt . $objWidget->value);
                 }
                 if (!$blnAuthenticated) {
                     $objWidget->value = '';
                     $objWidget->addError($GLOBALS['TL_LANG']['MSC']['oldPasswordWrong']);
                     sleep(2);
                     // Wait 2 seconds while brute forcing :)
                 }
             }
             if ($objWidget->hasErrors()) {
                 $doNotSubmit = true;
             }
         }
         $strFields .= $objWidget->parse();
     }
     $this->Template->fields = $strFields;
     $this->Template->hasError = $doNotSubmit;
     // Store the new password
     if (\Input::post('FORM_SUBMIT') == $strFormId && !$doNotSubmit) {
         $objMember->tstamp = time();
         $objMember->password = $objNewPassword->value;
         $objMember->save();
         // Create a new version
         if ($GLOBALS['TL_DCA'][$strTable]['config']['enableVersioning']) {
             $objVersions->create();
         }
         // HOOK: set new password callback
         if (isset($GLOBALS['TL_HOOKS']['setNewPassword']) && is_array($GLOBALS['TL_HOOKS']['setNewPassword'])) {
             foreach ($GLOBALS['TL_HOOKS']['setNewPassword'] as $callback) {
                 $this->import($callback[0]);
                 $this->{$callback[0]}->{$callback[1]}($objMember, $objNewPassword->value, $this);
             }
         }
         // Check whether there is a jumpTo page
         if (($objJumpTo = $this->objModel->getRelated('jumpTo')) instanceof PageModel) {
             $this->jumpToOrReload($objJumpTo->row());
         }
         $flashBag->set('mod_change_password_confirm', $GLOBALS['TL_LANG']['MSC']['newPasswordSet']);
         $this->reload();
     }
     // Confirmation message
     if ($flashBag->has('mod_change_password_confirm')) {
         $arrMessages = $flashBag->get('mod_change_password_confirm');
         $this->Template->message = $arrMessages[0];
     }
     $this->Template->formId = $strFormId;
     $this->Template->action = \Environment::get('indexFreeRequest');
     $this->Template->slabel = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['changePassword']);
     $this->Template->rowLast = 'row_' . $row . ' row_last' . ($row % 2 == 0 ? ' even' : ' odd');
 }
开发者ID:contao,项目名称:core-bundle,代码行数:101,代码来源:ModuleChangePassword.php

示例11: renderFiletree

 /**
  * Recursively render the filetree
  *
  * @param string  $path
  * @param integer $intMargin
  * @param boolean $mount
  * @param boolean $blnProtected
  * @param array   $arrFound
  *
  * @return string
  */
 protected function renderFiletree($path, $intMargin, $mount = false, $blnProtected = true, $arrFound = array())
 {
     // Invalid path
     if (!is_dir($path)) {
         return '';
     }
     // Make sure that $this->varValue is an array (see #3369)
     if (!is_array($this->varValue)) {
         $this->varValue = array($this->varValue);
     }
     static $session;
     /** @var AttributeBagInterface $objSessionBag */
     $objSessionBag = \System::getContainer()->get('session')->getBag('contao_backend');
     $session = $objSessionBag->all();
     $flag = substr($this->strField, 0, 2);
     $node = 'tree_' . $this->strTable . '_' . $this->strField;
     $xtnode = 'tree_' . $this->strTable . '_' . $this->strName;
     // Get session data and toggle nodes
     if (\Input::get($flag . 'tg')) {
         $session[$node][\Input::get($flag . 'tg')] = isset($session[$node][\Input::get($flag . 'tg')]) && $session[$node][\Input::get($flag . 'tg')] == 1 ? 0 : 1;
         $objSessionBag->replace($session);
         $this->redirect(preg_replace('/(&(amp;)?|\\?)' . $flag . 'tg=[^& ]*/i', '', \Environment::get('request')));
     }
     $return = '';
     $intSpacing = 20;
     $files = array();
     $folders = array();
     $level = $intMargin / $intSpacing + 1;
     // Mount folder
     if ($mount) {
         $folders = array($path);
     } else {
         foreach (scan($path) as $v) {
             if (strncmp($v, '.', 1) === 0) {
                 continue;
             }
             if (is_dir($path . '/' . $v)) {
                 $folders[] = $path . '/' . $v;
             } else {
                 $files[] = $path . '/' . $v;
             }
         }
     }
     natcasesort($folders);
     $folders = array_values($folders);
     natcasesort($files);
     $files = array_values($files);
     // Sort descending (see #4072)
     if ($this->sort == 'desc') {
         $folders = array_reverse($folders);
         $files = array_reverse($files);
     }
     $folderClass = $this->files || $this->filesOnly ? 'tl_folder' : 'tl_file';
     // Process folders
     for ($f = 0, $c = count($folders); $f < $c; $f++) {
         $content = scan($folders[$f]);
         $currentFolder = str_replace(TL_ROOT . '/', '', $folders[$f]);
         $countFiles = count($content);
         // Check whether there are subfolders or files
         foreach ($content as $file) {
             if (strncmp($file, '.', 1) === 0) {
                 --$countFiles;
             } elseif (!$this->files && !$this->filesOnly && is_file($folders[$f] . '/' . $file)) {
                 --$countFiles;
             } elseif (!empty($arrFound) && !in_array($currentFolder . '/' . $file, $arrFound) && !preg_grep('/^' . preg_quote($currentFolder . '/' . $file, '/') . '\\//', $arrFound)) {
                 --$countFiles;
             }
         }
         if (!empty($arrFound) && $countFiles < 1 && !in_array($currentFolder, $arrFound)) {
             continue;
         }
         $tid = md5($folders[$f]);
         $folderAttribute = 'style="margin-left:20px"';
         $session[$node][$tid] = is_numeric($session[$node][$tid]) ? $session[$node][$tid] : 0;
         $currentFolder = str_replace(TL_ROOT . '/', '', $folders[$f]);
         $blnIsOpen = !empty($arrFound) || $session[$node][$tid] == 1 || count(preg_grep('/^' . preg_quote($currentFolder, '/') . '\\//', $this->varValue)) > 0;
         $return .= "\n    " . '<li class="' . $folderClass . ' toggle_select hover-div"><div class="tl_left" style="padding-left:' . $intMargin . 'px">';
         // Add a toggle button if there are childs
         if ($countFiles > 0) {
             $folderAttribute = '';
             $img = $blnIsOpen ? 'folMinus.svg' : 'folPlus.svg';
             $alt = $blnIsOpen ? $GLOBALS['TL_LANG']['MSC']['collapseNode'] : $GLOBALS['TL_LANG']['MSC']['expandNode'];
             $return .= '<a href="' . \Backend::addToUrl($flag . 'tg=' . $tid) . '" title="' . \StringUtil::specialchars($alt) . '" onclick="return AjaxRequest.toggleFiletree(this,\'' . $xtnode . '_' . $tid . '\',\'' . $currentFolder . '\',\'' . $this->strField . '\',\'' . $this->strName . '\',' . $level . ')">' . \Image::getHtml($img, '', 'style="margin-right:2px"') . '</a>';
         }
         $protected = $blnProtected;
         // Check whether the folder is public
         if ($protected === true && array_search('.public', $content) !== false) {
             $protected = false;
         }
//.........这里部分代码省略.........
开发者ID:qzminski,项目名称:contao-core-bundle,代码行数:101,代码来源:FileSelector.php

示例12: setNewPassword

 /**
  * Set the new password
  */
 protected function setNewPassword()
 {
     $objMember = \MemberModel::findOneByActivation(\Input::get('token'));
     if ($objMember === null || $objMember->login == '') {
         $this->strTemplate = 'mod_message';
         /** @var FrontendTemplate|object $objTemplate */
         $objTemplate = new \FrontendTemplate($this->strTemplate);
         $this->Template = $objTemplate;
         $this->Template->type = 'error';
         $this->Template->message = $GLOBALS['TL_LANG']['MSC']['accountError'];
         return;
     }
     $strTable = $objMember->getTable();
     // Initialize the versioning (see #8301)
     $objVersions = new \Versions($strTable, $objMember->id);
     $objVersions->setUsername($objMember->username);
     $objVersions->setUserId(0);
     $objVersions->setEditUrl('contao/main.php?do=member&act=edit&id=%s&rt=1');
     $objVersions->initialize();
     // Define the form field
     $arrField = $GLOBALS['TL_DCA']['tl_member']['fields']['password'];
     /** @var Widget $strClass */
     $strClass = $GLOBALS['TL_FFL']['password'];
     // Fallback to default if the class is not defined
     if (!class_exists($strClass)) {
         $strClass = 'FormPassword';
     }
     /** @var Widget $objWidget */
     $objWidget = new $strClass($strClass::getAttributesFromDca($arrField, 'password'));
     // Set row classes
     $objWidget->rowClass = 'row_0 row_first even';
     $objWidget->rowClassConfirm = 'row_1 odd';
     $this->Template->rowLast = 'row_2 row_last even';
     /** @var SessionInterface $objSession */
     $objSession = \System::getContainer()->get('session');
     // Validate the field
     if (strlen(\Input::post('FORM_SUBMIT')) && \Input::post('FORM_SUBMIT') == $objSession->get('setPasswordToken')) {
         $objWidget->validate();
         // Set the new password and redirect
         if (!$objWidget->hasErrors()) {
             $objSession->set('setPasswordToken', '');
             $objMember->tstamp = time();
             $objMember->activation = '';
             $objMember->password = $objWidget->value;
             $objMember->save();
             // Create a new version
             if ($GLOBALS['TL_DCA'][$strTable]['config']['enableVersioning']) {
                 $objVersions->create();
             }
             // HOOK: set new password callback
             if (isset($GLOBALS['TL_HOOKS']['setNewPassword']) && is_array($GLOBALS['TL_HOOKS']['setNewPassword'])) {
                 foreach ($GLOBALS['TL_HOOKS']['setNewPassword'] as $callback) {
                     $this->import($callback[0]);
                     $this->{$callback[0]}->{$callback[1]}($objMember, $objWidget->value, $this);
                 }
             }
             // Redirect to the jumpTo page
             if (($objTarget = $this->objModel->getRelated('reg_jumpTo')) instanceof PageModel) {
                 /** @var PageModel $objTarget */
                 $this->redirect($objTarget->getFrontendUrl());
             }
             // Confirm
             $this->strTemplate = 'mod_message';
             /** @var FrontendTemplate|object $objTemplate */
             $objTemplate = new \FrontendTemplate($this->strTemplate);
             $this->Template = $objTemplate;
             $this->Template->type = 'confirm';
             $this->Template->message = $GLOBALS['TL_LANG']['MSC']['newPasswordSet'];
             return;
         }
     }
     $strToken = md5(uniqid(mt_rand(), true));
     $objSession->set('setPasswordToken', $strToken);
     $this->Template->formId = $strToken;
     $this->Template->fields = $objWidget->parse();
     $this->Template->action = \Environment::get('indexFreeRequest');
     $this->Template->slabel = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['setNewPassword']);
 }
开发者ID:qzminski,项目名称:contao-core-bundle,代码行数:81,代码来源:ModulePassword.php

示例13: generateFeedTag

 /**
  * Generate the markup for an RSS feed tag
  *
  * @param string $href   The script path
  * @param string $format The feed format
  * @param string $title  The feed title
  *
  * @return string The markup string
  */
 public static function generateFeedTag($href, $format, $title)
 {
     return '<link type="application/' . $format . '+xml" rel="alternate" href="' . $href . '" title="' . \StringUtil::specialchars($title) . '">';
 }
开发者ID:contao,项目名称:core-bundle,代码行数:13,代码来源:Template.php

示例14: compile


//.........这里部分代码省略.........
             $strQuery .= " ORDER BY CAST(" . \Input::get('order_by') . " AS SIGNED) " . \Input::get('sort');
         } else {
             $strQuery .= " ORDER BY " . \Input::get('order_by') . ' ' . \Input::get('sort');
         }
     } elseif ($this->list_sort) {
         if ($isInt($this->list_sort)) {
             $strQuery .= " ORDER BY CAST(" . $this->list_sort . " AS SIGNED)";
         } else {
             $strQuery .= " ORDER BY " . $this->list_sort;
         }
     }
     $objDataStmt = $this->Database->prepare($strQuery);
     // Limit
     if (\Input::get('per_page')) {
         $objDataStmt->limit(\Input::get('per_page'), ($page - 1) * $per_page);
     } elseif ($this->perPage) {
         $objDataStmt->limit($this->perPage, ($page - 1) * $per_page);
     }
     $objData = $objDataStmt->execute($varKeyword);
     /**
      * Prepare the URL
      */
     $strUrl = preg_replace('/\\?.*$/', '', \Environment::get('request'));
     $blnQuery = false;
     foreach (preg_split('/&(amp;)?/', \Environment::get('queryString')) as $fragment) {
         if ($fragment != '' && strncasecmp($fragment, 'order_by', 8) !== 0 && strncasecmp($fragment, 'sort', 4) !== 0 && strncasecmp($fragment, $id, strlen($id)) !== 0) {
             $strUrl .= (!$blnQuery ? '?' : '&amp;') . $fragment;
             $blnQuery = true;
         }
     }
     $this->Template->url = $strUrl;
     $strVarConnector = $blnQuery ? '&amp;' : '?';
     /**
      * Prepare the data arrays
      */
     $arrTh = array();
     $arrTd = array();
     $arrFields = \StringUtil::trimsplit(',', $this->list_fields);
     // THEAD
     for ($i = 0, $c = count($arrFields); $i < $c; $i++) {
         // Never show passwords
         if ($GLOBALS['TL_DCA'][$this->list_table]['fields'][$arrFields[$i]]['inputType'] == 'password') {
             continue;
         }
         $class = '';
         $sort = 'asc';
         $strField = strlen($label = $GLOBALS['TL_DCA'][$this->list_table]['fields'][$arrFields[$i]]['label'][0]) ? $label : $arrFields[$i];
         // Add a CSS class to the order_by column
         if (\Input::get('order_by') == $arrFields[$i]) {
             $sort = \Input::get('sort') == 'asc' ? 'desc' : 'asc';
             $class = ' sorted ' . \Input::get('sort');
         }
         $arrTh[] = array('link' => $strField, 'href' => ampersand($strUrl) . $strVarConnector . 'order_by=' . $arrFields[$i] . '&amp;sort=' . $sort, 'title' => \StringUtil::specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['list_orderBy'], $strField)), 'class' => $class . ($i == 0 ? ' col_first' : ''));
     }
     $j = 0;
     $arrRows = $objData->fetchAllAssoc();
     // TBODY
     for ($i = 0, $c = count($arrRows); $i < $c; $i++) {
         $j = 0;
         $class = 'row_' . $i . ($i == 0 ? ' row_first' : '') . ($i + 1 == count($arrRows) ? ' row_last' : '') . ($i % 2 == 0 ? ' even' : ' odd');
         foreach ($arrRows[$i] as $k => $v) {
             // Skip the primary key
             if ($k == $this->strPk && !in_array($this->strPk, $arrFields)) {
                 continue;
             }
             if ($k == '_details') {
                 continue;
             }
             // Never show passwords
             if ($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['inputType'] == 'password') {
                 continue;
             }
             $value = $this->formatValue($k, $v);
             $arrTd[$class][$k] = array('raw' => $v, 'content' => $value ? $value : '&nbsp;', 'class' => 'col_' . $j . ($j++ == 0 ? ' col_first' : '') . ($this->list_info ? '' : ($j >= count($arrRows[$i]) - 1 ? ' col_last' : '')), 'id' => $arrRows[$i][$this->strPk], 'field' => $k, 'url' => $strUrl . $strVarConnector . 'show=' . $arrRows[$i][$this->strPk], 'details' => isset($arrRows[$i]['_details']) ? $arrRows[$i]['_details'] : 1);
         }
     }
     $this->Template->thead = $arrTh;
     $this->Template->tbody = $arrTd;
     /**
      * Pagination
      */
     $objPagination = new \Pagination($objTotal->count, $per_page, \Config::get('maxPaginationLinks'), $id);
     $this->Template->pagination = $objPagination->generate("\n  ");
     $this->Template->per_page = $per_page;
     $this->Template->total = $objTotal->count;
     /**
      * Template variables
      */
     $this->Template->action = \Environment::get('indexFreeRequest');
     $this->Template->details = $this->list_info != '' ? true : false;
     $this->Template->search_label = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['search']);
     $this->Template->per_page_label = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['list_perPage']);
     $this->Template->fields_label = $GLOBALS['TL_LANG']['MSC']['all_fields'][0];
     $this->Template->keywords_label = $GLOBALS['TL_LANG']['MSC']['keywords'];
     $this->Template->search = \Input::get('search');
     $this->Template->for = \Input::get('for');
     $this->Template->order_by = \Input::get('order_by');
     $this->Template->sort = \Input::get('sort');
     $this->Template->col_last = 'col_' . $j;
 }
开发者ID:contao,项目名称:listing-bundle,代码行数:101,代码来源:ModuleListing.php

示例15: renderPagetree

 /**
  * Recursively render the pagetree
  *
  * @param integer $id
  * @param integer $intMargin
  * @param boolean $protectedPage
  * @param boolean $blnNoRecursion
  * @param array   $arrFound
  *
  * @return string
  */
 protected function renderPagetree($id, $intMargin, $protectedPage = false, $blnNoRecursion = false, $arrFound = array())
 {
     static $session;
     /** @var AttributeBagInterface $objSessionBag */
     $objSessionBag = \System::getContainer()->get('session')->getBag('contao_backend');
     $session = $objSessionBag->all();
     $flag = substr($this->strField, 0, 2);
     $node = 'tree_' . $this->strTable . '_' . $this->strField;
     $xtnode = 'tree_' . $this->strTable . '_' . $this->strName;
     // Get the session data and toggle the nodes
     if (\Input::get($flag . 'tg')) {
         $session[$node][\Input::get($flag . 'tg')] = isset($session[$node][\Input::get($flag . 'tg')]) && $session[$node][\Input::get($flag . 'tg')] == 1 ? 0 : 1;
         $objSessionBag->replace($session);
         $this->redirect(preg_replace('/(&(amp;)?|\\?)' . $flag . 'tg=[^& ]*/i', '', \Environment::get('request')));
     }
     $objPage = $this->Database->prepare("SELECT id, alias, type, protected, published, start, stop, hide, title FROM tl_page WHERE id=?")->limit(1)->execute($id);
     // Return if there is no result
     if ($objPage->numRows < 1) {
         return '';
     }
     $return = '';
     $intSpacing = 20;
     $childs = array();
     // Check whether there are child records
     if (!$blnNoRecursion) {
         $objNodes = $this->Database->prepare("SELECT id FROM tl_page WHERE pid=?" . (!empty($arrFound) ? " AND id IN(" . implode(',', array_map('intval', $arrFound)) . ")" : '') . " ORDER BY sorting")->execute($id);
         if ($objNodes->numRows) {
             $childs = $objNodes->fetchEach('id');
         }
     }
     $return .= "\n    " . '<li class="' . ($objPage->type == 'root' ? 'tl_folder' : 'tl_file') . ' toggle_select hover-div"><div class="tl_left" style="padding-left:' . ($intMargin + $intSpacing) . 'px">';
     $folderAttribute = 'style="margin-left:20px"';
     $session[$node][$id] = is_numeric($session[$node][$id]) ? $session[$node][$id] : 0;
     $level = $intMargin / $intSpacing + 1;
     $blnIsOpen = !empty($arrFound) || $session[$node][$id] == 1 || in_array($id, $this->arrNodes);
     if (!empty($childs)) {
         $folderAttribute = '';
         $img = $blnIsOpen ? 'folMinus.svg' : 'folPlus.svg';
         $alt = $blnIsOpen ? $GLOBALS['TL_LANG']['MSC']['collapseNode'] : $GLOBALS['TL_LANG']['MSC']['expandNode'];
         $return .= '<a href="' . \Backend::addToUrl($flag . 'tg=' . $id) . '" title="' . \StringUtil::specialchars($alt) . '" onclick="return AjaxRequest.togglePagetree(this,\'' . $xtnode . '_' . $id . '\',\'' . $this->strField . '\',\'' . $this->strName . '\',' . $level . ')">' . \Image::getHtml($img, '', 'style="margin-right:2px"') . '</a>';
     }
     // Set the protection status
     $objPage->protected = $objPage->protected || $protectedPage;
     // Add the current page
     if (!empty($childs)) {
         $return .= \Image::getHtml($this->getPageStatusIcon($objPage), '', $folderAttribute) . ' <a href="' . \Backend::addToUrl('pn=' . $objPage->id) . '" title="' . \StringUtil::specialchars($objPage->title . ' (' . $objPage->alias . \Config::get('urlSuffix') . ')') . '">' . ($objPage->type == 'root' ? '<strong>' : '') . $objPage->title . ($objPage->type == 'root' ? '</strong>' : '') . '</a></div> <div class="tl_right">';
     } else {
         $return .= \Image::getHtml($this->getPageStatusIcon($objPage), '', $folderAttribute) . ' ' . ($objPage->type == 'root' ? '<strong>' : '') . $objPage->title . ($objPage->type == 'root' ? '</strong>' : '') . '</div> <div class="tl_right">';
     }
     // Add checkbox or radio button
     switch ($this->fieldType) {
         case 'checkbox':
             $return .= '<input type="checkbox" name="' . $this->strName . '[]" id="' . $this->strName . '_' . $id . '" class="tl_tree_checkbox" value="' . \StringUtil::specialchars($id) . '" onfocus="Backend.getScrollOffset()"' . static::optionChecked($id, $this->varValue) . '>';
             break;
         default:
         case 'radio':
             $return .= '<input type="radio" name="' . $this->strName . '" id="' . $this->strName . '_' . $id . '" class="tl_tree_radio" value="' . \StringUtil::specialchars($id) . '" onfocus="Backend.getScrollOffset()"' . static::optionChecked($id, $this->varValue) . '>';
             break;
     }
     $return .= '</div><div style="clear:both"></div></li>';
     // Begin a new submenu
     if ($blnIsOpen || !empty($childs) && $objSessionBag->get('page_selector_search') != '') {
         $return .= '<li class="parent" id="' . $node . '_' . $id . '"><ul class="level_' . $level . '">';
         for ($k = 0, $c = count($childs); $k < $c; $k++) {
             $return .= $this->renderPagetree($childs[$k], $intMargin + $intSpacing, $objPage->protected, $blnNoRecursion, $arrFound);
         }
         $return .= '</ul></li>';
     }
     return $return;
 }
开发者ID:qzminski,项目名称:contao-core-bundle,代码行数:81,代码来源:PageSelector.php


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