';
return $outstr;
}
function output_ff_contact($citydata) {
$outstr = '
';
$contact = $citydata['contact'];
// Output -- rather ugly but the data is not uniform, some fields are URIs, some are usernames, ...
if (!empty($contact['email'])) {
$outstr .= sprintf("E-Mail: %s \n", $contact['email'], $contact['email']);
}
if (!empty($contact['ml'])) {
$outstr .= sprintf("Mailingliste: %s \n", $contact['ml'], $contact['ml']);
}
if (!empty($contact['irc'])) {
$outstr .= sprintf("IRC: %s \n", $contact['irc'], $contact['irc']);
}
if (!empty($contact['twitter'])) {
// catch username instead of URI
if ($contact['twitter'][0] === "@") {
$twitter_url = 'http://twitter.com/' . ltrim($contact['twitter'], "@");
$twitter_handle = $contact['twitter'];
} else {
$twitter_url = $contact['twitter'];
$twitter_handle = '@' . substr($contact['twitter'], strrpos($contact['twitter'], '/') + 1);
}
$outstr .= sprintf("Twitter: %s \n", $twitter_url, $twitter_handle);
}
if (!empty($contact['facebook'])) {
$outstr .= sprintf("Facebook: %s \n", $contact['facebook'], $contact['facebook']);
}
if (!empty($contact['googleplus'])) {
$outstr .= sprintf("G+: %s \n", $contact['googleplus'], $contact['googleplus']);
}
if (!empty($contact['jabber'])) {
$outstr .= sprintf("XMPP: %s \n", $contact['jabber'], $contact['jabber']);
}
$outstr .= '
';
return $outstr;
}
function output_ff_list() {
return 'here be some ff_list';
}
function shortcode_handler($atts, $content, $shortcode) {
// $atts[0] holds the city name, if given
if (empty($atts[0])) {
$city = get_option('FF_meta_city', FF_META_DEFAULT_CITY);
} else {
$city = $atts[0];
}
if (false === ($cityurl = $this->dir->get_url_by_city($city))) {
return "\n";
}
if (false === ($metadata = FF_Meta_Externaldata::get($cityurl))) {
return "\n";
}
$outstr = "
";
switch ($shortcode) {
case 'ff_state':
$outstr .= $this->output_ff_state($metadata);
break;
case 'ff_location':
$outstr .= $this->output_ff_location($metadata);
break;
case 'ff_services':
$outstr .= $this->output_ff_services($metadata);
break;
case 'ff_contact':
$outstr .= $this->output_ff_contact($metadata);
break;
case 'ff_list':
$outstr .= $this->output_ff_list();
break;
default:
$outstr .= "";
break;
}
$outstr .= "
";
return $outstr;
}
function admin_menu() {
// Options Page:
add_options_page(
'FF Meta Plugin', // page title
'FF Meta', // menu title
'manage_options', // req'd capability
'ff_meta_plugin', // menu slug
array ('FF_meta', 'options_page') // callback function
);
}
function admin_init() {
register_setting(
'ff_meta_settings-group', // group name
'ff_meta_cachetime' // option name
);
register_setting(
'ff_meta_settings-group', // group name
'ff_meta_city' // option name
);
add_settings_section(
'ff_meta_section-one', // ID
'Section One', // Title
array ('FF_Meta', 'section_one_callback'), // callback to fill
'ff_meta_plugin' // page to display on
);
add_settings_field(
'ff_meta_city', // ID
'Default community', // Title
array ('FF_Meta', 'city_callback'), // callback to fill field
'ff_meta_plugin', // menu page=slug to display field on
'ff_meta_section-one', // section to display the field in
array('label_for' => 'ff_meta_city_id') // ID of input element
);
add_settings_field(
'ff_meta_cachetime', // ID
'Cache time', // Title
array ('FF_Meta', 'cachetime_callback'), // callback to fill field
'ff_meta_plugin', // menu page=slug to display field on
'ff_meta_section-one', // section to display the field in
array('label_for' => 'ff_meta_cachetime_id') // ID of input element
);
}
function section_one_callback() {
echo 'This Plugin provides shortcodes to display information from the Freifunk meta.json.';
}
function cachetime_callback() {
$time = get_option( 'ff_meta_cachetime', FF_META_DEFAULT_CACHETIME );
echo " minutes"
."
Data from external URLs is cached for this number of minutes.