aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Willingham <founder@kakste.com>2013-08-14 20:46:48 +0100
committerThomas Willingham <founder@kakste.com>2013-08-14 20:46:48 +0100
commit608e04c65eb2433a1cece9b5798f8577b611a288 (patch)
treec63c91f20d0bd5fd71e9afda20998d00ea28e3a8
parenta0dfd44f9178796eaf55e4a2ab0194c12e7dfd21 (diff)
downloadvolse-hubzilla-608e04c65eb2433a1cece9b5798f8577b611a288.tar.gz
volse-hubzilla-608e04c65eb2433a1cece9b5798f8577b611a288.tar.bz2
volse-hubzilla-608e04c65eb2433a1cece9b5798f8577b611a288.zip
More progress on pages - extend writepages widget, add pagelist widget
-rw-r--r--include/page_widgets.php31
-rw-r--r--mod/editwebpage.php12
-rw-r--r--mod/page.php6
-rw-r--r--mod/webpages.php8
-rw-r--r--view/tpl/webpagelist.tpl9
5 files changed, 46 insertions, 20 deletions
diff --git a/include/page_widgets.php b/include/page_widgets.php
index 21d5e5382..23d6d25ba 100644
--- a/include/page_widgets.php
+++ b/include/page_widgets.php
@@ -1,8 +1,8 @@
<?php
-// A toolbar for observers with write_pages permissions
+// A basic toolbar for observers with write_pages permissions
function writepages_widget ($who,$which){
-return replace_macros(get_markup_template('write_pages.tpl'), array(
+ return replace_macros(get_markup_template('write_pages.tpl'), array(
'$new' => t('New Page'),
'$newurl' => "webpages/$who",
'$edit' => t('edit'),
@@ -10,3 +10,30 @@ return replace_macros(get_markup_template('write_pages.tpl'), array(
));
}
+
+
+// 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,
+ ));
+
+}
diff --git a/mod/editwebpage.php b/mod/editwebpage.php
index 46c6b8817..f89be67c4 100644
--- a/mod/editwebpage.php
+++ b/mod/editwebpage.php
@@ -1,7 +1,8 @@
<?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) {
@@ -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;
+// You may or may not be a local user. This won't work,
if(feature_enabled(local_user(),'richtext'))
$plaintext = false;
@@ -91,11 +91,9 @@ function editwebpage_content(&$a) {
//$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
-//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.
+//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.
- $rp = 'channel' . '/' . $which;
+ $rp = '/webpages/' . $which;
$o .= replace_macros($tpl,array(
'$return_path' => $rp,
diff --git a/mod/page.php b/mod/page.php
index 1bdc3027a..4b2b95b6a 100644
--- a/mod/page.php
+++ b/mod/page.php
@@ -58,7 +58,6 @@ function page_content(&$a) {
dbesc($page_id),
intval(ITEM_WEBPAGE)
);
- logger('r: ' . print_r($r,true));
if(! $r) {
notice( t('Item not found.') . EOL);
@@ -66,16 +65,13 @@ function page_content(&$a) {
}
// 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);
$r = fetch_post_tags($r,true);
$a->profile = array('profile_uid' => $u[0]['channel_id']);
diff --git a/mod/webpages.php b/mod/webpages.php
index 8e3901d90..fb133eccf 100644
--- a/mod/webpages.php
+++ b/mod/webpages.php
@@ -21,13 +21,15 @@ function webpages_content(&$a) {
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']);
}
-// We can do better, but since editing only works for local users and all posts are webpages, return anyone else for now.
+
+// Get the observer, check their permissions
$observer = $a->get_observer();
$ob_hash = (($observer) ? $observer['xchan_hash'] : '');
@@ -40,6 +42,7 @@ function webpages_content(&$a) {
}
// 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');
$x = array(
'webpage' => 1,
@@ -54,7 +57,7 @@ require_once ('include/conversation.php');
$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.
-// 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' order by sid asc",
intval($owner)
@@ -79,6 +82,7 @@ $r = q("select * from item_id where uid = %d and service = 'WEBPAGE' order by si
'$pages' => $pages,
'$channel' => $which,
'$view' => t('View'),
+ '$preview' => '1',
));
diff --git a/view/tpl/webpagelist.tpl b/view/tpl/webpagelist.tpl
index f3fe90da5..b09dc9f38 100644
--- a/view/tpl/webpagelist.tpl
+++ b/view/tpl/webpagelist.tpl
@@ -5,10 +5,11 @@
<div id="pagelist-content-wrapper">
{{foreach $pages as $key => $items}}
{{foreach $items as $item}}
- <div class="page-list-item"><a href="{{$baseurl}}/{{$item.url}}">{{$edit}}</a> |
- <a href="page/{{$channel}}/{{$item.title}}">{{$view}}</a>
- {{$item.title}} |
- <a href="page/{{$channel}}/{{$item.title}}?iframe=true&width=80%&height=80%" rel="prettyPhoto[iframes]">Preview</a>
+ <div class="page-list-item">
+ {{if $edit}}<a href="{{$baseurl}}/{{$item.url}}">{{$edit}}</a> | {{/if}}
+ {{if $view}}<a href="page/{{$channel}}/{{$item.title}}">{{$view}}</a> {{$item.title}} | {{/if}}
+ {{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>
{{/foreach}}