]> git.mxchange.org Git - friendica.git/blobdiff - include/contact_widgets.php
provide theme_init() functions
[friendica.git] / include / contact_widgets.php
index 424f2997ef1610e4bd17ef46e8ec42f3ba05f73b..e0f37f078f7cf2241b3e4efc34fbe3b9bcecc3c8 100644 (file)
@@ -15,8 +15,6 @@ function findpeople_widget() {
 
        $a = get_app();
 
-       $inv = (($a->config['register_policy'] != REGISTER_CLOSED) ? t('Invite Friends') : '');
-
        if(get_config('system','invitation_only')) {
                $x = get_pconfig(local_user(),'system','invites_remaining');
                if($x || is_site_admin()) {
@@ -34,7 +32,7 @@ function findpeople_widget() {
                '$findthem' => t('Find'),
                '$suggest' => t('Friend Suggestions'),
                '$similar' => t('Similar Interests'),
-               '$inv' => $inv
+               '$inv' => t('Invite Friends')
        ));
 
 }
@@ -48,7 +46,7 @@ function networks_widget($baseurl,$selected = '') {
                return '';
 
        
-       $r = q("select distinct(network) from contact where uid = %d",
+       $r = q("select distinct(network) from contact where uid = %d and self = 0",
                intval(local_user())
        );
 
@@ -61,6 +59,9 @@ function networks_widget($baseurl,$selected = '') {
                }
        }
 
+       if(count($nets) < 2)
+               return '';
+
        return replace_macros(get_markup_template('nets.tpl'),array(
                '$title' => t('Networks'),
                '$desc' => '',
@@ -72,4 +73,61 @@ function networks_widget($baseurl,$selected = '') {
        ));
 }
 
+function fileas_widget($baseurl,$selected = '') {
+       $a = get_app();
+       if(! local_user())
+               return '';
+
+       $saved = get_pconfig(local_user(),'system','filetags');
+       if(! strlen($saved))
+               return;
+
+       $matches = false;
+       $terms = array();
+    $cnt = preg_match_all('/\[(.*?)\]/',$saved,$matches,PREG_SET_ORDER);
+    if($cnt) {
+               foreach($matches as $mtch) {
+                       $unescaped = xmlify(file_tag_decode($mtch[1]));
+                       $terms[] = array('name' => $unescaped,'selected' => (($selected == $unescaped) ? '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' => $baseurl,
+
+       ));
+}
+
+function categories_widget($baseurl,$selected = '') {
+       $a = get_app();
+
+       $saved = get_pconfig($a->profile['profile_uid'],'system','filetags');
+       if(! strlen($saved))
+               return;
+
+       $matches = false;
+       $terms = array();
+        $cnt = preg_match_all('/<(.*?)>/',$saved,$matches,PREG_SET_ORDER);
+        if($cnt) {
+                foreach($matches as $mtch) {
+                       $unescaped = xmlify(file_tag_decode($mtch[1]));
+                       $terms[] = array('name' => $unescaped,'selected' => (($selected == $unescaped) ? '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' => $baseurl,
+
+       ));
+}