00001 <?php
00002
00014 class SMWSpecialProperties extends SpecialPage {
00015
00016 public function __construct() {
00017 parent::__construct( 'Properties' );
00018 }
00019
00020 public function execute( $param ) {
00021 wfProfileIn( 'smwfDoSpecialProperties (SMW)' );
00022
00023 global $wgOut;
00024
00025 $wgOut->setPageTitle( wfMsg( 'properties' ) );
00026
00027 $rep = new SMWPropertiesPage();
00028
00029 list( $limit, $offset ) = wfCheckLimits();
00030 $rep->doQuery( $offset, $limit );
00031
00032
00033 SMWOutputs::commitToOutputPage( $wgOut );
00034
00035 wfProfileOut( 'smwfDoSpecialProperties (SMW)' );
00036 }
00037 }
00038
00047 class SMWPropertiesPage extends SMWQueryPage {
00048
00049 function getPageHeader() {
00050 return '<p>' . wfMsg( 'smw_properties_docu' ) . "</p><br />\n";
00051 }
00052
00053 function getName() {
00054 return 'Properties';
00055 }
00056
00057 function formatResult( $skin, $result ) {
00058 global $wgLang;
00059 $linker = smwfGetLinker();
00060 list ( $property, $useCount ) = $result;
00061
00062 $errors = array();
00063
00064 $diWikiPage = $property->getDiWikiPage();
00065 $title = !is_null( $diWikiPage ) ? $diWikiPage->getTitle() : null;
00066
00067 if ( $property->isUserDefined() ) {
00068
00069 if ( $title === null ) {
00070 return '';
00071 }
00072
00073 if ( $useCount <= 5 ) {
00074 $errors[] = wfMsgHtml( 'smw_propertyhardlyused' );
00075 }
00076
00077
00078 global $smwgPDefaultType;
00079 $typeDataValue = SMWTypesValue::newFromTypeId( $smwgPDefaultType );
00080 $typestring = $typeDataValue->getLongHTMLText( $linker );
00081
00082 $label = htmlspecialchars( $property->getLabel() );
00083 if ( $title->exists() ) {
00084 $typeProperty = new SMWDIProperty( '_TYPE' );
00085 $types = smwfGetStore()->getPropertyValues( $diWikiPage, $typeProperty );
00086 if ( count( $types ) >= 1 ) {
00087 $typeDataValue = SMWDataValueFactory::newDataItemValue( current( $types ), $typeProperty );
00088 $typestring = $typeDataValue->getLongHTMLText( $linker );
00089 } else {
00090 $errors[] = wfMsgHtml( 'smw_propertylackstype', $typestring );
00091 }
00092
00093 $proplink = $linker->link( $title, $label );
00094 } else {
00095 $errors[] = wfMsgHtml( 'smw_propertylackspage' );
00096 $proplink = $linker->link( $title, $label, array(), array( 'action' => 'view' ) );
00097 }
00098
00099 } else {
00100 $typeid = $property->findPropertyTypeID();
00101 $typeDataValue = SMWTypesValue::newFromTypeId( $typeid );
00102 $typestring = $typeDataValue->getLongHTMLText( $linker );
00103 $propertyDataValue = SMWDataValueFactory::newDataItemValue( $property, null );
00104 $proplink = $propertyDataValue->getShortHtmlText( $linker );
00105 }
00106
00107 $warnings = smwfEncodeMessages( $errors, 'warning', '', false );
00108
00109 $useCount = $wgLang->formatNum( $useCount );
00110 if ( $typestring === '' ) {
00111 return wfMsgHtml( 'smw_property_template_notype', $proplink, $useCount ) . ' ' . $warnings;
00112 } else {
00113 return wfMsgHtml( 'smw_property_template', $proplink, $typestring, $useCount ) . ' ' . $warnings;
00114 }
00115 }
00116
00117 function getResults( $requestoptions ) {
00118 return smwfGetStore()->getPropertiesSpecial( $requestoptions );
00119 }
00120
00121 }