00001 <?php
00002
00016 class SMWConcept {
00017
00028 public static function render( Parser &$parser ) {
00029 global $wgContLang, $wgTitle;
00030
00031 $title = $parser->getTitle();
00032 $pconc = new SMWDIProperty( '_CONC' );
00033
00034 if ( $title->getNamespace() != SMW_NS_CONCEPT ) {
00035 $result = smwfEncodeMessages( array( wfMsgForContent( 'smw_no_concept_namespace' ) ) );
00036 SMWOutputs::commitToParser( $parser );
00037 return $result;
00038 } elseif ( count( SMWParseData::getSMWdata( $parser )->getPropertyValues( $pconc ) ) > 0 ) {
00039 $result = smwfEncodeMessages( array( wfMsgForContent( 'smw_multiple_concepts' ) ) );
00040 SMWOutputs::commitToParser( $parser );
00041 return $result;
00042 }
00043
00044
00045 $params = func_get_args();
00046 array_shift( $params );
00047
00048
00049 $concept_input = str_replace( array( '>', '<' ), array( '>', '<' ), array_shift( $params ) );
00050
00051
00052 $concept_docu = array_shift( $params );
00053
00054
00055 $query = SMWQueryProcessor::createQuery(
00056 $concept_input,
00057 SMWQueryProcessor::getProcessedParams( array( 'limit' => 20, 'format' => 'list' ) ),
00058 SMWQueryProcessor::CONCEPT_DESC
00059 );
00060
00061 $concept_text = $query->getDescription()->getQueryString();
00062
00063 if ( !is_null( SMWParseData::getSMWData( $parser ) ) ) {
00064 $diConcept = new SMWDIConcept( $concept_text, $concept_docu, $query->getDescription()->getQueryFeatures(), $query->getDescription()->getSize(), $query->getDescription()->getDepth() );
00065 SMWParseData::getSMWData( $parser )->addPropertyObjectValue( $pconc, $diConcept );
00066 }
00067
00068
00069 $rdflink = SMWInfolink::newInternalLink( wfMsgForContent( 'smw_viewasrdf' ), $wgContLang->getNsText( NS_SPECIAL ) . ':ExportRDF/' . $title->getPrefixedText(), 'rdflink' );
00070 SMWOutputs::requireResource( 'ext.smw.style' );
00071
00072
00073 $result = '<div class="smwfact"><span class="smwfactboxhead">' . wfMsgForContent( 'smw_concept_description', $title->getText() ) .
00074 ( count( $query->getErrors() ) > 0 ? ' ' . smwfEncodeMessages( $query->getErrors() ) : '' ) .
00075 '</span>' . '<span class="smwrdflink">' . $rdflink->getWikiText() . '</span>' . '<br />' .
00076 ( $concept_docu ? "<p>$concept_docu</p>" : '' ) .
00077 '<pre>' . str_replace( '[', '[', $concept_text ) . "</pre>\n</div>";
00078
00079 if ( !is_null( $wgTitle ) && $wgTitle->isSpecialPage() ) {
00080 global $wgOut;
00081 SMWOutputs::commitToOutputPage( $wgOut );
00082 }
00083 else {
00084 SMWOutputs::commitToParser( $parser );
00085 }
00086
00087 return $result;
00088 }
00089
00090 }