We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

public.php 3.13 KB
Newer Older
Evan Prodromou's avatar
Evan Prodromou committed
1
<?php
Evan Prodromou's avatar
Evan Prodromou committed
2
/*
Evan Prodromou's avatar
Evan Prodromou committed
3 4
 * Laconica - a distributed open-source microblogging tool
 * Copyright (C) 2008, Controlez-Vous, Inc.
Evan Prodromou's avatar
Evan Prodromou committed
5
 *
Evan Prodromou's avatar
Evan Prodromou committed
6 7 8 9
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
Evan Prodromou's avatar
Evan Prodromou committed
10
 *
Evan Prodromou's avatar
Evan Prodromou committed
11 12 13 14
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
Evan Prodromou's avatar
Evan Prodromou committed
15
 *
Evan Prodromou's avatar
Evan Prodromou committed
16 17 18 19
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

Evan Prodromou's avatar
Evan Prodromou committed
20
if (!defined('LACONICA')) { exit(1); }
Evan Prodromou's avatar
Evan Prodromou committed
21

Evan Prodromou's avatar
Evan Prodromou committed
22 23
require_once(INSTALLDIR.'/lib/stream.php');

Evan Prodromou's avatar
Evan Prodromou committed
24 25 26 27 28
class PublicAction extends StreamAction {

	function handle($args) {
		parent::handle($args);

29
		$page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
Evan Prodromou's avatar
Evan Prodromou committed
30

Evan Prodromou's avatar
Evan Prodromou committed
31
		header('X-XRDS-Location: '. common_local_url('publicxrds'));
32 33 34

		common_show_header(_('Public timeline'),
						   array($this, 'show_header'), NULL,
Evan Prodromou's avatar
Evan Prodromou committed
35
						   array($this, 'show_top'));
Evan Prodromou's avatar
Evan Prodromou committed
36 37 38 39 40 41 42 43

		# XXX: Public sidebar here?

		$this->show_notices($page);

		common_show_footer();
	}

Evan Prodromou's avatar
no arg  
Evan Prodromou committed
44
	function show_top() {
Evan Prodromou's avatar
Evan Prodromou committed
45
		if (common_logged_in()) {
46
			common_notice_form('public');
47 48 49 50 51 52
		} else {
			$instr = $this->get_instructions();
			$output = common_markup_to_html($instr);
			common_element_start('div', 'instructions');
			common_raw($output);
			common_element_end('div');
Evan Prodromou's avatar
Evan Prodromou committed
53
		}
54

55
		$this->public_views_menu();
56 57 58 59 60 61 62 63 64 65


		$this->show_feeds_list(array(0=>array('href'=>common_local_url('publicrss'),
											  'type' => 'rss',
											  'version' => 'RSS 1.0',
											  'item' => 'publicrss'),
									 1=>array('href'=>common_local_url('publicatom'),
											  'type' => 'atom',
											  'version' => 'Atom 1.0',
											  'item' => 'publicatom')));
Evan Prodromou's avatar
Evan Prodromou committed
66
	}
67

68 69
	function get_instructions() {
		return _('This is %%site.name%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
70 71
				 'based on the Free Software [Laconica](http://laconi.ca/) tool. ' .
				 '[Join now](%%action.register%%) to share notices about yourself with friends, family, and colleagues! ([Read more](%%doc.help%%))');
72 73
	}

74 75 76 77
	function show_header() {
		common_element('link', array('rel' => 'alternate',
									 'href' => common_local_url('publicrss'),
									 'type' => 'application/rss+xml',
78
									 'title' => _('Public Stream Feed')));
Evan Prodromou's avatar
Evan Prodromou committed
79 80 81
		# for client side of OpenID authentication
		common_element('meta', array('http-equiv' => 'X-XRDS-Location',
									 'content' => common_local_url('publicxrds')));
82
	}
83

Evan Prodromou's avatar
Evan Prodromou committed
84 85
	function show_notices($page) {

86
		$cnt = 0;
87 88
		$notice = Notice::publicStream(($page-1)*NOTICES_PER_PAGE,
									   NOTICES_PER_PAGE + 1);
89

90
		if ($notice) {
91
			common_element_start('ul', array('id' => 'notices'));
92 93 94
			while ($notice->fetch()) {
				$cnt++;
				if ($cnt > NOTICES_PER_PAGE) {
95 96
					break;
				}
97
				$this->show_notice($notice);
98
			}
99
			common_element_end('ul');
100
		}
101

102 103
		common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
						  $page, 'public');
Evan Prodromou's avatar
Evan Prodromou committed
104
	}
105
}