r94772 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94771‎ | r94772 | r94773 >
Date:16:34, 17 August 2011
Author:devayon
Status:deferred
Tags:
Comment:
follow-up: r94765 display errors on top of page
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialQueryCreator.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php
@@ -2027,45 +2027,47 @@
20282028 */
20292029 public function execute() {
20302030 $errors = array();
2031 - $query = SMWQueryProcessor::createQuery( $this->queryString, $this->parameters,
2032 - SMWQueryProcessor::SPECIAL_PAGE , $this->parameters['format'], $this->printOuts );
2033 - $res = smwfGetStore()->getQueryResult( $query );
2034 - $this->queryResult = $res;
 2031+ if ( $this->queryString != '' ) {
 2032+ $query = SMWQueryProcessor::createQuery( $this->queryString, $this->parameters,
 2033+ SMWQueryProcessor::SPECIAL_PAGE , $this->parameters['format'], $this->printOuts );
 2034+ $res = smwfGetStore()->getQueryResult( $query );
 2035+ $this->queryResult = $res;
20352036
2036 - $errors = array_merge( $errors, $res->getErrors() );
2037 - if ( !empty( $errors ) ) {
2038 - $this->errorsOccured = true;
2039 - $this->errors = array_merge( $errors, $this->errors );
2040 - }
 2037+ $errors = array_merge( $errors, $res->getErrors() );
 2038+ if ( !empty( $errors ) ) {
 2039+ $this->errorsOccured = true;
 2040+ $this->errors = array_merge( $errors, $this->errors );
 2041+ }
20412042
2042 - // BEGIN: Try to be smart for rss/ical if no description/title is given and we have a concept query
2043 - if ( $this->parameters['format'] == 'rss' ) {
2044 - $descKey = 'rssdescription';
2045 - $titleKey = 'rsstitle';
2046 - } elseif ( $this->parameters['format'] == 'icalendar' ) {
2047 - $descKey = 'icalendardescription';
2048 - $titleKey = 'icalendartitle';
2049 - } else {
2050 - $descKey = false;
2051 - }
 2043+ // BEGIN: Try to be smart for rss/ical if no description/title is given and we have a concept query
 2044+ if ( $this->parameters['format'] == 'rss' ) {
 2045+ $descKey = 'rssdescription';
 2046+ $titleKey = 'rsstitle';
 2047+ } elseif ( $this->parameters['format'] == 'icalendar' ) {
 2048+ $descKey = 'icalendardescription';
 2049+ $titleKey = 'icalendartitle';
 2050+ } else {
 2051+ $descKey = false;
 2052+ }
20522053
2053 - if ( $descKey && ( $query->getDescription() instanceof SMWConceptDescription ) &&
2054 - ( !isset( $this->parameters[$descKey] ) || !isset( $this->parameters[$titleKey] ) ) ) {
2055 - $concept = $query->getDescription()->getConcept();
 2054+ if ( $descKey && ( $query->getDescription() instanceof SMWConceptDescription ) &&
 2055+ ( !isset( $this->parameters[$descKey] ) || !isset( $this->parameters[$titleKey] ) ) ) {
 2056+ $concept = $query->getDescription()->getConcept();
20562057
2057 - if ( !isset( $this->parameters[$titleKey] ) ) {
2058 - $this->parameters[$titleKey] = $concept->getText();
2059 - }
 2058+ if ( !isset( $this->parameters[$titleKey] ) ) {
 2059+ $this->parameters[$titleKey] = $concept->getText();
 2060+ }
20602061
2061 - if ( !isset( $this->parameters[$descKey] ) ) {
2062 - // / @bug The current SMWStore will never return SMWConceptValue (an SMWDataValue) here; it might return SMWDIConcept (an SMWDataItem)
2063 - $dv = end( smwfGetStore()->getPropertyValues( SMWWikiPageValue::makePageFromTitle( $concept ), new SMWDIProperty( '_CONC' ) ) );
2064 - if ( $dv instanceof SMWConceptValue ) {
2065 - $this->parameters[$descKey] = $dv->getDocu();
 2062+ if ( !isset( $this->parameters[$descKey] ) ) {
 2063+ // / @bug The current SMWStore will never return SMWConceptValue (an SMWDataValue) here; it might return SMWDIConcept (an SMWDataItem)
 2064+ $dv = end( smwfGetStore()->getPropertyValues( SMWWikiPageValue::makePageFromTitle( $concept ), new SMWDIProperty( '_CONC' ) ) );
 2065+ if ( $dv instanceof SMWConceptValue ) {
 2066+ $this->parameters[$descKey] = $dv->getDocu();
 2067+ }
20662068 }
20672069 }
 2070+ // END: Try to be smart for rss/ical if no description/title is given and we have a concept query
20682071 }
2069 - // END: Try to be smart for rss/ical if no description/title is given and we have a concept query
20702072 }
20712073
20722074 /**
Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialQueryCreator.php
@@ -101,8 +101,7 @@
102102 protected function makeResults() {
103103 global $wgOut, $smwgScriptPath;
104104 $this->enableJQuery();
105 - $result='';
106 - //$result .= '<div class="smwqcerrors">' . $this->getErrorsHtml() . '</div>';
 105+ $result = '<div class="smwqcerrors">' . $this->getErrorsHtml() . '</div>';
107106 $specTitle = $this->getTitle();
108107 $formatBox = $this->getFormatSelectBoxSep( 'broadtable' );
109108 $result .= Html::openElement( 'form', array( 'name' => 'qc', 'action' => $specTitle->escapeLocalURL(), 'method' => 'get' ) ) . "\n" .

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r94765show error messages at the top of QCdevayon14:54, 17 August 2011