00001 <?php
00002
00013 class SMWPropertyPage extends SMWOrderedListPage {
00014
00019 protected function initParameters() {
00020 global $smwgPropertyPagingLimit;
00021 $this->limit = $smwgPropertyPagingLimit;
00022 $this->mProperty = SMWDIProperty::newFromUserLabel( $this->mTitle->getText() );
00023 return true;
00024 }
00025
00031 protected function getHtml() {
00032 wfProfileIn( __METHOD__ . ' (SMW)' );
00033
00034 $result = $this->getSubpropertyList() . $this->getPropertyValueList();
00035
00036 wfProfileOut( __METHOD__ . ' (SMW)' );
00037 return $result;
00038 }
00039
00046 protected function getSubpropertyList() {
00047 $store = smwfGetStore();
00048 $options = new SMWRequestOptions();
00049 $options->sort = true;
00050 $options->ascending = true;
00051 $subproperties = $store->getPropertySubjects( new SMWDIProperty( '_SUBP' ), $this->getDataItem(), $options );
00052
00053 $result = '';
00054
00055 $resultCount = count( $subproperties );
00056 if ( $resultCount > 0 ) {
00057 $titleText = htmlspecialchars( $this->mTitle->getText() );
00058 $result .= "<div id=\"mw-subcategories\">\n<h2>" . wfMsg( 'smw_subproperty_header', $titleText ) . "</h2>\n<p>";
00059
00060 if ( !$this->mProperty->isUserDefined() ) {
00061 $result .= wfMsg( 'smw_isspecprop' ) . ' ';
00062 }
00063
00064 $result .= wfMsgExt( 'smw_subpropertyarticlecount', array( 'parsemag' ), $resultCount ) . "</p>\n";
00065
00066 if ( $resultCount < 6 ) {
00067 $result .= SMWPageLister::getShortList( 0, $resultCount, $subproperties, null );
00068 } else {
00069 $result .= SMWPageLister::getColumnList( 0, $resultCount, $subproperties, null );
00070 }
00071
00072 $result .= "\n</div>";
00073 }
00074
00075 return $result;
00076 }
00077
00084 protected function getPropertyValueList() {
00085 if ( $this->limit > 0 ) {
00086 $store = smwfGetStore();
00087 $options = SMWPageLister::getRequestOptions( $this->limit, $this->from, $this->until );
00088 $diWikiPages = $store->getAllPropertySubjects( $this->mProperty, $options );
00089
00090 if ( !$options->ascending ) {
00091 $diWikiPages = array_reverse( $diWikiPages );
00092 }
00093 } else {
00094 return '';
00095 }
00096
00097 $result = '';
00098
00099 if ( count( $diWikiPages ) > 0 ) {
00100 $pageLister = new SMWPageLister( $diWikiPages, null, $this->limit, $this->from, $this->until );
00101 $this->mTitle->setFragment( '#SMWResults' );
00102 $navigation = $pageLister->getNavigationLinks( $this->mTitle );
00103
00104 $titleText = htmlspecialchars( $this->mTitle->getText() );
00105 $resultNumber = min( $this->limit, count( $diWikiPages ) );
00106
00107 $result .= "<a name=\"SMWResults\"></a><div id=\"mw-pages\">\n" .
00108 '<h2>' . wfMsg( 'smw_attribute_header', $titleText ) . "</h2>\n<p>";
00109 if ( !$this->mProperty->isUserDefined() ) {
00110 $result .= wfMsg( 'smw_isspecprop' ) . ' ';
00111 }
00112 $result .= wfMsgExt( 'smw_attributearticlecount', array( 'parsemag' ), $resultNumber ) . "</p>\n" .
00113 $navigation . $this->subjectObjectList( $diWikiPages ) . $navigation . "\n</div>";
00114 }
00115
00116 return $result;
00117 }
00118
00126 protected function subjectObjectList( array $diWikiPages ) {
00127 global $wgContLang, $smwgMaxPropertyValues;
00128 $store = smwfGetStore();
00129
00130 $ac = count( $diWikiPages );
00131
00132 if ( $ac > $this->limit ) {
00133 if ( $this->until !== '' ) {
00134 $start = 1;
00135 } else {
00136 $start = 0;
00137 $ac = $ac - 1;
00138 }
00139 } else {
00140 $start = 0;
00141 }
00142
00143 $r = '<table style="width: 100%; ">';
00144 $prev_start_char = 'None';
00145
00146 for ( $index = $start; $index < $ac; $index++ ) {
00147 $diWikiPage = $diWikiPages[$index];
00148 $dvWikiPage = SMWDataValueFactory::newDataItemValue( $diWikiPage, null );
00149 $sortkey = smwfGetStore()->getWikiPageSortKey( $diWikiPage );
00150 $start_char = $wgContLang->convert( $wgContLang->firstChar( $sortkey ) );
00151
00152
00153 if ( $start_char != $prev_start_char ) {
00154 $r .= '<tr><th class="smwpropname"><h3>' . htmlspecialchars( $start_char ) . "</h3></th><th></th></tr>\n";
00155 $prev_start_char = $start_char;
00156 }
00157
00158
00159 $searchlink = SMWInfolink::newBrowsingLink( '+', $dvWikiPage->getShortHTMLText() );
00160 $r .= '<tr><td class="smwpropname">' . $dvWikiPage->getShortHTMLText( smwfGetLinker() ) .
00161 ' ' . $searchlink->getHTML( smwfGetLinker() ) . '</td><td class="smwprops">';
00162
00163
00164 $ropts = new SMWRequestOptions();
00165 $ropts->limit = $smwgMaxPropertyValues + 1;
00166 $values = $store->getPropertyValues( $diWikiPage, $this->mProperty, $ropts );
00167 $i = 0;
00168
00169 foreach ( $values as $di ) {
00170 if ( $i != 0 ) {
00171 $r .= ', ';
00172 }
00173 $i++;
00174
00175 if ( $i < $smwgMaxPropertyValues + 1 ) {
00176 $dv = SMWDataValueFactory::newDataItemValue( $di, $this->mProperty );
00177 $r .= $dv->getShortHTMLText( smwfGetLinker() ) . $dv->getInfolinkText( SMW_OUTPUT_HTML, smwfGetLinker() );
00178 } else {
00179 $searchlink = SMWInfolink::newInversePropertySearchLink( '…', $dvWikiPage->getWikiValue(), $this->mTitle->getText() );
00180 $r .= $searchlink->getHTML( smwfGetLinker() );
00181 }
00182 }
00183
00184 $r .= "</td></tr>\n";
00185 }
00186
00187 $r .= '</table>';
00188
00189 return $r;
00190 }
00191
00192 }