~fabiocbalbuquerque/sahana-agasti/web-services

« back to all changes in this revision

Viewing changes to web/wiki/feed.php

  • Committer: Chad Heuschober
  • Date: 2011-06-06 13:37:45 UTC
  • mfrom: (1.1.1244 trunk)
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: chad.heuschober@mail.cuny.edu-20110606133745-850mdvnjtv392zta
Pulled in most recent batch of changes from the cuny sps trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
// prepare cache depends
25
25
$depends['files'] = getConfigFiles('main');
26
26
$depends['age']   = $conf['rss_update'];
27
 
$depends['purge'] = ($_REQUEST['purge']) ? true : false;
 
27
$depends['purge'] = isset($_REQUEST['purge']);
28
28
 
29
29
// check cacheage and deliver if nothing has changed since last
30
30
// time or the update interval has not passed, also handles conditional requests
50
50
 
51
51
$image = new FeedImage();
52
52
$image->title = $conf['title'];
53
 
$image->url = DOKU_URL."lib/images/favicon.ico";
 
53
$image->url = tpl_getFavicon(true);
54
54
$image->link = DOKU_URL;
55
55
$rss->image = $image;
56
56
 
57
57
$data = null;
58
 
if($opt['feed_mode'] == 'list'){
59
 
    $data = rssListNamespace($opt);
60
 
}elseif($opt['feed_mode'] == 'search'){
61
 
    $data = rssSearch($opt);
62
 
}else{
 
58
$modes = array('list'   => 'rssListNamespace',
 
59
               'search' => 'rssSearch',
 
60
               'recent' => 'rssRecentChanges');
 
61
if (isset($modes[$opt['feed_mode']])) {
 
62
    $data = $modes[$opt['feed_mode']]($opt);
 
63
} else {
63
64
    $eventData = array(
64
65
        'opt'  => &$opt,
65
66
        'data' => &$data,
66
67
    );
67
68
    $event = new Doku_Event('FEED_MODE_UNKNOWN', $eventData);
68
69
    if ($event->advise_before(true)) {
69
 
        $data = rssRecentChanges($opt);
 
70
        echo sprintf('<error>Unknown feed mode %s</error>', hsc($opt['feed_mode']));
 
71
        exit;
70
72
    }
71
73
    $event->advise_after();
72
74
}
83
85
// ---------------------------------------------------------------- //
84
86
 
85
87
/**
86
 
 * Get URL parameters and config options and return a initialized option array
 
88
 * Get URL parameters and config options and return an initialized option array
87
89
 *
88
90
 * @author Andreas Gohr <andi@splitbrain.org>
89
91
 */
90
92
function rss_parseOptions(){
91
93
    global $conf;
92
94
 
93
 
    $opt['items']        = (int) $_REQUEST['num'];
94
 
    $opt['feed_type']    = $_REQUEST['type'];
95
 
    $opt['feed_mode']    = $_REQUEST['mode'];
96
 
    $opt['show_minor']   = $_REQUEST['minor'];
97
 
    $opt['namespace']    = $_REQUEST['ns'];
98
 
    $opt['link_to']      = $_REQUEST['linkto'];
99
 
    $opt['item_content'] = $_REQUEST['content'];
100
 
    $opt['search_query'] = $_REQUEST['q'];
101
 
 
102
 
    if(!$opt['feed_type'])    $opt['feed_type']    = $conf['rss_type'];
103
 
    if(!$opt['item_content']) $opt['item_content'] = $conf['rss_content'];
104
 
    if(!$opt['link_to'])      $opt['link_to']      = $conf['rss_linkto'];
105
 
    if(!$opt['items'])        $opt['items']        = $conf['recent'];
 
95
    $opt = array();
 
96
 
 
97
    foreach(array(
 
98
                  // Basic feed properties
 
99
                  // Plugins may probably want to add new values to these
 
100
                  // properties for implementing own feeds
 
101
 
 
102
                  // One of: list, search, recent
 
103
                  'feed_mode'    => array('mode', 'recent'),
 
104
                  // One of: diff, page, rev, current
 
105
                  'link_to'      => array('linkto', $conf['rss_linkto']),
 
106
                  // One of: abstract, diff, htmldiff, html
 
107
                  'item_content' => array('content', $conf['rss_content']),
 
108
 
 
109
                  // Special feed properties
 
110
                  // These are only used by certain feed_modes
 
111
 
 
112
                  // String, used for feed title, in list and rc mode
 
113
                  'namespace'    => array('ns', null),
 
114
                  // Positive integer, only used in rc mode
 
115
                  'items'        => array('num', $conf['recent']),
 
116
                  // Boolean, only used in rc mode
 
117
                  'show_minor'   => array('minor', false),
 
118
                  // String, only used in search mode
 
119
                  'search_query' => array('q', null),
 
120
 
 
121
                 ) as $name => $val) {
 
122
        $opt[$name] = (isset($_REQUEST[$val[0]]) && !empty($_REQUEST[$val[0]]))
 
123
                      ? $_REQUEST[$val[0]] : $val[1];
 
124
    }
 
125
 
 
126
    $opt['items']        = max(0, (int)  $opt['items']);
 
127
    $opt['show_minor']   = (bool) $opt['show_minor'];
 
128
 
106
129
    $opt['guardmail']  = ($conf['mailguard'] != '' && $conf['mailguard'] != 'none');
107
130
 
108
 
    switch ($opt['feed_type']){
 
131
    $type = valid_input_set('type', array('rss','rss2','atom','atom1','rss1',
 
132
                                          'default' => $conf['rss_type']),
 
133
                            $_REQUEST);
 
134
    switch ($type){
109
135
        case 'rss':
110
136
            $opt['feed_type'] = 'RSS0.91';
111
137
            $opt['mime_type'] = 'text/xml';
279
305
            }
280
306
 
281
307
            // add category
282
 
            if($meta['subject']){
 
308
            if(isset($meta['subject'])) {
283
309
                $item->category = $meta['subject'];
284
310
            }else{
285
311
                $cat = getNS($id);
349
375
    return $data;
350
376
}
351
377
 
352
 
//Setup VIM: ex: et ts=4 enc=utf-8 :
 
378
//Setup VIM: ex: et ts=4 :