Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code cleanup.
Browse files Browse the repository at this point in the history
parpalak committed Aug 5, 2024
1 parent 6e46eb4 commit 6c72da4
Showing 14 changed files with 38 additions and 57 deletions.
4 changes: 4 additions & 0 deletions _admin/js/editor.js
Original file line number Diff line number Diff line change
@@ -636,6 +636,10 @@ document.addEventListener('DOMContentLoaded', function () {
}
});

window.addEventListener('blur', function () {
altPressed = false;
});

isAltPressed = function () {
return altPressed;
}
2 changes: 1 addition & 1 deletion _admin/templates/layout.php.inc
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ if (!isset($this)) {
<script src="<?= $script ?>"></script>
<?php endforeach; ?>

<script src="lang/<?= $locale ?>/ui.js"></script>
<script src="<?php echo $basePath; ?>/_admin/lang/<?php echo $locale; ?>/ui.js"></script>
<style>:root {
--page-secondary-background: <?= $param('S2_ADMIN_COLOR') ?>;
}</style>
2 changes: 1 addition & 1 deletion _admin/templates/picture-manager.php.inc
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ $maxFileSize = $bytesFromString(ini_get('upload_max_filesize'))
<script src="<?php echo $basePath; ?>/_admin/js/jquery-tools.js"></script>
<script src="<?php echo $basePath; ?>/_admin/js/jquery.jstree.js"></script>
<script src="<?php echo $basePath; ?>/_admin/js/pictman.js"></script>
<script src="lang/<?= $locale ?>/ui.js"></script>
<script src="<?php echo $basePath; ?>/_admin/lang/<?php echo $locale; ?>/ui.js"></script>
</head>

<body>
3 changes: 2 additions & 1 deletion _admin/templates/structure/structure.php.inc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

/** @var callable $trans */
/** @var string $locale */
/** @var string $basePath */

?>
@@ -24,7 +25,7 @@
<div id="tree" class="treetree" tabindex="0"></div>
</section>
<script src="<?php echo $basePath; ?>/_admin/js/ajax.js"></script>
<script src="<?php echo $basePath; ?>/_admin/lang/<?php echo Lang::admin_code(); ?>/ui.js"></script>
<script src="<?php echo $basePath; ?>/_admin/lang/<?php echo $locale; ?>/ui.js"></script>
<script src="<?php echo $basePath; ?>/_admin/js/jquery.js"></script>
<script src="<?php echo $basePath; ?>/_admin/js/jquery-tools.js"></script>
<script src="<?php echo $basePath; ?>/_admin/js/jquery.jstree.js"></script>
2 changes: 1 addition & 1 deletion _extensions/s2_blog/Controller/TagsPageController.php
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ public function body(Request $request, HtmlTemplate $template): ?Response
if ($num) {
$tags[] = [
'title' => $tag_name[$id],
'link' => S2_BLOG_TAGS_PATH . urlencode($tag_url[$id]) . '/',
'link' => $this->blogUrlBuilder->tag($tag_url[$id]),
'num' => $num,
];
}
15 changes: 0 additions & 15 deletions _extensions/s2_blog/hooks/idx_start.php

This file was deleted.

13 changes: 0 additions & 13 deletions _include/Lang.php
Original file line number Diff line number Diff line change
@@ -54,19 +54,6 @@ public static function month ($month)
return $lang_month_big[$month - 1];
}

public static function friendly_filesize ($size)
{
$i = 0;
while (($size/1024) > 1)
{
$size /= 1024;
$i++;
}

$lang_filesize = self::get('File size units');
return sprintf(self::get('File size format'), self::number_format($size), $lang_filesize[$i]);
}

/**
* Outputs integers using current language settings
*
2 changes: 1 addition & 1 deletion _include/src/Image/ThumbnailGenerator.php
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ public function __construct(QueuePublisher $publisher, string $cacheUrlPrefix, s
{
$this->publisher = $publisher;
$this->cacheUrlPrefix = $cacheUrlPrefix;
$this->cacheFilesystemPrefix = $cacheFilesystemPrefix;
$this->cacheFilesystemPrefix = rtrim($cacheFilesystemPrefix, '/');
}

/**
7 changes: 5 additions & 2 deletions _include/src/Pdo/DbLayerPostgres.php
Original file line number Diff line number Diff line change
@@ -36,11 +36,14 @@ public function endTransaction(): void
}
}

public function query($sql, array $params = []): \PDOStatement
public function query($sql, array $params = [], array $types = []): \PDOStatement
{
$stmt = $this->pdo->prepare($sql);
try {
$stmt->execute($params);
foreach ($params as $key => $value) {
$stmt->bindValue($key, $value, $types[$key] ?? \PDO::PARAM_STR);
}
$stmt->execute();

return $stmt;
} catch (\PDOException $e) {
7 changes: 5 additions & 2 deletions _include/src/Pdo/DbLayerSqlite.php
Original file line number Diff line number Diff line change
@@ -33,11 +33,14 @@ public function endTransaction(): void
}
}

public function query($sql, array $params = []): \PDOStatement
public function query($sql, array $params = [], array $types = []): \PDOStatement
{
$stmt = $this->pdo->prepare($sql);
try {
$stmt->execute($params);
foreach ($params as $key => $value) {
$stmt->bindValue($key, $value, $types[$key] ?? \PDO::PARAM_STR);
}
$stmt->execute();

return $stmt;
} catch (\PDOException $e) {
6 changes: 3 additions & 3 deletions _include/src/Pdo/PDOStatement.php
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@
* 3. Updated code to PHP 8.2
*
* @copyright 2023-2024 Roman Parpalak, based on code (c) 2021 Filis Futsarov
* @license MIT
* @package S2
* @license MIT
* @package S2
*/

declare(strict_types=1);
@@ -40,7 +40,7 @@ public function bindParam(
int|string $param,
mixed &$var,
int $type = NativePdo::PARAM_STR,
int $maxLength = null,
int $maxLength = 0,
mixed $driverOptions = null
): bool {
$this->bindings[$param] = $var;
6 changes: 4 additions & 2 deletions _tests/integration/PicturesCest.php
Original file line number Diff line number Diff line change
@@ -270,9 +270,11 @@ public function testInvalidRenameFolder(\IntegrationTester $I): void

private function removeDir(string $dir): void
{
if (!is_dir($dir)) {
return;
}
$it = new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS);
$files = new \RecursiveIteratorIterator($it,
\RecursiveIteratorIterator::CHILD_FIRST);
$files = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::CHILD_FIRST);
foreach ($files as $file) {
if ($file->isDir()) {
rmdir($file->getPathname());
22 changes: 11 additions & 11 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
@@ -13,8 +13,6 @@
define('S2_ROOT', './');
require S2_ROOT . '_include/common.php';

($hook = s2_hook('idx_start')) ? eval($hook) : null;

header('X-Powered-By: S2/' . S2_VERSION);

// We create our own request URI with the path removed and only the parts to rewrite included
@@ -32,8 +30,6 @@
$_SERVER['REQUEST_URI'] = $request_uri;
}

($hook = s2_hook('idx_pre_redirect')) ? eval($hook) : null;

//
// Redirect to the admin page
//

0 comments on commit 6c72da4

Please sign in to comment.