function EmitEmailAddresses($journo_id) { ?> <h3>Email Addresses</h3> <?php $rows = db_getAll("SELECT * FROM journo_email WHERE journo_id=?", $journo_id); if ($rows) { ?> <ul> <?php foreach ($rows as $r) { $id = $r['id']; $email = $r['email']; $srcurl = $r['srcurl']; $srctype = $r['srctype']; $approved = $r['approved'] == 't'; $removelink = "<a href=\"?action=remove_email&journo_id={$journo_id}&email_id={$id}\">remove</a>"; if ($approved) { $divclass = 'approved'; $approvelink = sprintf("<a href=\"?action=disapprove_email&journo_id=%s&email_id=%s\">disapprove</a>", $journo_id, $id); } else { $divclass = 'unapproved'; $approvelink = sprintf("<a href=\"?action=approve_email&journo_id=%s&email_id=%s\">approve</a>", $journo_id, $id); } $desc = ''; if ($srcurl || $srctype) { $desc = "(srctype: '{$srctype}' srcurl: '{$srcurl}') "; } if (!$email) { $email = "<em>- Blank Address -</em>\n"; } print " <li>\n"; print " <div class=\"{$divclass}\">[{$id}] {$email} {$desc}" . "<small>[{$removelink}] [{$approvelink}]</small></div>"; print " </li>\n"; } ?> </ul> <?php } else { print "<p>-- no email addresses --</p>\n"; } ?> <form method="post"> email: <input type="text" name="email" size="80" /> <?php print form_element_hidden('action', 'add_email'); print form_element_hidden('journo_id', $journo_id); ?> <input type="submit" name="submit" value="Add Email Address" /> </form> <small><p> Note: add a blank address to suppress all email display on the journos page. This will also suppress any guessing of addresses based on previously-published articles. </p></small> <?php }
function EmitList($filter) { $actions = array('' => 'None', 'skip' => 'Skip (stop trying to scrape)', 'undecided' => 'Undecided (Continue trying to scrape)'); $whereclause = ''; if ($filter == 'undecided') { $whereclause = "WHERE action=' '"; } elseif ($filter == 'skip') { $whereclause = "WHERE action='s'"; } $sql = <<<EOT \tSELECT * FROM error_articlescrape {$whereclause} ORDER BY firstattempt DESC EOT; $r = db_query($sql); $cnt = db_num_rows($r); printf("<p>Found %d</p>\n", $cnt); if ($cnt == 0) { return; } ?> <form method="post" action="/adm/scrape-errors"> <?php echo form_element_hidden('filter', $filter); ?> Action (with selected articles): <?php echo form_element_select('action', $actions, $selected = ''); ?> <input type="submit" name="submit" value="Do it" /> <table> <thead> <tr> <th>First attempt</th> <th>Attempts</th> <th>srcid/URL</th> <th>Action</th> <th>Select</th> </tr> </thead> <tbody> <?php while ($row = db_fetch_array($r)) { $firstattempt = strftime('%d-%b-%y %H:%M', strtotime($row['firstattempt'])); $srcid = $row['srcid']; $attempts = $row['attempts']; $action = 'undecided'; $trclass = 'status_red'; if ($row['action'] == 's') { $action = 'Skip.'; $trclass = 'status_green'; } $title = $row['title']; /* title could be blank */ $srcurl = $row['srcurl']; $link = sprintf("<a href=\"%s\">%s</a>", $srcurl, $title ? $title : $srcurl); $link = "{$srcid}<br/><small>{$link}</small>"; $detailsurl = "/adm/scrape-errors?srcid={$srcid}&action=detail"; $detailslink = sprintf("<small>[<a href=\"%s\">details</a>]</small>\n", $detailsurl); /* checkbox element to select this item... */ $checkbox = "<input type=\"checkbox\" name=\"srcid[]\" value=\"{$srcid}\" />"; print " <tr class=\"{$trclass}\">\n" . " <td>{$firstattempt}</td>" . "<td>{$attempts} {$detailslink}</td>" . "<td>{$link}</td>" . "<td>{$action}</td>" . "<td>{$checkbox}</td>\n" . " </tr>\n"; } ?> </tbody> </table> Action (with selected articles): <?php echo form_element_select('action2', $actions, $selected = ''); ?> <input type="submit" name="submit2" value="Do it" /> </form> <?php }
function EmitAddressList($filter) { $whereclause = ''; if ($filter == 'approved') { $whereclause = "WHERE approved='t'"; } elseif ($filter == 'unapproved') { $whereclause = "WHERE approved='f'"; } $sql = <<<EOT \tSELECT e.id AS email_id, journo_id, j.ref AS journo_ref, j.prettyname, email, srcurl, approved \t FROM journo_email e \t JOIN journo j ON journo_id=j.id \t{$whereclause} \tORDER BY j.lastname, j.firstname, j.prettyname EOT; $r = db_query($sql); printf("<p>%d addresses:</p>\n", db_num_rows($r)); ?> <form method="post" action="/adm/journo-email"> <?php echo form_element_hidden('filter', $filter); ?> <!-- repeated below --> Action (with selected bios): <select name="action"> <option value="">None</option> <option value="approve">Approve</option> <option value="unapprove">Unapprove</option> </select> <input type="submit" name="submit" value="Do it" /> <table> <thead> <tr> <th>journo</th> <th>email</th> <th>approved?</th> <th>select</th> </tr> </thead> <tbody> <?php while ($row = db_fetch_array($r)) { $journo_id = $row['journo_id']; $journo_ref = $row['journo_ref']; $email_id = $row['email_id']; $approved = $row['approved']; $prettyname = $row['prettyname']; $srcurl = $row['srcurl']; $email = $row['email']; /* links to journo page and journo admin page */ $journo_link = "<a href=\"/{$journo_ref}\">{$prettyname}</a>"; $journo_adm_link = "<small>[<a href=\"/adm/journo?journo_id={$journo_id}\">admin</a>]</small>"; $links = $journo_link . " " . $journo_adm_link; /* checkbox element to select this bio... */ $checkbox = "<input type=\"checkbox\" name=\"email_id[]\" value=\"{$email_id}\" />"; $tr_class = $approved == 't' ? "bio_approved" : "bio_unapproved"; $col1 = $links; $col2 = "<large>{$email}</large> <small>(<a href=\"{$srcurl}\">source</a>)</small>"; $col3 = $approved == 't' ? 'yes' : 'no'; $col4 = $checkbox; print " <tr class=\"{$tr_class}\">\n" . " <td>{$col1}</td><td>{$col2}</td><td>{$col3}</td><td>{$col4}</td>\n" . " </tr>\n"; } ?> </tbody> </table> <!-- repeated above --> Action (with selected bios): <select name="action2"> <option value="">None</option> <option value="approve">Approve</option> <option value="unapprove">Unapprove</option> </select> <input type="submit" name="submit2" value="Do it" /> </form> <?php }
function EmitBioList($filter) { $whereclause = ''; if ($filter == 'approved') { $whereclause = "WHERE b.approved"; } elseif ($filter == 'unapproved') { $whereclause = "WHERE NOT b.approved"; } $sql = <<<EOT \tSELECT j.prettyname, j.ref, b.journo_id, b.bio, b.approved, \t b.id as bio_id, b.srcurl as url, b.type as bio_type \t\tFROM (journo_bio b INNER JOIN journo j ON j.id=b.journo_id) \t{$whereclause} \tORDER BY j.lastname, j.firstname, j.prettyname EOT; $r = db_query($sql); printf("<p>%d bios:</p>\n", db_num_rows($r)); ?> <form method="post" action="/adm/journo-bios"> <?php echo form_element_hidden('filter', $filter); ?> <!-- repeated below --> Action (with selected bios): <select name="action"> <option value="">None</option> <option value="approve">Approve</option> <option value="unapprove">Unapprove</option> </select> <input type="submit" name="submit" value="Do it" /> <table> <thead> <tr> <th>journo</th> <th>bio</th> <th>approved?</th> <th>select</th> </tr> </thead> <tbody> <?php while ($row = db_fetch_array($r)) { $journo_id = $row['journo_id']; $bio_id = $row['bio_id']; $bio = $row['bio']; $bio_type = $row['bio_type']; $ref = $row['ref']; $url = $row['url']; $prettyname = $row['prettyname']; $trclass = $row['approved'] == 't' ? 'bio_approved' : 'bio_unapproved'; $approved = $row['approved'] == 't' ? 'yes' : 'no'; /* links to journo page and journo admin page */ $journo_link = "<a href=\"/{$ref}\">{$prettyname}</a>"; $journo_adm_link = "<small>[<a href=\"/adm/journo?journo_id={$journo_id}\">admin</a>]</small>"; if ($bio_type == 'wikipedia:journo') { $source = 'Wikipedia'; $rescrape = ", <a href=\"?scrape={$ref}&filter={$filter}\">re-scrape</a>"; } else { if ($bio_type == 'cif:contributors-az') { $source = 'commentisfree'; $rescrape = ''; } else { $source = 'source'; $rescrape = ''; } } $bio_bit = "<small>{$bio} (<a href=\"{$url}\">{$source}</a>{$rescrape})</small>"; /* checkbox element to select this bio... */ $checkbox = "<input type=\"checkbox\" name=\"bio_id[]\" value=\"{$bio_id}\" />"; print " <tr class=\"{$trclass}\">\n" . " <td>{$journo_link} {$journo_adm_link}</td>" . "<td>{$bio_bit}</td>" . "<td>{$approved}</td>" . "<td>{$checkbox}</td>\n" . " </tr>\n"; } ?> </tbody> </table> <!-- repeated above --> Action (with selected bios): <select name="action2"> <option value="">None</option> <option value="approve">Approve</option> <option value="unapprove">Unapprove</option> </select> <input type="submit" name="submit2" value="Do it" /> </form> <?php }