/** * @since 2.1 */ public function initialize() { $params = explode('/', $this->queryString); reset($params); $escaped = false; // Remove empty elements $params = array_filter($params, 'strlen'); $property = isset($this->requestOptions['property']) ? $this->requestOptions['property'] : current($params); $value = isset($this->requestOptions['value']) ? $this->requestOptions['value'] : next($params); // Auto-generated link is marked with a leading : if ($property !== '' && $property[0] === ':') { $escaped = true; $property = $this->urlEncoder->unescape(ltrim($property, ':')); } $this->property = PropertyValue::makeUserProperty(str_replace(array('_'), array(' '), $property)); if (!$this->property->isValid()) { $this->propertyString = $property; $this->value = null; $this->valueString = $value; } else { $this->propertyString = $this->property->getDataItem()->getLabel(); $this->valueString = $this->getValue((string) $value, $escaped); } $this->setLimit(); $this->setOffset(); $this->setNearbySearch(); }
/** * @since 2.1 */ public function initialize() { $params = explode('/', $this->queryString); reset($params); // Remove empty elements $params = array_filter($params, 'strlen'); $property = isset($this->requestOptions['property']) ? $this->requestOptions['property'] : current($params); $value = isset($this->requestOptions['value']) ? $this->requestOptions['value'] : next($params); $property = $this->urlEncoder->decode($property); $value = str_replace(array('-25'), array('%'), $value); $this->property = PropertyValue::makeUserProperty($property); if (!$this->property->isValid()) { $this->propertyString = $property; $this->value = null; $this->valueString = $value; } else { $this->propertyString = $this->property->getWikiValue(); $this->value = DataValueFactory::getInstance()->newPropertyObjectValue($this->property->getDataItem(), $this->urlEncoder->decode($value)); $this->valueString = $this->value->isValid() ? $this->value->getWikiValue() : $value; } $this->setLimit(); $this->setOffset(); $this->setNearbySearch(); }
private function initPropertyChain($value) { $chain = explode('.', $value); // Get the last which represents the final output // Foo.Bar.Foobar.Baz $last = array_pop($chain); $this->lastPropertyChainValue = PropertyValue::makeUserProperty($last); if (!$this->lastPropertyChainValue->isValid()) { return $this->addError($this->lastPropertyChainValue->getErrors()); } $this->lastPropertyChainValue->setOptions($this->getOptions()); // Generate a forward list from the remaining property labels // Foo.Bar.Foobar foreach ($chain as $value) { $propertyValue = PropertyValue::makeUserProperty($value); if (!$propertyValue->isValid()) { continue; } $propertyValue->setOptions($this->getOptions()); $this->propertyValues[] = $propertyValue; } }