@@ -2,6 +2,6 @@ |
||
| 2 | 2 | //implements Smarty 3 style {nocache}{/nocache} block to prevent caching of a section of a template. |
| 3 | 3 | //remove this upon upgrade to Smarty 3 |
| 4 | 4 | function smarty_block_nocache($param, $content, &$smarty) { |
| 5 | - return $content; |
|
| 5 | + return $content; |
|
| 6 | 6 | } |
| 7 | 7 | ?> |
| 8 | 8 | \ No newline at end of file |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | function smarty_function_html_radios($params, &$smarty) |
| 42 | 42 | { |
| 43 | - require_once $smarty->_get_plugin_filepath('shared','escape_special_chars'); |
|
| 43 | + require_once $smarty->_get_plugin_filepath('shared', 'escape_special_chars'); |
|
| 44 | 44 | |
| 45 | 45 | $name = 'radio'; |
| 46 | 46 | $values = null; |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | $output = null; |
| 53 | 53 | $extra = ''; |
| 54 | 54 | |
| 55 | - foreach($params as $_key => $_val) { |
|
| 56 | - switch($_key) { |
|
| 55 | + foreach ($params as $_key => $_val) { |
|
| 56 | + switch ($_key) { |
|
| 57 | 57 | case 'name': |
| 58 | 58 | case 'separator': |
| 59 | 59 | $$_key = (string)$_val; |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | case 'checked': |
| 63 | 63 | case 'selected': |
| 64 | - if(is_array($_val)) { |
|
| 65 | - $smarty->trigger_error('html_radios: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING); |
|
| 64 | + if (is_array($_val)) { |
|
| 65 | + $smarty->trigger_error('html_radios: the "'.$_key.'" attribute cannot be an array', E_USER_WARNING); |
|
| 66 | 66 | } else { |
| 67 | 67 | $selected = (string)$_val; |
| 68 | 68 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | break; |
| 92 | 92 | |
| 93 | 93 | default: |
| 94 | - if(!is_array($_val)) { |
|
| 94 | + if (!is_array($_val)) { |
|
| 95 | 95 | $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; |
| 96 | 96 | } else { |
| 97 | 97 | $smarty->trigger_error("html_radios: extra attribute '$_key' cannot be an array", E_USER_NOTICE); |
@@ -119,10 +119,10 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - if(!empty($params['assign'])) { |
|
| 122 | + if (!empty($params['assign'])) { |
|
| 123 | 123 | $smarty->assign($params['assign'], $_html_result); |
| 124 | 124 | } else { |
| 125 | - return implode("\n",$_html_result); |
|
| 125 | + return implode("\n", $_html_result); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | } |
@@ -130,25 +130,25 @@ discard block |
||
| 130 | 130 | function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids) { |
| 131 | 131 | $_output = ''; |
| 132 | 132 | if ($labels) { |
| 133 | - if($label_ids) { |
|
| 134 | - $_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!', '_', $name . '_' . $value)); |
|
| 135 | - $_output .= '<label for="' . $_id . '">'; |
|
| 133 | + if ($label_ids) { |
|
| 134 | + $_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!', '_', $name.'_'.$value)); |
|
| 135 | + $_output .= '<label for="'.$_id.'">'; |
|
| 136 | 136 | } else { |
| 137 | 137 | $_output .= '<label>'; |
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | $_output .= '<input type="radio" name="' |
| 141 | - . smarty_function_escape_special_chars($name) . '" value="' |
|
| 142 | - . smarty_function_escape_special_chars($value) . '"'; |
|
| 141 | + . smarty_function_escape_special_chars($name).'" value="' |
|
| 142 | + . smarty_function_escape_special_chars($value).'"'; |
|
| 143 | 143 | |
| 144 | - if ($labels && $label_ids) $_output .= ' id="' . $_id . '"'; |
|
| 144 | + if ($labels && $label_ids) $_output .= ' id="'.$_id.'"'; |
|
| 145 | 145 | |
| 146 | - if ((string)$value==$selected) { |
|
| 146 | + if ((string)$value == $selected) { |
|
| 147 | 147 | $_output .= ' checked="checked"'; |
| 148 | 148 | } |
| 149 | - $_output .= $extra . ' />' . $output; |
|
| 149 | + $_output .= $extra.' />'.$output; |
|
| 150 | 150 | if ($labels) $_output .= '</label>'; |
| 151 | - $_output .= $separator; |
|
| 151 | + $_output .= $separator; |
|
| 152 | 152 | |
| 153 | 153 | return $_output; |
| 154 | 154 | } |
@@ -100,15 +100,18 @@ discard block |
||
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - if (!isset($options) && !isset($values)) |
|
| 104 | - return ''; /* raise error here? */ |
|
| 103 | + if (!isset($options) && !isset($values)) { |
|
| 104 | + return ''; |
|
| 105 | + } |
|
| 106 | + /* raise error here? */ |
|
| 105 | 107 | |
| 106 | 108 | $_html_result = array(); |
| 107 | 109 | |
| 108 | 110 | if (isset($options)) { |
| 109 | 111 | |
| 110 | - foreach ($options as $_key=>$_val) |
|
| 111 | - $_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids); |
|
| 112 | + foreach ($options as $_key=>$_val) { |
|
| 113 | + $_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids); |
|
| 114 | + } |
|
| 112 | 115 | |
| 113 | 116 | } else { |
| 114 | 117 | |
@@ -141,13 +144,17 @@ discard block |
||
| 141 | 144 | . smarty_function_escape_special_chars($name) . '" value="' |
| 142 | 145 | . smarty_function_escape_special_chars($value) . '"'; |
| 143 | 146 | |
| 144 | - if ($labels && $label_ids) $_output .= ' id="' . $_id . '"'; |
|
| 147 | + if ($labels && $label_ids) { |
|
| 148 | + $_output .= ' id="' . $_id . '"'; |
|
| 149 | + } |
|
| 145 | 150 | |
| 146 | 151 | if ((string)$value==$selected) { |
| 147 | 152 | $_output .= ' checked="checked"'; |
| 148 | 153 | } |
| 149 | 154 | $_output .= $extra . ' />' . $output; |
| 150 | - if ($labels) $_output .= '</label>'; |
|
| 155 | + if ($labels) { |
|
| 156 | + $_output .= '</label>'; |
|
| 157 | + } |
|
| 151 | 158 | $_output .= $separator; |
| 152 | 159 | |
| 153 | 160 | return $_output; |
@@ -127,6 +127,14 @@ |
||
| 127 | 127 | |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | +/** |
|
| 131 | + * @param string $name |
|
| 132 | + * @param null|string $selected |
|
| 133 | + * @param string $extra |
|
| 134 | + * @param string $separator |
|
| 135 | + * @param boolean $labels |
|
| 136 | + * @param boolean $label_ids |
|
| 137 | + */ |
|
| 130 | 138 | function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids) { |
| 131 | 139 | $_output = ''; |
| 132 | 140 | if ($labels) { |
@@ -130,18 +130,18 @@ |
||
| 130 | 130 | function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids) { |
| 131 | 131 | $_output = ''; |
| 132 | 132 | if ($labels) { |
| 133 | - if($label_ids) { |
|
| 134 | - $_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!', '_', $name . '_' . $value)); |
|
| 135 | - $_output .= '<label for="' . $_id . '">'; |
|
| 136 | - } else { |
|
| 137 | - $_output .= '<label>'; |
|
| 138 | - } |
|
| 139 | - } |
|
| 140 | - $_output .= '<input type="radio" name="' |
|
| 133 | + if($label_ids) { |
|
| 134 | + $_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!', '_', $name . '_' . $value)); |
|
| 135 | + $_output .= '<label for="' . $_id . '">'; |
|
| 136 | + } else { |
|
| 137 | + $_output .= '<label>'; |
|
| 138 | + } |
|
| 139 | + } |
|
| 140 | + $_output .= '<input type="radio" name="' |
|
| 141 | 141 | . smarty_function_escape_special_chars($name) . '" value="' |
| 142 | 142 | . smarty_function_escape_special_chars($value) . '"'; |
| 143 | 143 | |
| 144 | - if ($labels && $label_ids) $_output .= ' id="' . $_id . '"'; |
|
| 144 | + if ($labels && $label_ids) $_output .= ' id="' . $_id . '"'; |
|
| 145 | 145 | |
| 146 | 146 | if ((string)$value==$selected) { |
| 147 | 147 | $_output .= ' checked="checked"'; |
@@ -53,28 +53,28 @@ |
||
| 53 | 53 | |
| 54 | 54 | function smarty_function_sugar_getimage($params, &$smarty) { |
| 55 | 55 | |
| 56 | - // error checking for required parameters |
|
| 57 | - if(!isset($params['name'])) |
|
| 58 | - $smarty->trigger_error($GLOBALS['app_strings']['ERR_MISSING_REQUIRED_FIELDS'] . 'name'); |
|
| 56 | + // error checking for required parameters |
|
| 57 | + if(!isset($params['name'])) |
|
| 58 | + $smarty->trigger_error($GLOBALS['app_strings']['ERR_MISSING_REQUIRED_FIELDS'] . 'name'); |
|
| 59 | 59 | |
| 60 | - // temp hack to deprecate the use of other_attributes |
|
| 61 | - if(isset($params['other_attributes'])) |
|
| 62 | - $params['attr'] = $params['other_attributes']; |
|
| 60 | + // temp hack to deprecate the use of other_attributes |
|
| 61 | + if(isset($params['other_attributes'])) |
|
| 62 | + $params['attr'] = $params['other_attributes']; |
|
| 63 | 63 | |
| 64 | - // set defaults |
|
| 65 | - if(!isset($params['attr'])) |
|
| 66 | - $params['attr'] = ''; |
|
| 67 | - if(!isset($params['width'])) |
|
| 68 | - $params['width'] = null; |
|
| 69 | - if(!isset($params['height'])) |
|
| 70 | - $params['height'] = null; |
|
| 71 | - if(!isset($params['alt'])) |
|
| 72 | - $params['alt'] = ''; |
|
| 64 | + // set defaults |
|
| 65 | + if(!isset($params['attr'])) |
|
| 66 | + $params['attr'] = ''; |
|
| 67 | + if(!isset($params['width'])) |
|
| 68 | + $params['width'] = null; |
|
| 69 | + if(!isset($params['height'])) |
|
| 70 | + $params['height'] = null; |
|
| 71 | + if(!isset($params['alt'])) |
|
| 72 | + $params['alt'] = ''; |
|
| 73 | 73 | |
| 74 | - // deprecated ? |
|
| 75 | - if(!isset($params['ext'])) |
|
| 76 | - $params['ext'] = null; |
|
| 74 | + // deprecated ? |
|
| 75 | + if(!isset($params['ext'])) |
|
| 76 | + $params['ext'] = null; |
|
| 77 | 77 | |
| 78 | - return SugarThemeRegistry::current()->getImage($params['name'], $params['attr'], $params['width'], $params['height'], $params['ext'], $params['alt']); |
|
| 78 | + return SugarThemeRegistry::current()->getImage($params['name'], $params['attr'], $params['width'], $params['height'], $params['ext'], $params['alt']); |
|
| 79 | 79 | } |
| 80 | 80 | ?> |
@@ -54,25 +54,25 @@ |
||
| 54 | 54 | function smarty_function_sugar_getimage($params, &$smarty) { |
| 55 | 55 | |
| 56 | 56 | // error checking for required parameters |
| 57 | - if(!isset($params['name'])) |
|
| 58 | - $smarty->trigger_error($GLOBALS['app_strings']['ERR_MISSING_REQUIRED_FIELDS'] . 'name'); |
|
| 57 | + if (!isset($params['name'])) |
|
| 58 | + $smarty->trigger_error($GLOBALS['app_strings']['ERR_MISSING_REQUIRED_FIELDS'].'name'); |
|
| 59 | 59 | |
| 60 | 60 | // temp hack to deprecate the use of other_attributes |
| 61 | - if(isset($params['other_attributes'])) |
|
| 61 | + if (isset($params['other_attributes'])) |
|
| 62 | 62 | $params['attr'] = $params['other_attributes']; |
| 63 | 63 | |
| 64 | 64 | // set defaults |
| 65 | - if(!isset($params['attr'])) |
|
| 65 | + if (!isset($params['attr'])) |
|
| 66 | 66 | $params['attr'] = ''; |
| 67 | - if(!isset($params['width'])) |
|
| 67 | + if (!isset($params['width'])) |
|
| 68 | 68 | $params['width'] = null; |
| 69 | - if(!isset($params['height'])) |
|
| 69 | + if (!isset($params['height'])) |
|
| 70 | 70 | $params['height'] = null; |
| 71 | - if(!isset($params['alt'])) |
|
| 71 | + if (!isset($params['alt'])) |
|
| 72 | 72 | $params['alt'] = ''; |
| 73 | 73 | |
| 74 | 74 | // deprecated ? |
| 75 | - if(!isset($params['ext'])) |
|
| 75 | + if (!isset($params['ext'])) |
|
| 76 | 76 | $params['ext'] = null; |
| 77 | 77 | |
| 78 | 78 | return SugarThemeRegistry::current()->getImage($params['name'], $params['attr'], $params['width'], $params['height'], $params['ext'], $params['alt']); |
@@ -54,26 +54,33 @@ |
||
| 54 | 54 | function smarty_function_sugar_getimage($params, &$smarty) { |
| 55 | 55 | |
| 56 | 56 | // error checking for required parameters |
| 57 | - if(!isset($params['name'])) |
|
| 58 | - $smarty->trigger_error($GLOBALS['app_strings']['ERR_MISSING_REQUIRED_FIELDS'] . 'name'); |
|
| 57 | + if(!isset($params['name'])) { |
|
| 58 | + $smarty->trigger_error($GLOBALS['app_strings']['ERR_MISSING_REQUIRED_FIELDS'] . 'name'); |
|
| 59 | + } |
|
| 59 | 60 | |
| 60 | 61 | // temp hack to deprecate the use of other_attributes |
| 61 | - if(isset($params['other_attributes'])) |
|
| 62 | - $params['attr'] = $params['other_attributes']; |
|
| 62 | + if(isset($params['other_attributes'])) { |
|
| 63 | + $params['attr'] = $params['other_attributes']; |
|
| 64 | + } |
|
| 63 | 65 | |
| 64 | 66 | // set defaults |
| 65 | - if(!isset($params['attr'])) |
|
| 66 | - $params['attr'] = ''; |
|
| 67 | - if(!isset($params['width'])) |
|
| 68 | - $params['width'] = null; |
|
| 69 | - if(!isset($params['height'])) |
|
| 70 | - $params['height'] = null; |
|
| 71 | - if(!isset($params['alt'])) |
|
| 72 | - $params['alt'] = ''; |
|
| 67 | + if(!isset($params['attr'])) { |
|
| 68 | + $params['attr'] = ''; |
|
| 69 | + } |
|
| 70 | + if(!isset($params['width'])) { |
|
| 71 | + $params['width'] = null; |
|
| 72 | + } |
|
| 73 | + if(!isset($params['height'])) { |
|
| 74 | + $params['height'] = null; |
|
| 75 | + } |
|
| 76 | + if(!isset($params['alt'])) { |
|
| 77 | + $params['alt'] = ''; |
|
| 78 | + } |
|
| 73 | 79 | |
| 74 | 80 | // deprecated ? |
| 75 | - if(!isset($params['ext'])) |
|
| 76 | - $params['ext'] = null; |
|
| 81 | + if(!isset($params['ext'])) { |
|
| 82 | + $params['ext'] = null; |
|
| 83 | + } |
|
| 77 | 84 | |
| 78 | 85 | return SugarThemeRegistry::current()->getImage($params['name'], $params['attr'], $params['width'], $params['height'], $params['ext'], $params['alt']); |
| 79 | 86 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | { |
| 29 | 29 | if ($smarty->debugging) { |
| 30 | 30 | $_params = array(); |
| 31 | - require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); |
|
| 31 | + require_once(SMARTY_CORE_DIR.'core.get_microtime.php'); |
|
| 32 | 32 | $_debug_start_time = smarty_core_get_microtime($_params, $smarty); |
| 33 | 33 | } |
| 34 | 34 | |
@@ -59,13 +59,13 @@ discard block |
||
| 59 | 59 | 'resource_base_path' => $smarty->config_dir, |
| 60 | 60 | 'get_source' => false); |
| 61 | 61 | $smarty->_parse_resource_name($_params); |
| 62 | - $_file_path = $_params['resource_type'] . ':' . $_params['resource_name']; |
|
| 62 | + $_file_path = $_params['resource_type'].':'.$_params['resource_name']; |
|
| 63 | 63 | if (isset($_section)) |
| 64 | 64 | $_compile_file = $smarty->_get_compile_path($_file_path.'|'.$_section); |
| 65 | 65 | else |
| 66 | 66 | $_compile_file = $smarty->_get_compile_path($_file_path); |
| 67 | 67 | |
| 68 | - if($smarty->force_compile || !file_exists($_compile_file)) { |
|
| 68 | + if ($smarty->force_compile || !file_exists($_compile_file)) { |
|
| 69 | 69 | $_compile = true; |
| 70 | 70 | } elseif ($smarty->compile_check) { |
| 71 | 71 | $_params = array('resource_name' => $_file, |
@@ -77,10 +77,10 @@ discard block |
||
| 77 | 77 | $_compile = false; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - if($_compile) { |
|
| 80 | + if ($_compile) { |
|
| 81 | 81 | // compile config file |
| 82 | - if(!is_object($smarty->_conf_obj)) { |
|
| 83 | - require_once SMARTY_DIR . $smarty->config_class . '.class.php'; |
|
| 82 | + if (!is_object($smarty->_conf_obj)) { |
|
| 83 | + require_once SMARTY_DIR.$smarty->config_class.'.class.php'; |
|
| 84 | 84 | $smarty->_conf_obj = new $smarty->config_class(); |
| 85 | 85 | $smarty->_conf_obj->overwrite = $smarty->config_overwrite; |
| 86 | 86 | $smarty->_conf_obj->booleanize = $smarty->config_booleanize; |
@@ -97,13 +97,13 @@ discard block |
||
| 97 | 97 | $smarty->_conf_obj->set_file_contents($_file, $_params['source_content']); |
| 98 | 98 | $_config_vars = array_merge($smarty->_conf_obj->get($_file), |
| 99 | 99 | $smarty->_conf_obj->get($_file, $_section)); |
| 100 | - if(function_exists('var_export')) { |
|
| 101 | - $_output = '<?php $_config_vars = ' . var_export($_config_vars, true) . '; ?>'; |
|
| 100 | + if (function_exists('var_export')) { |
|
| 101 | + $_output = '<?php $_config_vars = '.var_export($_config_vars, true).'; ?>'; |
|
| 102 | 102 | } else { |
| 103 | - $_output = '<?php $_config_vars = unserialize(\'' . strtr(serialize($_config_vars),array('\''=>'\\\'', '\\'=>'\\\\')) . '\'); ?>'; |
|
| 103 | + $_output = '<?php $_config_vars = unserialize(\''.strtr(serialize($_config_vars), array('\''=>'\\\'', '\\'=>'\\\\')).'\'); ?>'; |
|
| 104 | 104 | } |
| 105 | 105 | $_params = (array('compile_path' => $_compile_file, 'compiled_content' => $_output, 'resource_timestamp' => $_params['resource_timestamp'])); |
| 106 | - require_once(SMARTY_CORE_DIR . 'core.write_compiled_resource.php'); |
|
| 106 | + require_once(SMARTY_CORE_DIR.'core.write_compiled_resource.php'); |
|
| 107 | 107 | smarty_core_write_compiled_resource($_params, $smarty); |
| 108 | 108 | } else { |
| 109 | 109 | include($_compile_file); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | if ($smarty->debugging) { |
| 130 | 130 | $_params = array(); |
| 131 | - require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); |
|
| 131 | + require_once(SMARTY_CORE_DIR.'core.get_microtime.php'); |
|
| 132 | 132 | $smarty->_smarty_debug_info[] = array('type' => 'config', |
| 133 | 133 | 'filename' => $_file.' ['.$_section.'] '.$_scope, |
| 134 | 134 | 'depth' => $smarty->_inclusion_depth, |
@@ -60,10 +60,11 @@ |
||
| 60 | 60 | 'get_source' => false); |
| 61 | 61 | $smarty->_parse_resource_name($_params); |
| 62 | 62 | $_file_path = $_params['resource_type'] . ':' . $_params['resource_name']; |
| 63 | - if (isset($_section)) |
|
| 64 | - $_compile_file = $smarty->_get_compile_path($_file_path.'|'.$_section); |
|
| 65 | - else |
|
| 66 | - $_compile_file = $smarty->_get_compile_path($_file_path); |
|
| 63 | + if (isset($_section)) { |
|
| 64 | + $_compile_file = $smarty->_get_compile_path($_file_path.'|'.$_section); |
|
| 65 | + } else { |
|
| 66 | + $_compile_file = $smarty->_get_compile_path($_file_path); |
|
| 67 | + } |
|
| 67 | 68 | |
| 68 | 69 | if($smarty->force_compile || !file_exists($_compile_file)) { |
| 69 | 70 | $_compile = true; |
@@ -23,6 +23,7 @@ |
||
| 23 | 23 | * 'global' => overrides scope, setting to parent if true) |
| 24 | 24 | * </pre> |
| 25 | 25 | * @param Smarty |
| 26 | + * @param Smarty $smarty |
|
| 26 | 27 | */ |
| 27 | 28 | function smarty_function_config_load($params, &$smarty) |
| 28 | 29 | { |
@@ -56,8 +56,8 @@ discard block |
||
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | $_params = array('resource_name' => $_file, |
| 59 | - 'resource_base_path' => $smarty->config_dir, |
|
| 60 | - 'get_source' => false); |
|
| 59 | + 'resource_base_path' => $smarty->config_dir, |
|
| 60 | + 'get_source' => false); |
|
| 61 | 61 | $smarty->_parse_resource_name($_params); |
| 62 | 62 | $_file_path = $_params['resource_type'] . ':' . $_params['resource_name']; |
| 63 | 63 | if (isset($_section)) |
@@ -69,8 +69,8 @@ discard block |
||
| 69 | 69 | $_compile = true; |
| 70 | 70 | } elseif ($smarty->compile_check) { |
| 71 | 71 | $_params = array('resource_name' => $_file, |
| 72 | - 'resource_base_path' => $smarty->config_dir, |
|
| 73 | - 'get_source' => false); |
|
| 72 | + 'resource_base_path' => $smarty->config_dir, |
|
| 73 | + 'get_source' => false); |
|
| 74 | 74 | $_compile = $smarty->_fetch_resource_info($_params) && |
| 75 | 75 | $_params['resource_timestamp'] > filemtime($_compile_file); |
| 76 | 76 | } else { |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | $_params = array('resource_name' => $_file, |
| 92 | - 'resource_base_path' => $smarty->config_dir, |
|
| 93 | - $_params['get_source'] = true); |
|
| 92 | + 'resource_base_path' => $smarty->config_dir, |
|
| 93 | + $_params['get_source'] = true); |
|
| 94 | 94 | if (!$smarty->_fetch_resource_info($_params)) { |
| 95 | 95 | return; |
| 96 | 96 | } |
@@ -47,19 +47,19 @@ discard block |
||
| 47 | 47 | function smarty_function_sugar_evalcolumn_old($params, &$smarty) |
| 48 | 48 | { |
| 49 | 49 | if (!isset($params['var']) || !isset($params['rowData'])) { |
| 50 | - if(!isset($params['var'])) |
|
| 50 | + if (!isset($params['var'])) |
|
| 51 | 51 | $smarty->trigger_error("evalcolumn: missing 'var' parameter"); |
| 52 | - if(!isset($params['rowData'])) |
|
| 52 | + if (!isset($params['rowData'])) |
|
| 53 | 53 | $smarty->trigger_error("evalcolumn: missing 'rowData' parameter"); |
| 54 | 54 | return; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - if($params['var'] == '') { |
|
| 57 | + if ($params['var'] == '') { |
|
| 58 | 58 | return; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - if(is_array($params['var'])) { |
|
| 62 | - foreach($params['var'] as $key => $value) { |
|
| 61 | + if (is_array($params['var'])) { |
|
| 62 | + foreach ($params['var'] as $key => $value) { |
|
| 63 | 63 | $params['var'][$key] = searchReplace($value, $params['rowData']); |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | $params['var'] = searchReplace($params['var'], $params['rowData']); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - if(isset($params['toJSON'])) { |
|
| 70 | + if (isset($params['toJSON'])) { |
|
| 71 | 71 | $json = getJSONobj(); |
| 72 | 72 | $params['var'] = $json->encode($params['var']); |
| 73 | 73 | } |
@@ -82,8 +82,8 @@ discard block |
||
| 82 | 82 | function searchReplace($value, &$rowData) { |
| 83 | 83 | preg_match_all('/\{\$(.*)\}/U', $value, $matches); |
| 84 | 84 | |
| 85 | - for($wp = 0; $wp < count($matches[0]); $wp++) { |
|
| 86 | - if(isset($rowData[$matches[1][$wp]])) |
|
| 85 | + for ($wp = 0; $wp < count($matches[0]); $wp++) { |
|
| 86 | + if (isset($rowData[$matches[1][$wp]])) |
|
| 87 | 87 | $value = str_replace($matches[0][$wp], $rowData[$matches[1][$wp]], $value); |
| 88 | 88 | else |
| 89 | 89 | $value = str_replace($matches[0][$wp], '', $value); |
@@ -47,10 +47,12 @@ discard block |
||
| 47 | 47 | function smarty_function_sugar_evalcolumn_old($params, &$smarty) |
| 48 | 48 | { |
| 49 | 49 | if (!isset($params['var']) || !isset($params['rowData'])) { |
| 50 | - if(!isset($params['var'])) |
|
| 51 | - $smarty->trigger_error("evalcolumn: missing 'var' parameter"); |
|
| 52 | - if(!isset($params['rowData'])) |
|
| 53 | - $smarty->trigger_error("evalcolumn: missing 'rowData' parameter"); |
|
| 50 | + if(!isset($params['var'])) { |
|
| 51 | + $smarty->trigger_error("evalcolumn: missing 'var' parameter"); |
|
| 52 | + } |
|
| 53 | + if(!isset($params['rowData'])) { |
|
| 54 | + $smarty->trigger_error("evalcolumn: missing 'rowData' parameter"); |
|
| 55 | + } |
|
| 54 | 56 | return; |
| 55 | 57 | } |
| 56 | 58 | |
@@ -62,8 +64,7 @@ discard block |
||
| 62 | 64 | foreach($params['var'] as $key => $value) { |
| 63 | 65 | $params['var'][$key] = searchReplace($value, $params['rowData']); |
| 64 | 66 | } |
| 65 | - } |
|
| 66 | - else { |
|
| 67 | + } else { |
|
| 67 | 68 | $params['var'] = searchReplace($params['var'], $params['rowData']); |
| 68 | 69 | } |
| 69 | 70 | |
@@ -83,10 +84,11 @@ discard block |
||
| 83 | 84 | preg_match_all('/\{\$(.*)\}/U', $value, $matches); |
| 84 | 85 | |
| 85 | 86 | for($wp = 0; $wp < count($matches[0]); $wp++) { |
| 86 | - if(isset($rowData[$matches[1][$wp]])) |
|
| 87 | - $value = str_replace($matches[0][$wp], $rowData[$matches[1][$wp]], $value); |
|
| 88 | - else |
|
| 89 | - $value = str_replace($matches[0][$wp], '', $value); |
|
| 87 | + if(isset($rowData[$matches[1][$wp]])) { |
|
| 88 | + $value = str_replace($matches[0][$wp], $rowData[$matches[1][$wp]], $value); |
|
| 89 | + } else { |
|
| 90 | + $value = str_replace($matches[0][$wp], '', $value); |
|
| 91 | + } |
|
| 90 | 92 | } |
| 91 | 93 | return $value; |
| 92 | 94 | } |
@@ -40,12 +40,12 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | function smarty_function_sugar_replace_vars($params, &$smarty) |
| 42 | 42 | { |
| 43 | - if(empty($params['subject'])) { |
|
| 44 | - $smarty->trigger_error("sugarvar: missing 'subject' parameter"); |
|
| 45 | - return; |
|
| 46 | - } |
|
| 47 | - $fields = empty($params['fields']) ? $smarty->get_template_vars('fields') : $params['fields']; |
|
| 48 | - $lDelim = "["; |
|
| 43 | + if(empty($params['subject'])) { |
|
| 44 | + $smarty->trigger_error("sugarvar: missing 'subject' parameter"); |
|
| 45 | + return; |
|
| 46 | + } |
|
| 47 | + $fields = empty($params['fields']) ? $smarty->get_template_vars('fields') : $params['fields']; |
|
| 48 | + $lDelim = "["; |
|
| 49 | 49 | $rDelim = "]"; |
| 50 | 50 | if ($params['use_curly']) |
| 51 | 51 | { |
@@ -53,10 +53,10 @@ discard block |
||
| 53 | 53 | $rDelim = "}"; |
| 54 | 54 | } |
| 55 | 55 | $subject = $params['subject']; |
| 56 | - $matches = array(); |
|
| 57 | - $count = preg_match_all('/\\' . $lDelim . '([^\\' . $rDelim . ']*)\\' . $rDelim . '/', $subject, $matches); |
|
| 56 | + $matches = array(); |
|
| 57 | + $count = preg_match_all('/\\' . $lDelim . '([^\\' . $rDelim . ']*)\\' . $rDelim . '/', $subject, $matches); |
|
| 58 | 58 | for($i = 0; $i < $count; $i++) { |
| 59 | - $match = $matches[1][$i]; |
|
| 59 | + $match = $matches[1][$i]; |
|
| 60 | 60 | //List views will have fields be an array where all the keys are upper case and the values are jsut strings |
| 61 | 61 | if (!isset($fields[$match]) && isset($fields[strtoupper($match)])) |
| 62 | 62 | $match = strtoupper($match); |
@@ -74,21 +74,21 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | if (isset($fields[$match]['type']) && $fields[$match]['type']=='enum' |
| 77 | - && isset($fields[$match]['options']) && isset($fields[$match]['options'][$value])) |
|
| 78 | - { |
|
| 79 | - $subject = str_replace($matches[0][$i], $fields[$match]['options'][$value], $subject); |
|
| 80 | - } else |
|
| 81 | - { |
|
| 82 | - $subject = str_replace($matches[0][$i], $value, $subject); |
|
| 83 | - } |
|
| 84 | - } |
|
| 85 | - } |
|
| 77 | + && isset($fields[$match]['options']) && isset($fields[$match]['options'][$value])) |
|
| 78 | + { |
|
| 79 | + $subject = str_replace($matches[0][$i], $fields[$match]['options'][$value], $subject); |
|
| 80 | + } else |
|
| 81 | + { |
|
| 82 | + $subject = str_replace($matches[0][$i], $value, $subject); |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - if (!empty($params['assign'])) |
|
| 88 | - { |
|
| 89 | - $smarty->assign($params['assign'], $subject); |
|
| 90 | - return ''; |
|
| 91 | - } |
|
| 87 | + if (!empty($params['assign'])) |
|
| 88 | + { |
|
| 89 | + $smarty->assign($params['assign'], $subject); |
|
| 90 | + return ''; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - return $subject; |
|
| 93 | + return $subject; |
|
| 94 | 94 | } |
| 95 | 95 | \ No newline at end of file |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | function smarty_function_sugar_replace_vars($params, &$smarty) |
| 42 | 42 | { |
| 43 | - if(empty($params['subject'])) { |
|
| 43 | + if (empty($params['subject'])) { |
|
| 44 | 44 | $smarty->trigger_error("sugarvar: missing 'subject' parameter"); |
| 45 | 45 | return; |
| 46 | 46 | } |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | $subject = $params['subject']; |
| 56 | 56 | $matches = array(); |
| 57 | - $count = preg_match_all('/\\' . $lDelim . '([^\\' . $rDelim . ']*)\\' . $rDelim . '/', $subject, $matches); |
|
| 58 | - for($i = 0; $i < $count; $i++) { |
|
| 57 | + $count = preg_match_all('/\\'.$lDelim.'([^\\'.$rDelim.']*)\\'.$rDelim.'/', $subject, $matches); |
|
| 58 | + for ($i = 0; $i < $count; $i++) { |
|
| 59 | 59 | $match = $matches[1][$i]; |
| 60 | 60 | //List views will have fields be an array where all the keys are upper case and the values are jsut strings |
| 61 | 61 | if (!isset($fields[$match]) && isset($fields[strtoupper($match)])) |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | $value = $value['value']; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - if (isset($fields[$match]['type']) && $fields[$match]['type']=='enum' |
|
| 76 | + if (isset($fields[$match]['type']) && $fields[$match]['type'] == 'enum' |
|
| 77 | 77 | && isset($fields[$match]['options']) && isset($fields[$match]['options'][$value])) |
| 78 | 78 | { |
| 79 | 79 | $subject = str_replace($matches[0][$i], $fields[$match]['options'][$value], $subject); |
@@ -58,8 +58,9 @@ discard block |
||
| 58 | 58 | for($i = 0; $i < $count; $i++) { |
| 59 | 59 | $match = $matches[1][$i]; |
| 60 | 60 | //List views will have fields be an array where all the keys are upper case and the values are jsut strings |
| 61 | - if (!isset($fields[$match]) && isset($fields[strtoupper($match)])) |
|
| 62 | - $match = strtoupper($match); |
|
| 61 | + if (!isset($fields[$match]) && isset($fields[strtoupper($match)])) { |
|
| 62 | + $match = strtoupper($match); |
|
| 63 | + } |
|
| 63 | 64 | |
| 64 | 65 | $value = isset($fields[$match]) ? $fields[$match] : null; |
| 65 | 66 | if (!is_null($value)) { |
@@ -67,8 +68,7 @@ discard block |
||
| 67 | 68 | { |
| 68 | 69 | $bean = $smarty->get_template_vars('bean'); |
| 69 | 70 | $value = $bean->$match; |
| 70 | - } |
|
| 71 | - else if (is_array($value) && isset($value['value'])) |
|
| 71 | + } else if (is_array($value) && isset($value['value'])) |
|
| 72 | 72 | { |
| 73 | 73 | $value = $value['value']; |
| 74 | 74 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | function smarty_function_html_checkboxes($params, &$smarty) |
| 42 | 42 | { |
| 43 | - require_once $smarty->_get_plugin_filepath('shared','escape_special_chars'); |
|
| 43 | + require_once $smarty->_get_plugin_filepath('shared', 'escape_special_chars'); |
|
| 44 | 44 | |
| 45 | 45 | $name = 'checkbox'; |
| 46 | 46 | $values = null; |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | $extra = ''; |
| 54 | 54 | |
| 55 | - foreach($params as $_key => $_val) { |
|
| 56 | - switch($_key) { |
|
| 55 | + foreach ($params as $_key => $_val) { |
|
| 56 | + switch ($_key) { |
|
| 57 | 57 | case 'name': |
| 58 | 58 | case 'separator': |
| 59 | 59 | $$_key = $_val; |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | break; |
| 87 | 87 | |
| 88 | 88 | default: |
| 89 | - if(!is_array($_val)) { |
|
| 89 | + if (!is_array($_val)) { |
|
| 90 | 90 | $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; |
| 91 | 91 | } else { |
| 92 | 92 | $smarty->trigger_error("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE); |
@@ -115,10 +115,10 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - if(!empty($params['assign'])) { |
|
| 118 | + if (!empty($params['assign'])) { |
|
| 119 | 119 | $smarty->assign($params['assign'], $_html_result); |
| 120 | 120 | } else { |
| 121 | - return implode("\n",$_html_result); |
|
| 121 | + return implode("\n", $_html_result); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | } |
@@ -127,15 +127,15 @@ discard block |
||
| 127 | 127 | $_output = ''; |
| 128 | 128 | if ($labels) $_output .= '<label>'; |
| 129 | 129 | $_output .= '<input type="checkbox" name="' |
| 130 | - . smarty_function_escape_special_chars($name) . '[]" value="' |
|
| 131 | - . smarty_function_escape_special_chars($value) . '"'; |
|
| 130 | + . smarty_function_escape_special_chars($name).'[]" value="' |
|
| 131 | + . smarty_function_escape_special_chars($value).'"'; |
|
| 132 | 132 | |
| 133 | 133 | if (in_array((string)$value, $selected)) { |
| 134 | 134 | $_output .= ' checked="checked"'; |
| 135 | 135 | } |
| 136 | - $_output .= $extra . ' />' . $output; |
|
| 136 | + $_output .= $extra.' />'.$output; |
|
| 137 | 137 | if ($labels) $_output .= '</label>'; |
| 138 | - $_output .= $separator; |
|
| 138 | + $_output .= $separator; |
|
| 139 | 139 | |
| 140 | 140 | return $_output; |
| 141 | 141 | } |
@@ -95,16 +95,19 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if (!isset($options) && !isset($values)) |
|
| 99 | - return ''; /* raise error here? */ |
|
| 98 | + if (!isset($options) && !isset($values)) { |
|
| 99 | + return ''; |
|
| 100 | + } |
|
| 101 | + /* raise error here? */ |
|
| 100 | 102 | |
| 101 | 103 | settype($selected, 'array'); |
| 102 | 104 | $_html_result = array(); |
| 103 | 105 | |
| 104 | 106 | if (isset($options)) { |
| 105 | 107 | |
| 106 | - foreach ($options as $_key=>$_val) |
|
| 107 | - $_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels); |
|
| 108 | + foreach ($options as $_key=>$_val) { |
|
| 109 | + $_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels); |
|
| 110 | + } |
|
| 108 | 111 | |
| 109 | 112 | |
| 110 | 113 | } else { |
@@ -125,7 +128,9 @@ discard block |
||
| 125 | 128 | |
| 126 | 129 | function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels) { |
| 127 | 130 | $_output = ''; |
| 128 | - if ($labels) $_output .= '<label>'; |
|
| 131 | + if ($labels) { |
|
| 132 | + $_output .= '<label>'; |
|
| 133 | + } |
|
| 129 | 134 | $_output .= '<input type="checkbox" name="' |
| 130 | 135 | . smarty_function_escape_special_chars($name) . '[]" value="' |
| 131 | 136 | . smarty_function_escape_special_chars($value) . '"'; |
@@ -134,7 +139,9 @@ discard block |
||
| 134 | 139 | $_output .= ' checked="checked"'; |
| 135 | 140 | } |
| 136 | 141 | $_output .= $extra . ' />' . $output; |
| 137 | - if ($labels) $_output .= '</label>'; |
|
| 142 | + if ($labels) { |
|
| 143 | + $_output .= '</label>'; |
|
| 144 | + } |
|
| 138 | 145 | $_output .= $separator; |
| 139 | 146 | |
| 140 | 147 | return $_output; |
@@ -123,6 +123,12 @@ |
||
| 123 | 123 | |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | +/** |
|
| 127 | + * @param string $name |
|
| 128 | + * @param string $extra |
|
| 129 | + * @param string $separator |
|
| 130 | + * @param boolean $labels |
|
| 131 | + */ |
|
| 126 | 132 | function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels) { |
| 127 | 133 | $_output = ''; |
| 128 | 134 | if ($labels) $_output .= '<label>'; |
@@ -56,9 +56,9 @@ |
||
| 56 | 56 | */ |
| 57 | 57 | function smarty_function_sugar_getscript($params, &$smarty) |
| 58 | 58 | { |
| 59 | - if(!isset($params['file'])) { |
|
| 60 | - $smarty->trigger_error($GLOBALS['app_strings']['ERR_MISSING_REQUIRED_FIELDS'] . 'file'); |
|
| 61 | - } |
|
| 62 | - return getVersionedScript($params['file']); |
|
| 59 | + if(!isset($params['file'])) { |
|
| 60 | + $smarty->trigger_error($GLOBALS['app_strings']['ERR_MISSING_REQUIRED_FIELDS'] . 'file'); |
|
| 61 | + } |
|
| 62 | + return getVersionedScript($params['file']); |
|
| 63 | 63 | } |
| 64 | 64 | ?> |
| 65 | 65 | \ No newline at end of file |
@@ -43,8 +43,8 @@ |
||
| 43 | 43 | */ |
| 44 | 44 | function smarty_function_sugar_getjspath($params, &$smarty) |
| 45 | 45 | { |
| 46 | - if(!isset($params['file'])) { |
|
| 47 | - $smarty->trigger_error($GLOBALS['app_strings']['ERR_MISSING_REQUIRED_FIELDS'] . 'file'); |
|
| 46 | + if (!isset($params['file'])) { |
|
| 47 | + $smarty->trigger_error($GLOBALS['app_strings']['ERR_MISSING_REQUIRED_FIELDS'].'file'); |
|
| 48 | 48 | } |
| 49 | 49 | return getJSPath($params['file']); |
| 50 | 50 | } |
@@ -77,9 +77,9 @@ |
||
| 77 | 77 | function smarty_modifier_to_url($string) |
| 78 | 78 | { |
| 79 | 79 | if (preg_match('/^[^:\/]*:\/\/.*/', $string)) { |
| 80 | - return $string; |
|
| 80 | + return $string; |
|
| 81 | 81 | } else { |
| 82 | - return 'http://' . $string; |
|
| 82 | + return 'http://' . $string; |
|
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | |
@@ -79,7 +79,7 @@ |
||
| 79 | 79 | if (preg_match('/^[^:\/]*:\/\/.*/', $string)) { |
| 80 | 80 | return $string; |
| 81 | 81 | } else { |
| 82 | - return 'http://' . $string; |
|
| 82 | + return 'http://'.$string; |
|
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | |