public function __construct($configuration, $wildcard, $anyCharactersOnLeft = FALSE, $anyCharactersOnRight = FALSE)
 {
     parent::__construct($configuration);
     $this->wildcard = StringHelper::trim($wildcard);
     $this->anyCharactersOnLeft = $anyCharactersOnLeft;
     $this->anyCharactersOnRight = $anyCharactersOnRight;
 }
 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'));
     }
 }
    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;
    }
 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);
 }
 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);
 }
Beispiel #6
0
 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;
 }
    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;
    }
 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;
 }
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);
    }
}
    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;
    }
    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;
    }
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);
}
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;
}
 public function __construct($configuration, $pattern)
 {
     parent::__construct($configuration);
     $this->pattern = StringHelper::trim($pattern);
 }
    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);
    }
    public static function mergeWith(&$instance, $source, $mergeCompositeProperty = FALSE, $existingPropertyRule = self::EXISTING_PROPERTY_RULE__ERROR_IF_PRESENT) {
        if (isset($source)) {
            if (is_object($source) || is_array($source)) {
                $isPropertyIndexed = ArrayHelper::isIndexed($source);
                foreach ($source as $name => $value) {
                    $value = StringHelper::trim($value);
                    $mergedValue = self::getPropertyValue($instance, $name);

                    if (is_object($value) || is_array($value)) {
                        if ($mergeCompositeProperty) {
                            self::mergeWith($mergedValue, $value, TRUE, $existingPropertyRule);
                        }
                    }
                    else {
                        if (isset($mergedValue) && isset($value)) {
                            if (($mergedValue != $value)) {
                                switch ($existingPropertyRule) {
                                    case self::EXISTING_PROPERTY_RULE__SKIP_IF_PRESENT:
                                        break;
                                    case self::EXISTING_PROPERTY_RULE__OVERRIDE_IF_PRESENT:
                                        $mergedValue = $value;
                                        break;
                                    default:
                                        LogHelper::log_error(t(
                                            "'@propertyName' property already contains value: @existingPropertyValue. Merge cannot be performed with new value: @newPropertyValue",
                                            array('@propertyName' => $name, '@existingPropertyValue' => $mergedValue, '@newPropertyValue' => $value)));
                                        throw new UnsupportedOperationException(t(
                                            '%propertyName property already contains value. Merge cannot be performed',
                                            array('%propertyName' => $name)));
                                }
                            }
                        }
                        else {
                            $mergedValue = $value;
                        }
                    }

                    if (!isset($instance)) {
                        $instance = $isPropertyIndexed ? array() : new stdClass();
                    }
                    if ($isPropertyIndexed) {
                        $instance[$name] = $mergedValue;
                    }
                    else {
                        $instance->$name = $mergedValue;
                    }
                }
            }
            else {
                if (isset($instance)) {
                    if (($instance != $source)) {
                        switch ($existingPropertyRule) {
                            case self::EXISTING_PROPERTY_RULE__SKIP_IF_PRESENT:
                                break;
                            case self::EXISTING_PROPERTY_RULE__OVERRIDE_IF_PRESENT:
                                $instance = $source;
                                break;
                            default:
                                LogHelper::log_error(t(
                                    "The instance already contains value: @existingPropertyValue. Assignment cannot be performed with new value: @newPropertyValue",
                                    array('@existingPropertyValue' => $instance, '@newPropertyValue' => $source)));
                                throw new UnsupportedOperationException(t('The instance already contains value. Assignment cannot be performed'));
                        }
                    }
                }
                else {
                    $instance = $source;
                }
            }
        }

        return $instance;
    }
    public function disableDataset($datasetName, array $observers = NULL) {
        $datasetName = StringHelper::trim($datasetName);

        $this->checkDatasetStructurePermission($datasetName);

        $callcontext = $this->prepareCallContext();

        $datasourceStructureHandler = $this->getDataSourceStructureHandlerByDatasetName($datasetName);

        $impl = new DisableDatasetImpl($datasourceStructureHandler);
        $impl->execute($callcontext, $datasetName, $observers);
    }
    public function __construct($configuration, $from = NULL, $to = NULL) {
        parent::__construct($configuration);

        $this->from = StringHelper::trim($from);
        $this->to = StringHelper::trim($to);
    }
    public static function trim($values) {
        $trimmedValues = NULL;

        if (isset($values)) {
            if (is_array($values)) {
                foreach ($values as $key => $value) {
                    $trimmedValue = is_array($value) ? self::trim($value) : StringHelper::trim($value);
                    if (isset($trimmedValue)) {
                        $trimmedValues[StringHelper::trim($key)] = $trimmedValue;
                    }
                }
            }
            else {
                // provided value is not an array. Converting result to an array with one element
                $value = StringHelper::trim($values);
                if (isset($value)) {
                    $trimmedValues[] = $value;
                }
            }
        }

        return $trimmedValues;
    }
 public function format($resourceId, $output) {
     return (!isset($output) || is_bool($output))
         ? NULL
         : StringHelper::trim($output);
 }
    protected function processColumnComments(SystemTableMetaModelLoaderCallContext $callcontext, AbstractMetaModel $metamodel, DataSourceMetaData $datasource) {
        if (!isset($callcontext->environment->options->table->column->metadata)) {
            return;
        }

        $metadata = $callcontext->environment->options->table->column->metadata;

        $supportedPropertyNames = NULL;
        foreach ($metadata as $propertyName => $propertyCfg) {
            if (isset($propertyCfg->source) && ($propertyCfg->source == 'comment')) {
                $supportedPropertyNames[] = $propertyName;
            }
        }
        if (!isset($supportedPropertyNames)) {
            return;
        }

        $columnCommentsProperties = $this->loadColumnComments($callcontext, $datasource);
        if (isset($columnCommentsProperties)) {
            foreach ($columnCommentsProperties as $columnCommentProperties) {
                if (!isset($columnCommentProperties[self::CN_COMMENT])) {
                    continue;
                }

                $tableOwner = $this->adjustOwnerName($columnCommentProperties[self::CN_TABLE_OWNER]);
                $tableName = $this->adjustTableName($columnCommentProperties[self::CN_TABLE_NAME]);
                $columnName = $this->adjustColumnName($columnCommentProperties[self::CN_COLUMN_NAME]);

                $columns = $this->findEligibleColumns4ColumnComment($callcontext, $metamodel, $tableOwner, $tableName, $columnName);
                if (!isset($columns)) {
                    continue;
                }

                $comment = $columnCommentProperties[self::CN_COMMENT];
                $comment = $this->commentGenerator->generate($comment);

                foreach ($metadata as $propertyName => $propertyCfg) {
                    $parts = isset($propertyCfg->options->delimiter)
                        ? explode($propertyCfg->options->delimiter, $comment)
                        : array($comment);

                    $index = isset($propertyCfg->options->position) ? $propertyCfg->options->position : NULL;

                    $value = isset($index)
                        ? (isset($parts[$index]) ? $parts[$index] : NULL)
                        : ((count($parts) >= 1) ? $parts[0] : NULL);
                    $value = StringHelper::trim($value);
                    if (!isset($value)) {
                        continue;
                    }

                    foreach ($columns as $column) {
                        $column->$propertyName = $value;
                    }
                }
            }
        }

        LogHelper::log_info(t(
            'Processed system meta data about @columnCommentCount column comment(s)',
            array('@columnCommentCount' => count($columnCommentsProperties))));
    }
    public function deleteDatasetRecordBatch($datasetName, IndexedRecordsHolder $recordsHolder) {
        $datasetName = StringHelper::trim($datasetName);

        $this->checkDatasetManipulationPermission($datasetName);

        $callcontext = $this->prepareCallContext();

        $request = new DatasetDeleteRequest($datasetName, $recordsHolder);

        LogHelper::log_debug($request);

        return $this->getDataSourceManipulationHandlerByDatasetName($datasetName)->deleteDatasetRecords($callcontext, $request);
    }
    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 RequestChainFactory::getInstance()->initializeChain()->getNextSequenceValues(
            $this->getDataSourceQueryHandler($datasourceName), $callcontext, $request);
    }
 public function __construct() {
     parent::__construct();
     $this->currencySymbol = StringHelper::trim($this->numberFormatter->getSymbol(NumberFormatter::CURRENCY_SYMBOL));
     if ($this->currencySymbol === FALSE) {
         throw new IllegalStateException(t('Cannot detect OS currency symbol'));
     }
 }