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


PHP StringUtil::splitFriendlyEmail方法代码示例

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


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

示例1: validator


//.........这里部分代码省略.........
                 } else {
                     // Validate the date (see #5086)
                     try {
                         new \Date($varInput, \Date::getNumericDateFormat());
                     } catch (\OutOfBoundsException $e) {
                         $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalidDate'], $varInput));
                     }
                 }
                 break;
                 // Check whether the current value is a valid time format
             // Check whether the current value is a valid time format
             case 'time':
                 if (!\Validator::isTime($varInput)) {
                     $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['time'], \Date::getInputFormat(\Date::getNumericTimeFormat())));
                 }
                 break;
                 // Check whether the current value is a valid date and time format
             // Check whether the current value is a valid date and time format
             case 'datim':
                 if (!\Validator::isDatim($varInput)) {
                     $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['dateTime'], \Date::getInputFormat(\Date::getNumericDatimFormat())));
                 } else {
                     // Validate the date (see #5086)
                     try {
                         new \Date($varInput, \Date::getNumericDatimFormat());
                     } catch (\OutOfBoundsException $e) {
                         $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalidDate'], $varInput));
                     }
                 }
                 break;
                 // Check whether the current value is a valid friendly name e-mail address
             // Check whether the current value is a valid friendly name e-mail address
             case 'friendly':
                 list($strName, $varInput) = \StringUtil::splitFriendlyEmail($varInput);
                 // no break;
                 // Check whether the current value is a valid e-mail address
             // no break;
             // Check whether the current value is a valid e-mail address
             case 'email':
                 if (!\Validator::isEmail($varInput)) {
                     $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['email'], $this->strLabel));
                 }
                 if ($this->rgxp == 'friendly' && !empty($strName)) {
                     $varInput = $strName . ' [' . $varInput . ']';
                 }
                 break;
                 // Check whether the current value is list of valid e-mail addresses
             // Check whether the current value is list of valid e-mail addresses
             case 'emails':
                 $arrEmails = \StringUtil::trimsplit(',', $varInput);
                 foreach ($arrEmails as $strEmail) {
                     $strEmail = \Idna::encodeEmail($strEmail);
                     if (!\Validator::isEmail($strEmail)) {
                         $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['emails'], $this->strLabel));
                         break;
                     }
                 }
                 break;
                 // Check whether the current value is a valid URL
             // Check whether the current value is a valid URL
             case 'url':
                 if (!\Validator::isUrl($varInput)) {
                     $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['url'], $this->strLabel));
                 }
                 break;
                 // Check whether the current value is a valid alias
开发者ID:contao,项目名称:core-bundle,代码行数:67,代码来源:Widget.php

示例2: run

 /**
  * Run the controller
  *
  * @return Response
  *
  * @throws AccessDeniedException
  */
 public function run()
 {
     global $objPage;
     $pageId = $this->getPageIdFromUrl();
     $objRootPage = null;
     // Load a website root page object if there is no page ID
     if ($pageId === null) {
         $objRootPage = $this->getRootPageFromUrl();
         /** @var PageRoot $objHandler */
         $objHandler = new $GLOBALS['TL_PTY']['root']();
         $pageId = $objHandler->generate($objRootPage->id, true, true);
     } elseif ($pageId === false) {
         $this->User->authenticate();
         throw new PageNotFoundException('Page not found');
     }
     // Get the current page object(s)
     $objPage = \PageModel::findPublishedByIdOrAlias($pageId);
     // Check the URL and language of each page if there are multiple results
     if ($objPage !== null && $objPage->count() > 1) {
         $objNewPage = null;
         $arrPages = array();
         // Order by domain and language
         while ($objPage->next()) {
             /** @var PageModel $objModel */
             $objModel = $objPage->current();
             $objCurrentPage = $objModel->loadDetails();
             $domain = $objCurrentPage->domain ?: '*';
             $arrPages[$domain][$objCurrentPage->rootLanguage] = $objCurrentPage;
             // Also store the fallback language
             if ($objCurrentPage->rootIsFallback) {
                 $arrPages[$domain]['*'] = $objCurrentPage;
             }
         }
         $strHost = \Environment::get('host');
         // Look for a root page whose domain name matches the host name
         if (isset($arrPages[$strHost])) {
             $arrLangs = $arrPages[$strHost];
         } else {
             $arrLangs = $arrPages['*'] ?: array();
             // empty domain
         }
         // Use the first result (see #4872)
         if (!\Config::get('addLanguageToUrl')) {
             $objNewPage = current($arrLangs);
         } elseif (($lang = \Input::get('language')) != '' && isset($arrLangs[$lang])) {
             $objNewPage = $arrLangs[$lang];
         }
         // Store the page object
         if (is_object($objNewPage)) {
             $objPage = $objNewPage;
         }
     }
     // Throw a 404 error if the page could not be found
     if ($objPage === null) {
         $this->User->authenticate();
         $this->log('No active page for page ID "' . $pageId . '" (' . \Environment::get('base') . \Environment::get('request') . ')', __METHOD__, TL_ERROR);
         throw new PageNotFoundException('Page not found');
     }
     // Throw a 500 error if the result is still ambiguous
     if ($objPage instanceof Model\Collection && $objPage->count() != 1) {
         $this->log('More than one page matches page ID "' . $pageId . '" (' . \Environment::get('base') . \Environment::get('request') . ')', __METHOD__, TL_ERROR);
         throw new \LogicException('More than one page found');
     }
     // Make sure $objPage is a Model
     if ($objPage instanceof Model\Collection) {
         $objPage = $objPage->current();
     }
     // If the page has an alias, it can no longer be called via ID (see #7661)
     if ($objPage->alias != '' && preg_match('#^' . $objPage->id . '[$/.]#', \Environment::get('relativeRequest'))) {
         $this->User->authenticate();
         throw new PageNotFoundException('Page not found');
     }
     // Load a website root page object (will redirect to the first active regular page)
     if ($objPage->type == 'root') {
         /** @var PageRoot $objHandler */
         $objHandler = new $GLOBALS['TL_PTY']['root']();
         $objHandler->generate($objPage->id);
     }
     // Inherit the settings from the parent pages if it has not been done yet
     if (!is_bool($objPage->protected)) {
         $objPage->loadDetails();
     }
     // Set the admin e-mail address
     if ($objPage->adminEmail != '') {
         list($GLOBALS['TL_ADMIN_NAME'], $GLOBALS['TL_ADMIN_EMAIL']) = \StringUtil::splitFriendlyEmail($objPage->adminEmail);
     } else {
         list($GLOBALS['TL_ADMIN_NAME'], $GLOBALS['TL_ADMIN_EMAIL']) = \StringUtil::splitFriendlyEmail(\Config::get('adminEmail'));
     }
     // Exit if the root page has not been published (see #2425)
     // Do not try to load the 404 page, it can cause an infinite loop!
     if (!BE_USER_LOGGED_IN && !$objPage->rootIsPublic) {
         throw new PageNotFoundException('Page not found');
     }
//.........这里部分代码省略.........
开发者ID:Mozan,项目名称:core-bundle,代码行数:101,代码来源:FrontendIndex.php

示例3: splitFriendlyName

 /**
  * Split a friendly-name e-address and return name and e-mail as array
  *
  * @param string $strEmail A friendly-name e-mail address
  *
  * @return array An array with name and e-mail address
  *
  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  *             Use StringUtil::splitFriendlyEmail() instead.
  */
 public static function splitFriendlyName($strEmail)
 {
     @trigger_error('Using System::splitFriendlyName() has been deprecated and will no longer work in Contao 5.0. Use StringUtil::splitFriendlyEmail() instead.', E_USER_DEPRECATED);
     return \StringUtil::splitFriendlyEmail($strEmail);
 }
开发者ID:contao,项目名称:core-bundle,代码行数:15,代码来源:System.php

示例4: splitFriendlyEmail

 /**
  * Split a friendly-name e-address and return name and e-mail as array.
  *
  * @param string $strEmail A friendly-name e-mail address.
  *
  * @return array An array with name and e-mail address
  */
 public static function splitFriendlyEmail($strEmail)
 {
     if (self::isStringUtilAvailable()) {
         return StringUtil::splitFriendlyEmail($strEmail);
     }
     return \Contao\String::splitFriendlyEmail($strEmail);
 }
开发者ID:contao-community-alliance,项目名称:events-contao-bindings,代码行数:14,代码来源:StringHelper.php


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