From 94335f237fdadd93b86b271526c25c2a77de9c40 Mon Sep 17 00:00:00 2001 From: Thomas Willingham Date: Sat, 10 Aug 2013 22:06:30 +0100 Subject: Initial shot at write_pages widget --- include/page_widgets.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 include/page_widgets.php (limited to 'include/page_widgets.php') diff --git a/include/page_widgets.php b/include/page_widgets.php new file mode 100644 index 000000000..21d5e5382 --- /dev/null +++ b/include/page_widgets.php @@ -0,0 +1,12 @@ + t('New Page'), + '$newurl' => "webpages/$who", + '$edit' => t('edit'), + '$editurl' => "editwebpage/$who/$which" + )); +} + -- cgit v1.2.3 From 608e04c65eb2433a1cece9b5798f8577b611a288 Mon Sep 17 00:00:00 2001 From: Thomas Willingham Date: Wed, 14 Aug 2013 20:46:48 +0100 Subject: More progress on pages - extend writepages widget, add pagelist widget --- include/page_widgets.php | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'include/page_widgets.php') 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 @@ 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, + )); + +} -- cgit v1.2.3 From 689cea3170968e1e488fb6fe84505ca7c9f6a2bf Mon Sep 17 00:00:00 2001 From: Thomas Willingham Date: Thu, 26 Sep 2013 18:26:03 +0100 Subject: Typo --- include/page_widgets.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/page_widgets.php') diff --git a/include/page_widgets.php b/include/page_widgets.php index 23d6d25ba..d70281afc 100644 --- a/include/page_widgets.php +++ b/include/page_widgets.php @@ -5,7 +5,7 @@ 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'), + '$edit' => t('Edit'), '$editurl' => "editwebpage/$who/$which" )); } -- cgit v1.2.3 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 --- include/page_widgets.php | 54 ++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 22 deletions(-) (limited to 'include/page_widgets.php') 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') + )); } -- cgit v1.2.3