function PostedFragment(&$r) { $orgs = get_org_names(); $org = $orgs[$r['srcorg']]; $pubdate = pretty_date(strtotime($r['pubdate'])); return "<cite class=\"posted\"><a href=\"{$r['permalink']}\">{$pubdate}, <em>{$org}</em></a></cite>"; }
function article_augment(&$a) { $d = new datetime($a['pubdate']); $a['pretty_pubdate'] = pretty_date(strtotime($a['pubdate'])); $a['iso_pubdate'] = $d->format('c'); // fill in prettyname of publisher, if possible if (!array_key_exists('srcorgname', $a) && array_key_exists('srcorg', $a)) { $orgs = get_org_names(); $a['srcorgname'] = arr_get($a['srcorg'], $orgs, '(unknown)'); } }
function EmitArticles($journo_id) { $orgs = get_org_names(); print "<h3>Articles</h3>\n"; $sql = <<<EOT SELECT id,title,permalink,status,srcorg,pubdate,wordcount \tFROM (article a INNER JOIN journo_attr attr ON a.id=attr.article_id) \t\tWHERE attr.journo_id=? ORDER BY pubdate DESC EOT; $rows = db_getAll($sql, $journo_id); printf("<p>%d Articles:</p>\n", sizeof($rows)); ?> <ul> <?php foreach ($rows as $row) { $id = $row['id']; $permalink = $row['permalink']; $title = $row['title']; $status = $row['status']; $org = $orgs[$row['srcorg']]; $pubdate = pretty_date(strtotime($row['pubdate'])); // TODO: correct the class usage! $divclass = $status == 'a' ? 'bio_approved' : 'bio_unapproved'; ?> <li> <div class="<?php echo $divclass; ?> "><a href="/adm/article?id=<?php echo $id; ?> "><?php echo $title; ?> </a> <small><?php echo $pubdate; ?> , <em><?php echo $org; ?> </em> (<?php echo $row['wordcount']; ?> words) [<a href="<?php echo $permalink; ?> ">original article</a>]</small></div> </li> <?php } ?> </ul> <?php }
function __construct() { $this->name = "ProlificJournos"; $this->ident = "prolificjournos"; $this->desc = "Rank journos according to total words/articles written over time interval (top 500)"; $orgs = get_org_names(); $orgs['all'] = 'All'; $this->param_spec = array(array('name' => 'from_date', 'label' => 'From date (yyyy-mm-dd):', 'default' => date_create('1 week ago')->format('Y-m-d')), array('name' => 'to_date', 'label' => 'To date (yyyy-mm-dd):', 'default' => date_create('today')->format('Y-m-d')), array('name' => 'orderby', 'label' => 'Who has written the:', 'options' => array('words' => 'Most Words', 'articles' => 'Most Articles'), 'default' => 'articles'), array('name' => 'publication', 'label' => 'Publication', 'options' => $orgs, 'default' => 'all')); }
function journo_calcWrittenFor($journo_id) { $orgs = get_org_names(); $writtenfor = db_getAll("SELECT DISTINCT a.srcorg " . "FROM article a INNER JOIN journo_attr j ON (a.status='a' AND a.id=j.article_id) " . "WHERE j.journo_id=?", $journo_id); $orglist = array(); foreach ($writtenfor as $row) { $srcorg = $row['srcorg']; // get jobtitles seen for this org: $titles = db_getAll("SELECT jobtitle FROM journo_jobtitle WHERE journo_id=? AND org_id=?", $journo_id, $srcorg); $titlelist = array(); foreach ($titles as $t) { $titlelist[] = $t['jobtitle']; } $s = "<span class=\"publication\">" . $orgs[$srcorg] . "</span>"; if (!empty($titlelist)) { $s .= ' (' . implode(', ', $titlelist) . ')'; } $orglist[] = $s; } $writtenfor = pretty_implode($orglist); return $writtenfor; }
function PostedFragment(&$r) { $orgs = get_org_names(); $org = $orgs[$r['srcorg']]; if ($r['pubdate'] instanceof DateTime) { $pubdate = pretty_date($r['pubdate']); } else { $pubdate = pretty_date(strtotime($r['pubdate'])); } /* depreicated */ return sprintf("<cite class=\"posted\"><a class=\"extlink\" href=\"%s\">%s, <em>%s</em></a></cite>", htmlentities($r['permalink']), $pubdate, $org); }
function EmitArticle($art) { $orgs = get_org_names(); $orgname = $orgs[$art['srcorg']]; $sql = <<<EOT SELECT a.id, a.title, a.pubdate, a.srcorg, s.score FROM (article_similar s INNER JOIN article a ON a.id=s.other_id ) WHERE s.article_id=? ORDER BY s.score DESC EOT; $similar_articles = db_getAll($sql, $art['id']); foreach ($similar_articles as &$sim) { $sim['srcorgname'] = $orgs[$sim['srcorg']]; } unset($sim); $urls = db_getAll("SELECT url FROM article_url WHERE article_id=?", $art['id']); ?> <table border="1"> <tr><th>title</th><td><h2><?php echo $art['title']; ?> </h2><a class="button edit" href="/adm/editarticle?id36=<?php echo article_id_to_id36($art['id']); ?> ">edit article</a></td></tr> <tr><th>status</th><td><?php echo $art['status']; ?> </td></tr> <tr><th>id</th><td><?php echo $art['id']; ?> [<a href="<?php echo article_url($art['id']); ?> ">go to article page</a>] <tr><th>srcorg</th><td><?php echo $orgname; ?> (id <?php echo $art['srcorg']; ?> )</td></tr> <tr><th>urls</th><td> permalink: <a href="<?php echo $art['permalink']; ?> "><?php echo $art['permalink']; ?> </a><br/> srcurl: <a href="<?php echo $art['srcurl']; ?> "><?php echo $art['srcurl']; ?> </a><br/> all urls <?php echo sizeof($urls); ?> : <ul><?php foreach ($urls as $foo) { $url = $foo['url']; ?> <li><a href="<?php echo $url; ?> "><?php echo $url; ?> </a></li> <?php } ?> </ul> </td></tr> <tr><th>pubdate</th><td><?php echo $art['pubdate']; ?> </td></tr> <tr><th>lastscraped</th><td><?php echo $art['lastscraped']; ?> </td></tr> <tr><th>byline</th> <td> raw byline: "<?php echo $art['byline']; ?> "<br/> attributed to:<br/> <?php EmitAttribution($art); ?> </td> </tr> <tr><th>description</th><td><?php echo $art['description']; ?> </td></tr> <tr><th>srcid</th><td><?php echo $art['srcid']; ?> </td></tr> <tr><th>total_comments</th><td><?php echo $art['total_comments']; ?> </td></tr> <tr><th>total_bloglinks</th><td><?php echo $art['total_bloglinks']; ?> </td></tr> <tr><th>needs_indexing</th><td><?php echo $art['needs_indexing']; ?> </td></tr> <tr><th>last_similar</th><td><?php echo $art['last_similar']; ?> </td></tr> <tr><th>last_comment_check</th><td><?php echo $art['last_comment_check']; ?> </td></tr> <tr><th>images</th><td> <ul> <?php foreach ($art['images'] as $im) { ?> <li> <a href="<?php echo $im['url']; ?> "><?php echo $im['url']; ?> </a><br/> caption: <?php echo h($im['caption']); ?> <br/> credit: <?php echo h($im['credit']); ?> <br/> <?php } ?> </ul> </td> </table> <h2>content</h2> <?php if (is_null($art['content'])) { ?> <p> -- content not scraped -- </p> <?php } else { ?> <table border=1> <tr><th>displayed</th><th>source HTML</th></tr> <tr> <td width="50%"> <?php echo $art['content']; ?> </td> <td width="50%"> <?php $srchtml = htmlentities($art['content'], ENT_COMPAT, 'UTF-8'); $srchtml = str_replace("\n", "<br>\n", $srchtml); print $srchtml; ?> </td> </tr> </table> <?php } ?> <h2>similar articles</h2> <a href="/adm/article?id=<?php echo $art['id']; ?> &action=update_similar">Run similar-articles tool now</a> (to update the list)<br/> <table> <tr><th>score</th><th>other article</th></tr> <?php foreach ($similar_articles as $sim) { ?> <tr> <td><?php echo $sim['score']; ?> </td> <td> <a href="/adm/article?id=<?php echo $sim['id']; ?> "><?php echo $sim['title']; ?> </a>, <?php echo $sim['srcorgname']; ?> , <?php echo $sim['pubdate']; ?> </td> <?php } ?> </table> <?php }
function JournoOverview($ref) { $journo = db_getRow("SELECT id,ref,prettyname FROM journo WHERE ref=?", $ref); $r = db_query("SELECT a.srcorg as orgid, COUNT(*) as numarticles " . "FROM (article a INNER JOIN journo_attr attr ON a.id=attr.article_id) " . "WHERE attr.journo_id=? " . "GROUP BY a.srcorg", $journo['id']); $orgs = get_org_names(); ?> <?php echo admJournoLink($journo['ref']); ?> <table border=1> <tr><th>publication</th><th>num articles</th></tr> <?php while ($row = db_fetch_array($r)) { $orgid = $row['orgid']; ?> <tr><td><?php echo $orgs[$orgid]; ?> </td><td><?php echo $row['numarticles']; ?> </td></tr> <?php } ?> </table> <?php }