Skip to content

Commit

Permalink
Merge pull request #7 from wouterverstuyf/master
Browse files Browse the repository at this point in the history
Fork v5 update (minor tweaks, no rewrite of code)
  • Loading branch information
jeroendesloovere authored Oct 19, 2018
2 parents cdec963 + faec748 commit 68bb46e
Show file tree
Hide file tree
Showing 20 changed files with 177 additions and 202 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
3.0.0 (2018-10-19)
--
* Upgrade to Fork CMS v5 (minor tweaks so it works, no complete rewrite of the code)

2.0.0 (2016-06-19)
--
* Upgrade to Fork CMS v4 with Twig template support
Expand Down
2 changes: 1 addition & 1 deletion VERSION.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0
3.0.0
31 changes: 14 additions & 17 deletions src/Backend/Modules/Compression/Actions/Settings.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
namespace Backend\Modules\Compression\Actions;

use Backend\Core\Engine\Base\ActionEdit as BackendBaseActionEdit;
use Backend\Core\Engine\Language;
use Backend\Core\Language\Language as BL;
use Backend\Core\Engine\Model as BackendModel;
use Backend\Core\Engine\Form as BackendForm;
use Backend\Core\Engine\Language as BL;
use Backend\Modules\Compression\Engine\Helper;
use Backend\Modules\Compression\Engine\Model as BackendCompressionModel;
use Symfony\Component\HttpKernel\KernelInterface;
Expand Down Expand Up @@ -71,7 +70,7 @@ public function __construct(KernelInterface $kernel)
/**
* Execute the action
*/
public function execute()
public function execute(): void
{
parent::execute();
$this->getCompressionParameters();
Expand All @@ -82,9 +81,9 @@ public function execute()
/**
* Get the api key
*/
private function getCompressionParameters()
private function getCompressionParameters(): void
{
$removeAction = $this->getParameter('remove');
$removeAction = $this->getRequest()->query->get('remove');

// We need to remove the api key
if (!empty($removeAction)) {
Expand All @@ -103,7 +102,7 @@ private function getCompressionParameters()
/**
* Load the compression settings form
*/
private function loadCompressionSettingsForm()
private function loadCompressionSettingsForm(): void
{
// Create compression folder form
$this->frmCompressionSettings = new BackendForm('compression');
Expand All @@ -121,7 +120,7 @@ private function loadCompressionSettingsForm()
if (isset($_POST['folders']) && is_array($_POST['folders'])) {
foreach ($_POST['folders'] as $folder) {
$this->folders[] = array(
'path' => (string) $folder,
'path' => (string)$folder,
'created_on' => BackendModel::getUTCDate()
);
}
Expand All @@ -132,7 +131,7 @@ private function loadCompressionSettingsForm()
/**
* Validates the compression settings form.
*/
private function validateCompressionSettingsForm()
private function validateCompressionSettingsForm(): void
{
if ($this->frmCompressionSettings->isSubmitted()) {
if ($this->frmCompressionSettings->isCorrect()) {
Expand All @@ -145,8 +144,6 @@ private function validateCompressionSettingsForm()
BackendCompressionModel::insertFolders($this->folders);
}
}

BackendModel::triggerEvent($this->getModule(), 'after_saved_settings');
$this->redirect(BackendModel::createURLForAction('Settings') . '&report=saved');
}
}
Expand All @@ -155,7 +152,7 @@ private function validateCompressionSettingsForm()
/**
* Parse the form
*/
protected function parse()
protected function parse(): void
{
parent::parse();

Expand All @@ -166,7 +163,7 @@ protected function parse()
// Create api key form
if (!isset($this->apiKey)) {
$this->frmApiKey = new BackendForm('settings');
$this->frmApiKey->addText('key', $this->apiKey)->setAttribute('placeholder', Language::lbl('YourApiKey'));
$this->frmApiKey->addText('key', $this->apiKey)->setAttribute('placeholder', BL::lbl('YourApiKey'));

if ($this->frmApiKey->isSubmitted()) {
$this->frmApiKey->getField('key')->isFilled(BL::err('FieldIsRequired'));
Expand All @@ -179,21 +176,21 @@ protected function parse()
}

// Parse the form into the template
$this->frmApiKey->parse($this->tpl);
$this->frmApiKey->parse($this->template);
}

// Show the actual settings form
if (isset($this->apiKey)) {
$this->loadCompressionSettingsForm();
$this->tpl->assign('directoryTree', $this->directoryTreeHtml);
$this->template->assign('directoryTree', $this->directoryTreeHtml);
$this->validateCompressionSettingsForm();

// Parse the form into the template
$this->frmCompressionSettings->parse($this->tpl);
$this->frmCompressionSettings->parse($this->template);
}

// Show the API key form if we don't have one set
$this->tpl->assign('apiKey', $this->apiKey);
$this->tpl->assign('folders', array_merge($this->savedDirectories, $this->folders));
$this->template->assign('apiKey', $this->apiKey);
$this->template->assign('folders', array_merge($this->savedDirectories, $this->folders));
}
}
9 changes: 5 additions & 4 deletions src/Backend/Modules/Compression/Ajax/ConsoleErase.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Backend\Core\Engine\Base\AjaxAction as BackendBaseAJAXAction;
use Backend\Modules\Compression\Engine\Model as BackendCompressionModel;
use SpoonFilter;
use Symfony\Component\HttpFoundation\Response;

/**
* This is the console ajax action that will erase the cache file
Expand All @@ -16,15 +16,16 @@ class ConsoleErase extends BackendBaseAJAXAction
/**
* Execute the action
*/
public function execute()
public function execute(): void
{
parent::execute();

$overwrite = (bool) SpoonFilter::getPostValue('overwrite', null, '');
$overwrite = $this->getRequest()->request->get('overwrite', '');
if ($overwrite) {
BackendCompressionModel::writeToCacheFile('');
}

$this->output(self::OK);
// output
$this->output(Response::HTTP_OK);
}
}
7 changes: 4 additions & 3 deletions src/Backend/Modules/Compression/Ajax/StartCompression.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Backend\Core\Engine\Model as BackendModel;
use Backend\Modules\Compression\Engine\Model as BackendCompressionModel;
use Backend\Modules\Compression\Engine\TinyPNGApi;
use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpFoundation\Response;

/**
* This is the console ajax action
Expand All @@ -32,7 +32,7 @@ class StartCompression extends BackendBaseAJAXAction
/**
* Execute the action
*/
public function execute()
public function execute(): void
{
parent::execute();

Expand Down Expand Up @@ -79,6 +79,7 @@ public function execute()
BackendCompressionModel::writeToCacheFile("There are no images that can be compressed.", true);
}

$this->output(self::OK);
// output
$this->output(Response::HTTP_OK);
}
}
Empty file modified src/Backend/Modules/Compression/Config.php
100644 → 100755
Empty file.
Empty file modified src/Backend/Modules/Compression/Cronjobs/CompressImages.php
100644 → 100755
Empty file.
Empty file modified src/Backend/Modules/Compression/Engine/Helper.php
100644 → 100755
Empty file.
Empty file modified src/Backend/Modules/Compression/Engine/Model.php
100644 → 100755
Empty file.
Empty file modified src/Backend/Modules/Compression/Engine/TinyPNGApi.php
100644 → 100755
Empty file.
Empty file modified src/Backend/Modules/Compression/Engine/cacert.pem
100644 → 100755
Empty file.
Empty file modified src/Backend/Modules/Compression/Installer/Data/install.sql
100644 → 100755
Empty file.
Empty file modified src/Backend/Modules/Compression/Installer/Data/locale.xml
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions src/Backend/Modules/Compression/Installer/Installer.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Installer extends ModuleInstaller
/**
* Insert an empty admin dashboard sequence
*/
private function addDashboardWidget()
private function addDashboardWidget(): void
{
$compressionWidget = array(
'column' => 'middle',
Expand All @@ -29,7 +29,7 @@ private function addDashboardWidget()
/**
* Install the module
*/
public function install()
public function install(): void
{
$this->addModule('Compression');

Expand Down
5 changes: 4 additions & 1 deletion src/Backend/Modules/Compression/Js/Compression.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ jsBackend.compression =
// Erase logfile and console first
$.ajax({
data: {
fork: { module: 'Compression', action: 'ConsoleErase' }
fork: {
module: 'Compression',
action: 'ConsoleErase'
}
},
success: function (result) {
if (result.code === 200) {
Expand Down
Empty file modified src/Backend/Modules/Compression/Layout/Css/Compression.css
100644 → 100755
Empty file.
Loading

0 comments on commit 68bb46e

Please sign in to comment.