convert optionhelp function to php file
This commit is contained in:
parent
e491f2ee76
commit
bc7cadcc73
|
@ -1,24 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
// HOW TO IMPLEMENT A NEW MODAL
|
|
||||||
// 1) Create a function in skins/classic/includes/functions that returns the desired modal HTML
|
|
||||||
// 2) Add a new entry to the switch case below that calls the new HTML function
|
|
||||||
// 3) Create a $j.getJSON Ajax call in js with the right parameters to retrieve the modal
|
|
||||||
// 4) Open the modal with $j('#myModal').modal('show')
|
|
||||||
//
|
|
||||||
// Should only report json
|
|
||||||
error_reporting(0);
|
|
||||||
|
|
||||||
if ( empty($_REQUEST['modal']) ) ajaxError('Modal Name Not Provided');
|
if ( empty($_REQUEST['modal']) ) {
|
||||||
|
ajaxError('Modal Name Not Provided');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
global $OLANG;
|
//global $OLANG;
|
||||||
$modal = validJsStr($_REQUEST['modal']);
|
$modal = validJsStr($_REQUEST['modal']);
|
||||||
$data = array();
|
$data = array();
|
||||||
|
|
||||||
switch ( $modal ) {
|
switch ( $modal ) {
|
||||||
case 'optionhelp' :
|
|
||||||
if ( empty($_REQUEST['ohndx']) ) ajaxError('Option Help Index Not Provided');
|
|
||||||
$data['html'] = getOptionHelpHTML($_REQUEST['ohndx'], $OLANG);
|
|
||||||
break;
|
|
||||||
case 'enoperm' :
|
case 'enoperm' :
|
||||||
$data['html'] = getENoPermHTML();
|
$data['html'] = getENoPermHTML();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,35 +1,43 @@
|
||||||
<div class="modal fade" id="filterdebugModal" data-backdrop="static" data-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
|
<?php
|
||||||
<div class="modal-dialog">
|
|
||||||
|
// Returns the modal html representing the selected Option Help item
|
||||||
|
if ( empty($_REQUEST['ohndx']) ) {
|
||||||
|
ajaxError('Option Help Index Not Provided');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
global $OLANG;
|
||||||
|
$result = '';
|
||||||
|
$optionHelpIndex = $_REQUEST['ohndx'];
|
||||||
|
$ZMoptionHelpIndex = 'ZM_'.$optionHelpIndex;
|
||||||
|
|
||||||
|
if ( !empty($OLANG[$optionHelpIndex]) ) {
|
||||||
|
$optionHelpText = $OLANG[$optionHelpIndex]['Help'];
|
||||||
|
} else {
|
||||||
|
$optionHelpText = dbFetchOne('SELECT Help FROM Config WHERE Name=?', 'Help', array($optionHelpIndex));
|
||||||
|
}
|
||||||
|
$optionHelpText = validHtmlStr($optionHelpText);
|
||||||
|
$optionHelpText = preg_replace('/~~/', '<br/>', $optionHelpText );
|
||||||
|
$optionHelpText = preg_replace('/\[(.+)\]\((.+)\)/', '<a href="$2" target="_blank">$1</a>', $optionHelpText);
|
||||||
|
|
||||||
|
?>
|
||||||
|
<div id="optionhelp" class="modal" tabindex="-1" role="dialog">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h5 class="modal-title"><?php echo translate('FilterDebug') ?></h5>
|
<h5 class="modal-title"><?php echo translate('OptionHelp') ?></h5>
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
<span aria-hidden="true">×</span>
|
<span aria-hidden="true">×</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<?php
|
<h3><?php echo validHtmlStr($optionHelpIndex) ?></h3>
|
||||||
//require_once('includes/Filter.php');
|
<p class="textblock"><?php echo $optionHelpText ?></p>
|
||||||
$fid = validInt($_REQUEST['fid']);
|
</div>
|
||||||
if ( !$fid ) {
|
|
||||||
echo '<div class="error">No filter id specified.</div>';
|
|
||||||
} else {
|
|
||||||
$filter = new ZM\Filter($_REQUEST['fid']);
|
|
||||||
if ( ! $filter->Id() ) {
|
|
||||||
echo '<div class="error">Filter not found for id '.$_REQUEST['fid'].'</div>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<form name="contentForm" id="filterdebugForm" method="post" action="?">
|
|
||||||
<?php
|
|
||||||
// We have to manually insert the csrf key into the form when using a modal generated via ajax call
|
|
||||||
echo getCSRFinputHTML();
|
|
||||||
?>
|
|
||||||
<p><label>SQL</label><?php echo $filter->sql() ?></p>
|
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="modal"><?php echo translate('Cancel')?> </button>
|
<button type="button" id="ohCloseBtn" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// Returns the modal html representing the selected Option Help item
|
||||||
|
if ( empty($_REQUEST['ohndx']) ) {
|
||||||
|
ajaxError('Option Help Index Not Provided');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
global $OLANG;
|
||||||
|
$result = '';
|
||||||
|
$optionHelpIndex = $_REQUEST['ohndx'];
|
||||||
|
$ZMoptionHelpIndex = 'ZM_'.$optionHelpIndex;
|
||||||
|
|
||||||
|
if ( !empty($OLANG[$optionHelpIndex]) ) {
|
||||||
|
$optionHelpText = $OLANG[$optionHelpIndex]['Help'];
|
||||||
|
} else {
|
||||||
|
$optionHelpText = dbFetchOne('SELECT Help FROM Config WHERE Name=?', 'Help', array($optionHelpIndex));
|
||||||
|
}
|
||||||
|
$optionHelpText = validHtmlStr($optionHelpText);
|
||||||
|
$optionHelpText = preg_replace('/~~/', '<br/>', $optionHelpText );
|
||||||
|
$optionHelpText = preg_replace('/\[(.+)\]\((.+)\)/', '<a href="$2" target="_blank">$1</a>', $optionHelpText);
|
||||||
|
|
||||||
|
?>
|
||||||
|
<div id="optionhelp" class="modal" tabindex="-1" role="dialog">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title"><?php echo translate('OptionHelp') ?></h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<h3><?php echo validHtmlStr($optionHelpIndex) ?></h3>
|
||||||
|
<p class="textblock"><?php echo $optionHelpText ?></p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" id="ohCloseBtn" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
|
@ -754,42 +754,6 @@ function runtimeStatus($running=null) {
|
||||||
return $running ? ($state ? $state : translate('Running')) : translate('Stopped');
|
return $running ? ($state ? $state : translate('Running')) : translate('Stopped');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the modal html representing the selected Option Help item
|
|
||||||
function getOptionHelpHTML($optionHelpIndex, $OLANG) {
|
|
||||||
$result = '';
|
|
||||||
$ZMoptionHelpIndex = 'ZM_'.$optionHelpIndex;
|
|
||||||
|
|
||||||
if ( !empty($OLANG[$optionHelpIndex]) ) {
|
|
||||||
$optionHelpText = $OLANG[$optionHelpIndex]['Help'];
|
|
||||||
} else {
|
|
||||||
$optionHelpText = dbFetchOne('SELECT Help FROM Config WHERE Name=?', 'Help', array($optionHelpIndex));
|
|
||||||
}
|
|
||||||
$optionHelpText = validHtmlStr($optionHelpText);
|
|
||||||
$optionHelpText = preg_replace('/~~/', '<br/>', $optionHelpText );
|
|
||||||
$optionHelpText = preg_replace('/\[(.+)\]\((.+)\)/', '<a href="$2" target="_blank">$1</a>', $optionHelpText);
|
|
||||||
|
|
||||||
$result .= '<div id="optionhelp" class="modal" tabindex="-1" role="dialog">'.PHP_EOL;
|
|
||||||
$result .= '<div class="modal-dialog" role="document">'.PHP_EOL;
|
|
||||||
$result .= '<div class="modal-content">'.PHP_EOL;
|
|
||||||
$result .= '<div class="modal-header">'.PHP_EOL;
|
|
||||||
$result .= '<h5 class="modal-title">' .translate('OptionHelp'). '</h5>'.PHP_EOL;
|
|
||||||
$result .= '<button type="button" class="close" data-dismiss="modal" aria-label="Close">'.PHP_EOL;
|
|
||||||
$result .= '<span aria-hidden="true">×</span>'.PHP_EOL;
|
|
||||||
$result .= '</button>'.PHP_EOL;
|
|
||||||
$result .= '</div>'.PHP_EOL;
|
|
||||||
$result .= '<div class="modal-body">'.PHP_EOL;
|
|
||||||
$result .= '<h3>' .validHtmlStr($optionHelpIndex). '</h3>'.PHP_EOL;
|
|
||||||
$result .= '<p class="textblock">' .$optionHelpText. '</p>'.PHP_EOL;
|
|
||||||
$result .= '</div>'.PHP_EOL;
|
|
||||||
$result .= '<div class="modal-footer">'.PHP_EOL;
|
|
||||||
$result .= '<button type="button" id="ohCloseBtn" class="btn btn-secondary" data-dismiss="modal">Close</button>'.PHP_EOL;
|
|
||||||
$result .= '</div>'.PHP_EOL;
|
|
||||||
$result .= '</div>'.PHP_EOL;
|
|
||||||
$result .= '</div>'.PHP_EOL;
|
|
||||||
$result .= '</div>'.PHP_EOL;
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return an Error No Permissions Modal
|
// Return an Error No Permissions Modal
|
||||||
function getENoPermHTML() {
|
function getENoPermHTML() {
|
||||||
$result = '';
|
$result = '';
|
||||||
|
|
Loading…
Reference in New Issue