r86852 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86851‎ | r86852 | r86853 >
Date:12:19, 25 April 2011
Author:mkroetzsch
Status:deferred
Tags:
Comment:
convenience method to check if ASK returned true
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/sparql/SMW_SparqlResultWrapper.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/sparql/SMW_SparqlResultWrapper.php
@@ -76,6 +76,27 @@
7777 }
7878
7979 /**
 80+ * Check if the result is what one would get for a SPARQL ASK query
 81+ * that returned true. Returns false in all other cases (including
 82+ * the case that the results do not look at all like the result of
 83+ * an ASK query).
 84+ *
 85+ * @return boolean
 86+ */
 87+ public function isBooleanTrue() {
 88+ if ( count( $this->m_data ) == 1 ) {
 89+ $row = reset( $this->m_data );
 90+ $expElement = reset( $row );
 91+ if ( ( count( $row ) == 1 ) && ( $expElement instanceof SMWExpLiteral ) &&
 92+ ( $expElement->getLexicalForm() == 'true' ) &&
 93+ ( $expElement->getDatatype() == 'http://www.w3.org/2001/XMLSchema#boolean' ) ) {
 94+ return true;
 95+ }
 96+ }
 97+ return false;
 98+ }
 99+
 100+ /**
80101 * Reset iterator to position 0. Standard method of Iterator.
81102 */
82103 public function rewind() {

Status & tagging log