aboutsummaryrefslogtreecommitdiffstats
path: root/include/page_widgets.php
blob: d70281afc92410b1eca6ad7c80d3724d935a6ae3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php

// A basic toolbar for observers with write_pages permissions
function writepages_widget ($who,$which){
	return replace_macros(get_markup_template('write_pages.tpl'), array(
			'$new' => t('New Page'),
			'$newurl' => "webpages/$who",
                        '$edit' => t('Edit'),
                        '$editurl' => "editwebpage/$who/$which"
			));
}



// Chan is channel_id, $who is channel_address - we'll need to pass observer later too.
function pagelist_widget ($chan,$who){
	$r = q("select * from item_id where uid = %d and service = 'WEBPAGE' order by sid asc",
	intval($chan)
	);
		$pages = null;
// TODO - only list public pages.  Doesn't matter for now, since we don't have ACL anyway.

		if($r) {
			$pages = array();
			foreach($r as $rr) {
				$pages[$rr['iid']][] = array('url' => $rr['iid'],'title' => $rr['sid']);
			} 
		}

	return replace_macros(get_markup_template('webpagelist.tpl'), array(
		'$baseurl' => $url,
		'$edit' => '',
		'$pages' => $pages,
		'$channel' => $who,
		'$preview' => '',
		'$widget' => 1,
	));

}