fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [7605] controller: XSLT alternative


From: Sigurd Nes
Subject: [Fmsystem-commits] [7605] controller: XSLT alternative
Date: Thu, 15 Sep 2011 11:46:14 +0000

Revision: 7605
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7605
Author:   sigurdne
Date:     2011-09-15 11:46:14 +0000 (Thu, 15 Sep 2011)
Log Message:
-----------
controller: XSLT alternative

Modified Paths:
--------------
    trunk/controller/inc/class.uicommon.inc.php
    trunk/controller/inc/class.uicontrol_item2.inc.php
    trunk/controller/js/yahoo/common.js
    trunk/controller/js/yahoo/controller.item.js
    trunk/controller/templates/base/control_item.xsl

Modified: trunk/controller/inc/class.uicommon.inc.php
===================================================================
--- trunk/controller/inc/class.uicommon.inc.php 2011-09-15 10:11:37 UTC (rev 
7604)
+++ trunk/controller/inc/class.uicommon.inc.php 2011-09-15 11:46:14 UTC (rev 
7605)
@@ -9,16 +9,23 @@
         *
         * @return array containg values from $array for the keys in $keys.
         */
-       
-
-       function extract_values($array, $keys)
+       function extract_values($array, $keys, $options = array())
        {
+               static $default_options = array(
+                       'prefix' => '',
+                       'suffix' => '', 
+                       'preserve_prefix' => false,
+                       'preserve_suffix' => false
+               );
+               
+               $options = array_merge($default_options, $options);
+               
                $result = array();
-               foreach($keys as $key)
+               foreach($keys as $write_key)
                {
-                       if(in_array($key, array_keys($array)))
-                       {
-                               $result[$key] = $array[$key];
+                       $array_key = 
$options['prefix'].$write_key.$options['suffix'];
+                       if(isset($array[$array_key])) {
+                               $result[($options['preserve_prefix'] ? 
$options['prefix'] : '').$write_key.($options['preserve_suffix'] ? 
$options['suffix'] : '')] = $array[$array_key];
                        }
                }
                return $result;
@@ -28,14 +35,74 @@
        {
                if(!isset($array[$key])) $array[$key] = $value;
        }
-       
-       define('MANAGER','MANAGER');
-       define('EXECUTIVE_OFFICER','EXECUTIVE_OFFICER');
-       define('ADMINISTRATOR','ADMINISTRATOR');
-       
+
+       /**
+        * Reformat an ISO timestamp into norwegian format
+        * 
+        * @param string $date    date
+        *
+        * @return string containg timestamp in norwegian format
+        */
+       function pretty_timestamp($date)
+       {
+               if (empty($date)) return "";
+               
+               if(is_array($date) && is_object($date[0]) && $date[0] 
instanceof DOMNode)
+               {
+                       $date = $date[0]->nodeValue;
+               }
+               preg_match('/([0-9]{4})-([0-9]{2})-([0-9]{2})( 
([0-9]{2}):([0-9]{2}))?/', $date, $match);
+
+               $dateformat = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+               if($match[4]) 
+               {
+                       $dateformat .= ' H:i';
+                       $timestamp = mktime($match[5], $match[6], 0, $match[2], 
$match[3], $match[1]);
+               }
+               else
+               {
+                       $timestamp = mktime(0, 0, 0, $match[2], $match[3], 
$match[1]);
+               }
+               $text = date($dateformat,$timestamp);
+                       
+               return $text;
+       }
+
+       /**
+        * Generates a javascript translator object/hash for the specified 
fields.
+        */
+       function js_lang()
+       {
+               $keys = func_get_args();
+               $strings = array();
+               foreach($keys as $key) { $strings[$key] = is_string($key) ? 
lang($key) : call_user_func_array('lang', $key); }
+               return json_encode($strings);
+       }
+
+       /**
+        * Creates an array of translated strings.
+        */
+       function lang_array()
+       {
+               $keys = func_get_args();
+               foreach($keys as &$key) $key = lang($key);
+               return $keys;
+       }
+
        abstract class controller_uicommon
        {
-               protected static $old_exception_handler;
+               const UI_SESSION_FLASH = 'flash_msgs';
+
+               protected       
+                       $filesArray;
+
+               protected static 
+                       $old_exception_handler;
+                       
+               private 
+                       $ui_session_key,
+                       $flash_msgs;
+
                
                const LOCATION_ROOT = '.';
                const LOCATION_IN = '.RESPONSIBILITY.INTO';
@@ -46,11 +113,11 @@
                
                public $type_of_user;
                
-               public $flash_msgs;
+       //      public $flash_msgs;
                
                public function __construct()
                {
-                       self::set_active_menu('activitycalendar');
+                       self::set_active_menu('controller');
                        
self::add_stylesheet('phpgwapi/js/yahoo/calendar/assets/skins/sam/calendar.css');
                        
self::add_stylesheet('phpgwapi/js/yahoo/autocomplete/assets/skins/sam/autocomplete.css');
                        
self::add_stylesheet('phpgwapi/js/yahoo/datatable/assets/skins/sam/datatable.css');
@@ -58,7 +125,7 @@
                        
self::add_stylesheet('phpgwapi/js/yahoo/paginator/assets/skins/sam/paginator.css');
                        
self::add_stylesheet('phpgwapi/js/yahoo/treeview/assets/skins/sam/treeview.css');
                        
//self::add_stylesheet('controller/templates/base/css/base.css');
-                       self::add_javascript('controller', 'controller', 
'common.js');
+                       self::add_javascript('controller', 'yahoo', 
'common.js');
                        $this->tmpl_search_path = array();
                        array_push($this->tmpl_search_path, PHPGW_SERVER_ROOT . 
'/phpgwapi/templates/base');
                        array_push($this->tmpl_search_path, PHPGW_SERVER_ROOT . 
'/phpgwapi/templates/' . $GLOBALS['phpgw_info']['server']['template_set']);
@@ -82,8 +149,69 @@
                        );*/
                        $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($GLOBALS['phpgw_info']['flags']['currentapp']);
                }
+
+               private function get_ui_session_key() {
+                       return $this->ui_session_key;
+               }
                
+               private function restore_flash_msgs() {
+                       if (($flash_msgs = 
$this->session_get(self::UI_SESSION_FLASH))) {
+                               if (is_array($flash_msgs)) {
+                                       $this->flash_msgs = $flash_msgs;
+                                       
$this->session_set(self::UI_SESSION_FLASH, array());
+                                       return true;
+                               }
+                       }
+                       
+                       $this->flash_msgs = array();
+                       return false;
+               }
+               
+               private function store_flash_msgs() {
+                       return $this->session_set(self::UI_SESSION_FLASH, 
$this->flash_msgs);
+               }
+               
+               private function reset_flash_msgs() {
+                       $this->flash_msgs = array();
+                       $this->store_flash_msgs();
+               }
+               
+               private function session_set($key, $data) {
+                       return 
phpgwapi_cache::session_set($this->get_ui_session_key(), $key, $data);
+               }
+               
+               private function session_get($key) {
+                       return 
phpgwapi_cache::session_get($this->get_ui_session_key(), $key);
+               }
+               
                /**
+                * Provides a private session cache setter per ui class.
+                */
+               protected function ui_session_set($key, $data) {
+                       return $this->session_set(get_class($this).'_'.$key, 
$data);
+               }
+               
+               /**
+                * Provides a private session cache getter per ui class .
+                */
+               protected function ui_session_get($key) {
+                       return $this->session_get(get_class($this).'_'.$key);
+               }
+
+               protected function generate_secret($length = 10)
+               {
+                       return 
substr(base64_encode(rand(1000000000,9999999999)),0, $length);
+               }
+               
+               public function add_js_event($event, $js) {
+                       $GLOBALS['phpgw']->js->add_event($event, $js);
+               }
+               
+               public function add_js_load_event($js) {
+                       $this->add_js_event('load', $js);
+               }
+               
+               /**
                 * Permission check. Proxy method for method check in 
phpgwapi->acl
                 * 
                 * @param $location
@@ -226,6 +354,68 @@
                        $GLOBALS['phpgw']->common->phpgw_exit();
         }
                
+               public function add_yui_translation(&$data)
+               {
+                       $this->add_template_file('yui_booking_i18n');
+                       $previous = lang('prev');
+                       $next = lang('next');
+                                                       
+                       $data['yui_booking_i18n'] = array(
+                               'Calendar' => array(
+                                       'WEEKDAYS_SHORT' => 
json_encode(lang_array('Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa')),
+                                       'WEEKDAYS_FULL' => 
json_encode(lang_array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 
'Friday', 'Saturday')),
+                                       'MONTHS_LONG' => 
json_encode(lang_array('January', 'February', 'March', 'April', 'May', 'June', 
'July', 'August', 'September', 'October', 'November', 'December')),
+                               ),
+                               'DataTable' => array(
+                                       'MSG_EMPTY' => json_encode(lang('No 
records found.')),
+                                       'MSG_LOADING' => 
json_encode(lang("Loading...")),
+                                       'MSG_SORTASC' => 
json_encode(lang('Click to sort ascending')),
+                                       'MSG_SORTDESC' => 
json_encode(lang('Click to sort descending')),
+                               ),
+                               'setupDatePickerHelper' => array(
+                                       'LBL_CHOOSE_DATE' => 
json_encode(lang('Choose a date')),
+                               ),
+                               'setupPaginator' => array(
+                               'pageReportTemplate' => 
json_encode(lang("Showing items {startRecord} - {endRecord} of 
{totalRecords}")),
+                                       'previousPageLinkLabel' => 
json_encode("< {$previous}"),
+                                       'nextPageLinkLabel' => 
json_encode("{$next} >"),
+                               ),
+                               'common' => array(
+                                       'LBL_NAME' => json_encode(lang('Name')),
+                                       'LBL_TIME' => json_encode(lang('Time')),
+                                       'LBL_WEEK' => json_encode(lang('Week')),
+                                       'LBL_RESOURCE' => 
json_encode(lang('Resource')),
+                               ),
+                       );
+               }
+  
+
+               public function add_template_helpers() {
+                       $this->add_template_file('helpers');
+               }
+
+               public function render_template_xsl($files, $data)
+               {
+                       $GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
+
+                       if($this->flash_msgs) {
+                               $data['msgbox_data'] = 
$GLOBALS['phpgw']->common->msgbox($this->flash_msgs);
+                       } else {
+                               $this->add_template_file('msgbox');
+                       }
+                       
+                       $this->reset_flash_msgs();
+                       
+                       $this->add_yui_translation($data);
+                       $data['webserver_url'] = 
$GLOBALS['phpgw_info']['server']['webserver_url'];
+                       
+                       $output = phpgw::get_var('output', 'string', 'REQUEST', 
'html');
+                       $GLOBALS['phpgw']->xslttpl->set_output($output);
+                       $this->add_template_file($files);
+                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('data' => $data));
+               }
+
+  
         public function check_active($url)
                {
                        if($_SERVER['REQUEST_METHOD'] == 'POST')
@@ -479,12 +669,5 @@
                public function __sleep()
                {
                        return array('table_name', 'fields');
-               }
-               
-               protected function generate_secret($length = 10)
-               {
-                       return 
substr(base64_encode(rand(1000000000,9999999999)),0, $length);
-               }
-               
+               }               
        }
-?>

Modified: trunk/controller/inc/class.uicontrol_item2.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol_item2.inc.php  2011-09-15 10:11:37 UTC 
(rev 7604)
+++ trunk/controller/inc/class.uicontrol_item2.inc.php  2011-09-15 11:46:14 UTC 
(rev 7605)
@@ -21,7 +21,6 @@
                public function __construct()
                {
                        parent::__construct();
-                       $GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
                        $this->so = CreateObject('controller.socontrol');
                        $this->so_control_item = 
CreateObject('controller.socontrol_item');
                        $this->so_control_group = 
CreateObject('controller.socontrol_group');
@@ -83,7 +82,7 @@
                                $control_type_options = array
                                (
                                        'id'    => $control_type->get_id(),
-                                       'name'  => $control_type->get_title()
+                                       'name'  => $control_type->get_name()
                                         
                                );
                        }
@@ -93,7 +92,7 @@
                                $control_group_options = array
                                (
                                        'id'    => $control_group->get_id(),
-                                       'name'  => $control_group->get_title()
+                                       'name'  => $control_group->get_name()
                                         
                                );
                        }
@@ -108,17 +107,17 @@
                        );
 
 
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('controller') . '::' . lang('Control_item');
+
+/*
                        
$GLOBALS['phpgw']->richtext->replace_element('what_to_do');
                        
$GLOBALS['phpgw']->richtext->replace_element('how_to_do');
-               //      $GLOBALS['phpgw']->richtext->generate_script();
+                       $GLOBALS['phpgw']->richtext->generate_script();
+*/
 
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('controller') . '::' . lang('Control_item');
-                       
$GLOBALS['phpgw']->xslttpl->add_file(array('control_item'));
-                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('item' => $data));
+//                     $GLOBALS['phpgw']->js->validate_file( 'yahoo', 
'controller.item', 'controller' );
 
-       //              $GLOBALS['phpgw']->js->validate_file( 'yahoo', 
'common', 'controller' );
-                       $GLOBALS['phpgw']->js->validate_file( 'yahoo', 
'controller.item', 'controller' );
-
+                       self::render_template_xsl('control_item', $data);
                }
                                        
 

Modified: trunk/controller/js/yahoo/common.js
===================================================================
--- trunk/controller/js/yahoo/common.js 2011-09-15 10:11:37 UTC (rev 7604)
+++ trunk/controller/js/yahoo/common.js 2011-09-15 11:46:14 UTC (rev 7605)
@@ -1,984 +1,766 @@
-/**
- * Javascript for the controller module.  Holds datasource init functions and 
form helpers.
- *
- * Functions and objects within this file are kept in the YAHOO.controller 
namespace.
- */
+YAHOO.namespace('portico');
 
-       // Holds data source setup funtions
-       YAHOO.controller.setupDatasource = new Array();
+YAHOO.portico.js_alias_method_chain = function(constructor_func, func_name, 
new_feature_name, feature_impl_func) {
+       constructor_func.prototype[func_name+'_without_'+new_feature_name] = 
constructor_func.prototype[func_name];
+       constructor_func.prototype[func_name+'_with_'+new_feature_name] = 
feature_impl_func;
+       constructor_func.prototype[func_name] = 
constructor_func.prototype[func_name+'_with_'+new_feature_name];
+};
 
-       //Holds all data sources
-       YAHOO.controller.datatables = new Array();
-
-       counter = 0;
-       // Adds data source setup funtions
-       function setDataSource(source_url, column_defs, form_id, filter_ids, 
container_id, paginator_id, datatable_id,rel_id, editor_action, 
disable_left_click) {
-               YAHOO.controller.setupDatasource.push(
-                       function() {
-                               this.url = source_url;
-                               this.columns = column_defs;
-                               this.form = form_id;
-                               this.filters = filter_ids;
-                               this.container = container_id;
-                               this.paginator = paginator_id;
-                               this.tid = datatable_id;
-                               this.related_datatable = rel_id;
-                               this.editor_action = editor_action;
-                               if(disable_left_click) {
-                                       this.disable_left_click = true;
-                               } else {
-                                       this.disable_left_click = false;
-                               }
-                       }
-               );
+YAHOO.portico.lang = function(section, config) {
+       config = config || {};
+       if (YAHOO && YAHOO.booking && YAHOO.portico.i18n && 
YAHOO.portico.i18n[section]) {
+               YAHOO.portico.i18n[section](config);
        }
+       return config;
+};
 
-       YAHOO.controller.formatDate = function(elCell, oRecord, oColumn, oData) 
{
-               //alert("oDate: " + oData);
-               if (oData && oData != "Invalid Date" && oData != "NaN") {
-                       var my_date = Math.round(Date.parse(oData) / 1000);
-                       elCell.innerHTML = formatDate('<?php echo 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'] ?>', 
my_date);
-               } else {
-                       elCell.innerHTML = "";
-               }
-       };
+/** Hook widgets to translations **/
+YAHOO.portico.js_alias_method_chain(YAHOO.widget.Calendar, 'init', 'i18n', 
function(id, container, config) {
+       YAHOO.portico.lang('Calendar', config);
+       return this.init_without_i18n(id, container, config);
+});
 
-       // Override the built-in formatter
-       YAHOO.widget.DataTable.formatCurrency = function(elCell, oRecord, 
oColumn, oData) {
-               if (oData != undefined) {
-                       elCell.innerHTML = YAHOO.util.Number.format( oData,
-                       {
-                               prefix: "<?php echo 
$GLOBALS['phpgw_info']['user']['preferences']['common']['currency'].' ' ?>",
-                               thousandsSeparator: ",",
-                               decimalPlaces: 2
-                   });
-               }
-               //if (oData != undefined) {
-               //      elCell.innerHTML = '<?php echo 
$GLOBALS['phpgw_info']['user']['preferences']['common']['currency'].' ' ?>' + 
parseFloat(oData).toFixed(2);
-               //}
-       };
+YAHOO.portico.js_alias_method_chain(YAHOO.widget.DataTable, '_initConfigs', 
'i18n', function(config) {
+       YAHOO.portico.lang('DataTable', config);
+       return this._initConfigs_without_i18n(config);
+});
 
-       // Reloads all data sources that are necessary based on the selected 
related datatable
-       function reloadDataSources(selected_datatable){
+function y2k(number) { return (number < 1000) ? number + 1900 : number; }
+YAHOO.portico.weeknumber = function(when) {
+       var year = when.getFullYear();
+       var month = when.getMonth();
+       var day = when.getDate();
 
-               //... hooks into  the regular callback function 
(onDataReturnInitializeTable) call to set empty payload array
-               var loaded =  function  ( sRequest , oResponse , oPayload ) {
-                       var payload = new Array();
-                       this.onDataReturnInitializeTable( sRequest , oResponse 
, payload );
-               }
+       var newYear = new Date(year,0,1);
+       var modDay = newYear.getDay();
+       if (modDay == 0) modDay=6; else modDay--;
 
-               //... refresh the selected data tables
-               
selected_datatable.getDataSource().sendRequest('',{success:loaded, 
scope:selected_datatable});
+       var daynum = ((Date.UTC(y2k(year),when.getMonth(),when.getDate(),0,0,0) 
- Date.UTC(y2k(year),0,1,0,0,0)) /1000/60/60/24) + 1;
 
-               //... traverse all datatables and refresh related (to the 
selected) data tables
-               for(var i=0; i<YAHOO.controller.datatables.length; i++){
-                       var datatable = YAHOO.controller.datatables[i];
+  if (modDay < 4 ) {
+    var weeknum = Math.floor((daynum+modDay-1)/7)+1;
+  } else {
+    var weeknum = Math.floor((daynum+modDay-1)/7);
+    if (weeknum == 0) {
+      year--;
+      var prevNewYear = new Date(year,0,1);
+      var prevmodDay = prevNewYear.getDay();
+      if (prevmodDay == 0) prevmodDay = 6; else prevmodDay--;
+      if (prevmodDay < 4) weeknum = 53; else weeknum = 52;
+    }
+  }
+  return + weeknum;
+}
 
-                       for(var j=0;j<selected_datatable.related.length;j++){
-                               var curr_related = 
selected_datatable.related[j];
-                               if(datatable.tid == curr_related){
-                                       
datatable.getDataSource().sendRequest('',{success:loaded,scope: datatable});
-                               }
+parseISO8601 = function (string) {
+       var regexp = "(([0-9]{4})(-([0-9]{1,2})(-([0-9]{1,2}))))?( 
)?(([0-9]{1,2}):([0-9]{1,2}))?";
+       var d = string.match(new RegExp(regexp));
+       var year = d[2] ? (d[2] * 1) : 0;
+       date = new Date(year, (d[4]||1)-1, d[6]||0);
+       if(d[9])
+               date.setHours(d[9]);
+       if(d[10])
+               date.setMinutes(d[10]);
+       return date;
+};
+
+YAHOO.portico.serializeForm = function(formID) {
+       var form = YAHOO.util.Dom.get(formID);
+       var values = [];
+       for(var i=0; i < form.elements.length; i++) {
+               var e = form.elements[i];
+               if(e.type=='checkbox' || e.type=='radio') {
+                       if(e.checked) {
+                               values.push(e.name + '=' + 
encodeURIComponent(e.value));
                        }
+               } 
+               else if(e.name) {
+                       values.push(e.name + '=' + encodeURIComponent(e.value));
                }
        }
+       return values.join('&');
+};
 
-       var highlightEditableCell = function(oArgs) {
-               var elCell = oArgs.target;
-               if(YAHOO.util.Dom.hasClass(elCell, "yui-dt-editable")) {
-                       this.highlightCell(elCell);
+YAHOO.portico.fillForm = function(formID, params) {
+       var form = YAHOO.util.Dom.get(formID);
+       var values = [];
+       for(var i=0; i < form.elements.length; i++) {
+               var e = form.elements[i];
+               if((e.type=='checkbox' || e.type=='radio') && params[e.name]) {
+                       e.checked = true;
+               } 
+               else if(e.name && params[e.name] != undefined) {
+                       e.value = params[e.name];
+                       if(e._update) { // Is this connected to a date picker?
+                               e._update();
+                       }
                }
-       };
+       }
+       return values.join('&');
+};
 
-       // Wraps data sources setup logic
-       function dataSourceWrapper(source_properties,pag) {
+YAHOO.portico.parseQS = function(qs) {
+       qs = qs.replace(/\+/g, ' ');
+       var args = qs.split('&');
+       var params = {};
+       for (var i = 0; i < args.length; i++) {
+               var pair = args[i].split('=');
+               var name = decodeURIComponent(pair[0]);
+               var value = (pair.length==2) ? decodeURIComponent(pair[1]) : 
name;
+               params[name] = value;
+       }
+       return params;
+}
 
-               this.properties = source_properties;
-               this.paginator = pag;
+YAHOO.portico.formatLink = function(elCell, oRecord, oColumn, oData) { 
+       var name = oRecord.getData(oColumn.key);
+       var link = oRecord.getData('link');
+       elCell.innerHTML = '<a href="' + link + '">' + name + '</a>'; 
+};
 
-               //... prepare base url
-               this.url = this.properties.url;
-               if(this.url[length-1] != '&') {
-                       this.url += '&';
+YAHOO.portico.formatGenericLink = function() {
+       var links = [];
+       var nOfLinks = arguments.length;
+       
+       for (var i=0; i < nOfLinks; i++) { links[i] = arguments[i]; }
+       
+       return function(elCell, oRecord, oColumn, oData)
+       {
+               var nOfLinks = links.length;
+               var data = oRecord.getData(oColumn.key);
+               
+               var linksHtml = '';
+               if (nOfLinks > 0) {
+                       //Use specified link names
+                       for (var i=0; i < nOfLinks; i++) {
+                               if (data[i])
+                               {
+                                       linksHtml += '<div><a href="' + data[i] 
+ '">' + links[i] + '</a></div>';
+                               }
+                       }
+               } else {
+                       //Get label from embedded data
+                       if (data['href'] != undefined && data['label'] != 
undefined) {
+                               linksHtml += '<div><a href="' + data['href'] + 
'">' + data['label'] + '</a></div>';
+                       } else if(data['href'] == undefined && data['label'] != 
undefined) {
+                               linksHtml += '<div>'+data['label']+'</div>';
+                       }
                }
+               
+               elCell.innerHTML = linksHtml;
+       };
+};
 
-               //... set up a new data source
-               this.source = new YAHOO.util.DataSource(this.url);
+YAHOO.portico.autocompleteHelper = function(url, field, hidden, container, 
label_attr) {
+       label_attr = label_attr || 'name';
+       var myDataSource = new YAHOO.util.DataSource(url);
+       myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
+       myDataSource.connXhrMode = "queueRequests";
+       myDataSource.responseSchema = {
+               resultsList: "ResultSet.Result",
+               fields: [label_attr, 'id']
+       };
+       myDataSource.maxCacheEntries = 5; 
+       var ac = new YAHOO.widget.AutoComplete(field, container, myDataSource);
+       ac.queryQuestionMark = false;
+       ac.resultTypeList = false;
+       ac.forceSelection = true;
+       ac.itemSelectEvent.subscribe(function(sType, aArgs) {
+               YAHOO.util.Dom.get(hidden).value = aArgs[2].id;
+       });
+       return ac;
+};
 
-               this.source.responseType = YAHOO.util.DataSource.TYPE_JSON;
-               this.source.connXhrMode = "queueRequests";
+YAHOO.portico.setupInlineTablePaginator = function(container) {
+       var paginatorConfig = {
+        rowsPerPage: 10,
+        alwaysVisible: false,
+        template: "{PreviousPageLink} <strong>{CurrentPageReport}</strong> 
{NextPageLink}",
+        pageReportTemplate: "Showing items {startRecord} - {endRecord} of 
{totalRecords}",
+        containers: [YAHOO.util.Dom.get(container)]
+    };
+       
+       YAHOO.portico.lang('setupPaginator', paginatorConfig);
+       var pag = new YAHOO.widget.Paginator(paginatorConfig);
+   pag.render();
+       return pag;
+};
 
-               this.source.responseSchema = {
-                       resultsList: "ResultSet.Result",
-                       fields: this.properties.columns,
-                       metaFields : {
-                               totalRecords: "ResultSet.totalRecords"
-                       }
+YAHOO.portico.inlineTableHelper = function(container, url, colDefs, options, 
disablePagination) {
+       var Dom = YAHOO.util.Dom;
+       
+       var container = Dom.get(container);
+       if(!disablePagination) {
+               var paginatorContainer = 
container.appendChild(document.createElement('div'));
+               var dataTableContainer = 
container.appendChild(document.createElement('div'));
+       }
+       else {
+               dataTableContainer = container;
+       }
+       options = options || {};
+       options.dynamicData = true;
+       
+       if(!disablePagination) {
+               options.paginator = 
YAHOO.portico.setupInlineTablePaginator(paginatorContainer);
+               url += 'results=' + options.paginator.getRowsPerPage() + '&';
+       }
+       var myDataSource = new YAHOO.util.DataSource(url);
+       myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
+       myDataSource.connXhrMode = "queueRequests";
+       myDataSource.responseSchema = {
+               resultsList: "ResultSet.Result",
+               metaFields : { totalResultsAvailable: 
"ResultSet.totalResultsAvailable", actions: 'Actions' }
+       };
+       
+       var myDataTable = new YAHOO.widget.DataTable(dataTableContainer, 
colDefs, myDataSource, options);
+       
+       myDataTable.handleDataReturnPayload = function(oRequest, oResponse, 
oPayload) {
+       oPayload.totalRecords = oResponse.meta.totalResultsAvailable;
+       return oPayload;
+   }
+       
+       myDataTable.doBeforeLoadData = function(nothing, data) {
+               if (!data.meta.actions) return data;
+               
+               actions = data.meta.actions;
+               
+               for (var key in actions) {
+                       var actionLink = document.createElement('a');
+                       actionLink.href = actions[key].href.replace(/&amp;/gi, 
'&');
+                       actionLink.innerHTML = actions[key].text;
+                       YAHOO.util.Dom.insertAfter(actionLink, container);
                };
+               
+               return data;
+       };
+       return {dataTable: myDataTable, dataSource: myDataSource};
+};
 
-               //... set up a new data table
-               if(this.properties.tid == 'total_price')
-               {
-                       //if the datatable is display of total price on 
contract, always initialize
-                       this.table = new YAHOO.widget.DataTable(
-                               this.properties.container,
-                               this.properties.columns,
-                               this.source,
-                               {
-                                       paginator: this.paginator,
-                                       dynamicData: true,
-                                       MSG_EMPTY: '<?php echo 
lang("DATATABLE_MSG_EMPTY")?>',
-                                       MSG_ERROR: '<?php echo 
lang("DATATABLE_MSG_ERROR")?>',
-                                       MSG_LOADING: '<?php echo 
lang("DATATABLE_MSG_LOADING")?>'
-                               }
-                       );
+YAHOO.portico.inlineImages = function(container, url, options)
+{
+       options = options || {};
+       var myDataSource = new YAHOO.util.DataSource(url);
+       myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
+       myDataSource.connXhrMode = "queueRequests";
+       myDataSource.responseSchema = {
+               resultsList: "ResultSet.Result",
+               metaFields : { totalResultsAvailable: 
"ResultSet.totalResultsAvailable", actions: 'Actions' }
+       };
+       
+       myDataSource.sendRequest('', {success: function(sRequest, oResponse, 
oPayload) {
+               var dlImages = new 
YAHOO.util.Element(document.createElement('dl'));
+               dlImages.addClass('proplist images');
+               
+               var displayContainer = false;
+               
+        for(var key in oResponse.results) { 
+                       displayContainer = true;
+                       var imgEl = 
dlImages.appendChild(document.createElement('dd')).appendChild(document.createElement('img'));
+                       var captionEl = 
dlImages.appendChild(document.createElement('dt'));
+                       imgEl.src = 
oResponse.results[key].src.replace(/&amp;/gi, '&');
+                       
captionEl.appendChild(document.createTextNode(oResponse.results[key].description));
                }
-               else
+               
+               if (displayContainer)
                {
-                       this.table = new YAHOO.widget.DataTable(
-                               this.properties.container,
-                               this.properties.columns,
-                               this.source,
-                               {
-                                       paginator: this.paginator,
-                                       dynamicData: true,
-                                       <?php
-                                               $populate = 
phpgw::get_var('populate_form'); 
-                                               echo isset($populate)? 
'initialLoad: false,':''
-                                       ?>
-                                       <?php 
-                                               $initLoad = 
phpgw::get_var('initial_load');
-                                               echo ($initLoad == 'no')? 
'initialLoad: false,':''
-                                       ?>
-                                       MSG_EMPTY: '<?php echo 
lang("DATATABLE_MSG_EMPTY")?>',
-                                       MSG_ERROR: '<?php echo 
lang("DATATABLE_MSG_ERROR")?>',
-                                       MSG_LOADING: '<?php echo 
lang("DATATABLE_MSG_LOADING")?>'
-                               }
-                       );
+                       new YAHOO.util.Element(container).appendChild(dlImages);
+               } else {
+                       new YAHOO.util.Element(container).setStyle('display', 
'none');
                }
+    }});
+};
 
-               //... set table properties
-               this.table.related = this.properties.related_datatable;
-               this.table.tid = this.properties.tid;
-               this.table.container_id = this.properties.container;
-               this.table.editor_action = this.properties.editor_action;
 
-               //... push the data table on a stack
-               YAHOO.controller.datatables.push(this.table);
+YAHOO.portico.radioTableHelper = function(container, url, name, selection) {
+       return YAHOO.portico.checkboxTableHelper(container, url, name, 
selection, {type: 'radio'});
+};
 
-               //... ?
-               this.table.handleDataReturnPayload = function(oRequest, 
oResponse, oPayload) {
-                       if(oPayload){
-                               oPayload.totalRecords = 
oResponse.meta.totalRecords;
-                               return oPayload;
-                       }
-               }
-
-               //... create context menu for each record after the table has 
loaded the data
-               this.table.doAfterLoadData = function() {
-                       onContextMenuBeforeShow = function(p_sType, p_aArgs)
-                       {
-                               var oTarget = this.contextEventTarget;
-                               if (this.getRoot() == this)
-                               {
-                                       if(oTarget.tagName != "TD")
-                                       {
-                                               oTarget = 
YAHOO.util.Dom.getAncestorByTagName(oTarget, "td");
-                                       }
-                                       oSelectedTR = 
YAHOO.util.Dom.getAncestorByTagName(oTarget, "tr");
-                                       oSelectedTR.style.backgroundColor  = 
'#AAC1D8' ;
-                                       oSelectedTR.style.color = "black";
-                                       YAHOO.util.Dom.addClass(oSelectedTR, 
prefixSelected);
-                               }
-                       }
-
-                       onContextMenuHide = function(p_sType, p_aArgs)
-                       {
-                               if (this.getRoot() == this && oSelectedTR)
-                               {
-                                       oSelectedTR.style.backgroundColor  = "" 
;
-                                       oSelectedTR.style.color = "";
-                                       YAHOO.util.Dom.removeClass(oSelectedTR, 
prefixSelected);
-                               }
-                       }
+YAHOO.portico.checkboxTableHelper = function(container, url, name, selection, 
options) {
+       options = YAHOO.lang.isObject(options) ? options : {};
+       
+       options = YAHOO.lang.merge(
+               {type: 'checkbox', selectionFieldOptions: {}, nameFieldOptions: 
{}, defaultChecked: false}, 
+               options
+       );
+       
+       var type = options['type'] || 'checkbox';
+       selection = selection || [];
+       var myDataSource = new YAHOO.util.DataSource(url);
+       myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
+       myDataSource.connXhrMode = "queueRequests";
+       myDataSource.responseSchema = {
+               resultsList: "ResultSet.Result",
+               metaFields : { totalResultsAvailable: 
"ResultSet.totalResultsAvailable" }
+       };
+       
+       var lang = {LBL_NAME: 'Name'};
+       YAHOO.portico.lang('common', lang);
+       
+       var changeListener = false;
+       
+       if (options.onSelectionChanged) {
+               changeListener = function(e) {
+                       var selectedItems = [];
+                       var items = 
YAHOO.util.Dom.getElementsBy(function(i){return i.checked;}, 'input', 
container);
                        
-                       var records = this.getRecordSet();
-                       var validRecords = 0;
-                       for(var i=0; i<records.getLength(); i++) {
-                               var record = records.getRecord(i);
-                               if(record == null)
-                               {
-                                       continue;
-                               }
-                               else
-                               {
-                                       validRecords++;
-                               }
-                                       
-                               // use a global counter to create unique names 
(even for the same datatable) for all context menues on the page
-                               var menuName = this.container_id + "_cm_" + 
counter;
-                               counter++;
-
-                               //... add menu items with label and handler 
function for click events
-                               var labels = record.getData().labels;
-                               //create a context menu that triggers on the 
HTML row element
-                               record.menu = new 
YAHOO.widget.ContextMenu(menuName,{trigger:this.getTrEl(validRecords -1 
),itemdata: labels, lazyload: true});
-
-                               //... subscribe handler for click events
-                               
record.menu.clickEvent.subscribe(onContextMenuClick, this);
-                               record.menu.subscribe("beforeShow", 
onContextMenuBeforeShow);
-                               record.menu.subscribe("hide", 
onContextMenuHide);
-
-                               //... render the menu on the related table row
-                               
record.menu.render(this.getTrEl(validRecords-1));
-                       }
-
+                       YAHOO.util.Dom.batch(items, function(e, selectedItems) {
+                               selectedItems.push(e.value);
+                       }, selectedItems);
                        
-               }
-
-               //... calback methods for handling ajax calls
-               var ajaxResponseSuccess = function(o){
-                       reloadDataSources(this.args);
+                       options.onSelectionChanged(selectedItems);
                };
-
-               var ajaxResponseFailure = function(o){
-                       reloadDataSources(this.args);
-               };
-
-               //...create a handler for context menu clicks
-               var onContextMenuClick = function(eventString, args, table) {
-                       //... the argument holds the selected index number in 
the context menu
-                       var task = args[1];
-                       //... only act on a data table
-                       if(table instanceof YAHOO.widget.DataTable) {
-                               //... retrieve the record based on the selected 
table row
-                               var row = 
table.getTrEl(this.contextEventTarget);
-                               var record = table.getRecord(row);
-
-                               //... check whether this action should be an 
AJAX call
-                               if(record.getData().ajax[task.index]) {
-                                       var request = 
YAHOO.util.Connect.asyncRequest(
-                                               'GET',
-                                               record.getData().actions[ 
task.index ],
-                                               {
-                                                       success: 
ajaxResponseSuccess,
-                                                       success: 
ajaxResponseFailure,
-                                                       args:table
-                                               });
-                               } else {
-                                       window.location = 
record.getData().actions[task.index];
-                               }
+       }
+       
+       var checkboxFormatter = function(elCell, oRecord, oColumn, oData) { 
+               var checked = false;
+               var newInput; 
+               for(var i=0; i < selection.length; i++) {
+                       if (selection[i] == oData) {
+                               checked = true;
+                               break;
                        }
-               };
-
-               // Handle mouseover and click events for inline editing
-               this.table.subscribe("cellMouseoverEvent", 
highlightEditableCell);
-               this.table.subscribe("cellMouseoutEvent", 
this.table.onEventUnhighlightCell);
-               this.table.subscribe("cellClickEvent", 
this.table.onEventShowCellEditor);
-
-               this.table.subscribe("editorSaveEvent", function(oArgs) {
-                       var field = oArgs.editor.getColumn().field;
-                       var value = oArgs.newData;
-                       var id = oArgs.editor.getRecord().getData().id;
-                       var action = oArgs.editor.getDataTable().editor_action;
-
-                       // Translate to unix time if the editor is a calendar.
-                       if (oArgs.editor._sType == 'date') {
-                               var selectedDate = 
oArgs.editor.calendar.getSelectedDates()[0];
-                               //alert("selDate1: " + selectedDate);
-                               // Make sure we're at midnight GMT
-                               selectedDate = selectedDate.toString().split(" 
");
-                               //for(var e=0;e<selectedDate.length;e++){
-                               //      alert("element " + e + ": " + 
selectedDate[e]);
-                               //}
-                               if(selectedDate[3] == "00:00:00"){
-                               //      alert("seldate skal byttes!");
-                                       selectedDate = 
selectedDate.slice(0,3).join(" ") + " " + selectedDate[5] + " 00:00:00 GMT"; 
-                               }
-                               else{
-                                       selectedDate = 
selectedDate.slice(0,4).join(" ") + " 00:00:00 GMT";
-                               }
-                               //selectedDate = 
selectedDate.toString().split(" ").slice(0, 4).join(" ") + " 00:00:00 GMT";
-                               //alert("selDate2: " + selectedDate);
-                               var value = Math.round(Date.parse(selectedDate) 
/ 1000);
-                               //alert("selDate3 value: " + value);
-                       }
-
-                       var request = YAHOO.util.Connect.asyncRequest(
-                                       'GET',
-                                       'index.php?menuaction=' + action + 
"&amp;field=" + field + "&amp;value=" + value + "&amp;id=" + id,
-                                       {
-                                               success: ajaxResponseSuccess,
-                                               failure: ajaxResponseFailure,
-                                               args:oArgs.editor.getDataTable()
-                                       }
-                               );
-               });
-
-               // Don't set the row to be left-clickable if the table is 
editable by inline editors.
-               // In that case we use cellClickEvents instead
-               var table_should_be_clickable = true;
-               for (i in this.properties.columns) {
-                       if (this.properties.columns[i].editor) {
-                               table_should_be_clickable = false;
-                       }
                }
-
-               if (table_should_be_clickable && 
!this.properties.disable_left_click) {
-                       //... create a handler for regular clicks on a table row
-                       this.table.subscribe("rowClickEvent", function(e,obj) {
-                               YAHOO.util.Event.stopEvent(e);
-
-                               //... trigger first action on row click
-                               var row = obj.table.getTrEl(e.target);
-                               if(row) {
-                                       var record = obj.table.getRecord(row);
-
-                                       //... check whether this action should 
be an AJAX call
-                                       if(record.getData().ajax[0]) {
-                                               var request = 
YAHOO.util.Connect.asyncRequest(
-                                                       'GET',
-                                                       //... execute first 
action
-                                                       
record.getData().actions[0],
-                                                       {
-                                                               success: 
ajaxResponseSuccess,
-                                                               failure: 
ajaxResponseFailure,
-                                                               args:obj.table
-                                                       }
-                                               );
-                                       } else {
-                                               //... execute first action
-                                               window.location = 
record.getData().actions[0];
-                                       }
-                               }
-                       },this);
-
-                       //... highlight rows on mouseover.  This too only 
happens if the table is
-                       // not editable.
-                       this.table.subscribe("rowMouseoverEvent", 
this.table.onEventHighlightRow);
-                       this.table.subscribe("rowMouseoutEvent", 
this.table.onEventUnhighlightRow);
+               
+               newInput = document.createElement('input');
+               newInput.setAttribute('type', type);
+               newInput.setAttribute('name', name);
+               newInput.setAttribute('value', oData);
+               if (checked || options.defaultChecked) {
+                       newInput.setAttribute('checked', 'checked');
+                       newInput.setAttribute('defaultChecked', true); //Needed 
for IE compatibility
                }
+               
+               if (changeListener != false) {
+                       //Using 'click' event on IE as the change event does 
not work as expected there.
+                       YAHOO.util.Event.addListener(newInput, (YAHOO.env.ua.ie 
> 0 ? 'click' : 'change'), changeListener);
+               }
+               
+               elCell.appendChild(newInput);
+               
+       };
+       var colDefs = [
+               YAHOO.lang.merge({key: "id", formatter: checkboxFormatter, 
label: ''}, options.selectionFieldOptions),
+               YAHOO.lang.merge({key: "name", label: lang['LBL_NAME'], 
sortable: true}, options.nameFieldOptions)
+       ];
+       
+       if (options['additional_fields'] && 
YAHOO.lang.isArray(options['additional_fields'])) {
+               for (var i=0; i < options['additional_fields'].length; i++) {
+                       colDefs.push(options['additional_fields'][i]);
+               }
+       }
+       
+       var myDataTable = new YAHOO.widget.DataTable(container, colDefs, 
myDataSource, {
+          sortedBy: {key: 'name', dir: YAHOO.widget.DataTable.CLASS_ASC}
+       });
+};
 
+YAHOO.portico.setupDatePickers = function() {
+       YAHOO.util.Dom.getElementsByClassName('date-picker', null, null, 
YAHOO.portico.setupDatePickerHelper, [true, false]);
+       YAHOO.util.Dom.getElementsByClassName('time-picker', null, null, 
YAHOO.portico.setupDatePickerHelper, [false, true]);
+       YAHOO.util.Dom.getElementsByClassName('datetime-picker', null, null, 
YAHOO.portico.setupDatePickerHelper, [true, true]);
+};
 
-               //... create context menues when the table renders
-               this.table.subscribe("renderEvent",this.table.doAfterLoadData);
-
-               //... listen for form submits and filter changes
-               
YAHOO.util.Event.addListener(this.properties.form,'submit',formListener,this,true);
-               YAHOO.util.Event.addListener(this.properties.filters, 
'change',formListener,this,true);
+YAHOO.portico.setupDatePickerHelper = function(field, args) {
+       if (!YAHOO.portico.setupDatePickerHelper.groups) {
+               YAHOO.portico.setupDatePickerHelper.groups = {};
        }
+       
+       var groups = YAHOO.portico.setupDatePickerHelper.groups;
+       var Dom = YAHOO.util.Dom;
+       
+       if(field._converted)
+               return;
+       field._converted = true;
+       var date = args[0];
+       var time = args[1];
+       var Dom = YAHOO.util.Dom;
+       var Event = YAHOO.util.Event;
+       var oCalendarMenu = new YAHOO.widget.Overlay(Dom.generateId(), { 
visible: false});
+       var oButton = new YAHOO.widget.Button({type: "menu", id: 
Dom.generateId(), menu: oCalendarMenu, container: field});
+       
+       oButton.with_time = time;
+       oButton.with_date = date;
+       
+       var lang = {LBL_CHOOSE_DATE: 'Choose a date'};
+       YAHOO.portico.lang('setupDatePickerHelper', lang);
+       
+       oButton._calendarMenu = oCalendarMenu;
+       oButton._input = field._input = Dom.getElementsBy(function(){return 
true;}, 'input', field)[0];
+       
+       oButton.hasDateSection = function() { return this.with_date; };
+       oButton.hasTimeSection = function() { return this.with_time; };
+       
+       oButton.fireUpdateEvent = function() {
+               if (oButton.on_update) {
+                       oButton.on_update.func.call(oButton.on_update.context, 
oButton);
+               }
+       };
+       
+       oButton.on("appendTo", function () {
+               this._calendarMenu.setBody(" ");
+               this._calendarMenu.body.id = Dom.generateId();
+       });
+       if(!date)
+               oButton.setStyle('display', 'none');
+       //oButton._input.setAttribute('type', 'hidden');
+       oButton._input.style.display = 'none';
+       if(oButton._input.value)
+               oButton._date = parseISO8601(oButton._input.value);
+       else
+               oButton._date = new Date(1, 1, 1);
+       oButton._input._update = function() {
+               if(oButton._input.value)
+                       oButton._date = parseISO8601(oButton._input.value);
+               else
+                       oButton._date = new Date(1, 1, 1);
+               oButton._update(false);
+       };
+       oButton._update = function(fire_update_event) {
+               var year = this._date.getFullYear();
+               var month = this._date.getMonth() + 1;
+               var day = this._date.getDate();
+               var hours = this._date.getHours();
+               var minutes = this._date.getMinutes();
+               var month = month < 10 ? '0' + month : '' + month;
+               var day = day < 10 ? '0' + day : '' + day;
+               var hours = hours < 10 ? '0' + hours : '' + hours;
+               var minutes = minutes  < 10 ? '0' + minutes : '' + minutes;
+               var dateValue = year + '-' + month + '-' + day;
+               var timeValue = hours + ':' + minutes;
+               if(year == 1901) {
+                       this.set('label', lang.LBL_CHOOSE_DATE);
+               } else {
+                       this.set('label', dateValue);
+               }
+               if(time) {
+                       this._hours.set('value', parseInt(hours, 10));
+                       this._minutes.set('value', parseInt(minutes, 10));
+                       this._hours.update();
+                       this._minutes.update();
+               }
+               if(year != 1901 && date && time)
+                       this._input.value = dateValue + ' ' + timeValue;
+               else if (year != 1901 && date)
+                       this._input.value = dateValue;
+               else if(!date && time)
+                       this._input.value = timeValue;
+               
+               if (fire_update_event) {
+                       oButton.fireUpdateEvent();
+               }
+       };
+       
+       oButton.getDate = function() {
+               return this._date;
+       };
 
-
-       // Set up data sources when the document has loaded
-       YAHOO.util.Event.addListener(window, "load", function() {
-               var i = 0;
-               while(YAHOO.controller.setupDatasource.length > 0){
-                       //... create a variable name, assign set up function to 
that variable and instantiate properties
-                       variableName = "YAHOO.controller.datasource" + i;
-                       eval(variableName + " = 
YAHOO.controller.setupDatasource.shift()");
-                       var source_properties = eval("new " + variableName + 
"()");
-
-<?php
-       if($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] 
> 0)
-       {
-               $user_rows_per_page = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+       oButton.on("click", function () {
+               YAHOO.widget.DateMath.WEEK_ONE_JAN_DATE = 4;
+               var oCalendar = new YAHOO.widget.Calendar(Dom.generateId(), 
this._calendarMenu.body.id, {START_WEEKDAY: 1,SHOW_WEEK_HEADER:true});
+               oCalendar._button = this;
+               if(this._date.getFullYear() == 1901) {
+                       var d = new Date();
+                       oCalendar.cfg.setProperty("pagedate", (d.getMonth()+1) 
+ "/" + d.getFullYear());
+               } else {
+                       oCalendar.select(this._date);
+                       oCalendar.cfg.setProperty("pagedate", 
(this._date.getMonth()+1) + "/" + this._date.getFullYear());
+               }
+               
+               oCalendar.render();
+               // Hide date picker on ESC
+               Event.on(this._calendarMenu.element, "keydown", function 
(p_oEvent) {
+                       if (Event.getCharCode(p_oEvent) === 27) {
+                               this._calendarMenu.hide();
+                               this.focus();
+                       }
+               }, null, this);
+               oCalendar.selectEvent.subscribe(function (p_sType, p_aArgs) {
+                       if (p_aArgs) {
+                               var aDate = p_aArgs[0][0];
+                               this._date.setFullYear(aDate[0]);
+                               this._date.setMonth(aDate[1]-1);
+                               this._date.setDate(aDate[2]);
+                               this._update(true);
+                               //this._input.value = value;
+                       }
+                       this._calendarMenu.hide();
+               }, this, true);
+       });
+       if(time) {
+               oButton._hours = new YAHOO.portico.InputNumberRange({min: 0, 
max:23});
+               oButton._minutes = new YAHOO.portico.InputNumberRange({min: 0, 
max:59});
+               
+               oButton._hours.on('updateEvent', function() {
+                       oButton._date.setHours(this.get('value'));
+                       oButton._update(true);
+               });
+               
+               oButton._minutes.on('updateEvent', function() {
+                       oButton._date.setMinutes(this.get('value'));
+                       oButton._update(true);
+               });
+               
+               oButton.on("appendTo", function () {
+                       var timePicker = 
Dom.get(field).appendChild(document.createElement('span'));
+                       Dom.addClass(timePicker, 'time-picker-inputs');
+                       timePicker.appendChild(document.createTextNode(' '));
+                       oButton._hours.render(timePicker);
+                       timePicker.appendChild(document.createTextNode(' : '));
+                       oButton._minutes.render(timePicker);
+                       oButton._update(false);
+               });
        }
-       else {
-               $user_rows_per_page = 10;
-       }
-?>
+       oButton._update(false);
+       
+       var id = Dom.getAttribute(oButton._input, 'id');
+       var matches = /^([a-zA-Z][\w0-9\-_.:]+)_(from|to)$/.exec(id);
+       
+       var group_name = matches ? matches[1] : false;
+       var from_to = matches ? matches[2] : false;
+       
+       if (group_name && from_to && oButton.hasDateSection()) {
+               if (!groups[group_name]) { groups[group_name] = {}; }
+               
+               groups[group_name][from_to] = oButton;
 
-                       // ... create a paginator for this datasource
-                       var pag = new YAHOO.widget.Paginator({
-                               rowsPerPage: <?php echo $user_rows_per_page ?>,
-                               alwaysVisible: true,
-                               rowsPerPageOptions: [5, 10, 25, 50, 100, 200],
-                               firstPageLinkLabel: "<< <?php echo 
lang('first') ?>",
-                               previousPageLinkLabel: "< <?php echo 
lang('previous') ?>",
-                               nextPageLinkLabel: "<?php echo lang('next') ?> 
>",
-                               lastPageLinkLabel: "<?php echo lang('last') ?> 
>>",
-                               template                        : 
"{RowsPerPageDropdown}<?php echo lang('elements_pr_page') 
?>.{CurrentPageReport}<br/>  {FirstPageLink} {PreviousPageLink} {PageLinks} 
{NextPageLink} {LastPageLink}",
-                               pageReportTemplate      : "<?php echo 
lang('shows_from') ?> {startRecord} <?php echo lang('to') ?> {endRecord} <?php 
echo lang('of_total') ?> {totalRecords}.",
-                               containers: [source_properties.paginator]
-                       });
-
-                       pag.render();
-
-                       //... send data source properties and paginator to 
wrapper function
-                       this.wrapper = new dataSourceWrapper(source_properties, 
pag);
-                       i+=1;
-
-                       <?php
-                               $populate = phpgw::get_var('populate_form');
-                               if(isset($populate)){?>
-                                       var qs = 
YAHOO.controller.serializeForm(source_properties.form);
-                                   this.wrapper.source.liveData = 
this.wrapper.url + qs + '&';
-                                   this.wrapper.source.sendRequest('', 
{success: function(sRequest, oResponse, oPayload) {
-                                       
this.wrapper.table.onDataReturnInitializeTable(sRequest, oResponse, 
this.wrapper.paginator);
-                                   }, scope: this});
-                       <?php }
-                       ?>
-
-                       // XXX: Create generic column picker for all datasources
-
-                       // Shows dialog, creating one when necessary
-                       var newCols = true;
-                       var showDlg = function(e) {
-                               YAHOO.util.Event.stopEvent(e);
-
-                               if(newCols) {
-                                       // Populate Dialog
-                                       // Using a template to create elements 
for the SimpleDialog
-                                       var allColumns = 
this.wrapper.table.getColumnSet().keys;
-                                       var elPicker = 
YAHOO.util.Dom.get("dt-dlg-picker");
-                                       var elTemplateCol = 
document.createElement("div");
-                                       YAHOO.util.Dom.addClass(elTemplateCol, 
"dt-dlg-pickercol");
-                                       var elTemplateKey = 
elTemplateCol.appendChild(document.createElement("span"));
-                                       YAHOO.util.Dom.addClass(elTemplateKey, 
"dt-dlg-pickerkey");
-                                       var elTemplateBtns = 
elTemplateCol.appendChild(document.createElement("span"));
-                                       YAHOO.util.Dom.addClass(elTemplateBtns, 
"dt-dlg-pickerbtns");
-                                       var onclickObj = {fn:handleButtonClick, 
obj:this, scope:false };
-
-                                       // Create one section in the 
SimpleDialog for each Column
-                                       var elColumn, elKey, elButton, 
oButtonGrp;
-
-                                       for(var 
i=0,l=allColumns.length;i<l;i++) {
-                                               var oColumn = allColumns[i];
-                                               if(oColumn.label != 
'unselectable') { // We haven't marked the column as unselectable for the user
-                                                       // Use the template
-                                                       elColumn = 
elTemplateCol.cloneNode(true);
-
-                                                       // Write the Column key
-                                                       elKey = 
elColumn.firstChild;
-                                                       elKey.innerHTML = 
oColumn.label;
-
-                                                       // Create a ButtonGroup
-                                                       oButtonGrp = new 
YAHOO.widget.ButtonGroup({
-                                                               id: 
"buttongrp"+i,
-                                                               name: 
oColumn.getKey(),
-                                                               container: 
elKey.nextSibling
-                                                       });
-                                                       oButtonGrp.addButtons([
-                                                               { label: "Vis", 
value: "Vis", checked: ((!oColumn.hidden)), onclick: onclickObj},
-                                                               { label: 
"Skjul", value: "Skjul", checked: ((oColumn.hidden)), onclick: onclickObj}
-                                                       ]);
-
-                                                       
elPicker.appendChild(elColumn);
-                                               }
+               if (groups[group_name]['from'] && groups[group_name]['to']) {
+                       groups[group_name]['from'].on_update = {
+                               context: groups[group_name]['to'], 
+                               func: function(fromDateButton) {
+                                       var fromDate = fromDateButton.getDate();
+                                       var currentYear = 
this._date.getFullYear();
+                                       
+                                       if (this._date.getFullYear() == 1901) {
+                                               
this._date.setFullYear(fromDate.getFullYear());
+                                               
this._date.setMonth(fromDate.getMonth());
+                                               
this._date.setDate(fromDate.getDate());
+                                       } else if (fromDate.getFullYear() <= 
this._date.getFullYear() && fromDate.getMonth() <= this._date.getMonth() && 
fromDate.getDate() <= this._date.getDate()) {
+                                               //this._date.
                                        }
-
-                                       newCols = false;
+                               
+                                       this._update(false);
                                }
-
-                               myDlg.show();
                        };
-
-                       var storeColumnsUrl = YAHOO.controller.storeColumnsUrl;
-                       var hideDlg = function(e) {
-                               this.hide();
-                               // After we've hidden the dialog we send a post 
call to store the columns the user has selected
-                               var postData = 'values[save]=1';
-                               var allColumns = 
wrapper.table.getColumnSet().keys;
-                               for(var i=0; i < allColumns.length; i++) {
-                                       if(!allColumns[i].hidden){
-                                               postData += 
'&values[columns][]=' + allColumns[i].getKey();
-                                       }
-                               }
-
-                               YAHOO.util.Connect.asyncRequest('POST', 
storeColumnsUrl, null, postData);
-                       };
-
-                       var handleButtonClick = function(e, oSelf) {
-                               var sKey = this.get("name");
-                               if(this.get("value") === "Skjul") {
-                                       // Hides a Column
-                                       wrapper.table.hideColumn(sKey);
-                               } else {
-                                       // Shows a Column
-                                       wrapper.table.showColumn(sKey);
-                               }
-                       };
-
-                       // Create the SimpleDialog
-                       YAHOO.util.Dom.removeClass("dt-dlg", "inprogress");
-                       var myDlg = new YAHOO.widget.SimpleDialog("dt-dlg", {
-                               width: "30em",
-                               visible: false,
-                               modal: false, // modal: true doesn't work for 
some reason - the dialog becomes unclickable
-                               buttons: [
-                                       {text:"Lukk", handler:hideDlg}
-                               ],
-                               fixedcenter: true,
-                               constrainToViewport: true
-                       });
-                       myDlg.render();
-
-                       // Nulls out myDlg to force a new one to be created
-                       wrapper.table.subscribe("columnReorderEvent", 
function(){
-                               newCols = true;
-                               YAHOO.util.Event.purgeElement("dt-dlg-picker", 
true);
-                               YAHOO.util.Dom.get("dt-dlg-picker").innerHTML = 
"";
-                       }, this, true);
-
-                       // Hook up the SimpleDialog to the link
-                       YAHOO.util.Event.addListener("dt-options-link", 
"click", showDlg, this, true);
+                       
+                       delete groups[group_name];
                }
-       });
-
-       /*
-        * Listen for events in form. Serialize all form elements. Stop
-        * the original request and send new request.
-        */
-       function formListener(event){
-               YAHOO.util.Event.stopEvent(event);
-               var qs = YAHOO.controller.serializeForm(this.properties.form);
-           this.source.liveData = this.url + qs + '&';
-           this.source.sendRequest('', {success: function(sRequest, oResponse, 
oPayload) {
-               this.table.onDataReturnInitializeTable(sRequest, oResponse, 
this.paginator);
-           }, scope: this});
        }
+};
 
+// Executed on all booking.uicommon-based pages
+YAHOO.util.Event.addListener(window, "load", function() {
+       YAHOO.portico.setupDatePickers();
+});
+var showIfNotEmpty = function(event, fieldname) {
+    if (document.getElementById(fieldname).value.length > 1) {
+        YAHOO.util.Dom.replaceClass(fieldname + "_edit", "hideit", "showit");
+    } else {
+        YAHOO.util.Dom.replaceClass(fieldname + "_edit", "showit", "hideit");
+    }
+};
 
+YAHOO.portico.rtfEditorHelper = function(textarea_id, options) {
+       options = YAHOO.lang.merge({width:522, height:300}, (options || {}));
+       var descEdit = new YAHOO.widget.SimpleEditor(textarea_id, {
+           height: options.height+'px',
+           width: options.width+'px',
+           dompath: true,
+           animate: true,
+               handleSubmit: true
+       });
+       descEdit.render();
+       return descEdit;
+};
 
-// TODO: All the calendar data must be removed when the 'old' calender is no 
longer used.
+YAHOO.portico.postToUrl = function(path, params, method) {
+    method = method || "post"; // Set method to post by default, if not 
specified.
+    var form = document.createElement("form");
+    form.setAttribute("method", method);
+    form.setAttribute("action", path);
 
-// CALENDAR LOGIC
+    for(var key in params) {
+        var hiddenField = document.createElement("input");
+        hiddenField.setAttribute("type", "hidden");
+        hiddenField.setAttribute("name", params[key][0]);
+        hiddenField.setAttribute("value", params[key][1]);
+        form.appendChild(hiddenField);
+    }
+    document.body.appendChild(form);    // Not entirely sure if this is 
necessary
+    form.submit();
+};
 
-function onClickOnInput(event)
-{
-       this.align();
-       this.show();
-}
+(function(){
+    var Dom = YAHOO.util.Dom,
+        Event = YAHOO.util.Event,
+        Panel = YAHOO.widget.Panel,
+               Lang = YAHOO.lang;
 
-function closeCalender(event)
-{
-       YAHOO.util.Event.stopEvent(event);
-       this.hide();
-}
+       var CSS_PREFIX = 'booking_number_range_';
+ 
+       var InputNumberRange = function(oConfigs) {
+           InputNumberRange.superclass.constructor.call(this, 
document.createElement('span'), oConfigs);
+           this.createEvent('updateEvent');
+               this.refresh(['id'],true);
+       };
 
-function clearCalendar(event)
-{
-       YAHOO.util.Event.stopEvent(event);
-       this.clear();
-       document.getElementById(this.inputFieldID).value = '';
-       document.getElementById(this.hiddenField).value = '';
-}
+       YAHOO.portico.InputNumberRange = InputNumberRange;
 
-function initCalendar(inputFieldID, divContainerID, calendarBodyId, 
calendarTitle, closeButton,clearButton,hiddenField,noPostOnSelect)
-{
-       console.log("i init!!! " + inputFieldID + " : " + divContainerID + " : 
" + calendarBodyId + " : " + calendarTitle );
-       var overlay = new YAHOO.widget.Dialog(
-               divContainerID,
-               {       visible: false,
-                       close: true
-               }
-       );
-
-       var navConfig = {
-                       strings: {
-                               month:"<?php echo lang('month') ?>",
-                               year:"<?php echo lang('year') ?>",
-                               submit: "<?php echo lang('ok') ?>",
-                               cancel: "<?php echo lang('cancel') ?>",
-                               invalidYear: "<?php echo 
lang('select_date_valid_year') ?>"
-                               },
-                               initialFocus: "month"
-                       }
+       Lang.extend(InputNumberRange, YAHOO.util.Element, {
+               initAttributes: function (oConfigs) { 
+                       InputNumberRange.superclass.initAttributes.call(this, 
oConfigs);
+                       
+                       var container = this.get('element');
+               
+                       this.setAttributeConfig('inputEl', {
+                       readOnly: true,
+                       value: 
container.appendChild(document.createElement('span'))
+                   });
        
-       var cal = new YAHOO.widget.Calendar(
-               calendarBodyId,
-               {       navigator:navConfig,
-                       title: '<?php echo lang('select_date') ?>',
-                       start_weekday:1,
-                       LOCALE_WEEKDAYS:"short"}
-       );
-
-       cal.cfg.setProperty("MONTHS_LONG",<?php echo lang('calendar_months') 
?>);
-       cal.cfg.setProperty("WEEKDAYS_SHORT",<?php echo 
lang('calendar_weekdays') ?>);
-       cal.render();
-
-       
cal.selectEvent.subscribe(onCalendarSelect,[inputFieldID,overlay,hiddenField,noPostOnSelect],false);
-       cal.inputFieldID = inputFieldID;
-       cal.hiddenField = hiddenField;
-
-       
YAHOO.util.Event.addListener(closeButton,'click',closeCalender,overlay,true);
-       
YAHOO.util.Event.addListener(clearButton,'click',clearCalendar,cal,true);
-       
YAHOO.util.Event.addListener(inputFieldID,'click',onClickOnInput,overlay,true);
-
-       return cal;
-}
-
-function onCalendarSelect(type,args,array){
-       //console.log("onCalendarSelect");
-       var firstDate = args[0][0];
-       var month = firstDate[1] + "";
-       var day = firstDate[2] + "";
-       var year = firstDate[0] + "";
-       var date = month + "/" + day + "/" + year;
-       var hiddenDateField = document.getElementById(array[2]);
-       if(hiddenDateField != null)
-       {
-               if(month < 10)
+                       this.setAttributeConfig('id', {
+                       writeOnce: true,
+                       validator: function (value) {
+                           return /^[a-zA-Z][\w0-9\-_.:]*$/.test(value);
+                       },
+                       value: Dom.generateId(),
+                       method: function (value) {
+                           this.get('inputEl').id = value;
+                       }
+                   });
+       
+                       this.setAttributeConfig('value', {
+                               value: 0,
+                               validator: Lang.isNumber
+                 });
+               
+                       this.setAttributeConfig('input', {
+                               value: null
+                 });
+               
+                       this.setAttributeConfig('min', {
+                               validator: Lang.isNumber,
+                               value: 100
+                 });
+               
+                       this.setAttributeConfig('max', {
+                               validator: Lang.isNumber,
+                               value: 0
+                       });
+               
+                       this.setAttributeConfig('input_length', {
+                               validator: Lang.isNumber,
+                               value: null
+                       });
+               },
+       
+               destroy: function () { 
+                       var el = this.get('element');
+                   Event.purgeElement(el, true);
+                   el.parentNode.removeChild(el);
+               },
+               
+               _padValue: function(value)
                {
-                       month = '0' + month;
-               }
-               if(day < 10)
+                       value = value.toString('10');
+                       var padding = this.get('input_length') - value.length;
+                       if (padding > 0) {
+                               return ((new Array(padding+1).join('0')) + 
value);
+                       }
+                       return value;
+               },
+               
+               _updateValue: function() {
+                       var input = this.get('input');
+                       var value;
+                       
+                       if (input.value.length > 0) {
+                               value = parseInt(input.value, 10);
+                       } else {
+                               value = 0;
+                       }
+                               
+                       if (isNaN(value)) { 
+                               value = this.get('min');
+                       }
+                       
+                       if (value < this.get('min')) {
+                               value = this.get('min');
+                       }
+                       
+                       if (value > this.get('max')) {
+                               value = this.get('max');
+                       }
+                       
+                       this.set('value', value);
+               },
+               
+               _fireUpdateEvent: function()
                {
-                       day = '0' + day;
+                       this._updateValue();
+                       this.update();
+                       
+                       this.fireEvent('updateEvent');
+               },
+               
+               update: function() {
+                       if (!this.get('input')) { return; }
+                       this.get('input').value = 
this._padValue(this.get('value'));
+               },
+               
+               render: function (parentEl) {
+                       parentEl = Dom.get(parentEl);
+           
+                       if (!parentEl) {
+                               YAHOO.log('Missing mandatory argument in 
YAHOO.portico.InputNumberRange.render:  parentEl','error','Field');
+                               return null;
+                 }
+               
+                       var containerEl = this.get('element');
+                       this.addClass(CSS_PREFIX + 'container');
+               
+                       var inputEl = this.get('inputEl');
+                       Dom.addClass(inputEl, CSS_PREFIX + 'input');
+               
+                       this._renderInputEl(inputEl);
+               
+                       parentEl.appendChild(containerEl); //Appends to 
document to show the component
+               },
+               
+               _renderInputEl: function (containerEl) { 
+                       var input = 
containerEl.appendChild(document.createElement('input'));
+               
+                       if (!this.get('input_length')) {
+                               this.set('input_length', 
this.get('max').toString().length);
+                       }
+               
+                       var size = this.get('input_length');
+                       input.setAttribute('size', size);
+                       input.setAttribute('maxlength', size);
+                       
+                       if (YAHOO.env.ua.ie > 6) {
+                               YAHOO.util.Dom.setStyle(input, 'width', '2em');
+                       }
+                       
+                       input.value = this._padValue(this.get('value'));
+               
+                       this.set('input', input);
+               
+                       Event.on(input,'keyup', function (oArgs) {
+                               this._updateValue();
+                               }, this, true);
+               
+                       Event.on(input, 'change', function(oArgs) {
+                               this._fireUpdateEvent();
+                       }, this, true);
+                       
+                       oForm = input.form;
+                       
+                       if (oForm) {
+                               Event.on(oForm, "submit", function() {
+                                       this._fireUpdateEvent();
+                               }, null, this);
+                       }
+                       
                }
-               hiddenDateField.value = year + '-' + month + '-' + day;
-       }
-       document.getElementById(array[0]).value = formatDate('<?php echo 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'] 
?>',Math.round(Date.parse(date)/1000));
-       array[1].hide();
-       if (cal_postOnChange || (array[3] != undefined && !array[3])) {
-               document.getElementById('ctrl_search_button').click();
-       }
-
-}
-
-/**
- * Update the selected calendar date with a date from an input field
- * Input field value must be of the format YYYY-MM-DD
- */
-function updateCalFromInput(cal, inputId) {
-       var txtDate1 = document.getElementById(inputId);
-
-       if (txtDate1.value != "") {
-
-               var date_elements = txtDate1.value.split('-');
-               var year = date_elements[0];
-               var month = date_elements[1];
-               var day = date_elements[2];
-
-               cal.select(month + "/" + day + "/" + year);
-               var selectedDates = cal.getSelectedDates();
-               if (selectedDates.length > 0) {
-                       var firstDate = selectedDates[0];
-                       cal.cfg.setProperty("pagedate", 
(firstDate.getMonth()+1) + "/" + firstDate.getFullYear());
-                       cal.render();
-               }
-
-       }
-}
-
-function formatDate ( format, timestamp ) {
-    // http://kevin.vanzonneveld.net
-    // +   original by: Carlos R. L. Rodrigues (http://www.jsfromhell.com)
-    // +      parts by: Peter-Paul Koch 
(http://www.quirksmode.org/js/beat.html)
-    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
-    // +   improved by: MeEtc (http://yass.meetcweb.com)
-    // +   improved by: Brad Touesnard
-    // +   improved by: Tim Wiel
-    // +   improved by: Bryan Elliott
-    // +   improved by: Brett Zamir (http://brett-zamir.me)
-    // +   improved by: David Randall
-    // +      input by: Brett Zamir (http://brett-zamir.me)
-    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
-    // +   improved by: Brett Zamir (http://brett-zamir.me)
-    // +   improved by: Brett Zamir (http://brett-zamir.me)
-    // +   derived from: gettimeofday
-    // %        note 1: Uses global: php_js to store the default timezone
-    // *     example 1: date('H:m:s \\m \\i\\s \\m\\o\\n\\t\\h', 1062402400);
-    // *     returns 1: '09:09:40 m is month'
-    // *     example 2: date('F j, Y, g:i a', 1062462400);
-    // *     returns 2: 'September 2, 2003, 2:26 am'
-    // *     example 3: date('Y W o', 1062462400);
-    // *     returns 3: '2003 36 2003'
-    // *     example 4: x = date('Y m d', (new Date()).getTime()/1000); // 
2009 01 09
-    // *     example 4: (x+'').length == 10
-    // *     returns 4: true
-
-    var jsdate=(
-        (typeof(timestamp) == 'undefined') ? new Date() : // Not provided
-        (typeof(timestamp) == 'number') ? new Date(timestamp*1000) : // UNIX 
timestamp
-        new Date(timestamp) // Javascript Date()
-    ); // , tal=[]
-    var pad = function(n, c){
-        if( (n = n + "").length < c ) {
-            return new Array(++c - n.length).join("0") + n;
-        } else {
-            return n;
-        }
-    };
-    var _dst = function (t) {
-        // Calculate Daylight Saving Time (derived from gettimeofday() code)
-        var dst=0;
-        var jan1 = new Date(t.getFullYear(), 0, 1, 0, 0, 0, 0);  // jan 1st
-        var june1 = new Date(t.getFullYear(), 6, 1, 0, 0, 0, 0); // june 1st
-        var temp = jan1.toUTCString();
-        var jan2 = new Date(temp.slice(0, temp.lastIndexOf(' ')-1));
-        temp = june1.toUTCString();
-        var june2 = new Date(temp.slice(0, temp.lastIndexOf(' ')-1));
-        var std_time_offset = (jan1 - jan2) / (1000 * 60 * 60);
-        var daylight_time_offset = (june1 - june2) / (1000 * 60 * 60);
-
-        if (std_time_offset === daylight_time_offset) {
-            dst = 0; // daylight savings time is NOT observed
-        }
-        else {
-            // positive is southern, negative is northern hemisphere
-            var hemisphere = std_time_offset - daylight_time_offset;
-            if (hemisphere >= 0) {
-                std_time_offset = daylight_time_offset;
-            }
-            dst = 1; // daylight savings time is observed
-        }
-        return dst;
-    };
-    var ret = '';
-    var txt_weekdays = ["Sunday","Monday","Tuesday","Wednesday",
-        "Thursday","Friday","Saturday"];
-    var txt_ordin = {1:"st",2:"nd",3:"rd",21:"st",22:"nd",23:"rd",31:"st"};
-    var txt_months =  ["", "January", "February", "March", "April",
-        "May", "June", "July", "August", "September", "October", "November",
-        "December"];
-
-    var f = {
-        // Day
-            d: function(){
-                return pad(f.j(), 2);
-            },
-            D: function(){
-                var t = f.l();
-                return t.substr(0,3);
-            },
-            j: function(){
-                return jsdate.getDate();
-            },
-            l: function(){
-                return txt_weekdays[f.w()];
-            },
-            N: function(){
-                return f.w() + 1;
-            },
-            S: function(){
-                return txt_ordin[f.j()] ? txt_ordin[f.j()] : 'th';
-            },
-            w: function(){
-                return jsdate.getDay();
-            },
-            z: function(){
-                return (jsdate - new Date(jsdate.getFullYear() + "/1/1")) / 
864e5 >> 0;
-            },
-
-        // Week
-            W: function(){
-                var a = f.z(), b = 364 + f.L() - a;
-                var nd2, nd = (new Date(jsdate.getFullYear() + 
"/1/1").getDay() || 7) - 1;
-
-                if(b <= 2 && ((jsdate.getDay() || 7) - 1) <= 2 - b){
-                    return 1;
-                }
-                if(a <= 2 && nd >= 4 && a >= (6 - nd)){
-                    nd2 = new Date(jsdate.getFullYear() - 1 + "/12/31");
-                    return date("W", Math.round(nd2.getTime()/1000));
-                }
-                return (1 + (nd <= 3 ? ((a + nd) / 7) : (a - (7 - nd)) / 7) >> 
0);
-            },
-
-        // Month
-            F: function(){
-                return txt_months[f.n()];
-            },
-            m: function(){
-                return pad(f.n(), 2);
-            },
-            M: function(){
-                var t = f.F();
-                return t.substr(0,3);
-            },
-            n: function(){
-                return jsdate.getMonth() + 1;
-            },
-            t: function(){
-                var n;
-                if( (n = jsdate.getMonth() + 1) == 2 ){
-                    return 28 + f.L();
-                }
-                if( n & 1 && n < 8 || !(n & 1) && n > 7 ){
-                    return 31;
-                }
-                return 30;
-            },
-
-        // Year
-            L: function(){
-                var y = f.Y();
-                return (!(y & 3) && (y % 1e2 || !(y % 4e2))) ? 1 : 0;
-            },
-            o: function(){
-                if (f.n() === 12 && f.W() === 1) {
-                    return jsdate.getFullYear()+1;
-                }
-                if (f.n() === 1 && f.W() >= 52) {
-                    return jsdate.getFullYear()-1;
-                }
-                return jsdate.getFullYear();
-            },
-            Y: function(){
-                return jsdate.getFullYear();
-            },
-            y: function(){
-                return (jsdate.getFullYear() + "").slice(2);
-            },
-
-        // Time
-            a: function(){
-                return jsdate.getHours() > 11 ? "pm" : "am";
-            },
-            A: function(){
-                return f.a().toUpperCase();
-            },
-            B: function(){
-                // peter paul koch:
-                var off = (jsdate.getTimezoneOffset() + 60)*60;
-                var theSeconds = (jsdate.getHours() * 3600) +
-                                 (jsdate.getMinutes() * 60) +
-                                  jsdate.getSeconds() + off;
-                var beat = Math.floor(theSeconds/86.4);
-                if (beat > 1000) {
-                    beat -= 1000;
-                }
-                if (beat < 0) {
-                    beat += 1000;
-                }
-                if ((String(beat)).length == 1) {
-                    beat = "00"+beat;
-                }
-                if ((String(beat)).length == 2) {
-                    beat = "0"+beat;
-                }
-                return beat;
-            },
-            g: function(){
-                return jsdate.getHours() % 12 || 12;
-            },
-            G: function(){
-                return jsdate.getHours();
-            },
-            h: function(){
-                return pad(f.g(), 2);
-            },
-            H: function(){
-                return pad(jsdate.getHours(), 2);
-            },
-            i: function(){
-                return pad(jsdate.getMinutes(), 2);
-            },
-            s: function(){
-                return pad(jsdate.getSeconds(), 2);
-            },
-            u: function(){
-                return pad(jsdate.getMilliseconds()*1000, 6);
-            },
-
-        // Timezone
-            e: function () {
-/*                var abbr='', i=0;
-                if (this.php_js && this.php_js.default_timezone) {
-                    return this.php_js.default_timezone;
-                }
-                if (!tal.length) {
-                    tal = timezone_abbreviations_list();
-                }
-                for (abbr in tal) {
-                    for (i=0; i < tal[abbr].length; i++) {
-                        if (tal[abbr][i].offset === 
-jsdate.getTimezoneOffset()*60) {
-                            return tal[abbr][i].timezone_id;
-                        }
-                    }
-                }
-*/
-                return 'UTC';
-            },
-            I: function(){
-                return _dst(jsdate);
-            },
-            O: function(){
-               var t = pad(Math.abs(jsdate.getTimezoneOffset()/60*100), 4);
-               t = (jsdate.getTimezoneOffset() > 0) ? "-"+t : "+"+t;
-               return t;
-            },
-            P: function(){
-                var O = f.O();
-                return (O.substr(0, 3) + ":" + O.substr(3, 2));
-            },
-            T: function () {
-/*                var abbr='', i=0;
-                if (!tal.length) {
-                    tal = timezone_abbreviations_list();
-                }
-                if (this.php_js && this.php_js.default_timezone) {
-                    for (abbr in tal) {
-                        for (i=0; i < tal[abbr].length; i++) {
-                            if (tal[abbr][i].timezone_id === 
this.php_js.default_timezone) {
-                                return abbr.toUpperCase();
-                            }
-                        }
-                    }
-                }
-                for (abbr in tal) {
-                    for (i=0; i < tal[abbr].length; i++) {
-                        if (tal[abbr][i].offset === 
-jsdate.getTimezoneOffset()*60) {
-                            return abbr.toUpperCase();
-                        }
-                    }
-                }
-*/
-                return 'UTC';
-            },
-            Z: function(){
-               return -jsdate.getTimezoneOffset()*60;
-            },
-
-        // Full Date/Time
-            c: function(){
-                return f.Y() + "-" + f.m() + "-" + f.d() + "T" + f.h() + ":" + 
f.i() + ":" + f.s() + f.P();
-            },
-            r: function(){
-                return f.D()+', '+f.d()+' '+f.M()+' '+f.Y()+' 
'+f.H()+':'+f.i()+':'+f.s()+' '+f.O();
-            },
-            U: function(){
-                return Math.round(jsdate.getTime()/1000);
-            }
-    };
-
-    return format.replace(/[\\]?([a-zA-Z])/g, function(t, s){
-        if( t!=s ){
-            // escaped
-            ret = s;
-        } else if( f[s] ){
-            // a date function exists
-            ret = f[s]();
-        } else{
-            // nothing special
-            ret = s;
-        }
-        return ret;
-    });
-}
-/*
-YAHOO.controller.autocompleteHelper = function(url, field, hidden, container, 
label_attr) {
-       label_attr = label_attr || 'name';
-       var myDataSource = new YAHOO.util.DataSource(url);
-       myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
-       myDataSource.connXhrMode = "queueRequests";
-       myDataSource.responseSchema = {
-               resultsList: "ResultSet.Result",
-               fields: [label_attr, 'id']
-       };
-       myDataSource.maxCacheEntries = 5; 
-       console.log(myDataSource);
-       console.log(field);
-       console.log(container);
-       var ac = new YAHOO.widget.AutoComplete(field, container, myDataSource);
-       ac.queryQuestionMark = false;
-       ac.resultTypeList = false;
-       ac.forceSelection = true;
-       console.log(ac);
-       ac.itemSelectEvent.subscribe(function(sType, aArgs) {
-               YAHOO.util.Dom.get(hidden).value = aArgs[2].id;
        });
-       return ac;
-};
-*/
+
+})();

Modified: trunk/controller/js/yahoo/controller.item.js
===================================================================
--- trunk/controller/js/yahoo/controller.item.js        2011-09-15 10:11:37 UTC 
(rev 7604)
+++ trunk/controller/js/yahoo/controller.item.js        2011-09-15 11:46:14 UTC 
(rev 7605)
@@ -2,3 +2,4 @@
  *
  */
 
+alert('dette er respons fra "controller/js/yahoo/controller.item.js"');

Modified: trunk/controller/templates/base/control_item.xsl
===================================================================
--- trunk/controller/templates/base/control_item.xsl    2011-09-15 10:11:37 UTC 
(rev 7604)
+++ trunk/controller/templates/base/control_item.xsl    2011-09-15 11:46:14 UTC 
(rev 7605)
@@ -1,6 +1,8 @@
 <!-- item  -->
-<xsl:template match="item" xmlns:php="http://php.net/xsl";>
-       <xsl:variable name="form_action"><xsl:value-of 
select="form_action"/></xsl:variable>
+
+<xsl:template match="data" xmlns:php="http://php.net/xsl";>
+
+<xsl:call-template name="yui_booking_i18n"/>
 <div class="identifier-header">
 <h1><img src="{img_go_home}" /> 
                <xsl:value-of select="php:function('lang', 'Control_item')" />




reply via email to

[Prev in Thread] Current Thread [Next in Thread]