/**
  * Messages are not resolved until the output and instead will be kept with the
  * message and argument keys (e.g. `[2,"smw_baduri","~*0123*"]`). This allows to
  * switch the a representation without requiring language context by the object
  * that reports an error.
  *
  * @since 2.4
  *
  * @param $parameters
  * @param integer|null $type
  * @param integer|null $language
  */
 public function addErrorMsg($parameters, $type = null)
 {
     $this->mErrors[] = Message::encode($parameters, $type);
     $this->mHasErrors = true;
 }
 /**
  * Apply structural restrictions to the current description.
  */
 public function applyRestrictions()
 {
     global $smwgQMaxSize, $smwgQMaxDepth, $smwgQConceptMaxSize, $smwgQConceptMaxDepth;
     if (!is_null($this->description)) {
         if ($this->isUsedInConcept) {
             $maxsize = $smwgQConceptMaxSize;
             $maxdepth = $smwgQConceptMaxDepth;
         } else {
             $maxsize = $smwgQMaxSize;
             $maxdepth = $smwgQMaxDepth;
         }
         $log = array();
         $this->description = $this->description->prune($maxsize, $maxdepth, $log);
         if (count($log) > 0) {
             $this->errors[] = Message::encode(array('smw_querytoolarge', str_replace('[', '[', implode(', ', $log))));
         }
     }
 }
 /**
  * @since 2.5
  *
  * @param DataValue $dataValue
  *
  * @return DIContainer|null
  */
 public function getErrorContainerFromDataValue(DataValue $dataValue)
 {
     if ($dataValue->getErrors() === array()) {
         return null;
     }
     $property = $dataValue->getProperty();
     $hash = '';
     if ($property !== null) {
         $hash = $property->getKey();
     }
     $containerSemanticData = $this->newContainerSemanticData($hash);
     foreach ($dataValue->getErrors() as $error) {
         $this->addToContainerSemanticData($containerSemanticData, $property, Message::encode($error));
     }
     return new DIContainer($containerSemanticData);
 }
 protected function addDataValuesToSubobject(ParserParameterProcessor $parserParameterProcessor)
 {
     // Named subobjects containing a "." in the first five characters are reserved to be
     // used by extensions only in order to separate them from user land and avoid having
     // them accidentally to refer to the same named ID
     // (i.e. different access restrictions etc.)
     if (strpos(mb_substr($parserParameterProcessor->getFirst(), 0, 5), '.') !== false) {
         return $this->parserData->addError(Message::encode(array('smw-subobject-parser-invalid-naming-scheme', $parserParameterProcessor->getFirst())));
     }
     list($parameters, $id) = $this->getParameters($parserParameterProcessor);
     $this->subobject->setEmptyContainerForId($id);
     $subject = $this->subobject->getSubject();
     foreach ($parameters as $property => $values) {
         if ($property === self::PARAM_SORTKEY) {
             $property = DIProperty::TYPE_SORTKEY;
         }
         if ($property === self::PARAM_CATEGORY) {
             $property = DIProperty::TYPE_CATEGORY;
         }
         foreach ($values as $value) {
             $dataValue = DataValueFactory::getInstance()->newDataValueByText($property, $value, false, $subject);
             $this->subobject->addDataValue($dataValue);
         }
     }
     $this->doAugmentSortKeyForWhenDisplayTitleIsAccessible($this->subobject->getSemanticData());
     return true;
 }
 private function parseFromJson($results)
 {
     if (!isset($results['@json']) || !isset($results['@json'][0])) {
         return $results;
     }
     // Restrict the depth to avoid resolving recursive assignment
     // that can not be handled beyond the 2:n
     $depth = 3;
     $params = json_decode($results['@json'][0], true, $depth);
     if ($params === null || json_last_error() !== JSON_ERROR_NONE) {
         $this->addError(Message::encode(array('smw-parser-invalid-json-format', ErrorCode::getStringFromJsonErrorCode(json_last_error()))));
         return $results;
     }
     array_walk($params, function (&$value, $key) {
         if ($value === '') {
             $value = array();
         }
         if (!is_array($value)) {
             $value = array($value);
         }
     });
     unset($results['@json']);
     return array_merge($results, $params);
 }
 public function testEncode()
 {
     $this->assertEquals('[2,"Foo"]', Message::encode('Foo'));
     $this->assertEquals('[2,"Foo"]', Message::encode(array('Foo')));
     $this->assertEquals('[2,"Foo"]', Message::encode('[2,"Foo"]'));
 }
 /**
  * @since 2.4
  *
  * @param string $msgKey
  */
 public function addErrorWithMsgKey($msgKey)
 {
     $this->errors[] = Message::encode(func_get_args());
 }