<?php if (!defined('PmWiki')) exit(); /********************************************************************** Copyright 2005 Mike Ivanov <mike70i@yahoo.com> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. **********************************************************************/ $InsideTMenu = 0; function BuildTMenu($name) { global $PubDirUrl, $HTMLHeaderFmt, $InsideTMenu; if ($name == 'tmenu') { $InsideTMenu = 1; return "<:block><div class='tmenu'>"; } if ($name == 'tmenuend') { $InsideTMenu = 0; return '<:block></div>'; } return '<:block>'; } function BuildTItem($star,$tail) { global $InsideTMenu, $pagename, $DefaultPage; if( $InsideTMenu ) { $prefix = "%tmenuitem% "; if( preg_match("/^\\s*\\[\\[([^|]*?)(\\|.*?)?\\]\\]/", $tail, $match ) ) { $pn = MakePageName( $DefaultPage, $match[1] ); if( $pn == $pagename ) { $prefix = "%tmenucurrent% "; } } $tail = $prefix . $tail . " %%"; } return $star . $tail; } ## precede link handlers Markup('tmenu','<links','/^\\(:(tmenu|tmenuend)\\s?:\\)/e', "BuildTMenu('$1')"); Markup('^*T','>tmenu','/^(\\*+)(.*)/e', "BuildTItem('$1','$2')"); ?>