aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-03-15 18:48:27 -0700
committerMario Vavti <mario@mariovavti.com>2017-03-29 11:48:35 +0200
commit17977effe775ef05a48a84da40da4b1f049b00d9 (patch)
tree383ce66a9993826a9fe98e9ae00c3ab4537cb728
parent477ed97c2fbfff903f9ebf0ffa7fba078eeac10f (diff)
downloadvolse-hubzilla-17977effe775ef05a48a84da40da4b1f049b00d9.tar.gz
volse-hubzilla-17977effe775ef05a48a84da40da4b1f049b00d9.tar.bz2
volse-hubzilla-17977effe775ef05a48a84da40da4b1f049b00d9.zip
more widgets
-rw-r--r--Zotlabs/Widget/Follow.php37
-rw-r--r--Zotlabs/Widget/Savedsearch.php91
-rw-r--r--Zotlabs/Widget/Sitesearch.php38
-rw-r--r--include/widgets.php154
-rw-r--r--util/typo.php25
5 files changed, 172 insertions, 173 deletions
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 @@
+<?php
+
+namespace Zotlabs\Widget;
+
+
+class Follow {
+
+ function widget($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
+ ));
+ }
+}
+
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 @@
+<?php
+
+namespace Zotlabs\Widget;
+
+class Savedsearch {
+
+ function widget($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=') . '&amp;searchremove=1&amp;search=' . urlencode($rr['term']),
+ 'srchlink' => z_root() . '/' . $srchurl . (($hasq || $hasamp) ? '' : '?f=') . '&amp;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 @@
+<?php
+
+namespace Zotlabs\Widget;
+
+
+class Sitesearch {
+
+ function widget($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;
+ }
+}
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=') . '&amp;searchremove=1&amp;search=' . urlencode($rr['term']),
- 'srchlink' => z_root() . '/' . $srchurl . (($hasq || $hasamp) ? '' : '?f=') . '&amp;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);
}