From jbk@wild-e.com Sun Dec 1 04:35:05 2002 From: jbk@wild-e.com (Jon Knepher) Date: Sat, 30 Nov 2002 20:35:05 -0800 Subject: [klutz]Patch for a summary page of klutz Message-ID: <1038717305.3de991799f074@discovery.wild-e.com> Skipped content of type multipart/signed-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-keys Size: 967 bytes Desc: PGP Public Key Url : http://lists.horde.org/archives/klutz/attachments/20021130/3c371cf9/attachment-0001.bin -------------- next part -------------- ? klutzsummary.diff Index: config/prefs.php.dist =================================================================== RCS file: /repository/klutz/config/prefs.php.dist,v retrieving revision 1.4 diff -u -b -B -r1.4 prefs.php.dist --- config/prefs.php.dist 20 Jul 2002 04:28:51 -0000 1.4 +++ config/prefs.php.dist 1 Dec 2002 04:25:54 -0000 @@ -14,7 +14,7 @@ 'column' => _("Other Options"), 'label' => _("Display Options"), 'desc' => _("Change display options such as color scheme, what comics you see, and how comics are sorted."), - 'members' => array('comic_select', 'show_unselected')); + 'members' => array('comic_select', 'show_unselected', 'summ_showall')); // user language $_prefs['language'] = array( @@ -45,3 +45,11 @@ 'shared' => false, 'type' => 'checkbox', 'desc' => _("Show comics you haven't selected on the browse page?")); + +$_prefs['summ_showall'] = array( + 'value' => 0, + 'locked' => false, + 'shared' => false, + 'type' => 'checkbox', + 'desc' => _("Show all of your selected comics on the summary page?")); + Index: lib/api.php =================================================================== RCS file: /repository/klutz/lib/api.php,v retrieving revision 1.5 diff -u -b -B -r1.5 api.php --- lib/api.php 13 Nov 2002 21:49:45 -0000 1.5 +++ lib/api.php 1 Dec 2002 04:25:54 -0000 @@ -20,3 +20,60 @@ 'link' => '%application%/backend.php', 'name' => _("Update"))); } + +$_services['summary'] = array( + 'args' => array(), + 'type' => 'string'); + +function _klutz_summary() +{ + @define('KLUTZ_BASE', dirname(__FILE__) . '/..'); + require_once KLUTZ_BASE . '/lib/base.php'; + require_once KLUTZ_BASE . '/config/html.php'; + + global $prefs; + $showall = $prefs->getValue('summ_showall'); + $summary = ''; + $summary .= ''; + $summary .= ''; + $date = time(); + + // Get the list of comics to display. + $comics = explode("\t", $prefs->getValue('viewcomics')); + if (count($comics) == 1 && empty($comics[0])) { + $comics = null; + } + + $comicstoday = $klutz->listEnabled($comics, $date); + + if ($showall) { + foreach ($comicstoday as $index) { + $name = $klutz->getProperty($index, 'name'); + $author = $klutz->getProperty($index, 'author'); + if ($storage->imageExists($index, $date)) { + $size = $storage->imageSize($index, $date); + $url = Horde::url('comics.php', 1); + $url = Horde::addParameter($url, 'actionID=' . KLUTZ_DISPLAY_IMAGE); + $url = Horde::addParameter($url, "date=$date"); + $url = Horde::addParameter($url, "index=$index"); + $summary .= ''; + } + } + } else { + $index=$comicstoday[rand(0,count($comicstoday))]; + $name = $klutz->getProperty($index, 'name'); + $author = $klutz->getProperty($index, 'author'); + if ($storage->imageExists($index, $date)) { + $size = $storage->imageSize($index, $date); + $url = Horde::url('comics.php', 1); + $url = Horde::addParameter($url, 'actionID=' . KLUTZ_DISPLAY_IMAGE); + $url = Horde::addParameter($url, "date=$date"); + $url = Horde::addParameter($url, "index=$index"); + $summary .= ''; + $summary .= ''; + } + } + + $summary .= '
Comics
' . $name . '
' . $name . ' by ' . $author . '
' . $name . '
'; + return $summary; +}