]> git.mxchange.org Git - friendica.git/blobdiff - mod/contacts.php
add settings sections and add contacts; other tweaks and fixes
[friendica.git] / mod / contacts.php
index 769239fe0cd81c62c5fd41cb1841978044fa1fbe..8a36fa4cb6ced11b63946b00bd81a4f5e0193eaf 100644 (file)
@@ -28,21 +28,42 @@ function contacts_init(&$a) {
 
        if($contact_id) {
                        $a->data['contact'] = $r[0];
-                       $o .= '<div class="vcard">';
-                       $o .= '<div class="fn">' . $a->data['contact']['name'] . '</div>';
-                       $o .= '<div id="profile-photo-wrapper"><img class="photo" style="width: 175px; height: 175px;" src="' . $a->data['contact']['photo'] . '" alt="' . $a->data['contact']['name'] . '" /></div>';
-                       $o .= '</div>';
-                       $a->page['aside'] .= $o;
-
+                       $vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"),array(
+                               '$name' => $a->data['contact']['name'],
+                               '$photo' => $a->data['contact']['photo']
+                       ));
+                       $follow_widget = '';
        }       
-       else
-               $a->page['aside'] .= follow_widget();
+       else {
+               $vcard_widget = '';
+               $follow_widget = follow_widget();
+       }
 
-       $a->page['aside'] .= group_side('contacts','group',false,0,$contact_id);
+       $groups_widget .= group_side('contacts','group',false,0,$contact_id);
+       $findpeople_widget .= findpeople_widget();
+       $networks_widget .= networks_widget('contacts',$_GET['nets']);
+       $a->page['aside'] .= replace_macros(get_markup_template("contacts-widget-sidebar.tpl"),array(
+               '$vcard_widget' => $vcard_widget,
+               '$follow_widget' => $follow_widget,
+               '$groups_widget' => $groups_widget,
+               '$findpeople_widget' => $findpeople_widget,
+               '$networks_widget' => $networks_widget
+       ));
+
+       $base = $a->get_baseurl();
+       $tpl = get_markup_template("contacts-head.tpl");
+       $a->page['htmlhead'] .= replace_macros($tpl,array(
+               '$baseurl' => $a->get_baseurl(true),
+               '$base' => $base
+       ));
+
+       $tpl = get_markup_template("contacts-end.tpl");
+       $a->page['end'] .= replace_macros($tpl,array(
+               '$baseurl' => $a->get_baseurl(true),
+               '$base' => $base
+       ));
 
-       $a->page['aside'] .= findpeople_widget();
 
-       $a->page['aside'] .= networks_widget('contacts',$_GET['nets']);
 }
 
 function contacts_post(&$a) {
@@ -227,6 +248,10 @@ function contacts_content(&$a) {
                        '$baseurl' => $a->get_baseurl(true),
                        '$editselect' => $editselect,
                ));
+               $a->page['end'] .= replace_macros(get_markup_template('contact_end.tpl'), array(
+                       '$baseurl' => $a->get_baseurl(true),
+                       '$editselect' => $editselect,
+               ));
 
                require_once('include/contact_selectors.php');
 
@@ -315,6 +340,7 @@ function contacts_content(&$a) {
                $tab_tpl = get_markup_template('common_tabs.tpl');
                $tab_str = replace_macros($tab_tpl, array('$tabs' => $tabs));
 
+               $lost_contact = (($contact['archive'] && $contact['term-date'] != '0000-00-00 00:00:00' && $contact['term-date'] < datetime_convert('','','now')) ? t('Communications lost with this contact!') : '');
 
                $o .= replace_macros($tpl,array(
                        '$header' => t('Contact Editor'),
@@ -339,6 +365,7 @@ function contacts_content(&$a) {
                        '$poll_interval' => contact_poll_interval($contact['priority'],(! $poll_enabled)),
                        '$poll_enabled' => $poll_enabled,
                        '$lastupdtext' => t('Last update:'),
+                       '$lost_contact' => $lost_contact,
                        '$updpub' => t('Update public posts'),
                        '$last_update' => $last_update,
                        '$udnow' => t('Update now'),
@@ -457,12 +484,13 @@ function contacts_content(&$a) {
 
 
 
-
+       $searching = false;
        if($search) {
                $search_hdr = $search;
-               $search = dbesc($search.'*');
+               $search_txt = dbesc(protect_sprintf(preg_quote($search)));
+               $searching = true;
        }
-       $sql_extra .= ((strlen($search)) ? " AND MATCH `name` AGAINST ('$search' IN BOOLEAN MODE) " : "");
+       $sql_extra .= (($searching) ? " AND `name` REGEXP '$search_txt' " : "");
 
        if($nets)
                $sql_extra .= sprintf(" AND network = '%s' ", dbesc($nets));
@@ -479,7 +507,6 @@ function contacts_content(&$a) {
        }
 
 
-
        $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 ORDER BY `name` ASC LIMIT %d , %d ",
                intval($_SESSION['uid']),
                intval($a->pager['start']),
@@ -546,7 +573,7 @@ function contacts_content(&$a) {
                '$total' => $total,
                '$search' => $search_hdr,
                '$desc' => t('Search your contacts'),
-               '$finding' => (strlen($search) ? t('Finding: ') . "'" . $search . "'" : ""),
+               '$finding' => (($searching) ? t('Finding: ') . "'" . $search . "'" : ""),
                '$submit' => t('Find'),
                '$cmd' => $a->cmd,
                '$contacts' => $contacts,