r24086 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24085‎ | r24086 | r24087 >
Date:11:10, 14 July 2007
Author:mkroetzsch
Status:old
Tags:
Comment:
Further support for Type:Page to replace the current relations
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DataValueFactory.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php
@@ -211,6 +211,23 @@
212212 }
213213 $db->freeResult($res);
214214 break;
 215+ case '_wpg': // wiki page
 216+ $res = $db->select( $db->tableName('smw_relations'),
 217+ 'object_title, object_namespace',
 218+ 'subject_id=' . $db->addQuotes($subject->getArticleID()) .
 219+ ' AND relation_title=' . $db->addQuotes($attribute->getDBkey()) .
 220+ $this->getSQLConditions($requestoptions,'object_title','object_title'),
 221+ 'SMW::getAttributeValues', $this->getSQLOptions($requestoptions,'object_title') );
 222+ if($db->numRows( $res ) > 0) {
 223+ while($row = $db->fetchObject($res)) {
 224+ $dv = SMWDataValueFactory::newTypeIDValue('_wpg');
 225+ $dv->setOutputFormat($outputformat);
 226+ $dv->setValues($row->object_title, $row->object_namespace);
 227+ $result[] = $dv;
 228+ }
 229+ }
 230+ $db->freeResult($res);
 231+ break;
215232 default: // all others
216233 if ( ($requestoptions !== NULL) && ($requestoptions->boundary !== NULL) &&
217234 ($requestoptions->boundary->isNumeric()) ) {
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValueFactory.php
@@ -47,7 +47,10 @@
4848 if ($atitle !== NULL) {
4949 return SMWDataValueFactory::newAttributeObjectValue($atitle,$value,$caption);
5050 } else {
51 - return new SMWErrorValue(wfMsgForContent('smw_notype'),$value,$caption);
 51+ $type = SMWDataValueFactory::newTypeIDValue('__typ');
 52+ $type->setXSDValue('_wpg');
 53+ SMWDataValueFactory::$m_typelabels[$attstring] = $type;
 54+ return SMWDataValueFactory::newTypeIDValue('_wpg',$value,$caption,$attstring);
5255 }
5356 }
5457
@@ -68,7 +71,10 @@
6972 $result = SMWDataValueFactory::newTypeObjectValue(SMWDataValueFactory::$m_typelabels[$attstring], $value, $caption, $attstring);
7073 return $result;
7174 } elseif (count($typearray)==0) {
72 - return new SMWErrorValue(wfMsgForContent('smw_notype'), $value, $caption);
 75+ $type = SMWDataValueFactory::newTypeIDValue('__typ');
 76+ $type->setXSDValue('_wpg');
 77+ SMWDataValueFactory::$m_typelabels[$attstring] = $type;
 78+ return SMWDataValueFactory::newTypeIDValue('_wpg',$value,$caption,$attstring);
7379 } else {
7480 return new SMWErrorValue(wfMsgForContent('smw_manytypes'), $value, $caption);
7581 }

Status & tagging log