Merge pull request #12009 from poush/fix_#12005
Templating toggleButton() and getDivForSliderEffect() (Fix #12005)
This commit is contained in:
commit
386cbc8f6c
@ -2862,26 +2862,11 @@ class Util
|
||||
*/
|
||||
public static function getDivForSliderEffect($id = '', $message = '')
|
||||
{
|
||||
if ($GLOBALS['cfg']['InitialSlidersState'] == 'disabled') {
|
||||
return '<div' . ($id ? ' id="' . $id . '"' : '') . '>';
|
||||
}
|
||||
/**
|
||||
* Bad hack on the next line. document.write() conflicts with jQuery,
|
||||
* hence, opening the <div> with PHP itself instead of JavaScript.
|
||||
*
|
||||
* @todo find a better solution that uses $.append(), the recommended
|
||||
* method maybe by using an additional param, the id of the div to
|
||||
* append to
|
||||
*/
|
||||
|
||||
return '<div'
|
||||
. ($id ? ' id="' . $id . '"' : '')
|
||||
. (($GLOBALS['cfg']['InitialSlidersState'] == 'closed')
|
||||
? ' style="display: none; overflow:auto;"'
|
||||
: '')
|
||||
. ' class="pma_auto_slider"'
|
||||
. ($message ? ' title="' . htmlspecialchars($message) . '"' : '')
|
||||
. '>';
|
||||
return Template::get('getDivForSliderEffect')->render([
|
||||
'id' => $id,
|
||||
'InitialSlidersState' => $GLOBALS['cfg']['InitialSlidersState'],
|
||||
'message' => $message,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2911,42 +2896,19 @@ class Util
|
||||
$state = 'on';
|
||||
}
|
||||
|
||||
// Generate output
|
||||
return "<!-- TOGGLE START -->\n"
|
||||
. "<div class='wrapper toggleAjax hide'>\n"
|
||||
. " <div class='toggleButton'>\n"
|
||||
. " <div title='" . __('Click to toggle')
|
||||
. "' class='container $state'>\n"
|
||||
. " <img src='" . htmlspecialchars($GLOBALS['pmaThemeImage'])
|
||||
. "toggle-" . htmlspecialchars($GLOBALS['text_dir']) . ".png'\n"
|
||||
. " alt='' />\n"
|
||||
. " <table class='nospacing nopadding'>\n"
|
||||
. " <tbody>\n"
|
||||
. " <tr>\n"
|
||||
. " <td class='toggleOn'>\n"
|
||||
. " <span class='hide'>$link_on</span>\n"
|
||||
. " <div>"
|
||||
. str_replace(' ', ' ', htmlspecialchars($options[1]['label']))
|
||||
. "\n" . " </div>\n"
|
||||
. " </td>\n"
|
||||
. " <td><div> </div></td>\n"
|
||||
. " <td class='toggleOff'>\n"
|
||||
. " <span class='hide'>$link_off</span>\n"
|
||||
. " <div>"
|
||||
. str_replace(' ', ' ', htmlspecialchars($options[0]['label']))
|
||||
. "\n" . " </div>\n"
|
||||
. " </tr>\n"
|
||||
. " </tbody>\n"
|
||||
. " </table>\n"
|
||||
. " <span class='hide callback'>"
|
||||
. htmlspecialchars($callback) . "</span>\n"
|
||||
. " <span class='hide text_direction'>"
|
||||
. htmlspecialchars($GLOBALS['text_dir']) . "</span>\n"
|
||||
. " </div>\n"
|
||||
. " </div>\n"
|
||||
. "</div>\n"
|
||||
. "<!-- TOGGLE END -->";
|
||||
|
||||
return Template::get('toggleButton')->render(
|
||||
[
|
||||
'pmaThemeImage' => $GLOBALS['pmaThemeImage'],
|
||||
'text_dir' => $GLOBALS['text_dir'],
|
||||
'link_on' => $link_on,
|
||||
'toggleOn' => str_replace(' ', ' ', htmlspecialchars(
|
||||
$options[1]['label'])),
|
||||
'toggleOff' => str_replace(' ', ' ', htmlspecialchars(
|
||||
$options[0]['label'])),
|
||||
'link_off' => $link_off,
|
||||
'callback' => $callback,
|
||||
'state' => $state
|
||||
]);
|
||||
} // end toggleButton()
|
||||
|
||||
/**
|
||||
|
||||
15
templates/getDivForSliderEffect.phtml
Normal file
15
templates/getDivForSliderEffect.phtml
Normal file
@ -0,0 +1,15 @@
|
||||
<?php if($InitialSlidersState == 'disabled'): ?>
|
||||
<div <?= $id? "id=\"$id\"": '' ?>>
|
||||
<?php else: ?>
|
||||
<?php /**
|
||||
* Bad hack on the next line. document.write() conflicts with jQuery,
|
||||
* hence, opening the <div> with PHP itself instead of JavaScript.
|
||||
*
|
||||
* @todo find a better solution that uses $.append(), the recommended
|
||||
* method maybe by using an additional param, the id of the div to
|
||||
* append to
|
||||
*/ ?>
|
||||
<div <?= $id? "id=\"$id\"": '' ?>
|
||||
<?= ($InitialSlidersState == 'closed')? ' style="display: none; overflow:auto;"':'' ?> class="pma_auto_slider"
|
||||
<?= $message? 'title="'. htmlspecialchars($message) . '"': ""?> >
|
||||
<?php endif; ?>
|
||||
27
templates/toggleButton.phtml
Normal file
27
templates/toggleButton.phtml
Normal file
@ -0,0 +1,27 @@
|
||||
<!-- TOGGLE START -->
|
||||
<div class='wrapper toggleAjax hide'>
|
||||
<div class='toggleButton'>
|
||||
<div title=" <?= __('Click to toggle') ?>" class='container <?=$state?>'>
|
||||
<img src="<?= htmlspecialchars($pmaThemeImage) ?>toggle-<?= htmlspecialchars($text_dir) ?>.png" alt='' />
|
||||
<table class='nospacing nopadding'>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class='toggleOn'>
|
||||
<span class='hide'><?= $link_on ?></span>
|
||||
<div><?= $toggleOn ?></div>
|
||||
</td>
|
||||
<td><div> </div></td>
|
||||
<td class='toggleOff'>
|
||||
<span class='hide'><?= $link_off ?></span>
|
||||
<div><?= $toggleOff ?></div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<span class='hide callback'><?= htmlspecialchars($callback) ?></span>
|
||||
<span class='hide text_direction'><?= $text_dir ?></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- TOGGLE END -->
|
||||
@ -35,8 +35,7 @@ class PMA_GetDivForSliderEffectTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
$this->assertEquals(
|
||||
PMA\libraries\Util::getDivForSliderEffect($id, $message),
|
||||
'<div id="' . $id . '" class="pma_auto_slider" title="'
|
||||
. htmlspecialchars($message) . '">'
|
||||
"<div id=\"$id\" class=\"pma_auto_slider\"\ntitle=\"" . htmlspecialchars($message) . "\" >"
|
||||
);
|
||||
}
|
||||
|
||||
@ -55,8 +54,7 @@ class PMA_GetDivForSliderEffectTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
$this->assertEquals(
|
||||
PMA\libraries\Util::getDivForSliderEffect($id, $message),
|
||||
'<div id="' . $id . '" style="display: none; overflow:auto;" '
|
||||
. 'class="pma_auto_slider" title="' . htmlspecialchars($message) . '">'
|
||||
"<div id=\"$id\" style=\"display: none; overflow:auto;\" class=\"pma_auto_slider\"\ntitle=\"" . htmlspecialchars($message) . "\" >"
|
||||
);
|
||||
|
||||
}
|
||||
@ -76,7 +74,7 @@ class PMA_GetDivForSliderEffectTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
$this->assertEquals(
|
||||
PMA\libraries\Util::getDivForSliderEffect($id, $message),
|
||||
'<div id="' . $id . '">'
|
||||
"<div id=\"$id\">"
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user