[dev] weatherdotcom portal block issues

Rick Emery rick at emery.homelinux.net
Wed Feb 4 13:34:32 PST 2004


Quoting Chuck Hagenbuch <chuck at horde.org>:

> Quoting Rick Emery <rick at emery.homelinux.net>:
>
>> Also, I'd been pondering for some time how to keep from allowing the user to
>> select weather blocks if the pear Services_Weather package is not installed.
>> Included in the patch is my attempt to accomplish that; I doubt it's 
>> the best
>> way, but it worked on my install.
>
> It works - it's not ideal, since most times you include registry.php 
> you won't
> really need Services_Weather included. I don't have a better idea 
> right now, so
> I'm leaving it for now, but would like it to go eventually.

OK, how about this? It puts the check in Collection.php, and is only done (as
far as I can tell) when the portal layout screen is displayed.

If this looks OK, you can just revert the earlier change to registry.php.dist
and apply these. I wanted to include a patch against current CVS, but it looked
like it hadn't synch'ed yet when I made the patch. I can do it later and
resend if you want.

Thanks,
Rick

--
Rick Emery

"When once you have tasted flight, you will forever walk the Earth
 with your eyes turned skyward, for there you have been, and there
 you will always long to return"
                                              -- Leonardo Da Vinci
-------------- next part --------------
Index: Collection.php
===================================================================
RCS file: /repository/horde/lib/Block/Collection.php,v
retrieving revision 1.16
diff -u -r1.16 Collection.php
--- Collection.php	17 Jan 2004 19:29:07 -0000	1.16
+++ Collection.php	4 Feb 2004 21:26:15 -0000
@@ -37,6 +37,17 @@
         foreach ($registry->listApps() as $app) {
             $blocks = $registry->callByPackage($app, 'blocks');
             if (!is_a($blocks, 'PEAR_Error')) {
+                if (isset($blocks['metar']) || isset($blocks['weatherdotcom'])) {
+                    $result = @include_once 'Services/Weather.php';
+                    if (!$result) {
+                        if (isset($blocks['metar'])) {
+                            unset($blocks['metar']);
+                        }
+                        if (isset($blocks['weatherdotcom'])) {
+                            unset($blocks['weatherdotcom']);
+                        }
+                    }
+                }
                 $this->_blocks[$app] = $blocks;
             }
         }
-------------- next part --------------
Index: registry.php.dist
===================================================================
RCS file: /repository/horde/config/registry.php.dist,v
retrieving revision 1.208
diff -u -r1.208 registry.php.dist
--- registry.php.dist	27 Jan 2004 21:57:37 -0000	1.208
+++ registry.php.dist	4 Feb 2004 21:29:05 -0000
@@ -593,3 +593,8 @@
 $this->applets['metar'] = array(
     'name' => _("Metar Weather"),
 );
+
+$this->applets['weatherdotcom'] = array(
+    'name' => _("weather.com"),
+);
+


More information about the dev mailing list