Initial shot at write_pages widget

This commit is contained in:
Thomas Willingham 2013-08-10 22:06:30 +01:00
parent 4ac5348b3f
commit 94335f237f
3 changed files with 29 additions and 1 deletions

12
include/page_widgets.php Normal file
View File

@ -0,0 +1,12 @@
<?php
// A 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"
));
}

View File

@ -2,6 +2,8 @@
require_once('include/items.php'); require_once('include/items.php');
require_once('include/conversation.php'); require_once('include/conversation.php');
require_once('include/page_widgets.php');
function page_init(&$a) { function page_init(&$a) {
// We need this to make sure the channel theme is always loaded. // We need this to make sure the channel theme is always loaded.
$which = argv(1); $which = argv(1);
@ -32,7 +34,6 @@ function page_content(&$a) {
return; return;
} }
if(argc() < 3) { if(argc() < 3) {
notice( t('Invalid item.') . EOL); notice( t('Invalid item.') . EOL);
return; return;
@ -57,12 +58,24 @@ function page_content(&$a) {
dbesc($page_id), dbesc($page_id),
intval(ITEM_WEBPAGE) intval(ITEM_WEBPAGE)
); );
logger('r: ' . print_r($r,true));
if(! $r) { if(! $r) {
notice( t('Item not found.') . EOL); notice( t('Item not found.') . EOL);
return; return;
} }
// Use of widgets should be determined by Comanchie, but we don't have it yet, so...
if ($perms['write_pages']) {
$who = $channel_address;
$which = $r[0]['id'];
$o .= writepages_widget($who,$which);
}
xchan_query($r); xchan_query($r);
$r = fetch_post_tags($r,true); $r = fetch_post_tags($r,true);
$a->profile = array('profile_uid' => $u[0]['channel_id']); $a->profile = array('profile_uid' => $u[0]['channel_id']);

3
view/tpl/write_pages.tpl Normal file
View File

@ -0,0 +1,3 @@
<div id="write-pages" class="bigwidget">
<center><span id="wp-new"><a href="{{$newurl}}">{{$new}}</a></span> <span id="wp-edit"><a href="{{$editurl}}">{{$edit}}</a></span></center>
</div>