r24886 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24885‎ | r24886 | r24887 >
Date:22:45, 17 August 2007
Author:yaron
Status:old
Tags:
Comment:
Fix - avoid attribute and relation pages that are only redirects
Modified paths:
  • /trunk/extensions/SemanticForms/specials/SF_CreateTemplate.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/specials/SF_CreateTemplate.php
@@ -15,6 +15,7 @@
1616
1717 SpecialPage::addPage( new SpecialPage('CreateTemplate','',true,'doSpecialCreateTemplate',false) );
1818
 19+// Custom sort function, used in getSemanticProperties()
1920 function cmp($a, $b)
2021 {
2122 if ($a == $b) {
@@ -30,7 +31,7 @@
3132 $all_properties = array();
3233
3334 $res = $dbr->query("SELECT page_title FROM " . $dbr->tableName('page') .
34 - " WHERE page_namespace = " . SMW_NS_ATTRIBUTE);
 35+ " WHERE page_namespace = " . SMW_NS_ATTRIBUTE . " AND page_is_redirect = 0");
3536 while ($row = $dbr->fetchRow($res)) {
3637 $attribute_name = str_replace('_', ' ', $row[0]);
3738 $all_properties[$attribute_name . ":="] = $attribute_name;
@@ -38,13 +39,15 @@
3940 $dbr->freeResult($res);
4041
4142 $res = $dbr->query("SELECT page_title FROM " . $dbr->tableName('page') .
42 - " WHERE page_namespace = " . SMW_NS_RELATION);
 43+ " WHERE page_namespace = " . SMW_NS_RELATION . " AND page_is_redirect = 0");
4344 while ($row = $dbr->fetchRow($res)) {
4445 $relation_name = str_replace('_', ' ', $row[0]);
4546 $all_properties[$relation_name . "::"] = $relation_name;
4647 }
4748 $dbr->freeResult($res);
4849
 50+ // sort properties list alphabetically - custom sort function is needed
 51+ // because the regular sort function destroys the "keys" of the array
4952 uasort($all_properties, "cmp");
5053 return $all_properties;
5154 }

Status & tagging log