mirror of
https://github.com/D-Modem/speaking-clock.git
synced 2026-11-28 12:38:05 -08:00
app_speakingclock adds SpeakingClock(), which places each announcement by sample against the system clock, so the time mark (the third pip) lands on the second it announces, as on the real machines. Voices are folders of 8 kHz WAV clips with a voice.conf; the module supports TIM-style (phrase, hour, minute, seconds, pips), talking-clock, chime and hourly voices. voices/ holds the asterisk-tim pair (Pat Simmons, Gordon Gow), garrysblog's Amy and Celine, and the Steve's Talking Clock library, converted by tools/build_voices.py from what tools/fetch-sources.sh downloads. The recordings belong to their original owners (NOTICE.md); the code is GPL-2.0-or-later. freepbx/speakingclock is a FreePBX module: clocks as destinations, with optional numbers to dial, and speakingclock.conf from its settings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B82eRVXG9MBYPxmcs9cFxs
64 lines
2.2 KiB
PHP
64 lines
2.2 KiB
PHP
<?php
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
// Copyright (C) 2026 D-Modem Authors
|
|
//
|
|
// views/_form.php - form helpers for clock.php and settings.php: $row,
|
|
// $text, $select, $check, $zone. Given $errors.
|
|
|
|
if (!defined('FREEPBX_IS_AUTH')) {
|
|
die('No direct script access allowed');
|
|
}
|
|
use FreePBX\modules\Speakingclock as S;
|
|
|
|
$row = function ($id, $label, $field, $help) use ($errors) {
|
|
$err = isset($errors[$id]) ? $errors[$id] : '';
|
|
?>
|
|
<div class="element-container<?php echo $err !== '' ? ' has-error' : ''; ?>" data-field="<?php echo S::h($id); ?>">
|
|
<div class="row form-group">
|
|
<div class="col-md-3">
|
|
<label class="control-label" for="<?php echo S::h($id); ?>"><?php echo S::h($label); ?></label>
|
|
</div>
|
|
<div class="col-md-9">
|
|
<?php echo $field; ?>
|
|
<?php if ($err !== ''): ?>
|
|
<span class="help-block speakingclock-error"><?php echo S::h($err); ?></span>
|
|
<?php endif; ?>
|
|
<span class="help-block"><?php echo S::h($help); ?></span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
};
|
|
$text = function ($id, $value, $extra = '') {
|
|
return '<input type="text" class="form-control" id="' . S::h($id) .
|
|
'" name="' . S::h($id) . '" value="' . S::h($value) . '"' . $extra . '>';
|
|
};
|
|
$select = function ($id, $value, array $options) {
|
|
$h = '<select class="form-control" id="' . S::h($id) . '" name="' . S::h($id) . '">';
|
|
foreach ($options as $v => $label)
|
|
$h .= '<option value="' . S::h($v) . '"' .
|
|
((string)$v === (string)$value ? ' selected' : '') . '>' .
|
|
S::h($label) . '</option>';
|
|
return $h . '</select>';
|
|
};
|
|
$check = function ($id, $on) {
|
|
return '<input type="checkbox" id="' . S::h($id) . '" name="' . S::h($id) .
|
|
'" value="yes"' . ($on ? ' checked' : '') . '>';
|
|
};
|
|
/* a time zone select; '' is the default */
|
|
$zone = function ($id, $value, $defaultLabel) use ($select) {
|
|
$o = ['' => $defaultLabel];
|
|
foreach (\DateTimeZone::listIdentifiers() as $z)
|
|
$o[$z] = $z;
|
|
return $select($id, $value, $o);
|
|
};
|
|
/* voice id => "Name (id)", with the current one kept if it is missing */
|
|
$voiceOptions = function (array $voices, $current) {
|
|
$o = [];
|
|
foreach ($voices as $id => $v)
|
|
$o[$id] = $v['name'] . ' (' . $id . ', ' . $v['mode'] . ')';
|
|
if ($current !== '' && !isset($o[$current]))
|
|
$o[$current] = $current . ' ' . _('(missing)');
|
|
return $o;
|
|
};
|