Permalink
Browse files

Add Twitter functionality and some open streetmap experiments

  • Loading branch information...
1 parent 32150e2 commit a77b553c6e51842282d4d2bb7a64a9ae51f4d3db Clemens John committed Feb 26, 2012
@@ -845,14 +845,14 @@ function my_calendar_locations_table() {
// Mail functions by Roland
function my_calendar_send_email( $details ) {
$event = event_as_array($details);
-
if ( get_option('mc_event_mail') == 'true' ) {
$to = get_option('mc_event_mail_to');
- $subject = get_option('mc_event_mail_subject');
+ $subject = jd_draw_template( $event, get_option('mc_event_mail_subject'));
$message = jd_draw_template( $event, get_option('mc_event_mail_message') );
$mail = wp_mail($to, $subject, $message);
}
}
+
// checks submitted events against akismet, if available, otherwise just returns false
function mc_akismet( $event_url='', $description='' ) {
global $akismet_api_host, $akismet_api_port, $user;
@@ -3,6 +3,12 @@
die ('Please do not load this page directly. Thanks!');
}
+//Load wptwitbox plugin
+$wptwitbox_plugin_path = WP_CONTENT_DIR."/plugins/wptwitbox/wptwitbox.php";
+if(file_exists($wptwitbox_plugin_path)) {
+ require_once($wptwitbox_plugin_path);
+}
+
/*
param = event id, date to split around
return = message confirming successful edits
@@ -327,6 +333,27 @@ function my_calendar_save( $action,$output,$event_id=false ) {
$event[0]->event_start_ts = $event_start_ts;
my_calendar_send_email( $event[0] );
$message = "<div class='updated'><p>". __('Event added. It will now show in your calendar.','my-calendar') . "</p></div>";
+
+ //Call wptwitbox if activated
+ if(!empty($GLOBALS['wpTwitBox'])) {
+ $event_as_array = event_as_array( $event[0] );
+ //Build own details link, because bitly wont build a short url from guid in $event_as_array. Parse guid through urlencode to see why!
+ $id_start = date('Y-m-d',strtotime($event_as_array['dtstart']));
+ $mcid = 'mc_'.$id_start.'_'.$event_as_array['id'];
+ $details_url = "http://piratenpartei-oldenburg.de/?page_id=544&mc_id=$mcid";
+
+ $short_link = $GLOBALS['wpTwitBox']->get_bitly_link("$details_url");
+
+ $status = "Neuer Termin: $event_as_array[title] am $event_as_array[date] um $event_as_array[time] $short_link";
+
+ $GLOBALS['wpTwitBox']->exe_twitter_call(
+ 'statuses/update',
+ 'post',
+ array(
+ 'status' => "$status"
+ )
+ );
+ }
}
}
if ( $action == 'edit' && $proceed == true ) {
@@ -258,6 +258,9 @@ function my_calendar_draw_event($event, $type="calendar", $process_date) {
$is_external = mc_external_link( $event_link );
$link_template = ( isset($templates['link']))?$templates['link']:'{title}';
$link_text = jd_draw_template($data,$link_template);
+ if(empty($link_text)) {
+ $link_text = $event_link;
+ }
$details = "\n". $header_details . $body_details . $description . $short . $status."<p><a href='$event_link' $is_external>".$link_text.'</a></p>'.$return;
} else {
$details = "\n". $header_details . $body_details . $description . $short . $status . $return;
@@ -309,7 +312,14 @@ function my_calendar_draw_event($event, $type="calendar", $process_date) {
case 'single':$details = apply_filters('mc_event_content_single',$details,$event);
break;
}
-
+
+
+/*echo "<pre>";
+echo "hallo";
+
+echo "</pre>";
+*/
+
if ( get_option( 'mc_event_approve' ) == 'true' ) {
if ( $event->event_approved == 1 ) {
return $details;
@@ -17,23 +17,47 @@ function jd_draw_template($array,$template,$type='list') {
}
function mc_maplink( $event, $request='map', $source='event' ) {
+//&zoom=17
+
if ( $source == 'event' ) {
+ //Google Map String
$map_string = $event->event_street.' '.$event->event_street2.' '.$event->event_city.' '.$event->event_state.' '.$event->event_postcode.' '.$event->event_country;
$zoom = ($event->event_zoom != 0)?$event->event_zoom:'15';
$map_string = str_replace(" ","+",$map_string);
+
+
+ //Open Routeservice Map String http://wiki.openstreetmap.org/wiki/Search
+ /*echo "http://nominatim.openstreetmap.org/search?email=admin@piratenpartei-oldenburg.de&limit=1format=json&q=".urlencode("$event->event_city $event->event_street");
+print_r($nominatim);
+ $map_string = "mlat=".$nominatim[0]->lat."&"."mlon=".$nominatim[0]->lon;
+*/
if ($event->event_longitude != '0.000000' && $event->event_latitude != '0.000000') {
+ //Google Maps String
$map_string = "$event->event_latitude,$event->event_longitude";
+/* //Open Streetmap String
+ $map_string = "mlat=$event->event_latitude&mlon=$event->event_longitude";*/
}
} else {
$map_string = $event->location_street.' '.$event->location_street2.' '.$event->location_city.' '.$event->location_state.' '.$event->location_postcode.' '.$event->location_country;
$zoom = ($event->location_zoom != 0)?$event->location_zoom:'15';
$map_string = str_replace(" ","+",$map_string);
+
+/* //Open Routeservice Map String http://wiki.openstreetmap.org/wiki/Search
+ $nominatim = json_decode(file_get_contents("http://nominatim.openstreetmap.org/search?email=admin@piratenpartei-oldenburg.de&limit=1&format=json&q=".urlencode("$event->event_city $event->event_street")));
+ $map_string = "mlat=".$nominatim[0]->lat."&"."mlon=".$nominatim[0]->lon;*/
+
if ($event->location_longitude != '0.000000' && $event->location_latitude != '0.000000') {
+ //Google Maps String
$map_string = "$event->location_latitude,$event->location_longitude";
- }
+/* //Open Streetmap String
+ $map_string = "mlat=$event->event_latitude&mlon=$event->event_longitude";*/
+ }
}
if ( strlen( trim( $map_string ) ) > 5 ) {
$map_url = "http://maps.google.com/maps?f=q&amp;z=$zoom&amp;q=to+$map_string";
+// $map_url = "http://nominatim.openstreetmap.org/search.php?countrycodes=de&q=$map_string&polygon=1";
+ // $map_url = "http://www.openstreetmap.org/?$map_string&zoom=17";
+
if ( $request == 'url' || $source == 'location' ) { return $map_url; }
$map_label = stripslashes( ($event->event_label != "")?$event->event_label:$event->event_title);
$map = "<a href=\"$map_url\" class='map-link external'>".sprintf(__('Map<span> to %s</span>','my-calendar'),$map_label )."</a>";
@@ -201,6 +225,7 @@ function event_as_array($event,$type='html') {
$details_link = '';
}
$details['details'] = ( get_option( 'mc_uri' ) != '' )?"<a href='$details_link'>$details_label</a>":'';
+ $details['details_2'] = ( get_option( 'mc_uri' ) != '' )?"<a href='$details_link'>$event->event_title</a>":'';
$details['dateid'] = $dateid;
$details['id'] = $id;
// RSS guid
@@ -211,6 +236,8 @@ function event_as_array($event,$type='html') {
$ical_description = mc_newline_replace(strip_tags($event->event_desc));
$details['ical_description'] = str_replace( "\r", "=0D=0A=", $event->event_desc );
$details['ical_desc'] = $ical_description;
+ $details['event_last_notification'] = $event->event_last_notification;
+
$details = apply_filters( 'mc_filter_shortcodes',$details,$event );
@@ -268,6 +268,7 @@ function my_calendar_upcoming_events($before='default',$after='default',$type='d
$events = mc_get_all_events($category); // grab all events within reasonable proximity
$output .= mc_produce_upcoming_events( $events,$template,$before,$after,'list',$order,$skip );
}
+
if ($output != '') {
$output = $header.$output.$footer;
return $output;
@@ -66,6 +66,7 @@
include(dirname(__FILE__).'/my-calendar-templating.php' );
include(dirname(__FILE__).'/my-calendar-group-manager.php' );
include(dirname(__FILE__).'/my-calendar-export.php' );
+include(dirname(__FILE__).'/my-calendar-cronjobs.php' );
// Install on activation
register_activation_hook( __FILE__, 'check_my_calendar' );
@@ -108,6 +109,7 @@
add_action( 'wp_footer','my_calendar_calendar_javascript' );
add_action( 'wp_head','my_calendar_fouc' );
add_action( 'init', 'my_calendar_export_vcal', 200 );
+add_action( 'init', 'my_calendar_cronjobs', 200 );
// Add filters
add_filter( 'widget_text', 'do_shortcode', 9 );
add_filter('plugin_action_links', 'jd_calendar_plugin_action', -10, 2);

0 comments on commit a77b553

Please sign in to comment.