Úprava systému PHPBB a jeho pluginu Calendar a SmartFeed tak, aby se události v kalendáři zobrazovaly v RSS.
Předpokládám, že máte v systému PHPBB nainstalovaný plugin SmartFeed a Kalendář.
Do souboru smartfeed.php přidáme tyto řádky:
include_once("./includes/functions_calendar.php"); $rowset = display_next_events_for_x_days_rss( $x ); //do display_next_events_for_x_days pridana return $events // loop through the rowset, each row is an item in the feed if (is_array($rowset)) { foreach ($rowset as $row) // This post goes in the newsfeed $username = $row['POSTER']; $item = new FeedItem(); $forum_name = ($row['forum_name'] == NULL) ? $user->lang['SMARTFEED_GLOBAL_ANNOUNCEMENT'] : $row['forum_name']; $item->title = "Event: ".html_entity_decode(censor_text($row['SUBJECT'])); $url = str_replace("&","&",$row['EVENT_URL']); // Create a number of item attributes, not all of which are necessarily in the feed (it depends on the feed type) $item->date = $row['START_TIME']; $item->pubDate = $item->date; $item->link = $url; $item->source = $board_url; $item->category = html_entity_decode($row['forum_name']); $item->guid = $item->link; $item->descriptionHtmlSyndicated = true; $item->comments = $row['EVENT_URL']; $item->author = $username; $item->authorEmail = ''; $message = $item->date." - ".$item->title.". Autor: ".$item->author; $item->description = $message; $rss->addItem($item); }
Do souboru calendar_function.php přidáme:
/* displays the upcoming events for the next x number of days RSS */ function display_next_events_x_events_rss( $x ) { $limit = $x; //num of events global $auth, $db, $user, $config, $template, $date, $available_etype_colors, $available_etype_images, $available_etype_display_names, $month_sel_code, $day_sel_code, $year_sel_code, $mode_sel_code; global $phpEx, $phpbb_root_path; $etype_url_opts = get_etype_url_opts(); // Is the user able to view ANY events? $user_can_view_events = true; //if ( $auth->acl_get('u_calendar_view_events') ) { init_calendar_data(); $subject_limit = get_calendar_config_value("display_truncated_name", 0); $group_options = get_sql_group_options($user->data['user_id']); $etype_options = get_etype_filter(); $start_temp_date = time(); //$end_temp_date = $start_temp_date + 31536000; $end_temp_date = $start_temp_date + ( $x * 86400 ); // find all day events that are still taking place $sort_timestamp_cutoff = $start_temp_date - 86400+1; $disp_date_format = get_calendar_config_value("date_format", 'M d, Y'); $disp_date_time_format = get_calendar_config_value("date_time_format", 'M d, Y h:i a'); // public events $sql = 'SELECT * FROM ' . CALENDAR_EVENTS_TABLE . ' WHERE ( (event_access_level = 2) AND (sort_timestamp > '.$db->sql_escape($sort_timestamp_cutoff).' ) ) ORDER BY sort_timestamp ASC LIMIT '.$limit; $result = $db->sql_query($sql); //echo $sql; while ($row = $db->sql_fetchrow($result)) { $events['EVENT_URL'] = append_sid("{$phpbb_root_path}calendar.$phpEx", "view=event&calEid=".$row['event_id'].$etype_url_opts); $events['IMAGE'] = $available_etype_images[$row['etype_id']]; $events['COLOR'] = $available_etype_colors[$row['etype_id']]; $events['ETYPE_DISPLAY_NAME'] = $available_etype_display_names[$row['etype_id']]; $events['FULL_SUBJECT'] = censor_text($row['event_subject']); $events['SUBJECT'] = $events['FULL_SUBJECT']; if( $subject_limit > 0 ) { if(utf8_strlen($events['SUBJECT']) > $subject_limit) { $events['SUBJECT'] = truncate_string($events['SUBJECT'], $subject_limit) . '...'; } } $poster_url = ''; $invite_list = ''; get_event_invite_list_and_poster_url($row, $poster_url, $invite_list ); $events['POSTER'] = $poster_url; $events['INVITED'] = $invite_list; $events['ALL_DAY'] = 0; if( $row['event_all_day'] == 1 ) { list($eday['eday_day'], $eday['eday_month'], $eday['eday_year']) = explode('-', $row['event_day']); $row['event_start_time'] = gmmktime(0,0,0,$eday['eday_month'], $eday['eday_day'], $eday['eday_year'])- $user->timezone - $user->dst; $row['event_end_time'] = $row['event_start_time']+86399; $events['ALL_DAY'] = 1; $events['START_TIME'] = $user->format_date($row['event_start_time'], $disp_date_format, true); $events['END_TIME'] = $user->format_date($row['event_end_time'], $disp_date_format, true); } else { $events['START_TIME'] = $user->format_date($row['event_start_time'], $disp_date_time_format, true); $events['END_TIME'] = $user->format_date($row['event_end_time'], $disp_date_time_format, true); } //$events['START_TIME'] = $user->format_date($row['event_start_time']); //$events['END_TIME'] = $user->format_date($row['event_end_time']); $tmp[] = $events; } $db->sql_freeresult($result); return $tmp; } }
Tento web jsem zakládal na střední, v roce 2008. Je zde hlavně archiv mé tvorby.
Aktuální věci publikuji kvůli úspoře času na Twitter.
Honza
"Náš blahobyt nespočívá v tom, co máme, ale v tom, co nás těší."