From 31fd284b3c99595a11e3a1401409f5ca2a5d5cfd Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 29 Apr 2014 18:28:05 -0700 Subject: clean up the webpage list a bit --- assets/home.html | 2 +- include/page_widgets.php | 54 +++++++++------- mod/webpages.php | 125 ++++++++++++++++++++------------------ version.inc | 2 +- view/css/mod_webpages.css | 6 ++ view/theme/redbasic/css/style.css | 13 ---- view/tpl/webpagelist.tpl | 29 +++++++-- 7 files changed, 129 insertions(+), 102 deletions(-) create mode 100644 view/css/mod_webpages.css diff --git a/assets/home.html b/assets/home.html index be270dbb8..d0c242f16 100644 --- a/assets/home.html +++ b/assets/home.html @@ -164,7 +164,7 @@ $(document).ready(function() {
Dream it. Do it.
RedMatrix
-The RedMatrix (aka "red") is an open source webapp providing a complete decentralised publishing, sharing, and communications system. It provides communications (private messaging, chat and social networking), media management (photos, events, files, web pages) and enough other features to make your head spin. +The RedMatrix (aka "red") is an open source webapp providing a complete decentralised publishing, sharing, and communications system. It provides communications (private messaging, chat and social networking), media management (photos, events, files, web pages) and enough features to make your head spin.

diff --git a/include/page_widgets.php b/include/page_widgets.php index d70281afc..49d1439be 100644 --- a/include/page_widgets.php +++ b/include/page_widgets.php @@ -3,37 +3,47 @@ // 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" - )); + '$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) +// Chan is channel_id, $which is channel_address - we'll need to pass observer later too. +function pagelist_widget ($owner,$which){ + + $r = q("select * from item_id left join item on item_id.iid = item.id where item_id.uid = %d and service = 'WEBPAGE' order by item.created desc", + intval($owner) ); - $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']); - } + + $pages = null; + + if($r) { + $pages = array(); + foreach($r as $rr) { + $pages[$rr['iid']][] = array('url' => $rr['iid'],'pagetitle' => $rr['sid'],'title' => $rr['title'],'created' => datetime_convert('UTC',date_default_timezone_get(),$rr['created']),'edited' => datetime_convert('UTC',date_default_timezone_get(),$rr['edited'])); } + } - return replace_macros(get_markup_template('webpagelist.tpl'), array( + //Build the base URL for edit links + $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). + return $o . replace_macros(get_markup_template("webpagelist.tpl"), array( '$baseurl' => $url, - '$edit' => '', + '$edit' => t('Edit'), '$pages' => $pages, - '$channel' => $who, - '$preview' => '', - '$widget' => 1, + '$channel' => $which, + '$view' => t('View'), + '$preview' => t('Preview'), + '$actions_txt' => t('Actions'), + '$pagelink_txt' => t('Page Link'), + '$title_txt' => t('Title'), + '$created_txt' => t('Created'), + '$edited_txt' => t('Edited') + )); } diff --git a/mod/webpages.php b/mod/webpages.php index 6328454a6..dea034357 100644 --- a/mod/webpages.php +++ b/mod/webpages.php @@ -15,44 +15,44 @@ function webpages_content(&$a) { if((local_user()) && (argc() > 2) && (argv(2) === 'view')) { $which = $channel['channel_address']; - $profile = argv(1); + $profile = argv(1); } 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']); + // 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']); } -// Get the observer, check their permissions + // Get the observer, check their permissions - $observer = $a->get_observer(); - $ob_hash = (($observer) ? $observer['xchan_hash'] : ''); + $observer = $a->get_observer(); + $ob_hash = (($observer) ? $observer['xchan_hash'] : ''); - $perms = get_all_perms($owner,$ob_hash); + $perms = get_all_perms($owner,$ob_hash); - if(! $perms['write_pages']) { - notice( t('Permission denied.') . EOL); - return; - } + if(! $perms['write_pages']) { + notice( t('Permission denied.') . EOL); + return; + } // if(local_user() && local_user() == $owner) { // $a->set_widget('design',design_tools()); // } - $mimetype = get_config('system','page_mimetype'); - if(! $mimetype) - $mimetype = 'choose'; + $mimetype = get_config('system','page_mimetype'); + if(! $mimetype) + $mimetype = 'choose'; - $layout = get_config('system','page_layout'); - if(! $layout) - $layout = 'choose'; + $layout = get_config('system','page_layout'); + if(! $layout) + $layout = 'choose'; // Create a status editor (for now - we'll need a WYSIWYG eventually) to create pages @@ -61,43 +61,43 @@ function webpages_content(&$a) { require_once('include/acl_selectors.php'); - if(local_user() && local_user() == $a->profile_uid) { - $channel = $a->get_channel(); - $channel_acl = array( - 'allow_cid' => $channel['channel_allow_cid'], - 'allow_gid' => $channel['channel_allow_gid'], - 'deny_cid' => $channel['channel_deny_cid'], - 'deny_gid' => $channel['channel_deny_gid'] - ); - } - else - $channel_acl = array(); - - require_once('include/conversation.php'); - $o = profile_tabs($a,true); - - $o .= '

' . t('Webpages') . '

'; - - $x = array( - 'webpage' => ITEM_WEBPAGE, - 'is_owner' => true, - 'nickname' => $a->profile['channel_address'], - 'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), - 'bang' => (($group || $cid) ? '!' : ''), - 'acl' => ((local_user() && local_user() == $owner) ? populate_acl($channel_acl) : ''), - 'visitor' => true, - 'profile_uid' => intval($owner), - 'mimetype' => $mimetype, - 'layout' => $layout, + if(local_user() && local_user() == $a->profile_uid) { + $channel = $a->get_channel(); + $channel_acl = array( + 'allow_cid' => $channel['channel_allow_cid'], + 'allow_gid' => $channel['channel_allow_gid'], + 'deny_cid' => $channel['channel_deny_cid'], + 'deny_gid' => $channel['channel_deny_gid'] ); + } + else + $channel_acl = array(); + + require_once('include/conversation.php'); + $o = profile_tabs($a,true); + + $o .= '

' . t('Webpages') . '

'; + + $x = array( + 'webpage' => ITEM_WEBPAGE, + 'is_owner' => true, + 'nickname' => $a->profile['channel_address'], + 'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), + 'bang' => (($group || $cid) ? '!' : ''), + 'acl' => ((local_user() && local_user() == $owner) ? populate_acl($channel_acl) : ''), + 'visitor' => true, + 'profile_uid' => intval($owner), + 'mimetype' => $mimetype, + 'layout' => $layout, + ); - $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. -//TODO - this should be replaced with pagelist_widget + // 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. + //TODO - this should be replaced with pagelist_widget - $r = q("select item_id.* from item_id left join item on item_id.iid = item.id where item_id.uid = %d and service = 'WEBPAGE' order by item.created desc", + $r = q("select * from item_id left join item on item_id.iid = item.id where item_id.uid = %d and service = 'WEBPAGE' order by item.created desc", intval($owner) ); @@ -106,23 +106,28 @@ function webpages_content(&$a) { if($r) { $pages = array(); foreach($r as $rr) { - $pages[$rr['iid']][] = array('url' => $rr['iid'],'title' => $rr['sid']); - } + $pages[$rr['iid']][] = array('url' => $rr['iid'],'pagetitle' => $rr['sid'],'title' => $rr['title'],'created' => datetime_convert('UTC',date_default_timezone_get(),$rr['created']),'edited' => datetime_convert('UTC',date_default_timezone_get(),$rr['edited'])); + } } //Build the base URL for edit links - $url = z_root() . "/editwebpage/" . $which; + $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). - return $o . replace_macros(get_markup_template("webpagelist.tpl"), array( + return $o . replace_macros(get_markup_template("webpagelist.tpl"), array( '$baseurl' => $url, '$edit' => t('Edit'), '$pages' => $pages, '$channel' => $which, '$view' => t('View'), '$preview' => t('Preview'), - - )); - + '$actions_txt' => t('Actions'), + '$pagelink_txt' => t('Page Link'), + '$title_txt' => t('Title'), + '$created_txt' => t('Created'), + '$edited_txt' => t('Edited') + +)); + } diff --git a/version.inc b/version.inc index 6bc57efd0..de307641d 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2014-04-28.659 +2014-04-29.660 diff --git a/view/css/mod_webpages.css b/view/css/mod_webpages.css new file mode 100644 index 000000000..1b5a798cd --- /dev/null +++ b/view/css/mod_webpages.css @@ -0,0 +1,6 @@ +.webpage-list-table tr { + height: 20px; +} +.webpage-list-table td { + padding: 5px; +} diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css index 881377e00..26ac639ee 100644 --- a/view/theme/redbasic/css/style.css +++ b/view/theme/redbasic/css/style.css @@ -1715,19 +1715,6 @@ header { .profile-thing-list { list-style-type: none; } -/* -.profile-thing-list li { - float: left; - margin-right: 25px; -} -*/ - - -div#pagelist-content-wrapper { -width: 80%; -margin-left: auto; -margin-right: auto; -} div.page-list-item { margin: 20px; diff --git a/view/tpl/webpagelist.tpl b/view/tpl/webpagelist.tpl index c19836a28..4ae153423 100644 --- a/view/tpl/webpagelist.tpl +++ b/view/tpl/webpagelist.tpl @@ -1,16 +1,35 @@ {{if $pages}}
+ + {{foreach $pages as $key => $items}} {{foreach $items as $item}} -
- {{if $edit}} {{/if}} - {{if $view}} {{/if}} - {{if $preview}} {{/if}} +
+ + + + + + {{/foreach}} {{/foreach}} + +
{{$actions_txt}}{{$pagelink_txt}}{{$title_txt}}{{$created_txt}}{{$edited_txt}}
+ {{if $edit}} {{/if}} + {{if $view}} {{/if}} + {{if $preview}} {{/if}} + + {{if $view}}{{$item.pagetitle}} + {{else}}{{$item.pagetitle}} + {{/if}} + {{$item.title}} - + + {{$item.created}} + + {{$item.edited}} +
-- cgit v1.2.3