Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Craft 5 Compatibility #17

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
## 4.0.1 - 2024-03-19
### Fixed
- Escape unsafe HTML, this allows XML and HTML tags to display as text instead of render

## 3.0.6 - 2022-05-10
### Fixed
- Escape unsafe HTML, this allows XML and HTML tags to display as text instead of render

## 4.0.0 - 2022-07-11
### Changed
- Craft 4 release

## 3.0.5 - 2021-11-23
### Added
- Add truncate / delete buttons
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "ether/logs",
"description": "Access logs from the CP",
"version": "3.0.6",
"version": "4.0.1",
"type": "craft-plugin",
"minimum-stability": "dev",
"require": {
"craftcms/cms": "^3.0.0-RC1"
"craftcms/cms": "^4.0.0"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions src/Logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public function init ()

Event::on(
Utilities::class,
Utilities::EVENT_REGISTER_UTILITY_TYPES,
Utilities::EVENT_REGISTER_UTILITIES,
function (RegisterComponentTypesEvent $event) {
$event->types[] = Utility::class;
}
);
}

}
}
12 changes: 8 additions & 4 deletions src/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ class Service extends Component
public function truncate ($log)
{
$logsDir = Craft::getAlias('@storage/logs');
file_put_contents($logsDir . DIRECTORY_SEPARATOR . $log, '');
Craft::$app->getSession()->setNotice($log . ' truncated.');
$success = file_put_contents($logsDir . DIRECTORY_SEPARATOR . $log, '');

if ($success !== false) Craft::$app->getSession()->setNotice($log . ' truncated.');
else Craft::$app->getSession()->setError('Failed to truncate ' . $log . ', check file permissions');
}

public function delete ($log)
{
$logsDir = Craft::getAlias('@storage/logs');
unlink($logsDir . DIRECTORY_SEPARATOR . $log);
Craft::$app->getSession()->setNotice($log . ' deleted.');
$success = unlink($logsDir . DIRECTORY_SEPARATOR . $log);

if ($success !== false) Craft::$app->getSession()->setNotice($log . ' deleted.');
else Craft::$app->getSession()->setError('Failed to delete ' . $log . ', check file permissions');
}

}
2 changes: 1 addition & 1 deletion src/Utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static function id (): string
return 'logs';
}

public static function iconPath ()
public static function iconPath (): null|string
{
return Craft::getAlias('@ether/logs/utility_icon.svg');
}
Expand Down