Readme file update
This commit is contained in:
211
ReadMe.md
211
ReadMe.md
@@ -22,25 +22,214 @@ Alternative setup composer local zip file repot:
|
||||
|
||||
## Install package
|
||||
|
||||
`composer require egrajp/smarty-extended:^4.3`
|
||||
`composer require egrajp/smarty-extended:^5`
|
||||
|
||||
## How to update
|
||||
|
||||
1) update the original composer for ^4.3
|
||||
2) copy over the src/sysplugins and all base files in src/
|
||||
3) check either function.html_checkboxes.php and function.html_options.php have changed
|
||||
4) copy src/plugins except the above two files, be sure to keep the block.t.php and function_popup*.php
|
||||
5) Create new release version as official relase number
|
||||
1) update the original composer for ^5
|
||||
2) copy over the following into `src/BlockHandler/`:
|
||||
1) T.php
|
||||
3) copy over the following into `src/FunctionHandler`:
|
||||
1) Popup.php
|
||||
2) PopupInit.php
|
||||
4) Upate the global `src/Extensions/DefaultExtension.php`:
|
||||
1) `getFunctionHandler`: popup_init, popup
|
||||
2) `getBlockHandler`: t
|
||||
5) check either `src/FunctionHander/HtmlCheckboxes.php` and `src/FunctionHander/HtmlOptions.php` have changed
|
||||
1) Update and leep the label/pos changes
|
||||
6) Create new release version as official relase number
|
||||
|
||||
## Updated files (different from master)
|
||||
|
||||
### New
|
||||
|
||||
`src/plugins/block.t.php`
|
||||
`src/plugins/function_popup.php`
|
||||
`src/plugins/function_popup.init.php`
|
||||
- `src/BlockHandler/T.php`
|
||||
- `src/FunctionHandler/Popup.php`
|
||||
- `src/FunctionHandler/PopupInit.php`
|
||||
|
||||
### Changed
|
||||
|
||||
`src/plugins/function.html_checkboxes.php`
|
||||
`src/plugins/function.html_options.php`
|
||||
- `src/FunctionHander/HtmlCheckboxes.php`
|
||||
|
||||
```diff
|
||||
--- Smarty/Smarty-git/src/FunctionHandler/HtmlCheckboxes.php 2024-04-16 18:06:25.299206501 +0900
|
||||
+++ core_data/composer-packages/Smarty-Extended/src/FunctionHandler/HtmlCheckboxes.php 2024-07-26 11:48:23.698784159 +0900
|
||||
@@ -24,6 +24,7 @@
|
||||
* - checked (optional) - array default not set
|
||||
* - separator (optional) - ie <br> or
|
||||
* - output (optional) - the output next to each checkbox
|
||||
+ * - pos (optional) - position entry into the [] for multi checkboxes
|
||||
* - assign (optional) - assign the output as an array to this variable
|
||||
* - escape (optional) - escape the content (not value), defaults to true
|
||||
*
|
||||
@@ -50,6 +51,7 @@
|
||||
$labels = true;
|
||||
$label_ids = false;
|
||||
$output = null;
|
||||
+ $pos = null;
|
||||
$extra = '';
|
||||
foreach ($params as $_key => $_val) {
|
||||
switch ($_key) {
|
||||
@@ -111,6 +113,9 @@
|
||||
);
|
||||
$options = (array)$_val;
|
||||
break;
|
||||
+ case 'pos':
|
||||
+ $$_key = array_values((array)$_val);
|
||||
+ break;
|
||||
case 'strict':
|
||||
case 'assign':
|
||||
break;
|
||||
@@ -145,6 +150,7 @@
|
||||
$_html_result = [];
|
||||
if (isset($options)) {
|
||||
foreach ($options as $_key => $_val) {
|
||||
+ $_pos = isset($pos[ $_key ]) ? $pos[ $_key ] : '';
|
||||
$_html_result[] =
|
||||
$this->getHtmlForInput(
|
||||
'checkbox',
|
||||
@@ -157,12 +163,14 @@
|
||||
$separator,
|
||||
$labels,
|
||||
$label_ids,
|
||||
+ $_pos,
|
||||
$escape
|
||||
);
|
||||
}
|
||||
} else {
|
||||
foreach ($values as $_i => $_key) {
|
||||
$_val = isset($output[$_i]) ? $output[$_i] : '';
|
||||
+ $_pos = isset($pos[ $_i ]) ? $pos[ $_i ] : '';
|
||||
$_html_result[] =
|
||||
$this->getHtmlForInput(
|
||||
'checkbox',
|
||||
@@ -175,6 +183,7 @@
|
||||
$separator,
|
||||
$labels,
|
||||
$label_ids,
|
||||
+ $_pos,
|
||||
$escape
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
- `src/FunctionHander/HtmlOptions.php`
|
||||
|
||||
```diff
|
||||
--- Smarty/Smarty-git/src/FunctionHandler/HtmlOptions.php 2024-04-16 18:06:25.299206501 +0900
|
||||
+++ core_data/composer-packages/Smarty-Extended/src/FunctionHandler/HtmlOptions.php 2024-07-26 11:51:13.287320709 +0900
|
||||
@@ -17,6 +17,7 @@
|
||||
* - selected (optional) - string default not set
|
||||
* - output (required) - if not options supplied) - array
|
||||
* - id (optional) - string default not set
|
||||
+ * - label (optional) - label strinng to set
|
||||
* - class (optional) - string default not set
|
||||
*
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
@@ -40,6 +41,7 @@
|
||||
$output = null;
|
||||
$id = null;
|
||||
$class = null;
|
||||
+ $label = true;
|
||||
$extra = '';
|
||||
foreach ($params as $_key => $_val) {
|
||||
switch ($_key) {
|
||||
@@ -89,6 +91,11 @@
|
||||
$selected = smarty_function_escape_special_chars((string)$_val);
|
||||
}
|
||||
break;
|
||||
+ case 'label':
|
||||
+ if ($_val == 'true' || $_val == 'false') {
|
||||
+ $$_key = (string)$_val;
|
||||
+ }
|
||||
+ break;
|
||||
case 'strict':
|
||||
break;
|
||||
case 'disabled':
|
||||
@@ -124,12 +131,12 @@
|
||||
$_idx = 0;
|
||||
if (isset($options)) {
|
||||
foreach ($options as $_key => $_val) {
|
||||
- $_html_result .= $this->output($_key, $_val, $selected, $id, $class, $_idx);
|
||||
+ $_html_result .= $this->output($_key, $_val, $selected, $id, $class, $label, $_idx);
|
||||
}
|
||||
} else {
|
||||
foreach ($values as $_i => $_key) {
|
||||
$_val = $output[$_i] ?? '';
|
||||
- $_html_result .= $this->output($_key, $_val, $selected, $id, $class, $_idx);
|
||||
+ $_html_result .= $this->output($_key, $_val, $selected, $id, $class, $label, $_idx);
|
||||
}
|
||||
}
|
||||
if (!empty($name)) {
|
||||
@@ -149,15 +156,20 @@
|
||||
* @param $selected
|
||||
* @param $id
|
||||
* @param $class
|
||||
+ * @param $label
|
||||
* @param $idx
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
- private function output($key, $value, $selected, $id, $class, &$idx)
|
||||
+ private function output($key, $value, $selected, $id, $class, $label, &$idx)
|
||||
{
|
||||
if (!is_array($value)) {
|
||||
$_key = smarty_function_escape_special_chars($key);
|
||||
- $_html_result = '<option value="' . $_key . '"';
|
||||
+ $_html_result = '<option'
|
||||
+ . ($label == 'true' ?
|
||||
+ ' label="' . smarty_function_escape_special_chars($value) . '"' : ''
|
||||
+ )
|
||||
+ . ' value="' . $_key . '"';
|
||||
if (is_array($selected)) {
|
||||
if (isset($selected[ $_key ])) {
|
||||
$_html_result .= ' selected="selected"';
|
||||
@@ -192,6 +204,7 @@
|
||||
$selected,
|
||||
!empty($id) ? ($id . '-' . $idx) : null,
|
||||
$class,
|
||||
+ $label,
|
||||
$_idx
|
||||
);
|
||||
$idx++;
|
||||
@@ -209,11 +222,11 @@
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
- private function getHtmlForOptGroup($key, $values, $selected, $id, $class, &$idx)
|
||||
+ private function getHtmlForOptGroup($key, $values, $selected, $id, $class, $label, &$idx)
|
||||
{
|
||||
$optgroup_html = '<optgroup label="' . smarty_function_escape_special_chars($key) . '">' . "\n";
|
||||
foreach ($values as $key => $value) {
|
||||
- $optgroup_html .= $this->output($key, $value, $selected, $id, $class, $idx);
|
||||
+ $optgroup_html .= $this->output($key, $value, $selected, $id, $class, $label, $idx);
|
||||
}
|
||||
$optgroup_html .= "</optgroup>\n";
|
||||
return $optgroup_html;
|
||||
```
|
||||
|
||||
### Updated
|
||||
|
||||
- `src/Extensions/DefaultExtension.php`
|
||||
|
||||
```diff
|
||||
--- Smarty/Smarty-git/src/Extension/DefaultExtension.php 2024-07-19 18:44:16.158700904 +0900
|
||||
+++ core_data/composer-packages/Smarty-Extended/src/Extension/DefaultExtension.php 2024-07-26 17:38:18.257179379 +0900
|
||||
@@ -94,6 +94,8 @@
|
||||
case 'html_table': $this->functionHandlers[$functionName] = new \Smarty\FunctionHandler\HtmlTable(); break;
|
||||
case 'mailto': $this->functionHandlers[$functionName] = new \Smarty\FunctionHandler\Mailto(); break;
|
||||
case 'math': $this->functionHandlers[$functionName] = new \Smarty\FunctionHandler\Math(); break;
|
||||
+ case 'popup_init': $this->functionHandlers[$functionName] = new \Smarty\FunctionHandler\PopupInit(); break;
|
||||
+ case 'popup': $this->functionHandlers[$functionName] = new \Smarty\FunctionHandler\Popup(); break;
|
||||
}
|
||||
|
||||
return $this->functionHandlers[$functionName] ?? null;
|
||||
@@ -103,6 +105,7 @@
|
||||
|
||||
switch ($blockTagName) {
|
||||
case 'textformat': $this->blockHandlers[$blockTagName] = new \Smarty\BlockHandler\TextFormat(); break;
|
||||
+ case 't': $this->blockHandlers[$blockTagName] = new \Smarty\BlockHandler\T(); break;
|
||||
}
|
||||
|
||||
return $this->blockHandlers[$blockTagName] ?? null;
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user