summaryrefslogtreecommitdiff
path: root/smartyplugins
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-05-16 13:38:28 +0100
committerLester Caine <lester@lsces.co.uk>2026-05-16 13:38:28 +0100
commit80975a340c65e7fc02c7c7bcf23623abf6d9bcef (patch)
treec6032c83c33f32d0ae211a93e2d3ded7c397606d /smartyplugins
parent1f532bccdd238e78dd217509bb81f1a7098376e2 (diff)
downloadthemes-80975a340c65e7fc02c7c7bcf23623abf6d9bcef.tar.gz
themes-80975a340c65e7fc02c7c7bcf23623abf6d9bcef.tar.bz2
themes-80975a340c65e7fc02c7c7bcf23623abf6d9bcef.zip
Drop legacy smarty elements
Diffstat (limited to 'smartyplugins')
-rwxr-xr-xsmartyplugins/AddLinkTicket.php43
-rwxr-xr-xsmartyplugins/outputfilter.highlight.php124
-rwxr-xr-xsmartyplugins/prefilter.tr.php86
3 files changed, 0 insertions, 253 deletions
diff --git a/smartyplugins/AddLinkTicket.php b/smartyplugins/AddLinkTicket.php
deleted file mode 100755
index 7f9ef6a..0000000
--- a/smartyplugins/AddLinkTicket.php
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-/**
- * smarty_prefilter_add_link_ticket This will insert a ticket on all template URL's that have GET parameters.
- *
- * @param string $pTplSource source of template
- * @return string ammended template source
- */
-
- namespace Bitweaver\Plugins;
-
- use Smarty\Compile\Modifier\ModifierCompilerInterface;
- use Smarty\Compiler\Template;
-
-class AddLinkTicket implements ModifierCompilerInterface {
- public function __construct() {
- // Initialization code
- }
-
- public function compile($params, Template $template) {
- global $gBitUser;
-
- $source = $params[0];
-
- if( is_object( $gBitUser ) && $gBitUser->isRegistered() ) {
- // $from = '#href="(.*PKG_URL.*php)\?(.*)&(.*)"#i';
- // $to = 'href="\\1?\\2&amp;tk={$gBitUser->mTicket}&\\3"';
- // $pTplSource = preg_replace( $from, $to, $pTplSource );
- $from = '#<form([^>]*)>#i';
- // div tag is for stupid XHTML compliance.
- $to = '<form\\1><div style="display:inline"><input type="hidden" name="tk" value="{$gBitUser->mTicket}" /></div>';
- $pTplSource = preg_replace( $from, $to, $source );
- if( strpos( $pTplSource[0], '{form}' )) {
- $source = str_replace( '{form}', '{form}<div style="display:inline"><input type="hidden" name="tk" value="{$gBitUser->mTicket}" /></div>', $pTplSource );
- } elseif( strpos( $pTplSource[0], '{form ' ) ) {
- $from = '#\{form(\}| [^\}]*)\}#i';
- $to = '{form\\1}<div style="display:inline"><input type="hidden" name="tk" value="{$gBitUser->mTicket}" /></div>';
- $source = preg_replace( $from, $to, $pTplSource );
- }
- }
-
- return $source;
- }
-} \ No newline at end of file
diff --git a/smartyplugins/outputfilter.highlight.php b/smartyplugins/outputfilter.highlight.php
deleted file mode 100755
index c10ff62..0000000
--- a/smartyplugins/outputfilter.highlight.php
+++ /dev/null
@@ -1,124 +0,0 @@
-<?php
-/**
- * Smarty plugin
- * @package Smarty
- * @subpackage plugins
- */
-
-/**
- * Smarty plugin
- * -------------------------------------------------------------
- * File: outputfilter.highlight.php
- * Type: outputfilter
- * Name: highlight
- * Version: 1.1
- * Date: Sep 18, 2003
- * Version: 1.0
- * Date: Aug 10, 2003
- * Purpose: Adds Google-cache-like highlighting for terms in a
- * template after its rendered. This can be used
- * easily integrated with the wiki search functionality
- * to provide highlighted search terms.
- * Install: Drop into the plugin directory, call
- * $gBitSmarty->loadFilter('output','highlight');
- * from application.
- * Author: Greg Hinkle <ghinkl@users.sourceforge.net>
- * patched by mose <mose@feu.org>
- * -------------------------------------------------------------
- */
-use Bitweaver\KernelTools;
-function smarty_output_highlight( $source, $gBitSmarty ) {
- global $gBitSystem;
- if( $gBitSystem->isFeatureActive( 'themes_output_highlighting' ) ) {
- // This array is used to choose colours for supplied highlight terms
- $colorArr = [ '#ffffcc', '#ffcccc', '#a0ffff', '#ffccff', '#ccffcc' ];
-
- // don't highlight characters that are used as replacements
- $find = [
- "!(\s|^)%(\s|$)!",
- "!(\s|^)#(\s|$)!",
- "!(\s|^)@(\s|$)!",
- "!(\s|^):(\s|$)!",
- "!(\s|^)&(\s|$)!",
- ];
- $words = trim( preg_replace( $find, "$1$2", urldecode( $_REQUEST['highlight'] )));
- if( empty( $words )) {
- return $source;
- }
-
- // get all text that needs to be highlighted
- $extractor = "#<div\s+class=.?body[^>]*>.*?<!--\s*end\s*\.?body\s*-->#is";
- preg_match_all( $extractor, $source, $match );
- $highlights = $match[0];
-
- $ret = [];
- foreach( $highlights as $key => $highlight ) {
- // if we picked something up, we highlight the contents
- if( !empty( $highlight ) ) {
- // highlighted words
- $source = preg_replace( $extractor, "@@@##########:#########%:##########@@@", $source );
-
- // extraction patterns and their replacements
- $patterns = [
- // scripts
- "!<script[^>]+>.*?</script>!is" => "@@@##########:#########%:#########&@@@",
- // maketoc
- "!<div class=.?maketoc[^>]*>.*?</div>!si" => "@@@##########:#########%:#########@@@@",
- // html tags
- "'<[\/\!]*?[^<>]*?>'si" => "@@@##########:#########%:#########:@@@",
- ];
-
- ksort( $patterns );
-
- foreach( $patterns as $pattern => $replace ) {
- preg_match_all( $pattern, $highlight, $match );
- $matches[$replace] = $match[0];
- $highlight = preg_replace( $pattern, $replace, $highlight );
- }
-
- // Wrap all the highlight words with a colourful span
- $wordArr = [];
- $pattern = '#"([^"]*)"#';
- if( preg_match_all( $pattern, $words, $ms ) ) {
- $wordArr = $ms[1];
- // remove the words we've just dealt with
- $words = preg_replace( $pattern, "", $words );
- }
-
- $words = preg_replace( "!\s+!", " ", $words );
- if( !empty( $words ) ) {
- $wordArr = array_merge( $wordArr, explode( ' ', strip_tags($words) ) );
- }
-
- //$wordArr = split( " ", urldecode( $words ) );
- //vd($wordArr);
- $i = 0;
- $wordList = KernelTools::tra( "Highlighted words" ).': ';
- foreach( $wordArr as $word ) {
- $wordList .= '<span style="font-weight:bold;padding:0 0.3em;color:black;background-color:'.$colorArr[$i].';">'.$word.'</span> ';
- $highlight = preg_replace( "/(".preg_quote( $word, '/' ).")/si", '<span style="font-weight:bold;color:black;background-color:'.$colorArr[$i++].';">$1</span>', $highlight );
- }
-
- krsort( $patterns );
-
- foreach( $patterns as $pattern ) {
- foreach( $matches[$pattern] as $insert ) {
- $highlight = preg_replace( "!{$pattern}!", $insert, $highlight, 1 );
- }
- }
-
- $highlight = '<div class="wordlist">'.$wordList.'</div>'.$highlight;
- $ret[] = $highlight;
- }
- }
-
- // insert the highlighted code back into the source
- foreach( $ret as $highlight ) {
- // Escape dollars in highlight so they don't back reference
- $highlight = preg_replace('!\$!','\\\$', $highlight);
- $source = preg_replace( "!@@@##########:#########%:##########@@@!", $highlight, $source, 1 );
- }
- }
-
- return $source;
-} \ No newline at end of file
diff --git a/smartyplugins/prefilter.tr.php b/smartyplugins/prefilter.tr.php
deleted file mode 100755
index 04fbbe5..0000000
--- a/smartyplugins/prefilter.tr.php
+++ /dev/null
@@ -1,86 +0,0 @@
-<?php
-namespace Bitweaver\Plugins;
-
-/**
- * Smarty plugin
- * @package Smarty
- * @subpackage plugins
- */
-
-/**
- * smarty_prefilter_tr
- *
- * @param array $source
- * @access public
- * @return full source with partially treated {tr} sections
- */
-function smarty_prefilter_tr( $source ) {
- // Now replace the matched language strings with the entry in the file
- // $return = preg_replace_callback( '#\{tr[^\{]*\}([^\{]+)\{/tr\}#', '_translate_lang', $source );
- //
- // correction: in order to match when a variable is inside {tr} tags.
- // Example: {tr}The newsletter was sent to {$sent} email addresses{/tr},
- // and where there are parameters with {tr} take away the smarty comments
- // {* *} in case they have tr tags
- return( preg_replace_callback( '#(?s)(\{tr[^\}]*\})(.+?)\{/tr\}#', '_translate_lang', preg_replace ( '#(?s)\{\*.*?\*\}#', '', $source ) ) );
-}
-
-/**
- * _translate_lang
- *
- * @param array $pKey Hash passed in by smarty_prefilter_tr() above
- * @param array $pKey[0] starting {tr} tag
- * @param array $pKey[1] string that needs to be translated
- * @param array $pKey[2] flosing {/tr} tag
- * @access protected
- * @return translated string
- *
- * Note: If you want to have a {tr} block interpreted AFTER variable substitution, add a parameter to {tr}
- * e.g.: {tr post=1}text {$that} needs to be {$evaluated}{/tr}
- */
-function _translate_lang( $pKey ) {
- global $gBitLanguage, $lang;
-
- // this is the original codeblock:
-// if (strstr($pKey[2], "{\$")) {
-// // We have a variable - keep the tags to be perhaps translated in block.tr.php
-// return $pKey[1].$pKey[2]."{/tr}";
-// } elseif ($pKey[1] == "{tr}") {
-// // no more possible translation in block.tr.php
-// return $trans;
-// } else {
-// // perhaps variable substitution to do in block.tr.php
-// return $pKey[1].$trans."{/tr}";
-// }
- // Explanation why this doesn't work:
- // - case 1
- // returning stuff like {tr}waiting for {$number} ratings{/tr}
- // will get translated by block.tr.php but only after the {$number} has
- // been interpreted and we will end up with master strings like:
- // waiting for 4 ratings
- // waiting for 5 ratings
- // waiting for 6 ratings
- //
- // - case 2
- // this should be fine since it has been translated and the {tr} blocks
- // have been removed i.e. block.tr.php won't be called anymore
- //
- // - case 3
- // this will leave everything as is. this will work as well, but only if
- // there is no {$var} in the string - see case 1
- // --- xing
-
- // if the entire string in {tr} is a variable, we pass it on to block.tr.php
- // e.g. {tr}{$menu.menu_title}{/tr} in top_bar.tpl
- // if you change this regexp, please modify the one in languages/BitLanguage.php as well (approx line 256)
- if( preg_match( '!^(\{\$[^\}]*\})+$!', $pKey[2] ) ) {
- return $pKey[1].$pKey[2]."{/tr}";
- } elseif( $pKey[1] == "{tr}" ) {
- // no parameters set for block.tr.php
- $trans = $gBitLanguage->translate( $pKey[2] );
- return $trans;
- }
- // perhaps there are parameters set for block.tr.php
- return $pKey[1].$pKey[2]."{/tr}";
-
-}