tags and allows several arguments in the pmWiki makrup. * Version 2.00 , on 2008-05-10, by Skrol29 : The content is insterted in the pmWiki page, but it is not processed by pmWiki Makups |+| Compatibility with TBS 3.3.0. |+| [var..pmwiki_url] |+| compatibility with $EnablePathInfo=1 * Works with TBS version 3.2.0 or higher. TinyButStrong site : www.tinybutstrong.com * In your PmWiki page add (:tbscontent example1:) to insert the dynamic content made by TBS. */ // ---------------------- // --- PmWiki Cookbook -- // ---------------------- $RecipeInfo['TbsDynamicContent']['Version'] = '2.00'; if (defined('PmWiki')) { // Put a tag like this into your pmWiki page: (:TbsContent action:) action is a keywork transmeted by pmWiki to your script. Markup('tbscontent', 'directives', '/\\(:tbscontent (.*?):\\)/e', "TbsContent('$1')"); $MarkupTable['tbscontent']['seq'] = 'C'; // Change the order of execution, this markup will be processed as the last one, but before the markups for adding skins. unset($MarkupRules); // it seems to not be done correctly in DisableMarkup() because the varibale is not declared as global. function TbsContent($ArgLst='') { // Split arguments $ArgLst = explode(' ',$ArgLst); $iMax = count($ArgLst)-1; for ($i=0;$i<=$iMax;$i++) {$ArgLst[$i]=trim($ArgLst[$i]);} $TbsAction = $ArgLst[0]; if ($TbsAction=='') return '(TBS for pmWiki) Error : no parameter defined.'; global $TbsScriptToCall, $TbsScriptArgs; if (!isset($TbsScriptToCall)) return '(TBS for pmWiki) Error : no script defined.'; $TbsScriptArgs = $ArgLst; if (is_array($TbsScriptToCall)) { // Allowed scripts are defined ins a PHP array if (isset($TbsScriptToCall['path'])) { $path = $TbsScriptToCall['path']; } else { $path = ''; } if (isset($TbsScriptToCall[$TbsAction])) { include_once($path.$TbsScriptToCall[$TbsAction]); } else { return '(TBS for pmWiki) Error : parameter \''.$TbsAction.'\' is not allowed.'; } } else { include_once($TbsScriptToCall); } $x = $GLOBALS['_TbsContentForPmWiki']; unset($GLOBALS['_TbsContentForPmWiki']); return $x; } } // --------------------- // --- TBS Plug-In -- // --------------------- // Name of the class is a keyword used for Plug-In authentication. So i'ts better to save it into a constant. define('TBS_PMWIKI','clsTbsPmWiki'); // Put the name of the class into global variable array $_TBS_AutoInstallPlugIns to have it automatically installed for any new TBS instance. $GLOBALS['_TBS_AutoInstallPlugIns'][] = TBS_PMWIKI; class clsTbsPmWiki { function OnInstall() { global $RecipeInfo, $NoHTMLCache; $this->Version = $RecipeInfo['TbsDynamicContent']['Version']; $NoHTMLCache = 1; // Avoid pmWiki cache for next pages. // Compatibility with TBS 3.3.0 if (!function_exists('tbs_Html_GetPart')) { $GLOBALS['_TbsHook'] =& $this->TBS; function tbs_Html_GetPart(&$Txt,$Tag,$WithTags=false,$CancelIfEmpty=false) { return $GLOBALS['_TbsHook']->f_Xml_GetPart($Txt,$Tag,$WithTags,$CancelIfEmpty); } } return array('BeforeLoadTemplate','OnSpecialVar','AfterShow'); } function BeforeLoadTemplate(&$File,&$HtmlCharSet) { // Prepare data to found the template in the given path if any. if ( ($this->TBS->_LastFile=='') and (isset($GLOBALS['TbsScriptToCall']['path'])) ) { $this->TBS->_LastFile = $GLOBALS['TbsScriptToCall']['path'].'nofile.txt'; } } function OnSpecialVar($Name,&$IsSupported,&$Value,&$PrmLst) { if ($Name=='pmwiki_url') { $IsSupported = true; $p = (isset($PrmLst['page'])) ? trim($PrmLst['page']) : ''; if ($p=='') $p = $GLOBALS['pagename']; $Value = PageVar($p,'$PageUrl'); return; } if ($Name=='pmwiki_page') { // Compatibility with plugin version 1.X: returns the full URL with all GET parameters $IsSupported = true; $Value = basename($_SERVER['PHP_SELF']); $q = trim(''.$_SERVER['QUERY_STRING']); if ($q!=='') $Value .= '?'.$q; return; } } function AfterShow(&$Render) { $Render = TBS_NOTHING; $body = tbs_Html_GetPart($this->TBS->Source,'body'); $before = ''; if ($body=='') { // It is not a full HTML content $html = $this->TBS->Source; } else { // It is a full HTML content $html = $body; $p = false; if ($p===false) $p = strpos($this->TBS->Source,'TBS->Source,''); if ($p===false) $p = strpos($this->TBS->Source,'TBS->Source,''); if ($p!==false) { $x = substr($this->TBS->Source,0,$p); $before .= "\r\n".tbs_Html_GetPart($x,'script',true); // Add possible Javascripts snipets of the Html page $before .= "\r\n".tbs_Html_GetPart($x,'style',true); // Add possible local Styles of the Html page $before .= "\r\n"; } } $GLOBALS['_TbsContentForPmWiki'] = $before.$html; } } ?>