00001 <?php
00002
00014 final class SMGeoCoordsHooks {
00015
00030 public static function addGeoCoordsDefaultFormat( &$format, array $printRequests, array $params ) {
00031
00032 if ( $format === false ) {
00033
00034
00035 if ( count( $printRequests ) > 1 ) {
00036 $allValid = true;
00037 $hasCoords = false;
00038
00039
00040 foreach( $printRequests as $printRequest ) {
00041
00042 if ( $printRequest->getMode() == SMWPrintRequest::PRINT_THIS ) {
00043 continue;
00044 }
00045
00046 $typeId = $printRequest->getTypeID();
00047
00048 if ( $typeId == '_geo' ) {
00049 $hasCoords = true;
00050 }
00051 else {
00052 $allValid = false;
00053 break;
00054 }
00055 }
00056
00057
00058 if ( $allValid && $hasCoords ) {
00059 $format = 'map';
00060 }
00061 }
00062
00063 }
00064
00065 return true;
00066 }
00067
00077 public static function initGeoCoordsType() {
00078 SMWDataValueFactory::registerDatatype( '_geo', 'SMGeoCoordsValue', SMWDataItem::TYPE_GEO );
00079 return true;
00080 }
00081
00082 }