3 * Utility functions used by FeedPublisher (a Vanilla extension).
9 * @param $Configuration
12 function GetFeedUriForFeed( &$Configuration, $Parameters )
14 if ( $Configuration[ 'URL_BUILDING_METHOD' ] == 'mod_rewrite' )
15 $Parameters->Remove( 'DiscussionID' );
16 // force page 1 at all times
17 $Parameters->Remove( 'page' );
18 $Parameters->Set( 'page', 1 );
20 $Uri = GetRequestUri();
21 $Uri = explode( '?', $Uri );
23 return $Uri . '?' . $Parameters->GetQueryString();
29 * Adds a clickable link to the Vanilla panel
30 * and adds an 'auto-discovery' link in the html head section.
35 function AddLinks( &$Context, &$Head, &$Panel, $Properties )
37 // prepare parameters for the GetFeedUriForFeed() function
38 $p = $Context->ObjectFactory
->NewObject($Context, 'Parameters');
39 $p->DefineCollection( $_GET );
40 $p->Set( 'Feed', $Properties[ 'FeedType' ] );
42 $FeedUrl = GetFeedUriForFeed( $Context->Configuration
, $p );
47 // prepare some strings
48 $ListName = $Context->GetDefinition( 'Feeds' );
49 $ListItem = $Context->GetDefinition( $Properties[ 'FeedType' ] . 'Feed' );
50 $BodyTitle = $Context->GetDefinition(
51 'FP_feedLinkToolTip_' . $Properties[ 'PageType' ] );
54 $Panel->AddList( $ListName, 5 );
60 'title="' . $BodyTitle . '" class="'.$Properties[ 'FeedType' ].'"' );
62 // to the html head section
65 // quick fix for the MIME type
66 if ( $Properties[ 'FeedType' ] == 'RSS2' )
68 else $MIME = strtolower( $Properties[ 'FeedType' ] );
71 $HeadTitle = $Context->GetDefinition( $Properties[ 'FeedType' ] . 'Feed' );
74 $HeadLink = '<link rel="alternate" ';
75 $HeadLink.= 'type="application/'. $MIME . '+xml" ';
76 $HeadLink.= 'href="' . $FeedUrl . '" ';
77 $HeadLink.= 'title="' . $HeadTitle . '"';
79 $HeadLink = "\n " . $HeadLink . "\n "; // beautiful html source
80 $Head->AddString( $HeadLink );