Simplify and speed up services listing.

parent 7dbdbaef
......@@ -81,46 +81,49 @@ foreach ($pods as $pod) {
echo '<td>' . $pod['city'] . '</td>';
echo '<td>' . $pod['state'] . '</td>';
echo '<td data-toggle="tooltip" title="' . ($pod['detectedlanguage'] ? $iso->languageByCode1($pod['detectedlanguage']) : '') . '">' . ($pod['detectedlanguage'] ? strtoupper($pod['detectedlanguage']) : '') . '</td>';
$services = json_decode($pod['services'] ?? '[]') ?: [];
// Special case for XMPP, which is not an official service, but listed in the same cell.
($pod['service_xmpp'] ?? false) && $services[] = 'xmpp';
$services_list = [
'facebook' => ['img' => '/images/facebook.png', 'title' => 'Publish to Facebook'],
'twitter' => ['img' => '/images/twitter.png', 'title' => 'Publish to Twitter'],
'tumblr' => ['img' => '/images/tumblr.png', 'title' => 'Publish to Tumblr'],
'wordpress' => ['img' => '/images/wordpress.png', 'title' => 'Publish to WordPress'],
'xmpp' => ['img' => '/images/xmpp.png', 'title' => 'XMPP chat server'],
'appnet' => ['img' => '/images/appnet.png', 'title' => 'Publish to App.'],
'atom' => ['img' => '/images/atom.png', 'title' => 'Publish to Atom'],
'blogger' => ['img' => '/images/blogger.png', 'title' => 'Publish to Blogger'],
'gnusocial' => ['img' => '/images/gnusocial.png', 'title' => 'Publish to GNUSocial'],
'google' => ['img' => '/images/google.png', 'title' => 'Publish to Google+'],
'libertree' => ['img' => '/images/libertree.png', 'title' => 'Publish to Libertree'],
'linkedin' => ['img' => '/images/linkedin.png', 'title' => 'Publish to LinkedIn'],
'livejournal' => ['img' => '/images/livejournal.png', 'title' => 'Publish to Live Journal'],
'pinterest' => ['img' => '/images/pinterest.png', 'title' => 'Publish to Pinterest'],
'pumpio' => ['img' => '/images/pumpio.png', 'title' => 'Publish to Pump.io'],
];
echo '<td class="text-truncate">';
foreach ($services as $service) {
// Make sure we have this service in the list.
if (!isset($services_list[$service])) {
continue;
}
($pod['services'] ? $services = json_decode($pod['services']) : $services = '');
if (is_array($services)) {
$facebook = array_search('facebook', $services);
$twitter = array_search('twitter', $services);
$tumblr = array_search('tumblr', $services);
$wordpress = array_search('wordpress', $services);
$appnet = array_search('appnet', $services);
$atom = array_search('atom1.0', $services);
$blogger = array_search('blogger', $services);
$gnusocial = array_search('gnusocial', $services);
$google = array_search('google', $services);
$libertree = array_search('libertree', $services);
$linkedin = array_search('linkedin', $services);
$livejournal = array_search('livejournal', $services);
$pinterest = array_search('pinterest', $services);
$pumpio = array_search('pumpio', $services);
printf(
'<div class="smlogo"><img src="%1$s" data-toggle="tooltip" title="%2$s" alt="%2$s"></div>',
$services_list[$service]['img'],
$services_list[$service]['title']
);
}
$facebook !== false && print '<div class="smlogo"><img src="/images/facebook.png" data-toggle="tooltip" title="Publish to Facebook" alt="Publish to Facebook"></div>';
$twitter !== false && print '<div class="smlogo"><img src="/images/twitter.png" data-toggle="tooltip" title="Publish to Twitter" alt="Publish to Twitter"></div>';
$tumblr !== false && print '<div class="smlogo"><img src="/images/tumblr.png" data-toggle="tooltip" title="Publish to Tumblr" alt="Publish to Tumblr"></div>';
$wordpress !== false && print '<div class="smlogo"><img src="/images/wordpress.png" data-toggle="tooltip" title="Publish to WordPress" alt="Publish to WordPress"></div>';
$pod['service_xmpp'] && print '<div class="smlogo"><img src="/images/xmpp.png" data-toggle="tooltip" title="XMPP chat server" alt="XMPP chat server"></div>';
$appnet !== false && print '<div class="smlogo"><img src="/images/appnet.png" data-toggle="tooltip" title="Publish to App.net" alt="Publish to App.net"></div>';
$atom !== false && print '<div class="smlogo"><img src="/images/atom.png" data-toggle="tooltip" title="Publish to Atom" alt="Publish to Atom"></div>';
$blogger !== false && print '<div class="smlogo"><img src="/images/blogger.png" data-toggle="tooltip" title="Publish to Blogger" alt="Publish to Blogger"></div>';
$gnusocial !== false && print '<div class="smlogo"><img src="/images/gnusocial.png" data-toggle="tooltip" title="Publish to GNUSocial" alt="Publish to GNUSocial"></div>';
$google !== false && print '<div class="smlogo"><img src="/images/google.png" data-toggle="tooltip" title="Publish to Google+" alt="Publish to Google+"></div>';
$libertree !== false && print '<div class="smlogo"><img src="/images/libertree.png" data-toggle="tooltip" title="Publish to Libertree" alt="Publish to Libertree"></div>';
$linkedin !== false && print '<div class="smlogo"><img src="/images/linkedin.png" data-toggle="tooltip" title="Publish to LinkedIn" alt="Publish to LinkedIn"></div>';
$livejournal !== false && print '<div class="smlogo"><img src="/images/livejournal.png" data-toggle="tooltip" title="Publish to Live Journal" alt="Publish to Live Journal"></div>';
$pinterest !== false && print '<div class="smlogo"><img src="/images/pinterest.png" data-toggle="tooltip" title="Publish to Pinterest" alt="Publish to Pinterest"></div>';
$pumpio !== false && print '<div class="smlogo"><img src="/images/pumpio.png" data-toggle="tooltip" title="Publish to Pump.io" alt="Publish to Pump.io"></div>';
echo '</td>';
echo '<td>' . ($facebook !== false ? 'Yes' : 'No') . '</td>';
echo '<td>' . ($twitter !== false ? 'Yes' : 'No') . '</td>';
echo '<td>' . ($tumblr !== false ? 'Yes' : 'No') . '</td>';
echo '<td>' . ($wordpress !== false ? 'Yes' : 'No') . '</td>';
echo '<td>' . ($pod['service_xmpp'] ? 'Yes' : 'No') . '</td>';
echo '<td>' . (in_array('facebook', $services, true) ? 'Yes' : 'No') . '</td>';
echo '<td>' . (in_array('twitter', $services, true) ? 'Yes' : 'No') . '</td>';
echo '<td>' . (in_array('tumblr', $services, true) ? 'Yes' : 'No') . '</td>';
echo '<td>' . (in_array('wordpress', $services, true) ? 'Yes' : 'No') . '</td>';
echo '<td>' . (in_array('xmpp', $services, true) ? 'Yes' : 'No') . '</td>';
$podmin_statement = htmlentities($pod['podmin_statement'] ?? '', ENT_QUOTES);
echo '<td>' . ($podmin_statement ? '<a href="#" data-featherlight="<p>' . $podmin_statement . '</p>">&#128172;</a>' : '&nbsp;') . '</td></tr>';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment