commit
7d0b1506a8
39
include/page_widgets.php
Normal file
39
include/page_widgets.php
Normal file
@ -0,0 +1,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,
|
||||||
|
));
|
||||||
|
|
||||||
|
}
|
@ -1,7 +1,8 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once('acl_selectors.php');
|
// What is this here for? I think it's cruft, but comment out for now in case it's here for a reason
|
||||||
|
// require_once('acl_selectors.php');
|
||||||
|
|
||||||
function editwebpage_content(&$a) {
|
function editwebpage_content(&$a) {
|
||||||
|
|
||||||
@ -59,9 +60,8 @@ function editwebpage_content(&$a) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// All of the following is straight from editpost - but we'll need richer editing options for webpages eventually, so we may as well have it's own mod now.
|
|
||||||
|
|
||||||
$plaintext = true;
|
$plaintext = true;
|
||||||
|
// You may or may not be a local user. This won't work,
|
||||||
if(feature_enabled(local_user(),'richtext'))
|
if(feature_enabled(local_user(),'richtext'))
|
||||||
$plaintext = false;
|
$plaintext = false;
|
||||||
|
|
||||||
@ -91,11 +91,9 @@ function editwebpage_content(&$a) {
|
|||||||
|
|
||||||
//$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
|
//$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
|
||||||
|
|
||||||
//FIXME A return path with $_SESSION doesn't work for observer (at least, not here it doesn't). It'll WSoD instead of loading a sensible page. So, send folk
|
//FIXME A return path with $_SESSION doesn't always work for observer - it may WSoD instead of loading a sensible page. So, send folk to the webpage list.
|
||||||
//back to the channel address until somebody figures out how to fix it - we can't send them back to webpages, because that could leak private pages they can't see
|
|
||||||
//when ACL is done.
|
|
||||||
|
|
||||||
$rp = 'channel' . '/' . $which;
|
$rp = '/webpages/' . $which;
|
||||||
|
|
||||||
$o .= replace_macros($tpl,array(
|
$o .= replace_macros($tpl,array(
|
||||||
'$return_path' => $rp,
|
'$return_path' => $rp,
|
||||||
|
11
mod/page.php
11
mod/page.php
@ -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;
|
||||||
@ -63,6 +64,14 @@ function page_content(&$a) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use of widgets should be determined by Comanchie, but we don't have it yet, so...
|
||||||
|
if ($perms['write_pages']) {
|
||||||
|
$chan = $a->channel['channel_id'];
|
||||||
|
$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']);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
function webpages_init(&$a) {
|
function webpages_content(&$a) {
|
||||||
|
|
||||||
if(argc() > 1)
|
if(argc() > 1)
|
||||||
$which = argv(1);
|
$which = argv(1);
|
||||||
@ -20,16 +20,29 @@ function webpages_init(&$a) {
|
|||||||
|
|
||||||
profile_load($a,$which,$profile);
|
profile_load($a,$which,$profile);
|
||||||
|
|
||||||
|
|
||||||
|
// Figure out who the page owner is.
|
||||||
|
$r = q("select channel_id from channel where channel_address = '%s'",
|
||||||
|
dbesc($which)
|
||||||
|
);
|
||||||
|
if($r) {
|
||||||
|
$owner = intval($r[0]['channel_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function webpages_content(&$a) {
|
// Get the observer, check their permissions
|
||||||
|
|
||||||
// We can do better, but since editing only works for local users and all posts are webpages, return anyone else for now.
|
$observer = $a->get_observer();
|
||||||
|
$ob_hash = (($observer) ? $observer['xchan_hash'] : '');
|
||||||
|
|
||||||
if (!local_user()) return;
|
$perms = get_all_perms($owner,$ob_hash);
|
||||||
|
|
||||||
|
if(! $perms['write_pages']) {
|
||||||
|
notice( t('Permission denied.') . EOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Create a status editor (for now - we'll need a WYSIWYG eventually) to create pages
|
// Create a status editor (for now - we'll need a WYSIWYG eventually) to create pages
|
||||||
|
// Nickname is set to the observers xchan, and profile_uid to the owners. This lets you post pages at other people's channels.
|
||||||
require_once ('include/conversation.php');
|
require_once ('include/conversation.php');
|
||||||
$x = array(
|
$x = array(
|
||||||
'webpage' => 1,
|
'webpage' => 1,
|
||||||
@ -38,16 +51,16 @@ require_once ('include/conversation.php');
|
|||||||
'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
|
'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
|
||||||
'bang' => (($group || $cid) ? '!' : ''),
|
'bang' => (($group || $cid) ? '!' : ''),
|
||||||
'visitor' => 'block',
|
'visitor' => 'block',
|
||||||
'profile_uid' => local_user()
|
'profile_uid' => intval($owner),
|
||||||
);
|
);
|
||||||
|
|
||||||
$o .= status_editor($a,$x);
|
$o .= status_editor($a,$x);
|
||||||
|
|
||||||
//Get a list of webpages. We can't display all them because endless scroll makes that unusable, so just list titles and an edit link.
|
//Get a list of webpages. We can't display all them because endless scroll makes that unusable, so just list titles and an edit link.
|
||||||
// FIXME - we should sort these results, but it's not obvious what order yet. Alphabetical? Created order?
|
//TODO - this should be replaced with pagelist_widget
|
||||||
|
|
||||||
$r = q("select * from item_id where uid = %d and service = 'WEBPAGE'",
|
$r = q("select * from item_id where uid = %d and service = 'WEBPAGE' order by sid asc",
|
||||||
intval(local_user())
|
intval($owner)
|
||||||
);
|
);
|
||||||
|
|
||||||
$pages = null;
|
$pages = null;
|
||||||
@ -61,14 +74,15 @@ $r = q("select * from item_id where uid = %d and service = 'WEBPAGE'",
|
|||||||
|
|
||||||
|
|
||||||
//Build the base URL for edit links
|
//Build the base URL for edit links
|
||||||
$url = z_root() . "/editwebpage/" . $a->profile['channel_address'];
|
$url = z_root() . "/editwebpage/" . $which;
|
||||||
// This isn't pretty, but it works. Until I figure out what to do with the UI, it's Good Enough(TM).
|
// This isn't pretty, but it works. Until I figure out what to do with the UI, it's Good Enough(TM).
|
||||||
return $o . replace_macros(get_markup_template("webpagelist.tpl"), array(
|
return $o . replace_macros(get_markup_template("webpagelist.tpl"), array(
|
||||||
'$baseurl' => $url,
|
'$baseurl' => $url,
|
||||||
'$edit' => t('Edit'),
|
'$edit' => t('Edit'),
|
||||||
'$pages' => $pages,
|
'$pages' => $pages,
|
||||||
'$channel' => $a->profile['channel_address'],
|
'$channel' => $which,
|
||||||
'$view' => t('View'),
|
'$view' => t('View'),
|
||||||
|
'$preview' => '1',
|
||||||
|
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -5,10 +5,11 @@
|
|||||||
<div id="pagelist-content-wrapper">
|
<div id="pagelist-content-wrapper">
|
||||||
{{foreach $pages as $key => $items}}
|
{{foreach $pages as $key => $items}}
|
||||||
{{foreach $items as $item}}
|
{{foreach $items as $item}}
|
||||||
<div class="page-list-item"><a href="{{$baseurl}}/{{$item.url}}">{{$edit}}</a> |
|
<div class="page-list-item">
|
||||||
<a href="page/{{$channel}}/{{$item.title}}">{{$view}}</a>
|
{{if $edit}}<a href="{{$baseurl}}/{{$item.url}}">{{$edit}}</a> | {{/if}}
|
||||||
{{$item.title}} |
|
{{if $view}}<a href="page/{{$channel}}/{{$item.title}}">{{$view}}</a> {{$item.title}} | {{/if}}
|
||||||
<a href="page/{{$channel}}/{{$item.title}}?iframe=true&width=80%&height=80%" rel="prettyPhoto[iframes]">Preview</a>
|
{{if $preview}} <a href="page/{{$channel}}/{{$item.title}}?iframe=true&width=80%&height=80%" rel="prettyPhoto[iframes]">Preview</a> {{/if}}
|
||||||
|
{{if $widget}}<a href="page/{{$channel}}/{{$item.title}}">{{$item.title}}</a>{{/if}}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
|
3
view/tpl/write_pages.tpl
Normal file
3
view/tpl/write_pages.tpl
Normal 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>
|
Reference in New Issue
Block a user