コード例 #1
0
 /**
  * @param bool $asValue
  *
  * @return string
  */
 public function getQueryString($asValue = false)
 {
     $comparator = QueryLanguage::getStringForComparator($this->comparator);
     $dataValue = DataValueFactory::getInstance()->newDataItemValue($this->dataItem, $this->property);
     if ($asValue) {
         return $comparator . $dataValue->getWikiValue();
     }
     // this only is possible for values of Type:Page
     if ($comparator === '') {
         // some extra care for Category: pages
         return '[[:' . $dataValue->getWikiValue() . ']]';
     }
     return '[[' . $comparator . $dataValue->getWikiValue() . ']]';
 }
コード例 #2
0
 /**
  * Helper function for getQueryDescription() that prepares a single value
  * string, possibly extracting comparators. $value is changed to consist
  * only of the remaining effective value string (without the comparator).
  *
  * @param string $value
  * @param string $comparator
  */
 protected static function prepareValue(&$value, &$comparator)
 {
     // Loop over the comparators to determine which one is used and what the actual value is.
     foreach (SMWQueryLanguage::getComparatorStrings() as $string) {
         if (strpos($value, $string) === 0) {
             $comparator = SMWQueryLanguage::getComparatorFromString(substr($value, 0, strlen($string)));
             $value = substr($value, strlen($string));
             break;
         }
     }
 }
コード例 #3
0
 /**
  * Initializes the $comparators field.
  * 
  * @since 1.5.3
  */
 protected static function initializeComparators()
 {
     global $smwgQComparators, $smwStrictComparators;
     static $initialized = false;
     if ($initialized) {
         return;
     }
     $initialized = true;
     // Note: Comparators that contain other comparators at the beginning of the string need to be at beginning of the array.
     $comparators = array('!~' => SMW_CMP_NLKE, '<<' => SMW_CMP_LESS, '>>' => SMW_CMP_GRTR, '<' => $smwStrictComparators ? SMW_CMP_LESS : SMW_CMP_LEQ, '>' => $smwStrictComparators ? SMW_CMP_GRTR : SMW_CMP_GEQ, '≤' => SMW_CMP_LEQ, '≥' => SMW_CMP_GEQ, '!' => SMW_CMP_NEQ, '~' => SMW_CMP_LIKE);
     $allowedComparators = explode('|', $smwgQComparators);
     // Remove the comparators that are not allowed.
     foreach ($comparators as $string => $comparator) {
         if (!in_array($string, $allowedComparators)) {
             unset($comparators[$string]);
         }
     }
     self::$comparators = $comparators;
 }