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


PHP StringUtil::length方法代码示例

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


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

示例1: execute

 /**
  * @see wcf\system\template\IModifierTemplatePlugin::execute()
  */
 public function execute($tagArgs, TemplateEngine $tplObj)
 {
     // default values
     $length = 80;
     $etc = '...';
     $breakWords = false;
     // get values
     $string = $tagArgs[0];
     if (isset($tagArgs[1])) {
         $length = intval($tagArgs[1]);
     }
     if (isset($tagArgs[2])) {
         $etc = $tagArgs[2];
     }
     if (isset($tagArgs[3])) {
         $breakWords = $tagArgs[3];
     }
     // execute plugin
     if ($length == 0) {
         return '';
     }
     if (StringUtil::length($string) > $length) {
         $length -= StringUtil::length($etc);
         if (!$breakWords) {
             $string = preg_replace('/\\s+?(\\S+)?$/', '', StringUtil::substring($string, 0, $length + 1));
         }
         return StringUtil::substring($string, 0, $length) . $etc;
     } else {
         return $string;
     }
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:34,代码来源:TruncateModifierTemplatePlugin.class.php

示例2: validate

	/**
	 * @see	wcf\system\option\IOptionType::validate()
	 */
	public function validate(Option $option, $newValue) {
		if ($option->minlength !== null && $option->minlength > StringUtil::length($newValue)) {
			throw new UserInputException($option->optionName, 'tooShort');
		}
		if ($option->maxlength !== null && $option->maxlength < StringUtil::length($newValue)) {
			throw new UserInputException($option->optionName, 'tooLong');
		}
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:11,代码来源:TextOptionType.class.php

示例3: isValidUsername

 /**
  * Returns true, if the given name is a valid username.
  * 
  * @param	string		$name		username
  * @return 	boolean
  */
 public static function isValidUsername($name)
 {
     // check illegal characters
     if (!preg_match('!^[^,\\n]+$!', $name)) {
         return false;
     }
     // check long words
     $words = preg_split('!\\s+!', $name, -1, PREG_SPLIT_NO_EMPTY);
     foreach ($words as $word) {
         if (StringUtil::length($word) > 20) {
             return false;
         }
     }
     return true;
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:21,代码来源:UserUtil.class.php

示例4: validate

 /**
  * @see wcf\form\IForm::validate()
  */
 public function validate()
 {
     ACPForm::validate();
     if (empty($this->masterPassword)) {
         throw new UserInputException('masterPassword');
     }
     // check password security
     if (StringUtil::length($this->masterPassword) < 8) {
         throw new UserInputException('masterPassword', 'notSecure');
     }
     // digits
     if (!Regex::compile('\\d')->match($this->masterPassword)) {
         throw new UserInputException('masterPassword', 'notSecure');
     }
     // latin characters (lower-case)
     if (!Regex::compile('[a-z]')->match($this->masterPassword)) {
         throw new UserInputException('masterPassword', 'notSecure');
     }
     // latin characters (upper-case)
     if (!Regex::compile('[A-Z]')->match($this->masterPassword)) {
         throw new UserInputException('masterPassword', 'notSecure');
     }
     // special characters
     if (!Regex::compile('[^0-9a-zA-Z]')->match($this->masterPassword)) {
         throw new UserInputException('masterPassword', 'notSecure');
     }
     // password equals username
     if ($this->masterPassword == WCF::getUser()->username) {
         throw new UserInputException('masterPassword', 'notSecure');
     }
     // search for identical admin passwords
     $sql = "SELECT\tpassword, salt\n\t\t\tFROM\twcf" . WCF_N . "_user\n\t\t\tWHERE\tuserID IN (\n\t\t\t\t\tSELECT\tuserID\n\t\t\t\t\tFROM\twcf" . WCF_N . "_user_to_group\n\t\t\t\t\tWHERE\tgroupID = 4\n\t\t\t\t)";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute();
     while ($row = $statement->fetchArray()) {
         if (StringUtil::getDoubleSaltedHash($this->masterPassword, $row['salt']) == $row['password']) {
             throw new UserInputException('masterPassword', 'notSecure');
         }
     }
     // confirm master password
     if (empty($this->confirmMasterPassword)) {
         throw new UserInputException('confirmMasterPassword');
     }
     if ($this->confirmMasterPassword != $this->masterPassword) {
         throw new UserInputException('confirmMasterPassword', 'notEqual');
     }
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:50,代码来源:MasterPasswordInitForm.class.php

示例5: validate

	/**
	 * @see	wcf\form\IForm::validate()
	 */
	public function validate() {
		AbstractForm::validate();
		
		if (empty($this->masterPassword)) {
			throw new UserInputException('masterPassword');
		}
		
		// check password security
		if (StringUtil::length($this->masterPassword) < 8) {
			throw new UserInputException('masterPassword', 'notSecure');
		}
		// digits
		if (!Regex::compile('\d')->match($this->masterPassword)) {
			throw new UserInputException('masterPassword', 'notSecure');
		}
		// latin characters (lower-case)
		if (!Regex::compile('[a-z]')->match($this->masterPassword)) {
			throw new UserInputException('masterPassword', 'notSecure');
		}
		// latin characters (upper-case)
		if (!Regex::compile('[A-Z]')->match($this->masterPassword)) {
			throw new UserInputException('masterPassword', 'notSecure');
		}
		// special characters
		if (!Regex::compile('[^0-9a-zA-Z]')->match($this->masterPassword)) {
			throw new UserInputException('masterPassword', 'notSecure');
		}
		
		// password equals username
		if ($this->masterPassword == WCF::getUser()->username) {
			throw new UserInputException('masterPassword', 'notSecure');
		}
		
		// confirm master password
		if (empty($this->confirmMasterPassword)) {
			throw new UserInputException('confirmMasterPassword');
		}
		
		if ($this->confirmMasterPassword != $this->masterPassword) {
			throw new UserInputException('confirmMasterPassword', 'notEqual');
		}
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:45,代码来源:MasterPasswordInitForm.class.php

示例6: addMbqEtPcMsg

 /**
  * add private conversation message
  *
  * @param  Object  $oMbqEtPcMsg
  * @param  Object  $oMbqEtPc
  */
 public function addMbqEtPcMsg($oMbqEtPcMsg, $oMbqEtPc)
 {
     $oConversation = $oMbqEtPc->mbqBind['oViewableConversation']->getDecoratedObject();
     //ref wcf\form\MessageForm,wcf\form\ConversationMessageAddForm
     $oMbqEtPcMsg->msgContent->setOriValue(MessageUtil::stripCrap(StringUtil::trim($oMbqEtPcMsg->msgContent->oriValue)));
     $attachmentObjectType = 'com.woltlab.wcf.conversation.message';
     $attachmentObjectID = 0;
     $tmpHash = StringUtil::getRandomID();
     $attachmentParentObjectID = 0;
     //settings
     $preParse = $enableSmilies = $enableBBCodes = $showSignature = $enableHtml = 0;
     $preParse = 1;
     if (WCF::getSession()->getPermission('user.message.canUseSmilies')) {
         $enableSmilies = 1;
     }
     //if (WCF::getSession()->getPermission('user.message.canUseHtml')) $enableHtml = 1;
     if (WCF::getSession()->getPermission('user.message.canUseBBCodes')) {
         $enableBBCodes = 1;
     }
     $showSignature = 1;
     // get max text length
     $maxTextLength = WCF::getSession()->getPermission('user.conversation.maxLength');
     //!!! use this,is better than 0
     //begin validate
     $allowedBBCodesPermission = 'user.message.allowedBBCodes';
     //validateText
     if (empty($oMbqEtPcMsg->msgContent->oriValue)) {
         MbqError::alert('', "Need message content.", '', MBQ_ERR_APP);
     }
     // check text length
     if ($maxTextLength != 0 && StringUtil::length($oMbqEtPcMsg->msgContent->oriValue) > $maxTextLength) {
         MbqError::alert('', "Message content is too long.", '', MBQ_ERR_APP);
     }
     if ($enableBBCodes && $allowedBBCodesPermission) {
         $disallowedBBCodes = BBCodeParser::getInstance()->validateBBCodes($oMbqEtPcMsg->msgContent->oriValue, ArrayUtil::trim(explode(',', WCF::getSession()->getPermission($allowedBBCodesPermission))));
         if (!empty($disallowedBBCodes)) {
             MbqError::alert('', "Message content included disallowed bbcodes.", '', MBQ_ERR_APP);
         }
     }
     // search for censored words
     if (ENABLE_CENSORSHIP) {
         $result = Censorship::getInstance()->test($oMbqEtPcMsg->msgContent->oriValue);
         if ($result) {
             MbqError::alert('', "Found censored words in message content.", '', MBQ_ERR_APP);
         }
     }
     //language
     $languageID = NULL;
     //attachment
     if (MODULE_ATTACHMENT && $attachmentObjectType) {
         $attachmentHandler = new AttachmentHandler($attachmentObjectType, $attachmentObjectID, $tmpHash, $attachmentParentObjectID);
     }
     //save
     if ($preParse) {
         // BBCodes are enabled
         if ($enableBBCodes) {
             if ($allowedBBCodesPermission) {
                 $oMbqEtPcMsg->msgContent->setOriValue(PreParser::getInstance()->parse($oMbqEtPcMsg->msgContent->oriValue, ArrayUtil::trim(explode(',', WCF::getSession()->getPermission($allowedBBCodesPermission)))));
             } else {
                 $oMbqEtPcMsg->msgContent->setOriValue(PreParser::getInstance()->parse($oMbqEtPcMsg->msgContent->oriValue));
             }
         } else {
             $oMbqEtPcMsg->msgContent->setOriValue(PreParser::getInstance()->parse($oMbqEtPcMsg->msgContent->oriValue, array()));
         }
     }
     // save message
     $data = array('conversationID' => $oConversation->conversationID, 'message' => $oMbqEtPcMsg->msgContent->oriValue, 'time' => TIME_NOW, 'userID' => WCF::getUser()->userID, 'username' => WCF::getUser()->username, 'enableBBCodes' => $enableBBCodes, 'enableHtml' => $enableHtml, 'enableSmilies' => $enableSmilies, 'showSignature' => $showSignature);
     $messageData = array('data' => $data, 'attachmentHandler' => $attachmentHandler);
     $objectAction = new ConversationMessageAction(array(), 'create', $messageData);
     $resultValues = $objectAction->executeAction();
     if ($resultValues['returnValues']->messageID) {
         $oMbqEtPcMsg->msgId->setOriValue($resultValues['returnValues']->messageID);
     } else {
         MbqError::alert('', "Can not create topic.", '', MBQ_ERR_APP);
     }
     return $oMbqEtPcMsg;
 }
开发者ID:keweiliu6,项目名称:test-kunena3,代码行数:83,代码来源:MbqWrEtPcMsg.php

示例7: validate

 /**
  * @see	wcf\form\IForm::validate()
  */
 public function validate()
 {
     // remove user doubles
     $this->user = array_unique($this->user);
     foreach ($this->user as $id => $user) {
         if ($user === null) {
             unset($this->user[$id]);
         }
     }
     if ($this->sum < 1 && !$this->isModerativ) {
         throw new UserInputException('sum', 'tooLess');
     }
     if (StringUtil::length($this->reason) > 255) {
         throw new UserInputException('reason', 'tooLong');
     }
     if (StringUtil::length($this->reason) < 3) {
         throw new UserInputException('reason', 'tooShort');
     }
     if (count($this->user) == 0) {
         throw new UserInputException('username', 'empty');
     }
     foreach ($this->user as $user) {
         if ($user->isIgnoredUser(WCF::getUser()->userID)) {
             WCF::getTPL()->assign(array('ignoredUsername' => $user->username));
             throw new UserInputException('user', 'isIgnored');
         }
     }
     if (WCF::getUser()->jCoinsBalance < $this->sum * count($this->user) && !$this->isModerativ) {
         throw new UserInputException('sum', 'tooMuch');
     }
     parent::validate();
 }
开发者ID:jacboy,项目名称:JCoins,代码行数:35,代码来源:JCoinsTransferForm.class.php

示例8: encodeAllChars

 /**
  * Returns html entities of all characters in the given string.
  * 
  * @param	string		$string
  * @return	string
  */
 public static function encodeAllChars($string)
 {
     $result = '';
     for ($i = 0, $j = StringUtil::length($string); $i < $j; $i++) {
         $char = StringUtil::substring($string, $i, 1);
         $result .= '&#' . StringUtil::getCharValue($char) . ';';
     }
     return $result;
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:15,代码来源:StringUtil.class.php

示例9: execute

 /**
  * @see \wcf\system\event\listener\IParameterizedEventListener::execute()
  */
 public function execute($eventObj, $className, $eventName, array &$parameters)
 {
     if (MODULE_JCOINS == 0 || MODULE_LIKE == 0) {
         return;
     }
     switch ($eventObj->getActionName()) {
         case 'like':
         case 'dislike':
             break;
         default:
             return;
     }
     $returnValues = $eventObj->getReturnValues();
     $returnValues = $returnValues['returnValues'];
     $objectID = $eventObj->getParameters();
     $like = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.like.likeableObject', $objectID['data']['objectType'])->getProcessor()->getObjectByID($objectID['data']['objectID']);
     // the object-user-id is unknown
     if (!$like->userID) {
         return;
     }
     $addtionalData = array('username' => \wcf\system\WCF::getUser()->username);
     if ($like->getObjectID() != 0) {
         $addtionalData['title'] = $like->getTitle();
     }
     // because a title which is to long is uncool (profile-comments)
     if (isset($addtionalData['title']) && StringUtil::length($addtionalData['title']) > 30) {
         $addtionalData['title'] = StringUtil::substring($addtionalData['title'], 0, 26);
         $addtionalData['title'] .= '...';
     }
     switch ($returnValues['oldValue']) {
         case Like::LIKE:
             if (JCOINS_RECEIVECOINS_LIKE != 0) {
                 $this->statementAction = new UserJcoinsStatementAction(array(), 'create', array('data' => array('userID' => $like->userID, 'reason' => 'wcf.jcoins.statement.like.revoke', 'sum' => JCOINS_RECEIVECOINS_LIKE * -1, 'link' => $like->getURL(), 'additionalData' => $addtionalData), 'changeBalance' => 1));
                 $this->statementAction->validateAction();
                 $this->statementAction->executeAction();
             }
             break;
         case Like::DISLIKE:
             if (JCOINS_RECEIVECOINS_DISLIKE != 0) {
                 $this->statementAction = new UserJcoinsStatementAction(array(), 'create', array('data' => array('userID' => $like->userID, 'reason' => 'wcf.jcoins.statement.dislike.revoke', 'sum' => JCOINS_RECEIVECOINS_DISLIKE * -1, 'link' => $like->getURL(), 'additionalData' => $addtionalData), 'changeBalance' => 1));
                 $this->statementAction->validateAction();
                 $this->statementAction->executeAction();
             }
             break;
     }
     switch ($returnValues['newValue']) {
         case Like::LIKE:
             if (JCOINS_RECEIVECOINS_LIKE != 0) {
                 $this->statementAction = new UserJcoinsStatementAction(array(), 'create', array('data' => array('userID' => $like->userID, 'reason' => 'wcf.jcoins.statement.like.recive', 'sum' => JCOINS_RECEIVECOINS_LIKE, 'link' => $like->getURL(), 'additionalData' => $addtionalData), 'changeBalance' => 1));
                 $this->statementAction->validateAction();
                 $this->statementAction->executeAction();
             }
             break;
         case Like::DISLIKE:
             if (JCOINS_RECEIVECOINS_DISLIKE != 0) {
                 $this->statementAction = new UserJcoinsStatementAction(array(), 'create', array('data' => array('userID' => $like->userID, 'reason' => 'wcf.jcoins.statement.dislike.recive', 'sum' => JCOINS_RECEIVECOINS_DISLIKE, 'link' => $like->getURL(), 'additionalData' => $addtionalData), 'changeBalance' => 1));
                 $this->statementAction->validateAction();
                 $this->statementAction->executeAction();
             }
             break;
     }
 }
开发者ID:jacboy,项目名称:JCoins,代码行数:65,代码来源:JCoinsLikeActionListener.class.php

示例10: addMbqEtForumTopic

 /**
  * add forum topic
  *
  * @param  $oMbqEtForumTopic
  */
 public function addMbqEtForumTopic($oMbqEtForumTopic)
 {
     $oMbqRdEtForum = MbqMain::$oClk->newObj('MbqRdEtForum');
     $objsMbqEtForum = $oMbqRdEtForum->getObjsMbqEtForum(array($oMbqEtForumTopic->forumId->oriValue), array('case' => 'byForumIds'));
     if ($oMbqEtForum = $objsMbqEtForum[0]) {
         $oBoard = $oMbqEtForum->mbqBind['oDetailedBoardNode']->getBoard();
     } else {
         MbqError::alert('', "Need valid forum.", '', MBQ_ERR_APP);
     }
     //ref wcf\form\MessageForm,wbb\form\ThreadAddForm
     $oMbqEtForumTopic->topicTitle->setOriValue(StringUtil::trim($oMbqEtForumTopic->topicTitle->oriValue));
     $oMbqEtForumTopic->topicContent->setOriValue(MessageUtil::stripCrap(StringUtil::trim($oMbqEtForumTopic->topicContent->oriValue)));
     $attachmentObjectType = 'com.woltlab.wbb.post';
     $attachmentObjectID = 0;
     $tmpHash = $oMbqEtForumTopic->groupId->oriValue ? $oMbqEtForumTopic->groupId->oriValue : StringUtil::getRandomID();
     $attachmentParentObjectID = $oBoard->boardID;
     //settings
     $preParse = $enableSmilies = $enableBBCodes = $showSignature = $subscribeThread = $enableHtml = 0;
     $preParse = 1;
     if (WCF::getSession()->getPermission('user.message.canUseSmilies')) {
         $enableSmilies = 1;
     }
     //if (WCF::getSession()->getPermission('user.message.canUseHtml')) $enableHtml = 1;
     if (WCF::getSession()->getPermission('user.message.canUseBBCodes')) {
         $enableBBCodes = 1;
     }
     $showSignature = 1;
     $subscribeThread = 1;
     $type = Thread::TYPE_DEFAULT;
     // get max text length
     $maxTextLength = WCF::getSession()->getPermission('user.board.maxPostLength');
     $minCharLength = WBB_THREAD_MIN_CHAR_LENGTH;
     $minWordCount = WBB_THREAD_MIN_WORD_COUNT;
     //begin validate
     $allowedBBCodesPermission = 'user.message.allowedBBCodes';
     //validateSubject
     if (empty($oMbqEtForumTopic->topicTitle->oriValue)) {
         MbqError::alert('', "Need topic title.", '', MBQ_ERR_APP);
     }
     if (StringUtil::length($oMbqEtForumTopic->topicTitle->oriValue) > 255) {
         MbqError::alert('', "Topic title is too long.", '', MBQ_ERR_APP);
     }
     // search for censored words
     if (ENABLE_CENSORSHIP) {
         $result = Censorship::getInstance()->test($oMbqEtForumTopic->topicTitle->oriValue);
         if ($result) {
             MbqError::alert('', "Found censored words in topic title.", '', MBQ_ERR_APP);
         }
     }
     //validateText
     if (empty($oMbqEtForumTopic->topicContent->oriValue)) {
         MbqError::alert('', "Need topic content.", '', MBQ_ERR_APP);
     }
     // check text length
     if ($maxTextLength != 0 && StringUtil::length($oMbqEtForumTopic->topicContent->oriValue) > $maxTextLength) {
         MbqError::alert('', "Topic content is too long.", '', MBQ_ERR_APP);
     }
     if ($enableBBCodes && $allowedBBCodesPermission) {
         $disallowedBBCodes = BBCodeParser::getInstance()->validateBBCodes($oMbqEtForumTopic->topicContent->oriValue, ArrayUtil::trim(explode(',', WCF::getSession()->getPermission($allowedBBCodesPermission))));
         if (!empty($disallowedBBCodes)) {
             MbqError::alert('', "Topic content included disallowed bbcodes.", '', MBQ_ERR_APP);
         }
     }
     // search for censored words
     if (ENABLE_CENSORSHIP) {
         $result = Censorship::getInstance()->test($oMbqEtForumTopic->topicContent->oriValue);
         if ($result) {
             MbqError::alert('', "Found censored words in topic content.", '', MBQ_ERR_APP);
         }
     }
     if ($minCharLength && StringUtil::length($oMbqEtForumTopic->topicContent->oriValue) < $minCharLength) {
         MbqError::alert('', "Topic content is too short.", '', MBQ_ERR_APP);
     }
     if ($minWordCount && count(explode(' ', $oMbqEtForumTopic->topicContent->oriValue)) < $minWordCount) {
         MbqError::alert('', "Need more words in topic content", '', MBQ_ERR_APP);
     }
     //language
     //$languageID = LanguageFactory::getInstance()->getUserLanguage()->languageID;
     $languageID = NULL;
     //attachment
     if (MODULE_ATTACHMENT && $attachmentObjectType) {
         $attachmentHandler = new AttachmentHandler($attachmentObjectType, $attachmentObjectID, $tmpHash, $attachmentParentObjectID);
     }
     //save
     if ($preParse) {
         // BBCodes are enabled
         if ($enableBBCodes) {
             if ($allowedBBCodesPermission) {
                 $oMbqEtForumTopic->topicContent->setOriValue(PreParser::getInstance()->parse($oMbqEtForumTopic->topicContent->oriValue, ArrayUtil::trim(explode(',', WCF::getSession()->getPermission($allowedBBCodesPermission)))));
             } else {
                 $oMbqEtForumTopic->topicContent->setOriValue(PreParser::getInstance()->parse($oMbqEtForumTopic->topicContent->oriValue));
             }
         } else {
             $oMbqEtForumTopic->topicContent->setOriValue(PreParser::getInstance()->parse($oMbqEtForumTopic->topicContent->oriValue, array()));
         }
//.........这里部分代码省略.........
开发者ID:keweiliu6,项目名称:test-kunena3,代码行数:101,代码来源:MbqWrEtForumTopic.php

示例11: mdfMbqEtForumPost

 /**
  * modify forum post
  *
  * @param $oMbqEtForumPost
  */
 public function mdfMbqEtForumPost($oMbqEtForumPost, $mbqOpt)
 {
     $oBoard = $oMbqEtForumPost->oMbqEtForumTopic->oMbqEtForum->mbqBind['oDetailedBoardNode']->getBoard();
     $oThread = $oMbqEtForumPost->oMbqEtForumTopic->mbqBind['oViewableThread']->getDecoratedObject();
     $oPost = $oMbqEtForumPost->mbqBind['oViewablePost']->getDecoratedObject();
     //ref wbb\form\PostEditForm,wcf\form\MessageForm,wbb\form\ThreadAddForm
     $oMbqEtForumPost->postTitle->setOriValue(StringUtil::trim($oMbqEtForumPost->postTitle->oriValue));
     $oMbqEtForumPost->postContent->setOriValue(MessageUtil::stripCrap(StringUtil::trim($oMbqEtForumPost->postContent->oriValue)));
     $editReason = '';
     $attachmentObjectType = 'com.woltlab.wbb.post';
     $attachmentObjectID = $oMbqEtForumPost->postId->oriValue;
     if ($oThread->firstPostID == $oMbqEtForumPost->postId->oriValue) {
         $enableMultilingualism = true;
         $isFirstPost = true;
     }
     $tmpHash = StringUtil::getRandomID();
     $attachmentParentObjectID = $oBoard->boardID;
     //$attachmentParentObjectID = 0;
     //settings
     $preParse = $enableSmilies = $enableBBCodes = $showSignature = $subscribeThread = $enableHtml = 0;
     $preParse = 1;
     if (WCF::getSession()->getPermission('user.message.canUseSmilies')) {
         $enableSmilies = 1;
     }
     //if (WCF::getSession()->getPermission('user.message.canUseHtml')) $enableHtml = 1;
     if (WCF::getSession()->getPermission('user.message.canUseBBCodes')) {
         $enableBBCodes = 1;
     }
     $showSignature = 1;
     $subscribeThread = 1;
     $type = Thread::TYPE_DEFAULT;
     if ($oThread->isSticky) {
         $type = Thread::TYPE_STICKY;
     } elseif ($oThread->isAnnouncement) {
         MbqError::alert('', __METHOD__ . ',line:' . __LINE__ . '.' . 'Sorry,do not support announcement type.');
     }
     if ($oBoard->getPermission('canHideEditNote')) {
         $hideEditNote = true;
     } else {
         $hideEditNote = false;
     }
     // get max text length
     $maxTextLength = WCF::getSession()->getPermission('user.board.maxPostLength');
     $minCharLength = WBB_POST_MIN_CHAR_LENGTH;
     $minWordCount = WBB_POST_MIN_WORD_COUNT;
     //begin validate
     $allowedBBCodesPermission = 'user.message.allowedBBCodes';
     //validateSubject
     if (StringUtil::length($oMbqEtForumPost->postTitle->oriValue) > 255) {
         MbqError::alert('', "Post title is too long.", '', MBQ_ERR_APP);
     }
     // search for censored words
     if (ENABLE_CENSORSHIP) {
         $result = Censorship::getInstance()->test($oMbqEtForumPost->postTitle->oriValue);
         if ($result) {
             MbqError::alert('', "Found censored words in post title.", '', MBQ_ERR_APP);
         }
     }
     //validateText
     if (empty($oMbqEtForumPost->postContent->oriValue)) {
         MbqError::alert('', "Need post content.", '', MBQ_ERR_APP);
     }
     // check text length
     if ($maxTextLength != 0 && StringUtil::length($oMbqEtForumPost->postContent->oriValue) > $maxTextLength) {
         MbqError::alert('', "Post content is too long.", '', MBQ_ERR_APP);
     }
     if ($enableBBCodes && $allowedBBCodesPermission) {
         $disallowedBBCodes = BBCodeParser::getInstance()->validateBBCodes($oMbqEtForumPost->postContent->oriValue, ArrayUtil::trim(explode(',', WCF::getSession()->getPermission($allowedBBCodesPermission))));
         if (!empty($disallowedBBCodes)) {
             MbqError::alert('', "Post content included disallowed bbcodes.", '', MBQ_ERR_APP);
         }
     }
     // search for censored words
     if (ENABLE_CENSORSHIP) {
         $result = Censorship::getInstance()->test($oMbqEtForumPost->postContent->oriValue);
         if ($result) {
             MbqError::alert('', "Found censored words in post content.", '', MBQ_ERR_APP);
         }
     }
     if ($minCharLength && StringUtil::length($oMbqEtForumPost->postContent->oriValue) < $minCharLength) {
         MbqError::alert('', "Post content is too short.", '', MBQ_ERR_APP);
     }
     if ($minWordCount && count(explode(' ', $oMbqEtForumPost->postContent->oriValue)) < $minWordCount) {
         MbqError::alert('', "Need more words in Post content", '', MBQ_ERR_APP);
     }
     //attachment
     if (MODULE_ATTACHMENT && $attachmentObjectType) {
         $attachmentHandler = new AttachmentHandler($attachmentObjectType, $attachmentObjectID, $tmpHash, $attachmentParentObjectID);
     }
     //save
     if ($preParse) {
         // BBCodes are enabled
         if ($enableBBCodes) {
             if ($allowedBBCodesPermission) {
                 $oMbqEtForumPost->postContent->setOriValue(PreParser::getInstance()->parse($oMbqEtForumPost->postContent->oriValue, ArrayUtil::trim(explode(',', WCF::getSession()->getPermission($allowedBBCodesPermission)))));
//.........这里部分代码省略.........
开发者ID:keweiliu6,项目名称:test-kunena3,代码行数:101,代码来源:MbqWrEtForumPost.php

示例12: addMbqEtPc

 /**
  * add private conversation
  *
  * @param  Object  $oMbqEtPc
  */
 public function addMbqEtPc($oMbqEtPc)
 {
     //ref wcf\form\MessageForm,wcf\form\ConversationAddForm
     $oMbqEtPc->convTitle->setOriValue(StringUtil::trim($oMbqEtPc->convTitle->oriValue));
     $oMbqEtPc->convContent->setOriValue(MessageUtil::stripCrap(StringUtil::trim($oMbqEtPc->convContent->oriValue)));
     $attachmentObjectType = 'com.woltlab.wcf.conversation.message';
     $attachmentObjectID = 0;
     $tmpHash = StringUtil::getRandomID();
     $attachmentParentObjectID = 0;
     // check max pc permission
     if (ConversationHandler::getInstance()->getConversationCount() >= WCF::getSession()->getPermission('user.conversation.maxConversations')) {
         MbqError::alert('', 'Sorry.You can not create more conversations.', '', MBQ_ERR_APP);
     }
     //settings
     $preParse = $enableSmilies = $enableBBCodes = $showSignature = $enableHtml = 0;
     $preParse = 1;
     if (WCF::getSession()->getPermission('user.message.canUseSmilies')) {
         $enableSmilies = 1;
     }
     //if (WCF::getSession()->getPermission('user.message.canUseHtml')) $enableHtml = 1;
     if (WCF::getSession()->getPermission('user.message.canUseBBCodes')) {
         $enableBBCodes = 1;
     }
     $showSignature = 1;
     // get max text length
     $maxTextLength = WCF::getSession()->getPermission('user.conversation.maxLength');
     //begin validate
     try {
         $participantIDs = Conversation::validateParticipants(implode(",", $oMbqEtPc->userNames->oriValue));
     } catch (UserInputException $e) {
         MbqError::alert('', $e->getMessage(), '', MBQ_ERR_APP);
     } catch (Exception $e) {
         MbqError::alert('', $e->getMessage(), '', MBQ_ERR_APP);
     }
     if (empty($participantIDs)) {
         MbqError::alert('', 'Need valid participant user ids.', '', MBQ_ERR_APP);
     }
     // check number of participants
     if (count($participantIDs) > WCF::getSession()->getPermission('user.conversation.maxParticipants')) {
         MbqError::alert('', 'Too many participants.', '', MBQ_ERR_APP);
     }
     $allowedBBCodesPermission = 'user.message.allowedBBCodes';
     //validateSubject
     if (empty($oMbqEtPc->convTitle->oriValue)) {
         MbqError::alert('', "Need conversation title.", '', MBQ_ERR_APP);
     }
     if (StringUtil::length($oMbqEtPc->convTitle->oriValue) > 255) {
         MbqError::alert('', "Conversation title is too long.", '', MBQ_ERR_APP);
     }
     // search for censored words
     if (ENABLE_CENSORSHIP) {
         $result = Censorship::getInstance()->test($oMbqEtPc->convTitle->oriValue);
         if ($result) {
             MbqError::alert('', "Found censored words in conversation title.", '', MBQ_ERR_APP);
         }
     }
     //validateText
     if (empty($oMbqEtPc->convContent->oriValue)) {
         MbqError::alert('', "Need conversation content.", '', MBQ_ERR_APP);
     }
     // check text length
     if ($maxTextLength != 0 && StringUtil::length($oMbqEtPc->convContent->oriValue) > $maxTextLength) {
         MbqError::alert('', "Conversation content is too long.", '', MBQ_ERR_APP);
     }
     if ($enableBBCodes && $allowedBBCodesPermission) {
         $disallowedBBCodes = BBCodeParser::getInstance()->validateBBCodes($oMbqEtPc->convContent->oriValue, ArrayUtil::trim(explode(',', WCF::getSession()->getPermission($allowedBBCodesPermission))));
         if (!empty($disallowedBBCodes)) {
             MbqError::alert('', "Conversation content included disallowed bbcodes.", '', MBQ_ERR_APP);
         }
     }
     // search for censored words
     if (ENABLE_CENSORSHIP) {
         $result = Censorship::getInstance()->test($oMbqEtPc->convContent->oriValue);
         if ($result) {
             MbqError::alert('', "Found censored words in conversation content.", '', MBQ_ERR_APP);
         }
     }
     //language
     $languageID = NULL;
     //attachment
     if (MODULE_ATTACHMENT && $attachmentObjectType) {
         $attachmentHandler = new AttachmentHandler($attachmentObjectType, $attachmentObjectID, $tmpHash, $attachmentParentObjectID);
     }
     //save
     if ($preParse) {
         // BBCodes are enabled
         if ($enableBBCodes) {
             if ($allowedBBCodesPermission) {
                 $oMbqEtPc->convContent->setOriValue(PreParser::getInstance()->parse($oMbqEtPc->convContent->oriValue, ArrayUtil::trim(explode(',', WCF::getSession()->getPermission($allowedBBCodesPermission)))));
             } else {
                 $oMbqEtPc->convContent->setOriValue(PreParser::getInstance()->parse($oMbqEtPc->convContent->oriValue));
             }
         } else {
             $oMbqEtPc->convContent->setOriValue(PreParser::getInstance()->parse($oMbqEtPc->convContent->oriValue, array()));
         }
//.........这里部分代码省略.........
开发者ID:keweiliu6,项目名称:test-kunena3,代码行数:101,代码来源:MbqWrEtPc.php

示例13: compileTag

	/**
	 * Compiles a template tag.
	 * 
	 * @param	string		$tag
	 * @param	string		$identifier
	 * @param	array		$metaData
	 */
	protected function compileTag($tag, $identifier, array &$metaData) {
		if (preg_match('~^'.$this->outputPattern.'~s', $tag)) {
			// variable output
			return $this->compileOutputTag($tag);
		}
		
		$match = array();
		// replace 'else if' with 'elseif'
		$tag = preg_replace('~^else\s+if(?=\s)~i', 'elseif', $tag);
		
		if (preg_match('~^(/?\w+)~', $tag, $match)) {
			// build in function or plugin
			$tagCommand = $match[1];
			$tagArgs = StringUtil::substring($tag, StringUtil::length($tagCommand));
			
			switch ($tagCommand) {
				case 'if':
					$this->pushTag('if');
					return $this->compileIfTag($tagArgs);
					
				case 'elseif':
					list($openTag) = end($this->tagStack);
					if ($openTag != 'if' && $openTag != 'elseif') {
						throw new SystemException($this->formatSyntaxError('unxepected {elseif}', $this->currentIdentifier, $this->currentLineNo));
					}
					else if ($openTag == 'if') {
						$this->pushTag('elseif');
					}
					return $this->compileIfTag($tagArgs, true);
					
				case 'else':
					list($openTag) = end($this->tagStack);
					if ($openTag != 'if' && $openTag != 'elseif') {
						throw new SystemException($this->formatSyntaxError('unexpected {else}', $this->currentIdentifier, $this->currentLineNo));
					}
					$this->pushTag('else');
					return '<?php } else { ?>';
					
				case '/if':
					list($openTag) = end($this->tagStack);
					if ($openTag != 'if' && $openTag != 'elseif' && $openTag != 'else') {
						throw new SystemException($this->formatSyntaxError('unexpected {/if}', $this->currentIdentifier, $this->currentLineNo));
					}
					$this->popTag('if');
					return '<?php } ?>';
					
				case 'include':
					return $this->compileIncludeTag($tagArgs, $identifier, $metaData);
					
				case 'foreach':
					$this->pushTag('foreach');
					return $this->compileForeachTag($tagArgs);
					
				case 'foreachelse':
					list($openTag) = end($this->tagStack);
					if ($openTag != 'foreach') {
						throw new SystemException($this->formatSyntaxError('unexpected {foreachelse}', $this->currentIdentifier, $this->currentLineNo));
					}
					$this->pushTag('foreachelse');
					return '<?php } } else { { ?>';
					
				case '/foreach':
					list($openTag) = end($this->tagStack);
					if ($openTag != 'foreach' && $openTag != 'foreachelse') {
						throw new SystemException($this->formatSyntaxError('unexpected {/foreach}', $this->currentIdentifier, $this->currentLineNo));
					}
					$this->popTag('foreach');
					return "<?php } } ?>";
					
				case 'section':
					$this->pushTag('section');
					return $this->compileSectionTag($tagArgs);
					
				case 'sectionelse':
					list($openTag) = end($this->tagStack);
					if ($openTag != 'section') {
						throw new SystemException($this->formatSyntaxError('unexpected {sectionelse}', $this->currentIdentifier, $this->currentLineNo));
					}
					$this->pushTag('sectionelse');
					return '<?php } } else { { ?>';
					
				case '/section':
					list($openTag) = end($this->tagStack);
					if ($openTag != 'section' && $openTag != 'sectionelse') {
						throw new SystemException($this->formatSyntaxError('unexpected {/section}', $this->currentIdentifier, $this->currentLineNo));
					}
					$this->popTag('section');
					return "<?php } } ?>";
					
				case 'capture':
					$this->pushTag('capture');
					return $this->compileCaptureTag(true, $tagArgs);
					
//.........这里部分代码省略.........
开发者ID:0xLeon,项目名称:WCF,代码行数:101,代码来源:TemplateScriptingCompiler.class.php

示例14: readPackages

	/**
	 * Read available packages.
	 */
	protected function readPackages() {
		$sql = "SELECT		*
			FROM		wcf".WCF_N."_package
			ORDER BY	packageName";
		$statement = WCF::getDB()->prepareStatement($sql);
		$statement->execute(array($this->languageID));
		while ($row = $statement->fetchArray()) {
			$row['packageNameLength'] = StringUtil::length(WCF::getLanguage()->get($row['packageName']));
			$this->packages[] = new Package(null, $row);
			if ($row['packageNameLength'] > $this->packageNameLength) {
				$this->packageNameLength = $row['packageNameLength'];	
			} 
		}
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:17,代码来源:LanguageExportForm.class.php


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