Skip to content

Commit a24bcf5

Browse files
# Conflicts: # lib/ShortPixelWeb.php
2 parents e142090 + 63a71c3 commit a24bcf5

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

lib/ShortPixelWeb.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
namespace ShortPixelWeb;
88

9-
const WEB_VERSION = "1.0.1";
9+
const WEB_VERSION = "1.0.2";
1010

1111

1212
use ShortPixelWeb\XTemplate;
@@ -17,10 +17,12 @@ class ShortPixelWeb
1717
{
1818
private $settingsHandler;
1919
private $xtpl;
20+
private $basePath;
2021

2122
function __construct() {
2223
$this->xtpl = new XTemplate('main.html', __DIR__ . '/ShortPixelWeb/tpl');
2324
$this->settingsHandler = new \ShortPixel\Settings(dirname(__DIR__). '/shortpixel.ini');
25+
$this->basePath = str_replace(DIRECTORY_SEPARATOR, '/', dirname(dirname(__DIR__))); // get that damn separator straight on Windows too :))
2426
}
2527

2628
function bootstrap() {
@@ -74,8 +76,7 @@ function pathToRelative($path, $reference) {
7476
}
7577

7678
private function folderFullPath($folder) {
77-
$root = dirname(dirname(__DIR__));
78-
return rawurldecode($root.$folder );
79+
return rawurldecode($this->basePath . $folder );
7980
}
8081

8182
function renderFolderOptionsData($folder) {
@@ -180,6 +181,7 @@ function renderBrowseFolderFragment($folder, $multiSelect, $onlyFolders, $onlyFi
180181
$backupPath = $backupFolder . '/' . $file;
181182

182183
if($backupFolder && $backupUrl && file_exists($backupPath)) {
184+
<<<<<<< HEAD
183185
preg_match_all('#/#', $backupDir,$matches, PREG_OFFSET_CAPTURE);
184186
if(!empty($matches[0])) { //if a subfolder
185187
$start = $matches[0][0][1];
@@ -193,6 +195,9 @@ function renderBrowseFolderFragment($folder, $multiSelect, $onlyFolders, $onlyFi
193195
$originalUrl = $backupUrl . '/' . $backupDir .'/' . $file;
194196
}
195197

198+
=======
199+
$originalUrl = $backupUrl . '/' . $file; $optimizedUrl = $backupUrl . '/' . $file;
200+
>>>>>>> 63a71c3b46ea062883012eb7085df9d914610e3c
196201
echo "<a class='optimized-view' href='#' data-original='" . $originalUrl . "' data-optimized='" . $optimizedUrl . "' title='Compare images for " . $file . " (original vs. lossy)' style='display: inline;'>";
197202
echo "<span class='dashicons sp-eye-open' style='cursor:pointer;font-size:1.2em'></span>";
198203
echo "</a>";
@@ -240,7 +245,7 @@ function initJSConstants() {
240245
$username = $pwu_data['name'];
241246
}
242247
$this->xtpl->assign("current_os_user", $username);
243-
$this->xtpl->assign("shortpixel_os_path", dirname(dirname(__DIR__)));
248+
$this->xtpl->assign("shortpixel_os_path", $this->basePath); // get that damn separator straight on Windows too :))
244249
$this->xtpl->assign("shortpixel_api_key", $this->settingsHandler->get("API_KEY"));
245250
}
246251

@@ -267,7 +272,7 @@ function renderStartPage($messages) {
267272
function renderOptimizeNow($optData) {
268273
$folder = $optData['folder'];
269274
$exclude = array();
270-
$folderPath = $this->normalizePath(dirname(dirname(__DIR__)) . $folder);
275+
$folderPath = $this->normalizePath($this->basePath . $folder);
271276
if(!strlen($folder)) {
272277
$this->renderStartPage(array('error' => "Please select a folder."));
273278
return;
@@ -288,7 +293,7 @@ function renderOptimizeNow($optData) {
288293
}
289294
}
290295
$this->setupWrapper($folderPath);
291-
$status = \ShortPixel\folderInfo(dirname(dirname(__DIR__)) . $folder, true, false, $exclude);
296+
$status = \ShortPixel\folderInfo($this->basePath . $folder, true, false, $exclude);
292297
$this->xtpl->assign('folder', $folder);
293298

294299
if( $status->status !== 'error'
@@ -333,7 +338,7 @@ function optimizeAction($folder, $slice) {
333338
$timeLimit = 60;
334339
}
335340

336-
$folderPath = dirname(dirname(__DIR__)) . $folder;
341+
$folderPath = $this->basePath . $folder; // get that damn separator straight on Windows too :))
337342
$this->setupWrapper($folderPath);
338343
$slice = $slice ? $slice : \ShortPixel\ShortPixel::MAX_ALLOWED_FILES_PER_CALL;
339344

0 commit comments

Comments
 (0)