Permalink
Browse files

lots of widget work - the widget now works as before, with better for…

…matting, much simpler code
  • Loading branch information...
1 parent 00cfed3 commit 7a6e88f23388f1404388bbc9c8ded5425e8fdc70 @iamcal committed Oct 28, 2010
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,37 @@
+{if $smarty.get.mini}
+ {assign var='w' value=80}
+ {assign var='h' value=15}
+ {assign var='src' value='browser_mini.gif'}
+{else}
+ {assign var='w' value=143}
+ {assign var='h' value=54}
+ {assign var='src' value='browser.gif'}
+{/if}
+{assign var='menu_w' value=200}
+{math assign='menu_offset_x' equation="0-((menu_w-w)/2)" w=$w menu_w=$menu_w}
+{math assign='menu_offset_y' equation="h+5" h=$h}
+
+
+<div id="london-bloggers-widget-{$uid}" style="position: relative; width: {$w}px;">
+ <div style="position: relative;">
+ <a href="{$cfg.abs_root_url}" onclick="return ToggleTubeMenu('{$uid}');"><img border="0" style="border: 0" src="{$cfg.abs_root_url}images/{$src}" width="{$w}" height="{$h}"></a>
+ </div>
+ <div id="london-bloggers-widget-menu-{$uid}" style="position: absolute; left: {$menu_offset_x}px; top: {$menu_offset_y}px; zIndex: 10; background-color: #fff; width: {$menu_w}px; display: none">
+ <div style="border: 1px solid #666666; font-size: 11px; font-family: Arial, Helvetica, sans-serif; padding: 8px;">
+
+{foreach from=$stations item='station'}
+ <b>Weblogs at <a href="{$cfg.abs_root_url}stations/{$station.id}/">{$station.name|escape}</a>:</b><br>
+ <br>
+ {foreach from=$station.weblogs item='weblog'}
+ &bull; <a href="{$weblog.blog_url|escape}">{$weblog.blog_name|escape}</a><br>
+ {/foreach}
+ {if $station.more}
+ &bull; and {$station.more} more...<br>
+ {/if}
+ <br>
+{/foreach}
+ <b><a href="{$cfg.abs_root_url}">Are you a London Blogger?</a></b>
+
+ </div>
+ </div>
+</div>
@@ -0,0 +1,20 @@
+{"Content-type: text/plain; charset=UTF-8"|header}
+{capture assign='html'}{include file='inc_widget_html.txt'}{/capture}
+var html = '{$html|trim|escape:'javascript'}';
+
+{literal}
+
+var needs_close = false;
+if (document.all && navigator.appVersion.toLowerCase().indexOf("mac") == -1) needs_close = true;
+if (navigator.userAgent.indexOf('Gecko') != -1) needs_close = true;
+
+document.write(html);
+if (needs) document.close();
+
+function ToggleTubeMenu(uid){
+ var m = document.getElementById('london-bloggers-widget-menu-'+uid);
+ m.style.display = m.style.display == 'block' ? 'none' : 'block';
+ return false;
+}
+
+{/literal}
@@ -13,14 +13,14 @@
If you're using an older browser, it will just take you to the london bloggers homepage.<br>
<br>
To show multiple stations in your weblog browser, change the "ids=5" part of the code
- into "ids=5,12" where 5 and 12 are the station numbers (you can find these out by looking
- at the weblog browser code on each station's page). You can add as many station id's as you
- like, seperated by commas e.g "ids=1,2,3,4,5,6".<br>
+ into "ids=5,12" where 5 and 12 are the station IDs (you can find these out by looking
+ at the weblog browser code on each station's page). You can add as many station IDs as you
+ like, seperated by commas (e.g. "ids=1,2,3,4,5,6").<br>
<br>
To use the mini version of the browser, add <code>&amp;mini=1</code> after the station ids.
- It will then use the following graphic:<br>
+ The mini version looks like this:<br>
<br>
- <img src="/images/browser_mini.gif" width="80" height="15" />
+ <script src="/widget/?ids=3,4&mini=1" type="text/javascript"></script>
</div>
{include file='inc_foot.txt'}
View
@@ -0,0 +1,62 @@
+<?
+ include("include/init.php");
+
+
+ #
+ # fetch stations / weblogs
+ #
+
+ $stations = array();
+
+ $ids = explode(',', $_GET['ids']);
+ foreach ($ids as $id){
+ $id = intval($id);
+
+ $station = db_single(db_fetch("SELECT * FROM tube_stations WHERE id=$id"));
+ if (!$station['id']) continue;
+
+
+ #
+ # weblogs
+ #
+
+ $limit = 5;
+
+ $ret2 = db_fetch("SELECT w.*,s.station_id FROM tube_weblogs AS w, tube_weblog_stations AS s WHERE w.id=s.weblog_id AND s.station_id=$station[id] ORDER BY w.date_create DESC LIMIT $limit");
+ list($total) = db_list(db_fetch("SELECT COUNT(w.id) FROM tube_weblogs AS w, tube_weblog_stations AS s WHERE w.id=s.weblog_id AND s.station_id=$station[id]"));
+
+ $station['weblogs'] = $ret2['rows'];
+ $station['more'] = max(0, $total - $limit);
+
+
+ $stations[] = $station;
+ }
+
+ $smarty->assign('stations', $stations);
+
+
+ #
+ # uid allows multiple widgets per page, somehow!
+ #
+
+ $smarty->assign('uid', time().rand(100,999));
+
+
+
+ #
+ # test mode just return the html, with no script to make
+ # the menu open - just easier for seeing the raw html
+ #
+
+ if ($_GET['test']){
+ $smarty->display('inc_widget_html.txt');
+ exit;
+ }
+
+
+ #
+ # output
+ #
+
+ $smarty->display('js_widget.txt');
+?>

0 comments on commit 7a6e88f

Please sign in to comment.