From 755b75161494ea9810ab0e38242cb1a318793ed3 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 15 Mar 2017 16:55:47 -0700 Subject: Comanche: allow widgets to be class based and stored appropriately in Zotlabs --- Zotlabs/Render/Comanche.php | 14 ++++++++++++++ Zotlabs/Widget/Notes.php | 23 +++++++++++++++++++++++ include/widgets.php | 16 ---------------- 3 files changed, 37 insertions(+), 16 deletions(-) create mode 100644 Zotlabs/Widget/Notes.php diff --git a/Zotlabs/Render/Comanche.php b/Zotlabs/Render/Comanche.php index 5826063fd..899fbd8aa 100644 --- a/Zotlabs/Render/Comanche.php +++ b/Zotlabs/Render/Comanche.php @@ -410,6 +410,20 @@ class Comanche { } } + $clsname = ucfirst($name); + $nsname = "Zotlabs\\Widget\\" . $clsname; + if(file_exists('Zotlabs/SiteWidget/' . $clsname . '.php')) + require_once('Zotlabs/SiteWidget/' . $clsname . '.php'); + elseif(file_exists('Zotlabs/Widget/' . $clsname . '.php')) + require_once('Zotlabs/Widget/' . $clsname . '.php'); + if(class_exists($nsname)) { + $x = new $nsname; + $f = 'widget'; + if(method_exists($x,$f)) { + return $x->$f($vars); + } + } + $func = 'widget_' . trim($name); if(! function_exists($func)) { diff --git a/Zotlabs/Widget/Notes.php b/Zotlabs/Widget/Notes.php new file mode 100644 index 000000000..5c83a550f --- /dev/null +++ b/Zotlabs/Widget/Notes.php @@ -0,0 +1,23 @@ + t('Notes'), + '$text' => $text, + '$save' => t('Save'), + )); + + return $o; + } +} diff --git a/include/widgets.php b/include/widgets.php index c88c03f7e..54390ede4 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -174,22 +174,6 @@ function widget_follow($args) { } -function widget_notes($arr) { - if(! local_channel()) - return ''; - if(! feature_enabled(local_channel(),'private_notes')) - return ''; - - $text = get_pconfig(local_channel(),'notes','text'); - - $o = replace_macros(get_markup_template('notes.tpl'), array( - '$banner' => t('Notes'), - '$text' => $text, - '$save' => t('Save'), - )); - - return $o; -} function widget_savedsearch($arr) { -- cgit v1.2.3 From 242ef70a775a86050152c0aea9096ec1cd6d0312 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 15 Mar 2017 17:05:16 -0700 Subject: use absolute namespace --- Zotlabs/Render/Comanche.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Zotlabs/Render/Comanche.php b/Zotlabs/Render/Comanche.php index 899fbd8aa..60a7b232c 100644 --- a/Zotlabs/Render/Comanche.php +++ b/Zotlabs/Render/Comanche.php @@ -411,7 +411,8 @@ class Comanche { } $clsname = ucfirst($name); - $nsname = "Zotlabs\\Widget\\" . $clsname; + $nsname = "\\Zotlabs\\Widget\\" . $clsname; + if(file_exists('Zotlabs/SiteWidget/' . $clsname . '.php')) require_once('Zotlabs/SiteWidget/' . $clsname . '.php'); elseif(file_exists('Zotlabs/Widget/' . $clsname . '.php')) -- cgit v1.2.3 From 477ed97c2fbfff903f9ebf0ffa7fba078eeac10f Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 15 Mar 2017 18:31:34 -0700 Subject: convert more widgets to classes --- Zotlabs/Widget/Collections.php | 51 ++++++++++++++++ Zotlabs/Widget/Profile | 13 ++++ Zotlabs/Widget/Suggestions.php | 58 ++++++++++++++++++ Zotlabs/Widget/Tagcloud.php | 33 ++++++++++ Zotlabs/Widget/Zcard.php | 11 ++++ include/widgets.php | 133 ----------------------------------------- 6 files changed, 166 insertions(+), 133 deletions(-) create mode 100644 Zotlabs/Widget/Collections.php create mode 100644 Zotlabs/Widget/Profile create mode 100644 Zotlabs/Widget/Suggestions.php create mode 100644 Zotlabs/Widget/Tagcloud.php create mode 100644 Zotlabs/Widget/Zcard.php diff --git a/Zotlabs/Widget/Collections.php b/Zotlabs/Widget/Collections.php new file mode 100644 index 000000000..d2b29679a --- /dev/null +++ b/Zotlabs/Widget/Collections.php @@ -0,0 +1,51 @@ + 2) ? mt_rand(0,count($r) - 2) : 0); + + for($x = $index; $x <= ($index+1); $x ++) { + $rr = $r[$x]; + if(! $rr['xchan_url']) + break; + + $connlnk = z_root() . '/follow/?url=' . $rr['xchan_addr']; + + $arr[] = array( + 'url' => chanlink_url($rr['xchan_url']), + 'profile' => $rr['xchan_url'], + 'name' => $rr['xchan_name'], + 'photo' => $rr['xchan_photo_m'], + 'ignlnk' => z_root() . '/directory?ignore=' . $rr['xchan_hash'], + 'conntxt' => t('Connect'), + 'connlnk' => $connlnk, + 'ignore' => t('Ignore/Hide') + ); + } + + $o = replace_macros(get_markup_template('suggest_widget.tpl'),array( + '$title' => t('Suggestions'), + '$more' => t('See more...'), + '$entries' => $arr + )); + + return $o; + } +} diff --git a/Zotlabs/Widget/Tagcloud.php b/Zotlabs/Widget/Tagcloud.php new file mode 100644 index 000000000..cf7a4932e --- /dev/null +++ b/Zotlabs/Widget/Tagcloud.php @@ -0,0 +1,33 @@ +

' . t('Categories') . '

'; + foreach($r as $rv) { + $o .= '' . $rv[0] .' ' . "\r\n"; + } + $o .= '
'; + } + return $o; + } +} diff --git a/Zotlabs/Widget/Zcard.php b/Zotlabs/Widget/Zcard.php new file mode 100644 index 000000000..12e53eaab --- /dev/null +++ b/Zotlabs/Widget/Zcard.php @@ -0,0 +1,11 @@ + 875)); + } +} diff --git a/include/widgets.php b/include/widgets.php index 54390ede4..3559f8a82 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -10,141 +10,8 @@ require_once('include/contact_widgets.php'); require_once('include/attach.php'); -function widget_profile($args) { - $block = observer_prohibited(); - return profile_sidebar(App::$profile, $block, true); -} - -function widget_zcard($args) { - - $block = observer_prohibited(); - $channel = channelx_by_n(App::$profile_uid); - return get_zcard($channel,get_observer_hash(),array('width' => 875)); -} - - - - -// FIXME The problem with the next widget is that we don't have a search function for webpages that we can send the links to. -// Then we should also provide an option to search webpages and conversations. - -function widget_tagcloud($args) { - - $o = ''; - //$tab = 0; - - $uid = App::$profile_uid; - $count = ((x($args,'count')) ? intval($args['count']) : 24); - $flags = 0; - $type = TERM_CATEGORY; - - // FIXME there exists no $authors variable - $r = tagadelic($uid, $count, $authors, $owner, $flags, ITEM_TYPE_WEBPAGE, $type); - - if($r) { - $o = '

' . t('Categories') . '

'; - foreach($r as $rr) { - $o .= ''.$rr[0].' ' . "\r\n"; - } - $o .= '
'; - } - return $o; -} - -function widget_collections($args) { - require_once('include/group.php'); - - $mode = ((array_key_exists('mode',$args)) ? $args['mode'] : 'conversation'); - switch($mode) { - case 'conversation': - $every = argv(0); - $each = argv(0); - $edit = true; - $current = $_REQUEST['gid']; - $abook_id = 0; - $wmode = 0; - break; - case 'connections': - $every = 'connections'; - $each = 'group'; - $edit = true; - $current = $_REQUEST['gid']; - $abook_id = 0; - $wmode = 0; - case 'groups': - $every = 'connections'; - $each = argv(0); - $edit = false; - $current = intval(argv(1)); - $abook_id = 0; - $wmode = 1; - break; - case 'abook': - $every = 'connections'; - $each = 'group'; - $edit = false; - $current = 0; - $abook_id = App::$poi['abook_xchan']; - $wmode = 1; - break; - default: - return ''; - break; - } - - return group_side($every, $each, $edit, $current, $abook_id, $wmode); -} - -function widget_suggestions($arr) { - - if((! local_channel()) || (! feature_enabled(local_channel(),'suggest'))) - return ''; - - require_once('include/socgraph.php'); - - $r = suggestion_query(local_channel(),get_observer_hash(),0,20); - - if(! $r) { - return; - } - - $arr = array(); - - // Get two random entries from the top 20 returned. - // We'll grab the first one and the one immediately following. - // This will throw some entropy intot he situation so you won't - // be looking at the same two mug shots every time the widget runs - - $index = ((count($r) > 2) ? mt_rand(0,count($r) - 2) : 0); - for($x = $index; $x <= ($index+1); $x ++) { - $rr = $r[$x]; - if(! $rr['xchan_url']) - break; - - $connlnk = z_root() . '/follow/?url=' . $rr['xchan_addr']; - - $arr[] = array( - 'url' => chanlink_url($rr['xchan_url']), - 'profile' => $rr['xchan_url'], - 'name' => $rr['xchan_name'], - 'photo' => $rr['xchan_photo_m'], - 'ignlnk' => z_root() . '/directory?ignore=' . $rr['xchan_hash'], - 'conntxt' => t('Connect'), - 'connlnk' => $connlnk, - 'ignore' => t('Ignore/Hide') - ); - } - - $o = replace_macros(get_markup_template('suggest_widget.tpl'),array( - '$title' => t('Suggestions'), - '$more' => t('See more...'), - '$entries' => $arr - )); - - return $o; -} function widget_follow($args) { -- cgit v1.2.3 From 17977effe775ef05a48a84da40da4b1f049b00d9 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 15 Mar 2017 18:48:27 -0700 Subject: more widgets --- Zotlabs/Widget/Follow.php | 37 ++++++++++ Zotlabs/Widget/Savedsearch.php | 91 ++++++++++++++++++++++++ Zotlabs/Widget/Sitesearch.php | 38 ++++++++++ include/widgets.php | 154 +---------------------------------------- util/typo.php | 25 ++----- 5 files changed, 172 insertions(+), 173 deletions(-) create mode 100644 Zotlabs/Widget/Follow.php create mode 100644 Zotlabs/Widget/Savedsearch.php create mode 100644 Zotlabs/Widget/Sitesearch.php diff --git a/Zotlabs/Widget/Follow.php b/Zotlabs/Widget/Follow.php new file mode 100644 index 000000000..c4aecc8e1 --- /dev/null +++ b/Zotlabs/Widget/Follow.php @@ -0,0 +1,37 @@ + t('Add New Connection'), + '$desc' => t('Enter channel address'), + '$hint' => t('Examples: bob@example.com, https://example.com/barbara'), + '$follow' => t('Connect'), + '$abook_usage_message' => $abook_usage_message + )); + } +} + diff --git a/Zotlabs/Widget/Savedsearch.php b/Zotlabs/Widget/Savedsearch.php new file mode 100644 index 000000000..378c27139 --- /dev/null +++ b/Zotlabs/Widget/Savedsearch.php @@ -0,0 +1,91 @@ + $rr['tid'], + 'term' => $rr['term'], + 'dellink' => z_root() . '/' . $srchurl . (($hasq || $hasamp) ? '' : '?f=') . '&searchremove=1&search=' . urlencode($rr['term']), + 'srchlink' => z_root() . '/' . $srchurl . (($hasq || $hasamp) ? '' : '?f=') . '&search=' . urlencode($rr['term']), + 'displayterm' => htmlspecialchars($rr['term'], ENT_COMPAT,'UTF-8'), + 'encodedterm' => urlencode($rr['term']), + 'delete' => t('Remove term'), + 'selected' => ($search==$rr['term']), + ); + } + } + + $tpl = get_markup_template("saved_searches.tpl"); + $o = replace_macros($tpl, array( + '$title' => t('Saved Searches'), + '$add' => t('add'), + '$searchbox' => searchbox($search, 'netsearch-box', $srchurl . (($hasq) ? '' : '?f='), true), + '$saved' => $saved, + )); + + return $o; + } +} diff --git a/Zotlabs/Widget/Sitesearch.php b/Zotlabs/Widget/Sitesearch.php new file mode 100644 index 000000000..b3a25d76a --- /dev/null +++ b/Zotlabs/Widget/Sitesearch.php @@ -0,0 +1,38 @@ + t('Search'), + '$searchbox' => searchbox($search, 'netsearch-box', $srchurl . (($hasq) ? '' : '?f='), false), + '$saved' => $saved, + )); + + return $o; + } +} diff --git a/include/widgets.php b/include/widgets.php index 3559f8a82..20b4a312c 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -2,7 +2,7 @@ /** * @file include/widgets.php * - * @brief This file contains the widgets. + * @brief This file contains some widgets. */ require_once('include/dir_fns.php'); @@ -10,158 +10,6 @@ require_once('include/contact_widgets.php'); require_once('include/attach.php'); - - - - -function widget_follow($args) { - if(! local_channel()) - return ''; - - $uid = App::$channel['channel_id']; - $r = q("select count(*) as total from abook where abook_channel = %d and abook_self = 0 ", - intval($uid) - ); - if($r) - $total_channels = $r[0]['total']; - $limit = service_class_fetch($uid,'total_channels'); - if($limit !== false) { - $abook_usage_message = sprintf( t("You have %1$.0f of %2$.0f allowed connections."), $total_channels, $limit); - } - else { - $abook_usage_message = ''; - } - return replace_macros(get_markup_template('follow.tpl'),array( - '$connect' => t('Add New Connection'), - '$desc' => t('Enter channel address'), - '$hint' => t('Examples: bob@example.com, https://example.com/barbara'), - '$follow' => t('Connect'), - '$abook_usage_message' => $abook_usage_message - )); -} - - - - -function widget_savedsearch($arr) { - if((! local_channel()) || (! feature_enabled(local_channel(),'savedsearch'))) - return ''; - - $search = ((x($_GET,'netsearch')) ? $_GET['netsearch'] : ''); - if(! $search) - $search = ((x($_GET,'search')) ? $_GET['search'] : ''); - - if(x($_GET,'searchsave') && $search) { - $r = q("select * from term where uid = %d and ttype = %d and term = '%s' limit 1", - intval(local_channel()), - intval(TERM_SAVEDSEARCH), - dbesc($search) - ); - if(! $r) { - q("insert into term ( uid,ttype,term ) values ( %d, %d, '%s') ", - intval(local_channel()), - intval(TERM_SAVEDSEARCH), - dbesc($search) - ); - } - } - - if(x($_GET,'searchremove') && $search) { - q("delete from term where uid = %d and ttype = %d and term = '%s'", - intval(local_channel()), - intval(TERM_SAVEDSEARCH), - dbesc($search) - ); - $search = ''; - } - - $srchurl = App::$query_string; - - $srchurl = rtrim(preg_replace('/searchsave\=[^\&].*?(\&|$)/is','',$srchurl),'&'); - $hasq = ((strpos($srchurl,'?') !== false) ? true : false); - $srchurl = rtrim(preg_replace('/searchremove\=[^\&].*?(\&|$)/is','',$srchurl),'&'); - - $srchurl = rtrim(preg_replace('/search\=[^\&].*?(\&|$)/is','',$srchurl),'&'); - $srchurl = rtrim(preg_replace('/submit\=[^\&].*?(\&|$)/is','',$srchurl),'&'); - $srchurl = str_replace(array('?f=','&f='),array('',''),$srchurl); - - - $hasq = ((strpos($srchurl,'?') !== false) ? true : false); - $hasamp = ((strpos($srchurl,'&') !== false) ? true : false); - - if(($hasamp) && (! $hasq)) - $srchurl = substr($srchurl,0,strpos($srchurl,'&')) . '?f=&' . substr($srchurl,strpos($srchurl,'&')+1); - - $o = ''; - - $r = q("select tid,term from term WHERE uid = %d and ttype = %d ", - intval(local_channel()), - intval(TERM_SAVEDSEARCH) - ); - - $saved = array(); - - if(count($r)) { - foreach($r as $rr) { - $saved[] = array( - 'id' => $rr['tid'], - 'term' => $rr['term'], - 'dellink' => z_root() . '/' . $srchurl . (($hasq || $hasamp) ? '' : '?f=') . '&searchremove=1&search=' . urlencode($rr['term']), - 'srchlink' => z_root() . '/' . $srchurl . (($hasq || $hasamp) ? '' : '?f=') . '&search=' . urlencode($rr['term']), - 'displayterm' => htmlspecialchars($rr['term'], ENT_COMPAT,'UTF-8'), - 'encodedterm' => urlencode($rr['term']), - 'delete' => t('Remove term'), - 'selected' => ($search==$rr['term']), - ); - } - } - - $tpl = get_markup_template("saved_searches.tpl"); - $o = replace_macros($tpl, array( - '$title' => t('Saved Searches'), - '$add' => t('add'), - '$searchbox' => searchbox($search, 'netsearch-box', $srchurl . (($hasq) ? '' : '?f='), true), - '$saved' => $saved, - )); - - return $o; -} - -function widget_sitesearch($arr) { - - $search = ((x($_GET,'search')) ? $_GET['search'] : ''); - - $srchurl = App::$query_string; - - $srchurl = rtrim(preg_replace('/search\=[^\&].*?(\&|$)/is','',$srchurl),'&'); - $srchurl = rtrim(preg_replace('/submit\=[^\&].*?(\&|$)/is','',$srchurl),'&'); - $srchurl = str_replace(array('?f=','&f='),array('',''),$srchurl); - - - $hasq = ((strpos($srchurl,'?') !== false) ? true : false); - $hasamp = ((strpos($srchurl,'&') !== false) ? true : false); - - if(($hasamp) && (! $hasq)) - $srchurl = substr($srchurl,0,strpos($srchurl,'&')) . '?f=&' . substr($srchurl,strpos($srchurl,'&')+1); - - $o = ''; - - $saved = array(); - - $tpl = get_markup_template("sitesearch.tpl"); - $o = replace_macros($tpl, array( - '$title' => t('Search'), - '$searchbox' => searchbox($search, 'netsearch-box', $srchurl . (($hasq) ? '' : '?f='), false), - '$saved' => $saved, - )); - - return $o; -} - - - - - function widget_filer($arr) { if(! local_channel()) return ''; diff --git a/util/typo.php b/util/typo.php index f9c9e5353..a8d363340 100644 --- a/util/typo.php +++ b/util/typo.php @@ -28,17 +28,18 @@ include_once($file); } - echo "Directory: include/RedDAV\n"; - $files = glob('include/RedDAV/*.php'); + echo "Directory: include/photo\n"; + $files = glob('include/photo/*.php'); foreach($files as $file) { echo $file . "\n"; include_once($file); } + echo "Directory: Zotlabs\n"; $files = glob('Zotlabs/*/*.php'); foreach($files as $file) { - if(strpos($file,'SiteModule') === false) { + if((strpos($file,'SiteModule') === false) || (strpos($file,'SiteWidget') === false)) { echo $file . "\n"; include_once($file); } @@ -51,21 +52,6 @@ include_once($file); } - - echo "Directory: include/photo\n"; - $files = glob('include/photo/*.php'); - foreach($files as $file) { - echo $file . "\n"; - include_once($file); - } - -// echo "Directory: mod\n"; -// $files = glob('mod/*.php'); -// foreach($files as $file) { -// echo $file . "\n"; -// include_once($file); -// } - echo "Directory: addon\n"; $dirs = glob('addon/*'); @@ -93,6 +79,5 @@ foreach($files as $file) { echo $file . "\n"; - passthru($phpath . ' util/typohelper.php ' . $file); -// include_once($file); + passthru($phpath . ' util/typohelper.php ' . $file); } -- cgit v1.2.3 From 74f58818d628a30297f48720b73c094b215f593b Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 15 Mar 2017 19:13:16 -0700 Subject: filename issue --- Zotlabs/Widget/Profile | 13 ------------- Zotlabs/Widget/Profile.php | 13 +++++++++++++ 2 files changed, 13 insertions(+), 13 deletions(-) delete mode 100644 Zotlabs/Widget/Profile create mode 100644 Zotlabs/Widget/Profile.php diff --git a/Zotlabs/Widget/Profile b/Zotlabs/Widget/Profile deleted file mode 100644 index bffd910b6..000000000 --- a/Zotlabs/Widget/Profile +++ /dev/null @@ -1,13 +0,0 @@ - Date: Wed, 15 Mar 2017 19:30:57 -0700 Subject: more widgets --- Zotlabs/Widget/Archive.php | 55 ++++++++++++++++++++++++++++ Zotlabs/Widget/Filer.php | 35 ++++++++++++++++++ Zotlabs/Widget/Fullprofile.php | 16 ++++++++ include/widgets.php | 83 ------------------------------------------ 4 files changed, 106 insertions(+), 83 deletions(-) create mode 100644 Zotlabs/Widget/Archive.php create mode 100644 Zotlabs/Widget/Filer.php create mode 100644 Zotlabs/Widget/Fullprofile.php diff --git a/Zotlabs/Widget/Archive.php b/Zotlabs/Widget/Archive.php new file mode 100644 index 000000000..c151ca563 --- /dev/null +++ b/Zotlabs/Widget/Archive.php @@ -0,0 +1,55 @@ + t('Archives'), + '$size' => $visible_years, + '$cutoff_year' => $cutoff_year, + '$cutoff' => $cutoff, + '$url' => $url, + '$style' => $style, + '$showend' => $showend, + '$dates' => $ret + )); + return $o; + } +} + diff --git a/Zotlabs/Widget/Filer.php b/Zotlabs/Widget/Filer.php new file mode 100644 index 000000000..cb9a0becf --- /dev/null +++ b/Zotlabs/Widget/Filer.php @@ -0,0 +1,35 @@ + $rr['term'], 'selected' => (($selected == $rr['term']) ? 'selected' : '')); + + return replace_macros(get_markup_template('fileas_widget.tpl'),array( + '$title' => t('Saved Folders'), + '$desc' => '', + '$sel_all' => (($selected == '') ? 'selected' : ''), + '$all' => t('Everything'), + '$terms' => $terms, + '$base' => z_root() . '/' . \App::$cmd + )); + } +} diff --git a/Zotlabs/Widget/Fullprofile.php b/Zotlabs/Widget/Fullprofile.php new file mode 100644 index 000000000..d7340ef40 --- /dev/null +++ b/Zotlabs/Widget/Fullprofile.php @@ -0,0 +1,16 @@ + $rr['term'], 'selected' => (($selected == $rr['term']) ? 'selected' : '')); - - return replace_macros(get_markup_template('fileas_widget.tpl'),array( - '$title' => t('Saved Folders'), - '$desc' => '', - '$sel_all' => (($selected == '') ? 'selected' : ''), - '$all' => t('Everything'), - '$terms' => $terms, - '$base' => z_root() . '/' . App::$cmd - )); -} - -function widget_archive($arr) { - - $o = ''; - - if(! App::$profile_uid) { - return ''; - } - - $uid = App::$profile_uid; - - if(! feature_enabled($uid,'archives')) - return ''; - - if(! perm_is_allowed($uid,get_observer_hash(),'view_stream')) - return ''; - - $wall = ((array_key_exists('wall', $arr)) ? intval($arr['wall']) : 0); - $style = ((array_key_exists('style', $arr)) ? $arr['style'] : 'select'); - $showend = ((get_pconfig($uid,'system','archive_show_end_date')) ? true : false); - $mindate = get_pconfig($uid,'system','archive_mindate'); - $visible_years = get_pconfig($uid,'system','archive_visible_years'); - if(! $visible_years) - $visible_years = 5; - - $url = z_root() . '/' . App::$cmd; - - $ret = list_post_dates($uid,$wall,$mindate); - - if(! count($ret)) - return ''; - - $cutoff_year = intval(datetime_convert('',date_default_timezone_get(),'now','Y')) - $visible_years; - $cutoff = ((array_key_exists($cutoff_year,$ret))? true : false); - - $o = replace_macros(get_markup_template('posted_date_widget.tpl'),array( - '$title' => t('Archives'), - '$size' => $visible_years, - '$cutoff_year' => $cutoff_year, - '$cutoff' => $cutoff, - '$url' => $url, - '$style' => $style, - '$showend' => $showend, - '$dates' => $ret - )); - return $o; -} - - -function widget_fullprofile($arr) { - - if(! App::$profile['profile_uid']) - return; - - $block = observer_prohibited(); - - return profile_sidebar(App::$profile, $block); -} function widget_shortprofile($arr) { -- cgit v1.2.3 From f60309efa12be3b8d4f5b2c565ebdf7f051a987d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 15 Mar 2017 20:11:28 -0700 Subject: more widget migrations --- Zotlabs/Widget/Appcategories.php | 49 +++++++++++++++++++++++++++ Zotlabs/Widget/Appcloud.php | 13 +++++++ Zotlabs/Widget/Categories.php | 22 ++++++++++++ Zotlabs/Widget/Shortprofile.php | 18 ++++++++++ include/widgets.php | 73 ---------------------------------------- 5 files changed, 102 insertions(+), 73 deletions(-) create mode 100644 Zotlabs/Widget/Appcategories.php create mode 100644 Zotlabs/Widget/Appcloud.php create mode 100644 Zotlabs/Widget/Categories.php create mode 100644 Zotlabs/Widget/Shortprofile.php diff --git a/Zotlabs/Widget/Appcategories.php b/Zotlabs/Widget/Appcategories.php new file mode 100644 index 000000000..490ec1abc --- /dev/null +++ b/Zotlabs/Widget/Appcategories.php @@ -0,0 +1,49 @@ + $rr['term'], 'selected' => (($selected == $rr['term']) ? 'selected' : '')); + + return replace_macros(get_markup_template('categories_widget.tpl'),array( + '$title' => t('Categories'), + '$desc' => '', + '$sel_all' => (($selected == '') ? 'selected' : ''), + '$all' => t('Everything'), + '$terms' => $terms, + '$base' => $srchurl, + + )); + } + } +} diff --git a/Zotlabs/Widget/Appcloud.php b/Zotlabs/Widget/Appcloud.php new file mode 100644 index 000000000..2a4671eee --- /dev/null +++ b/Zotlabs/Widget/Appcloud.php @@ -0,0 +1,13 @@ + $rr['term'], 'selected' => (($selected == $rr['term']) ? 'selected' : '')); - - return replace_macros(get_markup_template('categories_widget.tpl'),array( - '$title' => t('Categories'), - '$desc' => '', - '$sel_all' => (($selected == '') ? 'selected' : ''), - '$all' => t('Everything'), - '$terms' => $terms, - '$base' => $srchurl, - - )); - } - - - -} - - - -function widget_appcloud($arr) { - if(! local_channel()) - return ''; - return app_tagblock(z_root() . '/apps'); -} function widget_tagcloud_wall($arr) { -- cgit v1.2.3 From 6e101e458268c0f9b7bf461cea3c31c37b5e3791 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 15 Mar 2017 20:56:12 -0700 Subject: widgets cont. --- Zotlabs/Widget/Affinity.php | 60 +++++++ Zotlabs/Widget/Catcloud_wall.php | 19 +++ Zotlabs/Widget/Conversations.php | 74 +++++++++ Zotlabs/Widget/Design_tools.php | 21 +++ Zotlabs/Widget/Eventstools.php | 19 +++ Zotlabs/Widget/Mailmenu.php | 36 ++++ Zotlabs/Widget/Photo_albums.php | 25 +++ Zotlabs/Widget/Settings_menu.php | 137 ++++++++++++++++ Zotlabs/Widget/Tagcloud_wall.php | 20 +++ include/widgets.php | 345 --------------------------------------- 10 files changed, 411 insertions(+), 345 deletions(-) create mode 100644 Zotlabs/Widget/Affinity.php create mode 100644 Zotlabs/Widget/Catcloud_wall.php create mode 100644 Zotlabs/Widget/Conversations.php create mode 100644 Zotlabs/Widget/Design_tools.php create mode 100644 Zotlabs/Widget/Eventstools.php create mode 100644 Zotlabs/Widget/Mailmenu.php create mode 100644 Zotlabs/Widget/Photo_albums.php create mode 100644 Zotlabs/Widget/Settings_menu.php create mode 100644 Zotlabs/Widget/Tagcloud_wall.php diff --git a/Zotlabs/Widget/Affinity.php b/Zotlabs/Widget/Affinity.php new file mode 100644 index 000000000..439ba1f33 --- /dev/null +++ b/Zotlabs/Widget/Affinity.php @@ -0,0 +1,60 @@ + $cmin . ',' . $cmax, + '$refresh' => t('Refresh'), + '$labels' => $label_str, + )); + + $arr = array('html' => $x); + call_hooks('main_slider',$arr); + return $arr['html']; + } + return ''; + } +} + \ No newline at end of file diff --git a/Zotlabs/Widget/Catcloud_wall.php b/Zotlabs/Widget/Catcloud_wall.php new file mode 100644 index 000000000..3795987cc --- /dev/null +++ b/Zotlabs/Widget/Catcloud_wall.php @@ -0,0 +1,19 @@ + 1) { + + switch(argv(1)) { + case 'combined': + $mailbox = 'combined'; + $header = t('Conversations'); + break; + case 'inbox': + $mailbox = 'inbox'; + $header = t('Received Messages'); + break; + case 'outbox': + $mailbox = 'outbox'; + $header = t('Sent Messages'); + break; + default: + $mailbox = 'combined'; + $header = t('Conversations'); + break; + } + + require_once('include/message.php'); + + // private_messages_list() can do other more complicated stuff, for now keep it simple + $r = private_messages_list(local_channel(), $mailbox, App::$pager['start'], App::$pager['itemspage']); + + if(! $r) { + info( t('No messages.') . EOL); + return $o; + } + + $messages = array(); + + foreach($r as $rr) { + + $messages[] = array( + 'mailbox' => $mailbox, + 'id' => $rr['id'], + 'from_name' => $rr['from']['xchan_name'], + 'from_url' => chanlink_hash($rr['from_xchan']), + 'from_photo' => $rr['from']['xchan_photo_s'], + 'to_name' => $rr['to']['xchan_name'], + 'to_url' => chanlink_hash($rr['to_xchan']), + 'to_photo' => $rr['to']['xchan_photo_s'], + 'subject' => (($rr['seen']) ? $rr['title'] : '' . $rr['title'] . ''), + 'delete' => t('Delete conversation'), + 'body' => $rr['body'], + 'date' => datetime_convert('UTC',date_default_timezone_get(),$rr['created'], 'c'), + 'seen' => $rr['seen'], + 'selected' => ((argv(2)) ? (argv(2) == $rr['id']) : ($r[0]['id'] == $rr['id'])) + ); + } + + $tpl = get_markup_template('mail_head.tpl'); + $o .= replace_macros($tpl, array( + '$header' => $header, + '$messages' => $messages + )); + + } + return $o; + } +} \ No newline at end of file diff --git a/Zotlabs/Widget/Design_tools.php b/Zotlabs/Widget/Design_tools.php new file mode 100644 index 000000000..8ab6a235d --- /dev/null +++ b/Zotlabs/Widget/Design_tools.php @@ -0,0 +1,21 @@ + t('Events Tools'), + '$export' => t('Export Calendar'), + '$import' => t('Import Calendar'), + '$submit' => t('Submit') + )); + } +} diff --git a/Zotlabs/Widget/Mailmenu.php b/Zotlabs/Widget/Mailmenu.php new file mode 100644 index 000000000..512f7d9c0 --- /dev/null +++ b/Zotlabs/Widget/Mailmenu.php @@ -0,0 +1,36 @@ + t('Private Mail Menu'), + '$combined' => array( + 'label' => t('Combined View'), + 'url' => z_root() . '/mail/combined', + 'sel' => (argv(1) == 'combined'), + ), + '$inbox' => array( + 'label' => t('Inbox'), + 'url' => z_root() . '/mail/inbox', + 'sel' => (argv(1) == 'inbox'), + ), + '$outbox' => array( + 'label' => t('Outbox'), + 'url' => z_root() . '/mail/outbox', + 'sel' => (argv(1) == 'outbox'), + ), + '$new' => array( + 'label' => t('New Message'), + 'url' => z_root() . '/mail/new', + 'sel'=> (argv(1) == 'new'), + ) + )); + } +} diff --git a/Zotlabs/Widget/Photo_albums.php b/Zotlabs/Widget/Photo_albums.php new file mode 100644 index 000000000..2a746e492 --- /dev/null +++ b/Zotlabs/Widget/Photo_albums.php @@ -0,0 +1,25 @@ + 1) ? true : false); + + $tabs = array( + array( + 'label' => t('Account settings'), + 'url' => z_root().'/settings/account', + 'selected' => ((argv(1) === 'account') ? 'active' : ''), + ), + + array( + 'label' => t('Channel settings'), + 'url' => z_root().'/settings/channel', + 'selected' => ((argv(1) === 'channel') ? 'active' : ''), + ), + + ); + + if(get_account_techlevel() > 0 && get_features()) { + $tabs[] = array( + 'label' => t('Additional features'), + 'url' => z_root().'/settings/features', + 'selected' => ((argv(1) === 'features') ? 'active' : ''), + ); + } + + $tabs[] = array( + 'label' => t('Feature/Addon settings'), + 'url' => z_root().'/settings/featured', + 'selected' => ((argv(1) === 'featured') ? 'active' : ''), + ); + + $tabs[] = array( + 'label' => t('Display settings'), + 'url' => z_root().'/settings/display', + 'selected' => ((argv(1) === 'display') ? 'active' : ''), + ); + + if($hublocs) { + $tabs[] = array( + 'label' => t('Manage locations'), + 'url' => z_root() . '/locs', + 'selected' => ((argv(1) === 'locs') ? 'active' : ''), + ); + } + + $tabs[] = array( + 'label' => t('Export channel'), + 'url' => z_root() . '/uexport', + 'selected' => '' + ); + + $tabs[] = array( + 'label' => t('Connected apps'), + 'url' => z_root() . '/settings/oauth', + 'selected' => ((argv(1) === 'oauth') ? 'active' : ''), + ); + + if(get_account_techlevel() > 2) { + $tabs[] = array( + 'label' => t('Guest Access Tokens'), + 'url' => z_root() . '/settings/tokens', + 'selected' => ((argv(1) === 'tokens') ? 'active' : ''), + ); + } + + if(feature_enabled(local_channel(),'permcats')) { + $tabs[] = array( + 'label' => t('Permission Groups'), + 'url' => z_root() . '/settings/permcats', + 'selected' => ((argv(1) === 'permcats') ? 'active' : ''), + ); + } + + + if($role === false || $role === 'custom') { + $tabs[] = array( + 'label' => t('Connection Default Permissions'), + 'url' => z_root() . '/connedit/' . $abook_self_id, + 'selected' => '' + ); + } + + if(feature_enabled(local_channel(),'premium_channel')) { + $tabs[] = array( + 'label' => t('Premium Channel Settings'), + 'url' => z_root() . '/connect/' . $channel['channel_address'], + 'selected' => '' + ); + } + + if(feature_enabled(local_channel(),'channel_sources')) { + $tabs[] = array( + 'label' => t('Channel Sources'), + 'url' => z_root() . '/sources', + 'selected' => '' + ); + } + + $tabtpl = get_markup_template("generic_links_widget.tpl"); + return replace_macros($tabtpl, array( + '$title' => t('Settings'), + '$class' => 'settings-widget', + '$items' => $tabs, + )); + } + +} \ No newline at end of file diff --git a/Zotlabs/Widget/Tagcloud_wall.php b/Zotlabs/Widget/Tagcloud_wall.php new file mode 100644 index 000000000..7cff6ce09 --- /dev/null +++ b/Zotlabs/Widget/Tagcloud_wall.php @@ -0,0 +1,20 @@ + $cmin . ',' . $cmax, - '$refresh' => t('Refresh'), - '$labels' => $label_str, - )); - $arr = array('html' => $x); - call_hooks('main_slider',$arr); - return $arr['html']; - } - - return ''; -} - - -function widget_settings_menu($arr) { - - if(! local_channel()) - return; - - - $channel = App::get_channel(); - - $abook_self_id = 0; - - // Retrieve the 'self' address book entry for use in the auto-permissions link - - $role = get_pconfig(local_channel(),'system','permissions_role'); - - $abk = q("select abook_id from abook where abook_channel = %d and abook_self = 1 limit 1", - intval(local_channel()) - ); - if($abk) - $abook_self_id = $abk[0]['abook_id']; - - $x = q("select count(*) as total from hubloc where hubloc_hash = '%s' and hubloc_deleted = 0 ", - dbesc($channel['channel_hash']) - ); - - $hublocs = (($x && $x[0]['total'] > 1) ? true : false); - - $tabs = array( - array( - 'label' => t('Account settings'), - 'url' => z_root().'/settings/account', - 'selected' => ((argv(1) === 'account') ? 'active' : ''), - ), - - array( - 'label' => t('Channel settings'), - 'url' => z_root().'/settings/channel', - 'selected' => ((argv(1) === 'channel') ? 'active' : ''), - ), - - ); - - if(get_account_techlevel() > 0 && get_features()) { - $tabs[] = array( - 'label' => t('Additional features'), - 'url' => z_root().'/settings/features', - 'selected' => ((argv(1) === 'features') ? 'active' : ''), - ); - } - - $tabs[] = array( - 'label' => t('Feature/Addon settings'), - 'url' => z_root().'/settings/featured', - 'selected' => ((argv(1) === 'featured') ? 'active' : ''), - ); - - $tabs[] = array( - 'label' => t('Display settings'), - 'url' => z_root().'/settings/display', - 'selected' => ((argv(1) === 'display') ? 'active' : ''), - ); - - if($hublocs) { - $tabs[] = array( - 'label' => t('Manage locations'), - 'url' => z_root() . '/locs', - 'selected' => ((argv(1) === 'locs') ? 'active' : ''), - ); - } - - $tabs[] = array( - 'label' => t('Export channel'), - 'url' => z_root() . '/uexport', - 'selected' => '' - ); - - $tabs[] = array( - 'label' => t('Connected apps'), - 'url' => z_root() . '/settings/oauth', - 'selected' => ((argv(1) === 'oauth') ? 'active' : ''), - ); - - if(get_account_techlevel() > 2) { - $tabs[] = array( - 'label' => t('Guest Access Tokens'), - 'url' => z_root() . '/settings/tokens', - 'selected' => ((argv(1) === 'tokens') ? 'active' : ''), - ); - } - - if(feature_enabled(local_channel(),'permcats')) { - $tabs[] = array( - 'label' => t('Permission Groups'), - 'url' => z_root() . '/settings/permcats', - 'selected' => ((argv(1) === 'permcats') ? 'active' : ''), - ); - } - if($role === false || $role === 'custom') { - $tabs[] = array( - 'label' => t('Connection Default Permissions'), - 'url' => z_root() . '/connedit/' . $abook_self_id, - 'selected' => '' - ); - } - if(feature_enabled(local_channel(),'premium_channel')) { - $tabs[] = array( - 'label' => t('Premium Channel Settings'), - 'url' => z_root() . '/connect/' . $channel['channel_address'], - 'selected' => '' - ); - } - if(feature_enabled(local_channel(),'channel_sources')) { - $tabs[] = array( - 'label' => t('Channel Sources'), - 'url' => z_root() . '/sources', - 'selected' => '' - ); - } - - $tabtpl = get_markup_template("generic_links_widget.tpl"); - return replace_macros($tabtpl, array( - '$title' => t('Settings'), - '$class' => 'settings-widget', - '$items' => $tabs, - )); -} - - -function widget_mailmenu($arr) { - if (! local_channel()) - return; - return replace_macros(get_markup_template('message_side.tpl'), array( - '$title' => t('Private Mail Menu'), - '$combined'=>array( - 'label' => t('Combined View'), - 'url' => z_root() . '/mail/combined', - 'sel' => (argv(1) == 'combined'), - ), - '$inbox'=>array( - 'label' => t('Inbox'), - 'url' => z_root() . '/mail/inbox', - 'sel' => (argv(1) == 'inbox'), - ), - '$outbox'=>array( - 'label' => t('Outbox'), - 'url' => z_root() . '/mail/outbox', - 'sel' => (argv(1) == 'outbox'), - ), - '$new'=>array( - 'label' => t('New Message'), - 'url' => z_root() . '/mail/new', - 'sel'=> (argv(1) == 'new'), - ) - )); -} -function widget_conversations($arr) { - if (! local_channel()) - return; - - if(argc() > 1) { - - switch(argv(1)) { - case 'combined': - $mailbox = 'combined'; - $header = t('Conversations'); - break; - case 'inbox': - $mailbox = 'inbox'; - $header = t('Received Messages'); - break; - case 'outbox': - $mailbox = 'outbox'; - $header = t('Sent Messages'); - break; - default: - $mailbox = 'combined'; - $header = t('Conversations'); - break; - } - - require_once('include/message.php'); - - // private_messages_list() can do other more complicated stuff, for now keep it simple - $r = private_messages_list(local_channel(), $mailbox, App::$pager['start'], App::$pager['itemspage']); - - if(! $r) { - info( t('No messages.') . EOL); - return $o; - } - - $messages = array(); - - foreach($r as $rr) { - - $messages[] = array( - 'mailbox' => $mailbox, - 'id' => $rr['id'], - 'from_name' => $rr['from']['xchan_name'], - 'from_url' => chanlink_hash($rr['from_xchan']), - 'from_photo' => $rr['from']['xchan_photo_s'], - 'to_name' => $rr['to']['xchan_name'], - 'to_url' => chanlink_hash($rr['to_xchan']), - 'to_photo' => $rr['to']['xchan_photo_s'], - 'subject' => (($rr['seen']) ? $rr['title'] : '' . $rr['title'] . ''), - 'delete' => t('Delete conversation'), - 'body' => $rr['body'], - 'date' => datetime_convert('UTC',date_default_timezone_get(),$rr['created'], 'c'), - 'seen' => $rr['seen'], - 'selected' => ((argv(2)) ? (argv(2) == $rr['id']) : ($r[0]['id'] == $rr['id'])) - ); - } - - $tpl = get_markup_template('mail_head.tpl'); - $o .= replace_macros($tpl, array( - '$header' => $header, - '$messages' => $messages - )); - - //$o .= alt_pager($a,count($r)); - - } - - return $o; -} - -function widget_eventstools($arr) { - if (! local_channel()) - return; - - return replace_macros(get_markup_template('events_tools_side.tpl'), array( - '$title' => t('Events Tools'), - '$export' => t('Export Calendar'), - '$import' => t('Import Calendar'), - '$submit' => t('Submit') - )); -} - -function widget_design_tools($arr) { - - // mod menu doesn't load a profile. For any modules which load a profile, check it. - // otherwise local_channel() is sufficient for permissions. - - if(App::$profile['profile_uid']) - if((App::$profile['profile_uid'] != local_channel()) && (! App::$is_sys)) - return ''; - - if(! local_channel()) - return ''; - - return design_tools(); -} function widget_website_portation_tools($arr) { @@ -380,20 +49,6 @@ function widget_findpeople($arr) { } -function widget_photo_albums($arr) { - - if(! App::$profile['profile_uid']) - return ''; - $channelx = channelx_by_n(App::$profile['profile_uid']); - if((! $channelx) || (! perm_is_allowed(App::$profile['profile_uid'], get_observer_hash(), 'view_storage'))) - return ''; - require_once('include/photos.php'); - $sortkey = ((array_key_exists('sortkey',$arr)) ? $arr['sortkey'] : 'album'); - $direction = ((array_key_exists('direction',$arr)) ? $arr['direction'] : 'asc'); - - return photos_album_widget($channelx, App::get_observer(),$sortkey,$direction); -} - function widget_vcard($arr) { return vcard_from_xchan('', App::get_observer()); -- cgit v1.2.3 From 0908da95298bdd7dd96dcb45ac490f8e7aa73a8e Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 15 Mar 2017 21:26:28 -0700 Subject: widgets cont. --- Zotlabs/Widget/Admin.php | 68 ++++++++++++ Zotlabs/Widget/Chatroom_list.php | 24 ++++ Zotlabs/Widget/Chatroom_members.php | 15 +++ Zotlabs/Widget/Menu_preview.php | 16 +++ Zotlabs/Widget/Tasklist.php | 30 +++++ Zotlabs/Widget/Vcard.php | 12 ++ Zotlabs/Widget/Wiki_list.php | 23 ++++ Zotlabs/Widget/Wiki_page_history.php | 27 +++++ Zotlabs/Widget/Wiki_pages.php | 59 ++++++++++ include/widgets.php | 207 ----------------------------------- 10 files changed, 274 insertions(+), 207 deletions(-) create mode 100644 Zotlabs/Widget/Admin.php create mode 100644 Zotlabs/Widget/Chatroom_list.php create mode 100644 Zotlabs/Widget/Chatroom_members.php create mode 100644 Zotlabs/Widget/Menu_preview.php create mode 100644 Zotlabs/Widget/Tasklist.php create mode 100644 Zotlabs/Widget/Vcard.php create mode 100644 Zotlabs/Widget/Wiki_list.php create mode 100644 Zotlabs/Widget/Wiki_page_history.php create mode 100644 Zotlabs/Widget/Wiki_pages.php diff --git a/Zotlabs/Widget/Admin.php b/Zotlabs/Widget/Admin.php new file mode 100644 index 000000000..a761eebe3 --- /dev/null +++ b/Zotlabs/Widget/Admin.php @@ -0,0 +1,68 @@ + array(z_root() . '/admin/site/', t('Site'), 'site'), + 'accounts' => array(z_root() . '/admin/accounts/', t('Accounts'), 'accounts', 'pending-update', t('Member registrations waiting for confirmation')), + 'channels' => array(z_root() . '/admin/channels/', t('Channels'), 'channels'), + 'security' => array(z_root() . '/admin/security/', t('Security'), 'security'), + 'features' => array(z_root() . '/admin/features/', t('Features'), 'features'), + 'plugins' => array(z_root() . '/admin/plugins/', t('Plugins'), 'plugins'), + 'themes' => array(z_root() . '/admin/themes/', t('Themes'), 'themes'), + 'queue' => array(z_root() . '/admin/queue', t('Inspect queue'), 'queue'), + 'profs' => array(z_root() . '/admin/profs', t('Profile Fields'), 'profs'), + 'dbsync' => array(z_root() . '/admin/dbsync/', t('DB updates'), 'dbsync') + ]; + + /* get plugins admin page */ + + $r = q("SELECT * FROM addon WHERE plugin_admin = 1"); + + $plugins = array(); + if($r) { + foreach ($r as $h){ + $plugin = $h['aname']; + $plugins[] = array(z_root() . '/admin/plugins/' . $plugin, $plugin, 'plugin'); + // temp plugins with admin + \App::$plugins_admin[] = $plugin; + } + } + + $logs = array(z_root() . '/admin/logs/', t('Logs'), 'logs'); + + $arr = array('links' => $aside,'plugins' => $plugins,'logs' => $logs); + call_hooks('admin_aside',$arr); + + $o .= replace_macros(get_markup_template('admin_aside.tpl'), array( + '$admin' => $aside, + '$admtxt' => t('Admin'), + '$plugadmtxt' => t('Plugin Features'), + '$plugins' => $plugins, + '$logtxt' => t('Logs'), + '$logs' => $logs, + '$h_pending' => t('Member registrations waiting for confirmation'), + '$admurl'=> z_root() . '/admin/' + )); + + return $o; + + } +} + diff --git a/Zotlabs/Widget/Chatroom_list.php b/Zotlabs/Widget/Chatroom_list.php new file mode 100644 index 000000000..e2aad0e05 --- /dev/null +++ b/Zotlabs/Widget/Chatroom_list.php @@ -0,0 +1,24 @@ + t('Chatrooms'), + '$baseurl' => z_root(), + '$nickname' => \App::$profile['channel_address'], + '$items' => $r, + '$overview' => t('Overview') + )); + } + } +} diff --git a/Zotlabs/Widget/Chatroom_members.php b/Zotlabs/Widget/Chatroom_members.php new file mode 100644 index 000000000..8ed77fb3c --- /dev/null +++ b/Zotlabs/Widget/Chatroom_members.php @@ -0,0 +1,15 @@ + t('Chat Members') + )); + } + +} diff --git a/Zotlabs/Widget/Menu_preview.php b/Zotlabs/Widget/Menu_preview.php new file mode 100644 index 000000000..51218f6cf --- /dev/null +++ b/Zotlabs/Widget/Menu_preview.php @@ -0,0 +1,16 @@ +var tasksShowAll = 0; $(document).ready(function() { tasksFetch(); $("#tasklist-new-form").submit(function(event) { event.preventDefault(); $.post( "tasks/new", $("#tasklist-new-form").serialize(), function(data) { tasksFetch(); $("#tasklist-new-summary").val(""); } ); return false; } )});'; + $o .= ''; + + $o .= '
' . '

' . t('Tasks') . '

'; + $o .= '
'; + $o .= '
'; + return $o; + + } +} + diff --git a/Zotlabs/Widget/Vcard.php b/Zotlabs/Widget/Vcard.php new file mode 100644 index 000000000..cab05dfdd --- /dev/null +++ b/Zotlabs/Widget/Vcard.php @@ -0,0 +1,12 @@ + t('Wiki List'), + '$channel' => $channel['channel_address'], + '$wikis' => $wikis['wikis'] + )); + } + return ''; + } + +} diff --git a/Zotlabs/Widget/Wiki_page_history.php b/Zotlabs/Widget/Wiki_page_history.php new file mode 100644 index 000000000..dcec9a037 --- /dev/null +++ b/Zotlabs/Widget/Wiki_page_history.php @@ -0,0 +1,27 @@ + \App::$profile_uid, + 'observer_hash' => get_observer_hash(), + 'resource_id' => $resource_id, + 'pageUrlName' => $pageUrlName + ]); + + return replace_macros(get_markup_template('nwiki_page_history.tpl'), array( + '$pageHistory' => $pageHistory['history'], + '$permsWrite' => $arr['permsWrite'], + '$name_lbl' => t('Name'), + '$msg_label' => t('Message','wiki_history') + )); + + } +} diff --git a/Zotlabs/Widget/Wiki_pages.php b/Zotlabs/Widget/Wiki_pages.php new file mode 100644 index 000000000..bad451475 --- /dev/null +++ b/Zotlabs/Widget/Wiki_pages.php @@ -0,0 +1,59 @@ + $hide, + '$resource_id' => $arr['resource_id'], + '$not_refresh' => $not_refresh, + '$header' => t('Wiki Pages'), + '$channel' => $channelname, + '$wikiname' => $wikiname, + '$pages' => $pages, + '$canadd' => $can_create, + '$candel' => $can_delete, + '$addnew' => t('Add new page'), + '$pageName' => array('pageName', t('Page name')), + )); + } +} + + diff --git a/include/widgets.php b/include/widgets.php index af23134c9..8ccaad23b 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -12,22 +12,6 @@ require_once('include/attach.php'); - - - - - - - - - - - - - - - - function widget_website_portation_tools($arr) { @@ -50,10 +34,6 @@ function widget_findpeople($arr) { -function widget_vcard($arr) { - return vcard_from_xchan('', App::get_observer()); -} - /* * The following directory widgets are only useful on the directory page @@ -68,114 +48,10 @@ function widget_dirtags($arr) { return dir_tagblock(z_root() . '/directory', null); } -function widget_menu_preview($arr) { - if(! App::$data['menu_item']) - return; - require_once('include/menu.php'); - - return menu_render(App::$data['menu_item']); -} - -function widget_chatroom_list($arr) { - - - $r = Zotlabs\Lib\Chatroom::roomlist(App::$profile['profile_uid']); - - if($r) { - return replace_macros(get_markup_template('chatroomlist.tpl'), array( - '$header' => t('Chatrooms'), - '$baseurl' => z_root(), - '$nickname' => App::$profile['channel_address'], - '$items' => $r, - '$overview' => t('Overview') - )); - } -} - -function widget_chatroom_members() { - $o = replace_macros(get_markup_template('chatroom_members.tpl'), array( - '$header' => t('Chat Members') - )); - - return $o; -} - -function widget_wiki_list($arr) { - - $channel = channelx_by_n(App::$profile_uid); - - $wikis = Zotlabs\Lib\NativeWiki::listwikis($channel,get_observer_hash()); - - if($wikis) { - return replace_macros(get_markup_template('wikilist_widget.tpl'), array( - '$header' => t('Wiki List'), - '$channel' => $channel['channel_address'], - '$wikis' => $wikis['wikis'] - )); - } - return ''; -} - -function widget_wiki_pages($arr) { - - $channelname = ((array_key_exists('channel',$arr)) ? $arr['channel'] : ''); - $c = channelx_by_nick($channelname); - $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; - } else { - $p = Zotlabs\Lib\NativeWikiPage::page_list($c['channel_id'],get_observer_hash(),$arr['resource_id']); - - if($p['pages']) { - $pages = $p['pages']; - $w = $p['wiki']; - // Wiki item record is $w['wiki'] - $wikiname = $w['urlName']; - if (!$wikiname) { - $wikiname = ''; - } - } - } - $can_create = perm_is_allowed(\App::$profile['uid'],get_observer_hash(),'write_wiki'); - - $can_delete = ((local_channel() && (local_channel() == \App::$profile['uid'])) ? true : false); - - return replace_macros(get_markup_template('wiki_page_list.tpl'), array( - '$hide' => $hide, - '$resource_id' => $arr['resource_id'], - '$not_refresh' => $not_refresh, - '$header' => t('Wiki Pages'), - '$channel' => $channelname, - '$wikiname' => $wikiname, - '$pages' => $pages, - '$canadd' => $can_create, - '$candel' => $can_delete, - '$addnew' => t('Add new page'), - '$pageName' => array('pageName', t('Page name')), - )); -} -function widget_wiki_page_history($arr) { - $pageUrlName = ((array_key_exists('pageUrlName', $arr)) ? $arr['pageUrlName'] : ''); - $resource_id = ((array_key_exists('resource_id', $arr)) ? $arr['resource_id'] : ''); - $pageHistory = Zotlabs\Lib\NativeWikiPage::page_history(array('channel_id' => App::$profile_uid, 'observer_hash' => get_observer_hash(), 'resource_id' => $resource_id, 'pageUrlName' => $pageUrlName)); - return replace_macros(get_markup_template('nwiki_page_history.tpl'), array( - '$pageHistory' => $pageHistory['history'], - '$permsWrite' => $arr['permsWrite'], - '$name_lbl' => t('Name'), - '$msg_label' => t('Message','wiki_history') - )); - -} function widget_bookmarkedchats($arr) { @@ -749,27 +625,6 @@ function widget_activity($arr) { -function widget_tasklist($arr) { - - if (! local_channel()) - return; - - require_once('include/event.php'); - $o .= ''; - $o .= ''; - - $o .= '
' . '

' . t('Tasks') . '

'; - $o .= '
'; - $o .= '
'; - return $o; - -} function widget_helpindex($arr) { @@ -814,68 +669,6 @@ function widget_helpindex($arr) { -function widget_admin($arr) { - - /* - * Side bar links - */ - - if(! is_site_admin()) { - return ''; - } - - $o = ''; - - // array( url, name, extra css classes ) - - $aside = array( - 'site' => array(z_root() . '/admin/site/', t('Site'), 'site'), - 'accounts' => array(z_root() . '/admin/accounts/', t('Accounts'), 'accounts', 'pending-update', t('Member registrations waiting for confirmation')), - 'channels' => array(z_root() . '/admin/channels/', t('Channels'), 'channels'), - 'security' => array(z_root() . '/admin/security/', t('Security'), 'security'), - 'features' => array(z_root() . '/admin/features/', t('Features'), 'features'), - 'plugins' => array(z_root() . '/admin/plugins/', t('Plugins'), 'plugins'), - 'themes' => array(z_root() . '/admin/themes/', t('Themes'), 'themes'), - 'queue' => array(z_root() . '/admin/queue', t('Inspect queue'), 'queue'), - 'profs' => array(z_root() . '/admin/profs', t('Profile Fields'), 'profs'), - 'dbsync' => array(z_root() . '/admin/dbsync/', t('DB updates'), 'dbsync') - - ); - - /* get plugins admin page */ - - $r = q("SELECT * FROM addon WHERE plugin_admin = 1"); - - $plugins = array(); - if($r) { - foreach ($r as $h){ - $plugin = $h['aname']; - $plugins[] = array(z_root() . '/admin/plugins/' . $plugin, $plugin, 'plugin'); - // temp plugins with admin - App::$plugins_admin[] = $plugin; - } - } - - $logs = array(z_root() . '/admin/logs/', t('Logs'), 'logs'); - - $arr = array('links' => $aside,'plugins' => $plugins,'logs' => $logs); - call_hooks('admin_aside',$arr); - - $o .= replace_macros(get_markup_template('admin_aside.tpl'), array( - '$admin' => $aside, - '$admtxt' => t('Admin'), - '$plugadmtxt' => t('Plugin Features'), - '$plugins' => $plugins, - '$logtxt' => t('Logs'), - '$logs' => $logs, - '$h_pending' => t('Member registrations waiting for confirmation'), - '$admurl'=> z_root() . '/admin/' - )); - - return $o; - -} - function widget_album($args) { -- cgit v1.2.3 From cd57483ed9069a26b52ae8d7d74fdc537da89946 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 29 Mar 2017 11:59:20 +0200 Subject: namespace error --- Zotlabs/Widget/Conversations.php | 4 ++-- view/css/bootstrap-red.css | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Zotlabs/Widget/Conversations.php b/Zotlabs/Widget/Conversations.php index fa59ce20c..31fcb6c58 100644 --- a/Zotlabs/Widget/Conversations.php +++ b/Zotlabs/Widget/Conversations.php @@ -33,7 +33,7 @@ class Conversations { require_once('include/message.php'); // private_messages_list() can do other more complicated stuff, for now keep it simple - $r = private_messages_list(local_channel(), $mailbox, App::$pager['start'], App::$pager['itemspage']); + $r = private_messages_list(local_channel(), $mailbox, \App::$pager['start'], App::$pager['itemspage']); if(! $r) { info( t('No messages.') . EOL); @@ -71,4 +71,4 @@ class Conversations { } return $o; } -} \ No newline at end of file +} diff --git a/view/css/bootstrap-red.css b/view/css/bootstrap-red.css index 69886b141..4c4de22f9 100644 --- a/view/css/bootstrap-red.css +++ b/view/css/bootstrap-red.css @@ -33,7 +33,6 @@ nav .badge { padding: 0.2rem 0; } - #navbar-collapse-1 i { font-size: 1rem; } -- cgit v1.2.3 From 0bad26e116499d9b656c28f64c81275df4bbecb6 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 16 Mar 2017 17:11:48 -0700 Subject: the rest of the standard widgets converted --- Zotlabs/Widget/Activity.php | 61 +++ Zotlabs/Widget/Album.php | 106 ++++ Zotlabs/Widget/Bookmarkedchats.php | 28 ++ Zotlabs/Widget/Categories.php | 1 + Zotlabs/Widget/Clock.php | 63 +++ Zotlabs/Widget/Cover_photo.php | 59 +++ Zotlabs/Widget/Dirsort.php | 11 + Zotlabs/Widget/Dirtags.php | 13 + Zotlabs/Widget/Filer.php | 1 + Zotlabs/Widget/Findpeople.php | 12 + Zotlabs/Widget/Forums.php | 97 ++++ Zotlabs/Widget/Helpindex.php | 45 ++ Zotlabs/Widget/Item.php | 54 ++ Zotlabs/Widget/Photo.php | 55 +++ Zotlabs/Widget/Photo_rand.php | 66 +++ Zotlabs/Widget/Pubsites.php | 16 + Zotlabs/Widget/Random_block.php | 46 ++ Zotlabs/Widget/Rating.php | 67 +++ Zotlabs/Widget/Suggestedchats.php | 37 ++ Zotlabs/Widget/Website_portation_tools.php | 22 + include/widgets.php | 763 +---------------------------- 21 files changed, 861 insertions(+), 762 deletions(-) create mode 100644 Zotlabs/Widget/Activity.php create mode 100644 Zotlabs/Widget/Album.php create mode 100644 Zotlabs/Widget/Bookmarkedchats.php create mode 100644 Zotlabs/Widget/Clock.php create mode 100644 Zotlabs/Widget/Cover_photo.php create mode 100644 Zotlabs/Widget/Dirsort.php create mode 100644 Zotlabs/Widget/Dirtags.php create mode 100644 Zotlabs/Widget/Findpeople.php create mode 100644 Zotlabs/Widget/Forums.php create mode 100644 Zotlabs/Widget/Helpindex.php create mode 100644 Zotlabs/Widget/Item.php create mode 100644 Zotlabs/Widget/Photo.php create mode 100644 Zotlabs/Widget/Photo_rand.php create mode 100644 Zotlabs/Widget/Pubsites.php create mode 100644 Zotlabs/Widget/Random_block.php create mode 100644 Zotlabs/Widget/Rating.php create mode 100644 Zotlabs/Widget/Suggestedchats.php create mode 100644 Zotlabs/Widget/Website_portation_tools.php diff --git a/Zotlabs/Widget/Activity.php b/Zotlabs/Widget/Activity.php new file mode 100644 index 000000000..72a27bdf1 --- /dev/null +++ b/Zotlabs/Widget/Activity.php @@ -0,0 +1,61 @@ + $v) { + $arr[] = [ 'author_xchan' => $k, 'total' => $v ]; + } + usort($arr,'total_sort'); + xchan_query($arr); + } + + $x = [ 'entries' => $arr ]; + call_hooks('activity_widget',$x); + $arr = $x['entries']; + + if($arr) { + $o .= '
'; + $o .= '

' . t('Activity','widget') . '

'; + } + return $o; + } + +} + diff --git a/Zotlabs/Widget/Album.php b/Zotlabs/Widget/Album.php new file mode 100644 index 000000000..f359e6d0f --- /dev/null +++ b/Zotlabs/Widget/Album.php @@ -0,0 +1,106 @@ + $rr['id'], + 'twist' => ' ' . $twist . rand(2,4), + 'link' => $imagelink, + 'title' => t('View Photo'), + 'src' => z_root() . '/photo/' . $rr['resource_id'] . '-' . $rr['imgscale'] . '.' .$ext, + 'alt' => $imgalt_e, + 'desc'=> $desc_e, + 'ext' => $ext, + 'hash'=> $rr['resource_id'], + 'unknown' => t('Unknown') + ); + } + } + + + $tpl = get_markup_template('photo_album.tpl'); + $o .= replace_macros($tpl, array( + '$photos' => $photos, + '$album' => (($title) ? $title : $album), + '$album_id' => rand(), + '$album_edit' => array(t('Edit Album'), $album_edit), + '$can_post' => false, + '$upload' => array(t('Upload'), z_root() . '/photos/' . \App::$profile['channel_address'] . '/upload/' . bin2hex($album)), + '$order' => false, + '$upload_form' => $upload_form, + '$usage' => $usage_message + )); + + return $o; + } +} + diff --git a/Zotlabs/Widget/Bookmarkedchats.php b/Zotlabs/Widget/Bookmarkedchats.php new file mode 100644 index 000000000..d64bbdb4b --- /dev/null +++ b/Zotlabs/Widget/Bookmarkedchats.php @@ -0,0 +1,28 @@ + t('Bookmarked Chatrooms'), + '$rooms' => $r + )); + } +} diff --git a/Zotlabs/Widget/Categories.php b/Zotlabs/Widget/Categories.php index 82fffccc8..d1dcfda93 100644 --- a/Zotlabs/Widget/Categories.php +++ b/Zotlabs/Widget/Categories.php @@ -2,6 +2,7 @@ namespace Zotlabs\Widget; +require_once('include/contact_widgets.php'); class Categories { diff --git a/Zotlabs/Widget/Clock.php b/Zotlabs/Widget/Clock.php new file mode 100644 index 000000000..b63b5f748 --- /dev/null +++ b/Zotlabs/Widget/Clock.php @@ -0,0 +1,63 @@ + +

+ + +EOT; + + return $o; + } +} + diff --git a/Zotlabs/Widget/Cover_photo.php b/Zotlabs/Widget/Cover_photo.php new file mode 100644 index 000000000..d2eb1be92 --- /dev/null +++ b/Zotlabs/Widget/Cover_photo.php @@ -0,0 +1,59 @@ +') !== false) + $style = ''; + + if(array_key_exists('title', $arr) && isset($arr['title'])) + $title = $arr['title']; + else + $title = $channel['channel_name']; + + if(array_key_exists('subtitle', $arr) && isset($arr['subtitle'])) + $subtitle = $arr['subtitle']; + else + $subtitle = str_replace('@','@',$channel['xchan_addr']); + + $c = get_cover_photo($channel_id,'html'); + + if($c) { + $photo_html = (($style) ? str_replace('alt=',' style="' . $style . '" alt=',$c) : $c); + + $o = replace_macros(get_markup_template('cover_photo_widget.tpl'),array( + '$photo_html' => $photo_html, + '$title' => $title, + '$subtitle' => $subtitle, + '$hovertitle' => t('Click to show more'), + )); + } + return $o; + } +} diff --git a/Zotlabs/Widget/Dirsort.php b/Zotlabs/Widget/Dirsort.php new file mode 100644 index 000000000..e75a00e50 --- /dev/null +++ b/Zotlabs/Widget/Dirsort.php @@ -0,0 +1,11 @@ +'; + $o .= '

' . t('Forums') . '

'; + } + return $o; + + } +} diff --git a/Zotlabs/Widget/Helpindex.php b/Zotlabs/Widget/Helpindex.php new file mode 100644 index 000000000..62cecce1f --- /dev/null +++ b/Zotlabs/Widget/Helpindex.php @@ -0,0 +1,45 @@ +'; + + $level_0 = get_help_content('sitetoc'); + if(! $level_0) + $level_0 = get_help_content('toc'); + + $level_0 = preg_replace('/\/','