本文整理汇总了PHP中StringHelper::trim方法的典型用法代码示例。如果您正苦于以下问题:PHP StringHelper::trim方法的具体用法?PHP StringHelper::trim怎么用?PHP StringHelper::trim使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringHelper
的用法示例。
在下文中一共展示了StringHelper::trim方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($configuration, $wildcard, $anyCharactersOnLeft = FALSE, $anyCharactersOnRight = FALSE)
{
parent::__construct($configuration);
$this->wildcard = StringHelper::trim($wildcard);
$this->anyCharactersOnLeft = $anyCharactersOnLeft;
$this->anyCharactersOnRight = $anyCharactersOnRight;
}
示例2: __construct
public function __construct() {
parent::__construct();
$this->fractionDigits = StringHelper::trim($this->numberFormatter->getAttribute(NumberFormatter::FRACTION_DIGITS));
if ($this->fractionDigits === FALSE) {
throw new IllegalStateException(t('Cannot detect OS fraction digits'));
}
}
示例3: simplifyPath
protected function simplifyPath($path) {
$documentRoot = isset($_SERVER['DOCUMENT_ROOT']) ? StringHelper::trim($_SERVER['DOCUMENT_ROOT']) : NULL;
if (isset($documentRoot)) {
// 'fixing' slash
$documentRoot = str_replace(array('/', '\\'), array(DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR), $documentRoot);
}
return (isset($documentRoot) && (strpos($path, $documentRoot) === 0)) ? substr($path, strlen($documentRoot)) : $path;
}
示例4: getNextSequenceValues
public function getNextSequenceValues($datasourceName, $sequenceName, $quantity)
{
$datasourceName = StringHelper::trim($datasourceName);
$sequenceName = StringHelper::trim($sequenceName);
$callcontext = $this->prepareCallContext();
$request = new SequenceRequest($datasourceName, $sequenceName, $quantity);
LogHelper::log_debug($request);
return $this->getDataSourceQueryHandler($datasourceName)->getNextSequenceValues($callcontext, $request);
}
示例5: __construct
public function __construct($configuration, $value = NULL)
{
parent::__construct($configuration);
if (is_array($value)) {
$values = (array) $value;
throw new IllegalArgumentException(t('Only single value is supported for the operator: [@value]', array('@value' => implode(', ', $values))));
}
$parameterName = $this->getParameterName();
$this->{$parameterName} = StringHelper::trim($value);
}
示例6: getNumericFormattingElement
public function getNumericFormattingElement($elementName, $required = TRUE)
{
if (!isset($this->numericFormattingConfiguration)) {
$this->numericFormattingConfiguration = localeconv();
}
$elementValue = isset($this->numericFormattingConfiguration[$elementName]) ? StringHelper::trim($this->numericFormattingConfiguration[$elementName]) : NULL;
if (!isset($elementValue) && $required) {
throw new IllegalStateException(t('Numeric formatting information does not contain value for the element: @elementName', array('@elementName' => $elementName)));
}
return $elementValue;
}
示例7: convert
public function convert($input) {
$output = $input;
if (isset($output)) {
$output = str_replace(array("\r\n", "\n", "\t"), array(' ', ' ', ' '), $output);
$output = StringHelper::trim(preg_replace('#(\s){2,}#', ' ', $output));
}
return $output;
}
示例8: trimMap
public static function trimMap($map)
{
$trimmedMap = NULL;
if (isset($map)) {
foreach ($map as $key => $value) {
$key = StringHelper::trim($key);
$value = is_array($value) ? ArrayHelper::isIndexedArray($value) ? self::trimList($value) : self::trimMap($value) : StringHelper::trim($value);
$trimmedMap[$key] = $value;
}
}
return $trimmedMap;
}
示例9: gd_performance_admin_settings_submit
function gd_performance_admin_settings_submit ( $form, &$form_state ) {
$originalBatchSize = variable_get('gd_file_upload_batch_size', NULL);
$batchSize = StringHelper::trim($form_state['values']['file_upload_batch_size']);
if ($originalBatchSize != $batchSize) {
variable_set('gd_file_upload_batch_size', $batchSize);
$message = isset($batchSize)
? t('File upload batch size is set to @batchSize records', array('@batchSize' => $batchSize))
: t('File upload batch size is reset to default');
drupal_set_message($message);
}
}
示例10: convert
public function convert($input) {
$output = $input;
if (isset($output)) {
$output = preg_replace($this->getSingleLineCommentRegularExpression(), ' ', $output);
$output = preg_replace($this->getMultiLineCommentRegularExpression(), ' ', $output);
$output = StringHelper::trim($output);
}
return $output;
}
示例11: adjustCompositeParameter
protected function adjustCompositeParameter($compositeParameter) {
$adjustedCompositeParameter = NULL;
$parameterIndex = 0;
foreach ($compositeParameter as $key => $value) {
$adjustedKey = is_string($key) ? StringHelper::trim($key) : $key;
$adjustedValues = NULL;
if ($value instanceof OperatorHandler) {
// we do not need to change anything for the value
$adjustedValues[] = $value;
}
else {
// what if the value is a list of operators
$operatorFound = FALSE;
if (is_array($value)) {
foreach ($value as $v) {
if ($v instanceof OperatorHandler) {
$operatorFound = TRUE;
break;
}
}
}
// we found at least one operator in the list
if ($operatorFound) {
foreach ($value as $index => $v) {
$adjustedIndex = is_string($index) ? StringHelper::trim($index) : $index;
$adjustedValue = ($v instanceof OperatorHandler)
? $v
: OperatorFactory::getInstance()->initiateHandler(EqualOperatorHandler::OPERATOR__NAME, array($v));
$adjustedValue->weight = $parameterIndex++;
$adjustedValues[$adjustedIndex] = $adjustedValue;
}
}
else {
$adjustedValue = OperatorFactory::getInstance()->initiateHandler(EqualOperatorHandler::OPERATOR__NAME, array($value));
$adjustedValue->weight = $parameterIndex++;
$adjustedValues[] = $adjustedValue;
}
}
$adjustedCompositeParameter[$adjustedKey] = $adjustedValues;
}
return $adjustedCompositeParameter;
}
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:50,代码来源:DataQueryControllerRequestCleaner.php
示例12: gd_cache_admin_settings_submit
function gd_cache_admin_settings_submit($form, &$form_state) {
$text = StringHelper::trim($form_state['values']['resources']);
$resourceIds = isset($text) ? gd_cache_parse_resources($text): NULL;
$storageValue = isset($resourceIds) ? implode("\n", $resourceIds) : NULL;
if (isset($storageValue)) {
variable_set(VARIABLE_NAME__CACHE_URL, $storageValue);
$message = t('@count URLs saved', array('@count' => count($resourceIds)));
}
else {
variable_del(VARIABLE_NAME__CACHE_URL);
$message = t('List of URLs is cleared');
}
drupal_set_message($message);
}
示例13: get_node_field_value
function get_node_field_value($node, $fieldName, $index = 0, $storageSuffixName = 'value', $required = FALSE) {
$value = NULL;
if (!isset($node->language)) {
LogHelper::log_debug($node);
throw new IllegalArgumentException(t(
'%fieldName@index field is not accessible because language is not set for the node: %nodeId',
array(
'%nodeId' => $node->nid,
'%fieldName' => $fieldName,
'@index' => ((!isset($index) || ($index == 0)) ? '' : t('[%index]', array('%index' => $index))))));
}
$fieldValue = isset($node->$fieldName) ? $node->$fieldName : NULL;
if (isset($fieldValue[$node->language])) {
$fieldLocalizedValues = $fieldValue[$node->language];
if (isset($index)) {
// accessing individual value
if (isset($fieldLocalizedValues[$index][$storageSuffixName])) {
$value = StringHelper::trim($fieldLocalizedValues[$index][$storageSuffixName]);
}
}
else {
// we need to return an array of values
foreach ($fieldLocalizedValues as $i => $fieldLocalizedValue) {
$v = isset($fieldLocalizedValue[$storageSuffixName]) ? $fieldLocalizedValue[$storageSuffixName] : NULL;
if (!isset($v)) {
$v = StringHelper::trim($v);
}
$value[$i] = $v;
}
}
}
if ($required && !isset($value)) {
LogHelper::log_debug($node);
throw new IllegalArgumentException(t(
'%fieldName@index field has not been set for the node: %nodeId',
array(
'%nodeId' => $node->nid,
'%fieldName' => $fieldName,
'@index' => ((!isset($index) || ($index == 0)) ? '' : t('[%index]', array('%index' => $index))))));
}
return $value;
}
示例14: __construct
public function __construct($configuration, $pattern)
{
parent::__construct($configuration);
$this->pattern = StringHelper::trim($pattern);
}
示例15: cleanFunctionParameters
public static function cleanFunctionParameters($datasetName, $columns, $parameters, $orderBy, array $options = NULL) {
$metamodel = data_controller_get_metamodel();
$dataset = $metamodel->getDataset($datasetName);
$cleanedColumns = ArrayHelper::trim($columns);
$cleanedParameters = NULL;
if (isset($parameters)) {
foreach ($parameters as $key => $value) {
$key = StringHelper::trim($key);
// ignoring system parameters
list($elementNameSpace) = AbstractDatasetUIMetaDataGenerator::splitElementUIMetaDataName($key);
if (!isset($elementNameSpace)) {
continue;
}
$cleanedParameters[$key] = $value;
}
}
$cleanedOrderBy = NULL;
ArrayHelper::addUniqueValues($cleanedOrderBy, ArrayHelper::trim($orderBy));
$cleanedOptions = NULL;
if (isset($options)) {
foreach ($options as $name => $option) {
$cleanedOption = NULL;
if (isset($option)) {
if ($name == AbstractQueryRequest::OPTION__FORMULA_DEF) {
// cleaning all formulas
foreach ($option as $index => $formula) {
$cleanedFormula = clone $formula;
$parser = new FormulaExpressionParser($cleanedFormula->expressionLanguage);
$cleanedFormula->source = $parser->parse($cleanedFormula->source, 'DatasetUIMetaDataQueryHelper::cleanFormulaExpressionColumnNames');
$cleanedOption[$index] = $cleanedFormula;
}
// assembling clean formulas to calculate 'measure' flag
if (isset($cleanedOption)) {
$columnReferenceFactory = new CompositeColumnReferenceFactory(array(
$dataset,
new FormulaReferenceFactory($cleanedOption)));
$expressionAssembler = new FormulaExpressionAssembler($columnReferenceFactory);
foreach ($cleanedOption as $index => $cleanedFormula) {
// assembling full expressions to detect if any aggregation function present
$expression = $expressionAssembler->assemble($cleanedFormula);
// process the formula expression
$handler = FormulaExpressionLanguageFactory::getInstance()->getHandler($cleanedFormula->expressionLanguage);
$lexemes = $handler->lex($expression);
$syntaxTree = $handler->parse($lexemes);
// checking if the formula expression contains references to any aggregation functions
$cleanedFormula->isMeasure = $handler->isMeasure($syntaxTree);
}
}
}
elseif (is_array($option)) {
$cleanedOption = ArrayHelper::copy($option);
}
elseif (is_object($option)) {
$cleanedOption = clone $option;
}
else {
$cleanedOption = $option;
}
}
if (isset($cleanedOption)) {
$cleanedOptions[$name] = $cleanedOption;
}
}
}
// adjusting list of columns we need to return
$requestedColumnNames = NULL;
// preparing list of unique column names
ArrayHelper::addUniqueValues($requestedColumnNames, $cleanedColumns);
// adding columns which are used to sort result
if ($cleanedOrderBy) {
foreach ($cleanedOrderBy as $directionalColumnName) {
list($columnName, $isSortAscending) = ColumnBasedComparator_AbstractSortingConfiguration::parseDirectionalColumnName($directionalColumnName);
ArrayHelper::addUniqueValue($requestedColumnNames, $columnName);
}
}
return array($requestedColumnNames, $cleanedParameters, $cleanedOrderBy, $cleanedOptions);
}