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


PHP XoopsLocale::trim方法代码示例

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


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

示例1: validate

 /**
  * XoopsUserUtility::validate
  *
  * @return false|string
  */
 public static function validate()
 {
     $xoops = Xoops::getInstance();
     $args = func_get_args();
     $args_num = func_num_args();
     /* @var $user XoopsUser|null */
     $user = null;
     $uname = null;
     $email = null;
     $pass = null;
     $vpass = null;
     switch ($args_num) {
         case 1:
             $user = $args[0];
             break;
         case 2:
             list($uname, $email) = $args;
             break;
         case 3:
             list($user, $pass, $vpass) = $args;
             break;
         case 4:
             list($uname, $email, $pass, $vpass) = $args;
             break;
         default:
             return false;
     }
     if (is_object($user)) {
         $uname = $user->getVar('uname', 'n');
         $email = $user->getVar('email', 'n');
     }
     //$user = empty($user) ? null : trim($user);
     $uname = empty($uname) ? null : trim($uname);
     $email = empty($email) ? null : trim($email);
     $pass = empty($pass) ? null : trim($pass);
     $vpass = empty($vpass) ? null : trim($vpass);
     $xoops->getConfigs();
     $stop = '';
     // Invalid email address
     if (!$xoops->checkEmail($email)) {
         $stop .= XoopsLocale::E_INVALID_EMAIL . '<br />';
     }
     if (strrpos($email, ' ') > 0) {
         $stop .= XoopsLocale::E_EMAIL_SHOULD_NOT_CONTAIN_SPACES . '<br />';
     }
     // Check forbidden email address if current operator is not an administrator
     if (!$xoops->userIsAdmin) {
         $bad_emails = $xoops->getConfig('bad_emails');
         if (!empty($bad_emails)) {
             foreach ($bad_emails as $be) {
                 if (!empty($be) && preg_match('/' . $be . '/i', $email)) {
                     $stop .= XoopsLocale::E_INVALID_EMAIL . '<br />';
                     break;
                 }
             }
         }
     }
     $uname = XoopsLocale::trim($uname);
     $restriction = '';
     switch ($xoops->getConfig('uname_test_level')) {
         case 0:
             // strict
             $restriction = '/[^a-zA-Z0-9\\_\\-]/';
             break;
         case 1:
             // medium
             $restriction = '/[^a-zA-Z0-9\\_\\-\\<\\>\\,\\.\\$\\%\\#\\@\\!\\\'\']/';
             break;
         case 2:
             // loose
             $restriction = '/[\\000-\\040]/';
             break;
     }
     if (empty($uname) || preg_match($restriction, $uname)) {
         $stop .= XoopsLocale::E_INVALID_USERNAME . '<br />';
     }
     // Check uname settings if current operator is not an administrator
     if (!$xoops->userIsAdmin) {
         $maxuname = $xoops->getConfig('maxuname');
         if (!empty($maxuname) && mb_strlen($uname) > $maxuname) {
             $stop .= sprintf(XoopsLocale::EF_USERNAME_MUST_BE_LESS_THAN, $maxuname) . '<br />';
         }
         $minuname = $xoops->getConfig('minuname');
         if (!empty($minuname) && mb_strlen($uname) < $minuname) {
             $stop .= sprintf(XoopsLocale::EF_USERNAME_MUST_BE_MORE_THAN, $minuname) . '<br />';
         }
         $bad_unames = $xoops->getConfig('bad_unames');
         if (!empty($bad_unames)) {
             foreach ($bad_unames as $bu) {
                 if (!empty($bu) && preg_match('/' . $bu . '/i', $uname)) {
                     $stop .= XoopsLocale::E_NAME_IS_RESERVED . '<br />';
                     break;
                 }
             }
         }
//.........这里部分代码省略.........
开发者ID:redmexico,项目名称:XoopsCore,代码行数:101,代码来源:userutility.php

示例2: displayPost

 public function displayPost()
 {
     $xoops = Xoops::getInstance();
     if (Request::getMethod() !== 'POST') {
         $xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
     }
     $id = Request::getInt('com_id');
     $modid = Request::getInt('com_modid');
     if (empty($modid)) {
         $xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
     }
     /* @var $comment CommentsComment */
     $comment = $this->getHandlerComment()->get($id);
     if (!is_object($comment)) {
         $xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
     }
     if (!$comment->isNew()) {
         $modid = $comment->getVar('modid');
     } else {
         $comment->setVar('modid', $modid);
     }
     $module = $xoops->getModuleById($modid);
     if (!is_object($module)) {
         $xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
     }
     $moddir = $module->getVar('dirname');
     if ($xoops->isAdminSide) {
         if (empty($id)) {
             $xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
         }
         $redirect_page = $this->url('admin/main.php?com_modid=' . $modid . '&amp;com_itemid');
     } else {
         if (COMMENTS_APPROVENONE == $xoops->getModuleConfig('com_rule', $module->getVar('dirname'))) {
             $xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
         }
         $redirect_page = '';
     }
     /* @var $plugin CommentsPluginInterface */
     if ($plugin = \Xoops\Module\Plugin::getPlugin($moddir, 'comments')) {
         if (!$xoops->isAdminSide) {
             $redirect_page = $xoops->url('modules/' . $moddir . '/' . $plugin->pageName() . '?');
             if (is_array($extraParams = $plugin->extraParams())) {
                 $extra_params = '';
                 foreach ($extraParams as $extra_param) {
                     $extra_params .= isset($_POST[$extra_param]) ? $extra_param . '=' . htmlspecialchars($_POST[$extra_param]) . '&amp;' : $extra_param . '=amp;';
                 }
                 $redirect_page .= $extra_params;
             }
             $redirect_page .= $plugin->itemName();
         }
         $comment_url = $redirect_page;
         $op = Request::getBool('com_dopost') ? 'post' : '';
         $op = Request::getBool('com_dopreview') ? 'preview' : $op;
         $op = Request::getBool('com_dodelete') ? 'delete' : $op;
         if ($op === 'preview' || $op === 'post') {
             if (!$xoops->security()->check()) {
                 $op = '';
             }
         }
         if ($op === 'post' && !$xoops->isUser()) {
             $xoopsCaptcha = XoopsCaptcha::getInstance();
             if (!$xoopsCaptcha->verify()) {
                 $captcha_message = $xoopsCaptcha->getMessage();
                 $op = 'preview';
             }
         }
         $title = XoopsLocale::trim(Request::getString('com_title'));
         $text = XoopsLocale::trim(Request::getString('com_text'));
         $mode = XoopsLocale::trim(Request::getString('com_mode', 'flat'));
         $order = XoopsLocale::trim(Request::getString('com_order', COMMENTS_OLD1ST));
         $itemid = Request::getInt('com_itemid');
         $pid = Request::getInt('com_pid');
         $rootid = Request::getInt('com_rootid');
         $status = Request::getInt('com_status');
         $dosmiley = Request::getBool('com_dosmiley');
         $doxcode = Request::getBool('com_doxcode');
         $dobr = Request::getBool('com_dobr');
         $dohtml = Request::getBool('com_html');
         $doimage = Request::getBool('com_doimage');
         $icon = XoopsLocale::trim(Request::getString('com_icon'));
         $comment->setVar('title', $title);
         $comment->setVar('text', $text);
         $comment->setVar('itemid', $itemid);
         $comment->setVar('pid', $pid);
         $comment->setVar('rootid', $rootid);
         $comment->setVar('status', $status);
         $comment->setVar('dosmiley', $dosmiley);
         $comment->setVar('doxcode', $doxcode);
         $comment->setVar('dobr', $dobr);
         $comment->setVar('dohtml', $dohtml);
         $comment->setVar('doimage', $doimage);
         $comment->setVar('icon', $icon);
         switch ($op) {
             case "delete":
                 $this->displayDelete();
                 break;
             case "preview":
                 $comment->setVar('doimage', 1);
                 if ($comment->getVar('dohtml') != 0) {
                     if ($xoops->isUser()) {
//.........这里部分代码省略.........
开发者ID:ming-hai,项目名称:XoopsCore,代码行数:101,代码来源:helper.php

示例3: xoops_trim

/**
 * @deprecated
 * @param $text
 * @return string
 */
function xoops_trim($text)
{
    $xoops = Xoops::getInstance();
    $xoops->deprecated(__FUNCTION__ . ' is deprecated since XOOPS 2.6.0. See how to replace it in file ' . __FILE__ . ' line ' . __LINE__);
    return XoopsLocale::trim($text);
}
开发者ID:RanLee,项目名称:XoopsCore,代码行数:11,代码来源:functions.php


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