public function testGetLongHTMLText()
 {
     $instance = new PropertyChainValue();
     $instance->setUserValue('Foo.Bar');
     $this->assertEquals($this->testEnvironment->getLocalizedTextByNamespace(SMW_NS_PROPERTY, 'Property:Bar&nbsp;<span title="Foo.Bar">⠉</span>'), $instance->getLongHTMLText());
 }
Exemplo n.º 2
0
 /**
  * Create an PrintRequest object from a string description as one
  * would normally use in #ask and related inputs. The string must start
  * with a "?" and may contain label and formatting parameters after "="
  * or "#", respectively. However, further parameters, given in #ask by
  * "|+param=value" are not allowed here; they must be added
  * individually.
  *
  * @since 2.5
  *
  * @param string $text
  * @param boolean $showMode = false
  *
  * @return PrintRequest|null
  */
 public static function deserialize($text, $showMode = false)
 {
     list($parts, $outputFormat, $printRequestLabel) = self::getPartsFromText($text);
     $data = null;
     if ($printRequestLabel === '') {
         // print "this"
         $printmode = PrintRequest::PRINT_THIS;
         $label = '';
         // default
     } elseif (self::isCategory($printRequestLabel)) {
         // print categories
         $printmode = PrintRequest::PRINT_CATS;
         $label = $showMode ? '' : Localizer::getInstance()->getNamespaceTextById(NS_CATEGORY);
         // default
     } elseif (PropertyChainValue::isChained($printRequestLabel)) {
         $data = new PropertyChainValue();
         $data->setUserValue($printRequestLabel);
         $printmode = PrintRequest::PRINT_CHAIN;
         $label = $showMode ? '' : $data->getLastPropertyChainValue()->getWikiValue();
         // default
     } else {
         // print property or check category
         $title = Title::newFromText($printRequestLabel, SMW_NS_PROPERTY);
         // trim needed for \n
         // not a legal property/category name; give up
         if ($title === null) {
             return null;
         }
         if ($title->getNamespace() == NS_CATEGORY) {
             $printmode = PrintRequest::PRINT_CCAT;
             $data = $title;
             $label = $showMode ? '' : $title->getText();
             // default
         } else {
             // enforce interpretation as property (even if it starts with something that looks like another namespace)
             $printmode = PrintRequest::PRINT_PROP;
             $data = PropertyValue::makeUserProperty($printRequestLabel);
             if (!$data->isValid()) {
                 // not a property; give up
                 return null;
             }
             $label = $showMode ? '' : $data->getWikiValue();
             // default
         }
     }
     // "plain printout", avoid empty string to avoid confusions with "false"
     if ($outputFormat === '') {
         $outputFormat = '-';
     }
     // label found, use this instead of default
     if (count($parts) > 1) {
         $label = trim($parts[1]);
     }
     try {
         $printRequest = new PrintRequest($printmode, $label, $data, trim($outputFormat));
     } catch (InvalidArgumentException $e) {
         // something still went wrong; give up
         $printRequest = null;
     }
     return $printRequest;
 }