From e084b776eee9f1fc66e3f4a37b92ec70ccc49286 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 23 Aug 2017 00:01:02 -0700 Subject: cards feature --- Zotlabs/Module/Cards.php | 189 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 Zotlabs/Module/Cards.php (limited to 'Zotlabs/Module/Cards.php') diff --git a/Zotlabs/Module/Cards.php b/Zotlabs/Module/Cards.php new file mode 100644 index 000000000..1fdd3b63f --- /dev/null +++ b/Zotlabs/Module/Cards.php @@ -0,0 +1,189 @@ + 1) + $which = argv(1); + else + return; + + profile_load($which); + + } + + + function get() { + + if(observer_prohibited(true)) { + return login(); + } + + if(! \App::$profile) { + notice( t('Requested profile is not available.') . EOL ); + \App::$error = 404; + return; + } + + if(! feature_enabled(\App::$profile_uid,'cards')) { + return; + } + + nav_set_selected(t('Cards')); + + $category = (($_REQUEST['cat']) ? escape_tags(trim($_REQUEST['cat'])) : ''); + + if($category) { + $sql_extra2 .= protect_sprintf(term_item_parent_query(\App::$profile['profile_uid'],'item', $category, TERM_CATEGORY)); + } + + + $which = argv(1); + + $_SESSION['return_url'] = \App::$query_string; + + $uid = \App::$profile_uid; + $owner = 0; + $observer = \App::get_observer(); + + $channel = \App::$profile; + + if(! $owner) { + // 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']); + } + } + + $ob_hash = (($observer) ? $observer['xchan_hash'] : ''); + + if(! perm_is_allowed($owner,$ob_hash,'view_pages')) { + notice( t('Permission denied.') . EOL); + return; + } + + $mimetype = (($_REQUEST['mimetype']) ? $_REQUEST['mimetype'] : get_pconfig($owner,'system','page_mimetype')); + + $layout = (($_REQUEST['layout']) ? $_REQUEST['layout'] : get_pconfig($owner,'system','page_layout')); + + // 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 owner's. + // This lets you post pages at other people's channels. + + if((! $channel) && ($uid) && ($uid == \App::$profile_uid)) { + $channel = \App::get_channel(); + } + if($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 = [ 'allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '' ]; + } + + + $is_owner = ($uid && $uid == $owner); + + if(perm_is_allowed($owner,$ob_hash,'write_pages')) { + + $x = array( + 'webpage' => ITEM_TYPE_CARD, + 'is_owner' => true, + 'nickname' => \App::$profile['channel_address'], + 'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), + 'acl' => (($is_owner) ? populate_acl($channel_acl,false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_pages')) : ''), + 'permissions' => $channel_acl, + 'showacl' => (($is_owner) ? true : false), + 'visitor' => true, + 'hide_location' => true, + 'hide_voting' => true, + 'profile_uid' => intval($owner), + 'mimetype' => $mimetype, + 'mimeselect' => false, + 'layoutselect' => false, + 'expanded' => false, + 'novoting'=> true, + 'bbco_autocomplete' => 'bbcode', + 'bbcode' => true + ); + } + else { + $x = ''; + } + + if($_REQUEST['title']) + $x['title'] = $_REQUEST['title']; + if($_REQUEST['body']) + $x['body'] = $_REQUEST['body']; + + // 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. + + + $sql_extra = item_permissions_sql($owner); + + $r = q("select * from item + where item.uid = %d and item_type = %d + $sql_extra order by item.created desc", + intval($owner), + intval(ITEM_TYPE_CARD) + ); + + $item_normal = " and item.item_hidden = 0 and item.item_type in (0,6) and item.item_deleted = 0 + and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0 + and item.item_blocked = 0 "; + + + if($x) + $editor = status_editor($a,$x); + + if($r) { + + $parents_str = ids_to_querystr($r,'id'); + + $items = q("SELECT item.*, item.id AS item_id + FROM item + WHERE item.uid = %d $item_normal + AND item.parent IN ( %s ) + $sql_extra $sql_extra2 ", + intval(\App::$profile['profile_uid']), + dbesc($parents_str) + ); + if($items) { + xchan_query($items); + $items = fetch_post_tags($items, true); + $items = conv_sort($items,'created'); + } + else + $items = []; + } + + $mode = 'channel'; + + $content = conversation($items,$mode,false,'traditional'); + + $o = replace_macros(get_markup_template('cards.tpl'), [ + '$title' => t('Cards'), + '$editor' => $editor, + '$content' => $content, + '$pager' => alt_pager($a,count($items)) + ]); + + return $o; + } + +} -- cgit v1.2.3 From 3b68df1be6173cbcc50386efc0161ece2015112d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 23 Aug 2017 17:46:20 -0700 Subject: several card enhancements --- Zotlabs/Module/Cards.php | 54 ++++++++++++++++++++---------------------------- 1 file changed, 22 insertions(+), 32 deletions(-) (limited to 'Zotlabs/Module/Cards.php') diff --git a/Zotlabs/Module/Cards.php b/Zotlabs/Module/Cards.php index 1fdd3b63f..1c37ca13d 100644 --- a/Zotlabs/Module/Cards.php +++ b/Zotlabs/Module/Cards.php @@ -47,24 +47,14 @@ class Cards extends \Zotlabs\Web\Controller { $which = argv(1); + $selected_card = ((argc() > 2) ? argv(2) : ''); + $_SESSION['return_url'] = \App::$query_string; - $uid = \App::$profile_uid; - $owner = 0; + $uid = local_channel(); + $owner = \App::$profile_uid; $observer = \App::get_observer(); - $channel = \App::$profile; - - if(! $owner) { - // 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']); - } - } - $ob_hash = (($observer) ? $observer['xchan_hash'] : ''); if(! perm_is_allowed($owner,$ob_hash,'view_pages')) { @@ -76,13 +66,10 @@ class Cards extends \Zotlabs\Web\Controller { $layout = (($_REQUEST['layout']) ? $_REQUEST['layout'] : get_pconfig($owner,'system','page_layout')); - // 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 owner's. - // This lets you post pages at other people's channels. + $is_owner = ($uid && $uid == $owner); - if((! $channel) && ($uid) && ($uid == \App::$profile_uid)) { - $channel = \App::get_channel(); - } + $channel = channelx_by_n($owner); + if($channel) { $channel_acl = array( 'allow_cid' => $channel['channel_allow_cid'], @@ -95,28 +82,25 @@ class Cards extends \Zotlabs\Web\Controller { $channel_acl = [ 'allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '' ]; } - - $is_owner = ($uid && $uid == $owner); - if(perm_is_allowed($owner,$ob_hash,'write_pages')) { $x = array( 'webpage' => ITEM_TYPE_CARD, 'is_owner' => true, - 'nickname' => \App::$profile['channel_address'], + 'nickname' => $channel['channel_address'], 'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), 'acl' => (($is_owner) ? populate_acl($channel_acl,false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_pages')) : ''), 'permissions' => $channel_acl, 'showacl' => (($is_owner) ? true : false), 'visitor' => true, - 'hide_location' => true, - 'hide_voting' => true, + 'hide_location' => false, + 'hide_voting' => false, 'profile_uid' => intval($owner), 'mimetype' => $mimetype, 'mimeselect' => false, 'layoutselect' => false, 'expanded' => false, - 'novoting'=> true, + 'novoting'=> false, 'bbco_autocomplete' => 'bbcode', 'bbcode' => true ); @@ -130,12 +114,18 @@ class Cards extends \Zotlabs\Web\Controller { if($_REQUEST['body']) $x['body'] = $_REQUEST['body']; - // 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. - - + $sql_extra = item_permissions_sql($owner); - + + if($selected_card) { + $r = q("select * from iconfig where iconfig.cat = 'system' and iconfig.k = 'CARD' and iconfig.v = '%s' limit 1", + dbesc($selected_card) + ); + if($r) { + $sql_extra .= "and item.id = " . intval($r[0]['iid']) . " "; + } + } + $r = q("select * from item where item.uid = %d and item_type = %d $sql_extra order by item.created desc", -- cgit v1.2.3 From ecfc7b8f4cc6fbc646e58a2445398341fae5e642 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 23 Aug 2017 18:15:31 -0700 Subject: add category support to main page --- Zotlabs/Module/Cards.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Zotlabs/Module/Cards.php') diff --git a/Zotlabs/Module/Cards.php b/Zotlabs/Module/Cards.php index 1c37ca13d..c542cd6ff 100644 --- a/Zotlabs/Module/Cards.php +++ b/Zotlabs/Module/Cards.php @@ -82,6 +82,8 @@ class Cards extends \Zotlabs\Web\Controller { $channel_acl = [ 'allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '' ]; } + + if(perm_is_allowed($owner,$ob_hash,'write_pages')) { $x = array( @@ -101,6 +103,7 @@ class Cards extends \Zotlabs\Web\Controller { 'layoutselect' => false, 'expanded' => false, 'novoting'=> false, + 'catsenabled' => feature_enabled($owner,'categories'), 'bbco_autocomplete' => 'bbcode', 'bbcode' => true ); -- cgit v1.2.3 From f2e802229acb871e0b50afb729445cdef8586951 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 23 Aug 2017 20:02:28 -0700 Subject: add new conv_sort option --- Zotlabs/Module/Cards.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Module/Cards.php') diff --git a/Zotlabs/Module/Cards.php b/Zotlabs/Module/Cards.php index c542cd6ff..33688cba0 100644 --- a/Zotlabs/Module/Cards.php +++ b/Zotlabs/Module/Cards.php @@ -159,7 +159,7 @@ class Cards extends \Zotlabs\Web\Controller { if($items) { xchan_query($items); $items = fetch_post_tags($items, true); - $items = conv_sort($items,'created'); + $items = conv_sort($items,'updated'); } else $items = []; -- cgit v1.2.3 From 66b032823b4fd941f613b0194bb8412b216cc748 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 23 Aug 2017 20:47:08 -0700 Subject: oembed provider cleanup, add oembed to cards --- Zotlabs/Module/Cards.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Zotlabs/Module/Cards.php') diff --git a/Zotlabs/Module/Cards.php b/Zotlabs/Module/Cards.php index 33688cba0..f354544d5 100644 --- a/Zotlabs/Module/Cards.php +++ b/Zotlabs/Module/Cards.php @@ -38,6 +38,14 @@ class Cards extends \Zotlabs\Web\Controller { nav_set_selected(t('Cards')); + head_add_link([ + 'rel' => 'alternate', + 'type' => 'application/json+oembed', + 'href' => z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . \App::$query_string), + 'title' => 'oembed' + ]); + + $category = (($_REQUEST['cat']) ? escape_tags(trim($_REQUEST['cat'])) : ''); if($category) { -- cgit v1.2.3 From 4450170790de3999dc9c6f8876074e76edee8241 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 23 Aug 2017 21:26:09 -0700 Subject: partial support (unfinished) for ajax loading cards with liveupdate; page still functions even though this isn't finished --- Zotlabs/Module/Cards.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'Zotlabs/Module/Cards.php') diff --git a/Zotlabs/Module/Cards.php b/Zotlabs/Module/Cards.php index f354544d5..19932769f 100644 --- a/Zotlabs/Module/Cards.php +++ b/Zotlabs/Module/Cards.php @@ -19,8 +19,7 @@ class Cards extends \Zotlabs\Web\Controller { } - - function get() { + function get($update = 0, $load = false) { if(observer_prohibited(true)) { return login(); @@ -173,7 +172,7 @@ class Cards extends \Zotlabs\Web\Controller { $items = []; } - $mode = 'channel'; + $mode = 'cards'; $content = conversation($items,$mode,false,'traditional'); -- cgit v1.2.3 From e157e3bec8722c04ed8dc2d215cd2efd0ce3ce79 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 23 Aug 2017 22:06:42 -0700 Subject: cards: make page load after comment post --- Zotlabs/Module/Cards.php | 70 +++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 37 deletions(-) (limited to 'Zotlabs/Module/Cards.php') diff --git a/Zotlabs/Module/Cards.php b/Zotlabs/Module/Cards.php index 19932769f..9114e3b89 100644 --- a/Zotlabs/Module/Cards.php +++ b/Zotlabs/Module/Cards.php @@ -58,8 +58,8 @@ class Cards extends \Zotlabs\Web\Controller { $_SESSION['return_url'] = \App::$query_string; - $uid = local_channel(); - $owner = \App::$profile_uid; + $uid = local_channel(); + $owner = \App::$profile_uid; $observer = \App::get_observer(); $ob_hash = (($observer) ? $observer['xchan_hash'] : ''); @@ -68,11 +68,7 @@ class Cards extends \Zotlabs\Web\Controller { notice( t('Permission denied.') . EOL); return; } - - $mimetype = (($_REQUEST['mimetype']) ? $_REQUEST['mimetype'] : get_pconfig($owner,'system','page_mimetype')); - - $layout = (($_REQUEST['layout']) ? $_REQUEST['layout'] : get_pconfig($owner,'system','page_layout')); - + $is_owner = ($uid && $uid == $owner); $channel = channelx_by_n($owner); @@ -93,38 +89,42 @@ class Cards extends \Zotlabs\Web\Controller { if(perm_is_allowed($owner,$ob_hash,'write_pages')) { - $x = array( - 'webpage' => ITEM_TYPE_CARD, - 'is_owner' => true, - 'nickname' => $channel['channel_address'], - 'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), - 'acl' => (($is_owner) ? populate_acl($channel_acl,false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_pages')) : ''), - 'permissions' => $channel_acl, - 'showacl' => (($is_owner) ? true : false), - 'visitor' => true, - 'hide_location' => false, - 'hide_voting' => false, - 'profile_uid' => intval($owner), - 'mimetype' => $mimetype, - 'mimeselect' => false, - 'layoutselect' => false, - 'expanded' => false, - 'novoting'=> false, - 'catsenabled' => feature_enabled($owner,'categories'), + $x = [ + 'webpage' => ITEM_TYPE_CARD, + 'is_owner' => true, + 'nickname' => $channel['channel_address'], + 'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] + || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), + 'acl' => (($is_owner) ? populate_acl($channel_acl, false, + \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_pages')) : ''), + 'permissions' => $channel_acl, + 'showacl' => (($is_owner) ? true : false), + 'visitor' => true, + 'hide_location' => false, + 'hide_voting' => false, + 'profile_uid' => intval($owner), + 'mimetype' => 'text/bbcode', + 'mimeselect' => false, + 'layoutselect' => false, + 'expanded' => false, + 'novoting' => false, + 'catsenabled' => feature_enabled($owner,'categories'), 'bbco_autocomplete' => 'bbcode', - 'bbcode' => true - ); + 'bbcode' => true + ]; + + if($_REQUEST['title']) + $x['title'] = $_REQUEST['title']; + if($_REQUEST['body']) + $x['body'] = $_REQUEST['body']; + $editor = status_editor($a,$x); + } else { - $x = ''; + $editor = ''; } - if($_REQUEST['title']) - $x['title'] = $_REQUEST['title']; - if($_REQUEST['body']) - $x['body'] = $_REQUEST['body']; - $sql_extra = item_permissions_sql($owner); if($selected_card) { @@ -147,10 +147,6 @@ class Cards extends \Zotlabs\Web\Controller { and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0 and item.item_blocked = 0 "; - - if($x) - $editor = status_editor($a,$x); - if($r) { $parents_str = ids_to_querystr($r,'id'); -- cgit v1.2.3