]> git.mxchange.org Git - friendica.git/commitdiff
message: remove tabs, move new message link to aside, all message with gmail-style
authorFabio Comuni <fabrix.xm@gmail.com>
Wed, 28 Mar 2012 13:31:58 +0000 (15:31 +0200)
committerFabio Comuni <fabrix.xm@gmail.com>
Wed, 28 Mar 2012 13:31:58 +0000 (15:31 +0200)
mod/message.php
view/mail_conv.tpl
view/mail_display.tpl [new file with mode: 0644]
view/message_side.tpl [new file with mode: 0644]

index 8991f643d44618ef26d0525ea5de29f58a6e9bbe..949e5616cab554a4bb70427c1cc59891364cc0e5 100755 (executable)
@@ -3,6 +3,35 @@
 require_once('include/acl_selectors.php');
 require_once('include/message.php');
 
+function message_init(&$a) {
+       $tabs = array(
+       /*
+               array(
+                       'label' => t('All'),
+                       'url'=> $a->get_baseurl(true) . '/message',
+                       'sel'=> ($a->argc == 1),
+               ),
+               array(
+                       'label' => t('Sent'),
+                       'url' => $a->get_baseurl(true) . '/message/sent',
+                       'sel'=> ($a->argv[1] == 'sent'),
+               ),
+       */
+       );
+       $new = array(
+               'label' => t('New Message'),
+               'url' => $a->get_baseurl(true) . '/message/new',
+               'sel'=> ($a->argv[1] == 'new'),
+       );
+       
+       $tpl = get_markup_template('message_side.tpl');
+       $a->page['aside'] = replace_macros($tpl, array(
+               '$tabs'=>$tabs,
+               '$new'=>$new,
+       ));
+       
+}
+
 function message_post(&$a) {
 
        if(! local_user()) {
@@ -66,25 +95,7 @@ function message_content(&$a) {
        $myprofile = $a->get_baseurl(true) . '/profile/' . $a->user['nickname'];
 
 
-       $tabs = array(
-               array(
-                       'label' => t('Inbox'),
-                       'url'=> $a->get_baseurl(true) . '/message',
-                       'sel'=> (($a->argc == 1) ? 'active' : ''),
-               ),
-               array(
-                       'label' => t('Outbox'),
-                       'url' => $a->get_baseurl(true) . '/message/sent',
-                       'sel'=> (($a->argv[1] == 'sent') ? 'active' : ''),
-               ),
-               array(
-                       'label' => t('New Message'),
-                       'url' => $a->get_baseurl(true) . '/message/new',
-                       'sel'=> (($a->argv[1] == 'new') ? 'active' : ''),
-               ),
-       );
-       $tpl = get_markup_template('common_tabs.tpl');
-       $tab_content = replace_macros($tpl, array('$tabs'=>$tabs));
+
 
 
        $tpl = get_markup_template('mail_head.tpl');
@@ -186,9 +197,9 @@ function message_content(&$a) {
                $o .= $header;
                
                if($a->argc == 2)
-                       $eq = '='; // I'm not going to bother escaping this.
+                       $eq = sprintf( "AND `from-url` = '%s'", dbesc($myprofile)); 
                else
-                       $eq = '!='; // or this.
+                       $eq = '';
 
                $r = q("SELECT count(*) AS `total` FROM `mail` 
                        WHERE `mail`.`uid` = %d AND `from-url` $eq '%s' GROUP BY `parent-uri` ORDER BY `created` DESC",
@@ -199,11 +210,12 @@ function message_content(&$a) {
                        $a->set_pager_total($r[0]['total']);
        
                $r = q("SELECT max(`mail`.`created`) AS `mailcreated`, min(`mail`.`seen`) AS `mailseen`, 
-                       `mail`.* , `contact`.`name`, `contact`.`url`, `contact`.`thumb` , `contact`.`network`  
+                       `mail`.* , `contact`.`name`, `contact`.`url`, `contact`.`thumb` , `contact`.`network`,
+                       count( * ) as count
                        FROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id` 
-                       WHERE `mail`.`uid` = %d AND `from-url` $eq '%s' GROUP BY `parent-uri` ORDER BY `mailcreated` DESC  LIMIT %d , %d ",
+                       WHERE `mail`.`uid` = %d  $eq GROUP BY `parent-uri` ORDER BY `mailcreated` DESC  LIMIT %d , %d ",
                        intval(local_user()),
-                       dbesc($myprofile),
+                       //
                        intval($a->pager['start']),
                        intval($a->pager['itemspage'])
                );
@@ -214,9 +226,15 @@ function message_content(&$a) {
 
                $tpl = get_markup_template('mail_list.tpl');
                foreach($r as $rr) {
+                       if ($rr['from-url'] == $myprofile){
+                               $partecipants = sprintf( t("You and %s"), $rr['name']);
+                       } else {
+                               $partecipants = sprintf( t("%s and You"), $rr['from-name']);
+                       }
+                       
                        $o .= replace_macros($tpl, array(
                                '$id' => $rr['id'],
-                               '$from_name' =>$rr['from-name'],
+                               '$from_name' => $partecipants,
                                '$from_url' => (($rr['network'] === NETWORK_DFRN) ? $a->get_baseurl(true) . '/redir/' . $rr['contact-id'] : $rr['url']),
                                '$sparkle' => ' sparkle',
                                '$from_photo' => $rr['thumb'],
@@ -224,7 +242,9 @@ function message_content(&$a) {
                                '$delete' => t('Delete conversation'),
                                '$body' => template_escape($rr['body']),
                                '$to_name' => template_escape($rr['name']),
-                               '$date' => datetime_convert('UTC',date_default_timezone_get(),$rr['mailcreated'], t('D, d M Y - g:i A'))
+                               '$date' => datetime_convert('UTC',date_default_timezone_get(),$rr['mailcreated'], t('D, d M Y - g:i A')),
+                               '$seen' => $rr['mailseen'],
+                               '$count' => sprintf( tt('%d message', '%d messages', $rr['count']), $rr['count']),
                        ));
                }
                $o .= paginate($a);     
@@ -278,7 +298,8 @@ function message_content(&$a) {
                ));
 
 
-               $tpl = get_markup_template('mail_conv.tpl');
+               $mails = array();
+               $seen = 0;
                foreach($messages as $message) {
                        if($message['from-url'] == $myprofile) {
                                $from_url = $myprofile;
@@ -288,24 +309,35 @@ function message_content(&$a) {
                                $from_url = $a->get_baseurl(true) . '/redir/' . $message['contact-id'];
                                $sparkle = ' sparkle';
                        }
-                       $o .= replace_macros($tpl, array(
-                               '$id' => $message['id'],
-                               '$from_name' => template_escape($message['from-name']),
-                               '$from_url' => $from_url,
-                               '$sparkle' => $sparkle,
-                               '$from_photo' => $message['from-photo'],
-                               '$subject' => template_escape($message['title']),
-                               '$body' => template_escape(smilies(bbcode($message['body']))),
-                               '$delete' => t('Delete message'),
-                               '$to_name' => template_escape($message['name']),
-                               '$date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'],'D, d M Y - g:i A')
-                       ));
+                       $mails[] = array(
+                               'id' => $message['id'],
+                               'from_name' => template_escape($message['from-name']),
+                               'from_url' => $from_url,
+                               'sparkle' => $sparkle,
+                               'from_photo' => $message['from-photo'],
+                               'subject' => template_escape($message['title']),
+                               'body' => template_escape(smilies(bbcode($message['body']))),
+                               'delete' => t('Delete message'),
+                               'to_name' => template_escape($message['name']),
+                               'date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'],'D, d M Y - g:i A'),
+                       );
                                
+                       $seen = $message['seen'];
                }
                $select = $message['name'] . '<input type="hidden" name="messageto" value="' . $contact_id . '" />';
                $parent = '<input type="hidden" name="replyto" value="' . $message['parent-uri'] . '" />';
-               $tpl = get_markup_template('prv_message.tpl');
-               $o .= replace_macros($tpl,array(
+               
+
+               $tpl = get_markup_template('mail_display.tpl');
+               $o = replace_macros($tpl, array(
+                       '$thread_id' => $a->argv[1],
+                       '$thread_subject' => $message['title'],
+                       '$thread_seen' => $seen,
+                       '$delete' =>  t('Delete conversation'),
+                       
+                       '$mails' => $mails,
+                       
+                       // reply
                        '$header' => t('Send Reply'),
                        '$to' => t('To:'),
                        '$subject' => t('Subject:'),
@@ -318,6 +350,7 @@ function message_content(&$a) {
                        '$upload' => t('Upload photo'),
                        '$insert' => t('Insert web link'),
                        '$wait' => t('Please wait')
+
                ));
 
                return $o;
index ed36a7bb20667b47e5d0b2a3ae07836ce096c55c..75a4506f6a36119950c9b7800c7184592317b4c1 100755 (executable)
@@ -1,13 +1,13 @@
 <div class="mail-conv-outside-wrapper">
        <div class="mail-conv-sender" >
-               <a href="$from_url" class="mail-conv-sender-url" ><img class="mframe mail-conv-sender-photo$sparkle" src="$from_photo" heigth="80" width="80" alt="$from_name" /></a>
+               <a href="$mail.from_url" class="mail-conv-sender-url" ><img class="mframe mail-conv-sender-photo$mail.sparkle" src="$mail.from_photo" heigth="80" width="80" alt="$mail.from_name" /></a>
        </div>
        <div class="mail-conv-detail" >
-               <div class="mail-conv-sender-name" >$from_name</div>
-               <div class="mail-conv-date">$date</div>
-               <div class="mail-conv-subject">$subject</div>
-               <div class="mail-conv-body">$body</div>
-       <div class="mail-conv-delete-wrapper" id="mail-conv-delete-wrapper-$id" ><a href="message/drop/$id" class="icon drophide delete-icon mail-list-delete-icon" onclick="return confirmDelete();" title="$delete" id="mail-conv-delete-icon-$id" class="mail-conv-delete-icon" onmouseover="imgbright(this);" onmouseout="imgdull(this);" ></a></div><div class="mail-conv-delete-end"></div>
+               <div class="mail-conv-sender-name" >$mail.from_name</div>
+               <div class="mail-conv-date">$mail.date</div>
+               <div class="mail-conv-subject">$mail.subject</div>
+               <div class="mail-conv-body">$mail.body</div>
+       <div class="mail-conv-delete-wrapper" id="mail-conv-delete-wrapper-$mail.id" ><a href="message/drop/$mail.id" class="icon drophide delete-icon mail-list-delete-icon" onclick="return confirmDelete();" title="$mail.delete" id="mail-conv-delete-icon-$mail.id" class="mail-conv-delete-icon" onmouseover="imgbright(this);" onmouseout="imgdull(this);" ></a></div><div class="mail-conv-delete-end"></div>
        <div class="mail-conv-outside-wrapper-end"></div>
 </div>
 </div>
diff --git a/view/mail_display.tpl b/view/mail_display.tpl
new file mode 100644 (file)
index 0000000..69c7e07
--- /dev/null
@@ -0,0 +1,6 @@
+
+{{ for $mails as $mail }}
+       {{ inc mail_conv.tpl }}{{endinc}}
+{{ endfor }}
+
+{{ inc prv_message.tpl }}{{ endinc }}
diff --git a/view/message_side.tpl b/view/message_side.tpl
new file mode 100644 (file)
index 0000000..fce771b
--- /dev/null
@@ -0,0 +1,10 @@
+<div id="message-sidebar" class="widget">
+       <div id="message-new"><a href="$new.url" class="{{ if $new.sel }}newmessage-selected{{ endif }}">$new.label</a> </div>
+       
+       <ul class="message-ul">
+               {{ for $tabs as $t }}
+                       <li class="tool"><a href="$t.url" class="message-link{{ if $t.sel }}message-selected{{ endif }}">$t.label</a></li>
+               {{ endfor }}
+       </ul>
+       
+</div>