diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-05-14 09:55:19 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-05-14 09:55:19 +0100 |
| commit | 1721544d5a71c0f3b4bc3b498893a65f4d9f1c84 (patch) | |
| tree | 6a44ae4720a0190927a836911ce28aa67604a0e5 /smartyplugins | |
| parent | 8225200c6470d1abe939ca007b5915c82c601016 (diff) | |
| download | themes-1721544d5a71c0f3b4bc3b498893a65f4d9f1c84.tar.gz themes-1721544d5a71c0f3b4bc3b498893a65f4d9f1c84.tar.bz2 themes-1721544d5a71c0f3b4bc3b498893a65f4d9f1c84.zip | |
php-cs-fixer tidies to php8.5 standards
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'smartyplugins')
80 files changed, 726 insertions, 728 deletions
diff --git a/smartyplugins/AddLinkTicket.php b/smartyplugins/AddLinkTicket.php index 8a9a4d2..7f9ef6a 100755 --- a/smartyplugins/AddLinkTicket.php +++ b/smartyplugins/AddLinkTicket.php @@ -7,13 +7,14 @@ */ namespace Bitweaver\Plugins; + use Smarty\Compile\Modifier\ModifierCompilerInterface; use Smarty\Compiler\Template; - + class AddLinkTicket implements ModifierCompilerInterface { - public function __construct() { - // Initialization code - } + public function __construct() { + // Initialization code + } public function compile($params, Template $template) { global $gBitUser; diff --git a/smartyplugins/BlockBitModule.php b/smartyplugins/BlockBitModule.php index 0771ee3..b510de1 100755 --- a/smartyplugins/BlockBitModule.php +++ b/smartyplugins/BlockBitModule.php @@ -28,9 +28,9 @@ I fixed that error case. -- mose */ namespace Bitweaver\Plugins; + use Smarty\BlockHandler\BlockHandlerInterface; use Smarty\Template; -use Smarty\Exception; class BlockBitModule implements BlockHandlerInterface { @@ -43,9 +43,8 @@ class BlockBitModule implements BlockHandlerInterface { $gBitSmarty->assign( 'moduleTag', $moduleTag ); if( empty( $content )) { return ''; - } else { - $params['data'] = $content; } + $params['data'] = $content; if( !empty( $params['name'] ) ) { $params['name'] = preg_replace( "/[^a-zA-Z0-9\\-\\_]/", "", $params['name'] ); @@ -54,7 +53,7 @@ class BlockBitModule implements BlockHandlerInterface { $temp = $gBitSmarty->fetch('bitpackage:themes/module.tpl'); return $temp; - + } public function isCacheable(): bool { diff --git a/smartyplugins/BlockBox.php b/smartyplugins/BlockBox.php index e826237..0fb6393 100755 --- a/smartyplugins/BlockBox.php +++ b/smartyplugins/BlockBox.php @@ -1,5 +1,6 @@ <?php namespace Bitweaver\Plugins; + use Bitweaver\KernelTools; use Smarty\BlockHandler\BlockHandlerInterface; use Smarty\Template; diff --git a/smartyplugins/BlockForm.php b/smartyplugins/BlockForm.php index e79f4d7..ade37e7 100755 --- a/smartyplugins/BlockForm.php +++ b/smartyplugins/BlockForm.php @@ -1,9 +1,10 @@ <?php namespace Bitweaver\Plugins; + use Bitweaver\KernelTools; use Smarty\BlockHandler\BlockHandlerInterface; use Smarty\Template; - + /** * Smarty plugin * @package Smarty @@ -25,10 +26,8 @@ use Smarty\Template; * @todo somehow make the variable that is contained within $iselect global --> this will allow importing of outside variables not set in $_REQUEST */ - class BlockForm implements BlockHandlerInterface { - - + public function handle( $pParams, $pContent, Template $template, &$repeat): string { global $gBitSystem, $gSniffer; @@ -106,12 +105,12 @@ class BlockForm implements BlockHandlerInterface { $ret .= isset( $legend ) ? '</fieldset>' : ''; // close the open tags $ret .= '</form>'; return $ret; - } else { + } global $gSmartyFormHorizontal; // global var other plugin functions will pick up to add proper col-XX-YY styling for horizontal forms $gSmartyFormHorizontal = !empty( $pParams['class'] ) && strpos( $pParams['class'], 'form-horizontal' ) !== false; return ''; - } + } return ''; } diff --git a/smartyplugins/BlockFormInput.php b/smartyplugins/BlockFormInput.php index a7889a3..f46cf21 100755 --- a/smartyplugins/BlockFormInput.php +++ b/smartyplugins/BlockFormInput.php @@ -1,5 +1,6 @@ <?php namespace Bitweaver\Plugins; + use Smarty\BlockHandler\BlockHandlerInterface; use Smarty\Template; @@ -56,9 +57,9 @@ class BlockFormInput implements BlockHandlerInterface { if( $content ) { return '<div class="'.$class.'" '.$attr.' >'.$labelStart.$content.$labelEnd.'</div>'; - } else { - return ''; } + return ''; + } public function isCacheable(): bool { diff --git a/smartyplugins/BlockJstab.php b/smartyplugins/BlockJstab.php index db28a54..758dfd3 100755 --- a/smartyplugins/BlockJstab.php +++ b/smartyplugins/BlockJstab.php @@ -1,5 +1,6 @@ <?php namespace Bitweaver\Plugins; + use Bitweaver\BitBase; use Smarty\BlockHandler\BlockHandlerInterface; use Smarty\Template; @@ -25,13 +26,13 @@ use Bitweaver\KernelTools; public function handle( $params, $content, Template $template, &$repeat): string { if( empty( $repeat ) ){ global $jsTabLinks; - + $tClass = isset( $params['class'] ) ? ' class="'.$params['class'].'"' : ''; $tStyle = isset( $params['style'] ) ? ' style="'.$params['style'].'"' : ''; $tClick = isset( $params['onclick'] ) ? ' onclick="'.$params['onclick'].'"' : ''; - $tTitle = KernelTools::tra( isset( $params['title'] ) ? $params['title'] : 'No Title' ); + $tTitle = KernelTools::tra( $params['title'] ?? 'No Title' ); - $tabId = strtolower( isset( $params['id'] ) ? $params['id'] : 'tab'.preg_replace("/[^A-Za-z0-9]/", '', $tTitle) ); + $tabId = strtolower( $params['id'] ?? 'tab'.preg_replace("/[^A-Za-z0-9]/", '', $tTitle) ); $tabString = '<li '.$tClick.' '.$tClass.' '.$tStyle.'><a href="#'.$tabId.'">' . $tTitle . '</a></li>'; if( isset( $params['position'] ) ) { @@ -42,7 +43,7 @@ use Bitweaver\KernelTools; $tabType = BitBase::getParameter( $params, 'tabtype', 'tab' ); - $ret = '<div class="'.$tabType.'-pane" id="'.$tabId.'">'; + $ret = '<div class="'.$tabType.'-pane" id="'.$tabId.'">'; $ret .= $content; $ret .= '</div>'; diff --git a/smartyplugins/BlockJstabs.php b/smartyplugins/BlockJstabs.php index e9234aa..f630f32 100755 --- a/smartyplugins/BlockJstabs.php +++ b/smartyplugins/BlockJstabs.php @@ -1,5 +1,6 @@ <?php namespace Bitweaver\Plugins; + use Bitweaver\BitBase; use Smarty\BlockHandler\BlockHandlerInterface; use Smarty\Template; diff --git a/smartyplugins/BlockLegend.php b/smartyplugins/BlockLegend.php index d310b5e..f185fc4 100755 --- a/smartyplugins/BlockLegend.php +++ b/smartyplugins/BlockLegend.php @@ -1,5 +1,6 @@ <?php namespace Bitweaver\Plugins; + use Smarty\BlockHandler\BlockHandlerInterface; use Smarty\Template; use Bitweaver\KernelTools; @@ -21,20 +22,20 @@ use Bitweaver\KernelTools; class BlockLegend implements BlockHandlerInterface { public function handle( $params, $content, Template $template, &$repeat): string { - if( $content ) { - $attributes = ''; - $attributes .= !empty( $params['class'] ) ? ' class="'.$params['class'].'" ' : '' ; - $attributes .= !empty( $params['id'] ) ? ' id="'.$params['id'].'" ' : '' ; - $ret = '<fieldset '.$attributes.'>'; - if( !empty( $params['legend'] ) ) { - $ret .= '<legend>'.KernelTools::tra( $params['legend'] ).'</legend>'; - } - $ret .= $content; - $ret .= '</fieldset>'; - return $ret; - } - return ''; - } + if( $content ) { + $attributes = ''; + $attributes .= !empty( $params['class'] ) ? ' class="'.$params['class'].'" ' : '' ; + $attributes .= !empty( $params['id'] ) ? ' id="'.$params['id'].'" ' : '' ; + $ret = '<fieldset '.$attributes.'>'; + if( !empty( $params['legend'] ) ) { + $ret .= '<legend>'.KernelTools::tra( $params['legend'] ).'</legend>'; + } + $ret .= $content; + $ret .= '</fieldset>'; + return $ret; + } + return ''; + } public function isCacheable(): bool { return true; diff --git a/smartyplugins/BlockNavbar.php b/smartyplugins/BlockNavbar.php index 5fe2e4b..a10075b 100755 --- a/smartyplugins/BlockNavbar.php +++ b/smartyplugins/BlockNavbar.php @@ -1,5 +1,6 @@ <?php namespace Bitweaver\Plugins; + use Smarty\BlockHandler\BlockHandlerInterface; use Smarty\Template; @@ -20,7 +21,7 @@ class BlockNavbar implements BlockHandlerInterface { public function handle( $params, $content, Template $template, &$repeat): string { global $gBitSmarty; - + $links = $this->smarty_block_navbar_get_links( $content ); $gBitSmarty->assign( 'links',$links ); return $gBitSmarty->fetch( 'bitpackage:kernel/navbar.tpl' ); diff --git a/smartyplugins/BlockRepeat.php b/smartyplugins/BlockRepeat.php index d318c21..293f2fa 100755 --- a/smartyplugins/BlockRepeat.php +++ b/smartyplugins/BlockRepeat.php @@ -1,5 +1,6 @@ <?php namespace Bitweaver\Plugins; + use Smarty\BlockHandler\BlockHandlerInterface; use Smarty\Template; use Smarty\Exception; @@ -27,10 +28,10 @@ class BlockRepeat implements BlockHandlerInterface { public function handle( $params, $content, Template $template, &$repeat): string { global $gBitSmarty; if( !empty( $content ) ) { - $intCount = intval( $params['count'] ); + $intCount = (int) ( $params['count'] ); if( $intCount < 0 ) { throw new Exception( - "block: negative 'count' parameter" ); + "block: negative 'count' parameter", ); } $strRepeat = str_repeat( $content, $intCount ); diff --git a/smartyplugins/BlockSortLinks.php b/smartyplugins/BlockSortLinks.php index 9535212..fdcc596 100755 --- a/smartyplugins/BlockSortLinks.php +++ b/smartyplugins/BlockSortLinks.php @@ -1,5 +1,6 @@ <?php namespace Bitweaver\Plugins; + use Smarty\BlockHandler\BlockHandlerInterface; use Smarty\Template; @@ -16,32 +17,32 @@ use Smarty\Template; * Type: block * Name: sortlinks * ------------------------------------------------------------- - */ + */ class BlockSortLinks implements BlockHandlerInterface { - public function handle( $params, $content, Template $template, &$repeat): string { - if ($content) { - $links = mb_split("\n",mb_strtolower($content) ); - $links2 = []; - foreach ($links as $value) { - $splitted=preg_split("/[<>]/",$value,-1,PREG_SPLIT_NO_EMPTY); - $links2[$splitted[2]]=$value; - } + public function handle( $params, $content, Template $template, &$repeat): string { + if ($content) { + $links = mb_split("\n",mb_strtolower($content) ); + $links2 = []; + 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); - } + if( isset( $params['order'] ) && $params['order']=='reverse' ) { + krsort( $links2 ); + } else { + ksort($links2); + } - foreach($links2 as $value) { - echo $value; - } - } - return ''; - } + foreach($links2 as $value) { + echo $value; + } + } + return ''; + } - public function isCacheable(): bool { - return true; - } + public function isCacheable(): bool { + return true; + } } diff --git a/smartyplugins/BlockTr.php b/smartyplugins/BlockTr.php index c8ced70..11ca809 100755 --- a/smartyplugins/BlockTr.php +++ b/smartyplugins/BlockTr.php @@ -1,5 +1,6 @@ <?php namespace Bitweaver\Plugins; + use Bitweaver\KernelTools; use Smarty\BlockHandler\BlockHandlerInterface; use Smarty\Template; diff --git a/smartyplugins/PreTr.php b/smartyplugins/PreTr.php index 1ed16e5..8d10f54 100755 --- a/smartyplugins/PreTr.php +++ b/smartyplugins/PreTr.php @@ -14,6 +14,7 @@ */ namespace Bitweaver\Plugins; + use Smarty\Compile\Modifier\ModifierCompilerInterface; use Smarty\Compiler\Template; @@ -29,7 +30,7 @@ class PreTr implements ModifierCompilerInterface { // // correction: in order to match when a variable is inside tags. // Example: The newsletter was sent to {$sent} email addresses, - // and where there are parameters with take away the smarty comments + // and where there are parameters with take away the smarty comments // {* *} in case they have tr tags $ret = preg_replace_callback( '#(?s)(\{tr[^\}]*\})(.+?)\{/tr\}#', [ $this, 'translate_lang' ], preg_replace ( '#(?s)\{\*.*?\*\}#', '', $source ) ); return $ret; @@ -65,22 +66,21 @@ class PreTr implements ModifierCompilerInterface { // Explanation why this doesn't work: // - case 1 // returning stuff like waiting for {$number} ratings - // will get translated by block.tr.php but only after the {$number} has + // 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 blocks + // this should be fine since it has been translated and the 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 + // 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 is a variable, we pass it on to block.tr.php // e.g. {$menu.menu_title} in top_bar.tpl // if you change this regexp, please modify the one in languages/BitLanguage.php as well (approx line 256) @@ -90,9 +90,9 @@ class PreTr implements ModifierCompilerInterface { // 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].""; - } + } }
\ No newline at end of file diff --git a/smartyplugins/ResourceBitpackage.php b/smartyplugins/ResourceBitpackage.php index 1ac2337..d0dfe36 100755 --- a/smartyplugins/ResourceBitpackage.php +++ b/smartyplugins/ResourceBitpackage.php @@ -11,8 +11,8 @@ * @subpackage plugins */ - namespace Bitweaver\Plugins; + use Smarty\Resource\CustomPlugin; use Smarty\Template\Source; use Smarty\Template; @@ -37,7 +37,7 @@ class ResourceBitpackage extends CustomPlugin { * @param string $pFile file to be included, should be of the form "bitpackage:<packagename>/<templatename>" * @return void */ - public function populate(Source $source, ?Template $_template = null) { + public function populate(Source $source, ?Template $_template = null) { global $gBitThemes; $ret = FALSE; @@ -81,8 +81,7 @@ class ResourceBitpackage extends CustomPlugin { return $ret; } - - protected function fetchTimestamp( $pTplName ) { + protected function fetchTimestamp( $pTplName ) { $ret = FALSE; $locations = $this->getTplLocations( $pTplName ); foreach( $locations as $resource ) { diff --git a/smartyplugins/compiler.set.php b/smartyplugins/compiler.set.php index 617a616..b49903b 100755 --- a/smartyplugins/compiler.set.php +++ b/smartyplugins/compiler.set.php @@ -25,14 +25,14 @@ namespace Bitweaver\Plugins; * @param Smarty_Compiler object * @return void|string */ - + /** * Set Compiler Function * * @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 - */ + */ function smarty_compiler_set($params, &$smarty) { // Extract if "value" parameter contain an array $regularExpression = '/ value=array\([\'"]?.*[\'"]?\)/'; @@ -42,7 +42,7 @@ function smarty_compiler_set($params, &$smarty) { } $params = $smarty->_parse_attrs($params); - $functionsPermitted = array('empty', '!empty', 'is_null', '!is_null', 'isset', '!isset', 'is_void'); // Functions permitted in "if" parameter. + $functionsPermitted = ['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); @@ -59,14 +59,14 @@ function smarty_compiler_set($params, &$smarty) { 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 + } // others commands return "if ({$params['if']}({$params['var']})) {$params['var']} = {$params['value']};"; - } - } else { // "if" parameter not correct + + } // "if" parameter not correct $smarty->_syntax_error("set: 'if' parameter not valid", E_USER_WARNING); return; - } - } else { // normal setting + + } // normal setting return "{$params['var']} = {$params['value']};"; - } + } diff --git a/smartyplugins/function.alphabar.php b/smartyplugins/function.alphabar.php index cdf4daa..1022b3c 100755 --- a/smartyplugins/function.alphabar.php +++ b/smartyplugins/function.alphabar.php @@ -45,9 +45,9 @@ function smarty_function_alphabar( $params, &$gBitSmarty ) { $alpha = [ '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' => '' ); + $wrap = [ 'open' => '', 'close' => '' ]; if( !empty( $_REQUEST['char'] ) && $_REQUEST['char'] == strtolower( $char )) { - $wrap = array( 'open' => '<strong>', 'close' => '</strong>' ); + $wrap = [ 'open' => '<strong>', 'close' => '</strong>' ]; } $ret .= $wrap['open'].'<a href="'.$url.'?char='.urlencode( strtolower( $char )).$url_params.'">'.$char.'</a>'.$wrap['close'].' '; } diff --git a/smartyplugins/function.attachhelp.php b/smartyplugins/function.attachhelp.php index c42b989..825576f 100755 --- a/smartyplugins/function.attachhelp.php +++ b/smartyplugins/function.attachhelp.php @@ -1,5 +1,6 @@ <?php namespace Bitweaver\Plugins; + use Bitweaver\KernelTools; /** @@ -7,7 +8,7 @@ use Bitweaver\KernelTools; * @package Smarty * @subpackage plugins */ - + /** * smarty_function_attachmenthelp */ diff --git a/smartyplugins/function.banner.php b/smartyplugins/function.banner.php index efe196c..0777963 100755 --- a/smartyplugins/function.banner.php +++ b/smartyplugins/function.banner.php @@ -12,20 +12,20 @@ namespace Bitweaver\Plugins; */ function smarty_function_banner($params, &$gBitSmarty) { - global $gBitSystem; - include_once BANNERS_PKG_PATH.'banner_lib.php'; - if(!isset($bannerlib)) { - $bannerlib = new \Bitweaver\BannerLib(); - } + global $gBitSystem; + include_once BANNERS_PKG_PATH.'banner_lib.php'; + if(!isset($bannerlib)) { + $bannerlib = new \Bitweaver\BannerLib(); + } - extract($params); - // Param = zone + extract($params); + // Param = zone - if (empty($zone)) { - $gBitSmarty->trigger_error("assign: missing 'zone' parameter"); - return; - } - $banner = $bannerlib->select_banner($zone); - print $banner; + if (empty($zone)) { + $gBitSmarty->trigger_error("assign: missing 'zone' parameter"); + return; + } + $banner = $bannerlib->select_banner($zone); + print $banner; } diff --git a/smartyplugins/function.bit_html_options.php b/smartyplugins/function.bit_html_options.php index d53ad82..daa6872 100755 --- a/smartyplugins/function.bit_html_options.php +++ b/smartyplugins/function.bit_html_options.php @@ -27,190 +27,188 @@ namespace Bitweaver\Plugins; * @throws \Smarty\Exception */ function smarty_function_bit_html_options($params) { - $name = null; - $values = null; - $options = null; - $selected = null; - $output = null; - $id = null; - $class = null; - $extra = ''; - foreach ($params as $_key => $_val) { - switch ($_key) { - case 'name': - case 'class': - case 'id': - $$_key = (string)$_val; - break; - case 'options': - $options = (array)$_val; - break; - case 'values': - case 'output': - $$_key = array_values((array)$_val); - break; - case 'selected': - if (is_array($_val)) { - $selected = []; - foreach ($_val as $_sel) { - if (is_object($_sel)) { - if (method_exists($_sel, '__toString')) { - $_sel = smarty_function_escape_special_chars((string)$_sel->__toString()); - } else { - trigger_error( - 'html_options: selected attribute contains an object of class \'' . - get_class($_sel) . '\' without __toString() method', - E_USER_NOTICE - ); - continue; - } - } else { - $_sel = smarty_function_escape_special_chars((string)$_sel); - } - $selected[$_sel] = true; - } - } elseif (is_object($_val)) { - if (method_exists($_val, '__toString')) { - $selected = smarty_function_escape_special_chars((string)$_val->__toString()); - } else { - trigger_error( - 'html_options: selected attribute is an object of class \'' . get_class($_val) . - '\' without __toString() method', - E_USER_NOTICE - ); - } - } else { - $selected = smarty_function_escape_special_chars((string)$_val); - } - break; - case 'strict': - break; - case 'disabled': - case 'readonly': - if (!empty($params['strict'])) { - if (!is_scalar($_val)) { - trigger_error( - "html_options: {$_key} attribute must be a scalar, only boolean true or string '{$_key}' will actually add the attribute", - E_USER_NOTICE - ); - } - if ($_val === true || $_val === $_key) { - $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"'; - } - break; - } - // omit break; to fall through! - // no break - default: - if (!is_array($_val)) { - $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"'; - } else { - trigger_error("html_options: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE); - } - break; - } - } - if (!isset($options) && !isset($values)) { - /* raise error here? */ - return ''; - } - $_html_result = ''; - $_idx = 0; - if (isset($options)) { - foreach ($options as $_key => $_val) { - $_html_result .= \Bitweaver\Plugins\getHtmlOutput($_key, $_val, $selected, $id, $class, $_idx); - } - } else { - foreach ($values as $_i => $_key) { - $_val = $output[$_i] ?? ''; - $_html_result .= \Bitweaver\Plugins\getHtmlOutput($_key, $_val, $selected, $id, $class, $_idx); - } - } - if (!empty($name)) { - $_html_class = !empty($class) ? ' class="' . $class . '"' : ''; - $_html_id = !empty($id) ? ' id="' . $id . '"' : ''; - $_html_result = - '<select name="' . $name . '"' . $_html_class . $_html_id . $extra . '>' . "\n" . $_html_result . - '</select>' . "\n"; - } - return $_html_result; - } + $name = null; + $values = null; + $options = null; + $selected = null; + $output = null; + $id = null; + $class = null; + $extra = ''; + foreach ($params as $_key => $_val) { + switch ($_key) { + case 'name': + case 'class': + case 'id': + $$_key = (string)$_val; + break; + case 'options': + $options = (array)$_val; + break; + case 'values': + case 'output': + $$_key = array_values((array)$_val); + break; + case 'selected': + if (is_array($_val)) { + $selected = []; + foreach ($_val as $_sel) { + if (is_object($_sel)) { + if (method_exists($_sel, '__toString')) { + $_sel = smarty_function_escape_special_chars((string)$_sel->__toString()); + } else { + trigger_error( + 'html_options: selected attribute contains an object of class \'' . + $_sel::class . '\' without __toString() method', + E_USER_NOTICE, + ); + continue; + } + } else { + $_sel = smarty_function_escape_special_chars((string)$_sel); + } + $selected[$_sel] = true; + } + } elseif (is_object($_val)) { + if (method_exists($_val, '__toString')) { + $selected = smarty_function_escape_special_chars((string)$_val->__toString()); + } else { + trigger_error( + 'html_options: selected attribute is an object of class \'' . $_val::class . + '\' without __toString() method', + E_USER_NOTICE, + ); + } + } else { + $selected = smarty_function_escape_special_chars((string)$_val); + } + break; + case 'strict': + break; + case 'disabled': + case 'readonly': + if (!empty($params['strict'])) { + if (!is_scalar($_val)) { + trigger_error( + "html_options: {$_key} attribute must be a scalar, only boolean true or string '{$_key}' will actually add the attribute", + E_USER_NOTICE, + ); + } + if ($_val === true || $_val === $_key) { + $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"'; + } + break; + } + // omit break; to fall through! + // no break + default: + if (!is_array($_val)) { + $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"'; + } else { + trigger_error("html_options: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE); + } + break; + } + } + if (!isset($options) && !isset($values)) { + /* raise error here? */ + return ''; + } + $_html_result = ''; + $_idx = 0; + if (isset($options)) { + foreach ($options as $_key => $_val) { + $_html_result .= \Bitweaver\Plugins\getHtmlOutput($_key, $_val, $selected, $id, $class, $_idx); + } + } else { + foreach ($values as $_i => $_key) { + $_val = $output[$_i] ?? ''; + $_html_result .= \Bitweaver\Plugins\getHtmlOutput($_key, $_val, $selected, $id, $class, $_idx); + } + } + if (!empty($name)) { + $_html_class = !empty($class) ? ' class="' . $class . '"' : ''; + $_html_id = !empty($id) ? ' id="' . $id . '"' : ''; + $_html_result = + '<select name="' . $name . '"' . $_html_class . $_html_id . $extra . '>' . "\n" . $_html_result . + '</select>' . "\n"; + } + return $_html_result; + } + /** + * @param $key + * @param $value + * @param $selected + * @param $id + * @param $class + * @param $idx + * + * @return string + */ + function getHtmlOutput($key, $value, $selected, $id, $class, &$idx) + { + if (!is_array($value)) { + $_key = smarty_function_escape_special_chars($key); + $_html_result = '<option value="' . $_key . '"'; + if (is_array($selected)) { + if (isset($selected[ $_key ])) { + $_html_result .= ' selected="selected"'; + } + } elseif ($_key === $selected) { + $_html_result .= ' selected="selected"'; + } + $_html_class = !empty($class) ? ' class="' . $class . ' option"' : ''; + $_html_id = !empty($id) ? ' id="' . $id . '-' . $idx . '"' : ''; + if (is_object($value)) { + if (method_exists($value, '__toString')) { + $value = smarty_function_escape_special_chars((string)$value->__toString()); + } else { + trigger_error( + 'html_options: value is an object of class \'' . $value::class . + '\' without __toString() method', + E_USER_NOTICE, + ); + return ''; + } + } else { + $value = smarty_function_escape_special_chars((string)$value); + } + $_html_result .= $_html_class . $_html_id . '>' . $value . '</option>' . "\n"; + $idx++; + } else { + $_idx = 0; + $_html_result = + \Bitweaver\Plugins\getHtmlForOptGroup( + $key, + $value, + $selected, + !empty($id) ? ($id . '-' . $idx) : null, + $class, + $_idx, + ); + $idx++; + } + return $_html_result; + } - /** - * @param $key - * @param $value - * @param $selected - * @param $id - * @param $class - * @param $idx - * - * @return string - */ - function getHtmlOutput($key, $value, $selected, $id, $class, &$idx) - { - if (!is_array($value)) { - $_key = smarty_function_escape_special_chars($key); - $_html_result = '<option value="' . $_key . '"'; - if (is_array($selected)) { - if (isset($selected[ $_key ])) { - $_html_result .= ' selected="selected"'; - } - } elseif ($_key === $selected) { - $_html_result .= ' selected="selected"'; - } - $_html_class = !empty($class) ? ' class="' . $class . ' option"' : ''; - $_html_id = !empty($id) ? ' id="' . $id . '-' . $idx . '"' : ''; - if (is_object($value)) { - if (method_exists($value, '__toString')) { - $value = smarty_function_escape_special_chars((string)$value->__toString()); - } else { - trigger_error( - 'html_options: value is an object of class \'' . get_class($value) . - '\' without __toString() method', - E_USER_NOTICE - ); - return ''; - } - } else { - $value = smarty_function_escape_special_chars((string)$value); - } - $_html_result .= $_html_class . $_html_id . '>' . $value . '</option>' . "\n"; - $idx++; - } else { - $_idx = 0; - $_html_result = - \Bitweaver\Plugins\getHtmlForOptGroup( - $key, - $value, - $selected, - !empty($id) ? ($id . '-' . $idx) : null, - $class, - $_idx - ); - $idx++; - } - return $_html_result; - } - - /** - * @param $key - * @param $values - * @param $selected - * @param $id - * @param $class - * @param $idx - * - * @return string - */ - function getHtmlForOptGroup($key, $values, $selected, $id, $class, &$idx) - { - $optgroup_html = '<optgroup label="' . smarty_function_escape_special_chars($key) . '">' . "\n"; - foreach ($values as $key => $value) { - $optgroup_html .= \Bitweaver\Plugins\getHtmlOutput($key, $value, $selected, $id, $class, $idx); - } - $optgroup_html .= "</optgroup>\n"; - return $optgroup_html; - } - + /** + * @param $key + * @param $values + * @param $selected + * @param $id + * @param $class + * @param $idx + * + * @return string + */ + function getHtmlForOptGroup($key, $values, $selected, $id, $class, &$idx) + { + $optgroup_html = '<optgroup label="' . smarty_function_escape_special_chars($key) . '">' . "\n"; + foreach ($values as $key => $value) { + $optgroup_html .= \Bitweaver\Plugins\getHtmlOutput($key, $value, $selected, $id, $class, $idx); + } + $optgroup_html .= "</optgroup>\n"; + return $optgroup_html; + } diff --git a/smartyplugins/function.bit_select_datetime.php b/smartyplugins/function.bit_select_datetime.php index 2260cad..77e20a8 100755 --- a/smartyplugins/function.bit_select_datetime.php +++ b/smartyplugins/function.bit_select_datetime.php @@ -81,18 +81,18 @@ function smarty_function_bit_select_datetime( $pParams, &$gBitSmarty ) { //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 ( + $pDate = [ 'prefix' => $nname, 'all_extra' => "onchange=\"bit_select_datetime_{$nname}()\"", - 'time' => $time - ); + 'time' => $time, + ]; - $pTime = array ( + $pTime = [ 'prefix' => $nname, 'all_extra' => "onchange=\"bit_select_datetime_{$nname}()\"", 'display_seconds' => false, - 'time' => $time - ); + 'time' => $time, + ]; $html_result = "<input type=\"hidden\" name=\"$name\" value=\"{$time}\">"; $html_result .= smarty_function_html_select_date( $pDate, $gBitSmarty ); diff --git a/smartyplugins/function.bithelp.php b/smartyplugins/function.bithelp.php index b0628a6..a174e77 100755 --- a/smartyplugins/function.bithelp.php +++ b/smartyplugins/function.bithelp.php @@ -19,10 +19,10 @@ function smarty_function_bithelp($params, &$gBitSmarty) { $outstr = ""; if( $gBitSystem->isFeatureActive('site_online_help') ){ if($gBitUser->hasPermission( 'p_admin' )){ - $outstr .= "<a href=\"".KERNEL_PKG_URL."admin/index.php\">".smarty_function_booticon(array('ipackage'=>'icons', 'iname'=>'icon-cogs', 'iexplain'=>'Administration Menu') )."</a> "; + $outstr .= "<a href=\"".KERNEL_PKG_URL."admin/index.php\">".smarty_function_booticon(['ipackage'=>'icons', 'iname'=>'icon-cogs', 'iexplain'=>'Administration Menu'] )."</a> "; } if( $helpInfo = $gBitSmarty->getTemplateVars('TikiHelpInfo') ) { - $outstr .= "<a href=\"".$helpInfo["URL"]."\" >".smarty_function_booticon(array('ipackage'=>'icons', 'iname'=>'icon-question-sign', 'iexplain'=>(empty($helpInfo["Desc"])?"help":$helpInfo["Desc"])) )."</a>"; + $outstr .= "<a href=\"".$helpInfo["URL"]."\" >".smarty_function_booticon(['ipackage'=>'icons', 'iname'=>'icon-question-sign', 'iexplain'=>(empty($helpInfo["Desc"])?"help":$helpInfo["Desc"])] )."</a>"; } } return $outstr; diff --git a/smartyplugins/function.biticon.php b/smartyplugins/function.biticon.php index 6659513..380b76d 100755 --- a/smartyplugins/function.biticon.php +++ b/smartyplugins/function.biticon.php @@ -1,5 +1,6 @@ <?php namespace Bitweaver\Plugins; + use Bitweaver\KernelTools; /** @@ -210,15 +211,14 @@ function smarty_function_biticon( $pParams, $pSmall = false ) { // Still didn't find it! Well lets output something (return empty string if only the url is requested) if( isset( $pParams['url'] )) { return ''; - } else { + } if( empty( $pSmall ) ) { // if we were looking for the large icon, we'll try the whole kaboodle again, looking for the small icon $copyParams['ipath'] = preg_replace( "!/.*?/$!", "/small/", $pParams['ipath'] ); return smarty_function_biticon( $copyParams, true ); - } else { - return biticon_output( $pParams, '' ); } - } + return biticon_output( $pParams, '' ); + } /** diff --git a/smartyplugins/function.content.php b/smartyplugins/function.content.php index 5399739..24bb1df 100755 --- a/smartyplugins/function.content.php +++ b/smartyplugins/function.content.php @@ -12,16 +12,16 @@ namespace Bitweaver\Plugins; */ function smarty_function_content($params, &$gBitSmarty) { - global $gBitSystem; - global $dcslib; - include_once( DCS_PKG_PATH.'dcs_lib.php' ); - extract($params); - // Param = zone + 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); + 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 index e23041c..b6e9279 100755 --- a/smartyplugins/function.cookie.php +++ b/smartyplugins/function.cookie.php @@ -11,7 +11,7 @@ namespace Bitweaver\Plugins; * smarty_function_cookie */ function smarty_function_cookie($params, &$gBitSmarty) { - global $taglinelib; - include_once TIDBITS_PKG_PATH.'BitFortuneCookies.php'; + 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 index a1ea210..16b02f1 100755 --- a/smartyplugins/function.displaycomment.php +++ b/smartyplugins/function.displaycomment.php @@ -16,7 +16,7 @@ function smarty_function_displaycomment( $pParams, &$pSmarty ) { if (!empty($pParams['comment'])) { $comment = $pParams['comment']; $gBitSmarty->assign('comment', $comment); - $ret = ( empty( $pParams['template'] ) ) + $ret = ( empty( $pParams['template'] ) ) ? $gBitSmarty->fetch( 'bitpackage:liberty/display_comment.tpl' ) : $gBitSmarty->fetch( $pParams['template'] ); } diff --git a/smartyplugins/function.displayname.php b/smartyplugins/function.displayname.php index f77b0ba..fa10a2e 100755 --- a/smartyplugins/function.displayname.php +++ b/smartyplugins/function.displayname.php @@ -1,5 +1,6 @@ <?php namespace Bitweaver\Plugins; + use Bitweaver\BitBase; use Bitweaver\Users\RoleUser; diff --git a/smartyplugins/function.ed.php b/smartyplugins/function.ed.php index d48f783..1a6239f 100755 --- a/smartyplugins/function.ed.php +++ b/smartyplugins/function.ed.php @@ -12,16 +12,16 @@ namespace Bitweaver\Plugins; */ function smarty_function_ed($params, &$gBitSmarty) { - global $gBitSystem; - extract($params); - // Param = zone + global $gBitSystem; + extract($params); + // Param = zone - if (empty($id)) { - $gBitSmarty->trigger_error("ed: missing 'id' parameter"); - return; - } - - print($banner); + 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 index 3cfbd39..4d92d57 100755 --- a/smartyplugins/function.elapsed.php +++ b/smartyplugins/function.elapsed.php @@ -12,10 +12,10 @@ namespace Bitweaver\Plugins; */ function smarty_function_elapsed($params, &$gBitSmarty) { - global $gBitSystem; - - $ela = number_format($gBitSystem->mTimer->elapsed(),2); - print($ela); + global $gBitSystem; + + $ela = number_format($gBitSystem->mTimer->elapsed(),2); + print($ela); } /* vim: set expandtab: */ diff --git a/smartyplugins/function.formhelp.php b/smartyplugins/function.formhelp.php index 081e325..ee0da71 100755 --- a/smartyplugins/function.formhelp.php +++ b/smartyplugins/function.formhelp.php @@ -1,5 +1,6 @@ <?php namespace Bitweaver\Plugins; + use Bitweaver\KernelTools; /** diff --git a/smartyplugins/function.formlabel.php b/smartyplugins/function.formlabel.php index b2961f8..d2808a8 100755 --- a/smartyplugins/function.formlabel.php +++ b/smartyplugins/function.formlabel.php @@ -1,5 +1,6 @@ <?php namespace Bitweaver\Plugins; + use Bitweaver\KernelTools; /** diff --git a/smartyplugins/function.gallery.php b/smartyplugins/function.gallery.php index 6b9c066..5bbf69a 100755 --- a/smartyplugins/function.gallery.php +++ b/smartyplugins/function.gallery.php @@ -12,24 +12,24 @@ namespace Bitweaver\Plugins; */ function smarty_function_gallery($params, &$gBitSmarty) { - global $gBitSystem; - include_once IMAGEGALS_PKG_PATH.'imagegal_lib.php'; - extract($params); - // Param = id + 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'].'&image_id='.$img['image_id'].'"><img alt="thumbnail" class="athumb" src="show_image.php?id='.$img['image_id'].'&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>'; -} + 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'].'&image_id='.$img['image_id'].'"><img alt="thumbnail" class="athumb" src="show_image.php?id='.$img['image_id'].'&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>'; +} diff --git a/smartyplugins/function.helplink.php b/smartyplugins/function.helplink.php index 4fb24fe..da16ec1 100755 --- a/smartyplugins/function.helplink.php +++ b/smartyplugins/function.helplink.php @@ -12,13 +12,13 @@ namespace Bitweaver\Plugins; */ 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>"); + 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 index 6d28f8a..a676e65 100755 --- a/smartyplugins/function.html_select_date.php +++ b/smartyplugins/function.html_select_date.php @@ -1,7 +1,5 @@ <?php namespace Bitweaver\Plugins; -use Bitweaver\KernelTools; -use Bitweaver\BitDate; /** * Smarty plugin @@ -159,7 +157,7 @@ function smarty_function_html_select_date($params, &$pSmarty) { foreach ([ 'Y' => 'Year', 'm' => 'Month', - 'd' => 'Day' + 'd' => 'Day', ] as $_elementKey => $_elementName) { $_variableName = '_' . strtolower($_elementName); $$_variableName = @@ -170,7 +168,7 @@ function smarty_function_html_select_date($params, &$pSmarty) { foreach ([ 'Y' => 'Year', 'm' => 'Month', - 'd' => 'Day' + 'd' => 'Day', ] as $_elementKey => $_elementName) { $_variableName = '_' . strtolower($_elementName); $$_variableName = $time[$field_array][$prefix . $_elementName] ?? date($_elementKey); @@ -205,7 +203,7 @@ function smarty_function_html_select_date($params, &$pSmarty) { // Note preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match) is slower than trim+substr foreach ([ 'start', - 'end' + 'end', ] as $key) { $key .= '_year'; $t = $$key; @@ -246,7 +244,7 @@ function smarty_function_html_select_date($params, &$pSmarty) { $year_id !== null ? ($year_id ? $year_id : $_name) : ($all_id ? ($all_id . $_name) : - $_name) + $_name), ) . '"'; } if ($year_size) { @@ -254,7 +252,7 @@ function smarty_function_html_select_date($params, &$pSmarty) { } $_html_years .= $_extra . $extra_attrs . '>' . $option_separator; if (isset($year_empty) || isset($all_empty)) { - $_html_years .= '<option value="">' . (isset($year_empty) ? $year_empty : $all_empty) . '</option>' . + $_html_years .= '<option value="">' . ($year_empty ?? $all_empty) . '</option>' . $option_separator; } $op = $start_year > $end_year ? -1 : 1; @@ -282,7 +280,7 @@ function smarty_function_html_select_date($params, &$pSmarty) { $month_id !== null ? ($month_id ? $month_id : $_name) : ($all_id ? ($all_id . $_name) : - $_name) + $_name), ) . '"'; } if ($month_size) { @@ -324,7 +322,7 @@ function smarty_function_html_select_date($params, &$pSmarty) { $_html_days .= ' id="' . smarty_function_escape_special_chars( $day_id !== null ? ($day_id ? $day_id : $_name) : - ($all_id ? ($all_id . $_name) : $_name) + ($all_id ? ($all_id . $_name) : $_name), ) . '"'; } if ($day_size) { @@ -332,7 +330,7 @@ function smarty_function_html_select_date($params, &$pSmarty) { } $_html_days .= $_extra . $extra_attrs . '>' . $option_separator; if (isset($day_empty) || isset($all_empty)) { - $_html_days .= '<option value="">' . (isset($day_empty) ? $day_empty : $all_empty) . '</option>' . + $_html_days .= '<option value="">' . ($day_empty ?? $all_empty) . '</option>' . $option_separator; } for ($i = 1; $i <= 31; $i++) { diff --git a/smartyplugins/function.html_select_time.php b/smartyplugins/function.html_select_time.php index 693a5ea..4d376f2 100755 --- a/smartyplugins/function.html_select_time.php +++ b/smartyplugins/function.html_select_time.php @@ -1,5 +1,6 @@ <?php namespace Bitweaver\Plugins; + use \Bitweaver\BitDate; /** @@ -8,7 +9,6 @@ use \Bitweaver\BitDate; * @subpackage plugins */ - /** * Smarty {html_select_time} function plugin * @@ -23,153 +23,153 @@ use \Bitweaver\BitDate; */ function smarty_function_html_select_time($params, &$gBitSmarty) { - global $gBitSystem; + global $gBitSystem; // $gBitSmarty->loadPlugin( 'smarty_shared_make_timestamp' ); // $gBitSmarty->loadPlugin( 'smarty_function_bit_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; + /* 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); + extract($params); $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 = ''; + $html_result = ''; - if ($display_hours) { - $hours = $use_24_hours ? range(0, 23) : range(1, 12); - $hour_fmt = $use_24_hours ? '%H' : '%I'; + 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_bit_html_options( [ 'output' => $hours, - 'values' => $hours, - 'selected' => $selected, - 'print_result' => false ], - $gBitSmarty); - $html_result .= "</select>\n"; - } + 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_bit_html_options( [ '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"; + 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 = (int) (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_bit_html_options(array('output' => $minutes, - 'values' => $minutes, - 'selected' => $selected, - 'print_result' => false), - $gBitSmarty); - $html_result .= "</select>\n"; - } + $html_result .= smarty_function_bit_html_options(['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 ($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 = (int) (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"; + if (null !== $second_extra){ + $html_result .= ' ' . $second_extra; + } + if (null !== $all_extra){ + $html_result .= ' ' . $all_extra; + } + $html_result .= '>'."\n"; - $html_result .= smarty_function_bit_html_options(array('output' => $seconds, - 'values' => $seconds, - 'selected' => $selected, - 'print_result' => false), - $gBitSmarty); - $html_result .= "</select>\n"; - } + $html_result .= smarty_function_bit_html_options(['output' => $seconds, + 'values' => $seconds, + 'selected' => $selected, + 'print_result' => false, ], + $gBitSmarty, ); + $html_result .= "</select>\n"; + } - if ($display_meridian && !$use_24_hours) { - $html_result .= '<select name='; + 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 !== $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"; + if (null !== $meridian_extra){ + $html_result .= ' ' . $meridian_extra; + } + if (null !== $all_extra){ + $html_result .= ' ' . $all_extra; + } + $html_result .= '>'."\n"; - $html_result .= smarty_function_bit_html_options(array('output' => array('AM', 'PM'), - 'values' => array('am', 'pm'), - 'selected' => $selected, - 'print_result' => false), - $gBitSmarty); - $html_result .= "</select>\n"; - } + $html_result .= smarty_function_bit_html_options(['output' => ['AM', 'PM'], + 'values' => ['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>'; + $html_result = '<span dir="ltr">' . $html_result . '</span>'; - return $html_result; + return $html_result; } /* vim: set expandtab: */ diff --git a/smartyplugins/function.include_js.php b/smartyplugins/function.include_js.php index e309ad0..1178290 100755 --- a/smartyplugins/function.include_js.php +++ b/smartyplugins/function.include_js.php @@ -1,5 +1,6 @@ <?php namespace Bitweaver\Plugins; + use \Bitweaver\BitCache; /** @@ -29,7 +30,7 @@ function smarty_function_include_js( $params,&$gBitSmarty ) { $pack = FALSE; default: break; - } + } } if( is_file( $file )) { // pack it diff --git a/smartyplugins/function.include_wiki_page_content.php b/smartyplugins/function.include_wiki_page_content.php index dd136e4..4b5b34e 100755 --- a/smartyplugins/function.include_wiki_page_content.php +++ b/smartyplugins/function.include_wiki_page_content.php @@ -1,5 +1,6 @@ <?php namespace Bitweaver\Plugins; + use \Bitweaver\Wiki\BitPage; /** @@ -14,7 +15,6 @@ use \Bitweaver\Wiki\BitPage; * \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' } @@ -45,11 +45,11 @@ use \Bitweaver\Wiki\BitPage; # # 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. +# 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. +# 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: # @@ -59,14 +59,13 @@ use \Bitweaver\Wiki\BitPage; # Editing any other page will display the default edit notice. # - function smarty_function_include_wiki_page_content($params, &$gBitSmarty) { $parsed = ''; // if( ($pageName = !empty( $params['page'] ) ? $params['page'] : (!empty( $params['page_default'] ) ? $params['page_default'] : NULL )) ) { include_once WIKI_PKG_CLASS_PATH.'BitPage.php'; - if( $includePage = BitPage::lookupObject( array( 'page' => $pageName ) ) ) { + if( $includePage = BitPage::lookupObject( [ 'page' => $pageName ] ) ) { $parsed = $includePage->getParsedData(); } } diff --git a/smartyplugins/function.inlinemodule.php b/smartyplugins/function.inlinemodule.php index cfdba21..5fe2be7 100755 --- a/smartyplugins/function.inlinemodule.php +++ b/smartyplugins/function.inlinemodule.php @@ -7,7 +7,6 @@ namespace Bitweaver\Plugins; * @subpackage plugins */ - /** * Usage: add to the body of any .tpl file * Example: {inlinemodule file="bitpackage:wiki/mod_last_modif_pages.tpl" rows="50"} diff --git a/smartyplugins/function.jscalendar.php b/smartyplugins/function.jscalendar.php index 7d37ecd..64631cb 100755 --- a/smartyplugins/function.jscalendar.php +++ b/smartyplugins/function.jscalendar.php @@ -1,5 +1,6 @@ <?php namespace Bitweaver\Plugins; + use Bitweaver\BitDate; /** @@ -56,7 +57,7 @@ function smarty_function_jscalendar($params, &$gBitSmarty) { //]]></script>"; return $html_result; - } else { - return ''; } + return ''; + } diff --git a/smartyplugins/function.jspack.php b/smartyplugins/function.jspack.php index 3002cc1..677ae73 100755 --- a/smartyplugins/function.jspack.php +++ b/smartyplugins/function.jspack.php @@ -60,7 +60,7 @@ function smarty_function_jspack( $pParams, &$gBitSmarty ) { $defer = !empty( $pParams['defer'] ) ? " defer='".$pParams['defer']."'" : ""; return '<script'.$defer.' src="'.$bitCache->getCacheUrl( $cachefile ).'"></script>'; - } else { - return "<!-- ".tra( 'not a valid file: ' ).$pParams['ifile']." -->"; } + return "<!-- ".tra( 'not a valid file: ' ).$pParams['ifile']." -->"; + } diff --git a/smartyplugins/function.jspopup.php b/smartyplugins/function.jspopup.php index e91c875..fc20e79 100755 --- a/smartyplugins/function.jspopup.php +++ b/smartyplugins/function.jspopup.php @@ -1,5 +1,6 @@ <?php namespace Bitweaver\Plugins; + use Bitweaver\KernelTools; /** @@ -44,8 +45,7 @@ function smarty_function_jspopup( $pParams, &$pSmarty=NULL ) { unset( $pParams['text'] ); } - - $optionHash = array( 'type', 'width', 'height', 'gutsonly', 'img' ); + $optionHash = [ 'type', 'width', 'height', 'gutsonly', 'img' ]; $guts = ''; foreach( $pParams as $param => $val ) { if( !in_array( $param, $optionHash ) ) { @@ -98,7 +98,7 @@ function smarty_function_jspopup( $pParams, &$pSmarty=NULL ) { if( !empty( $pParams['gutsonly'] ) ) { return $guts; - } else { - return '<a '.$guts.'>'.( !empty( $img ) ? $img : $text ).'</a>'; } + return '<a '.$guts.'>'.( !empty( $img ) ? $img : $text ).'</a>'; + } diff --git a/smartyplugins/function.libertypagination.php b/smartyplugins/function.libertypagination.php index 6da32ec..27660a8 100755 --- a/smartyplugins/function.libertypagination.php +++ b/smartyplugins/function.libertypagination.php @@ -28,7 +28,7 @@ namespace Bitweaver\Plugins; */ function smarty_function_libertypagination($params, &$gSmartyTemplate) { global $gBitSmarty; - + if( isset( $params['ihash'] ) && is_array( $params['ihash'] ) ) { $params = array_merge( $params['ihash'], $params ); $params['ihash'] = NULL; @@ -39,10 +39,10 @@ function smarty_function_libertypagination($params, &$gSmartyTemplate) { parse_str( preg_replace( "/.*\?/", "", $params['url'] ), $urlParams ); $params = array_merge( $urlParams, $params ); } - $pgnName = isset( $params['pgnName'] ) ? $params['pgnName'] : ( isset( $params['curPage'] ) ? 'curPage' : 'page' ); + $pgnName = $params['pgnName'] ?? ( isset( $params['curPage'] ) ? 'curPage' : 'page' ); $pgnVars = ''; - $omitParams = array( 'numPages', 'url', $pgnName, 'pgnName', 'ianchor', 'ajaxId' ); + $omitParams = [ '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'] ) ? "&" : "&" ).$form_param."=".$form_val; @@ -64,11 +64,11 @@ function smarty_function_libertypagination($params, &$gSmartyTemplate) { $gBitSmarty->assign( 'pgnName', $pgnName ); $gBitSmarty->assign( 'pgnVars', $pgnVars ); $gBitSmarty->assign( 'pgnHidden', $pgnHidden ); - $gBitSmarty->assign( 'pgnPages', $pages ); - $gBitSmarty->assign( 'numPages', $params['numPages'] ); + $gBitSmarty->assign( 'pgnPages', $pages ); + $gBitSmarty->assign( 'numPages', $params['numPages'] ); if( !empty( $params['ajaxId'] ) ) { - $gBitSmarty->assign( 'ajaxId', $params['ajaxId'] ); + $gBitSmarty->assign( 'ajaxId', $params['ajaxId'] ); } - return $gBitSmarty->fetch( 'bitpackage:liberty/libertypagination.tpl' ); + return $gBitSmarty->fetch( 'bitpackage:liberty/libertypagination.tpl' ); } } diff --git a/smartyplugins/function.minifind.php b/smartyplugins/function.minifind.php index a915d64..d98c2de 100755 --- a/smartyplugins/function.minifind.php +++ b/smartyplugins/function.minifind.php @@ -1,5 +1,6 @@ <?php namespace Bitweaver\Plugins; + use Bitweaver\KernelTools; /** @@ -18,7 +19,7 @@ use Bitweaver\KernelTools; */ function smarty_function_minifind($params, &$gSmartyTemplate) { global $gBitSmarty; - + if(isset($params['legend'])) { $legend = $params['legend']; unset($params['legend']); @@ -29,11 +30,11 @@ function smarty_function_minifind($params, &$gSmartyTemplate) { if( !empty( $params['find_name'] ) ) { $gBitSmarty->assign( 'find_name', KernelTools::tra( $params['name'] ) ); } - + if( !empty( $params['prompt'] ) ) { $gBitSmarty->assign( 'prompt', KernelTools::tra( $params['prompt'] ).'...' ); } - + $gBitSmarty->assign( 'legend',$legend ); $gBitSmarty->assign( 'hidden',$params ); return $gBitSmarty->fetch( 'bitpackage:kernel/minifind.tpl' ); diff --git a/smartyplugins/function.moduleinc.php b/smartyplugins/function.moduleinc.php index 4e2073b..519657e 100755 --- a/smartyplugins/function.moduleinc.php +++ b/smartyplugins/function.moduleinc.php @@ -59,5 +59,5 @@ function smarty_function_moduleinc($pParams, &$gBitSmarty) { } } unset( $data ); - } + } } diff --git a/smartyplugins/function.pageurl.php b/smartyplugins/function.pageurl.php index 9b7464a..3e15571 100755 --- a/smartyplugins/function.pageurl.php +++ b/smartyplugins/function.pageurl.php @@ -61,7 +61,7 @@ function smarty_function_pageurl( $params, &$gBitSmarty ) { $pageUrlVar = preg_replace( '/^\&/', '', $str ); $pageUrl = $pgnUrl . "?" . $pageUrlVar; - + return $pageUrl; } diff --git a/smartyplugins/function.pagination.php b/smartyplugins/function.pagination.php index a9461c2..c7b54a5 100755 --- a/smartyplugins/function.pagination.php +++ b/smartyplugins/function.pagination.php @@ -22,15 +22,15 @@ function smarty_function_pagination( $params, &$gSmartyTemplate ) { global $gBitSmarty; $pgnUrl = $gBitSmarty->getTemplateVars('returnURL'); - if ( isset( $params['url'] ) ) { - $pgnUrl = $params['url']; - unset( $params['url'] ); - } - if( empty( $pgnUrl ) ) { - $pgnUrl = $_SERVER['SCRIPT_NAME']; + if ( isset( $params['url'] ) ) { + $pgnUrl = $params['url']; + unset( $params['url'] ); + } + if( empty( $pgnUrl ) ) { + $pgnUrl = $_SERVER['SCRIPT_NAME']; } - $gBitSmarty->assign( 'pgnUrl', $pgnUrl ); + $gBitSmarty->assign( 'pgnUrl', $pgnUrl ); $pgnVars = ''; $pgnHidden = []; @@ -40,8 +40,8 @@ function smarty_function_pagination( $params, &$gSmartyTemplate ) { $pgnHidden[$form_param] = $form_val; } } - - $gBitSmarty->assign( 'pgnVars', $pgnVars ); + + $gBitSmarty->assign( 'pgnVars', $pgnVars ); $gBitSmarty->assign( 'pgnHidden', $pgnHidden ); - return $gBitSmarty->fetch('bitpackage:kernel/pagination.tpl'); + return $gBitSmarty->fetch('bitpackage:kernel/pagination.tpl'); } diff --git a/smartyplugins/function.poll.php b/smartyplugins/function.poll.php index ad7b96e..b0e7208 100755 --- a/smartyplugins/function.poll.php +++ b/smartyplugins/function.poll.php @@ -10,33 +10,32 @@ namespace Bitweaver\Plugins; /** * smarty_function_base */ -use Bitweaver\BitBase; /** * smarty_function_poll */ function smarty_function_poll($params, &$gBitSmarty) { - global $polllib, $gBitSystem; + global $polllib, $gBitSystem; - extract($params); - // Param = zone + extract($params); + // Param = zone include_once( POLLS_PKG_PATH.'poll_lib.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 (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'); - } + $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'); + } } diff --git a/smartyplugins/function.popup.php b/smartyplugins/function.popup.php index 62a6151..797cda2 100755 --- a/smartyplugins/function.popup.php +++ b/smartyplugins/function.popup.php @@ -9,7 +9,6 @@ use Bitweaver\Liberty\LibertyContent; * @subpackage plugins */ - /** * Smarty {popup} function plugin * @@ -117,15 +116,15 @@ function smarty_function_popup($params, &$gBitSmarty) { if (!empty($target) && !empty($target_append)) { if (strstr($target, "?")) { - $target .= "&".$target_append; + $target .= "&".$target_append; } else { - $target .= "?".$target_append; + $target .= "?".$target_append; } } if (!empty($text)) { - $retval = $trigger . '="return overlib(\''.preg_replace(array("!'!","![\r\n]!"),array("\'",'\r'),$text).'\''; + $retval = $trigger . '="return overlib(\''.preg_replace(["!'!","![\r\n]!"],["\'",'\r'],$text).'\''; $retval .= $append . ');" onmouseout="nd();"'; } else { diff --git a/smartyplugins/function.querytable.php b/smartyplugins/function.querytable.php index 1321f0f..3821d18 100755 --- a/smartyplugins/function.querytable.php +++ b/smartyplugins/function.querytable.php @@ -32,19 +32,18 @@ namespace Bitweaver\Plugins; * } */ - //SECURITY HERE! function smarty_function_querytable($params, &$gBitSmarty) { global $gBitSystem; extract($params); //Security here - $arguments = Array('table','template','tableclass','where', + $arguments = ['table','template','tableclass','where', 'columns','height', 'sort_column','sort_order','colalign','columnheadingclass', 'max_rows','offset','total','directpagination', - 'combopagination'); - + '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'; @@ -69,7 +68,7 @@ function smarty_function_querytable($params, &$gBitSmarty) { $output.="&$arg=$val"; } $output.="'></iframe>"; - + return $output; } diff --git a/smartyplugins/function.rcontent.php b/smartyplugins/function.rcontent.php index 3a39294..0085b28 100755 --- a/smartyplugins/function.rcontent.php +++ b/smartyplugins/function.rcontent.php @@ -12,17 +12,17 @@ namespace Bitweaver\Plugins; */ function smarty_function_rcontent($params, &$gBitSmarty) { - global $gBitSystem; - include_once( DCS_PKG_PATH.'dcs_lib.php' ); - extract($params); - // Param = zone + 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); + 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 index 247f3b6..661e997 100755 --- a/smartyplugins/function.required.php +++ b/smartyplugins/function.required.php @@ -13,11 +13,11 @@ namespace Bitweaver\Plugins; function smarty_function_required( $pParams, &$pSmarty=NULL ) { global $gBitSmarty; // $gBitSmarty->loadPlugin( 'smarty_function_biticon' ); - $biticon = array( + $biticon = [ 'ipackage' => 'icons', 'iname' => 'emblem-important', 'iexplain' => 'Required', - ); + ]; $ret = \Bitweaver\Plugins\smarty_function_biticon( $biticon ); if( !empty( $pParams['legend'] )) { diff --git a/smartyplugins/function.sameurl.php b/smartyplugins/function.sameurl.php index ff0de72..2b26721 100755 --- a/smartyplugins/function.sameurl.php +++ b/smartyplugins/function.sameurl.php @@ -13,50 +13,50 @@ namespace Bitweaver\Plugins; */ 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='&'; - } + global $sameurl_elements; + $data = $_SERVER['SCRIPT_NAME']; + $first=true; + $sets=[]; + 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='&'; + } - $data.=$sep.urlencode($name).'='.urlencode($val); - $sets[]=$name; - } - } + $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='&'; - } + } + } - $data.=$sep.urlencode($name).'='.urlencode($val); - $sets[]=$name; - } - } - } - print($data); + 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='&'; + } + + $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 index a0a05d9..c8a9c3a 100755 --- a/smartyplugins/function.showdate.php +++ b/smartyplugins/function.showdate.php @@ -12,15 +12,15 @@ namespace Bitweaver\Plugins; */ function smarty_function_showdate($params, &$gBitSmarty) { - - extract($params); - // Param = zone - if (empty($mode)) { - $gBitSmarty->trigger_error("assign: missing 'mode' parameter"); - return; - } - print(date($mode)); + 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 index 8d56419..7d07e28 100755 --- a/smartyplugins/function.smartlink.php +++ b/smartyplugins/function.smartlink.php @@ -1,5 +1,6 @@ <?php namespace Bitweaver\Plugins; + use Bitweaver\KernelTools; /** @@ -70,7 +71,7 @@ function smarty_function_smartlink( $pParams, &$pSmarty=NULL ) { $url = !empty( $hash['ipackage'] ) ? ( $hash['ipackage'] == 'root' ? $url = BIT_ROOT_URL.$hash['ifile'] - : constant( strtoupper( $hash['ipackage'] ).'_PKG_URL' ).$hash['ifile'] ) + : constant( strtoupper( $hash['ipackage'] ).'_PKG_URL' ).$hash['ifile'] ) : constant( strtoupper( $gBitSystem->getActivePackage() ).'_PKG_URL' ).$hash['ifile']; } else { $url = $_SERVER['SCRIPT_NAME']; @@ -90,7 +91,7 @@ function smarty_function_smartlink( $pParams, &$pSmarty=NULL ) { // 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); + $isort_mode = $hash['isort_mode'] ?? ($_REQUEST['sort_mode'] ?? NULL); $sort_asc = $hash['isort'].'_asc'; $sort_desc = $hash['isort'].'_desc'; @@ -100,7 +101,7 @@ function smarty_function_smartlink( $pParams, &$pSmarty=NULL ) { // 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' ); + $isort_mode .= $hash['isort'].'_'.( $hash['iorder'] ?? 'asc' ); } // check if sort_mode has anything to do with our link @@ -121,7 +122,7 @@ function smarty_function_smartlink( $pParams, &$pSmarty=NULL ) { ]; $url_params .= $sort_asc; } else { - $url_params .= $hash['isort'].'_'.( isset( $hash['iorder'] ) ? $hash['iorder'] : 'asc' ); + $url_params .= $hash['isort'].'_'.( $hash['iorder'] ?? 'asc' ); } } diff --git a/smartyplugins/function.textarea.php b/smartyplugins/function.textarea.php index 97d7bca..8ce05c7 100755 --- a/smartyplugins/function.textarea.php +++ b/smartyplugins/function.textarea.php @@ -15,7 +15,7 @@ namespace Bitweaver\Plugins; * Type: function * Name: textarea * ------------------------------------------------------------- - */ + */ function smarty_function_textarea( $pParams, &$pSmartyTemplate ) { global $gBitSystem, $gContent, $gLibertySystem, $gBitSmarty; diff --git a/smartyplugins/function.tk.php b/smartyplugins/function.tk.php index 3a15b85..bffd2ae 100755 --- a/smartyplugins/function.tk.php +++ b/smartyplugins/function.tk.php @@ -11,6 +11,6 @@ namespace Bitweaver\Plugins; * smarty_function_cookie */ function smarty_function_tk($params, &$gBitSmarty) { - global $gBitUser; + global $gBitUser; print 'tk='.$gBitUser->mTicket; } diff --git a/smartyplugins/function.var_dump.php b/smartyplugins/function.var_dump.php index 35e9244..a131a55 100755 --- a/smartyplugins/function.var_dump.php +++ b/smartyplugins/function.var_dump.php @@ -13,7 +13,6 @@ namespace Bitweaver\Plugins; * \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} @@ -26,13 +25,13 @@ function smarty_function_var_dump($params, &$gBitSmarty) $v = $params['var']; if (strlen($v) != 0) { - $tmp = $gBitSmarty->getTemplateVars(); - 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"); + $tmp = $gBitSmarty->getTemplateVars(); + 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"); + $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 index c9373e3..4b59faa 100755 --- a/smartyplugins/modifier.act_icon.php +++ b/smartyplugins/modifier.act_icon.php @@ -14,28 +14,28 @@ 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; + 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; + return $img; } diff --git a/smartyplugins/modifier.adjust.php b/smartyplugins/modifier.adjust.php index d2cb5de..53d1e36 100755 --- a/smartyplugins/modifier.adjust.php +++ b/smartyplugins/modifier.adjust.php @@ -18,26 +18,25 @@ namespace Bitweaver\Plugins; * using $pad as filler. * ------------------------------------------------------------- */ -function smarty_modifier_adjust($string, $length = 80, - $pad = ' ', - $etc = '...', - $break_words = false) +function smarty_modifier_adjust($string, $length = 80, + $pad = ' ', + $etc = '...', + $break_words = false, ) { - if ($length == 0) - return ''; + 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)); + } + return $string; - 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.avatarize.php b/smartyplugins/modifier.avatarize.php index 4476ad0..7941905 100755 --- a/smartyplugins/modifier.avatarize.php +++ b/smartyplugins/modifier.avatarize.php @@ -20,7 +20,7 @@ function smarty_modifier_avatarize($user) global $gBitSystem, $gBitUser; $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; + $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 index 6fd5e92..d939678 100755 --- a/smartyplugins/modifier.bit_date_format.php +++ b/smartyplugins/modifier.bit_date_format.php @@ -1,7 +1,7 @@ <?php namespace Bitweaver\Plugins; + use Bitweaver\KernelTools; -use Bitweaver\BitDate; /** * Smarty plugin @@ -44,11 +44,11 @@ function smarty_modifier_bit_date_format( $pString, $format = "%b %e, %Y", $pTra : new \DateTime( $pString ); $disptime = strtotime($dateTimeUser->format(DATE_W3C)); return $gBitSystem->mServerTimestamp->strftime( $format, $disptime ); - } else { + } $format = $gBitSystem->get_display_offset() ? preg_replace( "/ ?%Z/",'', $format ) : $format = preg_replace( "/%Z/", "UTC", $format ); $disptime = $gBitSystem->mServerTimestamp->getDisplayDateFromUTC( $pString ); - } + return $gBitSystem->mServerTimestamp->strftime( $format, $disptime, TRUE ); } diff --git a/smartyplugins/modifier.bit_short_datetime.php b/smartyplugins/modifier.bit_short_datetime.php index a97cd3d..c86503b 100755 --- a/smartyplugins/modifier.bit_short_datetime.php +++ b/smartyplugins/modifier.bit_short_datetime.php @@ -20,7 +20,7 @@ function smarty_modifier_bit_short_datetime( $pString, $time='' ) { global $gBitSystem; if( !empty( $time ) && date( 'Ymd' ) == date( 'Ymd', $pString )) { return \Bitweaver\Plugins\smarty_modifier_bit_date_format( $pString, $gBitSystem->get_short_time_format(), '%H:%M %Z' ); - } else { - return \Bitweaver\Plugins\smarty_modifier_bit_date_format( $pString, $gBitSystem->get_short_datetime_format(), '%d %b %Y (%H:%M %Z)' ); } + return \Bitweaver\Plugins\smarty_modifier_bit_date_format( $pString, $gBitSystem->get_short_datetime_format(), '%d %b %Y (%H:%M %Z)' ); + } diff --git a/smartyplugins/modifier.cal_date_format.php b/smartyplugins/modifier.cal_date_format.php index b33381f..f213a35 100755 --- a/smartyplugins/modifier.cal_date_format.php +++ b/smartyplugins/modifier.cal_date_format.php @@ -1,5 +1,6 @@ <?php namespace Bitweaver\Plugins; + use Bitweaver\BitDate; /** @@ -30,7 +31,7 @@ function smarty_modifier_cal_date_format($string, $format = "%b %e, %Y", $defaul $mDate = new BitDate(0); $format = $mDate->get_display_offset() ? preg_replace("/ ?%Z/","",$format) - : preg_replace("/%Z/","UTC",$format); + : preg_replace("/%Z/","UTC",$format); $disptime = $mDate->getTimestampFromISO($string); diff --git a/smartyplugins/modifier.displayUrl.php b/smartyplugins/modifier.displayUrl.php index e5f424f..f6e8dc2 100755 --- a/smartyplugins/modifier.displayUrl.php +++ b/smartyplugins/modifier.displayUrl.php @@ -53,7 +53,7 @@ function smarty_modifier_displayUrl($pMixed, $lib='') { if (is_string($pMixed)) { if (empty($lib)) $lib ='BitPage'; if (smarty_modifier_displayUrl_findLib($lib)) { - $call =array($lib, 'getDisplayUrl'); + $call =[$lib, 'getDisplayUrl']; if (is_callable($call)) { return call_user_func($call,$pMixed); } diff --git a/smartyplugins/modifier.display_bytes.php b/smartyplugins/modifier.display_bytes.php index 284b793..9451471 100755 --- a/smartyplugins/modifier.display_bytes.php +++ b/smartyplugins/modifier.display_bytes.php @@ -18,7 +18,7 @@ namespace Bitweaver\Plugins; */ function smarty_modifier_display_bytes( $pSize, $pDecimalPlaces = 1 ) { $i = 0; - $iec = array( "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" ); + $iec = [ "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" ]; while( ( $pSize / 1024 ) > 1 ) { $pSize = $pSize / 1024; $i++; diff --git a/smartyplugins/modifier.display_duration.php b/smartyplugins/modifier.display_duration.php index 1b68722..9b3a77a 100755 --- a/smartyplugins/modifier.display_duration.php +++ b/smartyplugins/modifier.display_duration.php @@ -14,14 +14,14 @@ namespace Bitweaver\Plugins; * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure */ function smarty_modifier_display_duration( $pDuration ) { - $units = array( + $units = [ '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; diff --git a/smartyplugins/modifier.div.php b/smartyplugins/modifier.div.php index 27e5404..b13818d 100755 --- a/smartyplugins/modifier.div.php +++ b/smartyplugins/modifier.div.php @@ -7,7 +7,6 @@ namespace Bitweaver\Plugins; * @subpackage plugins */ - /** * Smarty plugin * ------------------------------------------------------------- @@ -19,7 +18,7 @@ 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); + return ceil(strlen($string)/$num); } /* vim: set expandtab: */ diff --git a/smartyplugins/modifier.duration.php b/smartyplugins/modifier.duration.php index 0d2fcc9..28cec79 100755 --- a/smartyplugins/modifier.duration.php +++ b/smartyplugins/modifier.duration.php @@ -11,7 +11,7 @@ namespace Bitweaver\Plugins; * @package Smarty * @subpackage plugins */ - + /** * Function body. * @@ -22,23 +22,23 @@ function smarty_modifier_duration($string) { $result=[]; if($string > 60*60*24) { - $days = floor($string/(60*60*24)); - $result[]="$days days"; - $string %= 60*60*24; + $days = floor($string/(60*60*24)); + $result[]="$days days"; + $string %= 60*60*24; } if($string > 60*60) { - $hours = floor($string/(60*60)); - $result[]="$hours hours"; - $string %= 60*60; + $hours = floor($string/(60*60)); + $result[]="$hours hours"; + $string %= 60*60; } if($string > 60) { - $mins = floor($string/60); - $result[]="$mins minutes"; - $string %= 60; + $mins = floor($string/60); + $result[]="$mins minutes"; + $string %= 60; } if($string > 0) { - $result[]="$string seconds"; + $result[]="$string seconds"; } - + return implode(' ',$result); } diff --git a/smartyplugins/modifier.htmlToText.php b/smartyplugins/modifier.htmlToText.php index eedea7e..b625134 100755 --- a/smartyplugins/modifier.htmlToText.php +++ b/smartyplugins/modifier.htmlToText.php @@ -7,7 +7,6 @@ namespace Bitweaver\Plugins; * @subpackage plugins */ - /** * Smarty htmlToText modifier plugin * diff --git a/smartyplugins/modifier.iconify.php b/smartyplugins/modifier.iconify.php index 571e246..64115b6 100755 --- a/smartyplugins/modifier.iconify.php +++ b/smartyplugins/modifier.iconify.php @@ -20,9 +20,8 @@ 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' />"; - } - + return "<img border='0' src='".IMG_PKG_URL."icn/{$string}.gif' alt='icon' class='icon' />"; + } + 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 index 86dae2a..b8ca8f5 100755 --- a/smartyplugins/modifier.nlbr.php +++ b/smartyplugins/modifier.nlbr.php @@ -18,5 +18,5 @@ namespace Bitweaver\Plugins; function smarty_modifier_nlbr($string) { return nl2br($string); - + } diff --git a/smartyplugins/modifier.plural.php b/smartyplugins/modifier.plural.php index 4e0f552..844215d 100755 --- a/smartyplugins/modifier.plural.php +++ b/smartyplugins/modifier.plural.php @@ -21,7 +21,7 @@ function smarty_modifier_plural($word = '', $counter = 0) # What to append to the word to make it plural? $plural_marker = 's'; - # Words ending in [ o ] + # Words ending in [ o ] if(preg_match('/o$/', $word)) { $plural_marker = 'es'; diff --git a/smartyplugins/modifier.quoted.php b/smartyplugins/modifier.quoted.php index c5dc911..a364f00 100755 --- a/smartyplugins/modifier.quoted.php +++ b/smartyplugins/modifier.quoted.php @@ -17,8 +17,8 @@ namespace Bitweaver\Plugins; */ function smarty_modifier_quoted($string) { - $string = str_replace("\n","\n>",$string); - return '>'.$string; + $string = str_replace("\n","\n>",$string); + return '>'.$string; } /* vim: set expandtab: */ diff --git a/smartyplugins/modifier.reltime.php b/smartyplugins/modifier.reltime.php index 57548ea..7b88c49 100755 --- a/smartyplugins/modifier.reltime.php +++ b/smartyplugins/modifier.reltime.php @@ -1,5 +1,6 @@ <?php namespace Bitweaver\Plugins; + use Bitweaver\KernelTools; /** @@ -49,9 +50,9 @@ function smarty_modifier_reltime( $pTimeStamp, $pMode = 'long', $pFallback = 'bi // hours if( $delta < $min * 2 ) { return KernelTools::tra( "one minute ago" ); - } else { - return round( $delta / $min )." ".KernelTools::tra( "minutes ago" ); } + return round( $delta / $min )." ".KernelTools::tra( "minutes ago" ); + } elseif( $delta < $day ) { // up to a day if( $delta < $hour * 1.1 ) { @@ -64,35 +65,33 @@ function smarty_modifier_reltime( $pTimeStamp, $pMode = 'long', $pFallback = 'bi 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 { + return floor( $delta / $hour )." hours {$delta_hours} minute ago"; + + } if( $delta_hours > 1 ){ return floor( $delta / $hour )." hour {$delta_hours} minutes ago"; - } else { - return floor( $delta / $hour )." hour {$delta_hours} minute ago"; } - } + return floor( $delta / $hour )." hour {$delta_hours} minute ago"; - } else { + } return round( $delta / $hour )." ".KernelTools::tra( "hour(s) ago" ); - } + } elseif( $delta < $week ) { // up to a week if( $delta < $day * 2 ) { return KernelTools::tra( "Yesterday" )." ".date( $strf, $pTimeStamp ); - } else { + } if( $pMode == 'short' ) { return date( 'D '.$strf, $pTimeStamp ); } return KernelTools::tra( date( 'l', $pTimeStamp ) )." ".date( $strf, $pTimeStamp ); - } - } else { + + } // anything longer than a week // $gBitSmarty->loadPlugin( "smarty_modifier_$pFallback" ); $pFallback = "Bitweaver\\Plugins\\smarty_modifier_$pFallback"; return $pFallback( $pTimeStamp ); - } + } diff --git a/smartyplugins/modifier.replace_limit.php b/smartyplugins/modifier.replace_limit.php index af60d0f..29c3a49 100755 --- a/smartyplugins/modifier.replace_limit.php +++ b/smartyplugins/modifier.replace_limit.php @@ -11,5 +11,5 @@ namespace Bitweaver\Plugins; * smarty_function_replace_limit */ function smarty_modifier_replace_limit( $pHaystack, $pNeedle, $pReplace, $pLimit ) { - return preg_replace('/'.str_replace('/', '\/', $pNeedle).'/', $pReplace, $pHaystack, $pLimit); + return preg_replace('/'.str_replace('/', '\/', $pNeedle).'/', $pReplace, $pHaystack, $pLimit); } diff --git a/smartyplugins/modifier.telephone_e164.php b/smartyplugins/modifier.telephone_e164.php index 5c37433..c82b292 100644 --- a/smartyplugins/modifier.telephone_e164.php +++ b/smartyplugins/modifier.telephone_e164.php @@ -14,10 +14,10 @@ function smarty_modifier_telephone_e164( $pTelephoneNumber, $pCountryCodeIso2='U global $gPhoneNumberUtil; if( empty( $gPhoneNumberUtil ) ) { spl_autoload_register(function ($class) { - // replace namespace separators with directory separators in the relative + // replace namespace separators with directory separators in the relative // class name, append with .php $class_path = str_replace('\\', '/', $class); - + $file = EXTERNAL_LIBS_PATH . $class_path . '.php'; // if the file exists, require it @@ -40,8 +40,7 @@ function smarty_modifier_telephone_e164( $pTelephoneNumber, $pCountryCodeIso2='U return $ret; } - -//$phonenumber = preg_replace(['/\D/', '/^0(?!0)/', '/^\+?0*((3[578]?|42?)\d)0*/'], +//$phonenumber = preg_replace(['/\D/', '/^0(?!0)/', '/^\+?0*((3[578]?|42?)\d)0*/'], // ['', '+49', '+$1'], $pTelephoneNumber ); /* diff --git a/smartyplugins/modifier.truncate.php b/smartyplugins/modifier.truncate.php index 2789e9f..3de2e20 100755 --- a/smartyplugins/modifier.truncate.php +++ b/smartyplugins/modifier.truncate.php @@ -7,7 +7,6 @@ namespace Bitweaver\Plugins; * @subpackage plugins */ - /** * Smarty truncate modifier plugin * @@ -42,7 +41,7 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_wo $etc .= "<span style='display:none;' id='dyn_".$divId."_edit'>".substr($string, strlen($fragment))."</span>"; } return $fragment.$etc; - } else + } return $string; } diff --git a/smartyplugins/outputfilter.groupslayout.php b/smartyplugins/outputfilter.groupslayout.php index 059048b..f3f747e 100755 --- a/smartyplugins/outputfilter.groupslayout.php +++ b/smartyplugins/outputfilter.groupslayout.php @@ -65,9 +65,9 @@ function smarty_outputfilter_groupslayout( $source, &$gBitSmarty ) { $source = preg_replace( $extractor, "@@@SMARTY:TRIM:CONTENT@@@", $source ); // Protect some parts - $patterns = array( - "!<script[^>]+>.*?</script>!is" => "@@@SMARTY:TRIM:SCRIPT@@@" - ); + $patterns = [ + "!<script[^>]+>.*?</script>!is" => "@@@SMARTY:TRIM:SCRIPT@@@", + ]; // ksort( $patterns ); @@ -94,8 +94,8 @@ function smarty_outputfilter_groupslayout( $source, &$gBitSmarty ) { // 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); + // Escape dollars in content so they don't back reference + $content = preg_replace('!\$!','\\\$', $content); $source = preg_replace( "!@@@SMARTY:TRIM:CONTENT@@@!", $content, $source, 1 ); } diff --git a/smartyplugins/outputfilter.highlight.php b/smartyplugins/outputfilter.highlight.php index ce29642..e8ebe97 100755 --- a/smartyplugins/outputfilter.highlight.php +++ b/smartyplugins/outputfilter.highlight.php @@ -76,7 +76,7 @@ function smarty_output_highlight( $source, $gBitSmarty ) { } // Wrap all the highlight words with a colourful span - $wordArr = array(); + $wordArr = []; $pattern = '#"([^"]*)"#'; if( preg_match_all( $pattern, $words, $ms ) ) { $wordArr = $ms[1]; diff --git a/smartyplugins/prefilter.tr.php b/smartyplugins/prefilter.tr.php index 01031fb..04fbbe5 100755 --- a/smartyplugins/prefilter.tr.php +++ b/smartyplugins/prefilter.tr.php @@ -20,7 +20,7 @@ function smarty_prefilter_tr( $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 + // 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 ) ) ); } @@ -55,22 +55,21 @@ function _translate_lang( $pKey ) { // 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 + // 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 + // 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 + // 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) @@ -80,8 +79,8 @@ function _translate_lang( $pKey ) { // 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._custom.php b/smartyplugins/resource._custom.php index 4046213..cdbac6d 100644 --- a/smartyplugins/resource._custom.php +++ b/smartyplugins/resource._custom.php @@ -1,5 +1,6 @@ <?php namespace Bitweaver\Plugins; + use Smarty\Resource\Smarty_Resource_Custom; /** @@ -46,10 +47,9 @@ class Smarty_Resource__Custom extends Smarty_Resource_Custom { $pTplTime = filemtime( $cacheFile ); } - protected function fetchTimestamp( $pTplName ) { + protected function fetchTimestamp( $pTplName ) { return null; } } - |
