function display() { ?> <h2>Contact Information</h2><?php $email = db_getRow("SELECT * FROM journo_email WHERE journo_id=? AND approved=true AND srctype='' LIMIT 1", $this->journo['id']); $phone = db_getRow("SELECT * FROM journo_phone WHERE journo_id=? LIMIT 1", $this->journo['id']); $address = db_getRow("SELECT * FROM journo_address WHERE journo_id=? LIMIT 1", $this->journo['id']); $twitter_id = journo_fetchTwitterID($this->journo['id']); $contact = array('email' => $email, 'phone' => $phone, 'address' => $address, 'twitter' => $twitter_id); $this->showForm($contact); }
function journo_collectData($journo, $quick_n_nasty = false) { $data = $journo; if ($data['fake'] == 't') { $data['fake'] = True; } $data['quick_n_nasty'] = $quick_n_nasty; if (!$quick_n_nasty) { $slowdata = journo_calculateSlowData($journo); $data = $data + $slowdata; } $data['rssurl'] = journoRSS($journo); $data['bios'] = journo_fetchBios($journo['id']); $data['picture'] = journo_getThumbnail($journo['id']); /* contact details */ $guessed = null; $known = fetchJournoEmail($journo); if (!is_null($known)) { /* if there is an email address, but it is blank, don't display _anything_ */ if ($known['email'] == '') { $known = null; } } else { if (!$quick_n_nasty) { $guessed = journo_guessContactDetails($journo, $data['guessed_main_org']); } } $data['address'] = db_getOne("SELECT address FROM journo_address WHERE journo_id=?", $journo['id']); $data['phone_number'] = db_getOne("SELECT phone_number FROM journo_phone WHERE journo_id=?", $journo['id']); $data['known_email'] = $known; $data['guessed'] = $guessed; $data['twitter_id'] = journo_fetchTwitterID($journo['id']); if ($data['twitter_id']) { $data['twitter_url'] = 'http://twitter.com/' . urlencode($data['twitter_id']); } else { $data['twitter_url'] = NULL; } /* assorted bio things */ $data['employers'] = journo_collectEmployment($journo['id']); $data['education'] = journo_collectEducation($journo['id']); $data['awards'] = journo_collectAwards($journo['id']); $data['books'] = db_getAll("SELECT * FROM journo_books WHERE journo_id=? ORDER BY year_published DESC", $journo['id']); /* admired journos */ $sql = <<<EOT SELECT a.admired_name AS prettyname, j.ref, j.oneliner FROM (journo_admired a LEFT JOIN journo j ON j.id=a.admired_id) WHERE a.journo_id=? EOT; $data['admired'] = db_getAll($sql, $journo['id']); /* journos who admire this one */ $sql = <<<EOT SELECT j.prettyname, j.ref, j.oneliner FROM (journo_admired a LEFT JOIN journo j ON j.id=a.journo_id) WHERE a.admired_id=? EOT; $data['admired_by'] = db_getAll($sql, $journo['id']); $data['num_alerts'] = (int) db_getOne("SELECT count(*) FROM alert WHERE journo_id=?", $journo['id']); $data['num_views_week'] = (int) db_getOne("SELECT num_views_week FROM journo_pageviews WHERE journo_id=?", $journo['id']); $data['articles'] = journo_collectArticles($journo); $data['more_articles'] = true; /*links*/ $sql = "SELECT id, url, description, kind " . "FROM journo_weblink " . "WHERE journo_id=? " . "AND approved ORDER BY rank DESC"; $links = db_getAll($sql, $journo['id']); foreach ($links as &$l) { $l['description'] = journo_describeWeblink($journo, $l); } unset($l); $links = array_merge($links, journo_getBioLinks($journo)); $data['links'] = $links; /* similar journos */ $sql = <<<EOT SELECT j.prettyname, j.ref, j.oneliner FROM (journo_similar s INNER JOIN journo j ON j.id=s.other_id) WHERE s.journo_id=? ORDER BY s.score DESC LIMIT 10 EOT; $data['similar_journos'] = db_getAll($sql, $journo['id']); return $data; }