Syntax update
This commit is contained in:
parent
9cf0ad70d5
commit
205a8e96b3
2 changed files with 23 additions and 16 deletions
|
|
@ -2,16 +2,16 @@
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
/** @var ReadingTimeExtension $this */
|
/** @var ReadingTimeExtension $this */
|
||||||
?>
|
?>
|
||||||
<form action="<?php echo _url('extension', 'configure', 'e', urlencode($this->getName())); ?>" method="post">
|
<form action="<?= _url('extension', 'configure', 'e', urlencode($this->getName())) ?>" method="post">
|
||||||
<input type="hidden" name="_csrf" value="<?php echo FreshRSS_Auth::csrfToken(); ?>" />
|
<input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" />
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="group-name" for="reading_time_speed"><?php echo _t('ext.reading_time.speed.label'); ?></label>
|
<label class="group-name" for="reading_time_speed"><?= _t('ext.reading_time.speed.label') ?></label>
|
||||||
<div class="group-controls">
|
<div class="group-controls">
|
||||||
<input type="number" id="reading_time_speed" name="reading_time_speed" value="<?= $this->getSpeed() ?>" min="1">
|
<input type="number" id="reading_time_speed" name="reading_time_speed" value="<?= $this->getSpeed() ?>" min="1">
|
||||||
<p class="help"><?= _i('help') ?> <?= _t('ext.reading_time.speed.help') ?></p>
|
<p class="help"><?= _i('help') ?> <?= _t('ext.reading_time.speed.help') ?></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<label class="group-name" for="reading_time_speed"><?php echo _t('ext.reading_time.metrics.label'); ?></label>
|
<label class="group-name" for="reading_time_speed"><?= _t('ext.reading_time.metrics.label') ?></label>
|
||||||
<div class="group-controls">
|
<div class="group-controls">
|
||||||
<select name="reading_time_metrics" id="reading_time_metrics" data-leave-validation="<?= $this->getMetrics() ?>">
|
<select name="reading_time_metrics" id="reading_time_metrics" data-leave-validation="<?= $this->getMetrics() ?>">
|
||||||
<option value="words"<?= $this->getMetrics() === 'words' ? ' selected="selected"' : '' ?>><?= _t('ext.reading_time.metrics.words') ?></option>
|
<option value="words"<?= $this->getMetrics() === 'words' ? ' selected="selected"' : '' ?>><?= _t('ext.reading_time.metrics.words') ?></option>
|
||||||
|
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
<div class="form-group form-actions">
|
<div class="form-group form-actions">
|
||||||
<div class="group-controls">
|
<div class="group-controls">
|
||||||
<button type="submit" class="btn btn-important"><?php echo _t('gen.action.submit'); ?></button>
|
<button type="submit" class="btn btn-important"><?= _t('gen.action.submit') ?></button>
|
||||||
<button type="reset" class="btn"><?php echo _t('gen.action.cancel'); ?></button>
|
<button type="reset" class="btn"><?= _t('gen.action.cancel') ?></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,9 @@ final class ReadingTimeExtension extends Minz_Extension {
|
||||||
private int $speed = 300;
|
private int $speed = 300;
|
||||||
private string $metrics = 'words';
|
private string $metrics = 'words';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws FreshRSS_Context_Exception
|
||||||
|
*/
|
||||||
#[\Override]
|
#[\Override]
|
||||||
public function init(): void {
|
public function init(): void {
|
||||||
$this->registerTranslates();
|
$this->registerTranslates();
|
||||||
|
|
@ -13,20 +16,20 @@ final class ReadingTimeExtension extends Minz_Extension {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Defaults
|
// Defaults
|
||||||
$speed = FreshRSS_Context::userConf()->attributeInt('reading_time_speed'); // @phpstan-ignore missingType.checkedException
|
$speed = FreshRSS_Context::userConf()->attributeInt('reading_time_speed');
|
||||||
if ($speed === null) {
|
if ($speed === null) {
|
||||||
FreshRSS_Context::userConf()->_attribute('reading_time_speed', $this->speed); // @phpstan-ignore missingType.checkedException
|
FreshRSS_Context::userConf()->_attribute('reading_time_speed', $this->speed);
|
||||||
} else {
|
} else {
|
||||||
$this->speed = $speed;
|
$this->speed = $speed;
|
||||||
}
|
}
|
||||||
$metrics = FreshRSS_Context::userConf()->attributeString('reading_time_metrics'); // @phpstan-ignore missingType.checkedException
|
$metrics = FreshRSS_Context::userConf()->attributeString('reading_time_metrics');
|
||||||
if ($metrics === null) {
|
if ($metrics === null) {
|
||||||
FreshRSS_Context::userConf()->_attribute('reading_time_metrics', $this->metrics); // @phpstan-ignore missingType.checkedException
|
FreshRSS_Context::userConf()->_attribute('reading_time_metrics', $this->metrics);
|
||||||
} else {
|
} else {
|
||||||
$this->metrics = $metrics;
|
$this->metrics = $metrics;
|
||||||
}
|
}
|
||||||
if (in_array(null, [$speed, $metrics], true)) {
|
if (in_array(null, [$speed, $metrics], true)) {
|
||||||
FreshRSS_Context::userConf()->save(); // @phpstan-ignore missingType.checkedException
|
FreshRSS_Context::userConf()->save();
|
||||||
}
|
}
|
||||||
$this->registerHook('js_vars', [$this, 'getParams']);
|
$this->registerHook('js_vars', [$this, 'getParams']);
|
||||||
Minz_View::appendScript($this->getFileUrl('readingtime.js', 'js'));
|
Minz_View::appendScript($this->getFileUrl('readingtime.js', 'js'));
|
||||||
|
|
@ -55,16 +58,20 @@ final class ReadingTimeExtension extends Minz_Extension {
|
||||||
return $vars;
|
return $vars;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws FreshRSS_Context_Exception
|
||||||
|
* @throws Minz_ActionException
|
||||||
|
*/
|
||||||
#[\Override]
|
#[\Override]
|
||||||
public function handleConfigureAction(): void {
|
public function handleConfigureAction(): void {
|
||||||
$this->registerTranslates();
|
$this->registerTranslates();
|
||||||
|
|
||||||
if (Minz_Request::isPost()) {
|
if (Minz_Request::isPost()) {
|
||||||
$speed = $this->validateSpeed(Minz_Request::paramInt('reading_time_speed')); // @phpstan-ignore missingType.checkedException
|
$speed = $this->validateSpeed(Minz_Request::paramInt('reading_time_speed'));
|
||||||
FreshRSS_Context::userConf()->_attribute('reading_time_speed', $speed); // @phpstan-ignore missingType.checkedException
|
FreshRSS_Context::userConf()->_attribute('reading_time_speed', $speed);
|
||||||
$metrics = $this->validateMetrics(Minz_Request::paramString('reading_time_metrics')); // @phpstan-ignore missingType.checkedException
|
$metrics = $this->validateMetrics(Minz_Request::paramString('reading_time_metrics'));
|
||||||
FreshRSS_Context::userConf()->_attribute('reading_time_metrics', $metrics); // @phpstan-ignore missingType.checkedException
|
FreshRSS_Context::userConf()->_attribute('reading_time_metrics', $metrics);
|
||||||
FreshRSS_Context::userConf()->save(); // @phpstan-ignore missingType.checkedException
|
FreshRSS_Context::userConf()->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue