1: <?php
2:
3: $block_name = _("Comics");
4:
5: 6: 7:
8: class Horde_Block_Klutz_Comics extends Horde_Core_Block
9: {
10: 11: 12:
13: var $updateable = false;
14:
15: var $_app = 'klutz';
16:
17: 18: 19: 20: 21:
22: function _title()
23: {
24: return Horde::link(Horde::url('comics.php')) .
25: $GLOBALS['registry']->get('name') . '</a>';
26: }
27:
28: 29: 30: 31: 32:
33: function _content()
34: {
35: require_once dirname(__FILE__) . '/../base.php';
36: global $prefs, $klutz, $klutz_driver;
37:
38: $showall = $prefs->getValue('summ_showall');
39: $date = time();
40:
41:
42: $comics = explode("\t", $prefs->getValue('viewcomics'));
43: if (count($comics) == 1 && empty($comics[0])) {
44: $comics = null;
45: }
46:
47: $comicstoday = $klutz->listEnabled($comics, $date);
48:
49: if ($showall) {
50: $summary = '';
51: foreach ($comicstoday as $index) {
52: $name = $klutz->getProperty($index, 'name');
53: $author = $klutz->getProperty($index, 'author');
54: if ($klutz_driver->imageExists($index, $date)) {
55: $size = $klutz_driver->imageSize($index, $date);
56: $url = Horde_Util::addParameter(Horde::url('comics.php'), array('date' => $date, 'index' => $index));
57: $img = Horde::img(Horde_Util::addParameter($url, 'actionID', 'image'), sprintf("%s by %s", $name, $author), $size, '');
58: $link = Horde::link(Horde_Util::addParameter($url, 'actionID', 'comic'), sprintf("%s by %s", $name, $author));
59: $summary .= '<p>' . $link . $img . '</a></p>';
60: }
61: }
62: } else {
63: $this->updateable = true;
64:
65: do {
66:
67:
68: if (!count($comicstoday)) {
69: return _("Could not find any comics to display.");
70: }
71:
72:
73: $i = rand(0, count($comicstoday) - 1);
74: $tmp = array_splice($comicstoday, $i, 1);
75: $index = array_shift($tmp);
76: } while ($klutz_driver->imageExists($index, $date) === false);
77:
78: $name = $klutz->getProperty($index, 'name');
79: $author = $klutz->getProperty($index, 'author');
80: $size = $klutz_driver->imageSize($index, $date);
81: $url = Horde_Util::addParameter(Horde::url('comics.php'), array('date' => $date, 'index' => $index));
82: $img = Horde::img(Horde_Util::addParameter($url, 'actionID', 'image'), sprintf("%s by %s", $name, $author), $size, '');
83: $link = Horde::link(Horde_Util::addParameter($url, 'actionID', 'comic'), sprintf("%s by %s", $name, $author));
84: $summary = '<p class="text">' . $link . $name . ' by ' . $author . '</a></p>' .
85: '<p>' . $link . $img . '</a></p>';
86: }
87:
88: return $summary;
89: }
90: }
91: