'); // all known peers hashed on peer_id class Peers { var $hash; function Peers ($api) { $hash=array(); // fake entry fot the local myplc $local_fake_peer = array ('peername' => PLC_NAME, 'shortname' => PLC_SHORTNAME, 'peer_id'=>'local'); $hash['local']=$local_fake_peer; // remote $peer_columns=array('peer_id','shortname','peername'); $peer_filter=NULL; $peers = $api->GetPeers($peer_filter,$peer_columns); if ($peers) foreach ($peers as $peer) { $hash[$peer['peer_id']]=$peer; } $this->hash=$hash; } public static function is_local ($peer) { return $peer['peer_id'] == 'local'; } function peer ($peer_id) { // use the fake local entry if (!$peer_id) $peer_id='local'; return $this->hash[$peer_id]; } public function peername ($peer_id) { $peer = $this->peer ($peer_id); return $peer['peername']; } public function shortname ($peer_id) { $peer = $this->peer ($peer_id); return $peer['shortname']; } public function label ($peer_id) { $peer = $this->peer ($peer_id); $result = $peer['peername'] . " (" . $peer['shortname'] . ")"; if (Peers::is_local ($peer)) $result = "[local] " . $result; return $result; } public function link ($peer_id,$text) { if (! $peer_id) return href("/",$text); $peer = $this->peer ($peer_id); return l_peer_t($peer['peer_id'],$text); } public function peer_link ($peer_id) { if (! $peer_id) return href("/",$this->label($peer_id)); $peer = $this->peer ($peer_id); return l_peer_t($peer['peer_id'],$this->label($peer_id)); } function classname ($peer_id) { $shortname=strtolower($this->shortname($peer_id)); return "peer-$shortname"; } function block_start ($peer_id) { // start a