[Svn] r2278 - in branches/devel-api: plugins plugins/userinfo program/include program/js skins/default skins/default/includes skins/default/templates

trac at roundcube.net trac at roundcube.net
Fri Feb 6 16:22:54 CET 2009


Author: thomasb
Date: 2009-02-06 09:22:54 -0600 (Fri, 06 Feb 2009)
New Revision: 2278

Added:
   branches/devel-api/plugins/userinfo/
   branches/devel-api/plugins/userinfo/userinfo.js
   branches/devel-api/plugins/userinfo/userinfo.php
   branches/devel-api/skins/default/templates/plugin.html
Modified:
   branches/devel-api/program/include/rcube_plugin_api.php
   branches/devel-api/program/include/rcube_template.php
   branches/devel-api/program/js/list.js
   branches/devel-api/skins/default/common.css
   branches/devel-api/skins/default/functions.js
   branches/devel-api/skins/default/includes/settingstabs.html
   branches/devel-api/skins/default/templates/identities.html
   branches/devel-api/skins/default/templates/managefolders.html
   branches/devel-api/skins/default/templates/settings.html
Log:
Added blank skin template for plugins + sample plugin adding a new tab to settings task

Added: branches/devel-api/plugins/userinfo/userinfo.js
===================================================================
--- branches/devel-api/plugins/userinfo/userinfo.js	                        (rev 0)
+++ branches/devel-api/plugins/userinfo/userinfo.js	2009-02-06 15:22:54 UTC (rev 2278)
@@ -0,0 +1,16 @@
+/* Show user-info plugin script */
+
+if (window.rcmail) {
+  rcmail.add_onload(function(){
+    // <span id="settingstabdefault" class="tablink"><roundcube:button command="preferences" type="link" label="preferences" title="editpreferences" /></span>
+    var tab = $('<span>').attr('id', 'settingstabpluginuserinfo').addClass('tablink');
+    
+    var button = $('<a>').attr('href', rcmail.env.comm_path+'&_action=plugin.userinfo').html('Userinfo').appendTo(tab);
+    button.bind('click', function(e){ return rcmail.command('plugin.userinfo', this) });
+    
+    // add button and register command
+    rcmail.add_element(tab, 'tabs');
+    rcmail.register_command('plugin.userinfo', function(){ rcmail.goto_url('plugin.userinfo') }, true);
+  })
+}
+

Added: branches/devel-api/plugins/userinfo/userinfo.php
===================================================================
--- branches/devel-api/plugins/userinfo/userinfo.php	                        (rev 0)
+++ branches/devel-api/plugins/userinfo/userinfo.php	2009-02-06 15:22:54 UTC (rev 2278)
@@ -0,0 +1,53 @@
+<?php
+
+/**
+ * Sample plugin that adds a new tab to the settings section
+ * to display some information about the current user
+ */
+class userinfo extends rcube_plugin
+{
+
+  function init()
+  {
+    $this->task = 'settings';
+    
+    $this->register_action('plugin.userinfo', array($this, 'infostep'));
+    $this->include_script('userinfo.js');
+  }
+
+  function infostep()
+  {
+    $this->register_handler('plugin.body', array($this, 'infohtml'));
+    rcmail::get_instance()->output->send('plugin');
+  }
+  
+  function infohtml()
+  {
+    $rcmail = rcmail::get_instance();
+    $user = $rcmail->user;
+    
+    $table = new html_table(array('cols' => 2, 'cellpadding' => 3));
+
+    $table->add('title', 'ID');
+    $table->add('', Q($user->ID));
+    
+    $table->add('title', 'Username');
+    $table->add('', Q($user->data['username']));
+    
+    $table->add('title', 'Server');
+    $table->add('', Q($user->data['mail_host']));
+
+    $table->add('title', 'Created');
+    $table->add('', Q($user->data['created']));
+
+    $table->add('title', 'Last Login');
+    $table->add('', Q($user->data['last_login']));
+    
+    $identity = $user->get_identity();
+    $table->add('title', 'Default Identity');
+    $table->add('', Q($identity['name'] . ' <' . $identity['email'] . '>'));
+    
+    return html::tag('h4', null, Q('Infos for ' . $user->get_username())) . $table->show();
+  }
+
+}
\ No newline at end of file

Modified: branches/devel-api/program/include/rcube_plugin_api.php
===================================================================
--- branches/devel-api/program/include/rcube_plugin_api.php	2009-02-06 14:42:39 UTC (rev 2277)
+++ branches/devel-api/program/include/rcube_plugin_api.php	2009-02-06 15:22:54 UTC (rev 2278)
@@ -38,6 +38,7 @@
   private $templobjects = array();
   private $objectsmap = array();
   private $scripts = array();
+  private $output;
   
 
   /**
@@ -111,6 +112,8 @@
       foreach ($this->scripts as $script)
         $output->add_header(html::tag('script', array('type' => "text/javascript", 'src' => $script)));
     }
+    
+    $this->output = $output;
   }
   
   
@@ -210,8 +213,14 @@
     
     // can register handler only if it's not taken or registered by myself
     if (!isset($this->objectsmap[$name]) || $this->objectsmap[$name] == $owner) {
-      $this->templobjects[$name] = $callback;
-      $this->objectsmap[$name] = $owner;
+      // output is ready
+      if ($this->output) {
+        $this->output->add_handler($name, $callback);
+      }
+      else {
+        $this->templobjects[$name] = $callback;
+        $this->objectsmap[$name] = $owner;
+      }
     }
     else {
       raise_error(array('code' => 525, 'type' => 'php', 'message' => "Cannot register template handler $name; already taken by another plugin"), true, false);

Modified: branches/devel-api/program/include/rcube_template.php
===================================================================
--- branches/devel-api/program/include/rcube_template.php	2009-02-06 14:42:39 UTC (rev 2277)
+++ branches/devel-api/program/include/rcube_template.php	2009-02-06 15:22:54 UTC (rev 2278)
@@ -71,7 +71,7 @@
         $this->add_script($javascript, 'head_top');
         $this->add_script($javascript_foot, 'foot');
         $this->scripts_path = 'program/js/';
-        $this->include_script('http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js');
+        $this->include_script('http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js');
         $this->include_script('common.js');
         $this->include_script('app.js');
 
@@ -695,7 +695,7 @@
         static $s_button_count = 100;
 
         // these commands can be called directly via url
-        $a_static_commands = array('compose', 'list');
+        $a_static_commands = array('compose', 'list', 'preferences', 'folders', 'identities');
 
         if (!($attrib['command'] || $attrib['name'])) {
             return '';

Modified: branches/devel-api/program/js/list.js
===================================================================
--- branches/devel-api/program/js/list.js	2009-02-06 14:42:39 UTC (rev 2277)
+++ branches/devel-api/program/js/list.js	2009-02-06 15:22:54 UTC (rev 2278)
@@ -732,9 +732,6 @@
 
       if (this.rows[this.selection[n]].obj)
       {
-        if (n == 0)
-          this.drag_start_pos = $(this.rows[this.selection[n]].obj).offset();
-        
         obj = this.rows[this.selection[n]].obj;
         subject = '';
 
@@ -745,6 +742,9 @@
             if (((node = obj.childNodes[i].firstChild) && (node.nodeType==3 || node.nodeName=='A')) &&
               (this.subject_col < 0 || (this.subject_col >= 0 && this.subject_col == c)))
             {
+              if (n == 0)
+                this.drag_start_pos = $(node).offset();
+              
               subject = node.nodeType==3 ? node.data : node.innerHTML;
               names += (subject.length > 50 ? subject.substring(0, 50)+'...' : subject) + '<br />';
               break;

Modified: branches/devel-api/skins/default/common.css
===================================================================
--- branches/devel-api/skins/default/common.css	2009-02-06 14:42:39 UTC (rev 2277)
+++ branches/devel-api/skins/default/common.css	2009-02-06 15:22:54 UTC (rev 2278)
@@ -246,6 +246,13 @@
   border: 1px solid #CCCCCC;
 }
 
+#pagecontent
+{
+  position: absolute;
+  top: 95px;
+  left: 20px;
+}
+
 .splitter
 {
   user-select: none;

Modified: branches/devel-api/skins/default/functions.js
===================================================================
--- branches/devel-api/skins/default/functions.js	2009-02-06 14:42:39 UTC (rev 2277)
+++ branches/devel-api/skins/default/functions.js	2009-02-06 15:22:54 UTC (rev 2278)
@@ -8,24 +8,16 @@
 
 function rcube_init_settings_tabs()
 {
+  var tab = '#settingstabdefault';
   if (window.rcmail && rcmail.env.action)
-    {
-    var action = rcmail.env.action=='preferences' ? 'default' : (rcmail.env.action.indexOf('identity')>0 ? 'identities' : rcmail.env.action);
-    var tab = document.getElementById('settingstab'+action);
-    }
-  else 
-    var tab = document.getElementById('settingstabdefault');
-  
-  if (tab)
-    tab.className = 'tablink-selected';
+    tab = '#settingstab' + (rcmail.env.action=='preferences' ? 'default' : (rcmail.env.action.indexOf('identity')>0 ? 'identities' : rcmail.env.action.replace(/\./g, '')));
+
+  $(tab).addClass('tablink-selected');
 }
 
 function rcube_show_advanced(visible)
 {
-  var rows = document.getElementsByTagName('TR');
-  for(var i=0; i<rows.length; i++)
-    if(rows[i].className && rows[i].className.match(/advanced/))
-      rows[i].style.display = visible ? (bw.ie ? 'block' : 'table-row') : 'none';
+  $('tr.advanced').css('display', (visible ? (bw.ie ? 'block' : 'table-row') : 'none'));
 }
 
 /**

Modified: branches/devel-api/skins/default/includes/settingstabs.html
===================================================================
--- branches/devel-api/skins/default/includes/settingstabs.html	2009-02-06 14:42:39 UTC (rev 2277)
+++ branches/devel-api/skins/default/includes/settingstabs.html	2009-02-06 15:22:54 UTC (rev 2278)
@@ -1,5 +1,7 @@
 <div id="tabsbar">
+<roundcube:container name="tabs" id="tabsbar" />
 <span id="settingstabdefault" class="tablink"><roundcube:button command="preferences" type="link" label="preferences" title="editpreferences" /></span>
 <span id="settingstabfolders" class="tablink"><roundcube:button command="folders" type="link" label="folders" title="managefolders" class="tablink" /></span>
 <span id="settingstabidentities" class="tablink"><roundcube:button command="identities" type="link" label="identities" title="manageidentities" class="tablink" /></span>
+<script type="text/javascript"> if (window.rcmail) rcmail.add_onload(rcube_init_settings_tabs); </script>
 </div>

Modified: branches/devel-api/skins/default/templates/identities.html
===================================================================
--- branches/devel-api/skins/default/templates/identities.html	2009-02-06 14:42:39 UTC (rev 2277)
+++ branches/devel-api/skins/default/templates/identities.html	2009-02-06 15:22:54 UTC (rev 2278)
@@ -6,7 +6,7 @@
 <link rel="stylesheet" type="text/css" href="/settings.css" />
 <script type="text/javascript" src="/functions.js"></script>
 </head>
-<body onload="rcube_init_settings_tabs()">
+<body>
 
 <roundcube:include file="/includes/taskbar.html" />
 <roundcube:include file="/includes/header.html" />

Modified: branches/devel-api/skins/default/templates/managefolders.html
===================================================================
--- branches/devel-api/skins/default/templates/managefolders.html	2009-02-06 14:42:39 UTC (rev 2277)
+++ branches/devel-api/skins/default/templates/managefolders.html	2009-02-06 15:22:54 UTC (rev 2278)
@@ -6,7 +6,7 @@
 <link rel="stylesheet" type="text/css" href="/settings.css" />
 <script type="text/javascript" src="/functions.js"></script>
 </head>
-<body onload="rcube_init_settings_tabs()">
+<body>
 
 <roundcube:include file="/includes/taskbar.html" />
 <roundcube:include file="/includes/header.html" />

Added: branches/devel-api/skins/default/templates/plugin.html
===================================================================
--- branches/devel-api/skins/default/templates/plugin.html	                        (rev 0)
+++ branches/devel-api/skins/default/templates/plugin.html	2009-02-06 15:22:54 UTC (rev 2278)
@@ -0,0 +1,24 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title><roundcube:object name="pagetitle" /></title>
+<roundcube:include file="/includes/links.html" />
+<link rel="stylesheet" type="text/css" href="/<roundcube:var name='env:task'/>.css" />
+<script type="text/javascript" src="/functions.js"></script>
+</head>
+<body>
+
+<roundcube:include file="/includes/taskbar.html" />
+<roundcube:include file="/includes/header.html" />
+<roundcube:if condition="env:task == 'settings'" />
+  <roundcube:include file="/includes/settingstabs.html" />
+<roundcube:endif />
+
+<div id="pagecontent">
+<roundcube:object name="plugin.body" />
+</div>
+  
+<roundcube:object name="plugin.footer" />
+
+</body>
+</html>

Modified: branches/devel-api/skins/default/templates/settings.html
===================================================================
--- branches/devel-api/skins/default/templates/settings.html	2009-02-06 14:42:39 UTC (rev 2277)
+++ branches/devel-api/skins/default/templates/settings.html	2009-02-06 15:22:54 UTC (rev 2278)
@@ -6,7 +6,7 @@
 <link rel="stylesheet" type="text/css" href="/settings.css" />
 <script type="text/javascript" src="/functions.js&quo