Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QP_JSONlink.php |
— | — | @@ -68,6 +68,7 @@ |
69 | 69 | $prefixedtext = $value->getPrefixedText(); |
70 | 70 | } |
71 | 71 | $valuestack[] = 'label: "'.$values.'"'; |
| 72 | + $label = $values; |
72 | 73 | } else { |
73 | 74 | $values = array(); |
74 | 75 | $finalvalues = ''; |
— | — | @@ -98,6 +99,21 @@ |
99 | 100 | $count++; |
100 | 101 | } |
101 | 102 | $valuestack[] = '"uri" : "'.$wgServer.$wgScriptPath.'/index.php?title='.$prefixedtext.'"'; |
| 103 | + |
| 104 | + //try to determine type/category |
| 105 | + $catlist = array(); |
| 106 | + $dbr = &wfGetDB(DB_SLAVE); |
| 107 | + $cl = $dbr->tableName('categorylinks'); |
| 108 | + $arttitle = Title::newFromText($label); |
| 109 | + if($arttitle instanceof Title){ |
| 110 | + $catid = $arttitle->getArticleID(); |
| 111 | + $catres = $dbr->select($cl, 'cl_to', "cl_from = $catid", __METHOD__, array('ORDER BY' => 'cl_sortkey')); |
| 112 | + while ($catrow = $dbr->fetchRow($catres)) $catlist[] = $catrow[0]; |
| 113 | + $dbr->freeResult($catres); |
| 114 | + if(sizeof($catlist) > 0) $valuestack[] = '"type" : "'.$catlist[0].'"'; |
| 115 | + } |
| 116 | + |
| 117 | + //create property list of item |
102 | 118 | $itemstack[] = "\t{\n\t\t\t".implode(",\n\t\t\t",$valuestack)."\n\t\t}"; |
103 | 119 | $row = $res->getNext(); |
104 | 120 | } |