当前位置: 首页>>代码示例>>PHP>>正文


PHP SMWQueryResult::addErrors方法代码示例

本文整理汇总了PHP中SMWQueryResult::addErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWQueryResult::addErrors方法的具体用法?PHP SMWQueryResult::addErrors怎么用?PHP SMWQueryResult::addErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SMWQueryResult的用法示例。


在下文中一共展示了SMWQueryResult::addErrors方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: buildResult

 /**
  * @see SMWResultPrinter::buildResult
  *
  * @since 1.8
  *
  * @param SMWQueryResult $results
  *
  * @return string
  */
 protected function buildResult(SMWQueryResult $results)
 {
     // Intro/outro are not planned to work with the widget option
     if ($this->params['intro'] !== '' && $this->params['widget'] !== '') {
         return $results->addErrors(array(wfMessage('srf-error-option-mix', 'intro/widget')->inContentLanguage()->text()));
     } elseif ($this->params['outro'] !== '' && $this->params['widget'] !== '') {
         return $results->addErrors(array(wfMessage('srf-error-option-mix', 'outro/widget')->inContentLanguage()->text()));
     }
     return $this->getResultText($results, $this->outputMode);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:19,代码来源:SRF_Gallery.php

示例2: getResultText

 /**
  * Return serialised results in specified format
  *
  * @param SMWQueryResult $results
  * @param $outputmode
  *
  * @return string
  */
 public function getResultText(SMWQueryResult $results, $outputmode)
 {
     // Check output conditions
     if ($this->params['widget'] == 'sphere' && $this->params['link'] !== 'all' && $this->params['template'] === '') {
         return $results->addErrors(array(wfMessage('srf-error-option-link-all', 'sphere')->inContentLanguage()->text()));
     }
     // Template support
     $this->hasTemplates = $this->params['template'] !== '';
     // Prioritize HTML setting
     $this->isHTML = $this->params['widget'] !== '';
     $this->isHTML = $this->params['template'] === '';
     $outputmode = SMW_OUTPUT_HTML;
     // Sphere widget
     if ($this->params['widget'] === 'sphere') {
         SMWOutputs::requireResource('ext.srf.tagcloud.sphere');
     }
     // Wordcloud widget
     if ($this->params['widget'] === 'wordcloud') {
         SMWOutputs::requireResource('ext.srf.tagcloud.wordcloud');
     }
     return $this->getTagCloud($this->getTagSizes($this->getTags($results, $outputmode)));
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:30,代码来源:SRF_TagCloud.php

示例3: getQueryResultFromSparqlResult

 /**
  * Build an SMWQueryResult object from a SMWSparqlResultWrapper. This
  * function is used to generate instance query results, and the given
  * result wrapper must have an according format (one result column that
  * contains URIs of wiki pages).
  *
  * @param $sparqlResultWrapper SMWSparqlResultWrapper
  * @param $query SMWQuery, SMWQueryResults hold a reference to original query
  * @return SMWQueryResult
  */
 protected function getQueryResultFromSparqlResult(SMWSparqlResultWrapper $sparqlResultWrapper, SMWQuery $query)
 {
     $resultDataItems = array();
     foreach ($sparqlResultWrapper as $resultRow) {
         if (count($resultRow) > 0) {
             $dataItem = SMWExporter::findDataItemForExpElement($resultRow[0]);
             if (!is_null($dataItem)) {
                 $resultDataItems[] = $dataItem;
             }
         }
     }
     if ($sparqlResultWrapper->numRows() > $query->getLimit()) {
         array_pop($resultDataItems);
         $hasFurtherResults = true;
     } else {
         $hasFurtherResults = false;
     }
     $result = new SMWQueryResult($query->getDescription()->getPrintrequests(), $query, $resultDataItems, $this->m_store, $hasFurtherResults);
     switch ($sparqlResultWrapper->getErrorCode()) {
         case SMWSparqlResultWrapper::ERROR_NOERROR:
             break;
         case SMWSparqlResultWrapper::ERROR_INCOMPLETE:
             $result->addErrors(array(wfMessage('smw_db_sparqlqueryincomplete')->inContentLanguage()->text()));
             break;
         default:
             $result->addErrors(array(wfMessage('smw_db_sparqlqueryproblem')->inContentLanguage()->text()));
             break;
     }
     return $result;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:40,代码来源:SMW_SparqlStoreQueryEngine.php

示例4: getResultText

 protected function getResultText(SMWQueryResult $res, $outputmode)
 {
     if ($this->mFormat == 'template' && $this->mTemplate == false) {
         $res->addErrors(array(wfMessage('smw_notemplategiven')->inContentLanguage()->text()));
         return '';
     }
     // Determine mark-up strings used around list items:
     if ($this->mFormat == 'ul' || $this->mFormat == 'ol') {
         $header = "<" . $this->mFormat . ">\n";
         $footer = "</" . $this->mFormat . ">\n";
         $rowstart = "\t<li>";
         $rowend = "</li>\n";
         $plainlist = false;
     } else {
         // "list" and "template" format
         $header = '';
         $footer = '';
         $rowstart = '';
         $rowend = '';
         $plainlist = true;
     }
     if ($this->mSep !== '') {
         // always respect custom separator
         $listsep = $this->mSep;
         $finallistsep = $listsep;
     } elseif ($this->mFormat == 'list') {
         // make default list ", , , and "
         // TODO: No default separator for "ul" and "ol" to not break
         // compatibility with SMW pre 1.7.1. But they really should have
         // default separators, i.e. the check should be for
         // $this->mFormat !== 'template'
         $listsep = ', ';
         $finallistsep = wfMessage('smw_finallistconjunct')->inContentLanguage()->text() . ' ';
     } else {
         // no default separators for format "template", "ul", "ol"
         $listsep = '';
         $finallistsep = '';
     }
     // Initialise more values
     $result = '';
     $column_width = 0;
     $rows_per_column = -1;
     // usually unnecessary
     $rows_in_cur_column = -1;
     // Set up floating divs, if there's more than one column
     if ($this->mColumns > 1) {
         $column_width = floor(100 / $this->mColumns);
         $result .= '<div style="float: left; width: ' . $column_width . '%">' . "\n";
         $rows_per_column = ceil($res->getCount() / $this->mColumns);
         $rows_in_cur_column = 0;
     }
     if ($header !== '') {
         $result .= $header;
     }
     if ($this->mIntroTemplate !== '') {
         $result .= "{{" . $this->mIntroTemplate . "}}";
     }
     // Now print each row
     $rownum = -1;
     while ($row = $res->getNext()) {
         $this->printRow($row, $rownum, $rows_in_cur_column, $rows_per_column, $this->mFormat, $plainlist, $header, $footer, $rowstart, $rowend, $result, $column_width, $res, $listsep, $finallistsep);
     }
     if ($this->mOutroTemplate !== '') {
         $result .= "{{" . $this->mOutroTemplate . "}}";
     }
     // Make label for finding further results
     if ($this->linkFurtherResults($res) && ($this->mFormat != 'ol' || $this->getSearchLabel(SMW_OUTPUT_WIKI))) {
         $this->showFurtherResults($result, $res, $rowstart, $rowend, $outputmode);
     }
     // Print footer
     if ($footer !== '') {
         $result .= $footer;
     }
     if ($this->mColumns > 1) {
         $result .= "</div>\n";
     }
     if ($this->mColumns > 1) {
         $result .= '<br style="clear: both" />' . "\n";
     }
     // Make sure that if the result set turns empty and if available display default
     if ($this->params['default'] !== '' && $result === '') {
         $result = $this->params['default'];
     }
     return $result;
 }
开发者ID:yusufchang,项目名称:app,代码行数:85,代码来源:SMW_QP_List.php

示例5: getResultText

	protected function getResultText( SMWQueryResult $res, $outputmode ) {
		if ( ( $this->mFormat == 'template' ) && ( $this->mTemplate == false ) ) {
			$res->addErrors( array( wfMsgForContent( 'smw_notemplategiven' ) ) );
			return '';
		}
		
		// Determine mark-up strings used around list items:
		if ( ( $this->mFormat == 'ul' ) || ( $this->mFormat == 'ol' ) ) {
			$header = "<" . $this->mFormat . ">\n";
			$footer = "</" . $this->mFormat . ">\n";
			$rowstart = "\t<li>";
			$rowend = "</li>\n";
			$plainlist = false;
			$finallistsep = '';
			$listsep = '';
		} else { // "list" and "template" format
			$header = '';
			$footer = '';
			$rowstart = '';
			$rowend = '';
			$plainlist = true;
			
			if ( $this->mSep !== '' ) { // always respect custom separator
				$listsep = $this->mSep;
				$finallistsep = $listsep;
			} elseif ( $this->mFormat == 'list' )  {  // make default list ", , , and "
				$listsep = ', ';
				$finallistsep = wfMsgForContent( 'smw_finallistconjunct' ) . ' ';
			} else { // no default separators for format "template"
				$listsep = '';
				$finallistsep = '';
			}
		}
		
		// Initialise more values
		$result = '';
		$column_width = 0;
		$rows_per_column = -1; // usually unnecessary
		$rows_in_cur_column = -1;
		
		// Set up floating divs, if there's more than one column
		if ( $this->mColumns > 1 ) {
			$column_width = floor( 100 / $this->mColumns );
			$result .= '<div style="float: left; width: ' . $column_width . '%">' . "\n";
			$rows_per_column = ceil( $res->getCount() / $this->mColumns );
			$rows_in_cur_column = 0;
		}

		if ( $header !== '' ) {
			$result .= $header;
		} 
		
		if ( $this->mIntroTemplate !== '' ) {
			$result .= "{{" . $this->mIntroTemplate . "}}";
		}

		// Now print each row
		$rownum = -1;
		while ( $row = $res->getNext() ) {
			$this->printRow( $row, $rownum, $rows_in_cur_column,
				$rows_per_column, $this->mFormat, $plainlist,
				$header, $footer, $rowstart, $rowend, $result,
				$column_width, $res, $listsep, $finallistsep );
		}
		
		if ( $this->mOutroTemplate !== '' ) {
			$result .= "{{" . $this->mOutroTemplate . "}}";
		}
		
		// Make label for finding further results
		if ( $this->linkFurtherResults( $res ) && ( ( $this->mFormat != 'ol' ) || ( $this->getSearchLabel( SMW_OUTPUT_WIKI ) ) ) ) {
			$this->showFurtherResults( $result, $res, $rowstart, $rowend );
		}

		// Print footer
		if ( $footer !== '' ) {
			$result .= $footer;
		}
		
		if ( $this->mColumns > 1 ) {
			$result .= "</div>\n";
		}
		
		if ( $this->mColumns > 1 ) {
			$result .= '<br style="clear: both" />' . "\n";
		}

		return $result;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:89,代码来源:SMW_QP_List.php

示例6: getResultText

 /**
  * Return serialised results in specified format.
  */
 protected function getResultText(SMWQueryResult $res, $outputmode)
 {
     if ($this->mTreeProp === null || $this->mTreeProp === '') {
         $res->addErrors(array(wfMessage('srf-noparentprop')->inContentLanguage()->text()));
         return '';
     }
     $store = $res->getStore();
     // first put everything in a list
     // elements appearing more than once will be inserted more than once,
     // but only one instance will be inserted with the hash
     // only this instance will be considered as a parent element in the tree
     $list = array();
     while ($row = $res->getNext()) {
         $hash = $row[0]->getResultSubject()->getSerialization();
         if (array_key_exists($hash, $list)) {
             $list[] = new SRFTreeElement($row);
         } else {
             $list[$hash] = new SRFTreeElement($row);
         }
     }
     // transfer the listelements into the tree
     // elements with more than one parent will be cloned for each parent
     $tree = array();
     foreach ($list as $hash => $listElem) {
         $parents = $store->getPropertyValues($listElem->mRow[0]->getResultSubject(), SMWDIProperty::newFromUserLabel($this->mTreeProp));
         // transfer element from list to tree
         foreach ($parents as $parent) {
             $parentPageHash = $parent->getSerialization();
             if ($hash !== null) {
                 if (array_key_exists($parentPageHash, $list)) {
                     $listElem->mParent = $parentPageHash;
                 }
                 $tree[$hash] = $listElem;
                 $hash = null;
             } else {
                 $treeElem = clone $listElem;
                 if (array_key_exists($parentPageHash, $list)) {
                     $treeElem->mParent = $parentPageHash;
                 } else {
                     $treeElem->mParent = null;
                 }
                 $tree[] = $treeElem;
             }
         }
     }
     foreach ($tree as $hash => $value) {
     }
     // build pointers from parants to children
     foreach ($tree as $hash => $treeElem) {
         if ($treeElem->mParent != null) {
             $tree[$treeElem->mParent]->mChildren[] = $treeElem;
         }
     }
     // remove children from toplevel
     foreach ($tree as $hash => $treeElem) {
         if ($treeElem->mParent != null) {
             unset($tree[$hash]);
         }
     }
     $result = '';
     $rownum = 0;
     foreach ($tree as $hash => $treeElem) {
         $this->printElement($result, $treeElem, $row);
     }
     return $result;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:69,代码来源:SRF_Tree.php

示例7: getFeed

 /**
  * Build a feed
  *
  * @since 1.8
  *
  * @param SMWQueryResult $results
  * @param $type
  *
  * @return string
  */
 protected function getFeed(SMWQueryResult $results, $type)
 {
     global $wgFeedClasses;
     if (!isset($wgFeedClasses[$type])) {
         $results->addErrors(array(wfMessage('feed-invalid')->inContentLanguage()->text()));
         return '';
     }
     // Get feed class instance
     /**
      * @var ChannelFeed $feed
      */
     $feed = new $wgFeedClasses[$type]($this->feedTitle(), $this->feedDescription(), $this->feedURL());
     // Create feed header
     $feed->outHeader();
     // Create feed items
     while ($row = $results->getNext()) {
         $feed->outItem($this->feedItem($row));
     }
     // Create feed footer
     $feed->outFooter();
     return $feed;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:32,代码来源:SMW_QP_Feed.php

示例8: makeQueryResultForInstance

 private function makeQueryResultForInstance(FederateResultSet $federateResultSet, Query $query)
 {
     $resultDataItems = array();
     foreach ($federateResultSet as $resultRow) {
         if (count($resultRow) > 0) {
             $dataItem = Exporter::findDataItemForExpElement($resultRow[0]);
             if (!is_null($dataItem)) {
                 $resultDataItems[] = $dataItem;
             }
         }
     }
     if ($federateResultSet->numRows() > $query->getLimit()) {
         array_pop($resultDataItems);
         $hasFurtherResults = true;
     } else {
         $hasFurtherResults = false;
     }
     $result = new QueryResult($query->getDescription()->getPrintrequests(), $query, $resultDataItems, $this->store, $hasFurtherResults);
     switch ($federateResultSet->getErrorCode()) {
         case FederateResultSet::ERROR_NOERROR:
             break;
         case FederateResultSet::ERROR_INCOMPLETE:
             $result->addErrors(array(wfMessage('smw_db_sparqlqueryincomplete')->inContentLanguage()->text()));
             break;
         default:
             $result->addErrors(array(wfMessage('smw_db_sparqlqueryproblem')->inContentLanguage()->text()));
             break;
     }
     return $result;
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:30,代码来源:QueryResultFactory.php

示例9: getResultText

 /**
  * Return serialised results in specified format.
  */
 protected function getResultText(SMWQueryResult $res, $outputmode)
 {
     if ($this->mTreeProp === '') {
         $res->addErrors(array(wfMessage('srf-noparentprop')->inContentLanguage()->text()));
         return '';
     }
     $store = $res->getStore();
     // put everything in a list and set parent hashes
     // elements appearing more than once will be inserted more than once and
     // elements with more than one parent will be cloned for each parent,
     // but only one instance will ever be inserted with the hash and
     // only this instance will later be considered as a parent element in the tree
     $tree = array();
     while ($row = $res->getNext()) {
         $element = new SRFTreeElement($row);
         $hash = $row[0]->getResultSubject()->getSerialization();
         if (array_key_exists($hash, $tree)) {
             $hash = null;
         }
         $parents = $store->getPropertyValues($element->mRow[0]->getResultSubject(), SMWDIProperty::newFromUserLabel($this->mTreeProp));
         if (empty($parents)) {
             // no parents: copy into tree as root level item
             if ($hash !== null) {
                 $tree[$hash] = $element;
             } else {
                 $tree[] = $element;
             }
         } else {
             // one or more parents: copy one copy per parent into tree
             foreach ($parents as $parent) {
                 if ($hash !== null) {
                     $tree[$hash] = $element;
                     $hash = null;
                 } else {
                     $element = clone $element;
                     $tree[] = $element;
                 }
                 $element->mParent = $parent->getSerialization();
             }
         }
     }
     $rootElements = array();
     // build pointers from parents to children and remove pointers to parents that don't exist in the tree
     foreach ($tree as $hash => $element) {
         if ($element->mParent !== null) {
             if (array_key_exists($element->mParent, $tree)) {
                 $tree[$element->mParent]->mChildren[] = $element;
             } else {
                 $element->mParent = null;
                 $rootElements[$hash] = $element;
             }
         } else {
             $rootElements[$hash] = $element;
         }
     }
     $result = '';
     $rownum = 0;
     // if a specific page was specified as root element of the tree
     if ($this->mRoot !== '') {
         // get the title object of the root page
         $rootTitle = Title::newFromText($this->mRoot);
         if ($rootTitle === null) {
             $res->addErrors(array(wfMessage('srf-rootinvalid')->params($this->mRoot)->inContentLanguage()->text()));
             return '';
         }
         $rootSerialization = SMWDIWikiPage::newFromTitle($rootTitle)->getSerialization();
         // find the root page in the tree and print it and its subtree
         if (array_key_exists($rootSerialization, $tree)) {
             $this->printElement($result, $tree[$rootSerialization], $rownum, $this->mStartLevel);
         }
     } else {
         // iterate through all tree elements
         foreach ($rootElements as $hash => $element) {
             // print current root element and its subtree
             $this->printElement($result, $element, $rownum, $this->mStartLevel);
         }
     }
     return $result;
 }
开发者ID:cicalese,项目名称:SemanticResultFormats,代码行数:82,代码来源:SRF_Tree.php


注:本文中的SMWQueryResult::addErrors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。