Difference between revisions of "Categories.php"
From Organic Design wiki
m |
(Attempt fix for cats-via-props update issue) |
||
Line 36: | Line 36: | ||
# Extract category information from article's content and properties | # Extract category information from article's content and properties | ||
− | if (eregi('^xml:(.+)$', $title, $match)) { | + | if ( $xml = eregi( '^xml:(.+)$', $title, $match ) ) { |
− | $content = xwArticleContent($title = $match[1], false); | + | $content = xwArticleContent( $title = $match[1], false ); |
− | preg_match_all("/$category_match/i", $content, $match); | + | preg_match_all( "/$category_match/i", $content, $match ); |
− | $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) ) { |
$title = $match[1]; | $title = $match[1]; | ||
$ns = NS_USER; | $ns = NS_USER; | ||
− | $content = xwArticleContent("User:$title", false); | + | $content = xwArticleContent( "User:$title", false ); |
− | preg_match_all("/$category_match/i", $content, $match); | + | preg_match_all( "/$category_match/i", $content, $match ); |
$categories = $match[1]; | $categories = $match[1]; | ||
− | foreach (xwGetListByTagname($article, 'groups') as $group) | + | foreach ( xwGetListByTagname($article, 'groups') as $group ) |
− | if (($group != $GLOBALS['xwUserName']) && ($group != 'anyone')) | + | if ( ($group != $GLOBALS['xwUserName']) && ($group != 'anyone') ) |
$categories[] = "$group Group Members"; | $categories[] = "$group Group Members"; | ||
$language = ''; | $language = ''; | ||
Line 101: | Line 101: | ||
$cat = addslashes(str_replace(' ', '_', $cat)); | $cat = addslashes(str_replace(' ', '_', $cat)); | ||
if ($update) $db->query("INSERT INTO $cl (cl_from,cl_to,cl_sortkey) VALUES('$id','$cat','$sortkey')"); | if ($update) $db->query("INSERT INTO $cl (cl_from,cl_to,cl_sortkey) VALUES('$id','$cat','$sortkey')"); | ||
+ | } | ||
+ | |||
+ | # Update links table from main article | ||
+ | if ($xml) { | ||
+ | $nt = Title::newFromText( $title ); | ||
+ | $ns = $nt->getNamespace(); | ||
+ | $result = $db->query("SELECT cur_id FROM $cur WHERE cur_title='$title' AND cur_namespace='$ns' LIMIT 1"); | ||
+ | if ( $row = mysql_fetch_assoc($result) ) fixLinksFromArticle( $row['cur_id'] ); | ||
} | } | ||
} | } | ||
} | } | ||
?> | ?> |
Revision as of 05:19, 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("/