public static function dispatch() { $action = get_http_var('action'); $r = null; if ($action == 'update') { $r = WeblinkWidget::fetch_from_httpvars(); } else { $id = get_http_var('id'); $r = WeblinkWidget::fetch_one($id); } $w = new WeblinkWidget($r); // perform whatever action has been requested $w->perform($action); // is request ajax? $ajax = get_http_var('ajax') ? true : false; if ($ajax) { $w->emit_core(); } else { // not an ajax request, so output a full page admPageHeader("Web Link", "WeblinkWidget::emit_head_js"); print "<h2>Web Link</h2>\n"; $w->emit_full(); admPageFooter(); } }
function EmitWebLinks($journo_id) { print "<h3>Web links</h3>\n"; $links = WeblinkWidget::fetch_lots($journo_id, ''); foreach ($links as $l) { $w = new WeblinkWidget($l); $w->emit_full(); } /* cheesy form to add a link */ /* replace with widget-based version */ ?> <form method="post"> url: <input type="text" name="url" size="40" /> description: <input type="text" name="desc" size="40" /> <?php print form_element_hidden('action', 'add_link'); print form_element_hidden('journo_id', $journo_id); ?> <input type="submit" name="submit" value="Add Link" /> </form> <?php return; }
<p>Web links for journos</p> <form method="post" action=""> Show: <select name="status"> <option <?php echo $status == '' ? 'selected ' : ''; ?> value="">All</option> <option <?php echo $status == 'unapproved' ? 'selected ' : ''; ?> value="unapproved">Unapproved</option> <option <?php echo $status == 'approved' ? 'selected ' : ''; ?> value="approved">Approved</option> </select> <input type="submit" name="submit" value="Filter" /> </form> <?php $rows = WeblinkWidget::fetch_lots(null, $status); foreach ($rows as $r) { $w = new WeblinkWidget($r); $w->emit_full(); } admPageFooter(); function ExtraHead() { WeblinkWidget::emit_head_js(); }