Difference between revisions of "Categories.php"
From Organic Design wiki
m |
m |
||
(10 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | <? | + | {{legacy}} |
+ | <php><? | ||
# XmlWiki Category Extension - 2005-08-25 - see discussion page | # XmlWiki Category Extension - 2005-08-25 - see discussion page | ||
global $xwIsProperties,$xwSection,$xwSave,$xwUserName; | global $xwIsProperties,$xwSection,$xwSave,$xwUserName; | ||
− | $update = $xwSave; | + | $update = ($xwSave && ($xwSection<1)); |
$apply = true; | $apply = true; | ||
Line 18: | Line 19: | ||
$apply = false; # Just let wiki-parser handle category-links for category pages | $apply = false; # Just let wiki-parser handle category-links for category pages | ||
} | } | ||
− | |||
− | if ($apply | + | if ($apply) { |
# Begin extracting category-link info - first get stuff we'll be needing | # Begin extracting category-link info - first get stuff we'll be needing | ||
Line 49: | Line 49: | ||
} | } | ||
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 ) { | + | if (!$language) { |
− | $article = preg_replace( "/$category_match/ie", '($categories[]="$1")?"":""', $article ); | + | $article = preg_replace("/$category_match/ie", '($categories[]="$1")?"":""', $article); |
− | if (ereg('{{stub}}',$article)) $categories[] = 'Stubs'; | + | if (ereg('{'.'{stub}}',$article)) $categories[] = 'Stubs'; |
} | } | ||
} | } | ||
Line 60: | Line 60: | ||
# Only do the rest if this is the top level article | # Only do the rest if this is the top level article | ||
# - the embeds still have to have their cat-links removed | # - the embeds still have to have their cat-links removed | ||
− | if ( $pt == $GLOBALS['xwArticleTitle'] ) { | + | if ($pt == $GLOBALS['xwArticleTitle']) { |
− | $nt = Title::newFromText( $title ); | + | $nt = Title::newFromText($title); |
$ns = $nt->getNamespace(); | $ns = $nt->getNamespace(); | ||
− | $t = addslashes( $nt->getDBkey() ); # Title used in db-tables | + | $t = addslashes($nt->getDBkey()); # Title used in db-tables |
− | $ul = strtoupper( $language ); | + | $ul = strtoupper($language); |
+ | $content = xwArticleContent($title); | ||
# Auto-Category: Language | # Auto-Category: Language | ||
Line 87: | Line 88: | ||
elseif ($ul == 'PHP' and count(preg_grep('/^(admin)|(dev)$/i',xwGetListByTagname(xwArticleProperties($title),'write')))) | elseif ($ul == 'PHP' and count(preg_grep('/^(admin)|(dev)$/i',xwGetListByTagname(xwArticleProperties($title),'write')))) | ||
$categories[] = 'Transforms'; | $categories[] = 'Transforms'; | ||
− | elseif ($ul == 'XML' and preg_match('/<!DOCTYPE[^>]+?xmlwiki-properties.dtd"\\s*>/', | + | elseif ($ul == 'XML' and preg_match('/<!DOCTYPE[^>]+?xmlwiki-properties.dtd"\\s*>/',$content)) $categories[] = 'Transforms'; |
− | + | if (preg_match('/<div\\s+class=["\']?tree-view["\']?.*?\\s*>/',$content)) $categories[] = 'Articles containing trees'; | |
# Get the db-key of this article | # Get the db-key of this article | ||
Line 105: | Line 106: | ||
# Remove duplicates and sort categories | # Remove duplicates and sort categories | ||
$tmp = array(); | $tmp = array(); | ||
− | foreach ( $categories as $cat ) { | + | foreach ($categories as $cat) { |
− | list( $cat, $sortkey ) = explode( '|', ucfirst($cat) ); | + | list($cat,$sortkey) = explode('|',ucfirst($cat)); |
− | if ( !$tmp[$cat] = $sortkey ) $tmp[$cat] = $t; | + | if (!$tmp[$cat] = $sortkey) $tmp[$cat] = $t; |
} | } | ||
− | ksort( $tmp ); | + | unset($categories[$title]); |
+ | ksort($tmp); | ||
# Loop through categories and process each | # Loop through categories and process each | ||
Line 128: | Line 130: | ||
} | } | ||
− | ?> | + | ?></php> |
Latest revision as of 09:37, 27 April 2007
<php><?
- XmlWiki Category Extension - 2005-08-25 - see discussion page
global $xwIsProperties,$xwSection,$xwSave,$xwUserName; $update = ($xwSave && ($xwSection<1)); $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 a category page, add class attribute to table since the MediaWiki fellas didn't for some reason
if ( ereg( '^Category:.+$', $title ) ) { # If event is view, adjust rendered output, else add this to view event if ( $event == 'view' ) { # Add CSS class to headings (see, not just me who hard-wires styles!)
$article = preg_replace( '/