Difference between revisions of "Categories.php"
From Organic Design wiki
(Cat bug fix confirmed :-)) |
(Still not quite right (cating xml's!)) |
||
Line 32: | Line 32: | ||
$cl = $db->tableName('categorylinks'); | $cl = $db->tableName('categorylinks'); | ||
$category_match = "\\[{2}\\s*category\\s*:\\s*(.+?)\\s*]]\\n?"; | $category_match = "\\[{2}\\s*category\\s*:\\s*(.+?)\\s*]]\\n?"; | ||
− | |||
− | |||
$pt = $title; | $pt = $title; | ||
Line 42: | Line 40: | ||
$categories = array_merge( xwGetListByTagname( $article, 'category' ), $match[1] ); | $categories = array_merge( xwGetListByTagname( $article, 'category' ), $match[1] ); | ||
xwGetProperty( $article, 'language', $language ); | xwGetProperty( $article, 'language', $language ); | ||
− | if (!$language) $language = xwArticleType( $title, $content ); | + | if ( !$language ) $language = xwArticleType( $title, $content ); |
} | } | ||
elseif ( eregi('^sys:(.+)$', $title, $match) ) { | elseif ( eregi('^sys:(.+)$', $title, $match) ) { | ||
Line 56: | Line 54: | ||
} | } | ||
else { | else { | ||
− | $categories = xwGetListByTagname($properties, 'category'); | + | $categories = xwGetListByTagname( $properties, 'category' ); |
# Must remove category-links from article so wiki-parser doesn't process them | # Must remove category-links from article so wiki-parser doesn't process them | ||
− | xwGetProperty($properties, 'language', $language); | + | xwGetProperty( $properties, 'language', $language ); |
− | if (!$language) $article = preg_replace("/$category_match/ie", '($categories[]="$1")?"":""', $article); | + | if ( !$language ) $article = preg_replace( "/$category_match/ie", '($categories[]="$1")?"":""', $article ); |
} | } | ||
Line 66: | Line 64: | ||
if ( $pt == $GLOBALS['xwArticleTitle'] ) { | if ( $pt == $GLOBALS['xwArticleTitle'] ) { | ||
− | + | $nt = Title::newFromText( $title ); | |
− | $t = addslashes( $nt->getDBkey() ); | + | $ns = $nt->getNamespace(); |
+ | $t = addslashes( $nt->getDBkey() ); # Title used in db-tables | ||
# Auto-Category: Language | # Auto-Category: Language | ||
− | if ($language) $categories[] = strtoupper($language); | + | if ( $language ) $categories[] = strtoupper( $language ); |
# Get the db-key of this article | # Get the db-key of this article | ||
− | if ($update) { | + | if ( $update ) { |
− | $result = $db->query("SELECT cur_id FROM $cur WHERE cur_title='$t' AND cur_namespace='$ns' LIMIT 1"); | + | $result = $db->query( "SELECT cur_id FROM $cur WHERE cur_title='$t' AND cur_namespace='$ns' LIMIT 1" ); |
if ( $row = mysql_fetch_assoc($result) ) $id = $row['cur_id']; | if ( $row = mysql_fetch_assoc($result) ) $id = $row['cur_id']; | ||
else $id = $update = false; | else $id = $update = false; |
Revision as of 07:45, 28 February 2006
<?
- XmlWiki Category Extension - 2005-08-25
- This data-transform replaces the current MediaWiki category parsing
- - It allows categories to be included in either the article content or its XML properties
- - Maintains rules-based auto-categorisation
- Only apply this transform for the root article, not embeds
$update = $GLOBALS['xwSave']; $apply = true;
- Don't apply if page is a category,
- or if action isn't view or submit
if (($action != 'view') && ($action != ) && !$update) $apply = false; if ($event != 'data') $apply = false;
- If a category page, add class attribute to table since the MediaWiki fellas didn't for some reason
if (ereg('^Category:.+$', $title)) { # Add this transform to the view stack to adjust page after it's built if ($event == 'data') xwSetProperty($properties, 'xpath:/properties:view', $tTitle); else { # If already in view event now, add a CSS class to letter-headings
$article = preg_replace("/