本文整理汇总了PHP中wcf\util\ArrayUtil::trim方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayUtil::trim方法的具体用法?PHP ArrayUtil::trim怎么用?PHP ArrayUtil::trim使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wcf\util\ArrayUtil
的用法示例。
在下文中一共展示了ArrayUtil::trim方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseKeywords
/**
* Parses search keywords.
*
* @param string $keywordString
*/
protected function parseKeywords($keywordString)
{
// convert encoding if necessary
if (!StringUtil::isUTF8($keywordString)) {
$keywordString = StringUtil::convertEncoding('ISO-8859-1', 'UTF-8', $keywordString);
}
// remove bad wildcards
$keywordString = preg_replace('/(?<!\\w)\\*/', '', $keywordString);
// remove search operators
$keywordString = preg_replace('/[\\+\\-><()~]+/', '', $keywordString);
if (mb_substr($keywordString, 0, 1) == '"' && mb_substr($keywordString, -1) == '"') {
// phrases search
$keywordString = StringUtil::trim(mb_substr($keywordString, 1, -1));
if (!empty($keywordString)) {
$this->keywords = array_merge($this->keywords, array(StringUtil::encodeHTML($keywordString)));
}
} else {
// replace word delimiters by space
$keywordString = str_replace(array('.', ','), ' ', $keywordString);
$keywords = ArrayUtil::encodeHTML(ArrayUtil::trim(explode(' ', $keywordString)));
if (!empty($keywords)) {
$this->keywords = array_merge($this->keywords, $keywords);
}
}
}
示例2: getCondition
/**
* @see wcf\system\option\ISearchableUserOption::getCondition()
*/
public function getCondition(PreparedStatementConditionBuilder &$conditions, Option $option, $value) {
if (!is_array($value) || empty($value)) return false;
$value = ArrayUtil::trim($value);
if (empty($value)) return false;
$conditions->add("option_value.userOption".$option->optionID." = ?", array(implode("\n", $value)));
return true;
}
示例3: validate
/**
* @see \wcf\system\option\IOptionType::validate()
*/
public function validate(Option $option, $newValue)
{
parent::validate($option, $newValue);
if ($option->allowedbbcodepermission) {
$disallowedBBCodes = BBCodeParser::getInstance()->validateBBCodes($newValue, explode(',', ArrayUtil::trim(WCF::getSession()->getPermission($option->allowedbbcodepermission))));
if (!empty($disallowedBBCodes)) {
WCF::getTPL()->assign('disallowedBBCodes', $disallowedBBCodes);
throw new UserInputException($option->optionName, 'disallowedBBCodes');
}
}
}
示例4: readFormParameters
/**
* @see \wcf\form\IForm::readFormParameters()
*/
public function readFormParameters()
{
parent::readFormParameters();
if (isset($_POST['name'])) {
$this->name = StringUtil::trim($_POST['name']);
}
if (isset($_POST['languageID'])) {
$this->languageID = intval($_POST['languageID']);
}
// actually these are synonyms
if (isset($_POST['tags']) && is_array($_POST['tags'])) {
$this->synonyms = ArrayUtil::trim($_POST['tags']);
}
}
示例5: getParsedTag
public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser)
{
// copyright
TeraliosBBCodesCopyright::callCopyright();
// first attribut is icon!
$icon = isset($openingTag['attributes'][0]) ? StringUtil::trim($openingTag['attributes'][0]) : 'fa-rebel';
// Yes, Rebel icon as default icon! ;)
if (substr($icon, 0, 3) != 'fa-') {
$icon = 'fa-' . $icon;
}
// map attributes
$this->mapAttributes(ArrayUtil::trim($openingTag['attributes']));
return '<span class="icon' . ($this->size > 0 ? ' icon' . $this->size : '') . ' ' . $icon . ($this->float != 'none' ? ' iconBB' . ucfirst($this->float) : '') . ' iconBBCode"></span>';
}
示例6: readFormParameters
public function readFormParameters()
{
parent::readFormParameters();
if (isset($_POST['tags']) && is_array($_POST['tags'])) {
$this->tags = ArrayUtil::trim($_POST['tags']);
}
if (isset($_POST['time'])) {
$this->time = $_POST['time'];
}
if (isset($_POST['imageID'])) {
$this->imageID = intval($_POST['imageID']);
}
if (isset($_POST['teaser'])) {
$this->teaser = StringUtil::trim($_POST['teaser']);
}
if (MODULE_POLL && WCF::getSession()->getPermission('user.cms.news.canStartPoll')) {
PollManager::getInstance()->readFormParameters();
}
}
示例7: getMessagePreview
/**
* Returns a rendered message preview.
*
* @return array
*/
public function getMessagePreview()
{
// get options
$enableBBCodes = isset($this->parameters['options']['enableBBCodes']) ? 1 : 0;
$enableHtml = isset($this->parameters['options']['enableHtml']) ? 1 : 0;
$enableSmilies = isset($this->parameters['options']['enableSmilies']) ? 1 : 0;
$preParse = isset($this->parameters['options']['preParse']) ? 1 : 0;
$allowedBBCodesPermission = isset($this->parameters['allowedBBCodesPermission']) ? $this->parameters['allowedBBCodesPermission'] : 'user.message.allowedBBCodes';
// validate permissions for options
if ($enableBBCodes && !WCF::getSession()->getPermission('user.message.canUseBBCodes')) {
$enableBBCodes = 0;
}
if ($enableHtml && !WCF::getSession()->getPermission('user.message.canUseHtml')) {
$enableHtml = 0;
}
if ($enableSmilies && !WCF::getSession()->getPermission('user.message.canUseSmilies')) {
$enableSmilies = 0;
}
// check if disallowed bbcode are used
if ($enableBBCodes && $allowedBBCodesPermission) {
$disallowedBBCodes = MessageParser::getInstance()->validateBBCodes($this->parameters['data']['message'], ArrayUtil::trim(explode(',', WCF::getSession()->getPermission($allowedBBCodesPermission))));
if (!empty($disallowedBBCodes)) {
throw new UserInputException('message', WCF::getLanguage()->getDynamicVariable('wcf.message.error.disallowedBBCodes', array('disallowedBBCodes' => $disallowedBBCodes)));
}
}
// get message
$message = StringUtil::trim($this->parameters['data']['message']);
// get embedded objects
MessageEmbeddedObjectManager::getInstance()->parseTemporaryMessage($message);
// parse URLs
if ($preParse && $enableBBCodes) {
if ($allowedBBCodesPermission) {
$message = PreParser::getInstance()->parse($message, ArrayUtil::trim(explode(',', WCF::getSession()->getPermission($allowedBBCodesPermission))));
} else {
$message = PreParser::getInstance()->parse($message);
}
}
// parse message
$preview = MessageParser::getInstance()->parse($message, $enableSmilies, $enableHtml, $enableBBCodes, false);
return array('message' => $preview);
}
示例8: getFirstParameters
/**
* Parses given message for specific bbcode parameters.
*
* @param string $message
* @param string $bbcode bbcode name
* @return array
*/
public static function getFirstParameters($message, $bbcode)
{
$pattern = '~\\[' . $bbcode . '=
(\'(?:[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'|(?:[^,\\]]*))
(?:,(?:\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|[^,\\]]*))*
\\]~ix';
if (preg_match_all($pattern, $message, $matches)) {
foreach ($matches[1] as &$value) {
// remove quotes
if (mb_substr($value, 0, 1) == "'" && mb_substr($value, -1) == "'") {
$value = str_replace("\\'", "'", $value);
$value = str_replace("\\\\", "\\", $value);
$value = mb_substr($value, 1, -1);
}
}
$results = ArrayUtil::trim($matches[1]);
$results = array_unique($results);
return $results;
}
return array();
}
示例9: readParameters
/**
* @see \wcf\action\IAction::readParameters()
*/
public function readParameters()
{
AbstractSecureAction::readParameters();
if (isset($_POST['actionName'])) {
$this->actionName = StringUtil::trim($_POST['actionName']);
}
if (isset($_POST['getFullQuoteObjectIDs'])) {
$this->_getFullQuoteObjectIDs = intval($_POST['getFullQuoteObjectIDs']);
}
if (isset($_POST['objectTypes']) && is_array($_POST['objectTypes'])) {
$this->objectTypes = ArrayUtil::trim($_POST['objectTypes']);
}
if (isset($_POST['quoteIDs'])) {
$this->quoteIDs = ArrayUtil::trim($_POST['quoteIDs']);
// validate quote ids
foreach ($this->quoteIDs as $key => $quoteID) {
if (MessageQuoteManager::getInstance()->getQuote($quoteID) === null) {
unset($this->quoteIDs[$key]);
}
}
}
}
示例10: init
/**
* @see \wcf\system\SingletonFactory::init()
*/
protected function init()
{
if (isset($_GET['highlight'])) {
$keywordString = $_GET['highlight'];
// remove search operators
$keywordString = preg_replace('/[\\+\\-><()~\\*]+/', '', $keywordString);
if (mb_substr($keywordString, 0, 1) == '"' && mb_substr($keywordString, -1) == '"') {
// phrases search
$keywordString = StringUtil::trim(mb_substr($keywordString, 1, -1));
if (!empty($keywordString)) {
$this->searchQuery = $keywordString;
}
} else {
$this->searchQuery = ArrayUtil::trim(explode(' ', $keywordString));
if (empty($this->searchQuery)) {
$this->searchQuery = false;
} else {
if (count($this->searchQuery) == 1) {
$this->searchQuery = reset($this->searchQuery);
}
}
}
}
}
示例11: readFormParameters
/**
* @see \wcf\form\IForm::readFormParameters()
*/
public function readFormParameters()
{
parent::readFormParameters();
if (isset($_POST['enableDelayedPublication'])) {
$this->enableDelayedPublication = intval($_POST['enableDelayedPublication']);
}
if (isset($_POST['publicationDate'])) {
$this->publicationDate = $_POST['publicationDate'];
}
if (isset($_POST['enableAutomaticArchiving'])) {
$this->enableAutomaticArchiving = intval($_POST['enableAutomaticArchiving']);
}
if (isset($_POST['archivingDate'])) {
$this->archivingDate = $_POST['archivingDate'];
}
if (isset($_POST['teaser'])) {
$this->teaser = StringUtil::trim($_POST['teaser']);
}
if (isset($_POST['tags']) && is_array($_POST['tags'])) {
$this->tags = ArrayUtil::trim($_POST['tags']);
}
if (isset($_POST['isHot'])) {
$this->isHot = intval($_POST['isHot']);
}
// news picture
if (NEWS_ENABLE_NEWSPICTURE) {
if (isset($_POST['pictureID'])) {
$this->pictureID = intval($_POST['pictureID']);
}
$this->picture = new NewsPicture($this->pictureID);
}
// sources
if (NEWS_ENTRY_ENABLE_SOURCES && isset($_POST['sourceLink']) && is_array($_POST['sourceLink']) && isset($_POST['sourceText']) && is_array($_POST['sourceText'])) {
$sourceLinks = $_POST['sourceLink'];
$sourceTexts = $_POST['sourceText'];
foreach ($sourceLinks as $index => $sourceLink) {
$this->sources[$index] = array('sourceLink' => StringUtil::trim($sourceLink));
if (isset($sourceTexts[$index])) {
$this->sources[$index]['sourceText'] = StringUtil::trim($sourceTexts[$index]);
unset($sourceTexts[$index]);
}
}
foreach ($sourceTexts as $index => $sourceText) {
$this->sources[$index] = array('sourceText' => StringUtil::trim($sourceText));
}
}
// quotes
MessageQuoteManager::getInstance()->readFormParameters();
// polls
if ($this->canCreatePoll()) {
PollManager::getInstance()->readFormParameters();
}
}
示例12: readFormParameters
/**
* @see wcf\form\IForm::readFormParameters()
*/
public function readFormParameters()
{
parent::readFormParameters();
if (isset($_POST['sum'])) {
$this->sum = (int) $_POST['sum'];
}
if (isset($_POST['reason'])) {
$this->reason = StringUtil::trim($_POST['reason']);
}
if (isset($_POST['username'])) {
$this->usernames = StringUtil::trim($_POST['username']);
}
if (isset($_POST['isModerativ']) && $_POST['isModerativ'] == 1 && WCF::getSession()->getPermission('mod.jcoins.canModTransfer')) {
$this->isModerativ = 1;
}
if (count(explode(',', $this->usernames)) > 0) {
$users = explode(',', $this->usernames);
$this->user = UserProfile::getUserProfilesByUsername(ArrayUtil::trim(explode(',', $this->usernames)));
}
}
示例13: validateParameters
/**
* Validates parameters for current request.
*
* @param \wcf\system\message\IMessageQuickReplyAction $object
* @param array<array> $parameters
* @param string $containerClassName
* @param string $containerDecoratorClassName
*/
public function validateParameters(IMessageQuickReplyAction $object, array &$parameters, $containerClassName, $containerDecoratorClassName = '')
{
if (!isset($parameters['data']['message'])) {
throw new UserInputException('message');
}
$parameters['data']['message'] = StringUtil::trim(MessageUtil::stripCrap($parameters['data']['message']));
if (empty($parameters['data']['message'])) {
throw new UserInputException('message', WCF::getLanguage()->get('wcf.global.form.error.empty'));
}
$parameters['lastPostTime'] = isset($parameters['lastPostTime']) ? intval($parameters['lastPostTime']) : 0;
if (!$parameters['lastPostTime']) {
throw new UserInputException('lastPostTime');
}
$parameters['pageNo'] = isset($parameters['pageNo']) ? intval($parameters['pageNo']) : 0;
if (!$parameters['pageNo']) {
throw new UserInputException('pageNo');
}
$parameters['objectID'] = isset($parameters['objectID']) ? intval($parameters['objectID']) : 0;
if (!$parameters['objectID']) {
throw new UserInputException('objectID');
}
$this->container = new $containerClassName($parameters['objectID']);
if (!empty($containerDecoratorClassName)) {
if (!ClassUtil::isInstanceOf($containerDecoratorClassName, 'wcf\\data\\DatabaseObjectDecorator')) {
throw new SystemException("'" . $containerDecoratorClassName . "' does not extend 'wcf\\data\\DatabaseObjectDecorator'");
}
$this->container = new $containerDecoratorClassName($this->container);
}
$object->validateContainer($this->container);
// validate message
$object->validateMessage($this->container, $parameters['data']['message']);
// check for message quote ids
$parameters['removeQuoteIDs'] = isset($parameters['removeQuoteIDs']) && is_array($parameters['removeQuoteIDs']) ? ArrayUtil::trim($parameters['removeQuoteIDs']) : array();
// check for tmp hash (attachments)
$parameters['tmpHash'] = '';
if (isset($parameters['data']['tmpHash'])) {
$parameters['tmpHash'] = StringUtil::trim($parameters['data']['tmpHash']);
unset($parameters['data']['tmpHash']);
}
// message settings
$parameters['data'] = array_merge($parameters['data'], MessageFormSettingsHandler::getSettings($parameters));
$parameters['data']['enableHtml'] = 0;
$parameters['data']['showSignature'] = WCF::getUser()->userID ? WCF::getUser()->showSignature : 0;
EventHandler::getInstance()->fireAction($this, 'validateParameters', $parameters);
}
示例14: getGenericIndexName
/**
* Creates a generic index name.
*
* @param string $tableName
* @param string $columns
* @param string $suffix
* @return string index name
*/
protected static function getGenericIndexName($tableName, $columns, $suffix = '') {
// get first column
$columns = ArrayUtil::trim(explode(',', $columns));
return md5($tableName . '_' . reset($columns)) . ($suffix ? '_' . $suffix : '');
}
示例15: addIndex
/**
* @see wcf\system\database\editor\DatabaseEditor::addIndex()
*/
public function addIndex($tableName, $indexName, $indexData) {
$columns = ArrayUtil::trim(explode(',', $indexData['columns']));
if (empty($indexName)) {
// create index name
$indexName = $tableName.'_'.(!empty($columns[0]) ? $columns[0] : 'generic').'_key';
// solve naming conflicts
$indices = $this->getIndices($tableName);
$i = 2;
while (in_array($indexName, $indices)) {
$indexName = $tableName.'_'.(!empty($columns[0]) ? $columns[0] : 'generic').'_'.$i.'_key';
$i++;
}
}
else if ($indexData['type'] != 'FULLTEXT') {
$indexName = $tableName.'_'.$indexName.'_key';
}
if ($indexData['type'] == 'FULLTEXT') {
// add new column for fulltext index
$sql = "ALTER TABLE ".$tableName." ADD COLUMN ".$indexName." tsvector";
$statement = $this->dbObj->prepareStatement($sql);
$statement->execute();
// add gin index
$sql = "CREATE INDEX ".$tableName."_".$indexName."_fulltext_key ON ".$tableName." USING gin(".$indexName.")";
$statement = $this->dbObj->prepareStatement($sql);
$statement->execute();
// update fulltext index
$sql = "UPDATE ".$tableName."
SET ".$indexName." = to_tsvector('english', \"".implode('" || \' \' || "', $columns)."\")";
$statement = $this->dbObj->prepareStatement($sql);
$statement->execute();
// add trigger
$sql = "CREATE TRIGGER ".$tableName."_".$indexName."_trigger
BEFORE INSERT OR UPDATE
ON ".$tableName."
FOR EACH ROW EXECUTE PROCEDURE
tsvector_update_trigger(".$indexName.", 'pg_catalog.english', ".implode(', ', $columns).");";
$statement = $this->dbObj->prepareStatement($sql);
$statement->execute();
}
else {
$sql = "CREATE ".($indexData['type'] == 'UNIQUE' ? "UNIQUE " : "")."INDEX ".$indexName." ON ".$tableName." (".$indexData['columns'].")";
$statement = $this->dbObj->prepareStatement($sql);
$statement->execute();
}
}