summaryrefslogtreecommitdiff
path: root/smartyplugins
diff options
context:
space:
mode:
Diffstat (limited to 'smartyplugins')
-rw-r--r--smartyplugins/block.bitmodule.php58
-rw-r--r--smartyplugins/block.box.php45
-rw-r--r--smartyplugins/block.form.php107
-rw-r--r--smartyplugins/block.forminput.php34
-rw-r--r--smartyplugins/block.jstab.php33
-rw-r--r--smartyplugins/block.jstabs.php60
-rw-r--r--smartyplugins/block.legend.php27
-rw-r--r--smartyplugins/block.navbar.php28
-rw-r--r--smartyplugins/block.repeat.php36
-rw-r--r--smartyplugins/block.sortlinks.php37
-rw-r--r--smartyplugins/block.textarea.php98
-rw-r--r--smartyplugins/block.tr.php22
-rw-r--r--smartyplugins/compiler.set.php68
-rw-r--r--smartyplugins/function.adsense.php19
-rw-r--r--smartyplugins/function.alphabar.php68
-rw-r--r--smartyplugins/function.attachhelp.php43
-rw-r--r--smartyplugins/function.banner.php32
-rw-r--r--smartyplugins/function.bit_select_datetime.php115
-rw-r--r--smartyplugins/function.bithelp.php27
-rw-r--r--smartyplugins/function.biticon.php299
-rw-r--r--smartyplugins/function.captcha.php33
-rw-r--r--smartyplugins/function.content.php27
-rw-r--r--smartyplugins/function.cookie.php16
-rw-r--r--smartyplugins/function.displaycomment.php25
-rw-r--r--smartyplugins/function.displayname.php61
-rw-r--r--smartyplugins/function.ed.php27
-rw-r--r--smartyplugins/function.elapsed.php21
-rw-r--r--smartyplugins/function.form_id.php21
-rw-r--r--smartyplugins/function.formfeedback.php77
-rw-r--r--smartyplugins/function.formhelp.php166
-rw-r--r--smartyplugins/function.formlabel.php52
-rw-r--r--smartyplugins/function.gallery.php47
-rw-r--r--smartyplugins/function.helplink.php24
-rw-r--r--smartyplugins/function.html_select_date.php255
-rw-r--r--smartyplugins/function.html_select_time.php176
-rw-r--r--smartyplugins/function.include_js.php57
-rw-r--r--smartyplugins/function.include_wiki_page_content.php79
-rw-r--r--smartyplugins/function.inlinemodule.php21
-rw-r--r--smartyplugins/function.jscalendar.php67
-rw-r--r--smartyplugins/function.jspack.php64
-rw-r--r--smartyplugins/function.jspopup.php103
-rw-r--r--smartyplugins/function.libertypagination.php72
-rw-r--r--smartyplugins/function.memusage.php55
-rw-r--r--smartyplugins/function.menu.php16
-rw-r--r--smartyplugins/function.minifind.php33
-rw-r--r--smartyplugins/function.moduleinc.php63
-rw-r--r--smartyplugins/function.nexus.php31
-rw-r--r--smartyplugins/function.pageurl.php82
-rw-r--r--smartyplugins/function.pagination.php39
-rw-r--r--smartyplugins/function.poll.php44
-rw-r--r--smartyplugins/function.popup.php134
-rw-r--r--smartyplugins/function.querytable.php77
-rw-r--r--smartyplugins/function.rcontent.php28
-rw-r--r--smartyplugins/function.required.php25
-rw-r--r--smartyplugins/function.rss.php17
-rw-r--r--smartyplugins/function.sameurl.php62
-rw-r--r--smartyplugins/function.showdate.php26
-rw-r--r--smartyplugins/function.smartlink.php199
-rw-r--r--smartyplugins/function.spellchecker.php22
-rw-r--r--smartyplugins/function.var_dump.php38
-rw-r--r--smartyplugins/modifier.act_icon.php41
-rw-r--r--smartyplugins/modifier.adjust.php43
-rw-r--r--smartyplugins/modifier.append_url.php17
-rw-r--r--smartyplugins/modifier.avatarize.php26
-rw-r--r--smartyplugins/modifier.bit_date_format.php55
-rw-r--r--smartyplugins/modifier.bit_long_date.php21
-rw-r--r--smartyplugins/modifier.bit_long_datetime.php21
-rw-r--r--smartyplugins/modifier.bit_long_time.php21
-rw-r--r--smartyplugins/modifier.bit_short_date.php21
-rw-r--r--smartyplugins/modifier.bit_short_datetime.php25
-rw-r--r--smartyplugins/modifier.bit_short_time.php21
-rw-r--r--smartyplugins/modifier.cal_date_format.php42
-rw-r--r--smartyplugins/modifier.countryflag.php23
-rw-r--r--smartyplugins/modifier.dbg.php29
-rw-r--r--smartyplugins/modifier.displayUrl.php102
-rw-r--r--smartyplugins/modifier.display_bytes.php26
-rw-r--r--smartyplugins/modifier.display_duration.php38
-rw-r--r--smartyplugins/modifier.div.php25
-rw-r--r--smartyplugins/modifier.duration.php41
-rw-r--r--smartyplugins/modifier.htmlToText.php20
-rw-r--r--smartyplugins/modifier.iconify.php28
-rw-r--r--smartyplugins/modifier.nlbr.php22
-rw-r--r--smartyplugins/modifier.ordinal_suffix.php72
-rw-r--r--smartyplugins/modifier.quoted.php24
-rw-r--r--smartyplugins/modifier.reltime.php96
-rw-r--r--smartyplugins/modifier.times.php18
-rw-r--r--smartyplugins/modifier.truncate.php49
-rw-r--r--smartyplugins/modifier.userlink.php17
-rw-r--r--smartyplugins/outputfilter.groupslayout.php102
-rw-r--r--smartyplugins/outputfilter.highlight.php121
-rw-r--r--smartyplugins/prefilter.tr.php86
-rw-r--r--smartyplugins/resource.bitpackage.php88
-rw-r--r--smartyplugins/resource.style.php64
93 files changed, 5183 insertions, 0 deletions
diff --git a/smartyplugins/block.bitmodule.php b/smartyplugins/block.bitmodule.php
new file mode 100644
index 0000000..b3cbfbb
--- /dev/null
+++ b/smartyplugins/block.bitmodule.php
@@ -0,0 +1,58 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+// $Header$
+/**
+ * \brief Smarty {bitmodule}{/bitmodule} block handler
+ *
+ * To make a module it is enough to place smth like following
+ * into corresponding mod-name.tpl file:
+ * \code
+ * {bitmodule name="module_name" title="Module title"}
+ * <!-- module Smarty/HTML code here -->
+ * {/bitmodule}
+ * \endcode
+ *
+ * This block may (can) use 2 Smarty templates:
+ * 1) module.tpl = usual template to generate module look-n-feel
+ * 2) module-error.tpl = to generate diagnostic error message about
+ * incorrect {bitmodule} parameters
+
+\Note
+error was used only in case the name was not there.
+I fixed that error case. -- mose
+
+ */
+function smarty_block_bitmodule( $pParams, $pContent, &$gBitSmarty) {
+ if( empty( $pContent )) {
+ return '';
+ } else {
+ $pParams['data'] = $pContent;
+ }
+
+// if( empty( $pParams['title'] )) {
+// $pParams['title'] = substr( $pContent, 0, 12 )."&hellip;";
+// }
+
+// if( empty( $pParams['name'] )) {
+// $pParams['name'] = preg_replace( "/[^-_a-zA-Z0-9]/", "", $pParams['title'] );
+// }
+
+ // this is outdated and will not work with our serialised cookies - xing
+ /*
+ if( $_COOKIE[$name] == 'c' ) {
+ $pParams['toggle_state'] = 'none';
+ } else {
+ $pParams['toggle_state'] = 'block';
+ }
+ */
+
+ $pParams['name'] = preg_replace( "/[^a-zA-Z0-9\\-\\_]/", "", $pParams['name'] );
+
+ $gBitSmarty->assign( 'modInfo', $pParams );
+ return $gBitSmarty->fetch('bitpackage:themes/module.tpl');
+}
+?>
diff --git a/smartyplugins/block.box.php b/smartyplugins/block.box.php
new file mode 100644
index 0000000..aba05be
--- /dev/null
+++ b/smartyplugins/block.box.php
@@ -0,0 +1,45 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {box} block plugin
+ *
+ * Type: block
+ * Name: box
+ * Input:
+ * - title (optional) box title
+ * - class (optional) overrides the default class 'box'
+ * - biticon values (optional) see function.biticon.php for details
+ * - idiv (optional) name of class of div that surrounds icon (if not set, no div is created)
+ * @uses smarty_function_escape_special_chars()
+ * @todo somehow make the variable that is contained within $iselect global --> this will allow importing of outside variables not set in $_REQUEST
+ */
+function smarty_block_box($params, $content, &$gBitSmarty) {
+ $atts = '';
+ foreach( $params as $key => $val ) {
+ switch( $key ) {
+ case 'title':
+ $gBitSmarty->assign( $key, tra( $val ) );
+ break;
+ case 'class':
+ case 'iclass':
+ case 'ipackage':
+ case 'iname':
+ case 'iexplain':
+ case 'idiv':
+ $gBitSmarty->assign( $key,$val );
+ break;
+ default:
+ $atts .= $key.'="'.$val.'" ';
+ break;
+ }
+ }
+ $gBitSmarty->assign( 'content',$content );
+ $gBitSmarty->assign( 'atts',$atts );
+ return $gBitSmarty->fetch( 'bitpackage:kernel/box.tpl' );
+}
+?>
diff --git a/smartyplugins/block.form.php b/smartyplugins/block.form.php
new file mode 100644
index 0000000..d5f605d
--- /dev/null
+++ b/smartyplugins/block.form.php
@@ -0,0 +1,107 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {form} block plugin
+ *
+ * Type: block
+ * Name: form
+ * Input:
+ * - ipackage (optional) - package where we should direct the form after submission
+ * - ifile (optional) - file that is targetted
+ * - ianchor (optional) - move to anchor after submitting
+ * if neither are set, $PHP_SELF is used as url
+ * - legend if set, it will generate a fieldset using the input as legend
+ * @uses smarty_function_escape_special_chars()
+ * @todo somehow make the variable that is contained within $iselect global --> this will allow importing of outside variables not set in $_REQUEST
+ */
+function smarty_block_form( $pParams, $pContent, &$gBitSmarty) {
+ global $gBitSystem, $gSniffer;
+
+ if( $pContent ) {
+ if( !isset( $pParams['method'] ) ) {
+ $pParams['method'] = 'post';
+ }
+ $atts = '';
+ if( isset( $pParams['secure'] ) && $pParams['secure'] ) {
+ // This is NEEDED to enforce HTTPS secure logins!
+ $url = 'https://' . $_SERVER['HTTP_HOST'];
+ } else {
+ $url = '';
+ }
+ // We need an onsubmit handler in safari to show all tabs again so uploads in hidden tabs work
+ $onsubmit = '';
+ if( $gSniffer->_browser_info['browser'] == 'sf' ) {
+ $onsubmit .= "disposeAllTabs();";
+ }
+
+ // services can add something to onsubmit
+ if( $gBitSmarty->get_template_vars( 'serviceOnsubmit' ) ) {
+ $onsubmit .= $gBitSmarty->get_template_vars( 'serviceOnsubmit' ).";";
+ }
+
+ foreach( $pParams as $key => $val ) {
+ switch( $key ) {
+ case 'ifile':
+ case 'ipackage':
+ if( $key == 'ipackage' ) {
+ if( $val == 'root' ) {
+ $url .= BIT_ROOT_URL.$pParams['ifile'];
+ } else {
+ $url .= constant( strtoupper( $val ).'_PKG_URL' ).$pParams['ifile'];
+ }
+ }
+ break;
+ case 'legend':
+ if( !empty( $val ) ) {
+ $legend = '<legend>'.tra( $val ).'</legend>';
+ }
+ break;
+ // this is needed for backwards compatibility since we sometimes pass in a url
+ case 'action':
+ if( substr( $val, 0, 4 ) == 'http' ) {
+ if( isset( $pParams['secure'] ) && $pParams['secure'] && ( substr( $val, 0, 5 ) != 'https' )) {
+ $val = preg_replace( '/^http/', 'https', $val );
+ }
+ $url = $val;
+ } else {
+ $url .= $val;
+ }
+ break;
+ case 'ianchor':
+ case 'secure':
+ break;
+ case 'onsubmit':
+ if( !empty( $val ) ) {
+ $onsubmit .= $val.";";
+ }
+ break;
+ default:
+ if( !empty( $val ) ) {
+ $atts .= $key.'="'.$val.'" ';
+ }
+ break;
+ }
+ }
+
+ if( empty( $url )) {
+ $url = $_SERVER['PHP_SELF'];
+ } else if( $url == 'https://' . $_SERVER['HTTP_HOST'] ) {
+ $url .= $_SERVER['PHP_SELF'];
+ }
+
+ $onsub = ( !empty( $onsubmit ) ? ' onsubmit="'.$onsubmit.'"' : '' );
+ $ret = '<form action="'.$url.( !empty( $pParams['ianchor'] ) ? '#'.$pParams['ianchor'] : '' ).'" '.$atts.$onsub.'>';
+ $ret .= isset( $legend ) ? '<fieldset>'.$legend : '<div>'; // adding the div makes it easier to be xhtml compliant
+ $ret .= $pContent;
+ $ret .= '<div class="clear"></div>'; // needed to avoid rendering issues
+ $ret .= isset( $legend ) ? '</fieldset>' : '</div>'; // close the open tags
+ $ret .= '</form>';
+ return $ret;
+ }
+}
+?>
diff --git a/smartyplugins/block.forminput.php b/smartyplugins/block.forminput.php
new file mode 100644
index 0000000..b507ac3
--- /dev/null
+++ b/smartyplugins/block.forminput.php
@@ -0,0 +1,34 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {forminput} block plugin
+ *
+ * Type: block
+ * Name: forminput
+ */
+function smarty_block_forminput($params, $content, &$gBitSmarty) {
+ // defaults
+ $class = "";
+ $id = "";
+
+ extract( $params );
+
+ if( !empty( $class ) ){
+ $class = ' '.trim( $class );
+ }
+
+ if( !empty( $id ) ){
+ $id = 'id="'.trim( $id ).'"';
+ }
+
+ if( $content ) {
+ $ret = '<div class="forminput'.$class.'" '.$id.' >'.$content.'</div>';
+ return $ret;
+ }
+}
+?>
diff --git a/smartyplugins/block.jstab.php b/smartyplugins/block.jstab.php
new file mode 100644
index 0000000..7c8ccc9
--- /dev/null
+++ b/smartyplugins/block.jstab.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {jstab} block plugin
+ *
+ * Type: block
+ * Name: jstab
+ * Input:
+ * Abstract: Used to enclose a set of tabs
+ */
+
+function smarty_block_jstab( $pParams, $pContent, &$gBitSmarty ) {
+
+ // if this is modified, please adjust the preg_match_all() pattern in block.jstabs.php
+ $pClass = isset( $pParams['class'] ) ? ' '.$pParams['class'] : '';
+
+ $tClass = isset( $pParams['class'] ) ? ' '.$pParams['class'] : '';
+ $tClick = isset( $pParams['onclick'] ) ? ' onclick="'.$pParams['onclick'].'"' : '';
+ $tTitle = tra( isset( $pParams['title'] ) ? $pParams['title'] : 'No Title' );
+
+ $ret = '<div class="tabpage' . $pClass . '">';
+ $ret .= '<h4 class="tab' . $tClass . '"' . $tClick . '>' . $tTitle . '</h4>';
+ $ret .= $pContent;
+ $ret .= '</div>';
+
+ return $ret;
+}
+?>
diff --git a/smartyplugins/block.jstabs.php b/smartyplugins/block.jstabs.php
new file mode 100644
index 0000000..ae73a79
--- /dev/null
+++ b/smartyplugins/block.jstabs.php
@@ -0,0 +1,60 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {jstabs} block plugin
+ *
+ * Type: block
+ * Name: jstabs
+ * Input: you can use {jstab tab=<tab number>} (staring with 0) to select a given tab
+ * or you can use the url to do so: page.php?jstab=<tab number>
+ * Abstract: Used to enclose a set of tabs
+ */
+function smarty_block_jstabs( $pParams, $pContent, &$gBitSmarty ) {
+ global $gBitSystem;
+ extract( $pParams );
+
+ $alwaysTab = ( isset( $alwaysTab )) ? ( boolean )$alwaysTab : FALSE;
+
+ // Work out if we want to insert tabs at all on this page
+ // This is necessary since we insert tabs dynamically using services
+ preg_match_all( '#<div class="tabpage.*?">#', $pContent, $tabs );
+ if( !empty( $tabs[0] ) && count( $tabs[0] ) <= 1 && $alwaysTab === FALSE ) {
+ $pContent = preg_replace( "#<h4[^>]*tab.*?</h4>#", '', $pContent );
+ return $pContent;
+ }
+
+ // When tabs are disabled, we simply wrap the tabs with the appropriate div for styling
+ if( $gBitSystem->isFeatureActive( 'site_disable_jstabs' ) ) {
+ $ret = '<div class="tabpane"';
+ $ret .= !empty( $pParams['id'] ) ? ' id="'.$pParams['id'].'"' : '';
+ $ret .= '>'.$pContent.'</div>';
+ } else {
+ // @TODO review this conditional or comment its purpose, $tab never seems to be set
+ if( isset( $tab ) || isset( $_REQUEST['jstab'] ) ) {
+ // make sure we aren't passed any evil shit
+ if( !isset( $tab ) && isset( $_REQUEST['jstab'] ) && preg_match( "!^\d+$!", $_REQUEST['jstab'] ) ) {
+ $tab = $_REQUEST['jstab'];
+ }
+ $ret = '<div class="tabpane" id="jstabs">';
+ $ret .= "<script type=\"text/javascript\">/*<![CDATA[*/ tabPane = new WebFXTabPane( $( 'jstabs' ), true ); /*]]>*/</script>";
+ $ret .= $pContent;
+ $ret .= "<script type=\"text/javascript\">/*<![CDATA[*/ setupAllTabs();".( isset( $tab ) ? "var tabPane; tabPane.setSelectedIndex( $tab );" : "" )."/*]]>*/</script>";
+ $ret .= '</div>';
+ } else {
+ $ret = '<div class="tabpane"';
+ $ret .= !empty( $pParams['id'] ) ? ' id="'.$pParams['id'].'"' : '';
+ $ret .= '>';
+ $ret .= $pContent;
+ $ret .= "<script type=\"text/javascript\">/*<![CDATA[*/ setupAllTabs();var tabPane; /*]]>*/</script>";
+ $ret .= '</div>';
+ }
+ }
+
+ return $ret;
+}
+?>
diff --git a/smartyplugins/block.legend.php b/smartyplugins/block.legend.php
new file mode 100644
index 0000000..3842769
--- /dev/null
+++ b/smartyplugins/block.legend.php
@@ -0,0 +1,27 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {form} block plugin
+ *
+ * Type: block
+ * Name: form
+ * Input:
+ * - legend (optional) - text that appears in the legend
+ */
+function smarty_block_legend($params, $content, &$gBitSmarty) {
+ if( $content ) {
+ $attributes = '';
+ $attributes .= !empty( $params['class'] ) ? ' class="'.$params['class'].'" ' : '' ;
+ $attributes .= !empty( $params['id'] ) ? ' id="'.$params['id'].'" ' : '' ;
+ $ret = '<fieldset '.$attributes.'><legend>'.tra( $params['legend'] ).'</legend>';
+ $ret .= $content;
+ $ret .= '<div class="clear"></div></fieldset>';
+ return $ret;
+ }
+}
+?>
diff --git a/smartyplugins/block.navbar.php b/smartyplugins/block.navbar.php
new file mode 100644
index 0000000..e4c5e5f
--- /dev/null
+++ b/smartyplugins/block.navbar.php
@@ -0,0 +1,28 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {navbar} block plugin
+ *
+ * Type: block
+ * Name: navbar
+ * Input: set of links that are used for navigation purposes
+ */
+function smarty_block_navbar($params, $content, &$gBitSmarty) {
+ $links = smarty_block_navbar_get_links( $content );
+ $gBitSmarty->assign( 'links',$links );
+ return $gBitSmarty->fetch( 'bitpackage:kernel/navbar.tpl' );
+}
+function smarty_block_navbar_get_links( $content ) {
+ $links = array();
+ if( preg_match_all( "/<a.*?href=\".*?\">.*?<\/a>/i",$content,$res ) ) {
+ $res = $res[0];
+ $links = array_unique( $res );
+ }
+ return $links;
+}
+?> \ No newline at end of file
diff --git a/smartyplugins/block.repeat.php b/smartyplugins/block.repeat.php
new file mode 100644
index 0000000..f11e69a
--- /dev/null
+++ b/smartyplugins/block.repeat.php
@@ -0,0 +1,36 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * File: block.repeat.php
+ * Type: block
+ * Name: repeat
+ * Purpose: repeat a template block a given number of times
+ * Parameters: count [required] - number of times to repeat
+ * assign [optional] - variable to collect output
+ * Author: Scott Matthewman <scott@matthewman.net>
+ * -------------------------------------------------------------
+ */
+function smarty_block_repeat( $params, $content, &$gBitSmarty ) {
+ if( !empty( $content ) ) {
+ $intCount = intval( $params['count'] );
+ if( $intCount < 0 ) {
+ $gBitSmarty->trigger_error( "block: negative 'count' parameter" );
+ return;
+ }
+
+ $strRepeat = str_repeat( $content, $intCount );
+ if( !empty( $params['assign'] ) ) {
+ $gBitSmarty->assign($params['assign'], $strRepeat );
+ } else {
+ echo $strRepeat;
+ }
+ }
+}
+?>
diff --git a/smartyplugins/block.sortlinks.php b/smartyplugins/block.sortlinks.php
new file mode 100644
index 0000000..7713656
--- /dev/null
+++ b/smartyplugins/block.sortlinks.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * File: block.sortlinks.php
+ * Type: block
+ * Name: sortlinks
+ * -------------------------------------------------------------
+ */
+function smarty_block_sortlinks($params, $content, &$gBitSmarty)
+{
+if ($content) {
+ $links=spliti("\n",$content);
+ $links2=array();
+ foreach ($links as $value) {
+ $splitted=preg_split("/[<>]/",$value,-1,PREG_SPLIT_NO_EMPTY);
+ $links2[$splitted[2]]=$value;
+ }
+
+ if( isset( $params['order'] ) && $params['order']=='reverse' ) {
+ krsort( $links2 );
+ } else {
+ ksort($links2);
+ }
+
+ foreach($links2 as $value) {
+ echo $value;
+ }
+}
+}
+?>
diff --git a/smartyplugins/block.textarea.php b/smartyplugins/block.textarea.php
new file mode 100644
index 0000000..2e720c2
--- /dev/null
+++ b/smartyplugins/block.textarea.php
@@ -0,0 +1,98 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ * @link http://www.bitweaver.org/wiki/block_textarea block_textarea
+ */
+
+/**
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * File: block.textarea.php
+ * Type: block
+ * Name: textarea
+ * -------------------------------------------------------------
+ */
+function smarty_block_textarea( $pParams, $pContent, &$gBitSmarty ) {
+ global $gBitSystem, $gContent, $gLibertySystem;
+ $attributes = '';
+ $style = '';
+ $class = '';
+ if (((!empty($gLibertySystem->mPlugins['bithtml']) && $gLibertySystem->mPlugins['bithtml']['is_active'] == 'y') ||
+ (!empty($gLibertySystem->mPlugins['tikiwiki']) && $gLibertySystem->mPlugins['tikiwiki']['is_active'] == 'y' &&
+ $gBitSystem->isFeatureActive( 'content_force_allow_html' )))
+ && empty( $pParams['nowysiwyg'] )
+ ) {
+ $class = 'wysiwyg';
+ }
+ if (empty($pParams['rows'])) {
+ $pParams['rows'] = (empty($_COOKIE['rows']) ? $gBitSystem->getConfig('liberty_textarea_height', 20) : $_COOKIE['rows']);
+ }
+ if (empty($pParams['cols'])) {
+ $pParams['cols'] = (empty($_COOKIE['cols']) ? $gBitSystem->getConfig('liberty_textarea_width', 35) : $_COOKIE['rows']);
+ }
+ if (empty($pParams['id'])) {
+ $pParams['id'] = LIBERTY_TEXT_AREA;
+ }
+ if( empty( $pParams['name'] ) ){
+ $pParams['name'] = 'edit';
+ }
+ if( empty( $pParams['maxchars'] ) ){
+ // prevent smarty presistence of vars
+ $pParams['maxchars'] = 0;
+ }
+ foreach ($pParams as $_key=>$_value) {
+ switch ($_key) {
+ case 'name':
+ case 'id':
+ case 'help':
+ case 'noformat':
+ case 'label':
+ case 'error':
+ case 'required':
+ case 'maxchars':
+ $gBitSmarty->assign("textarea_".$_key, $_value);
+ break;
+ case 'class':
+ $class .= ' '.$_key;
+ break;
+ case 'style':
+ $style .= $_key;
+ break;
+ case 'gContent':
+ // Trick out gContent
+ $oldContent = $gContent;
+ $gContent = $_value;
+ $gBitSmarty->assign('gContent', $_value);
+ break;
+ default:
+ $attributes .= $_key.'="'.$_value.'" ';
+ break;
+ }
+ }
+ // We control hieght here when bnspell is on so as to be able to not
+ // lose the rest of the style on the textarea.
+ if ($gBitSystem->isPackageActive('bnspell')) {
+ $style .= (empty($style) ? '' : ';').'height:'.$pParams['rows'].'em;';
+ }
+ $gBitSmarty->assign('textarea_attributes', $attributes);
+ $gBitSmarty->assign('textarea_data', $pContent);
+ if (!empty($style)) {
+ $gBitSmarty->assign('textarea_style', 'style="'.$style.'"');
+ }
+ $gBitSmarty->assign('textarea_class', 'class="'.$class.'"');
+ $ret = $gBitSmarty->fetch("bitpackage:liberty/edit_textarea.tpl");
+
+ // Restore gContent
+ if (isset($oldContent)) {
+ $gContent = $oldContent;
+ $gBitSmarty->assign('gContent', $oldContent);
+ }
+
+ // since we have the funky {textarea} in play, we'll display the edit help tab
+ $gBitSmarty->assign( 'display_help_tab', TRUE );
+
+ return $ret;
+}
+?>
diff --git a/smartyplugins/block.tr.php b/smartyplugins/block.tr.php
new file mode 100644
index 0000000..92e713d
--- /dev/null
+++ b/smartyplugins/block.tr.php
@@ -0,0 +1,22 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * File: block.translate.php
+ * Type: block
+ * Name: translate
+ * Purpose: translate a block of text
+ * -------------------------------------------------------------
+ */
+//global $lang;
+//include_once('lang/language.php');
+function smarty_block_tr( $pParams, $pContent, &$gBitSmarty ) {
+ echo( tra( $pContent ) );
+}
+?>
diff --git a/smartyplugins/compiler.set.php b/smartyplugins/compiler.set.php
new file mode 100644
index 0000000..5417288
--- /dev/null
+++ b/smartyplugins/compiler.set.php
@@ -0,0 +1,68 @@
+<?php
+/**
+ * @version $Header$
+ * @package kernel
+ * @subpackage plugins
+ *
+ * Smarty {set} compiler function plugin
+ *
+ * File: compiler.set.php
+ * Type: compiler function
+ * Name: set
+ * Purpose: Set a value to a variable (also arrays).
+ * The optional parameter "if" is used to set the value if the test is true. The test can be: 'empty', '!empty', 'is_null', '!is_null', 'isset', '!isset', 'is_void'.
+ * The new command 'is_void' test if the variable is empty and != 0, very useful for test $_REQUEST parameters.
+ *
+ * @link http://smarty.incutio.com/?page=set
+ * @link http://www.dav-muz.net/
+ * @version 1.0
+ * @copyright Copyright 2006 by Muzzarelli Davide
+ * @author Davide Muzzarelli <info@dav-muz.net>
+ *
+ * @param array parameters "var": variable. "value": value to assign. "if": assign the value only if this test is true (tests avaiables: 'empty', '!empty', 'is_null', '!is_null', 'isset', '!isset', 'is_void').
+ * @param Smarty_Compiler object
+ * @return void|string
+ */
+
+/**
+ * Set Compiler Function
+ */
+function smarty_compiler_set($params, &$smarty) {
+ // Extract if "value" parameter contain an array
+ $regularExpression = '/ value=array\([\'"]?.*[\'"]?\)/';
+ if (preg_match($regularExpression, $params, $array)) {
+ $array = substr($array[0], 7);
+ $params = preg_replace($regularExpression, '', $params);
+ }
+
+ $params = $smarty->_parse_attrs($params);
+ $functionsPermitted = array('empty', '!empty', 'is_null', '!is_null', 'isset', '!isset', 'is_void'); // Functions permitted in "if" parameter.
+
+ if (!isset($params['var'])) {
+ $smarty->_syntax_error("set: missing 'var' parameter", E_USER_WARNING);
+ return;
+ }
+ if (!empty($array)) {
+ $params['value'] = $array;
+ }
+
+ if (!isset($params['value'])) { // Clean setting
+ return "{$params['var']} = null;";
+ } elseif (isset($params['if'])) { // Setting with "if" parameter
+ $params['if'] = substr($params['if'], 1, -1);
+ if (in_array($params['if'], $functionsPermitted)) {
+ if ($params['if'] == 'is_void') { // "is_void" command
+ return "if (empty({$params['var']}) and ({$params['var']} !== 0) and ({$params['var']} !== '0')) {$params['var']} = {$params['value']};";
+ } else { // others commands
+ return "if ({$params['if']}({$params['var']})) {$params['var']} = {$params['value']};";
+ }
+ } else { // "if" parameter not correct
+ $smarty->_syntax_error("set: 'if' parameter not valid", E_USER_WARNING);
+ return;
+ }
+ } else { // normal setting
+ return "{$params['var']} = {$params['value']};";
+ }
+}
+?>
+
diff --git a/smartyplugins/function.adsense.php b/smartyplugins/function.adsense.php
new file mode 100644
index 0000000..83eee91
--- /dev/null
+++ b/smartyplugins/function.adsense.php
@@ -0,0 +1,19 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+* smarty_function_adsense
+*/
+function smarty_function_adsense( $params, &$gBitSmarty ) {
+ global $gBitSystem, $gLibertySystem;
+ if( $gBitSystem->isFeatureActive( 'liberty_plugin_status_dataadsense' ) ) {
+ echo data_adsense( '', $params );
+ } else {
+ echo "You need to activate the adsense liberty plugin to use this.";
+ }
+}
+?>
diff --git a/smartyplugins/function.alphabar.php b/smartyplugins/function.alphabar.php
new file mode 100644
index 0000000..e49441f
--- /dev/null
+++ b/smartyplugins/function.alphabar.php
@@ -0,0 +1,68 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ * @author xing <xing$synapse.plus.com>
+ */
+
+/**
+ * Smarty {alphabar} function plugin
+ *
+ * Type: function
+ * Name: alphabar
+ * Input:
+ * - iskip (optional) array of chars that can be skipped
+ * - iall (optional) if set to anything, it will include a link to all
+ * - ifile (optional) set the file where the link should point (default is the current file)
+ * - ipackage (optional) set the package the link should point to (default is the current package)
+ * - * (optional) anything else that gets added to the pile of items is appended using &amp;$key=$val
+ * Example - {alphabar}
+ */
+function smarty_function_alphabar( $params, &$gBitSmarty ) {
+ extract( $params );
+
+ // work out what the url is
+ if( isset( $ifile ) ) {
+ if( isset( $ipackage ) ) {
+ if( $ipackage == 'root' ) {
+ $url = BIT_ROOT_URL.$ifile;
+ } else {
+ $url = constant( strtoupper( $ipackage ).'_PKG_URL' ).$ifile;
+ }
+ } else {
+ $url = constant( strtoupper( ACTIVE_PACKAGE ).'_PKG_URL' ).$ifile;
+ }
+ } else {
+ $url = $_SERVER['PHP_SELF'];
+ }
+
+ $alphabar_params = array( 'ifile', 'ipackage', 'iall' );
+ // append any other paramters that were passed in
+ $url_params = '';
+ foreach( $params as $key => $val ) {
+ if( !empty( $val ) && !in_array( $key, $alphabar_params ) ) {
+ $url_params .= '&amp;'.$key."=".$val;
+ }
+ }
+
+ $ret = '<div class="pagination alphabar">';
+ $alpha = array( 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0-9','+' );
+ foreach( $alpha as $char ) {
+ if( empty( $iskip ) || !in_array( $char, $iskip )) {
+ $wrap = array( 'open' => '', 'close' => '' );
+ if( !empty( $_REQUEST['char'] ) && $_REQUEST['char'] == strtolower( $char )) {
+ $wrap = array( 'open' => '<strong>', 'close' => '</strong>' );
+ }
+ $ret .= $wrap['open'].'<a href="'.$url.'?char='.urlencode( strtolower( $char )).$url_params.'">'.$char.'</a>'.$wrap['close'].' ';
+ }
+ }
+
+ if( !empty( $params['iall'] ) ) {
+ $ret .= '<a href="'.$url.'?char='.urlencode( strtolower( 'All' ) ).$url_params.'">'.tra( 'All' ).'</a> ';
+ }
+ $ret .= '</div>';
+
+ return $ret;
+}
+?>
diff --git a/smartyplugins/function.attachhelp.php b/smartyplugins/function.attachhelp.php
new file mode 100644
index 0000000..73524ae
--- /dev/null
+++ b/smartyplugins/function.attachhelp.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+* smarty_function_attachmenthelp
+*/
+function smarty_function_attachhelp( $pParams, &$gBitSmarty ) {
+ global $gBitSystem;
+
+ // print legend if desired
+ if( !empty( $pParams['legend'] )) {
+ $gBitSmarty->assign( 'legend', TRUE );
+ }
+
+ // get all the info into the right place
+ if( !empty( $pParams['hash'] ) && is_array( $pParams['hash'] )) {
+ $pParams = array_merge( $pParams, $pParams['hash'] );
+ unset( $pParams['hash'] );
+ }
+
+ // prepare the output
+ if( empty( $pParams['attachment_id'] )) {
+ $gBitSmarty->trigger_error( tra( 'You need to provide an attachment_id' ));
+ return;
+ } elseif( !empty( $pParams['wiki_plugin_link'] )) {
+ $attachhelp = trim( $pParams['wiki_plugin_link'] );
+ } else {
+ $attachhelp = "{attachment id={$pParams['attachment_id']}}";
+ }
+
+ // if we're viewing this page at a particular size, we want to include that in the output
+ if( !empty( $_REQUEST['size'] )) {
+ $attachhelp = str_replace( "}", " size={$_REQUEST['size']}}", $attachhelp );
+ }
+
+ $gBitSmarty->assign( 'attachhelp', $attachhelp );
+ return $gBitSmarty->fetch( 'bitpackage:liberty/attachhelp.tpl' );
+}
+?>
diff --git a/smartyplugins/function.banner.php b/smartyplugins/function.banner.php
new file mode 100644
index 0000000..c80d73c
--- /dev/null
+++ b/smartyplugins/function.banner.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+* smarty_function_banner
+*/
+function smarty_function_banner($params, &$gBitSmarty)
+{
+ global $gBitSystem;
+ include_once( BANNERS_PKG_PATH.'banner_lib.php' );
+ if(!isset($bannerlib)) {
+ $bannerlib = new BannerLib();
+ }
+
+ extract($params);
+ // Param = zone
+
+ if (empty($zone)) {
+ $gBitSmarty->trigger_error("assign: missing 'zone' parameter");
+ return;
+ }
+ $banner = $bannerlib->select_banner($zone);
+ print($banner);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/smartyplugins/function.bit_select_datetime.php b/smartyplugins/function.bit_select_datetime.php
new file mode 100644
index 0000000..6110c4e
--- /dev/null
+++ b/smartyplugins/function.bit_select_datetime.php
@@ -0,0 +1,115 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ * @version $Id$
+ * @author hiran
+ */
+
+/**** smarty_function_bit_select_datetime
+ *
+ * NOTE: This code looks good but needs intensive testing, especially with different date/time formats.
+ *
+ * This function generates HTML code that adds a date picker to an HTML form.
+ * Depending on Bitweaver settings (Administration/Themes/Theme Settings)
+ * this can be the ordinary Smarty way of date/time picking (see html_select_date and html_select_time functions)
+ * or a nice javascript calendar.
+ *
+ * Parameters:
+ * name The name of the inputfield. Use this to identify the date/datetime input from other inputs. (will be used for <input name="..., defaults to 'date'.
+ * showtime defines whether you need a date or datetime picking method. Set to 'true' or 'false', defaults to 'true'.
+ * format The datetime format used to display/return the timestamp. Defaults to the user's preference on this Bitweaver system.
+ * time The time value to be displayed, in the format given in the format parameter. Defaults to the current system time.
+ *
+ * Usage sample:
+ * <form action="edit.php" method="POST">
+ * {formlabel label="Test JSCalendar"}
+ * {forminput}
+ * {bit_select_datetime name="mydate2" time=$gContent->mInfo.start}
+ * {/forminput}
+ * </form>
+ *
+ * Later, in edit.php, use this code to obtain the timestamp in UTC:
+ * $timestamp = $gBitSystem->mServerTimestamp->getUTCFromDisplayDate(_REQUEST['mydate2'])
+ *
+ */
+function smarty_function_bit_select_datetime( $pParams, &$gBitSmarty ) {
+ global $gBitSystem;
+ global $gBitUser;
+
+ // Default values
+ $name = 'date'; // ID of the input field
+ // unsupported as of now $format = $gBitSystem->getConfig( 'site_short_date_format' ).' '.$gBitSystem->getConfig( 'site_short_time_format' ); // date format used
+ $showtime = 'true'; //true: show time; false: pick date only
+ $time = time(); // override the currently set date
+
+ //extract actual parameters from the params hashmap.
+ extract( $pParams );
+
+ //calculate a name we can use for additional (internal) fields
+ $nname = str_replace('[', '_', str_replace(']', '_', $name));
+
+ if( $gBitSystem->isFeatureActive( 'site_use_jscalendar' ) ) {
+ // A readonly field will be used to display the currently selected value.
+ //A button besides the field will bring up the calendar (style similar to other PIM rich client applications)
+ //It is the readonly input field that will be evaluated back on the server
+
+ //unsupported $format = preg_replace( "/%Z/", "", $format ); // JSCalendar does not know about time zones
+ $html_result = "<input type=\"text\" name=\"$name\" id=\"${nname}_id\" value=\"$time\" readonly />\n";
+ $html_result = $html_result . "<button type=\"reset\" id=\"${nname}_button\">...</button>\n";
+ $html_result = $html_result . "<script type=\"text/javascript\">\n";
+ $html_result = $html_result . " Calendar.setup({\n";
+ $html_result = $html_result . " date : \"$time\",\n";
+ $html_result = $html_result . " inputField : \"${nname}_id\", // id of the input field\n";
+ $html_result = $html_result . " ifFormat : \"%Y-%m-%d %H:%M\", // format of the input field\n";
+ $html_result = $html_result . " showsTime : $showtime, // will display a time selector\n";
+ $html_result = $html_result . " button : \"${nname}_button\", // trigger for the calendar (button ID)\n";
+ $html_result = $html_result . " singleClick : true, // double-click mode\n";
+ $html_result = $html_result . " step : 1 // show all years in drop-down boxes (instead of every other year as default)\n";
+ $html_result = $html_result . " });\n";
+ $html_result = $html_result . "</script>\n";
+ } else {
+ require_once $gBitSmarty->_get_plugin_filepath( 'function', 'html_select_date' );
+ require_once $gBitSmarty->_get_plugin_filepath( 'function', 'html_select_time' );
+
+ // we use html_select_date and html_select_time to pick a date, which generate a number of select fields.
+ //On every change a hidden field will be updated via javascript.
+ //it's the hidden field that is evaluated back on the server.
+
+ $pDate = array (
+ 'prefix' => $nname,
+ 'all_extra' => "onchange=\"bit_select_datetime_${nname}()\"",
+ 'time' => $time
+ );
+
+ $pTime = array (
+ 'prefix' => $nname,
+ 'all_extra' => "onchange=\"bit_select_datetime_${nname}()\"",
+ 'display_seconds' => false,
+ 'time' => $time
+ );
+
+ $html_result = "<input type=\"hidden\" name=\"$name\" value=\"${time}\">";
+ $html_result .= smarty_function_html_select_date( $pDate, $gBitSmarty );
+ if( $showtime == 'true' ) {
+ $html_result .= smarty_function_html_select_time( $pTime, $gBitSmarty );
+ $html_result .= "<script type=\"text/javascript\"> \n";
+ $html_result .= " function bit_select_datetime_${nname} () {\n";
+ $html_result .= " var date = new Date(); \n date.setHours ( document.getElementsByName(\"${nname}Hour\")[0].value);\ndate.setMinutes( document.getElementsByName(\"${nname}Minute\")[0].value); \n date.setFullYear(document.getElementsByName(\"${nname}Year\")[0].value,document.getElementsByName(\"${nname}Month\")[0].value-1,document.getElementsByName(\"${nname}Day\")[0].value); \n ";
+ $html_result .= "document.getElementsByName(\"${name}\")[0].value = Math.floor(date.getTime() / 1000);";
+ $html_result .= "}\n";
+ $html_result .= "</script>\n";
+ } else {
+ $html_result .= "<script type=\"text/javascript\">\n";
+ $html_result .= " function bit_select_datetime_${name} () {\n";
+ $html_result .= " var date = new Date(); \n date.setDate( document.getElementsByName(\"${nname}Day\")[0].value ); \n date.setMonth(document.getElementsByName(\"${nname}Month\")[0].value-1); \n date.setFullYear(document.getElementsByName(\"${nname}Year\")[0].value); \n ";
+ $html_result .= " document.getElementsByName(\"${name}\")[0].value = Math.floor(date.getTime() / 1000);";
+ $html_result .= "}\n";
+ $html_result .= "</script>\n";
+ }
+ }
+
+ return $html_result."(".$gBitUser->getPreference('site_display_utc').")\n";
+}
+?>
diff --git a/smartyplugins/function.bithelp.php b/smartyplugins/function.bithelp.php
new file mode 100644
index 0000000..19c31fc
--- /dev/null
+++ b/smartyplugins/function.bithelp.php
@@ -0,0 +1,27 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * source elements
+ */
+require_once('function.biticon.php');
+/**
+* smarty_function_bithelp
+*/
+function smarty_function_bithelp($params, &$gBitSmarty) {
+ global $gBitSystem, $gBitUser;
+ $outstr = "";
+ if( $gBitSystem->isFeatureActive('site_online_help') ){
+ if($gBitUser->hasPermission( 'p_admin' )){
+ $outstr .= "<a href=\"".KERNEL_PKG_URL."admin/index.php\">".smarty_function_biticon(array('ipackage'=>'icons', 'iname'=>'preferences-system', 'iexplain'=>'Administration Menu'),$gBitSmarty)."</a> ";
+ }
+ if( $helpInfo = $gBitSmarty->get_template_vars('TikiHelpInfo') ) {
+ $outstr .= "<a href=\"".$helpInfo["URL"]."\" >".smarty_function_biticon(array('ipackage'=>'icons', 'iname'=>'help-browser', 'iexplain'=>(empty($helpInfo["Desc"])?"help":$helpInfo["Desc"])),$gBitSmarty)."</a>";
+ }
+ }
+ return $outstr;
+}
diff --git a/smartyplugins/function.biticon.php b/smartyplugins/function.biticon.php
new file mode 100644
index 0000000..d7f3b10
--- /dev/null
+++ b/smartyplugins/function.biticon.php
@@ -0,0 +1,299 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ * @link http://www.bitweaver.org/wiki/function_biticon function_biticon
+ */
+
+/**
+ * biticon_first_match
+ *
+ * @param string $pDir Directory in which we want to search for the icon
+ * @param array $pFilename Icon name without the extension
+ * @access public
+ * @return Icon name with extension on success, FALSE on failure
+ */
+function biticon_first_match( $pDir, $pFilename ) {
+ if( is_dir( $pDir )) {
+ global $gSniffer;
+
+ // if this is MSIE < 7, we try png last.
+ if( $gSniffer->_browser_info['browser'] == 'ie' && $gSniffer->_browser_info['maj_ver'] < 7 ) {
+ $extensions = array( 'gif', 'jpg', 'png' );
+ } else {
+ $extensions = array( 'png', 'gif', 'jpg' );
+ }
+
+ foreach( $extensions as $ext ) {
+ if( is_file( $pDir.$pFilename.'.'.$ext ) ) {
+ return $pFilename.'.'.$ext;
+ }
+ }
+ }
+ return FALSE;
+}
+
+/**
+ * Turn collected information into an html image
+ *
+ * @param boolean $pParams['url'] set to TRUE if you only want the url and nothing else
+ * @param string $pParams['iexplain'] Explanation of what the icon represents
+ * @param string $pParams['iforce'] takes following optins: icon, icon_text, text - will override system settings
+ * @param string $pFile Path to icon file
+ * @param string iforce override site-wide setting how to display icons (can be set to 'icon', 'text' or 'icon_text')
+ * @access public
+ * @return Full <img> on success
+ */
+function biticon_output( $pParams, $pFile ) {
+ global $gBitSystem;
+ $iexplain = isset( $pParams["iexplain"] ) ? tra( $pParams["iexplain"] ) : 'please set iexplain';
+
+ if( empty( $pParams['iforce'] )) {
+ $pParams['iforce'] = NULL;
+ }
+
+ if( isset( $pParams["url"] )) {
+ $outstr = $pFile;
+ } else {
+ if(( $gBitSystem->getConfig( 'site_biticon_display_style' ) == 'text' || $pParams['iforce'] == 'text' ) && $pParams['iforce'] != 'icon' ) {
+ $outstr = $iexplain;
+ } else {
+ $outstr='<img src="'.$pFile.'"';
+ if( isset( $pParams["iexplain"] ) ) {
+ $outstr .= ' alt="'.tra( $pParams["iexplain"] ).'" title="'.tra( $pParams["iexplain"] ).'"';
+ } else {
+ $outstr .= ' alt=""';
+ }
+
+ $ommit = array( 'ilocation', 'ipackage', 'ipath', 'iname', 'iexplain', 'iforce', 'istyle', 'iclass' );
+ foreach( $pParams as $name => $val ) {
+ if( !in_array( $name, $ommit ) ) {
+ $outstr .= ' '.$name.'="'.$val.'"';
+ }
+ }
+
+ if( !isset( $pParams["iclass"] ) ) {
+ $outstr .= ' class="icon"';
+ } else {
+ $outstr .= ' class="'.$pParams["iclass"].'"';
+ }
+
+ if( isset( $pParams["onclick"] ) ) {
+ $outstr .= ' onclick="'.$pParams["onclick"].'"';
+ }
+
+ // insert image width and height
+ list( $width, $height, $type, $attr ) = @getimagesize( BIT_ROOT_PATH.$pFile );
+ if( !empty( $width ) && !empty( $height ) ) {
+ $outstr .= ' width="'.$width.'" height="'.$height.'"';
+ }
+
+ $outstr .= " />";
+
+ if( $gBitSystem->getConfig( 'site_biticon_display_style' ) == 'icon_text' && $pParams['iforce'] != 'icon' || $pParams['iforce'] == 'icon_text' ) {
+ $outstr .= '&nbsp;'.$iexplain;
+ }
+ }
+ }
+
+ if( !preg_match( "#^broken\.#", $pFile )) {
+ if( !biticon_write_cache( $pParams, $outstr )) {
+ echo tra( 'There was a problem writing the icon cache file' );
+ }
+ }
+
+ return $outstr;
+}
+
+/**
+ * smarty_function_biticon
+ *
+ * @param array $pParams['ipath'] subdirectory within icon directory
+ * @param array $pParams['iname'] name of the icon without extension
+ * @param array $pParams['ipackage'] package the icon should be searched for - if it's part of an icon theme, this should be set to 'icons'
+ * @param array $gBitSmarty Referenced object
+ * @access public
+ * @return final <img>
+ */
+function smarty_function_biticon( $pParams, &$gBitSmarty, $pCheckSmall = FALSE ) {
+ global $gBitSystem, $gBitThemes, $gSniffer;
+
+ // this is needed in case everything goes horribly wrong
+ $copyParams = $pParams;
+
+ // ensure that ipath has a leading and trailing slash
+ if( !empty( $pParams['ipath'] )) {
+ $pParams['ipath'] = str_replace( "//", "/", "/".$pParams['ipath']."/" );
+ } else {
+ $pParams['ipath'] = '/';
+ }
+
+ // try to separate iname from ipath if we've been given some sloppy naming
+ if( strstr( $pParams['iname'], '/' )) {
+ $pParams['iname'] = $pParams['ipath'].$pParams['iname'];
+ $boom = explode( '/', $pParams['iname'] );
+ $pParams['iname'] = array_pop( $boom );
+ $pParams['ipath'] = str_replace( "//", "/", "/".implode( $boom, '/' )."/" );
+ }
+
+ // if we don't have an ipath yet, we will set it here
+ if( $pParams['ipath'] == '/' ) {
+ // iforce is generally only set in menus - we might need a parameter to identify menus more accurately
+ if( !empty( $pParams['ilocation'] )) {
+ if( $pParams['ilocation'] == 'menu' ) {
+ $pParams['ipath'] .= 'small/';
+ $pParams['iforce'] = 'icon_text';
+ } elseif( $pParams['ilocation'] == 'quicktag' ) {
+ $pParams['ipath'] .= 'small/';
+ $pParams['iforce'] = 'icon';
+ $pParams['iclass'] = 'quicktag icon';
+ }
+ } else {
+ $pParams['ipath'] .= $gBitSystem->getConfig( 'site_icon_size', 'small' ).'/';
+ }
+ }
+
+ // this only happens when we haven't found the original icon we've been looking for
+ if( $pCheckSmall ) {
+ $pParams['ipath'] = preg_replace( "!/.*?/$!", "/small/", $pParams['ipath'] );
+ }
+
+ // we have one special case: pkg_icons don't have a size variant
+ if( strstr( $pParams['iname'], 'pkg_' ) && !strstr( $pParams['ipath'], 'small' )) {
+ $pParams['ipath'] = preg_replace( "!/.*?/$!", "/", $pParams['ipath'] );
+ }
+
+ // make sure ipackage is set correctly
+ if( !empty( $pParams['ipackage'] )) {
+ $pParams['ipackage'] = strtolower( $pParams['ipackage'] );
+ } else {
+ $pParams['ipackage'] = 'icons';
+ }
+
+ // if the user is using a text-browser we force text instead of icons
+ if( $gSniffer->_browser_info['browser'] == 'lx' || $gSniffer->_browser_info['browser'] == 'li' ) {
+ $pParams['iforce'] = 'text';
+ }
+
+ // get out of here as quickly as possible if we've already cached the icon information before
+ if(( $ret = biticon_read_cache( $pParams )) && !( defined( 'TEMPLATE_DEBUG' ) && TEMPLATE_DEBUG == TRUE )) {
+ return $ret;
+ }
+
+ // first deal with most common scenario: icon themes
+ if( $pParams['ipackage'] == 'icons' ) {
+ // get the current icon style
+ // istyle is a private parameter!!! - only used on theme manager page for icon preview!!!
+ // violators will be poked with soft cushions by the Cardinal himself!!!
+ $icon_style = !empty( $pParams['istyle'] ) ? $pParams['istyle'] : $gBitSystem->getConfig( 'site_icon_style', DEFAULT_ICON_STYLE );
+
+ if( FALSE !== ( $matchFile = biticon_first_match( THEMES_PKG_PATH."icon_styles/$icon_style".$pParams['ipath'], $pParams['iname'] ))) {
+ return biticon_output( $pParams, THEMES_PKG_URL."icon_styles/$icon_style".$pParams['ipath'].$matchFile );
+ }
+
+ if( $icon_style != DEFAULT_ICON_STYLE && FALSE !== ( $matchFile = biticon_first_match( THEMES_PKG_PATH."icon_styles/".DEFAULT_ICON_STYLE.$pParams['ipath'], $pParams['iname'] ))) {
+ return biticon_output( $pParams, THEMES_PKG_URL."icon_styles/".DEFAULT_ICON_STYLE.$pParams['ipath'].$matchFile );
+ }
+
+ // if that didn't work, we'll try liberty
+ $pParams['ipath'] = '/'.$gBitSystem->getConfig( 'site_icon_size', 'small' ).'/';
+ $pParams['ipackage'] = 'liberty';
+ }
+
+ // since package icons reside in <pkg>/icons/ we don't need the small/ subdir
+ if( strstr( "/small/", $pParams['ipath'] )) {
+ $pParams['ipath'] = str_replace( "small/", "", $pParams['ipath'] );
+ $small = TRUE;
+ }
+
+ // first check themes/force
+ if( FALSE !== ( $matchFile = biticon_first_match( THEMES_PKG_PATH."force/icons/".$pParams['ipackage'].$pParams['ipath'], $pParams['iname'] ))) {
+ return biticon_output( $pParams, BIT_ROOT_URL."themes/force/icons/".$pParams['ipackage'].$pParams['ipath'].$matchFile );
+ }
+
+ //if we have site styles, look there
+ if( FALSE !== ( $matchFile = biticon_first_match( $gBitThemes->getStylePath().'/icons/'.$pParams['ipackage'].$pParams['ipath'], $pParams['iname'] ))) {
+ return biticon_output( $pParams, $gBitThemes->getStyleUrl().'/icons/'.$pParams['ipackage'].$pParams['ipath'].$matchFile );
+ }
+
+ //Well, then lets look in the package location
+ if( FALSE !== ( $matchFile = biticon_first_match( constant( strtoupper( $pParams['ipackage'] ).'_PKG_PATH' )."icons".$pParams['ipath'], $pParams['iname'] ))) {
+ return biticon_output( $pParams, constant( strtoupper( $pParams['ipackage'] ).'_PKG_URL' )."icons".$pParams['ipath'].$matchFile );
+ }
+
+ // Still didn't find it! Well lets output something (return FALSE if only the url is requested)
+ if( isset( $pParams['url'] )) {
+ return FALSE;
+ } else {
+ // if we were looking for the large icon, we'll try the whole kaboodle again, looking for the small icon
+ if( empty( $small ) && !$pCheckSmall ) {
+ return smarty_function_biticon( $copyParams, $gBitSmarty, TRUE );
+ } else {
+ return biticon_output( $pParams, "broken.".$pParams['ipackage']."/".$pParams['ipath'].$pParams['iname'] );
+ }
+ }
+}
+
+/**
+ * biticon_cache
+ *
+ * @param array $pParams
+ * @access public
+ * @return cached icon string on sucess, FALSE on failure
+ */
+function biticon_read_cache( $pParams ) {
+ $ret = FALSE;
+ $cacheFile = biticon_get_cache_file( $pParams );
+ if( is_readable( $cacheFile )) {
+ if( $h = fopen( $cacheFile, 'r' )) {
+ $ret = fread( $h, filesize( $cacheFile ));
+ fclose( $h );
+ }
+ }
+
+ return $ret;
+}
+
+/**
+ * biticon_write_cache
+ *
+ * @param array $pParams
+ * @access public
+ * @return TRUE on success, FALSE on failure
+ */
+function biticon_write_cache( $pParams, $pCacheString ) {
+ $ret = FALSE;
+ if( $cacheFile = biticon_get_cache_file( $pParams )) {
+ if( $h = fopen( $cacheFile, 'w' )) {
+ $ret = fwrite( $h, $pCacheString );
+ fclose( $h );
+ }
+ }
+
+ return( $ret != 0 );
+}
+
+/**
+ * will get the path to the cache files based on the stuff in $pParams
+ *
+ * @param array $pParams
+ * @access public
+ * @return full path to cachefile
+ */
+function biticon_get_cache_file( $pParams ) {
+ global $gBitThemes, $gBitSystem;
+
+ // create a hash filename based on the parameters given
+ $hashstring = '';
+ $ihash = array( 'iforce', 'ipath', 'iname', 'iexplain', 'ipackage', 'url', 'istyle', 'id', 'style', 'onclick' );
+ foreach( $pParams as $param => $value ) {
+ if( in_array( $param, $ihash )) {
+ $hashstring .= strtolower( $value );
+ }
+ }
+
+ // return path to cache file
+ return $gBitThemes->getIconCachePath().md5( $hashstring.$gBitSystem->getConfig( 'site_biticon_display_style', 'icon' ));
+}
+?>
diff --git a/smartyplugins/function.captcha.php b/smartyplugins/function.captcha.php
new file mode 100644
index 0000000..7011e45
--- /dev/null
+++ b/smartyplugins/function.captcha.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * smarty_function_captcha
+ */
+function smarty_function_captcha( $pParams, &$gBitSmarty ) {
+ global $gBitSystem, $gBitUser;
+ if( !empty( $pParams['force'] ) || empty( $_SESSION['captcha_verified'] ) && !$gBitUser->hasPermission( 'p_users_bypass_captcha' ) ) {
+ $pParams['size'] = !empty( $pParams['size'] ) ? $pParams['size'] : '5';
+ $pParams['variant'] = !empty( $pParams['variant'] ) ? $pParams['variant'] : 'condensed';
+
+ if( $gBitSystem->isFeatureActive( 'liberty_use_captcha_freecap' ) ) {
+ $pParams['source'] = UTIL_PKG_URL."freecap/freecap.php";
+ } else {
+ $getString = 'size='.$pParams['size'];
+ if( @BitBase::verifyId( $pParams['width'] ) ) {
+ $getString .= '&width='.$pParams['width'];
+ }
+ if( @BitBase::verifyId( $pParams['height'] ) ) {
+ $getString .= '&height='.$pParams['height'];
+ }
+ $pParams['source'] = USERS_PKG_URL."captcha_image.php?$getString";
+ }
+ $gBitSmarty->assign( 'params', $pParams );
+ print $gBitSmarty->fetch( "bitpackage:kernel/captcha.tpl" );
+ }
+}
+?>
diff --git a/smartyplugins/function.content.php b/smartyplugins/function.content.php
new file mode 100644
index 0000000..92db47b
--- /dev/null
+++ b/smartyplugins/function.content.php
@@ -0,0 +1,27 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * smarty_function_content
+ */
+function smarty_function_content($params, &$gBitSmarty)
+{
+ global $gBitSystem;
+ global $dcslib;
+ include_once( DCS_PKG_PATH.'dcs_lib.php' );
+ extract($params);
+ // Param = zone
+
+ if (empty($id)) {
+ $gBitSmarty->trigger_error("assign: missing 'zone' parameter");
+ return;
+ }
+ $data = $dcslib->get_actual_content($id);
+ print($data);
+}
+
+?>
diff --git a/smartyplugins/function.cookie.php b/smartyplugins/function.cookie.php
new file mode 100644
index 0000000..8c076f8
--- /dev/null
+++ b/smartyplugins/function.cookie.php
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * smarty_function_cookie
+ */
+function smarty_function_cookie($params, &$gBitSmarty) {
+ global $taglinelib;
+ include_once( TIDBITS_PKG_PATH.'BitFortuneCookies.php' );
+ print( $taglinelib->pick_cookie() );
+}
+?>
diff --git a/smartyplugins/function.displaycomment.php b/smartyplugins/function.displaycomment.php
new file mode 100644
index 0000000..e338117
--- /dev/null
+++ b/smartyplugins/function.displaycomment.php
@@ -0,0 +1,25 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * smarty_function_displaycomment
+ */
+function smarty_function_displaycomment($params) {
+ global $gBitSmarty;
+
+ if (!empty($params['comment'])) {
+ $comment = $params['comment'];
+ $gBitSmarty->assign('comment', $comment);
+ if (empty($params['template'])) {
+ $gBitSmarty->display('bitpackage:liberty/display_comment.tpl');
+ } else {
+ $gBitSmarty->display($params['template']);
+ }
+ }
+}
+
+?>
diff --git a/smartyplugins/function.displayname.php b/smartyplugins/function.displayname.php
new file mode 100644
index 0000000..78c87bd
--- /dev/null
+++ b/smartyplugins/function.displayname.php
@@ -0,0 +1,61 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**** smarty_function_displayName
+ * This is a smarty function which will allow different values to be
+ * output to identify users (real_name, user, user_id) as opposed todo
+ * only allowing the 'login' to be output.
+ * hash=fooHash is a short cut to specifying each parameter by hand
+ * usage: {displayname user= user_id= real_name= link_title=}
+*/
+function smarty_function_displayname( $pParams, &$gBitSmarty ) {
+ global $gBitUser;
+ if( !empty( $pParams['hash'] ) ) {
+ if( is_array( $pParams['hash'] ) ) {
+ $hash = array_merge( $pParams, $pParams['hash'] );
+ unset( $hash['hash'] );
+ // if the hash only has a user_id, we need to look up the user
+ if( @BitBase::verifyId( $hash['user_id'] ) && empty( $hash['user'] ) && empty( $hash['email'] ) && empty( $hash['login'] )) {
+ $lookupHash['user_id'] = $hash['user_id'];
+ }
+ } else {
+ // We were probably just passed the 'login' due to legacy code which has yet to be converted
+ if( strpos( '@', $pParams['hash'] ) ) {
+ $lookupHash['email'] = $hash;
+ } elseif( is_numeric( $pParams['hash'] ) ) {
+ $lookupHash['user_id'] = $hash;
+ } else {
+ $lookupHash['login'] = $hash;
+ }
+ }
+ } elseif( !empty( $pParams['user_id'] ) ) {
+ $lookupHash['user_id'] = $pParams['user_id'];
+ } elseif( !empty( $pParams['email'] ) ) {
+ $lookupHash['email'] = $pParams['email'];
+ } elseif( !empty( $pParams['login'] ) ) {
+ $lookupHash['login'] = $pParams['login'];
+ } elseif( !empty( $pParams['user'] ) ) {
+ $lookupHash['login'] = $pParams['user'];
+ } elseif( empty( $pParams ) ) {
+ global $gBitUser;
+ $hash = $gBitUser->mInfo;
+ }
+
+ if( !empty( $lookupHash ) ) {
+ $hash = $gBitUser->getUserInfo( $lookupHash );
+ }
+
+ if( !empty( $hash ) ) {
+ $displayName = BitUser::getDisplayName( empty( $pParams['nolink'] ), $hash );
+ } else {
+ // Now we're really in trouble. We don't even have a user_id to work with
+ $displayName = "Unknown";
+ }
+
+ return( $displayName );
+}
+?>
diff --git a/smartyplugins/function.ed.php b/smartyplugins/function.ed.php
new file mode 100644
index 0000000..c1a5912
--- /dev/null
+++ b/smartyplugins/function.ed.php
@@ -0,0 +1,27 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * smarty_function_ed
+ */
+function smarty_function_ed($params, &$gBitSmarty)
+{
+ global $gBitSystem;
+ extract($params);
+ // Param = zone
+
+ if (empty($id)) {
+ $gBitSmarty->trigger_error("ed: missing 'id' parameter");
+ return;
+ }
+
+ print($banner);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/smartyplugins/function.elapsed.php b/smartyplugins/function.elapsed.php
new file mode 100644
index 0000000..69bb602
--- /dev/null
+++ b/smartyplugins/function.elapsed.php
@@ -0,0 +1,21 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * smarty_function_elapsed
+ */
+function smarty_function_elapsed($params, &$gBitSmarty)
+{
+ global $gBitSystem;
+
+ $ela = number_format($gBitSystem->mTimer->elapsed(),2);
+ print($ela);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/smartyplugins/function.form_id.php b/smartyplugins/function.form_id.php
new file mode 100644
index 0000000..486a5a8
--- /dev/null
+++ b/smartyplugins/function.form_id.php
@@ -0,0 +1,21 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * this generates a relatively unique ids for the
+ * ajax attachment portions of a form, which must be uniquely identified
+ * when there are multiple forms enabling attachment uploads on one page.
+ */
+function smarty_function_form_id(){
+ if( !isset( $_SESSION['form_id_index'] ) ){
+ $ret = $_SESSION['form_id_index'] = 1;
+ }else{
+ $ret = ( $_SESSION['form_id_index']++ );
+ }
+ return $ret;
+}
+?>
diff --git a/smartyplugins/function.formfeedback.php b/smartyplugins/function.formfeedback.php
new file mode 100644
index 0000000..6b49826
--- /dev/null
+++ b/smartyplugins/function.formfeedback.php
@@ -0,0 +1,77 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {formfeedback} function plugin
+ *
+ * Type: function
+ * Name: formfeedback
+ * Input:
+ * - warning, error or success are defined css styles, but you can feed it anything
+ */
+function smarty_function_formfeedback( $params, &$gBitSmarty ) {
+ detoxify( $params );
+ if( !empty( $params['hash'] ) ) {
+ $hash = &$params['hash'];
+ } else {
+ // maybe params were passed in separately
+ $hash = &$params;
+ }
+ $feedback = '';
+ $i = 0;
+ $color = isset( $hash['color'] )?$hash['color']:"000000";
+ foreach( $hash as $key => $val ) {
+ if( $val ) {
+ require_once $gBitSmarty->_get_plugin_filepath( 'function', 'biticon' );
+
+ $keys = array( 'warning', 'success', 'error', 'important' );
+ if( in_array( $key, $keys )) {
+ if( $key === 'important' ) {
+ $iname = 'emblem-important';
+ } elseif( $key === 'success' ) {
+ $iname = 'dialog-ok';
+ } elseif( $key === 'warning' ) {
+ $iname = 'dialog-warning';
+ } elseif( $key === 'error' ) {
+ $iname = 'dialog-error';
+ }
+
+ $biticon = array(
+ 'ipackage' => 'icons',
+ 'iname' => $iname,
+ 'iexplain' => ucfirst( $key ),
+ 'iforce' => 'icon',
+ );
+ if( !is_array( $val ) ) {
+ $val = array( $val );
+ }
+
+ foreach( $val as $valText ) {
+ $feedback .= '<p id="fat'.rand( 0, 10000 ).'" class="fade-'.$color.' '.$key.'">'.smarty_function_biticon( $biticon, $gBitSmarty ).' '.$valText.'</p>';
+ }
+
+ } else {
+ /* unfortunately this plugin was written a little strictly and so it expects all params to be display text
+ * to allow setting of a background color we have to exclude that param when rendering out the html
+ * otherwise we'll render the color as text. -wjames5
+ */
+ if ( $key != 'color' ){
+ $feedback .= '<p class="'.$key.'">'.$val.'</p>';
+ }
+ }
+ }
+ }
+
+ $html = '';
+ if( !empty( $feedback ) ) {
+ $html = '<div class="formfeedback">';
+ $html .= $feedback;
+ $html .= '</div>';
+ }
+ return $html;
+}
+?>
diff --git a/smartyplugins/function.formhelp.php b/smartyplugins/function.formhelp.php
new file mode 100644
index 0000000..f055104
--- /dev/null
+++ b/smartyplugins/function.formhelp.php
@@ -0,0 +1,166 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {formhelp} function plugin
+ *
+ * Type: function
+ * Name: formhelp
+ * Input:
+ * - note (optional) words that are displayed, can also be an array, where: 'key: value'<br /> is printed
+ * only displayed if site_form_help is enabled
+ * - link (optional) provide a link to an internal page (avoids the problem with links being inerpreted
+ * prematurely by the tra() function
+ * <package>/<path to file>/<title>
+ * - package (optional) creates a page to 'Package'.ucfirst( $package ) and takes precedence over $page, should both be set.
+ * only dispalyed if help is enabled
+ * - install (optional) used for packages that require a separate installation
+ * passed in as an array:
+ * package => name of package to be installed
+ * file => path to installation file e.g.: admin/install.php
+ * - page (optional) page name on bitweaver
+ * only dispalyed if help is enabled
+ * - force (optional) if set, it will always dipslay this entry regardless of the feature settings
+ */
+function smarty_function_formhelp( $pParams, &$gBitSmarty ) {
+ $atts = $ret_note = $ret_page = $ret_link = $ret_install = '';
+
+ if( !empty( $pParams['hash'] ) ) {
+ $hash = &$pParams['hash'];
+ } else {
+ // maybe params were passed in separately
+ $hash = &$pParams;
+ }
+
+ // we need to do some hash modification if we're in the installer
+ if( !empty( $hash['is_installer'] )) {
+ if( !empty( $hash['note']['upgrade'] )) {
+ $hash['note']['version'] = $hash['note']['upgrade'];
+ unset( $hash['note']['upgrade'] );
+ }
+ }
+
+ foreach( $hash as $key => $val ) {
+ switch( $key ) {
+ case 'note':
+ case 'warning':
+ case 'link':
+ case 'page':
+ $rawHash[$key] = $val;
+ break;
+ case 'label':
+ case 'package':
+ case 'install':
+ case 'force':
+ $$key = $val;
+ break;
+ default:
+ if( $val ) {
+ $atts .= $key.'="'.$val.'" ';
+ }
+ break;
+ }
+ }
+
+ if( !empty( $package ) ) {
+ $rawHash['page'] = ucfirst( $package ).'Package';
+ }
+
+ // if link was passed in as a string, convert it into an array
+ if( !empty( $rawHash['link'] ) && is_string( $rawHash['link'] ) ) {
+ $l = explode( '/', $rawHash['link'] );
+ unset( $rawHash['link'] );
+ // package is first, title last, and all remaining elements file (can be 'foo/bar.php' as well)
+ $rawHash['link']['package'] = array_shift( $l );
+ $rawHash['link']['title'] = array_pop( $l );
+ $rawHash['link']['file'] = implode( '/', $l );
+ }
+
+ global $gBitSystem;
+ if( $gBitSystem->isFeatureActive( 'site_online_help' ) || $gBitSystem->isFeatureActive( 'site_form_help' ) || $force == 'y' ) {
+ if( !empty( $rawHash ) ) {
+ if( !empty( $rawHash['page'] ) && ( $gBitSystem->isFeatureActive('site_online_help') || $force == 'y' ) ) {
+ $ret_page = '<strong>'.tra( 'Online help' ).'</strong>: <a class=\'external\' href=\'http://doc.bitweaver.org/wiki/index.php?page='.$rawHash['page'].'\'>'.$rawHash['page'].'</a><br />';
+ }
+
+ if( !empty( $rawHash['link'] ) && ( $gBitSystem->isFeatureActive('site_online_help') || $force == 'y' ) ) {
+ if( is_array( $rawHash['link'] ) ) {
+ $ret_link = '<strong>'.tra( 'IntraLink' ).'</strong>: ';
+ $ret_link .= '<a href=\'';
+ $ret_link .= constant( strtoupper( $rawHash['link']['package'] ).'_PKG_URL' ).$rawHash['link']['file'];
+ $ret_link .= '\'>'.tra( $rawHash['link']['title'] ).'</a>';
+ }
+ }
+
+ if( ( !empty( $rawHash['note'] ) && $gBitSystem->isFeatureActive('site_form_help') ) || ( !empty( $force ) && !empty( $rawHash['note'] ) ) ) {
+ if( is_array( $rawHash['note'] ) ) {
+ foreach( $rawHash['note'] as $name => $value ) {
+ if( $name == 'install' ) {
+ $ret_install = '<strong>'.tra( 'Install' ).'</strong>: '.tra( 'To use this package, you will first have to run the package specific installer' ).': ';
+ $ret_install .= '<a href=\'';
+ $ret_install .= constant( strtoupper( $value['package'] ).'_PKG_URL' ).$value['file'];
+ $ret_install .= '\'>'.ucfirst( $value['package'] ).'</a>';
+ } else {
+ $ret_note .= '<strong>'.ucfirst( tra( $name ) ).'</strong>: '.tra( $value ).'<br />';
+ }
+ }
+ } else {
+ $ret_note .= tra( $rawHash['note'] ).'<br />';
+ }
+ }
+
+ if( !empty( $rawHash['warning'] ) ) {
+ $ret_note .= '<span class="warning">'.tra( $rawHash['warning'] ).'</span><br />';
+ }
+
+ // join all the output content into one string
+ $content = $ret_note.$ret_page.$ret_link.$ret_install;
+
+ $html = '';
+ // using the overlib popup system
+ if( !empty( $content ) ) {
+ if( $gBitSystem->isFeatureActive('site_help_popup') ) {
+ require_once $gBitSmarty->_get_plugin_filepath('function','popup');
+ require_once $gBitSmarty->_get_plugin_filepath('function','biticon');
+
+ $gBitSmarty->assign( 'title',tra('Extended Help') );
+
+ $gBitSmarty->assign( 'content', $content );
+ $gBitSmarty->assign( 'closebutton', TRUE );
+ $text = $gBitSmarty->fetch('bitpackage:kernel/popup_box.tpl');
+ $text = preg_replace( '/"/',"'",$text );
+
+ $popup = array(
+ 'trigger' => 'onclick',
+ 'text' => $text,
+ 'fullhtml' => '1',
+ 'sticky' => '1',
+ 'timeout' => '8000',
+ );
+
+ $biticon = array(
+ 'ipackage' => 'icons',
+ 'iname' => 'dialog-information',
+ 'iforce' => 'icon',
+ 'iexplain' => 'Extended Help',
+ );
+
+ $html .= ' <span class="formhelppopup" '.$atts.'>&nbsp;';
+ $html .= '<a '.smarty_function_popup( $popup, $gBitSmarty ).'>';
+ $html .= smarty_function_biticon( $biticon, $gBitSmarty );
+ $html .= '</a>';
+ $html .= '</span>';
+ } else {
+ $html .= '<div class="formhelp" '.$atts.'>'.$content.'</div>';
+ }
+ }
+
+ return $html;
+ }
+ }
+}
+?>
diff --git a/smartyplugins/function.formlabel.php b/smartyplugins/function.formlabel.php
new file mode 100644
index 0000000..0d4bb9a
--- /dev/null
+++ b/smartyplugins/function.formlabel.php
@@ -0,0 +1,52 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {formlabel} function plugin
+ *
+ * Type: function
+ * Name: formlabel
+ * Input:
+ * - label (required) - words that are displayed
+ * - mandatory (optional) - add a class formmandatory in the div
+ */
+function smarty_function_formlabel( $params,&$gBitSmarty ) {
+ $atts = '';
+ foreach($params as $key => $val) {
+ switch( $key ) {
+ case 'label':
+ $name = $val;
+ break;
+ case 'mandatory':
+ $mandatory = true;
+ default:
+ if( $val ) {
+ $atts .= ' '.$key.'="'.$val.'"';
+ }
+ break;
+ }
+ }
+ $html = '<div class="formlabel';
+ if (isset($mandatory) && $mandatory) {
+ $html .= ' formmandatory';
+ }
+ $html .= '">';
+ if( $atts != '' ) {
+ $html .= '<label'.$atts.'>';
+ }
+ if( empty( $params['no_translate'] ) ) {
+ $html .= tra( $name );
+ } else {
+ $html .= $name;
+ }
+ if( $atts != '' ) {
+ $html .= '</label>';
+ }
+ $html .= '</div>';
+ return $html;
+}
+?>
diff --git a/smartyplugins/function.gallery.php b/smartyplugins/function.gallery.php
new file mode 100644
index 0000000..eeff227
--- /dev/null
+++ b/smartyplugins/function.gallery.php
@@ -0,0 +1,47 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * smarty_function_gallery
+ */
+function smarty_function_gallery($params, &$gBitSmarty)
+{
+ global $gBitSystem;
+ include_once( IMAGEGALS_PKG_PATH.'imagegal_lib.php' );
+ extract($params);
+ // Param = id
+
+ if (empty($id)) {
+ $gBitSmarty->trigger_error("assign: missing 'id' parameter");
+ return;
+ }
+ $img = $gBitSystem->get_random_image($id);
+ print('<center>');
+ print('<table border="0" cellpadding="0" cellspacing="0">');
+ print('<tr>');
+ print('<td align=center>');
+ print('<a href="'.IMAGEGALS_PKG_URL.'browse_image.php?gallery_id='.$img['gallery_id'].'&amp;image_id='.$img['image_id'].'"><img alt="thumbnail" class="athumb" src="show_image.php?id='.$img['image_id'].'&amp;thumb=1" /></a><br/>');
+ print('<b>'.$img['name'].'</b><br>');
+ if ($showgalleryname == 1) {
+ print('<small>From <a href="'.IMAGEGALS_PKG_URL.'browse_gallery.php?gallery_id='.$img['gallery_id'].'">'.$img['gallery'].'</a></small>');
+ }
+ print('</td></tr></table></center>');
+}
+?>
+<!--
+<center>
+<table border="0" cellpadding="0" cellspacing="0">
+<tr>
+<td align=center>
+<a href="'.IMAGEGALS_PKG_URL.'browse_image.php?gallery_id=<?php echo $img['gallery_id']; ?>&amp;image_id=<?php echo $img['image_id']; ?>"><img alt="thumbnail" class="athumb" src="show_image.php?id=<?php echo $img['image_id']; ?>&amp;thumb=1" /></a><br/>
+<b><?php echo $img['name']; ?></b><br>
+<?php if ($showgalleryname == 1) { ?><small>From <a href="'.IMAGEGALS_PKG_URL.'browse_gallery.php?gallery_id=<?php echo $img['gallery_id']; ?>"><?php echo $img['gallery']; ?></a></small><?php } ?>
+</td>
+</tr>
+</table>
+</center>
+-->
diff --git a/smartyplugins/function.helplink.php b/smartyplugins/function.helplink.php
new file mode 100644
index 0000000..ce900b0
--- /dev/null
+++ b/smartyplugins/function.helplink.php
@@ -0,0 +1,24 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * smarty_function_helplink
+ */
+function smarty_function_helplink($params, &$gBitSmarty)
+{
+ extract($params);
+ // Param = zone
+ if(empty($page)) {
+ $gBitSmarty->trigger_error("assign: missing page parameter");
+ return;
+ }
+ print("<a title='help' href='#' onClick='javascript:window.open(\"".WIKI_PKG_URL."index_p.php?page=$page\",\"\",\"menubar=no,scrollbars=yes,resizable=yes,height=600,width=500\");'><img border='0' src='img/icons/help.gif' alt='".tra("help")."' /></a>");
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/smartyplugins/function.html_select_date.php b/smartyplugins/function.html_select_date.php
new file mode 100644
index 0000000..8edbb42
--- /dev/null
+++ b/smartyplugins/function.html_select_date.php
@@ -0,0 +1,255 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {html_select_date} plugin
+ *
+ * Type: function<br>
+ * Name: html_select_date<br>
+ * Purpose: Prints the dropdowns for date selection.
+ *
+ * ChangeLog:<br>
+ * - 1.0 initial release
+ * - 1.1 added support for +/- N syntax for begin
+ * and end year values. (Monte)
+ * - 1.2 added support for yyyy-mm-dd syntax for
+ * time value. (Jan Rosier)
+ * - 1.3 added support for choosing format for
+ * month values (Gary Loescher)
+ * - 1.3.1 added support for choosing format for
+ * day values (Marcus Bointon)
+ * @link http://smarty.php.net/manual/en/language.function.html.select.date.php {html_select_date}
+ * (Smarty online manual)
+ * @version 1.3
+ * @author Andrei Zmievski
+ * @param array
+ * @param Smarty
+ * @return string
+ */
+function smarty_function_html_select_date($params, &$gBitSmarty)
+{
+ global $gBitSystem;
+ require_once $gBitSmarty->_get_plugin_filepath('shared','make_timestamp');
+ require_once $gBitSmarty->_get_plugin_filepath('function','html_options');
+ /* Default values. */
+ $prefix = "Date_";
+ $start_year = strftime("%Y");
+ $end_year = $start_year;
+ $display_days = true;
+ $display_months = true;
+ $display_years = true;
+ $month_format = "%B";
+ /* Write months as numbers by default GL */
+ $month_value_format = "%m";
+ $day_format = "%02d";
+ /* Write day values using this format MB */
+ $day_value_format = "%d";
+ $year_as_text = false;
+ /* Display years in reverse order? Ie. 2000,1999,.... */
+ $reverse_years = false;
+ /* Should the select boxes be part of an array when returned from PHP?
+ e.g. setting it to "birthday", would create "birthday[Day]",
+ "birthday[Month]" & "birthday[Year]". Can be combined with prefix */
+ $field_array = null;
+ /* <select size>'s of the different <select> tags.
+ If not set, uses default dropdown. */
+ $day_size = null;
+ $month_size = null;
+ $year_size = null;
+ /* Unparsed attributes common to *ALL* the <select>/<input> tags.
+ An example might be in the template: all_extra ='class ="foo"'. */
+ $all_extra = null;
+ /* Separate attributes for the tags. */
+ $day_extra = null;
+ $month_extra = null;
+ $year_extra = null;
+ /* Order in which to display the fields.
+ "D" -> day, "M" -> month, "Y" -> year. */
+ $field_order = 'MDY';
+ /* String printed between the different fields. */
+ $field_separator = "\n";
+ $time = time();
+
+
+ extract($params);
+ // If $time is not in format yyyy-mm-dd
+ if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $time)) {
+ // then $time is empty or unix timestamp or mysql timestamp
+ // using smarty_make_timestamp to get an unix timestamp and
+ // strftime to make yyyy-mm-dd
+ // Just in case the offset moves us into another day.
+ $time = smarty_make_timestamp($time);
+ $date = new BitDate(0);
+ // sets the offset for the user - necessary because BitDate is a bitwack
+ $offset = $date->get_display_offset();
+ $time = $date->getDisplayDateFromUTC( $time );
+ $time = $gBitSystem->mServerTimestamp->strftime('%Y-%m-%d', smarty_make_timestamp($time), TRUE);
+ }
+ // Now split this in pieces, which later can be used to set the select
+ $time = explode("-", $time);
+
+ // make syntax "+N" or "-N" work with start_year and end_year
+ if (preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match)) {
+ if ($match[1] == '+') {
+ $end_year = strftime('%Y') + $match[2];
+ } else {
+ $end_year = strftime('%Y') - $match[2];
+ }
+ }
+ if (preg_match('!^(\+|\-)\s*(\d+)$!', $start_year, $match)) {
+ if ($match[1] == '+') {
+ $start_year = strftime('%Y') + $match[2];
+ } else {
+ $start_year = strftime('%Y') - $match[2];
+ }
+ }
+
+ $field_order = strtoupper($field_order);
+
+ $html_result = $month_result = $day_result = $year_result = "";
+
+ if ($display_months) {
+ $month_names = array();
+ $month_values = array();
+
+ for ($i = 1; $i <= 12; $i++) {
+
+ // date: 2003/03/20 22:54:34; author: ohertel; state: Exp; lines: +1 -1
+ // added many missing translation blocks and german translations for user admin page, newsreader, notepad and bookmarks, month from html_select_date is being translated now
+ // - $month_names[] = strftime($month_format, mktime(0, 0, 0, $i, 1, 2000));
+ // + $month_names[] = tra(strftime($month_format, mktime(0, 0, 0, $i, 1, 2000)));
+
+ $month_names[] = tra(strftime($month_format, mktime(0, 0, 0, $i, 1, 2000)));
+ $month_values[] = strftime($month_value_format, mktime(0, 0, 0, $i, 1, 2000));
+ }
+
+ $month_result .= '<select name=';
+ if (null !== $field_array){
+ $month_result .= '"' . $field_array . '[' . $prefix . 'Month]"';
+ } else {
+ $month_result .= '"' . $prefix . 'Month"';
+ }
+ if (null !== $month_size){
+ $month_result .= ' size="' . $month_size . '"';
+ }
+ if (null !== $month_extra){
+ $month_result .= ' ' . $month_extra;
+ }
+ if (null !== $all_extra){
+ $month_result .= ' ' . $all_extra;
+ }
+ $month_result .= '>'."\n";
+
+ $month_result .= smarty_function_html_options(array('output' => $month_names,
+ 'values' => $month_values,
+ 'selected' => $month_values[$time[1]-1],
+ 'print_result' => false),
+ $gBitSmarty);
+
+ $month_result .= '</select>';
+ }
+
+ if ($display_days) {
+ $days = array();
+ for ($i = 1; $i <= 31; $i++) {
+ $days[] = sprintf($day_format, $i);
+ $day_values[] = sprintf($day_value_format, $i);
+ }
+
+ $day_result .= '<select name=';
+ if (null !== $field_array){
+ $day_result .= '"' . $field_array . '[' . $prefix . 'Day]"';
+ } else {
+ $day_result .= '"' . $prefix . 'Day"';
+ }
+ if (null !== $day_size){
+ $day_result .= ' size="' . $day_size . '"';
+ }
+ if (null !== $all_extra){
+ $day_result .= ' ' . $all_extra;
+ }
+ if (null !== $day_extra){
+ $day_result .= ' ' . $day_extra;
+ }
+ $day_result .= '>'."\n";
+ $day_result .= smarty_function_html_options(array('output' => $days,
+ 'values' => $day_values,
+ 'selected' => $time[2],
+ 'print_result' => false),
+ $gBitSmarty);
+ $day_result .= '</select>';
+ }
+
+ if ($display_years) {
+ if (null !== $field_array){
+ $year_name = $field_array . '[' . $prefix . 'Year]';
+ } else {
+ $year_name = $prefix . 'Year';
+ }
+ if ($year_as_text) {
+ $year_result .= '<input type="text" name="' . $year_name . '" value="' . $time[0] . '" size="4" maxlength="4"';
+ if (null !== $all_extra){
+ $year_result .= ' ' . $all_extra;
+ }
+ if (null !== $year_extra){
+ $year_result .= ' ' . $year_extra;
+ }
+ $year_result .= '>';
+ } else {
+ $years = range((int)$start_year, (int)$end_year);
+ if ($reverse_years) {
+ rsort($years, SORT_NUMERIC);
+ }
+
+ $year_result .= '<select name="' . $year_name . '"';
+ if (null !== $year_size){
+ $year_result .= ' size="' . $year_size . '"';
+ }
+ if (null !== $all_extra){
+ $year_result .= ' ' . $all_extra;
+ }
+ if (null !== $year_extra){
+ $year_result .= ' ' . $year_extra;
+ }
+ $year_result .= '>'."\n";
+ $year_result .= smarty_function_html_options(array('output' => $years,
+ 'values' => $years,
+ 'selected' => $time[0],
+ 'print_result' => false),
+ $gBitSmarty);
+ $year_result .= '</select>';
+ }
+ }
+
+ // Loop thru the field_order field
+ for ($i = 0; $i <= 2; $i++){
+ $c = substr($field_order, $i, 1);
+ switch ($c){
+ case 'D':
+ $html_result .= $day_result;
+ break;
+
+ case 'M':
+ $html_result .= $month_result;
+ break;
+
+ case 'Y':
+ $html_result .= $year_result;
+ break;
+ }
+ // Add the field seperator
+ if($i != 2) {
+ $html_result .= $field_separator;
+ }
+ }
+
+ return $html_result;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/smartyplugins/function.html_select_time.php b/smartyplugins/function.html_select_time.php
new file mode 100644
index 0000000..5e0a014
--- /dev/null
+++ b/smartyplugins/function.html_select_time.php
@@ -0,0 +1,176 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {html_select_time} function plugin
+ *
+ * Type: function<br>
+ * Name: html_select_time<br>
+ * Purpose: Prints the dropdowns for time selection
+ * @link http://smarty.php.net/manual/en/language.function.html.select.time.php {html_select_time}
+ * (Smarty online manual)
+ * @param array
+ * @param Smarty
+ * @return string
+ * @uses smarty_make_timestamp()
+ */
+function smarty_function_html_select_time($params, &$gBitSmarty)
+{
+ global $gBitSystem;
+ require_once $gBitSmarty->_get_plugin_filepath('shared','make_timestamp');
+ require_once $gBitSmarty->_get_plugin_filepath('function','html_options');
+ /* Default values. */
+ $prefix = "Time_";
+ $time = time();
+ $display_hours = true;
+ $display_minutes = true;
+ $display_seconds = true;
+ $display_meridian = true;
+ $use_24_hours = true;
+ $minute_interval = 1;
+ $second_interval = 1;
+ /* Should the select boxes be part of an array when returned from PHP?
+ e.g. setting it to "birthday", would create "birthday[Hour]",
+ "birthday[Minute]", "birthday[Seconds]" & "birthday[Meridian]".
+ Can be combined with prefix. */
+ $field_array = null;
+ $all_extra = null;
+ $hour_extra = null;
+ $minute_extra = null;
+ $second_extra = null;
+ $meridian_extra = null;
+
+ extract($params);
+
+ $time = smarty_make_timestamp($time);
+ $date = new BitDate(0);
+ // sets the offset for the user - necessary because BitDate is a bitwack
+ $offset = $date->get_display_offset();
+ $disptime = $date->getDisplayDateFromUTC( $time );
+ $html_result = '';
+
+ if ($display_hours) {
+ $hours = $use_24_hours ? range(0, 23) : range(1, 12);
+ $hour_fmt = $use_24_hours ? '%H' : '%I';
+ $selected = $gBitSystem->mServerTimestamp->strftime($hour_fmt, $disptime, TRUE);
+ for ($i = 0, $for_max = count($hours); $i < $for_max; $i++)
+ $hours[$i] = sprintf('%02d', $hours[$i]);
+ $html_result .= '<select name=';
+ if (null !== $field_array) {
+ $html_result .= '"' . $field_array . '[' . $prefix . 'Hour]"';
+ } else {
+ $html_result .= '"' . $prefix . 'Hour"';
+ }
+ if (null !== $hour_extra){
+ $html_result .= ' ' . $hour_extra;
+ }
+ if (null !== $all_extra){
+ $html_result .= ' ' . $all_extra;
+ }
+ $html_result .= '>'."\n";
+ $html_result .= smarty_function_html_options(array('output' => $hours,
+ 'values' => $hours,
+ 'selected' => $selected,
+ 'print_result' => false),
+ $gBitSmarty);
+ $html_result .= "</select>\n";
+ }
+
+ if ($display_minutes) {
+ $all_minutes = range(0, 59);
+ for ($i = 0, $for_max = count($all_minutes); $i < $for_max; $i+= $minute_interval)
+ $minutes[] = sprintf('%02d', $all_minutes[$i]);
+ $selected = intval(floor($gBitSystem->mServerTimestamp->strftime('%M', $disptime, TRUE) / $minute_interval) * $minute_interval);
+ $html_result .= '<select name=';
+ if (null !== $field_array) {
+ $html_result .= '"' . $field_array . '[' . $prefix . 'Minute]"';
+ } else {
+ $html_result .= '"' . $prefix . 'Minute"';
+ }
+ if (null !== $minute_extra){
+ $html_result .= ' ' . $minute_extra;
+ }
+ if (null !== $all_extra){
+ $html_result .= ' ' . $all_extra;
+ }
+ $html_result .= '>'."\n";
+
+ $html_result .= smarty_function_html_options(array('output' => $minutes,
+ 'values' => $minutes,
+ 'selected' => $selected,
+ 'print_result' => false),
+ $gBitSmarty);
+ $html_result .= "</select>\n";
+ }
+
+ if ($display_seconds) {
+ $all_seconds = range(0, 59);
+ for ($i = 0, $for_max = count($all_seconds); $i < $for_max; $i+= $second_interval)
+ $seconds[] = sprintf('%02d', $all_seconds[$i]);
+ $selected = intval(floor($gBitSystem->mServerTimestamp->strftime('%S', $disptime, TRUE) / $second_interval) * $second_interval);
+ $html_result .= '<select name=';
+ if (null !== $field_array) {
+ $html_result .= '"' . $field_array . '[' . $prefix . 'Second]"';
+ } else {
+ $html_result .= '"' . $prefix . 'Second"';
+ }
+
+ if (null !== $second_extra){
+ $html_result .= ' ' . $second_extra;
+ }
+ if (null !== $all_extra){
+ $html_result .= ' ' . $all_extra;
+ }
+ $html_result .= '>'."\n";
+
+ $html_result .= smarty_function_html_options(array('output' => $seconds,
+ 'values' => $seconds,
+ 'selected' => $selected,
+ 'print_result' => false),
+ $gBitSmarty);
+ $html_result .= "</select>\n";
+ }
+
+ if ($display_meridian && !$use_24_hours) {
+ $html_result .= '<select name=';
+ $selected = strtolower($gBitSystem->mServerTimestamp->strftime('%p', $disptime, TRUE));
+ if (null !== $field_array) {
+ $html_result .= '"' . $field_array . '[' . $prefix . 'Meridian]"';
+ } else {
+ $html_result .= '"' . $prefix . 'Meridian"';
+ }
+
+ if (null !== $meridian_extra){
+ $html_result .= ' ' . $meridian_extra;
+ }
+ if (null !== $all_extra){
+ $html_result .= ' ' . $all_extra;
+ }
+ $html_result .= '>'."\n";
+
+ $html_result .= smarty_function_html_options(array('output' => array('AM', 'PM'),
+ 'values' => array('am', 'pm'),
+ 'selected' => $selected,
+ 'print_result' => false),
+ $gBitSmarty);
+ $html_result .= "</select>\n";
+ }
+
+ // date: 2003/02/12 21:23:52; author: gilshwartz; state: Exp; lines: +1 -1
+ // Enforce LTR direction of time entry regardless of overall directionality.
+ // - print $html_result;
+ // + print '<span dir="ltr">'.$html_result.'</span>';
+
+ $html_result = '<span dir="ltr">' . $html_result . '</span>';
+
+ return $html_result;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/smartyplugins/function.include_js.php b/smartyplugins/function.include_js.php
new file mode 100644
index 0000000..b67082b
--- /dev/null
+++ b/smartyplugins/function.include_js.php
@@ -0,0 +1,57 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {include_js} function plugin
+ *
+ * Type: function
+ * Name: include_js
+ * Input:
+ * - file (required) - fully qualified file to a javascript file
+ * - nopack (optional) - do not pack
+ */
+function smarty_function_include_js( $params,&$gBitSmarty ) {
+ global $gBitSystem;
+ $pack = TRUE;
+ foreach($params as $key => $val) {
+ switch( $key ) {
+ case 'file':
+ $file = $val;
+ break;
+ case 'nopack':
+ $pack = FALSE;
+ default:
+ break;
+ }
+ }
+ if( is_file( $file )) {
+ // pack it
+ if( $pack && $gBitSystem->isFeatureActive( 'themes_packed_js_css' ) && shell_exec( 'which java' ) ) {
+ // start up caching engine - pretend we are themes package
+ $BitCache = new BitCache( 'themes', TRUE );
+
+ // get a name for the cache file we're going to store
+ $cachefile = md5( $file ).'.js';
+
+ // if the file hasn't been packed and cached yet, we do that now.
+ if( !$BitCache->isCached( $cachefile, filemtime( $file ))) {
+ // pack and cache it
+ $cachedata = shell_exec( 'java -jar '.UTIL_PKG_PATH.'yui/yuicompressor-2.4.2.jar --type js '.$file );
+ $BitCache->writeCacheFile( $cachefile, $cachedata );
+ }
+
+ // update the file path with new path
+ $file = $BitCache->getCacheFile( $cachefile );
+ }
+ // get file text
+ $text = fread( fopen($file,'r'), filesize( $file ) );
+ }else{
+ // dump a comment to the page
+ $text = "if( typeof( console ) != undefined ){ console.log( 'There was an error trying to include js file: ".$file.", it could not be found. Please check the file path.' ); }";
+ }
+ return $text;
+}
diff --git a/smartyplugins/function.include_wiki_page_content.php b/smartyplugins/function.include_wiki_page_content.php
new file mode 100644
index 0000000..f599a0a
--- /dev/null
+++ b/smartyplugins/function.include_wiki_page_content.php
@@ -0,0 +1,79 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/** \file
+ * $Header:
+ *
+ * \author jht <jht@lj.net>
+ */
+
+
+/**
+ * \brief Smarty plugin to include specified wiki page content (transclusion)
+ * Usage format {include_wiki_page_content page=>'name of page' }
+ * or {include_wiki_page_content page=>'name of page' page_default='name of another page' }
+ */
+
+#
+# This fuction provides transclusion in page templates. To use transclusion
+# inside of content, use the Liberty 'include' plugin
+#
+# ( Transclusion is including information from one document into another.
+# For more on Transclusion - see: http://en.wikipedia.org/wiki/Wikipedia:Transclusion )
+#
+# This function can be used in any wiki template to include the content of any arbitrary
+# wiki page. There are many possible uses.
+# For example, when editing pages, you want to include custom editing instructions
+# but want these instructions to be easily updatable by any wiki user.
+# Adding this line to the wiki/templates/edit_page.tpl file will automatically display
+# the content of the page named: 'edit notice' whenever a wiki page is edited:
+#
+# {include_wiki_page_content page="edit notice"}
+#
+# Suppose that instead of a global notice that is the same for all pages, you want
+# custom tailored notices specific to each page, and want to display a default
+# notice for pages that don't have a custom notice defined.
+# Example: whenever a page named "ABC" is edited you would like to display this notice:
+# "Please Keep the Lists on this Page Alphabetical!"
+#
+# Step 1: Create a new page named: "ABC - edit notice" containing the notice
+# The content of this page is the notice that you want shown whenever the page "ABC" is edited.
+# The notice can be any length and include wiki markup.
+#
+# Step 2: Create a new page named something like: "default edit notice"
+# The content of this page is the notice that you want shown whenever a page without a custom edit notices is edited.
+# The notice can be any length and include wiki markup.
+#
+# Step 3: Include the following line in the wiki/edit_page.tpl file at the point where you want the notice displayed:
+#
+#{include_wiki_page_content page="`$pageInfo.original_title` - edit notice" page_default="default edit notice"}
+#
+# Now whenever "ABC" is edited the custom notice will be displayed on the edit page.
+# Editing any other page will display the default edit notice.
+#
+
+
+function smarty_function_include_wiki_page_content($params, &$gBitSmarty)
+{
+ global $debugger;
+ //
+ $pageName = !empty( $params['page'] ) ? $params['page'] : (!empty( $params['page_default'] ) ? $params['page_default'] : NULL );
+ $transclusion_parsed = '';
+ include_once( WIKI_PKG_PATH.'BitPage.php' );
+ $transclusion_bitpage = new BitPage();
+ if( $transclusion_page_id = $transclusion_bitpage->findByPageName($pageName) ) {
+ $transclusion_bitpage->mPageId = $transclusion_page_id;
+ if($transclusion_bitpage->load()) {
+ $transclusion_full_page_data = $transclusion_bitpage->mInfo['data'];
+ $transclusion_parsed = $transclusion_bitpage->parseData($transclusion_full_page_data, ( isset( $transclusion_bitpage->mInfo['format_guid'] ) ? $transclusion_bitpage->mInfo['format_guid'] : 'tikiwiki' ) ) ;
+ }
+ }
+
+ return $transclusion_parsed;
+}
+
+?>
diff --git a/smartyplugins/function.inlinemodule.php b/smartyplugins/function.inlinemodule.php
new file mode 100644
index 0000000..3be9001
--- /dev/null
+++ b/smartyplugins/function.inlinemodule.php
@@ -0,0 +1,21 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Usage: add to the body of any .tpl file
+ * Example: {inlinemodule file="bitpackage:wiki/mod_last_modif_pages.tpl" rows="50"}
+ */
+function smarty_function_inlinemodule($params, &$gBitSmarty) {
+ global $module_rows, $module_title, $module_params;
+
+ $module_rows = ( !empty( $params['rows'] ) && is_numeric( trim( $params['rows'] ) ) ? $params['rows'] : NULL );
+ $module_title = ( !empty( $params['title'] ) ? $params['title'] : NULL );
+ $module_params = ( !empty( $params ) ? $params : NULL );
+ print $gBitSmarty->fetch( $params['file'] );
+}
+?>
diff --git a/smartyplugins/function.jscalendar.php b/smartyplugins/function.jscalendar.php
new file mode 100644
index 0000000..7ddc9b5
--- /dev/null
+++ b/smartyplugins/function.jscalendar.php
@@ -0,0 +1,67 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {jscalendar} plugin
+ *
+ * Type: function<br>
+ * Name: jscalendar<br>
+ * Purpose: Prints the dropdowns for date selection.
+ *
+ * ChangeLog:<br>
+ * - 1.0 initial release
+ * @version 1.0
+ * @author Stephan Borg
+ * @param array
+ * @param Smarty
+ * @return string
+*/
+function smarty_function_jscalendar($params, &$gBitSmarty) {
+ global $gBitSystem;
+ if( $gBitSystem->isFeatureActive( 'site_use_jscalendar' ) ) {
+ //require_once $gBitSmarty->_get_plugin_filepath('shared', 'make_timestamp');
+ //require_once $gBitSmarty->_get_plugin_filepath('function', 'html_options');
+
+ // Default values
+ $inputField = ''; // ID of the input field
+ $fieldFormat = '%s'; // format of the input field
+ $electric = 'false'; // ID of the span where the date is to be shown
+ $time = time(); // override the currently set date
+ $onUpdate = ''; // execute the following javascript function when a link is pressed
+ $daFormat = $gBitSystem->getConfig( 'site_short_date_format' ).' '.$gBitSystem->getConfig( 'site_short_time_format' ); // format of output date
+ $displayArea = '';
+
+ // override default values
+ extract( $params );
+
+ $time = $gBitSystem->mServerTimestamp->getDisplayDateFromUTC( $time );
+ $time = strftime( "%m/%d/%Y %H:%M", $time );
+
+ if( $readonly ) {
+ $html_result = $time;
+ } else {
+ $html_result =
+ "<script type=\"text/javascript\">//<![CDATA[
+ Calendar.setup({
+ date : \"$time\",
+ inputField : \"$inputField\",
+ ifFormat : \"$fieldFormat\",
+ daFormat : \"$daFormat\",
+ displayArea : \"$displayArea\",
+ electric : $electric,
+ onUpdate : $onUpdate
+ });
+ //]]></script>"
+ ;
+ }
+
+ return $html_result;
+ } else {
+ return '';
+ }
+}
+?>
diff --git a/smartyplugins/function.jspack.php b/smartyplugins/function.jspack.php
new file mode 100644
index 0000000..c11459f
--- /dev/null
+++ b/smartyplugins/function.jspack.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * this function will output the URL to a given compressed and cached js file.
+ * NOTE: if you use the util package, it will automatically insert the javascript/ subdir
+ *
+ * @param string $pParams[ipackage] package the javascript file is in. this will default to: 'util'. e.g.: wiki
+ * @param string $pParams[ifile] subdir and filename of the file you wish to pack and cache. e.g.: libs/jsfile.js
+ * @param string $pParams[defer] includes defer='defer'
+ * @param object $gBitSmarty
+ * @access public
+ * @return URL to cached javascript file
+ */
+function smarty_function_jspack( $pParams, &$gBitSmarty ) {
+ // make sure we have a file to pack
+ if( empty( $pParams['ifile'] )) {
+ die();
+ }
+
+ if( empty( $pParams['ipackage'] )) {
+ $pParams['ipackage'] = 'util';
+ }
+
+ // get the full path to the file we want to pack - insert javasscript/ into path when we're getting stuff in util
+ $jsfile = constant( strtoupper( $pParams['ipackage'] ).'_PKG_PATH' ).(( $pParams['ipackage'] == 'util' ) ? 'javascript/' : '' ).$pParams['ifile'];
+
+ if( is_file( $jsfile )) {
+ // get a name for the cache file we're going to store
+ $cachefile = $pParams['ipackage'].'_'.str_replace( '/', '_', $pParams['ifile'] );
+
+ require_once( KERNEL_PKG_PATH.'BitCache.php' );
+ $bitCache = new BitCache( 'javascript', TRUE );
+
+ // if the file hasn't been packed and cached yet, we do that now.
+ if( !$bitCache->isCached( $cachefile, filemtime( $jsfile ))) {
+ /*
+ * params of the constructor :
+ * $script: the JavaScript to pack, string.
+ * $encoding: level of encoding, int or string :
+ * 0,10,62,95 or 'None', 'Numeric', 'Normal', 'High ASCII'.
+ * default: 62.
+ * $fastDecode: include the fast decoder in the packed result, boolean.
+ * default : true.
+ * $specialChars: if you have flagged your private and local variables
+ * in the script, boolean.
+ * default: false.
+ */
+ require_once( UTIL_PKG_PATH.'javascript/class.JavaScriptPacker.php' );
+ $packer = new JavaScriptPacker( file_get_contents( $jsfile ), 'Normal', TRUE, FALSE );
+ $bitCache->writeCacheFile( $cachefile, $packer->pack() );
+ }
+
+ $defer = !empty( $pParams['defer'] ) ? " defer='".$pParams['defer']."'" : "";
+ return '<script'.$defer.' type="text/javascript" src="'.$bitCache->getCacheUrl( $cachefile ).'"></script>';
+ } else {
+ return "<!-- ".tra( 'not a valid file: ' ).$pParams['ifile']." -->";
+ }
+}
+?>
diff --git a/smartyplugins/function.jspopup.php b/smartyplugins/function.jspopup.php
new file mode 100644
index 0000000..cef11ea
--- /dev/null
+++ b/smartyplugins/function.jspopup.php
@@ -0,0 +1,103 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * smarty_function_jspopup
+ */
+
+/**
+ * smarty_function_jspopup
+ *
+ * @param array $pParams hash of options
+ * @param srting $pParams[href] link the popup should open
+ * @param srting $pParams[title] title of the link
+ * @param srting $pParams[img] source of an image that is to be displayed instead of the title
+ * @param srting $pParams[href]
+ * @param srting $pParams[href]
+ * @param array $gBitSmarty
+ * @access public
+ * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
+ */
+function smarty_function_jspopup( $pParams, &$gBitSmarty ) {
+ global $gBitThemes;
+
+ $ret = '';
+ if( empty( $pParams['href'] ) ) {
+ return( 'assign: missing "href" parameter' );
+ }
+
+ if( empty( $pParams['title'] ) ) {
+ return( 'assign: missing "title" parameter' );
+ } else {
+ $title = empty( $pParams['notra'] ) ? $pParams['title'] : tra( $pParams['title'] );
+ }
+
+ if( empty( $pParams['text'] )){
+ $text = $title;
+ } else {
+ $text = empty( $pParams['notra'] ) ? $pParams['text'] : tra( $pParams['text'] );
+ // remove it from the hash since later the params are looped over for to formulate the a tag
+ unset( $pParams['text'] );
+ }
+
+
+ $optionHash = array( 'type', 'width', 'height', 'gutsonly', 'img' );
+ foreach( $pParams as $param => $val ) {
+ if( !in_array( $param, $optionHash ) ) {
+ if( $param == 'title' ) {
+ $guts .= ' '.$param.'="'.tra( 'This will open a new window: ' ).$title.'"';
+ }elseif( $param == 'href' && $gBitThemes->isJavascriptEnabled()){
+ $guts .= ' '.$param.'="javascript:void(0)"';
+ } else {
+ $guts .= ' '.$param.'="'.$val.'"';
+ }
+ }
+ }
+
+ if( !empty( $pParams['ibiticon'] ) ) {
+ require_once $gBitSmarty->_get_plugin_filepath( 'function','biticon' );
+
+ $tmp = explode( '/', $pParams['ibiticon'] );
+ $ibiticon = array(
+ 'ipackage' => $tmp[0],
+ 'iname' => $tmp[1],
+ 'iexplain' => $title,
+ );
+
+ if( !empty( $pParams['iforce'] ) ) {
+ $ibiticon['iforce'] = $pParams['iforce'];
+ }
+ $img = smarty_function_biticon( $ibiticon, $gBitSmarty );
+ }
+
+ if( !empty( $pParams['img'] )) {
+ $img_size = NULL;
+ $file = str_replace( '//', '/', BIT_BASE_PATH.( str_replace( BIT_ROOT_URI, '', urldecode( $pParams['img'] ))));
+ if( is_file( $file )) {
+ if( $imgSizeHash = @getimagesize( $file )) {
+ $img_size = $imgSizeHash[3];
+ }
+ }
+ $img = '<img src="'.$pParams['img'].'" alt="'.$title.'" title="'.$title.'" '.$img_size.' />';
+ }
+
+ if( !empty( $pParams['type'] ) && $pParams['type'] == 'fullscreen' ) {
+ $js = 'popUpWin(\''.$pParams['href'].'\',\'fullScreen\');';
+ } else {
+ $js = 'popUpWin(\''.$pParams['href'].'\',\'standard\','.( !empty( $pParams['width'] ) ? $pParams['width'] : 600 ).','.( !empty( $pParams['height'] ) ? $pParams['height'] : 400 ).');';
+ }
+
+ // deprecated slated for removal - onkeypress causes focus problems with browsers - if this is an ada issue get in touch -wjames5.
+ // $guts .= ' onkeypress="'.$js.'" onclick="'.$js.'return false;"';
+ $guts .= ' onclick="'.$js.'return false;"';
+
+ if( !empty( $pParams['gutsonly'] ) ) {
+ return $guts;
+ } else {
+ return( '<a '.$guts.'>'.( !empty( $img ) ? $img : $text ).'</a>' );
+ }
+}
diff --git a/smartyplugins/function.libertypagination.php b/smartyplugins/function.libertypagination.php
new file mode 100644
index 0000000..e82915f
--- /dev/null
+++ b/smartyplugins/function.libertypagination.php
@@ -0,0 +1,72 @@
+<?php
+/**
+ * Smarty {libertypagination} function plugin
+ *
+ * This provides a means of paging through longer lists of data using an up and down arrow.
+ * In addition, if the 'site_direct_pagination' feature is enabled, then a direct page number can be entered jump directly to
+ *
+ * Type: function<br>
+ * Name: libertypagination<br>
+ * Input:<br>
+ * - numPages Number of pages in total<br>
+ * - page current page<br>
+ * - pgnName (optional) parameter name used by script to find page you're on. defaults to page<br>
+ * - ianchor (optional) set an anchor<br>
+ * - ihash (optional) you can pass in all the above as an array called ihash or secondary * items common to all links<br>
+ * The ihash option allow the inclusion of additional link values as provided for smartlink navigation<br>
+ * Output: url of the form: $REQUEST_URI?attribute1=value1&attribute2=value2
+ *
+ * @package Smarty
+ * @subpackage plugins
+ * @link http://www.bitweaver.org/wiki/function_libertypagination function.libertypagination
+ */
+
+/**
+ * Smarty {libertypagination} function plugin
+ */
+function smarty_function_libertypagination($params, &$gBitSmarty) {
+ if( isset( $params['ihash'] ) && is_array( $params['ihash'] ) ) {
+ $params = array_merge( $params['ihash'], $params );
+ $params['ihash'] = NULL;
+ }
+
+ if( isset( $params['url'] ) ) {
+ $urlParams = '';
+ parse_str( preg_replace( "/.*\?/", "", $params['url'] ), $urlParams );
+ $params = array_merge( $urlParams, $params );
+ }
+ $pgnName = isset( $params['pgnName'] ) ? $params['pgnName'] : ( isset( $params['curPage'] ) ? 'curPage' : 'page' );
+ $pgnVars = '';
+
+ $omitParams = array( 'numPages', 'url', $pgnName, 'pgnName', 'ianchor', 'ajaxId' );
+ foreach( $params as $form_param => $form_val ) {
+ if ( !empty( $form_val ) && !in_array( $form_param, $omitParams ) ) {
+ $pgnVars .= ( !empty( $params['ajaxId'] ) ? "&" : "&amp;" ).$form_param."=".$form_val;
+ $pgnHidden[$form_param] = $form_val;
+ }
+ }
+ $pgnVars .= ( !empty( $params['ianchor'] ) ? '#'.$params['ianchor'] : '' );
+ for( $pageCount = 1; $pageCount < $params['numPages']+1; $pageCount++ ) {
+ if( $pageCount != $params[$pgnName] ) {
+ if( $params['ajaxId'] ) {
+ $pages[] = '<a href="javascript:void(0);" onclick="BitAjax.updater(\''.$params['ajaxId']."','".$_SERVER['REQUEST_URI']."','".$pgnName.'='.$pageCount.$pgnVars.'\')'.'">'.( $pageCount ).'</a>';
+ } else {
+ $pages[] = '<a href="'.$_SERVER['SCRIPT_URL'].'?'.$pgnName.'='.$pageCount.$pgnVars.'">'.( $pageCount ).'</a>';
+ }
+ } else {
+ $pages[] = '<strong>'.$pageCount.'</strong>';
+ }
+ }
+
+ if( $params['numPages'] > 1 ) {
+ $gBitSmarty->assign( 'pgnPage', $params[$pgnName] );
+ $gBitSmarty->assign( 'pgnName', $pgnName );
+ $gBitSmarty->assign( 'pgnVars', $pgnVars );
+ $gBitSmarty->assign( 'pgnHidden', $pgnHidden );
+ $gBitSmarty->assign( 'pgnPages', $pages );
+ $gBitSmarty->assign( 'numPages', $params['numPages'] );
+ $gBitSmarty->assign( 'ajaxId', $params['ajaxId'] );
+ $gBitSmarty->display( 'bitpackage:liberty/libertypagination.tpl' );
+ }
+}
+?>
diff --git a/smartyplugins/function.memusage.php b/smartyplugins/function.memusage.php
new file mode 100644
index 0000000..1e0158f
--- /dev/null
+++ b/smartyplugins/function.memusage.php
@@ -0,0 +1,55 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * smarty_function_memusage
+ */
+function smarty_function_memusage($params, &$gBitSmarty) {
+ if( function_exists( 'memory_get_usage' ) ) {
+ $memusage = memory_get_usage();
+ } else {
+ // If its Windows
+ // Tested on Win XP Pro SP2. Should work on Win 2003 Server too
+ // Doesn't work for 2000
+ // If you need it to work for 2000 look at http://us2.php.net/manual/en/function.memory-get-usage.php#54642
+ if( substr( PHP_OS, 0, 3 ) == 'WIN' ) {
+ if( substr( PHP_OS, 0, 3 ) == 'WIN' ) {
+ $output = array();
+ }
+ exec( 'tasklist /FI "PID eq ' . getmypid() . '" /FO LIST', $output );
+ $memusage = preg_replace( '/[\D]/', '', $output[5] ) * 1024;
+ } else {
+ // We now assume the OS is UNIX
+ // Tested on Mac OS X 10.4.6 and Linux Red Hat Enterprise 4
+ // This should work on most UNIX systems
+ $pid = getmypid();
+ exec( "ps -eo%mem,rss,pid | grep $pid", $output );
+ $output = explode( " ", trim( $output[0] ) );
+ // rss is given in 1024 byte units
+ $memusage = $output[1] * 1024;
+ }
+ }
+
+ if( $memusage > 0 ) {
+ $memunit="B";
+ if( $memusage > 1024 ) {
+ $memusage = $memusage/1024;
+ $memunit = "kB";
+ }
+ if( $memusage>1024 ) {
+ $memusage=$memusage/1024;
+ $memunit="MB";
+ }
+ if( $memusage>1024 ) {
+ $memusage=$memusage/1024;
+ $memunit="GB";
+ }
+ print( number_format( $memusage, 2 ).$memunit );
+ }
+}
+
+?>
diff --git a/smartyplugins/function.menu.php b/smartyplugins/function.menu.php
new file mode 100644
index 0000000..f22d012
--- /dev/null
+++ b/smartyplugins/function.menu.php
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * smarty_function_menu
+ *
+ * this is only kept to avoid sites from breaking that use {menu} in the layout
+ */
+function smarty_function_menu($params, &$gBitSmarty) {
+ // Dummy
+}
+?>
diff --git a/smartyplugins/function.minifind.php b/smartyplugins/function.minifind.php
new file mode 100644
index 0000000..8615349
--- /dev/null
+++ b/smartyplugins/function.minifind.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {minifind} function plugin
+ *
+ * Type: function
+ * Name: minifind
+ * Input: all parameters (except legend) that are passed in will be added as <input type="hidden" name=$name value=$value>. The 'legend' parameter will be used as the form legend, a string is expected.
+ * Output: a small form that allows you to search your table using $_REQUEST['find'] as search value
+ */
+function smarty_function_minifind($params, &$gBitSmarty) {
+
+ if(isset($params['legend'])) {
+ $legend = $params['legend'];
+ unset($params['legend']);
+ } else {
+ $legend = 'find in entries';
+ }
+
+ if( !empty( $params['prompt'] ) ) {
+ $gBitSmarty->assign( 'prompt', tra( $params['prompt'] ) );
+ }
+
+ $gBitSmarty->assign( 'legend',$legend );
+ $gBitSmarty->assign( 'hidden',$params );
+ $gBitSmarty->display( 'bitpackage:kernel/minifind.tpl' );
+}
+?>
diff --git a/smartyplugins/function.moduleinc.php b/smartyplugins/function.moduleinc.php
new file mode 100644
index 0000000..1d1f371
--- /dev/null
+++ b/smartyplugins/function.moduleinc.php
@@ -0,0 +1,63 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * moduleinc
+ *
+ * Usage: add to the body of any .tpl file
+ * Example: {inlinemodule file="_custom:custom/my_custom_module" cache_time=600}
+ *
+ * Note: currently only supports custom modules generated in themes package,
+ * could support any module with more work
+ * moduleinc mirrors process in modules_inc.php except $r is replaced with $pParams
+ * see modules_inc.php to expand support to other modules
+ *
+ * @param array $pParams
+ * @param string $pParams['module_rsrc'] the full name of the template, example: _custom:custom/my_custom_module
+ * @param integer $pParams['cache_time'] seconds the template will be cached
+ */
+function smarty_function_moduleinc($pParams, &$gBitSmarty) {
+ global $gBitSystem, $gBitThemes;
+
+ // go through some hassle here in consideration of a future day when this handles any module
+ list( $package, $template ) = split( '/', $pParams['module_rsrc'] );
+
+ if( $package == '_custom:custom' ) {
+ global $gBitLanguage;
+
+ // We're gonna run our own cache mechanism for user_modules
+ // the cache is here to avoid calls to consumming queries,
+ // each module is different for each language because of the strings
+ $cacheDir = TEMP_PKG_PATH.'modules/cache/';
+ if( !is_dir( $cacheDir )) {
+ mkdir_p( $cacheDir );
+ }
+ $cachefile = $cacheDir.'_custom.'.$gBitLanguage->mLanguage.'.'.$template.'.tpl.cache';
+
+ if( !empty( $pParams["cache_time"] ) && file_exists( $cachefile ) && !(( $gBitSystem->getUTCTime() - filemtime( $cachefile )) > $pParams["cache_time"] )) {
+ $fp = fopen( $cachefile, "r" );
+ $data = fread( $fp, filesize( $cachefile ));
+ fclose( $fp );
+ print( $data );
+ } else {
+ if( $moduleParams = $gBitThemes->getCustomModule( $template )) {
+ $moduleParams = array_merge( $pParams, $moduleParams );
+ $gBitSmarty->assign_by_ref( 'moduleParams', $moduleParams );
+ $data = $gBitSmarty->fetch( 'bitpackage:themes/custom_module.tpl' );
+
+ if( !empty( $pParams["cache_time"] ) ) {
+ // write to chache file
+ $fp = fopen( $cachefile, "w+" );
+ fwrite( $fp, $data, strlen( $data ));
+ fclose( $fp );
+ }
+ print( $data );
+ }
+ }
+ unset( $data );
+ }
+}
diff --git a/smartyplugins/function.nexus.php b/smartyplugins/function.nexus.php
new file mode 100644
index 0000000..9c54c32
--- /dev/null
+++ b/smartyplugins/function.nexus.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {nexus} function plugin
+ *
+ * Type: function
+ * Name: nexus
+ * Input: - id (required) - id of the menu that should be displayed
+ */
+function smarty_function_nexus( $params, &$gBitSmarty ) {
+ extract($params);
+
+ if( empty( $id ) ) {
+ $gBitSmarty->trigger_error("assign: missing id");
+ return;
+ }
+
+ require_once( NEXUS_PKG_PATH.'Nexus.php' );
+ $tmpNexus = new Nexus( $id );
+ $nexusMenu = $tmpNexus->mInfo;
+
+ $gBitSmarty->assign( 'nexusMenu', $nexusMenu );
+ $gBitSmarty->assign( 'nexusId', $id );
+ $gBitSmarty->display('bitpackage:nexus/nexus_module.tpl');
+}
+?> \ No newline at end of file
diff --git a/smartyplugins/function.pageurl.php b/smartyplugins/function.pageurl.php
new file mode 100644
index 0000000..0ee7540
--- /dev/null
+++ b/smartyplugins/function.pageurl.php
@@ -0,0 +1,82 @@
+<?php
+/**
+ * Smarty {pageurl} function plugin
+ * @package Smarty
+ * @subpackage plugins
+ * @link http://www.bitweaver.org/wiki/function_pageurl function_pageurl
+ */
+
+/**
+ * Smarty {pagination} function plugin
+ *
+ * Type: function<br>
+ * Name: pageurl<br>
+ * Input:
+ * - <listHash>=<attribute=>value> (optional) - pass in any attributes and they will be added to the url string<br>
+ * Output: url of the form: $PHP_SELF?attribute1=value1&attribute2=value2
+
+/* Build up URL variable string */
+function smarty_function_pageurl( $params, &$gBitSmarty ) {
+ extract( $params );
+
+ if( !isset( $pgnUrl ) ) {
+ $pgnUrl = $gBitSmarty->get_template_vars('returnURL');
+ if ( isset( $params['url'] ) ) {
+ $pgnUrl = $params['url'];
+ unset( $params['url'] );
+ }
+ if( empty( $pgnUrl ) ) {
+ $pgnUrl = $_SERVER['PHP_SELF'];
+ }
+ }
+
+ $str = '';
+
+ if( !empty( $listInfo['parameters'] ) ){
+ $str .= pageurl_hash_to_string( $listInfo['parameters'] );
+ }
+ if( !empty( $listInfo['ihash'] ) ){
+ $str .= pageurl_hash_to_string( $listInfo['ihash'] );
+ // find can show up in two places
+ $foundFind = !empty( $listInfo['ihash']['find'] );
+ }
+ if( !empty( $pgnHidden ) ){
+ $str .= pageurl_hash_to_string( $pgnHidden );
+ }
+ if ( !empty( $listInfo['sort_mode'] ) ){
+ if ( is_array( $listInfo['sort_mode']) ){
+ foreach( $listInfo['sort_mode'] as $sort ){
+ $str .= "&amp;sort_mode[]=".$sort;
+ }
+ }else{
+ $str .= "&amp;sort_mode=".$listInfo['sort_mode'];
+ }
+ }
+ if( !$foundFind && isset($listInfo['find']) && $listInfo['find'] != '' ){
+ $str .= "&amp;find=".$listInfo['find'];
+ }
+
+ $pageUrlVar = preg_replace( '/^\&amp;/', '', $str );
+
+ $pageUrl = $pgnUrl . "?" . $pageUrlVar;
+
+ return $pageUrl;
+}
+
+function pageurl_hash_to_string( $pParamHash ){
+ $str = "";
+
+ foreach( $pParamHash as $param=>$value ){
+ if( is_array( $value ) ){
+ foreach ( $value as $v ){
+ if ( $value != '' ){
+ $str .= "&amp;".$param."[]=".$v;
+ }
+ }
+ }elseif ( $value != '' ){
+ $str .= "&amp;".$param."=".$value;
+ }
+ }
+
+ return $str;
+}
diff --git a/smartyplugins/function.pagination.php b/smartyplugins/function.pagination.php
new file mode 100644
index 0000000..4963171
--- /dev/null
+++ b/smartyplugins/function.pagination.php
@@ -0,0 +1,39 @@
+<?php
+/**
+ * Smarty {pagination} function plugin
+ * @package Smarty
+ * @subpackage plugins
+ * @link http://www.bitweaver.org/wiki/function_pagination function_pagination
+ */
+
+/**
+ * Smarty {pagination} function plugin
+ *
+ * Type: function<br>
+ * Name: pagination<br>
+ * Input:<br>
+ * - <attribute>=<value> (optional) - pass in any attributes and they will be added to the pagination string<br>
+ * Output: url of the form: $PHP_SELF?attribute1=value1&attribute2=value2
+ */
+function smarty_function_pagination( $params, &$gBitSmarty ) {
+ $pgnUrl = $gBitSmarty->get_template_vars('returnURL');
+ if ( isset( $params['url'] ) ) {
+ $pgnUrl = $params['url'];
+ unset( $params['url'] );
+ }
+ if( empty( $pgnUrl ) ) {
+ $pgnUrl = $_SERVER['PHP_SELF'];
+ }
+
+ $gBitSmarty->assign( 'pgnUrl', $pgnUrl );
+
+ $pgnVars = '';
+ foreach( $params as $form_param => $form_val ) {
+ $pgnVars .= "&amp;".$form_param."=".$form_val;
+ $pgnHidden[$form_param] = $form_val;
+ }
+ $gBitSmarty->assign( 'pgnVars', $pgnVars );
+ $gBitSmarty->assign( 'pgnHidden', $pgnHidden );
+ $gBitSmarty->display('bitpackage:kernel/pagination.tpl');
+}
+?>
diff --git a/smartyplugins/function.poll.php b/smartyplugins/function.poll.php
new file mode 100644
index 0000000..dcc9142
--- /dev/null
+++ b/smartyplugins/function.poll.php
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * smarty_function_base
+ */
+require_once( KERNEL_PKG_PATH.'BitBase.php' );
+
+/**
+ * smarty_function_poll
+ */
+function smarty_function_poll($params, &$gBitSmarty) {
+ global $polllib, $gBitSystem;
+
+ extract($params);
+ // Param = zone
+ include_once( POLLS_PKG_PATH.'poll_lib.php' );
+ include_once( LIBERTY_PKG_PATH.'LibertyComment.php' );
+
+ if (empty($id)) {
+ $id = $polllib->get_random_active_poll();
+ }
+ if($id) {
+ $menu_info = $polllib->get_poll($id);
+ $channels = $polllib->list_poll_options($id,0,-1,'option_id_asc','');
+ if ($gBitSystem->getConfig('feature_poll_comments') == 'y') {
+ $comments = new LibertyComment();
+ $comments_count = $comments->count_comments("poll:".$menu_info["poll_id"]);
+ }
+ $gBitSmarty->assign('comments', $comments_count);
+ $gBitSmarty->assign('ownurl',POLLS_PKG_URL.'results.php?poll_id='.$id);
+ $gBitSmarty->assign('menu_info',$menu_info);
+ $gBitSmarty->assign('channels',$channels["data"]);
+ $gBitSmarty->display('bitpackage:polls/poll.tpl');
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/smartyplugins/function.popup.php b/smartyplugins/function.popup.php
new file mode 100644
index 0000000..bb69517
--- /dev/null
+++ b/smartyplugins/function.popup.php
@@ -0,0 +1,134 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {popup} function plugin
+ *
+ * Type: function<br>
+ * Name: popup<br>
+ * Purpose: make text pop up in windows via overlib
+ * @link http://smarty.php.net/manual/en/language.function.popup.php {popup}
+ * (Smarty online manual)
+ * @param array
+ * @param Smarty
+ * @return string
+ */
+require_once(LIBERTY_PKG_PATH."LibertyContent.php");
+
+function smarty_function_popup($params, &$gBitSmarty) {
+ $append = '';
+ foreach ($params as $_key=>$_value) {
+ switch ($_key) {
+ case 'target':
+ case 'text':
+ case 'trigger':
+ case 'content_id':
+ $$_key = (string)$_value;
+ break;
+
+ case 'caption':
+ case 'closetext':
+ case 'status':
+ $append .= ',' . strtoupper($_key) . ",'" . str_replace("'","\'",$_value) . "'";
+ break;
+
+ case 'fgcolor':
+ case 'bgcolor':
+ case 'textcolor':
+ case 'capcolor':
+ case 'closecolor':
+ case 'textfont':
+ case 'captionfont':
+ case 'closefont':
+ case 'textsize':
+ case 'captionsize':
+ case 'closesize':
+ case 'width':
+ case 'height':
+ case 'border':
+ case 'offsetx':
+ case 'offsety':
+ case 'fgbackground':
+ case 'bgbackground':
+ case 'inarray':
+ case 'caparray':
+ case 'capicon':
+ case 'snapx':
+ case 'snapy':
+ case 'fixx':
+ case 'fixy':
+ case 'background':
+ case 'padx':
+ case 'pady':
+ case 'frame':
+ case 'timeout':
+ case 'delay':
+ case 'function':
+ $append .= ',' . strtoupper($_key) . ",'$_value'";
+ break;
+
+ case 'sticky':
+ case 'left':
+ case 'right':
+ case 'center':
+ case 'above':
+ case 'below':
+ case 'noclose':
+ case 'autostatus':
+ case 'autostatuscap':
+ case 'fullhtml':
+ case 'hauto':
+ case 'vauto':
+ case 'mouseoff':
+ if ($_value) $append .= ',' . strtoupper($_key);
+ break;
+ case 'closeclick':
+ if ($_value) $append .= ',' . strtoupper($_key);
+ if ($_value) $target_append = $_key.'=1';
+ break;
+
+ default:
+ $gBitSmarty->trigger_error("[popup] unknown parameter $_key", E_USER_WARNING);
+ }
+ }
+
+ if (empty($target) && empty($text) && empty($content_id) && !isset($inarray) && empty($function)) {
+ $gBitSmarty->trigger_error("overlib: attribute 'target' or 'text' or 'inarray' or 'function' required");
+ return false;
+ }
+
+ if ((!empty($target) && !empty($text)) || (!empty($target) && !empty($content_id)) || (!empty($text) && !empty($content_id)) ) {
+ $gBitSmarty->trigger_error("overlib: You may only specify one of 'target', 'text' and 'content_id'..");
+ }
+
+ if (empty($trigger)) { $trigger = "onmouseover"; }
+
+ if (!empty($content_id)) {
+ $target = LibertyContent::getPreviewUrl($content_id);
+ }
+
+ if (!empty($target) && !empty($target_append)) {
+ if (strstr($target, "?")) {
+ $target .= "&".$target_append;
+ }
+ else {
+ $target .= "?".$target_append;
+ }
+ }
+
+ if (!empty($text)) {
+ $retval = $trigger . '="return overlib(\''.preg_replace(array("!'!","![\r\n]!"),array("\'",'\r'),$text).'\'';
+ $retval .= $append . ');" onmouseout="nd();"';
+ }
+ else {
+ $retval = $trigger . '="of=function(t){overlib(t'.$append.');};BitAjax.getAndCall(this,of,\''.$target.'\');" onmouseout="nd();"';
+ }
+
+ return $retval;
+}
+?>
diff --git a/smartyplugins/function.querytable.php b/smartyplugins/function.querytable.php
new file mode 100644
index 0000000..2a29372
--- /dev/null
+++ b/smartyplugins/function.querytable.php
@@ -0,0 +1,77 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Experimental work not finished yet
+ * An attempt to componentize all tables showing query results
+
+ * Usage:
+ * {querytable
+ * table ="" (Table or tables, example wiki_pages,users)
+ * template = "" (Template to be used for table rows, put them in templates/tables)
+ *
+ * where = "" (Where condition for the query)
+ * columns="col1,col2,col3" (Columns to be selected from the query, default = *)
+ * colalign="left,center,right" (Alignement for columns you can also use the template for this)
+ * sort_column = "col2" (Column to sort the data initially)
+ * sort_order = "desc" (Sort order)
+ * max_rows = "10" (Max number of rows to display per page)
+ * height = "" (Height for the table area)
+ * directpagination = "0" (Use directlinks to pages)
+ * combopagination = "0" (Use a combo to directly jump to a page)
+ * tableclass = "normal" (CSS class name for the table)
+ * columnheadingclass = "normal" (CSS class name for the columnheadings)
+ * oddrowclass = "odd"
+ * evenrowclass = "even"
+ * }
+ */
+
+
+//SECURITY HERE!
+
+function smarty_function_querytable($params, &$gBitSmarty) {
+ global $gBitSystem;
+ extract($params);
+ //Security here
+ $arguments = Array('table','template','tableclass','where',
+ 'columns','height',
+ 'sort_column','sort_order','colalign','columnheadingclass',
+ 'max_rows','offset','total','directpagination',
+ 'combopagination');
+
+ if(!isset($table)) {return "Table is a mandatory argument to querytable plugin!";}
+ if(!isset($template)) {return "Template is a mandatory argument to querytable plugin!";}
+ if(!isset($tableclass)) $tableclass='normal';
+ if(!isset($oddrowclass)) $oddrowclass="odd";
+ if(!isset($where)) $where="";
+ if(!isset($evenrowclass)) $evenrowclass="even";
+ if(!isset($columns)) $columns='*';
+ if(!isset($height)) $height=400;
+ if(!isset($directpagination)) $directpagination=0;
+ if(!isset($combopagination)) $combopagination=0;
+ if(!isset($max_rows)) $max_rows = 20;
+ if(!isset($offset)) $offset = 0;
+ if(!isset($total)) $total = 0;
+ if(!isset($sort_column)) $sort_column='';
+ if(!isset($sort_order)) $sort_order='';
+ if(!isset($colalign)) $colalign='left';
+ if(!isset($columnheadingclass)) $columnheadingclass='heading';
+ $columns = urlencode($columns);
+ $output = "<iframe marginwidth='4px' marginheight='4px' width='100%' height='$height' frameborder='0' scrolling='auto' src='querytable.php?f=1";
+ foreach($arguments as $arg) {
+ $val = $$arg;
+ $output.="&amp;$arg=$val";
+ }
+ $output.="'></iframe>";
+
+ return $output;
+
+}
+
+
+
+?>
diff --git a/smartyplugins/function.rcontent.php b/smartyplugins/function.rcontent.php
new file mode 100644
index 0000000..90b5d2c
--- /dev/null
+++ b/smartyplugins/function.rcontent.php
@@ -0,0 +1,28 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * smarty_function_rcontent
+ */
+function smarty_function_rcontent($params, &$gBitSmarty)
+{
+ global $gBitSystem;
+ include_once( DCS_PKG_PATH.'dcs_lib.php' );
+ extract($params);
+ // Param = zone
+
+ if (empty($id)) {
+ $gBitSmarty->trigger_error("assign: missing 'zone' parameter");
+ return;
+ }
+ $data = $dcslib->get_random_content($id);
+ print($data);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/smartyplugins/function.required.php b/smartyplugins/function.required.php
new file mode 100644
index 0000000..05f6767
--- /dev/null
+++ b/smartyplugins/function.required.php
@@ -0,0 +1,25 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * smarty_function_required
+ */
+function smarty_function_required( $pParams, &$gBitSmarty ) {
+ require_once $gBitSmarty->_get_plugin_filepath('function','biticon');
+ $biticon = array(
+ 'ipackage' => 'icons',
+ 'iname' => 'emblem-important',
+ 'iexplain' => 'Required',
+ );
+ $ret = smarty_function_biticon( $biticon, $gBitSmarty );
+
+ if( !empty( $pParams['legend'] )) {
+ $ret = "<p>$ret ".tra( "Elements marked with this symbol are required." )."</p>";
+ }
+ return $ret;
+}
+?>
diff --git a/smartyplugins/function.rss.php b/smartyplugins/function.rss.php
new file mode 100644
index 0000000..4ec93ff
--- /dev/null
+++ b/smartyplugins/function.rss.php
@@ -0,0 +1,17 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * smarty_function_rss
+ */
+function smarty_function_rss($params, &$gBitSmarty) {
+ global $gLibertySystem;
+ include_once( LIBERTY_PKG_PATH.'plugins/data.rss.php' );
+ $feed = rss_parse_data("", $params);
+ print $feed;
+}
+?>
diff --git a/smartyplugins/function.sameurl.php b/smartyplugins/function.sameurl.php
new file mode 100644
index 0000000..d4f581a
--- /dev/null
+++ b/smartyplugins/function.sameurl.php
@@ -0,0 +1,62 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+// Do NOT change this plugin under any circunstances!
+/**
+ * smarty_function_sameurl
+ */
+function smarty_function_sameurl($params, &$gBitSmarty)
+{
+ global $sameurl_elements;
+ $data = $_SERVER['SCRIPT_NAME'];
+ $first=true;
+ $sets=Array();
+ foreach($params as $name=>$val) {
+ if(isset($_REQUEST[$name])) {
+ $_REQUEST[$name]=$val;
+ } else {
+ if(in_array($name,$sameurl_elements)&&!is_array($name)&&!is_array($val)) {
+ if(!in_array($name,$sets)) {
+ if($first) {
+ $first = false;
+ $sep='?';
+ } else {
+ $sep='&amp;';
+ }
+
+ $data.=$sep.urlencode($name).'='.urlencode($val);
+ $sets[]=$name;
+ }
+ }
+
+ }
+ }
+
+ foreach($_REQUEST as $name=>$val) {
+ if(isset($$name)) {
+ $val = $$name;
+ }
+ if(in_array($name,$sameurl_elements)&&!is_array($name)&&!is_array($val)) {
+ if(!in_array($name,$sets)) {
+ if($first) {
+ $first = false;
+ $sep='?';
+ } else {
+ $sep='&amp;';
+ }
+
+ $data.=$sep.urlencode($name).'='.urlencode($val);
+ $sets[]=$name;
+ }
+ }
+ }
+ print($data);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/smartyplugins/function.showdate.php b/smartyplugins/function.showdate.php
new file mode 100644
index 0000000..e11c7af
--- /dev/null
+++ b/smartyplugins/function.showdate.php
@@ -0,0 +1,26 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * smarty_function_showdate
+ */
+function smarty_function_showdate($params, &$gBitSmarty)
+{
+
+ extract($params);
+ // Param = zone
+
+ if (empty($mode)) {
+ $gBitSmarty->trigger_error("assign: missing 'mode' parameter");
+ return;
+ }
+ print(date($mode));
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/smartyplugins/function.smartlink.php b/smartyplugins/function.smartlink.php
new file mode 100644
index 0000000..85fcaf8
--- /dev/null
+++ b/smartyplugins/function.smartlink.php
@@ -0,0 +1,199 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ * @author xing <xing$synapse.plus.com>
+ * @link http://www.bitweaver.org/wiki/function_smartlink function.smartlink
+ */
+
+/**
+ * Smarty {smartlink} function plugin
+ *
+ * Type: function<br>
+ * Name: smartlink<br>
+ * Input:<br>
+ * - ititle (required) words that are displayed<br>
+ * - iatitle (optional) alternative text for the link title (rollover, etc.) <br>
+ * - ianchor (optional) set the anchor where the link should point to<br>
+ * - isort (optional) name of the sort column without the orientation (e.g.: title)<br>
+ * - isort_mode(optional) this can be used to manually pass the sort mode to smartlink<br>
+ * overrides the value given in $_REQUEST['sort_mode'], which is the default<br>
+ * - iorder (optional) if set to asc or desc, it sets the default sorting order of this particular column<br>
+ * asc is default<br>
+ * - idefault (optional) if set, it will highlight this link if no $isort_mode is given<br>
+ * this should only be set once per sorting group since it represents the default sorting column<br>
+ * - itra (optional) if present then don't translate<br>
+ * - itype (optional) can be set to<br>
+ * url --> outputs only url<br>
+ * li --> outputs link as &lt;li&gt;&lt;a ... &gt;&lt;/li&gt;<br>
+ * - ionclick (optional) pass in any actions that should occur onclick<br>
+ * - ibiticon (optional) if you want to display an icon instead of text use ibiticon<br>
+ * format is: '&lt;ipackage&gt;/&lt;iname&gt;'<br>
+ * e.g.: 'liberty/edit'<br>
+ * - iforce (optional) pass iforce parameter through to biticon
+ * - iurl (optional) pass in a full url
+ * - ifile (optional) set the file where the link should point (default is the current file)<br>
+ * - ipackage (optional) set the package the link should point to (default is the current package)<br>
+ * - icontrol (optional) the hash sent out by postGetList()
+ * - * (optional) anything else that gets added to the pile of items is appended using &amp;$key=$val<br>
+ * - ihash (optional) you can pass in all the above as an array called ihash or secondary * items common to all links<br>
+ * Output: any kind of link. especially useful when it comes to links used to sort a table, due to the simplified syntax and loss of cumbersome if clauses
+ * also useful if the you want to display an icon as link since smartlink takes biticon parameters<br>
+ * Example - {smartlink ititle="Page Name" isort="title"}<br>
+ * - {smartlink ititle="Page Name" isort="title" iorder="desc" idefault=1}<br>
+ * setting iorder and idefault here, makes this link sort in a descending order by default (iorder)<br>
+ * and it is highlighted when $isort_mode ( or $_REQUEST['sort_mode'] ) is not set (idefault)<br>
+ * Note Be careful if ititle is generated dynamically since it is passed through tra() by default, use itra to override<br>
+ */
+function smarty_function_smartlink( $params, &$gBitSmarty ) {
+ if( !empty( $params['ihash'] ) ) {
+ $hash = array_merge( $params['ihash'], $params );
+ $hash['ihash'] = NULL;
+ } else {
+ // maybe params were passed in separately
+ $hash = &$params;
+ }
+
+ if( !isset( $hash['ititle'] ) ) {
+ return 'You need to supply "ititle" for {smartlink} to work.';
+ }
+
+ // work out what the url is
+ if( !empty( $hash['iurl'] ) ) {
+ $url = $hash['iurl'];
+ } elseif( !empty( $hash['ifile'] ) ) {
+ if( !empty( $hash['ipackage'] ) ) {
+ if( $hash['ipackage'] == 'root' ) {
+ $url = BIT_ROOT_URL.$hash['ifile'];
+ } else {
+ $url = constant( strtoupper( $hash['ipackage'] ).'_PKG_URL' ).$hash['ifile'];
+ }
+ } else {
+ $url = constant( strtoupper( ACTIVE_PACKAGE ).'_PKG_URL' ).$hash['ifile'];
+ }
+ } else {
+ $url = $_SERVER['PHP_SELF'];
+ }
+
+ $url_params = NULL;
+ if( !empty( $hash['itra'] ) || $hash['itra'] === FALSE ) {
+ $ititle = $hash['ititle'];
+ $iatitle = empty( $hash['iatitle'] ) ? $ititle : $hash['iatitle'];
+ } else {
+ $ititle = tra( $hash['ititle'] );
+ $iatitle = empty( $hash['iatitle'] ) ? $ititle : tra ( $hash['iatitle'] );
+ }
+
+ $atitle = 'title="'.$iatitle.'"';
+
+ // if isort is set, we need to deal with all the sorting stuff
+ if( !empty( $hash['isort'] ) ) {
+ $isort_mode = isset( $hash['isort_mode'] ) ? $hash['isort_mode'] : isset( $_REQUEST['sort_mode'] ) ? $_REQUEST['sort_mode'] : NULL ;
+ $sort_asc = $hash['isort'].'_asc';
+ $sort_desc = $hash['isort'].'_desc';
+
+ $atitle = 'title="'.tra( 'Sort by' ).": ".$iatitle.'"';
+ $url .= '?';
+ $url_params .= 'sort_mode=';
+
+ // check if we have to highlight this link, when $isort_mode isn't set
+ if( isset( $hash['idefault'] ) && empty( $isort_mode ) ) {
+ $isort_mode .= $hash['isort'].'_'.( isset( $hash['iorder'] ) ? $hash['iorder'] : 'asc' );
+ }
+
+ // check if sort_mode has anything to do with our link
+ if( $sort_asc == $isort_mode ) {
+ $sorticon = array(
+ 'ipackage' => 'icons',
+ 'iname' => 'view-sort-ascending',
+ 'iexplain' => 'ascending',
+ 'iforce' => 'icon',
+ );
+ $url_params .= $sort_desc;
+ } elseif( $sort_desc == $isort_mode ) {
+ $sorticon = array(
+ 'ipackage' => 'icons',
+ 'iname' => 'view-sort-descending',
+ 'iexplain' => 'descending',
+ 'iforce' => 'icon',
+ );
+ $url_params .= $sort_asc;
+ } else {
+ $url_params .= $hash['isort'].'_'.( isset( $hash['iorder'] ) ? $hash['iorder'] : 'asc' );
+ }
+ }
+
+ $ignore = array( 'iatitle', 'icontrol', 'isort', 'ianchor', 'isort_mode', 'iorder', 'ititle', 'idefault', 'ifile', 'ipackage', 'itype', 'iurl', 'ionclick', 'ibiticon', 'iforce', 'itra' );
+ // append any other paramters that were passed in
+ foreach( $hash as $key => $val ) {
+ if( !empty( $val ) && !in_array( $key, $ignore ) ) {
+ // normally the key is a string
+ if( !is_array( $val ) ){
+ $url_params .= empty( $url_params ) ? '?' : '&amp;';
+ $url_params .= $key."=".$val;
+ // but sometimes it can be an array
+ }else{
+ foreach( $val as $v ){
+ $url_params .= empty( $url_params ) ? '?' : '&amp;';
+ $url_params .= $key."[]=".$v;
+ }
+ }
+ }
+ }
+
+ if( !empty( $hash['icontrol'] ) && is_array( $hash['icontrol'] ) ) {
+ $sep = empty( $url_params ) ? '?' : '&amp;';
+ $url_params .= !empty( $hash['icontrol']['current_page'] ) ? $sep.'list_page='.$hash['icontrol']['current_page'] : '';
+ $sep = empty( $url_params ) ? '?' : '&amp;';
+ $url_params .= !empty( $hash['icontrol']['find'] ) ? $sep.'find='.$hash['icontrol']['find'] : '';
+ if( !empty( $hash['icontrol']['parameters'] ) && is_array( $hash['icontrol']['parameters'] ) ) {
+ foreach( $hash['icontrol']['parameters'] as $key => $value ) {
+ if( !empty( $value )) {
+ $sep = empty( $url_params ) ? '?' : '&amp;';
+ $url_params .= $sep.$key."=".$value;
+ }
+ }
+ }
+ }
+
+ // encode quote marks so we not break href="" construction
+ $url_params = preg_replace('/"/', '%22', $url_params);
+
+ require_once $gBitSmarty->_get_plugin_filepath( 'function','biticon' );
+
+ if( isset( $hash['itype'] ) && $hash['itype'] == 'url' ) {
+ $ret = $url.$url_params;
+ } else {
+ $ret = '<a '.$atitle.' '.( !empty( $params['ionclick'] ) ? 'onclick="'.$params['ionclick'].'" ' : '' ).'href="'.$url.$url_params.( !empty( $params['ianchor'] ) ? '#'.$params['ianchor'] : '' ).'">';
+
+ // if we want to display an icon instead of text, do that
+ if( isset( $hash['ibiticon'] ) ) {
+ $tmp = explode( '/', $hash['ibiticon'] );
+ if( !empty( $tmp[2] )) {
+ $tmp[1] .= "/".$tmp[2];
+ }
+ $ibiticon = array(
+ 'ipackage' => $tmp[0],
+ 'iname' => $tmp[1],
+ 'iexplain' => $hash['ititle'], // use untranslated ititle - biticon has a tra()
+ );
+ if( !empty( $hash['iforce'] ) ) {
+ $ibiticon['iforce'] = $hash['iforce'];
+ }
+ $ret .= smarty_function_biticon( $ibiticon, $gBitSmarty );
+ } else {
+ $ret .= $ititle;
+ }
+
+ if( isset( $sorticon ) ) {
+ $ret .= '&nbsp;'.smarty_function_biticon( $sorticon, $gBitSmarty );
+ }
+ $ret .= '</a>';
+ }
+ if( isset( $params['itype'] ) && $params['itype'] == 'li' ) {
+ $ret = '<li>'.$ret.'</li>';
+ }
+ return $ret;
+}
+?>
diff --git a/smartyplugins/function.spellchecker.php b/smartyplugins/function.spellchecker.php
new file mode 100644
index 0000000..92dbb0d
--- /dev/null
+++ b/smartyplugins/function.spellchecker.php
@@ -0,0 +1,22 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {spellchecker} function plugin
+ *
+ * Type: function
+ * Name: spellchecker
+ */
+function smarty_function_spellchecker( $params, &$gBitSmarty ) {
+ global $gBitSystem;
+ $rows = !empty($params['rows']) ? $params['rows'] : '20';
+
+ if( $gBitSystem->isPackageActive( 'bnspell' ) ) {
+ echo 'title="spellcheck_icons" accesskey="'.BNSPELL_PKG_URL.'spell_checker.php"';
+ }
+}
+?>
diff --git a/smartyplugins/function.var_dump.php b/smartyplugins/function.var_dump.php
new file mode 100644
index 0000000..74b3a05
--- /dev/null
+++ b/smartyplugins/function.var_dump.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/** \file
+ * $Header$
+ *
+ * \author zaufi <zaufi@sendmail.ru>
+ */
+
+
+/**
+ * \brief Smarty plugin to add variable dump to debug console log
+ * Usage format {var_dump var=var_name_2_dump}
+ */
+function smarty_function_var_dump($params, &$gBitSmarty)
+{
+ global $debugger;
+ require_once( DEBUG_PKG_PATH.'debugger.php' );
+ //
+ $v = $params['var'];
+ if (strlen($v) != 0)
+ {
+ $tmp = $gBitSmarty->get_template_vars();
+ if (is_array($tmp) && isset($tmp[$v]))
+ $debugger->msg("Smarty var_dump(".$v.') = '.print_r($tmp[$v], true));
+ else
+ $debugger->msg("Smarty var_dump(".$v."): Variable not found");
+ }
+ else
+ $debugger->msg("Smarty var_dump: Parameter 'var' not specified");
+ return '<!-- var_dump('.$v.') -->';
+}
+
+?>
diff --git a/smartyplugins/modifier.act_icon.php b/smartyplugins/modifier.act_icon.php
new file mode 100644
index 0000000..72d2d2d
--- /dev/null
+++ b/smartyplugins/modifier.act_icon.php
@@ -0,0 +1,41 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * smarty_modifier_act_icon
+ */
+function smarty_modifier_act_icon($type,$isInter='n')
+{
+ $md = $isInter == 'y' ? "_blue" : "";
+ switch($type) {
+ case 'activity':
+ $ic = "mini".$md."_rectangle.gif";
+ break;
+ case 'switch':
+ $ic = "mini".$md."_diamond.gif";
+ break;
+ case 'start':
+ $ic="mini".$md."_circle.gif";
+ break;
+ case 'end':
+ $ic='mini'.$md.'_dbl_circle.gif';
+ break;
+ case 'split':
+ $ic='mini'.$md.'_triangle.gif';
+ break;
+ case 'join':
+ $ic='mini'.$md.'_inv_triangle.gif';
+ break;
+ case 'standalone':
+ $ic='mini'.$md.'_hexagon.gif';
+ break;
+ }
+ $img="<img src='".GALAXIA_PKG_URL."icons/$ic' alt='$type' title='$type' />";
+ return $img;
+}
+
+?>
diff --git a/smartyplugins/modifier.adjust.php b/smartyplugins/modifier.adjust.php
new file mode 100644
index 0000000..b6b2078
--- /dev/null
+++ b/smartyplugins/modifier.adjust.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * Type: modifier
+ * Name: adjust
+ * Purpose: Adjust a string to a certain length if necessary,
+ * optionally splitting in the middle of a word, and
+ * appending the $etc string or padding the string
+ * using $pad as filler.
+ * -------------------------------------------------------------
+ */
+function smarty_modifier_adjust($string, $length = 80,
+ $pad = '&nbsp;',
+ $etc = '...',
+ $break_words = false)
+{
+ if ($length == 0)
+ return '';
+
+ if (strlen($string) > $length) {
+ $length -= strlen($etc);
+ $fragment = substr($string, 0, $length+1);
+ if ($break_words)
+ $fragment = substr($fragment, 0, -1);
+ else
+ $fragment = preg_replace('/\s+(\S+)?$/', '', $fragment);
+ return $fragment.$etc;
+ } elseif(strlen($string)<$length) {
+ return $string.str_repeat($pad,$length-strlen($string));
+ } else {
+ return $string;
+ }
+
+}
+
+?>
diff --git a/smartyplugins/modifier.append_url.php b/smartyplugins/modifier.append_url.php
new file mode 100644
index 0000000..dd66911
--- /dev/null
+++ b/smartyplugins/modifier.append_url.php
@@ -0,0 +1,17 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * smarty_modifier_append_url
+ */
+function smarty_modifier_append_url( $pUrl, $pKey, $pValue=NULL ) {
+ $ret = $pUrl;
+ if( isset( $pValue ) ) {
+ $ret .= (strpos( $pUrl, '?' ) ? '&' : '?').urlencode( $pKey ).'='.urlencode( $pValue );
+ }
+ return $ret;
+}
diff --git a/smartyplugins/modifier.avatarize.php b/smartyplugins/modifier.avatarize.php
new file mode 100644
index 0000000..029ed6b
--- /dev/null
+++ b/smartyplugins/modifier.avatarize.php
@@ -0,0 +1,26 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * Type: modifier
+ * Name: capitalize
+ * Purpose: capitalize words in the string
+ * -------------------------------------------------------------
+ */
+function smarty_modifier_avatarize($user)
+{
+ global $gBitSystem;
+ $avatar = $gBitSystem->get_user_avatar($user);
+ if($gBitUser->userNameExists($user)&&$gBitSystem->getConfig('users_information','public',$user)=='public') {
+ $avatar = '<a title="'.$user.'" href="'.USERS_PKG_URL.'index.php?home='.$user.'">'.$avatar.'</a>';
+ }
+ return $avatar;
+}
+
+?>
diff --git a/smartyplugins/modifier.bit_date_format.php b/smartyplugins/modifier.bit_date_format.php
new file mode 100644
index 0000000..eb853b3
--- /dev/null
+++ b/smartyplugins/modifier.bit_date_format.php
@@ -0,0 +1,55 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * required setup
+ */
+global $gBitSmarty;
+require_once $gBitSmarty->_get_plugin_filepath('shared','make_timestamp');
+
+/**
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * Type: modifier
+ * Name: bit_date_format
+ * Purpose: format datestamps via strftime, (timezone adjusted to administrator specified timezone)
+ * Input: string: input date string
+ * format: strftime format for output
+ * -------------------------------------------------------------
+ */
+function smarty_modifier_bit_date_format( $pString, $format = "%b %e, %Y", $pTraFormat = "%b %e, %Y" ) {
+ global $gBitSystem, $gBitUser, $gBitLanguage;
+
+ if( empty( $pString )) {
+ return '';
+ }
+
+ // we translate the entire date format string for total control
+ if( $gBitSystem->getConfig( "bitlanguage", "en" ) != $gBitLanguage->mLanguage ) {
+ $format = tra( $pTraFormat );
+ }
+
+ if( $gBitUser->getPreference( 'site_display_utc' ) == 'Fixed' && class_exists( 'DateTime' ) ) {
+ date_default_timezone_set( $gBitUser->getPreference( 'site_display_timezone', 'UTC' ) );
+ if ( is_numeric( $pString )) {
+ $dateTimeUser = new DateTime( '@'.$pString );
+ } else {
+ $dateTimeUser = new DateTime( $pString );
+ }
+ $disptime = strtotime($dateTimeUser->format(DATE_W3C));
+ return $gBitSystem->mServerTimestamp->strftime( $format, $disptime );
+ } else {
+ if( $gBitSystem->get_display_offset() ) {
+ $format = preg_replace( "/ ?%Z/",'', $format );
+ } else {
+ $format = preg_replace( "/%Z/", "UTC", $format );
+ }
+ $disptime = $gBitSystem->mServerTimestamp->getDisplayDateFromUTC( $pString );
+ }
+ return $gBitSystem->mServerTimestamp->strftime( $format, $disptime, TRUE );
+}
+?>
diff --git a/smartyplugins/modifier.bit_long_date.php b/smartyplugins/modifier.bit_long_date.php
new file mode 100644
index 0000000..4e6a695
--- /dev/null
+++ b/smartyplugins/modifier.bit_long_date.php
@@ -0,0 +1,21 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * required setup
+ */
+global $gBitSmarty;
+require_once $gBitSmarty->_get_plugin_filepath( 'modifier', 'bit_date_format' );
+
+/**
+ * smarty_modifier_bit_long_date
+ */
+function smarty_modifier_bit_long_date( $pString ) {
+ global $gBitSystem;
+ return smarty_modifier_bit_date_format( $pString, $gBitSystem->get_long_date_format(), '%A %d of %B, %Y' );
+}
+?>
diff --git a/smartyplugins/modifier.bit_long_datetime.php b/smartyplugins/modifier.bit_long_datetime.php
new file mode 100644
index 0000000..8c13747
--- /dev/null
+++ b/smartyplugins/modifier.bit_long_datetime.php
@@ -0,0 +1,21 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * required setup
+ */
+global $gBitSmarty;
+require_once $gBitSmarty->_get_plugin_filepath( 'modifier', 'bit_date_format' );
+
+/**
+ * smarty_modifier_bit_long_datetime
+ */
+function smarty_modifier_bit_long_datetime( $pString ) {
+ global $gBitSystem;
+ return smarty_modifier_bit_date_format( $pString, $gBitSystem->get_long_datetime_format(), '%A %d of %B, %Y (%H:%M:%S %Z)' );
+}
+?>
diff --git a/smartyplugins/modifier.bit_long_time.php b/smartyplugins/modifier.bit_long_time.php
new file mode 100644
index 0000000..60f6ded
--- /dev/null
+++ b/smartyplugins/modifier.bit_long_time.php
@@ -0,0 +1,21 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * required setup
+ */
+global $gBitSmarty;
+require_once $gBitSmarty->_get_plugin_filepath( 'modifier', 'bit_date_format' );
+
+/**
+ * smarty_modifier_bit_long_time
+ */
+function smarty_modifier_bit_long_time( $pString ) {
+ global $gBitSystem;
+ return smarty_modifier_bit_date_format( $pString, $gBitSystem->get_long_time_format(), '%H:%M:%S %Z' );
+}
+?>
diff --git a/smartyplugins/modifier.bit_short_date.php b/smartyplugins/modifier.bit_short_date.php
new file mode 100644
index 0000000..17b8aa6
--- /dev/null
+++ b/smartyplugins/modifier.bit_short_date.php
@@ -0,0 +1,21 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * required setup
+ */
+global $gBitSmarty;
+require_once $gBitSmarty->_get_plugin_filepath('modifier','bit_date_format');
+
+/**
+ * smarty_modifier_bit_short_date
+ */
+function smarty_modifier_bit_short_date( $pString ) {
+ global $gBitSystem;
+ return smarty_modifier_bit_date_format( $pString, $gBitSystem->get_short_date_format(), '%d %b %Y' );
+}
+?>
diff --git a/smartyplugins/modifier.bit_short_datetime.php b/smartyplugins/modifier.bit_short_datetime.php
new file mode 100644
index 0000000..bc5aee9
--- /dev/null
+++ b/smartyplugins/modifier.bit_short_datetime.php
@@ -0,0 +1,25 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * required setup
+ */
+global $gBitSmarty;
+require_once $gBitSmarty->_get_plugin_filepath( 'modifier', 'bit_date_format' );
+
+/**
+ * smarty_modifier_bit_short_datetime
+ */
+function smarty_modifier_bit_short_datetime( $pString, $time='' ) {
+ global $gBitSystem;
+ if( !empty( $time ) && date( 'Ymd' ) == date( 'Ymd', $pString )) {
+ return smarty_modifier_bit_date_format( $pString, $gBitSystem->get_short_time_format(), '%H:%M %Z' );
+ } else {
+ return smarty_modifier_bit_date_format( $pString, $gBitSystem->get_short_datetime_format(), '%a %d of %b, %Y (%H:%M %Z)' );
+ }
+}
+?>
diff --git a/smartyplugins/modifier.bit_short_time.php b/smartyplugins/modifier.bit_short_time.php
new file mode 100644
index 0000000..b133c1d
--- /dev/null
+++ b/smartyplugins/modifier.bit_short_time.php
@@ -0,0 +1,21 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * required setup
+ */
+global $gBitSmarty;
+require_once $gBitSmarty->_get_plugin_filepath( 'modifier', 'bit_date_format' );
+
+/**
+ * smarty_modifier_bit_short_time
+ */
+function smarty_modifier_bit_short_time( $pString ) {
+ global $gBitSystem;
+ return smarty_modifier_bit_date_format( $pString, $gBitSystem->get_short_time_format(), '%H:%M %Z' );
+}
+?>
diff --git a/smartyplugins/modifier.cal_date_format.php b/smartyplugins/modifier.cal_date_format.php
new file mode 100644
index 0000000..f764e42
--- /dev/null
+++ b/smartyplugins/modifier.cal_date_format.php
@@ -0,0 +1,42 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * required setup
+ */
+global $gBitSmarty;
+require_once $gBitSmarty->_get_plugin_filepath('shared','make_timestamp');
+
+/**
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * Type: modifier
+ * Name: cal_date_format
+ * Purpose: format datestamps via strftime, (timezone adjusted to calendar specified timezone)
+ * Input: string: input date string
+ * format: strftime format for output
+ * default_date: default date if $string is empty
+ * -------------------------------------------------------------
+ */
+function smarty_modifier_cal_date_format($string, $format = "%b %e, %Y", $default_date=null, $tra_format=null)
+{
+ $mDate = new BitDate(0);
+ if ( $mDate->get_display_offset()) $format = preg_replace("/ ?%Z/","",$format);
+ else $format = preg_replace("/%Z/","UTC",$format);
+
+ $disptime = $mDate->getTimestampFromISO($string);
+
+ global $gBitSystem, $gBitLanguage; //$gBitLanguage->mLanguage= $gBitSystem->getConfig("language", "en");
+ if ($gBitSystem->getConfig("language", "en") != $gBitLanguage->mLanguage && $tra_format) {
+ $format = $tra_format;
+ }
+ return $mDate->strftime($format, $disptime, true);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/smartyplugins/modifier.countryflag.php b/smartyplugins/modifier.countryflag.php
new file mode 100644
index 0000000..094c027
--- /dev/null
+++ b/smartyplugins/modifier.countryflag.php
@@ -0,0 +1,23 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * Type: modifier
+ * Name: countryflag
+ * Purpose: get countryflag for a given user
+ * -------------------------------------------------------------
+ */
+function smarty_modifier_countryflag($user)
+{
+ global $gBitSystem;
+ $flag = $gBitSystem->getConfig('users_country','Other',$user);
+ return "<img alt='flag' src='".IMG_PKG_URL."flags/".$flag.".gif' />";
+}
+
+?>
diff --git a/smartyplugins/modifier.dbg.php b/smartyplugins/modifier.dbg.php
new file mode 100644
index 0000000..0fd8e7c
--- /dev/null
+++ b/smartyplugins/modifier.dbg.php
@@ -0,0 +1,29 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/** \file
+ * $Header$
+ *
+ * @author zaufi <zaufi@sendmail.ru>
+ */
+
+/**
+ * \brief Smarty modifier plugin to add string to debug console log w/o modify output
+ * Usage format {$gBitSmarty_var|dbg}
+ */
+function smarty_modifier_dbg($string, $label = '')
+{
+ global $debugger, $gBitSystem;
+ if( $gBitSystem->isPackageActive( 'debug' ) ) {
+ require_once( DEBUG_PKG_PATH.'debugger.php' );
+ //
+ $debugger->msg('Smarty log'.((strlen($label) > 0) ? ': '.$label : '').': '.$string);
+ return $string;
+ }
+}
+
+?>
diff --git a/smartyplugins/modifier.displayUrl.php b/smartyplugins/modifier.displayUrl.php
new file mode 100644
index 0000000..d5c257b
--- /dev/null
+++ b/smartyplugins/modifier.displayUrl.php
@@ -0,0 +1,102 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * Type: modifier
+ * Name: displayUrl
+ * Purpose: give back the display URL
+ * If the modification is preformed on a string then the (new <lib>)->getDisplayUrl method is called, (this defaults to BitPage if not specified)
+ * If the modification is preformed on an object then, if <lib> is given, then it is passed as the parameter to (new <lib>)->getDisplayUrl otherwise, the object' getDisplayUrl method is called
+ * If the modification is preformed on an array then, if <lib> is given, then it is passed as the parameter to (new <lib>)->getDisplayUrl otherwise the following is attempted:
+ * If the array contains an element display_url it is returned
+ * If the array contains an element content_type_guid then lib becomes the handler class of the content_type_guid and the array is passed as the parameter to (new <lib>)->getDisplayUrl
+ * If the array contains an element handler_class then lib becomes the handler_class and the array is passed as the parameter to (new <lib>)->getDisplayUrl
+ * --
+ * If all of the above tests fail then LibertyContent::getDisplayUrl with the argument to the modifier passed as the second argument
+ * Example: {'My Page'|displayUrl}, {'admin'|displayUrl:BitUser}, {$gContent|displayUrl:MyObject}
+ * -------------------------------------------------------------
+ */
+
+function smarty_modifier_displayUrl_findLib(&$lib,$class_only=false) {
+ global $gLibertySystem;
+ if (!class_exists($lib)) {
+ foreach ($gLibertySystem->mContentTypes as $type) {
+ if ($type['handler_class']==$lib) {
+ smarty_modifier_displayUrl_loadLib($type);
+ return true;
+ } elseif ((!$class_only) && ($type['content_type_guid']==$lib)) {
+ $lib = $type['handler_class'];
+ smarty_modifier_displayUrl_loadLib($type);
+ return true;
+ }
+ }
+ return false;
+ }
+ return true;
+}
+
+function smarty_modifier_displayUrl_loadLib($type) {
+ $path = constant(strtoupper($type['handler_package']).'_PKG_PATH');
+ require_once($path.$type['handler_file']);
+}
+
+function smarty_modifier_displayUrl($pMixed, $lib='') {
+ global $gLibertySystem;
+ if (is_string($pMixed)) {
+ if (empty($lib)) $lib ='BitPage';
+ if (smarty_modifier_displayUrl_findLib($lib)) {
+ $call =array($lib, 'getDisplayUrl');
+ if (is_callable($call)) {
+ return call_user_func($call,$pMixed);
+ }
+ $i = $lib();
+ if (method_exists($i,'getDisplayUrl')) {
+ return $i->getDisplayUrl($pMixed);
+ }
+ }
+ } elseif (is_object($pMixed)) {
+ if (!empty($lib)) {
+ if (smarty_modifier_displayUrl_findLib($lib)) {
+ $i = $lib();
+ return $i->getDisplayUrl($pMixed);
+ }
+ }
+ if (method_exists($pMixed,'getDisplayUrl')) {
+ return $pMixed->getDisplayUrl();
+ }
+ } elseif (is_array($pMixed)) {
+ if (!empty($lib)) {
+ if (smarty_modifier_displayUrl_findLib($lib)) {
+ $i = new $lib();
+ return $i->getDisplayUrl($pMixed);
+ }
+ }
+ if (!empty($pMixed['display_url'])) {
+ return $pMixed['display_url'];
+ }
+ if (!empty($pMixed['content_type_guid'])) {
+ $type =$gLibertySystem->mContentTypes[$pContentType];
+ if (!empty($type)) {
+ $lib = $type['handler_class'];
+ smarty_modifier_displayUrl_loadLib($type);
+ $i = new $lib();
+ return $i->getDisplayUrl($pMixed);
+ }
+ }
+ if (!empty($pMixed['handler_class'])) {
+ $lib= $pMixed['handler_class'];
+ if (smarty_modifier_displayUrl_findLib($lib,true)) {
+ $i = $lib();
+ return $i->getDisplayUrl($pMixed);
+ }
+ }
+ }
+ return LibertyContent::getDisplayUrl(null,$pMixed);
+}
+?>
diff --git a/smartyplugins/modifier.display_bytes.php b/smartyplugins/modifier.display_bytes.php
new file mode 100644
index 0000000..aed6c99
--- /dev/null
+++ b/smartyplugins/modifier.display_bytes.php
@@ -0,0 +1,26 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * Type: modifier
+ * Name: display_bytes
+ * Purpose: show an integer in a human readable Byte size with optional resolution
+ * Example: {$someFile|filesize|display_bytes:2}
+ * -------------------------------------------------------------
+ */
+function smarty_modifier_display_bytes( $pSize, $pDecimalPlaces = 1 ) {
+ $i = 0;
+ $iec = array( "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" );
+ while( ( $pSize / 1024 ) > 1 ) {
+ $pSize = $pSize / 1024;
+ $i++;
+ }
+ return round( $pSize, $pDecimalPlaces )." ".$iec[$i];
+}
+?>
diff --git a/smartyplugins/modifier.display_duration.php b/smartyplugins/modifier.display_duration.php
new file mode 100644
index 0000000..7d2fe19
--- /dev/null
+++ b/smartyplugins/modifier.display_duration.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * basic function to convert a number of seconds into a human readable format
+ *
+ * @param array $pDuration Duration of event in seconds
+ * @access public
+ * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
+ */
+function smarty_modifier_display_duration( $pDuration ) {
+ $units = array(
+ 'month' => 60 * 60 * 24 * 7 * 4,
+ 'week' => 60 * 60 * 24 * 7,
+ 'day' => 60 * 60 * 24,
+ 'hour' => 60 * 60,
+ 'min' => 60,
+ 'sec' => 1,
+ );
+
+ foreach( $units as $unit => $secs ) {
+ $duration[$unit] = 0;
+ if( $pDuration > $secs ) {
+ $duration[$unit] = floor( $pDuration / $secs );
+ $pDuration = $pDuration % $secs;
+ }
+ }
+
+ $ret = !empty( $duration['month'] ) ? $duration['month'].tra( 'month(s)' ).' ' : '';
+ $ret .= !empty( $duration['week'] ) ? $duration['week'] .tra( 'week(s)' ).' ' : '';
+ $ret .= !empty( $duration['day'] ) ? $duration['day'] .tra( 'day(s)' ).' ' : '';
+ $ret .= str_pad( $duration['hour'], 2, 0, STR_PAD_LEFT ).':'.str_pad( $duration['min'], 2, 0, STR_PAD_LEFT ).':'.str_pad( $duration['sec'], 2, 0, STR_PAD_LEFT );
+ return $ret;
+}
+?>
diff --git a/smartyplugins/modifier.div.php b/smartyplugins/modifier.div.php
new file mode 100644
index 0000000..7431b1f
--- /dev/null
+++ b/smartyplugins/modifier.div.php
@@ -0,0 +1,25 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * Type: modifier
+ *
+ * -------------------------------------------------------------
+ */
+function smarty_modifier_div($string,$num,$max=10)
+{
+ if($num==0) return 0;
+ if(ceil(strlen($string)/$num)>$max) return $max;
+ return ceil(strlen($string)/$num);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/smartyplugins/modifier.duration.php b/smartyplugins/modifier.duration.php
new file mode 100644
index 0000000..51daa45
--- /dev/null
+++ b/smartyplugins/modifier.duration.php
@@ -0,0 +1,41 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * Type: modifier
+ * Name: duration
+ * Purpose: formats a duration from seconds
+ * -------------------------------------------------------------
+ */
+function smarty_modifier_duration($string)
+{
+ $result=Array();
+ if($string > 60*60*24) {
+ $days = floor($string/(60*60*24));
+ $result[]="$days days";
+ $string = $string % (60*60*24);
+ }
+ if($string > 60*60) {
+ $hours = floor($string/(60*60));
+ $result[]="$hours hours";
+ $string = $string % (60*60);
+ }
+ if($string > 60) {
+ $mins = floor($string/(60));
+ $result[]="$mins minutes";
+ $string = $string % (60);
+ }
+ if($string > 0) {
+ $result[]="$string seconds";
+ }
+
+ return implode(' ',$result);
+}
+
+?>
diff --git a/smartyplugins/modifier.htmlToText.php b/smartyplugins/modifier.htmlToText.php
new file mode 100644
index 0000000..c1c4107
--- /dev/null
+++ b/smartyplugins/modifier.htmlToText.php
@@ -0,0 +1,20 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty htmlToText modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: html2text<br>
+ * Purpose: transform a html to a text version
+ * @param string
+ */
+function smarty_modifier_htmlToText( $string ) {
+ return preg_replace('/<.*>/U', '', $string);
+}
+?>
diff --git a/smartyplugins/modifier.iconify.php b/smartyplugins/modifier.iconify.php
new file mode 100644
index 0000000..31eb528
--- /dev/null
+++ b/smartyplugins/modifier.iconify.php
@@ -0,0 +1,28 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * Type: modifier
+ * Name: capitalize
+ * Purpose: capitalize words in the string
+ * -------------------------------------------------------------
+ */
+function smarty_modifier_iconify($string)
+{
+ // XINGICON what are we going to do with this function? is this needed?
+ $string=substr($string,strlen($string)-3);
+ if(file_exists(IMG_PKG_PATH."icn/$string".".gif")) {
+ return "<img border='0' src='".IMG_PKG_URL."icn/${string}.gif' alt='icon' class='icon' />";
+ } else {
+ return "<img border='0' src='".IMG_PKG_URL."icn/else.gif' alt='icon' class='icon' />";
+ }
+
+}
+
+?>
diff --git a/smartyplugins/modifier.nlbr.php b/smartyplugins/modifier.nlbr.php
new file mode 100644
index 0000000..03f9d96
--- /dev/null
+++ b/smartyplugins/modifier.nlbr.php
@@ -0,0 +1,22 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * Type: modifier
+ * Name: capitalize
+ * Purpose: capitalize words in the string
+ * -------------------------------------------------------------
+ */
+function smarty_modifier_nlbr($string)
+{
+ return nl2br($string);
+
+}
+
+?>
diff --git a/smartyplugins/modifier.ordinal_suffix.php b/smartyplugins/modifier.ordinal_suffix.php
new file mode 100644
index 0000000..ac94175
--- /dev/null
+++ b/smartyplugins/modifier.ordinal_suffix.php
@@ -0,0 +1,72 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * Type: modifier
+ * Name: display_bytes
+ * Purpose: show an integer in a human readable Byte size with optional resolution
+ * Example: {$someFile|filesize|display_bytes:2}
+ * -------------------------------------------------------------
+ */
+function smarty_modifier_ordinal_suffix( $pNum ) {
+
+ // first convert to string if needed
+ $ret = (string) $pNum;
+ // now we grab the last digit of the number
+ $last_digit = substr($ret, -1, 1);
+ // if the string is more than 2 chars long, we get
+ // the second to last character to evaluate
+ if (strlen($ret)>1) {
+ $next_to_last = substr($ret, -2, 1);
+ } else {
+ $next_to_last = "";
+ }
+ // now iterate through possibilities in a switch
+ switch($last_digit) {
+ case "1":
+ // testing the second from last digit here
+ switch($next_to_last) {
+ case "1":
+ $suffix ="th";
+ break;
+ default:
+ $suffix ="st";
+ }
+ break;
+ case "2":
+ // testing the second from last digit here
+ switch($next_to_last) {
+ case "1":
+ $suffix ="th";
+ break;
+ default:
+ $suffix ="nd";
+ }
+ break;
+ // if last digit is a 3
+ case "3":
+ // testing the second from last digit here
+ switch($next_to_last) {
+ case "1":
+ $suffix ="th";
+ break;
+ default:
+ $suffix ="rd";
+ }
+ break;
+ // for all the other numbers we use "th"
+ default:
+ $suffix ="th";
+ }
+
+ // finally, return our string with it's new suffix
+ return $pNum.tra( $suffix );
+
+}
+?>
diff --git a/smartyplugins/modifier.quoted.php b/smartyplugins/modifier.quoted.php
new file mode 100644
index 0000000..f529375
--- /dev/null
+++ b/smartyplugins/modifier.quoted.php
@@ -0,0 +1,24 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * Type: modifier
+ * Name: spacify
+ * Purpose: add spaces between characters in a string
+ * -------------------------------------------------------------
+ */
+function smarty_modifier_quoted($string)
+{
+ $string = str_replace("\n","\n>",$string);
+ return '>'.$string;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/smartyplugins/modifier.reltime.php b/smartyplugins/modifier.reltime.php
new file mode 100644
index 0000000..cce7afd
--- /dev/null
+++ b/smartyplugins/modifier.reltime.php
@@ -0,0 +1,96 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * smarty_modifier_reltime
+ */
+function smarty_modifier_reltime( $pTimeStamp, $pMode = 'long', $pFallback = 'bit_short_datetime' ) {
+ global $gBitSystem, $gBitSmarty;
+
+ // if this feature is not desired, we simply don't use it.
+ if( !$gBitSystem->isFeatureActive( 'site_display_reltime' ) ) {
+ require_once $gBitSmarty->_get_plugin_filepath( 'modifier', $pFallback );
+ $pFallback = "smarty_modifier_$pFallback";
+ return $pFallback( $pTimeStamp );
+ }
+
+ $min = 60;
+ $hour = $min * 60;
+ $day = $hour * 24;
+ $week = $day * 7;
+
+ $strf = "H:i";
+
+ if( !is_numeric( $pTimeStamp ) ) {
+ return $pTimeStamp;
+ }
+
+ $delta = $gBitSystem->mServerTimestamp->getUTCTime() - $pTimeStamp;
+
+ if( $delta < 0 ) {
+ $delta = -$delta;
+ return tra( "In the future" ).": ";
+ }
+
+ if( $delta < 1 ) {
+ // seconds
+ return tra( "within the last second" );
+ } elseif( $delta < $min ) {
+ // minutes
+ return tra( "within the last minute" );
+ } elseif( $delta < $hour ) {
+ // hours
+ if( $delta < $min * 2 ) {
+ return tra( "one minute ago" );
+ } else {
+ return round( $delta / $min )." ".tra( "minutes ago" );
+ }
+ } elseif( $delta < $day ) {
+ // up to a day
+ if( $delta < $hour * 1.1 ) {
+ return tra( "one hour ago" );
+ } elseif( $delta < $day ) {
+ $delta_hours = floor( ( $delta - ( floor( $delta / $hour ) * $hour ) ) / $min );
+ if( $pMode == 'short' ) {
+ return floor( $delta / $hour )."h {$delta_hours}m ago";
+ }
+ if( floor( $delta / $hour ) > 1 ){
+ if( $delta_hours > 1 ){
+ return floor( $delta / $hour )." hours {$delta_hours} minutes ago";
+ } else {
+ return floor( $delta / $hour )." hours {$delta_hours} minute ago";
+ }
+ } else {
+ if( $delta_hours > 1 ){
+ return floor( $delta / $hour )." hour {$delta_hours} minutes ago";
+ } else {
+ return floor( $delta / $hour )." hour {$delta_hours} minute ago";
+ }
+ }
+
+ } else {
+
+ return round( $delta / $hour )." ".tra( "hour(s) ago" );
+ }
+ } elseif( $delta < $week ) {
+ // up to a week
+ if( $delta < $day * 2 ) {
+ return tra( "Yesterday" )." ".date( $strf, $pTimeStamp );
+ } else {
+ if( $pMode == 'short' ) {
+ return date( 'D '.$strf, $pTimeStamp );
+ }
+ return tra( date( 'l', $pTimeStamp ) )." ".date( $strf, $pTimeStamp );
+ }
+ } else {
+ // anything longer than a week
+ require_once $gBitSmarty->_get_plugin_filepath( 'modifier', $pFallback );
+ $pFallback = "smarty_modifier_$pFallback";
+ return $pFallback( $pTimeStamp );
+ }
+}
+?>
diff --git a/smartyplugins/modifier.times.php b/smartyplugins/modifier.times.php
new file mode 100644
index 0000000..385d134
--- /dev/null
+++ b/smartyplugins/modifier.times.php
@@ -0,0 +1,18 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * smarty_modifier_times
+ */
+function smarty_modifier_times($n1,$n2)
+{
+ return $n1*$n2;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/smartyplugins/modifier.truncate.php b/smartyplugins/modifier.truncate.php
new file mode 100644
index 0000000..0ef73c6
--- /dev/null
+++ b/smartyplugins/modifier.truncate.php
@@ -0,0 +1,49 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty truncate modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: truncate<br>
+ * Purpose: Truncate a string to a certain length if necessary,
+ * optionally splitting in the middle of a word, and
+ * appending the $etc string.
+ * @link http://smarty.php.net/manual/en/language.modifier.truncate.php
+ * truncate (Smarty online manual)
+ * @param string
+ * @param integer
+ * @param string
+ * @param boolean
+ * @param string
+ * @return string
+ */
+function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $divId='') {
+ if ($length == 0)
+ return '';
+
+ if (strlen($string) > $length) {
+ $length -= strlen($etc);
+ if ($break_words) // break the word
+ $fragment = mb_substr($string, 0, $length);
+ else {
+ $fragment = mb_substr($string, 0, $length + 1);
+ $fragment = preg_replace('/\s+(\S+)?$/', '', $fragment);
+ }
+ if (!empty($divId)) {
+ $etc = "<span style='display:inline;' id='dyn_".$divId."_display'><a class='truncate' onclick='javascript:toggle_dynamic_var(\"$divId\");' title='".tra('Click to see the full text')."'>$etc</a></span>";
+ $etc .= "<span style='display:none;' id='dyn_".$divId."_edit'>".substr($string, strlen($fragment))."</span>";
+ }
+ return $fragment.$etc;
+ } else
+ return $string;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/smartyplugins/modifier.userlink.php b/smartyplugins/modifier.userlink.php
new file mode 100644
index 0000000..b7d2f36
--- /dev/null
+++ b/smartyplugins/modifier.userlink.php
@@ -0,0 +1,17 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * smarty_modifier_userlink
+ */
+function smarty_modifier_userlink($user,$class='username') {
+ return '<a class="'.$class.'" href="'.USERS_PKG_URL.'index.php?home='.$user.'">'.$user.'</a>';
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/smartyplugins/outputfilter.groupslayout.php b/smartyplugins/outputfilter.groupslayout.php
new file mode 100644
index 0000000..e813cf6
--- /dev/null
+++ b/smartyplugins/outputfilter.groupslayout.php
@@ -0,0 +1,102 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Handler
+ */
+function group_replace_url_hander($matched) {
+ $url = $matched[2];
+ // Make sure it is not an off site url
+ if( substr($url, 0, strlen(BIT_ROOT_URL)) == BIT_ROOT_URL ||
+ substr($url, 0, strlen(BIT_ROOT_URI)) == BIT_ROOT_URI ) {
+ // Make sure it is decoded
+ $url = urldecode($url);
+ // Figure out which way to express it
+ if( strstr($url, '?') ) {
+ $url = $url.'&group_layout_id='.$_REQUEST['group_layout_id'];
+ }
+ else {
+ $url = $url.'?group_layout_id='.$_REQUEST['group_layout_id'];
+ }
+ // Return it in the right way.
+ return $matched[1].$url.$matched[3];
+ }
+
+ return $matched[0];
+}
+
+/**
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * File: outputfilter.groupslayout.php
+ * Type: outputfilter
+ * Name: groupslayout
+ * Version: 1.0
+ * Date: April 14, 2008
+ * Purpose:
+ * Install: Drop into the plugin directory, call
+ * $gBitSmarty->load_filter('output','groupslayout');
+ * from application.
+ * Author: Nick Palmer <nick@slugardy.net> based on highlight filter by
+ * Greg Hinkle <ghinkl@users.sourceforge.net>
+ * and mose <mose@feu.org>
+ * -------------------------------------------------------------
+ */
+function smarty_outputfilter_groupslayout( $source, &$gBitSmarty ) {
+ if( empty($_REQUEST['group_layout_id']) || !is_numeric($_REQUEST['group_layout_id']) ) {
+ return $source;
+ }
+
+ // get all text that needs to be
+ $extractor = "|<div\s+id=.?content[^>]*>.*?<!--\s*end\s*#content\s*-->|is";
+ preg_match_all( $extractor, $source, $match );
+ $contents = $match[0];
+
+ $ret = array();
+ foreach( $contents as $key => $content ) {
+ // if we picked something up, we rip it out and modify
+ if( !empty( $content ) ) {
+ $source = preg_replace( $extractor, "@@@SMARTY:TRIM:CONTENT@@@", $source );
+
+ // Protect some parts
+ $patterns = array(
+ "!<script[^>]+>.*?</script>!is" => "@@@SMARTY:TRIM:SCRIPT@@@"
+ );
+
+ // ksort( $patterns );
+
+ foreach( $patterns as $pattern => $replace ) {
+ preg_match_all( $pattern, $content, $match );
+ $matches[$replace] = $match[0];
+ $content = preg_replace( $pattern, $replace, $content );
+ }
+
+ // Now we can finally fix up the anchor tags
+ $pattern = '#(<a\s+.*?href=[\"\'])(.+?)([\"\']\s*[^>]*>)#';
+ $content = preg_replace_callback($pattern, group_replace_url_hander, $content);
+
+ // Put the protected parts back in.
+ foreach( $patterns as $pattern ) {
+ foreach( $matches[$pattern] as $insert ) {
+ $content = preg_replace( "!{$pattern}!", $insert, $content, 1 );
+ }
+ }
+
+ $ret[] = $content;
+ }
+ }
+
+ // insert the code back into the source
+ foreach( $ret as $content ) {
+ // Escape dollars in content so they don't back reference
+ $content = preg_replace('!\$!','\\\$', $content);
+ $source = preg_replace( "!@@@SMARTY:TRIM:CONTENT@@@!", $content, $source, 1 );
+ }
+
+ return $source;
+}
+?>
diff --git a/smartyplugins/outputfilter.highlight.php b/smartyplugins/outputfilter.highlight.php
new file mode 100644
index 0000000..7842d1f
--- /dev/null
+++ b/smartyplugins/outputfilter.highlight.php
@@ -0,0 +1,121 @@
+<?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->load_filter('output','highlight');
+ * from application.
+ * Author: Greg Hinkle <ghinkl@users.sourceforge.net>
+ * patched by mose <mose@feu.org>
+ * -------------------------------------------------------------
+ */
+function smarty_outputfilter_highlight( $source, &$gBitSmarty ) {
+ // This array is used to choose colours for supplied highlight terms
+ $colorArr = array( '#ffffcc', '#ffcccc', '#a0ffff', '#ffccff', '#ccffcc' );
+
+ // don't highlight characters that are used as replacements
+ $find = array(
+ "!(\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 = array();
+ 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 = array(
+ // 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 = array();
+ $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( ' ', $words ) );
+ }
+
+ //$wordArr = split( " ", urldecode( $words ) );
+ //vd($wordArr);
+ $i = 0;
+ $wordList = 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;
+}
+?>
diff --git a/smartyplugins/prefilter.tr.php b/smartyplugins/prefilter.tr.php
new file mode 100644
index 0000000..5311626
--- /dev/null
+++ b/smartyplugins/prefilter.tr.php
@@ -0,0 +1,86 @@
+<?php
+/**
+ * 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;
+ } else {
+ // perhaps there are parameters set for block.tr.php
+ return $pKey[1].$pKey[2]."{/tr}";
+ }
+}
+?>
diff --git a/smartyplugins/resource.bitpackage.php b/smartyplugins/resource.bitpackage.php
new file mode 100644
index 0000000..5b6e6c5
--- /dev/null
+++ b/smartyplugins/resource.bitpackage.php
@@ -0,0 +1,88 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * File: resource.bitpackage.php
+ * Type: resource
+ * Name: bitpackage
+ * Purpose: Fetches templates from the correct package
+ * -------------------------------------------------------------
+ */
+function smarty_resource_bitpackage_source( $pTplName, &$pTplSource, &$gBitSmarty ) {
+ $resources = smarty_get_bitweaver_resources( $pTplName );
+ foreach( $resources as $resource ) {
+ if( file_exists( $resource )) {
+ $pTplSource = file_get_contents( $resource );
+ return TRUE;
+ }
+ }
+
+ vd( "Missing template:" );
+ vd( $resources );
+ return FALSE;
+}
+
+// the PHP sibling file needs to be included in modules_inc before this fetch so caching works properly
+function smarty_resource_bitpackage_timestamp( $pTplName, &$pTplTimestamp, &$gBitSmarty ) {
+ foreach( smarty_get_bitweaver_resources( $pTplName ) as $resource ) {
+ if( file_exists( $resource )) {
+ $pTplTimestamp = filemtime( $resource );
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+function smarty_resource_bitpackage_secure( $pTplName, &$gBitSmarty ) {
+ // assume all templates are secure
+ return TRUE;
+}
+
+function smarty_resource_bitpackage_trusted( $pTplName, &$gBitSmarty ) {
+ // not used for templates
+}
+
+function smarty_get_bitweaver_resources( $pTplName ) {
+ global $gBitThemes, $gNoForceStyle;
+
+ $path = explode( '/', $pTplName );
+ $package = array_shift( $path );
+ $template = array_pop( $path );
+ $subdir = '';
+ foreach( $path as $p ) {
+ $subdir .= $p.'/';
+ }
+
+ // files found in temp are special - these are stored in temp/<pkg>/(templates|modules)/<template.tpl>
+ if( $package == 'temp' ) {
+ // if it's a module, we need to look in the correct place
+ $subdir .= ( preg_match( '/\b(help_)?mod_/', $template ) ? 'modules' : 'templates' );
+ // we can't override these templates - they only exist in temp
+ $ret['package_template'] = constant( strtoupper( $package ).'_PKG_PATH' )."$subdir/$template";
+ } else {
+ if( empty( $gNoForceStyle )) {
+ // look in themes/force/
+ $ret['force'] = THEMES_PKG_PATH."force/$package/$subdir$template";
+ $ret['force_simple'] = THEMES_PKG_PATH."force/$subdir$template";
+ }
+
+ // look in themes/style/<stylename>/
+ $ret['override'] = $gBitThemes->getStylePath()."$package/$subdir$template";
+ $ret['override_simple'] = $gBitThemes->getStylePath().$subdir.$template;
+
+ // if it's a module, we need to look in the correct place
+ $subdir = ( preg_match( '/\b(help_)?mod_/', $template ) ? 'modules' : 'templates' )."/".$subdir;
+
+ // look for default package template
+ $ret['package_template'] = constant( strtoupper( $package ).'_PKG_PATH' )."$subdir$template";
+ }
+
+ return $ret;
+}
+?>
diff --git a/smartyplugins/resource.style.php b/smartyplugins/resource.style.php
new file mode 100644
index 0000000..fbfa3c6
--- /dev/null
+++ b/smartyplugins/resource.style.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty plugin - smarty_resource_style_source
+ * -------------------------------------------------------------
+ *
+ * -------------------------------------------------------------
+ */
+function smarty_resource_style_source($tpl_name, &$tpl_source, &$gBitSmarty)
+{
+ // Check if file exists in the style directory if not
+ // check if file exists in the templates directory,
+ // if not then fall
+}
+
+/**
+ * Smarty plugin - smarty_resource_style_timestamp
+ * -------------------------------------------------------------
+ *
+ * -------------------------------------------------------------
+ */
+function smarty_resource_style_timestamp($tpl_name, &$tpl_timestamp, &$gBitSmarty)
+{
+ // do database call here to populate $tpl_timestamp.
+ $sql = new SQL;
+ $sql->query("select tpl_timestamp
+ from my_table
+ where tpl_name='$tpl_name'");
+ if ($sql->num_rows) {
+ $tpl_timestamp = $sql->record['tpl_timestamp'];
+ return true;
+ } else {
+ return false;
+ }
+}
+
+/**
+ * Smarty plugin - smarty_resource_style_secure
+ * -------------------------------------------------------------
+ *
+ * -------------------------------------------------------------
+ */
+function smarty_resource_style_secure($tpl_name, &$gBitSmarty)
+{
+ // assume all templates are secure
+ return true;
+}
+
+/**
+ * Smarty plugin - smarty_resource_style_trusted
+ * -------------------------------------------------------------
+ *
+ * -------------------------------------------------------------
+ */
+function smarty_resource_style_trusted($tpl_name, &$gBitSmarty)
+{
+ // not used for templates
+}
+?>