Skip to content

Commit

Permalink
Merge pull request #259 from lat9/support-zc157-php81
Browse files Browse the repository at this point in the history
#256: MAJOR restructuring, now supporting zc157 and later
  • Loading branch information
lat9 committed Jul 30, 2022
2 parents db45d64 + 7e0fc81 commit 5c94654
Show file tree
Hide file tree
Showing 22 changed files with 612 additions and 673 deletions.
652 changes: 300 additions & 352 deletions YOUR_ADMIN/image_handler.php

Large diffs are not rendered by default.

98 changes: 36 additions & 62 deletions YOUR_ADMIN/image_handler_uninstall.php
@@ -1,22 +1,24 @@
<?php
// -----
// Part of the "Image Handler" plugin, v5.0.0 and later, by Cindy Merkin a.k.a. lat9 (cindy@vinosdefrutastropicales.com)
// Copyright (c) 2017-2019 Vinos de Frutas Tropicales
// Copyright (c) 2017-2022 Vinos de Frutas Tropicales
//
// Last updated: IH 5.3.0
//
require 'includes/application_top.php';

// -----
// If the admin has confirmed the removal of "Image Handler" ...
//
if (isset($_POST['action']) && $_POST['action'] == 'uninstall') {
if (isset($_POST['action']) && $_POST['action'] === 'uninstall') {
// -----
// Build up a list of files to be unconditionally removed.
//
// Note: The two template-override files are **not** removed. They do no harm and might
// be used by the Fual Slimbox or ColorBox plugins!
//
$files_to_remove = array(
'storefront' => array(
$files_to_remove = [
'storefront' => [
'auto_loaders/config.image_handler.php',
'classes/bmz_image_handler.class.php',
'classes/bmz_gif_info.class.php',
Expand All @@ -25,15 +27,16 @@
'extra_configures/bmz_io_conf.php',
'functions/extra_functions/functions_bmz_image_handler.php',
'functions/extra_functions/functions_bmz_io.php',
),
'template' => array(
],
'template' => [
'css/style_imagehover.css',
'jscript/jscript_imagehover.js',
),
'admin_includes' => array(
],
'admin_includes' => [
'ih_manager.php',
'auto_loaders/config.image_handler.php',
'classes/ImageHandlerAdmin.php',
'css/image_handler.css',
'extra_configures/bmz_image_handler_conf.php',
'extra_configures/bmz_io_conf.php',
'extra_datafiles/image_handler.php',
Expand All @@ -47,14 +50,14 @@
'languages/english/extra_definitions/bmz_image_handler.php',
'languages/english/extra_definitions/bmz_language_admin.php',
'languages/english/extra_definitions/image_handler_extra_definitions.php'
),
'admin_root' => array(
],
'admin_root' => [
'image_handler.php',
'image_handler_uninstall.php',
'image_handler_view_config.php'
),
);
],
];

// -----
// Now, see if either of the "large-image display" plugins are installed and, if not,
// remove the storefront observers loaded on their behalf.
Expand All @@ -67,7 +70,7 @@
$files_to_remove['storefront'][] = 'auto_loaders/config.colorbox.php';
$files_to_remove['storefront'][] = 'classes/observers/ColorBoxObserver.php';
}

// -----
// Remove those files ...
//
Expand Down Expand Up @@ -119,7 +122,7 @@
"DELETE FROM " . TABLE_ADMIN_PAGES . "
WHERE page_key IN ('configImageHandler4', 'toolsImageHandlerUninstall', 'toolsImageHandlerViewConfig' )"
);

// -----
// Set a message notifying the admin of the removal, note the change in the activity
// log and redirect back to the admin dashboard.
Expand All @@ -135,7 +138,7 @@
// first form-submittal, the admin is asked to confirm their removal request and on the next
// form-submittal, the file/configuration removal is actually performed.
//
if (!isset($_POST['action']) || $_POST['action'] != 'confirm') {
if (!isset($_POST['action']) || $_POST['action'] !== 'confirm') {
$next_action = 'confirm';
$current_message = TEXT_ARE_YOU_SURE;
} else {
Expand All @@ -146,54 +149,25 @@
<!doctype html>
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta charset="<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
<script src="includes/menu.js"></script>
<script src="includes/general.js"></script>
<script>
<!--
function init()
{
cssjsmenu('navbar');
if (document.getElementById)
{
var kill = document.getElementById('hoverJS');
kill.disabled = true;
}
}
// -->
</script>
<?php require DIR_WS_INCLUDES . 'admin_html_head.php'; ?>
</head>
<body onload="init()">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr>
<!-- body_text //-->
<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
<tr>
<td><?php echo zen_draw_form('remove', FILENAME_IMAGE_HANDLER_UNINSTALL) . zen_draw_hidden_field('action', $next_action);?>
<p><?php echo $current_message; ?></p>
<p><a href="<?php echo zen_href_link(FILENAME_DEFAULT); ?>" class="btn btn-warning"><?php echo IMAGE_CANCEL; ?></a>&nbsp;&nbsp;<input type="submit" class="btn btn-danger" value="<?php echo IMAGE_GO; ?>" /></p>
</form></td>
</tr>
</table></td>
</tr>
</table>
<!-- body_eof //-->
<!-- footer //-->
<?php
require DIR_WS_INCLUDES . 'footer.php';
?>
<!-- footer_eof //-->
<br>

<body>
<?php require DIR_WS_INCLUDES . 'header.php' ; ?>
<div class="container-fluid">
<h1><?php echo HEADING_TITLE; ?></h1>
<p><?php echo $current_message; ?></p>
<?php echo zen_draw_form('remove', FILENAME_IMAGE_HANDLER_UNINSTALL) . zen_draw_hidden_field('action', $next_action); ?>
<div class="row">
<a href="<?php echo zen_href_link(FILENAME_DEFAULT); ?>" class="btn btn-warning"><?php echo IMAGE_CANCEL; ?></a>
<input type="submit" class="btn btn-danger" value="<?php echo IMAGE_GO; ?>" />
</div>
<?php echo '</form>'; ?>

<?php require DIR_WS_INCLUDES . 'footer.php'; ?>
</div>
</body>

</html>
<?php
require DIR_WS_INCLUDES . 'application_bottom.php';
113 changes: 46 additions & 67 deletions YOUR_ADMIN/image_handler_view_config.php
@@ -1,7 +1,9 @@
<?php
// -----
// Part of the "Image Handler" plugin, v5.0.0 and later, by Cindy Merkin a.k.a. lat9 (cindy@vinosdefrutastropicales.com)
// Copyright (c) 2018-2021 Vinos de Frutas Tropicales
// Copyright (c) 2018-2022 Vinos de Frutas Tropicales
//
// Last updated: IH 5.3.0
//
require 'includes/application_top.php';

Expand All @@ -17,35 +19,9 @@
<!doctype html>
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta charset="<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" href="includes/stylesheet.css">
<link rel="stylesheet" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
<style>
th, td { padding: 0.5em; }
#ih-main { float: left; }
#ih-conf::after { clear: both; }
#ih-main tr:nth-child(even), #ih-conf tr:nth-child(even) {background: #ebebeb; }
.ih-group { background-color: #ccc; font-weight: bold; text-align: center; }
.ih-sub { text-align: right; }
tr.ih-error td:last-child { color: red; font-weight: bold; }
tr span { font-size: smaller; }
</style>
<script src="includes/menu.js"></script>
<script src="includes/general.js"></script>
<script>
function init()
{
cssjsmenu('navbar');
if (document.getElementById) {
var kill = document.getElementById('hoverJS');
kill.disabled = true;
}
}
</script>
<?php require DIR_WS_INCLUDES . 'admin_html_head.php'; ?>
</head>
<body onload="init();">
<!-- header //-->
<body>
<?php
require DIR_WS_INCLUDES . 'header.php';

Expand Down Expand Up @@ -94,14 +70,14 @@ function init()
'trans_threshold' => ['check' => CHECK_NONE],
'im_convert' => ['check' => CHECK_NONE],
'gdlib' => ['check' => CHECK_INTEGER],
'resize' => ['check' => CHECK_BOOLEAN],
'default' => [
'check' => CHECK_ARRAY,
'fields' => [
'bg' => ['check' => CHECK_BACKGROUND],
'quality' => ['check' => CHECK_QUALITY],
],
],
'resize' => ['check' => CHECK_BOOLEAN],
'dir' => [
'check' => CHECK_ARRAY,
'fields' => [
Expand Down Expand Up @@ -156,14 +132,14 @@ function init()
]
];
?>
<!-- header_eof //-->
<!-- body //-->
<h1><?php echo HEADING_TITLE; ?></h1>
<p><?php echo sprintf(INSTRUCTIONS, DIR_FS_CATALOG . 'includes/extra_configures/bmx_image_handler_conf.php', DIR_FS_CATALOG . 'includes/functions/extra_functions/functions_bmz_image_handler.php'); ?></p>
<table id="ih-main">
<tr>
<td colspan="3" class="ih-group"><?php echo sprintf(CONFIG_HEADING, zen_href_link(FILENAME_CONFIGURATION, 'gID=4')); ?></td>
</tr>
<div class="container-fluid">
<h1><?php echo HEADING_TITLE; ?></h1>
<p><?php echo sprintf(INSTRUCTIONS, DIR_FS_CATALOG . 'includes/extra_configures/bmx_image_handler_conf.php', DIR_FS_CATALOG . 'includes/functions/extra_functions/functions_bmz_image_handler.php'); ?></p>
<div class="col-md-6">
<table class="table table-striped">
<tr>
<th colspan="3" class="text-center"><?php echo sprintf(CONFIG_HEADING, zen_href_link(FILENAME_CONFIGURATION, 'gID=4')); ?></th>
</tr>
<?php
foreach ($config_values['configuration'] as $config_name => $config_options) {
$entry_error = false;
Expand All @@ -185,7 +161,7 @@ function init()
$config_link = $config_name;
} else {
$entry_title = $info->fields['configuration_title'];
$config_link = '<a href="' . zen_href_link(FILENAME_CONFIGURATION, 'gID=4&amp;cID=' . $info->fields['configuration_id'] . '&amp;action=edit') . '">' . $config_name . '</a>';
$config_link = '<a href="' . zen_href_link(FILENAME_CONFIGURATION, 'gID=4&cID=' . $info->fields['configuration_id'] . '&action=edit') . '">' . $config_name . '</a>';
}
$entry_message = '&nbsp;';
switch ($config_options['check']) {
Expand Down Expand Up @@ -221,19 +197,21 @@ function init()
}
}
?>
<tr<?php echo ($entry_error) ? ' class="ih-error"' : ''; ?>>
<td><?php echo $config_link; ?></td>
<td><?php echo $entry_title; ?></td>
<td><?php echo $entry_value; ?> <span><?php echo $entry_message; ?></span></td>
</tr>
<tr<?php echo ($entry_error) ? ' class="danger"' : ''; ?>>
<td><?php echo $config_link; ?></td>
<td><?php echo $entry_title; ?></td>
<td><?php echo $entry_value; ?> <span><?php echo $entry_message; ?></span></td>
</tr>
<?php
}
?>
</table>
<table id="ih-conf">
<tr>
<td colspan="2" class="ih-group">Values from the $ihConf array</td>
</tr>
</table>
</div>
<div class="col-md-6">
<table class="table table-striped">
<tr>
<th colspan="2" class="text-center">Values from the $ihConf array</th>
</tr>
<?php
foreach ($config_values['ihConf'] as $key => $values) {
$entry_error = false;
Expand Down Expand Up @@ -283,11 +261,10 @@ function init()
if (!is_array($entry_value)) {
$entry_error = true;
$entry_message = ERROR_NOT_ARRAY;
$entry_value = json_encode($entry_value);
} else {
$single_entry = false;
$entry_value = (isset($values['fields'])) ? '&nbsp;' : json_encode($entry_value);
$single_entry = !isset($values['fields']);
}
$entry_value = json_encode($entry_value);
break;
default:
break;
Expand All @@ -299,11 +276,16 @@ function init()
$entry_message = "($entry_message)";
}
?>
<tr<?php echo ($entry_error) ? ' class="ih-error"' : ''; ?>>
<td><?php echo '$ihConf[' . $key . ']'; ?></td>
<td><?php echo $entry_value; ?> <span><?php echo $entry_message; ?></span></td>
</tr>
<tr<?php echo ($entry_error) ? ' class="danger"' : ''; ?>>
<td<?php echo ($single_entry === true) ? '' : ' colspan="2" class="text-center info"'?>><?php echo '$ihConf[' . $key . ']'; ?></td>
<?php
if ($single_entry === true) {
?>
<td><?php echo $entry_value; ?> <span><?php echo $entry_message; ?></span></td>
</tr>
<?php
}

if (!$single_entry && isset($values['fields'])) {
foreach ($values['fields'] as $subkey => $subvalues) {
$subkey_value = $ihConf[$key][$subkey];
Expand Down Expand Up @@ -349,22 +331,19 @@ function init()
$entry_message = "($entry_message)";
}
?>
<tr<?php echo ($entry_error) ? ' class="ih-error"' : ''; ?>>
<td class="ih-sub"><?php echo $subkey; ?></td>
<td><?php echo ($subkey_value === true) ? 'true' : (($subkey_value === false) ? 'false' : $subkey_value); ?> <span><?php echo $entry_message; ?></span></td>
</tr>
<tr<?php echo ($entry_error) ? ' class="danger"' : ''; ?>>
<td><?php echo $subkey; ?></td>
<td><?php echo ($subkey_value === true) ? 'true' : (($subkey_value === false) ? 'false' : $subkey_value); ?> <span><?php echo $entry_message; ?></span></td>
</tr>
<?php
}
}
}
?>
</table>
<!-- body_eof //-->
<!-- footer //-->
<?php
require DIR_WS_INCLUDES . 'footer.php';
?>
<!-- footer_eof //-->
</table>
</div>
</div>
<?php require DIR_WS_INCLUDES . 'footer.php'; ?>
</body>
</html>
<?php
Expand Down
8 changes: 5 additions & 3 deletions YOUR_ADMIN/includes/auto_loaders/config.image_handler.php
@@ -1,7 +1,9 @@
<?php
// -----
// Part of the "Image Handler" plugin, v5.0.0 and later, by Cindy Merkin a.k.a. lat9 (cindy@vinosdefrutastropicales.com)
// Copyright (c) 2017 Vinos de Frutas Tropicales
// Copyright (c) 2017-2022 Vinos de Frutas Tropicales
//
// Last updated: IH 5.3.0
//
if (!defined('IS_ADMIN_FLAG') || IS_ADMIN_FLAG !== true) {
exit('Illegal Access');
Expand All @@ -10,7 +12,7 @@
// -----
// Load the plugin's initialization script.
//
$autoLoadConfig[199][] = array(
$autoLoadConfig[199][] = [
'autoType' => 'init_script',
'loadFile' => 'init_image_handler.php'
);
];

0 comments on commit 5c94654

Please sign in to comment.