[
'name' => 'Time in UTC',
'type' => 'list',
'values' => [
'0:00' => 0,
'1:00' => 1,
'2:00' => 2,
'3:00' => 3,
'4:00' => 4,
'5:00' => 5,
'6:00' => 6,
'7:00' => 7,
'8:00' => 8,
'9:00' => 9,
'10:00' => 10,
'11:00' => 11,
'12:00' => 12,
'13:00' => 13,
'14:00' => 14,
'15:00' => 15,
'16:00' => 16,
'17:00' => 17,
'18:00' => 18,
'19:00' => 19,
'20:00' => 20,
'21:00' => 21,
'22:00' => 22,
'23:00' => 23,
],
'defaultValue' => 5
],
'lucky' => [
'name' => 'Lucky number (optional)',
'type' => 'text'
]
]];
const LIMIT_ITEMS = 7;
const DAY_SECS = 86400;
public function getDescription()
{
return self::DESCRIPTION . '
Set a lucky number to get your personal quotes, like ' . mt_rand();
}
public function collectData()
{
$time = gmmktime((int)$this->getInput('time'), 0, 0);
if ($time > time()) {
$time -= self::DAY_SECS;
}
for ($i = self::LIMIT_ITEMS; $i > 0; --$i) {
$seed = gmdate('Ymd', $time) . $this->getInput('lucky');
$quote = $this->getQuote($seed);
$item['title'] = strftime('%A, %x', $time);
$item['content'] = htmlentities($quote, ENT_QUOTES, 'UTF-8');
$item['timestamp'] = $time;
$item['uid'] = hash('sha1', $seed);
$this->items[] = $item;
$time -= self::DAY_SECS;
}
}
private function getQuote($seed)
{
$quotes = explode(
'//',
<<