popnoire/site/OFF_plugins/imagekit/lib/imagekit.php
2026-02-12 15:22:46 +01:00

73 lines
1.6 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace Kirby\Plugins\ImageKit;
use F;
use Obj;
use Str;
/**
* Utility class for retrieving information about the plugin
* version and its license.
*/
class ImageKit {
protected $version;
protected function __construct() {
// Just declared to prevent direct instantiation of this
// class (singleton pattern).
}
public static function instance() {
static $instance;
return ($instance ?: $instance = new static());
}
public function version() {
if(is_null($this->version)) {
$package = json_decode(f::read(dirname(__DIR__) . DS . 'package.json'));
$this->version = $package->version;
}
return $this->version;
}
public function root() {
return dirname(__DIR__);
}
public function license() {
$key = kirby()->option('imagekit.license');
$type = 'trial';
/**
* Hey there,
*
* if you have digged deep into Kirbys source code,
* than youve probably stumbled across a similiar
* message, asking you to be honest when using the
* software. I ask you the same, if your intention is to
* use ImageKit. Writing this plugin took a lot of time
* and it hopefully saves you a lot of headaches. If you
* would use a cloud-provider instead of rolling your own
* thumb engine, then your would also have to pay them.
*
* Anyway, have a nice day!
*
* Fabian
*/
if (str::startsWith($key, 'IMGKT1') && str::length($key) === 39) {
$type = 'ImageKit 1';
} else {
$key = null;
}
return new Obj(array(
'key' => $key,
'type' => $type,
));
}
}