From c6aa42773a17d53b4572488967b99666ab97ef97 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Sat, 21 May 2016 14:56:42 -0400 Subject: Trying to fix wiki branch starting fresh from dev --- include/widgets.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'include/widgets.php') diff --git a/include/widgets.php b/include/widgets.php index 2641a718e..acbd9bcd3 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -857,6 +857,33 @@ function widget_chatroom_members() { return $o; } +function widget_wiki_list($arr) { + + require_once("include/wiki.php"); + $r = wiki_list(App::$profile['channel_hash']); + + if($r) { + return replace_macros(get_markup_template('wikilist.tpl'), array( + '$header' => t('Wiki List'), + '$read' => $r['read'], + '$write' => $r['write'] + )); + } +} + +function widget_wiki_pages($arr) { + + require_once("include/wiki.php"); + $r = wiki_pages(App::$profile['channel_hash']); + + if($r) { + return replace_macros(get_markup_template('wiki_page_list.tpl'), array( + '$header' => t('Wiki Pages'), + '$pages' => $r['pages'] + )); + } +} + function widget_bookmarkedchats($arr) { if(! feature_enabled(App::$profile['profile_uid'],'ajaxchat')) -- cgit v1.2.3 From a36bef7979aecd72751d319f85b7037991979e35 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Sat, 21 May 2016 21:55:09 -0400 Subject: List of wikis populates with links according to observer permissions. --- include/widgets.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'include/widgets.php') diff --git a/include/widgets.php b/include/widgets.php index acbd9bcd3..cff58d225 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -860,13 +860,19 @@ function widget_chatroom_members() { function widget_wiki_list($arr) { require_once("include/wiki.php"); - $r = wiki_list(App::$profile['channel_hash']); + if(argc()>1) { + $nick = argv(1); + } else { + $channel = \App::get_channel(); + $nick = $channel['channel_address']; + } + $wikis = wiki_list($nick, get_observer_hash()); - if($r) { + if($wikis) { return replace_macros(get_markup_template('wikilist.tpl'), array( '$header' => t('Wiki List'), - '$read' => $r['read'], - '$write' => $r['write'] + '$channel' => $nick, + '$wikis' => $wikis['wikis'] )); } } -- cgit v1.2.3 From f884fa66782544cd6fc44a81b978a905d4755cea Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Sat, 28 May 2016 07:17:42 -0400 Subject: Wiki page list is fetched and the page widget is updated --- include/widgets.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'include/widgets.php') diff --git a/include/widgets.php b/include/widgets.php index 1cc6dfc28..0d734d6cf 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -877,14 +877,21 @@ function widget_wiki_list($arr) { function widget_wiki_pages($arr) { require_once("include/wiki.php"); - $r = wiki_pages(App::$profile['channel_hash']); - if($r) { - return replace_macros(get_markup_template('wiki_page_list.tpl'), array( - '$header' => t('Wiki Pages'), - '$pages' => $r['pages'] - )); + $pages = array(); + if (!array_key_exists('resource_id', $arr)) { + $hide = true; + } else { + $p = wiki_page_list($arr['resource_id']); + if ($p['pages']) { + $pages = $p['pages']; + } } + return replace_macros(get_markup_template('wiki_page_list.tpl'), array( + '$hide' => $hide, + '$header' => t('Wiki Pages'), + '$pages' => $pages + )); } function widget_bookmarkedchats($arr) { -- cgit v1.2.3 From ae94e8a855d31125b96e158c0fb8c0d6f22631d6 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Sat, 28 May 2016 07:42:18 -0400 Subject: Wiki page list links work. File content is not yet loaded into the editor. Removed some logger calls. --- include/widgets.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'include/widgets.php') diff --git a/include/widgets.php b/include/widgets.php index 0d734d6cf..539d227aa 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -877,7 +877,13 @@ function widget_wiki_list($arr) { function widget_wiki_pages($arr) { require_once("include/wiki.php"); - + $channelname = ((array_key_exists('channel',$arr)) ? $arr['channel'] : ''); + $wikiname = ''; + if (array_key_exists('refresh', $arr)) { + $not_refresh = (($arr['refresh']=== true) ? false : true); + } else { + $not_refresh = true; + } $pages = array(); if (!array_key_exists('resource_id', $arr)) { $hide = true; @@ -885,11 +891,19 @@ function widget_wiki_pages($arr) { $p = wiki_page_list($arr['resource_id']); if ($p['pages']) { $pages = $p['pages']; + $w = wiki_get_wiki($arr['resource_id']); + $wikiname = $w['wiki']['title']; + if (!$wikiname) { + $wikiname = ''; + } } } return replace_macros(get_markup_template('wiki_page_list.tpl'), array( '$hide' => $hide, + '$not_refresh' => $not_refresh, '$header' => t('Wiki Pages'), + '$channel' => $channelname, + '$wikiname' => $wikiname, '$pages' => $pages )); } -- cgit v1.2.3 From 00d32f6b947d10b836cf1a4d59dbff3413517fd5 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Sun, 29 May 2016 20:39:19 -0400 Subject: Only show wiki delete control if channel owner --- include/widgets.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'include/widgets.php') diff --git a/include/widgets.php b/include/widgets.php index 539d227aa..b19c36bc6 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -857,19 +857,25 @@ function widget_chatroom_members() { function widget_wiki_list($arr) { require_once("include/wiki.php"); - if(argc()>1) { + if (argc() > 1) { $nick = argv(1); + $channel = get_channel_by_nick($nick); } else { $channel = \App::get_channel(); $nick = $channel['channel_address']; } - $wikis = wiki_list($nick, get_observer_hash()); - - if($wikis) { + $wikis = wiki_list($channel, get_observer_hash()); + if (local_channel() === intval($channel['channel_id'])) { + $showControls = true; + } else { + $showControls = false; + } + if ($wikis) { return replace_macros(get_markup_template('wikilist.tpl'), array( '$header' => t('Wiki List'), '$channel' => $nick, - '$wikis' => $wikis['wikis'] + '$wikis' => $wikis['wikis'], + '$showControls' => $showControls )); } } -- cgit v1.2.3 From 8d284bab474c7e669ae9a639bdb22f7b28b95cc3 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Mon, 30 May 2016 20:59:54 -0400 Subject: Created page history widget to dynamically fetch and display the git commit history for wiki pages. --- include/widgets.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include/widgets.php') diff --git a/include/widgets.php b/include/widgets.php index b19c36bc6..536af8818 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -914,6 +914,17 @@ function widget_wiki_pages($arr) { )); } +function widget_wiki_page_history($arr) { + require_once("include/wiki.php"); + $pagename = ((array_key_exists('page', $arr)) ? $arr['page'] : ''); + $resource_id = ((array_key_exists('resource_id', $arr)) ? $arr['resource_id'] : ''); + $pageHistory = wiki_page_history(array('resource_id' => $resource_id, 'page' => $pagename)); + + return replace_macros(get_markup_template('wiki_page_history.tpl'), array( + '$pageHistory' => $pageHistory['history'] + )); +} + function widget_bookmarkedchats($arr) { if(! feature_enabled(App::$profile['profile_uid'],'ajaxchat')) -- cgit v1.2.3 From b70c6809648bb3c78e5e26f9293727b3a7aa4025 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Thu, 2 Jun 2016 22:27:26 -0400 Subject: Major corrections to access control and page construction. --- include/widgets.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'include/widgets.php') diff --git a/include/widgets.php b/include/widgets.php index 536af8818..d9dac1afa 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -857,27 +857,27 @@ function widget_chatroom_members() { function widget_wiki_list($arr) { require_once("include/wiki.php"); - if (argc() > 1) { - $nick = argv(1); - $channel = get_channel_by_nick($nick); - } else { + $channel = null; + if (argc() < 2 && local_channel()) { + // This should not occur because /wiki should redirect to /wiki/channel ... $channel = \App::get_channel(); - $nick = $channel['channel_address']; - } - $wikis = wiki_list($channel, get_observer_hash()); - if (local_channel() === intval($channel['channel_id'])) { - $showControls = true; } else { - $showControls = false; + $channel = get_channel_by_nick(argv(1)); // Channel being viewed by observer } + if (!$channel) { + return ''; + } + $wikis = wiki_list($channel, get_observer_hash()); if ($wikis) { return replace_macros(get_markup_template('wikilist.tpl'), array( '$header' => t('Wiki List'), - '$channel' => $nick, + '$channel' => $channel['channel_address'], '$wikis' => $wikis['wikis'], - '$showControls' => $showControls + // If the observer is the local channel owner, show the wiki controls + '$showControls' => ((local_channel() === intval($channel['channel_id'])) ? true : false) )); } + return ''; } function widget_wiki_pages($arr) { -- cgit v1.2.3 From 344c293424716cc53eed2fea9eb3a7512e725516 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Sat, 4 Jun 2016 15:12:04 -0400 Subject: Wiki and page filenames are abstracted from their displayed names. Special characters do not seem to break things. --- include/widgets.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'include/widgets.php') diff --git a/include/widgets.php b/include/widgets.php index b5c3b425a..9ea517a2d 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -897,13 +897,15 @@ function widget_wiki_pages($arr) { $p = wiki_page_list($arr['resource_id']); if ($p['pages']) { $pages = $p['pages']; - $w = wiki_get_wiki($arr['resource_id']); - $wikiname = $w['wiki']['title']; + $w = $p['wiki']; + // Wiki item record is $w['wiki'] + $wikiname = $w['urlName']; if (!$wikiname) { $wikiname = ''; } } } + logger('pages: ' . json_encode($pages)); return replace_macros(get_markup_template('wiki_page_list.tpl'), array( '$hide' => $hide, '$not_refresh' => $not_refresh, @@ -916,9 +918,9 @@ function widget_wiki_pages($arr) { function widget_wiki_page_history($arr) { require_once("include/wiki.php"); - $pagename = ((array_key_exists('page', $arr)) ? $arr['page'] : ''); + $pageUrlName = ((array_key_exists('pageUrlName', $arr)) ? $arr['pageUrlName'] : ''); $resource_id = ((array_key_exists('resource_id', $arr)) ? $arr['resource_id'] : ''); - $pageHistory = wiki_page_history(array('resource_id' => $resource_id, 'page' => $pagename)); + $pageHistory = wiki_page_history(array('resource_id' => $resource_id, 'pageUrlName' => $pageUrlName)); return replace_macros(get_markup_template('wiki_page_history.tpl'), array( '$pageHistory' => $pageHistory['history'] -- cgit v1.2.3 From 4528becf4ccbeea3d63f729ed643b5fc7d67f1bb Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Sun, 5 Jun 2016 20:52:40 -0400 Subject: Remove debugging logger statements --- include/widgets.php | 1 - 1 file changed, 1 deletion(-) (limited to 'include/widgets.php') diff --git a/include/widgets.php b/include/widgets.php index 9ea517a2d..5237b1a30 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -905,7 +905,6 @@ function widget_wiki_pages($arr) { } } } - logger('pages: ' . json_encode($pages)); return replace_macros(get_markup_template('wiki_page_list.tpl'), array( '$hide' => $hide, '$not_refresh' => $not_refresh, -- cgit v1.2.3