[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [7561] demo: add YUI
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [7561] demo: add YUI |
Date: |
Wed, 07 Sep 2011 14:01:52 +0000 |
Revision: 7561
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7561
Author: sigurdne
Date: 2011-09-07 14:01:50 +0000 (Wed, 07 Sep 2011)
Log Message:
-----------
demo: add YUI
Modified Paths:
--------------
trunk/demo/inc/class.bodemo.inc.php
trunk/demo/inc/class.menu.inc.php
trunk/demo/inc/class.sodemo.inc.php
trunk/demo/inc/class.uidemo.inc.php
trunk/demo/templates/base/demo.xsl
Added Paths:
-----------
trunk/demo/js/
trunk/demo/js/yahoo/
trunk/demo/js/yahoo/demo.index.js
Modified: trunk/demo/inc/class.bodemo.inc.php
===================================================================
--- trunk/demo/inc/class.bodemo.inc.php 2011-09-07 13:55:04 UTC (rev 7560)
+++ trunk/demo/inc/class.bodemo.inc.php 2011-09-07 14:01:50 UTC (rev 7561)
@@ -122,9 +122,8 @@
*
* @return array Array with records.
*/
- public function read2()
+ public function read2($dry_run = false)
{
- $custom_attributes =
$this->custom->find($this->currentapp, $this->acl_location, 0, '', 'ASC',
'attrib_sort', true, true);
$lookup = array
(
'start' => $this->start,
@@ -134,13 +133,13 @@
'cat_id' => $this->cat_id,
'allrows' => $this->allrows,
'filter' => $this->filter,
- 'custom_attributes' => $custom_attributes
+ 'dry_run' => $dry_run
);
- $demo_info = $this->so->read2($lookup);
+ $values = $this->so->read2($lookup);
$this->total_records = $this->so->total_records;
$this->uicols = $this->so->uicols;
- return $demo_info;
+ return $values;
}
public function read_single($id = 0)
Modified: trunk/demo/inc/class.menu.inc.php
===================================================================
--- trunk/demo/inc/class.menu.inc.php 2011-09-07 13:55:04 UTC (rev 7560)
+++ trunk/demo/inc/class.menu.inc.php 2011-09-07 14:01:50 UTC (rev 7561)
@@ -125,8 +125,8 @@
),
'alternative' => array
(
- 'text' => lang('Alternative'),
- 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'demo.uidemo.index2', 'output' => 'html'))
+ 'text' => 'YAHOO-table',
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'demo.uidemo.index2'))
)
);
return $menus;
Modified: trunk/demo/inc/class.sodemo.inc.php
===================================================================
--- trunk/demo/inc/class.sodemo.inc.php 2011-09-07 13:55:04 UTC (rev 7560)
+++ trunk/demo/inc/class.sodemo.inc.php 2011-09-07 14:01:50 UTC (rev 7561)
@@ -49,14 +49,16 @@
function demo_sodemo($acl_location)
{
- $this->account =&
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->db =
clone($GLOBALS['phpgw']->db);
+ $this->account = &
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->db = &
$GLOBALS['phpgw']->db;
- $this->like =& $this->db->like;
- $this->join =& $this->db->join;
- $this->left_join =& $this->db->left_join;
+ $this->like = & $this->db->like;
+ $this->join = & $this->db->join;
+ $this->left_join = &
$this->db->left_join;
$this->acl_location = $acl_location;
+ $this->custom =
createObject('property.custom_fields');
+
$this->grants =
$GLOBALS['phpgw']->acl->get_grants('demo', $this->acl_location);
}
@@ -157,24 +159,25 @@
function read2($data)
{
- $db2 = clone($this->db);
+//_debug_array($data);
+ $start = isset($data['start']) &&
$data['start'] ? (int)$data['start'] : 0;
+ $query = isset($data['query']) ?
$data['query'] : '';
+ $query = isset($data['query']) ?
$data['query'] : '';
+ $sort = isset($data['sort']) ? $data['sort']
: 'DESC';
+ $order = isset($data['order']) ?
$data['order'] : '';
+ $allrows = isset($data['allrows']) ?
$data['allrows'] : '';
+ $cat_id = isset($data['cat_id']) &&
$data['cat_id'] ? (int)$data['cat_id'] : 0;
+ $filter = isset($data['filter']) ?
$data['filter'] : '';
+ $dry_run = isset($data['dry_run']) ?
$data['dry_run'] : '';
- if(is_array($data))
- {
- $start = isset($data['start']) &&
$data['start'] ? $data['start'] : 0;
- $query = isset($data['query']) ?
$data['query'] : '';
- $query = isset($data['query']) ?
$data['query'] : '';
- $sort = isset($data['sort']) ?
$data['sort'] : 'DESC';
- $order = isset($data['order']) ?
$data['order'] : '';
- $allrows = isset($data['allrows']) ?
$data['allrows'] : '';
- $cat_id = isset($data['cat_id']) &&
$data['cat_id'] ? $data['cat_id'] : 0;
- $filter = isset($data['filter']) ?
$data['filter'] : '';
- $custom_attributes =
(isset($data['custom_attributes'])?$data['custom_attributes']:'');
- }
+// $custom_attributes = $this->custom->find('demo',
$this->acl_location, 0, '', 'ASC', 'attrib_sort', true, true);
- $contacts =
CreateObject('phpgwapi.contacts');
-
$table = 'phpgw_demo_table';
+ $choice_table = 'phpgw_cust_choice';
+ $attribute_table = 'phpgw_cust_attribute';
+ $location_id =
$GLOBALS['phpgw']->locations->get_id('demo', $this->acl_location);
+ $attribute_filter = " location_id = {$location_id}";
+
$where= 'WHERE';
$filtermethod = '';
@@ -230,6 +233,13 @@
$uicols['statustext'][] = 'Demo ID';
$uicols['datatype'][] = 'I';
+ $cols_return[] = 'name';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'name';
+ $uicols['descr'][] = 'Name';
+ $uicols['statustext'][] = 'Name';
+ $uicols['datatype'][] = 'V';
+
$cols_return[] = 'entry_date';
$uicols['input_type'][] = 'text';
$uicols['name'][] = 'entry_date';
@@ -255,36 +265,55 @@
);
- $i = count($uicols['name']);
- if(isset($custom_attributes) &&
is_array($custom_attributes))
- {
- foreach($custom_attributes as $column_info)
+ $user_columns =
isset($GLOBALS['phpgw_info']['user']['preferences']['demo']['columns'])?$GLOBALS['phpgw_info']['user']['preferences']['demo']['columns']:array();
+
+ $_user_columns = array();
+ foreach ($user_columns as $user_column_id)
{
- if($column_info['list'])
+ if(ctype_digit($user_column_id))
{
- if($column_info['datatype'] ==
'link')
- {
- $uicols['input_type'][]
= 'link';
- }
- else
- {
- $uicols['input_type'][]
= 'text';
- }
- $cols_return[]
= $column_info['column_name'];
- $uicols['name'][]
= $column_info['column_name'];
- $uicols['descr'][]
= $column_info['input_text'];
- $uicols['statustext'][]
= $column_info['statustext'];
- $uicols['datatype'][$i]
= $column_info['datatype'];
- $cols_return_extra[]= array(
- 'name' =>
$column_info['column_name'],
- 'datatype' =>
$column_info['datatype'],
- 'attrib_id' =>
$column_info['id']
- );
- $i++;
+ $_user_columns[] =
$user_column_id;
}
}
- }
+ $user_column_filter = '';
+ if (isset($user_columns) AND
is_array($user_columns) AND $user_columns[0])
+ {
+ $user_column_filter = " OR
($attribute_filter AND id IN (" . implode(',',$_user_columns) .'))';
+ }
+ $this->db->query("SELECT * FROM
$attribute_table WHERE list=1 AND $attribute_filter $user_column_filter ORDER
BY group_id, attrib_sort ASC");
+
+ $i = count($uicols['name']);
+ while ($this->db->next_record())
+ {
+ $uicols['input_type'][] =
'text';
+ $uicols['name'][]
= $this->db->f('column_name');
+ $uicols['descr'][]
= $this->db->f('input_text');
+ $uicols['statustext'][] =
$this->db->f('statustext');
+ $uicols['datatype'][$i] =
$this->db->f('datatype');
+ $uicols['sortable'][$i] = true;
+ $uicols['exchange'][$i] = false;
+ $uicols['formatter'][$i] = '';
+ $uicols['classname'][$i] = '';
+
+ $uicols['cols_return_extra'][$i] = array
+ (
+ 'name' =>
$this->db->f('column_name'),
+ 'datatype' =>
$this->db->f('datatype'),
+ 'attrib_id' =>
$this->db->f('id')
+ );
+
+
+ $cols_return_extra[]= array(
+ 'name' =>
$this->db->f('column_name'),
+ 'datatype' =>
$this->db->f('datatype'),
+ 'attrib_id' =>
$this->db->f('id')
+ );
+
+ $i++;
+ }
+
+
$this->uicols = $uicols;
$sql = "SELECT COUNT(phpgw_demo_table.id) as cnt FROM
$table $filtermethod $querymethod";
@@ -292,6 +321,11 @@
$this->db->next_record();
$this->total_records = $this->db->f('cnt');
+ if($dry_run)
+ {
+ return array();
+ }
+
$sql = "SELECT * FROM $table $filtermethod $querymethod
$ordermethod";
if ( $allrows )
{
@@ -302,84 +336,28 @@
$this->db->limit_query($sql, $start, __LINE__,
__FILE__);
}
- $demo_info = '';
+ $values = array();
+ $cols_return = $uicols['name'];
- $j=0;
- $n=count($cols_return);
-
+ $dataset = array();
+ $row = 0;
while ($this->db->next_record())
{
- for ($i=0;$i<$n;$i++)
+ foreach($cols_return as $key => $field)
{
- $demo_info[$j][$cols_return[$i]] =
$this->db->f($cols_return[$i]);
- $demo_info[$j]['grants'] =
(int)$this->grants[$this->db->f('user_id')];
+ $dataset[$row][$field] = array
+ (
+ 'value' =>
$this->db->f($field),
+ 'datatype' =>
$uicols['datatype'][$key],
+ 'attrib_id' =>
$uicols['cols_return_extra'][$key]['attrib_id']
+ );
}
+ $row ++;
+ }
- for ($i=0;$i<count($cols_return_extra);$i++)
- {
- $value='';
-
$value=$this->db->f($cols_return_extra[$i]['name']);
+ $values = $this->custom->translate_value($dataset,
$location_id);
-
if(($cols_return_extra[$i]['datatype']=='R' ||
$cols_return_extra[$i]['datatype']=='LB') && $value)
- {
- $sql="SELECT value FROM
phpgw_cust_choice WHERE appname= 'demo' AND location= '{$this->acl_location}'
AND attrib_id=" .$cols_return_extra[$i]['attrib_id']. " AND id=" . $value;
- $db2->query($sql);
- $db2->next_record();
-
$demo_info[$j][$cols_return_extra[$i]['name']] = $db2->f('value');
- }
- else
if($cols_return_extra[$i]['datatype']=='AB' && $value)
- {
- $contact_data =
$contacts->read_single_entry($value,array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
-
$demo_info[$j][$cols_return_extra[$i]['name']] = $contact_data[0]['n_family']
. ', ' . $contact_data[0]['n_given'];
- }
- else
if($cols_return_extra[$i]['datatype']=='VENDOR' && $value)
- {
- $sql="SELECT org_name FROM
fm_vendor where id=$value";
- $db2->query($sql);
- $db2->next_record();
-
$demo_info[$j][$cols_return_extra[$i]['name']] = $db2->f('org_name', true);
- }
- else
if($cols_return_extra[$i]['datatype']=='CH' && $value)
- {
- $ch= unserialize($value);
-
- if (isset($ch) AND
is_array($ch))
- {
- for
($k=0;$k<count($ch);$k++)
- {
- $sql="SELECT
value FROM phpgw_cust_choice WHERE appname= '{'demo'}' AND location=
'{$this->acl_location}' AND attrib_id=" .$cols_return_extra[$i]['attrib_id']. "
AND id=" . $ch[$k];
-
$db2->query($sql);
- while
($db2->next_record())
- {
-
$ch_value[] = $db2->f('value');
- }
- }
-
$demo_info[$j][$cols_return_extra[$i]['name']] = @implode(",", $ch_value);
- unset($ch_value);
- }
- }
- else
if($cols_return_extra[$i]['datatype']=='D' && $value)
- {
-
$demo_info[$j][$cols_return_extra[$i]['name']]=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($value));
- }
- else
if($cols_return_extra[$i]['datatype']=='timestamp' && $value)
- {
-
$demo_info[$j][$cols_return_extra[$i]['name']]=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],$value);
- }
- else
if($cols_return_extra[$i]['datatype']=='user_id' && $value)
- {
-
$demo_info[$j][$cols_return_extra[$i]['name']]=
$GLOBALS['phpgw']->accounts->get($value)->__toString();
- }
- else
- {
-
$demo_info[$j][$cols_return_extra[$i]['name']]=$value;
- }
- }
-
- $j++;
- }
-//_debug_array($demo_info);
- return $demo_info;
+ return $values;
}
/**
Modified: trunk/demo/inc/class.uidemo.inc.php
===================================================================
--- trunk/demo/inc/class.uidemo.inc.php 2011-09-07 13:55:04 UTC (rev 7560)
+++ trunk/demo/inc/class.uidemo.inc.php 2011-09-07 14:01:50 UTC (rev 7561)
@@ -26,6 +26,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+ phpgw::import_class('phpgwapi.yui');
/**
* Description
* @package demo
@@ -153,6 +154,7 @@
$this->cat_id = $this->bo->cat_id;
$this->filter = $this->bo->filter;
$GLOBALS['phpgw_info']['flags']['menu_selection'] =
'demo';
+ $this->bocommon =
CreateObject('property.bocommon');
}
private function save_sessiondata()
@@ -326,171 +328,333 @@
$this->no_access();
return;
}
+ if(!$this->acl_read)
+ {
+ $this->bocommon->no_access();
+ return;
+ }
-
$GLOBALS['phpgw']->xslttpl->add_file(array('demo','nextmatchs',
-
'search_field'));
+ $receipt =
$GLOBALS['phpgw']->session->appsession('session_data', "demo_receipt");
+ $this->save_sessiondata();
- $demo_info = $this->bo->read2();
+ $datatable = array();
- $uicols = $this->bo->uicols;
-//_debug_array($uicols);
- $j=0;
+ $dry_run = false;
- if (isset($demo_info) && is_array($demo_info))
+ if( phpgw::get_var('phpgw_return_as') != 'json' )
{
- foreach($demo_info as $entry)
- {
- for
($i=0;$i<count($uicols['name']);$i++)
- {
-
if($uicols['input_type'][$i]!='hidden')
- {
-
$content[$j]['row'][$i]['value'] = $entry[$uicols['name'][$i]];
-
$content[$j]['row'][$i]['name'] = $uicols['name'][$i];
-
if($uicols['input_type'][$i]=='link')
- {
-
$content[$j]['row'][$i]['text'] = lang('link');
-
$content[$j]['row'][$i]['link'] = $entry[$uicols['name'][$i]];
-
$content[$j]['row'][$i]['target'] = '_blank';
- }
- }
- }
+ $datatable['config']['base_url'] =
$GLOBALS['phpgw']->link('/index.php', array
+ (
+ 'menuaction' => 'demo.uidemo.index2'
+ ));
- if($this->acl_read)
- {
-
$content[$j]['row'][$i]['statustext'] = lang('view the
record');
- $content[$j]['row'][$i]['text']
= lang('view');
-
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=>
'demo.uidemo.view','demo_id'=> $entry['id']));
- }
- if($this->acl_edit)
- {
-
$content[$j]['row'][$i]['statustext'] = lang('edit the
record');
- $content[$j]['row'][$i]['text']
= lang('edit');
-
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=> 'demo.uidemo.edit',
'demo_id'=> $entry['id']));
- }
- if($this->acl_delete)
- {
-
$content[$j]['row'][$i]['statustext'] = lang('delete the
record');
- $content[$j]['row'][$i]['text']
= lang('delete');
-
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=>
'demo.uidemo.delete', 'demo_id'=> $entry['id']));
- }
+ $datatable['config']['base_java_url'] =
"menuaction:'demo.uidemo.index2'";
- $j++;
- }
+ $link_data = array
+ (
+ 'menuaction' => 'demo.uidemo.index2'
+ );
+
+
+ $datatable['config']['allow_allrows'] = true;
+
+ $values_combo_box = array();
+ $values_combo_box[0] =
$this->cats->formatted_xslt_list(array('format'=>'filter','selected' =>
$this->cat_id,'globals' => true,'use_acl' => $this->_category_acl));
+ $default_value = array ('cat_id'=>'','name'=>
lang('no category'));
+ array_unshift
($values_combo_box[0]['cat_list'],$default_value);
+
+ $datatable['actions']['form'] = array
+ (
+ array
+ (
+ 'action' =>
$GLOBALS['phpgw']->link('/index.php',
+ array
+ (
+ 'menuaction'
=> 'demo.uidemo.index2'
+ )
+ ),
+ 'fields' => array
+ (
+ 'field' => array
+ (
+ array
+ ( //boton
CATEGORY
+ 'id' =>
'btn_cat_id',
+ 'name'
=> 'cat_id',
+ 'value'
=> lang('Category'),
+ 'type'
=> 'button',
+ 'style'
=> 'filter',
+
'tab_index' => 1
+ ),
+ array
+ (
+ 'type'
=> 'button',
+ 'id'
=> 'btn_export',
+ 'value'
=> lang('download'),
+
'tab_index' => 10
+ ),
+ array
+ (
+ 'type'
=> 'button',
+ 'id'
=> 'btn_done',
+ 'value'
=> lang('done'),
+
'tab_index' => 9
+ ),
+ array
+ (
+ 'type'
=> 'button',
+ 'id'
=> 'btn_new',
+ 'value'
=> lang('add'),
+
'tab_index' => 8
+ ),
+ array
+ ( //button
SEARCH
+ 'id' =>
'btn_search',
+ 'name'
=> 'search',
+ 'value'
=> lang('search'),
+ 'type'
=> 'button',
+
'tab_index' => 7
+ ),
+ array
+ ( // TEXT INPUT
+ 'name'
=> 'query',
+ 'id'
=> 'txt_query',
+ 'value'
=> $this->query,
+ 'type'
=> 'text',
+
'onkeypress' => 'return pulsar(event)',
+ 'size'
=> 28,
+
'tab_index' => 6
+ )
+ ),
+ 'hidden_value' => array
+ (
+ array
+ ( //div values
combo_box_0
+ 'id' =>
'values_combo_box_0',
+ 'value'
=> $this->bocommon->select2String($values_combo_box[0]['cat_list'], 'cat_id')
//i.e. id,value/id,vale/
+ )
+ )
+ )
+ )
+ );
+
+// $dry_run = false;
}
- for ($i=0;$i<count($uicols['descr']);$i++)
+ $values = $this->bo->read2($dry_run);
+
+ $uicols = $this->bo->uicols;
+
+ $j = 0;
+ $count_uicols_name = count($uicols['name']);
+
+ foreach($values as $entry)
{
- if($uicols['input_type'][$i]!='hidden')
+ for ($k=0;$k<$count_uicols_name;$k++)
{
- $table_header[$i]['header'] =
$uicols['descr'][$i];
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- if($uicols['datatype'][$i]!='T' &&
$uicols['datatype'][$i]!='CH')
+ if($uicols['input_type'][$k]!='hidden')
{
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatches->show_sort_order(array
- (
- 'sort' => $this->sort,
- 'var' =>
$uicols['name'][$i],
- 'order' => $this->order,
- 'extra' => array
- (
- 'menuaction'
=> 'demo.uidemo.index2',
- 'query'
=> $this->query,
- 'cat_id'
=> $this->cat_id,
- 'filter'
=> $this->filter,
- 'output'
=> $output,
- 'allrows'
=> $this->allrows
- )
- ));
+
$datatable['rows']['row'][$j]['column'][$k]['name'] =
$uicols['name'][$k];
+
$datatable['rows']['row'][$j]['column'][$k]['value'] =
$entry[$uicols['name'][$k]];
+
$datatable['rows']['row'][$j]['column'][$k]['format'] =
$uicols['datatype'][$k];
}
}
+ $j++;
}
- if($this->acl_read)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('view');
- $i++;
- }
+ $datatable['rowactions']['action'] = array();
+
+ $parameters = array
+ (
+ 'parameter' => array
+ (
+ array
+ (
+ 'name' =>
'demo_id',
+ 'source' => 'id'
+ ),
+ )
+ );
+
if($this->acl_edit)
{
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('edit');
- $i++;
+ $datatable['rowactions']['action'][] = array
+ (
+ 'my_name' =>
'edit',
+ 'statustext' => lang('edit
the entry'),
+ 'text' =>
lang('edit'),
+ 'action' =>
$GLOBALS['phpgw']->link('/index.php',array
+ (
+ 'menuaction'
=> 'demo.uidemo.edit'
+ )),
+ 'parameters' => $parameters
+ );
+ $datatable['rowactions']['action'][] = array
+ (
+ 'my_name' =>
'edit',
+ 'text' =>
lang('open edit in new window'),
+ 'action' =>
$GLOBALS['phpgw']->link('/index.php',array
+ (
+ 'menuaction'
=> 'demo.uidemo.edit',
+ 'target'
=> '_blank'
+ )),
+ 'parameters' => $parameters
+ );
}
+
if($this->acl_delete)
{
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('delete');
- $i++;
+ $datatable['rowactions']['action'][] = array
+ (
+ 'my_name' =>
'delete',
+ 'statustext' => lang('delete
the entry'),
+ 'text' =>
lang('delete'),
+ 'confirm_msg' => lang('do you
really want to delete this entry'),
+ 'action' =>
$GLOBALS['phpgw']->link('/index.php',array
+ (
+ 'menuaction' =>
'demo.uidemo.delete'
+ )),
+ 'parameters' => $parameters
+ );
}
+ unset($parameters);
-
if($this->acl_add)
{
- $table_add[] = array
+ $datatable['rowactions']['action'][] = array
+ (
+ 'my_name'
=> 'add',
+ 'statustext' => lang('add'),
+ 'text' =>
lang('add'),
+ 'action' =>
$GLOBALS['phpgw']->link('/index.php',array
+ (
+ 'menuaction' =>
'demo.uidemo.edit',
+ 'type'
=> $this->type,
+ 'type_id'
=> $this->type_id
+ ))
+ );
+ }
+
+ for ($i=0;$i<$count_uicols_name;$i++)
+ {
+ if($uicols['input_type'][$i]!='hidden')
+ {
+
$datatable['headers']['header'][$i]['formatter'] =
($uicols['formatter'][$i]==''? '""' : $uicols['formatter'][$i]);
+
$datatable['headers']['header'][$i]['name'] =
$uicols['name'][$i];
+
$datatable['headers']['header'][$i]['text'] =
$uicols['descr'][$i];
+
$datatable['headers']['header'][$i]['visible'] = true;
+
$datatable['headers']['header'][$i]['sortable'] =
$uicols['sortable'][$i];
+
$datatable['headers']['header'][$i]['sort_field'] = $uicols['name'][$i];
+ }
+ }
+
+ //path for property.js
+ $datatable['property_js'] =
$GLOBALS['phpgw_info']['server']['webserver_url']."/property/js/yahoo/property.js";
+
+ // Pagination and sort values
+ $datatable['pagination']['records_start'] =
(int)$this->bo->start;
+ $datatable['pagination']['records_limit'] =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ $datatable['pagination']['records_returned']=
count($values);
+ $datatable['pagination']['records_total'] =
$this->bo->total_records;
+
+ $appname =
$this->location_info['name'];
+ $function_msg = lang('list %1', $appname);
+
+ if ( ($this->start == 0) && (!$this->order))
+ {
+ $datatable['sorting']['order']
= $this->location_info['id']['name']; // name key Column in myColumnDef
+ $datatable['sorting']['sort']
= 'asc'; // ASC / DESC
+ }
+ else
+ {
+ $datatable['sorting']['order']
= $this->order; // name of column of Database
+ $datatable['sorting']['sort']
= $this->sort; // ASC / DESC
+ }
+
+ //-- BEGIN----------------------------- JSON CODE
------------------------------
+ //values for Pagination
+ $json = array
(
- 'lang_add'
=> lang('add'),
- 'lang_add_statustext' => lang('add a
demo'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=>
'demo.uidemo.edit','output'=>$output)),
+ 'recordsReturned' =>
$datatable['pagination']['records_returned'],
+ 'totalRecords' =>
(int)$datatable['pagination']['records_total'],
+ 'startIndex' =>
$datatable['pagination']['records_start'],
+ 'sort' =>
$datatable['sorting']['order'],
+ 'dir' =>
$datatable['sorting']['sort'],
+ 'records' =>
array()
);
+
+ // values for datatable
+ if(isset($datatable['rows']['row']) &&
is_array($datatable['rows']['row']))
+ {
+ foreach( $datatable['rows']['row'] as $row )
+ {
+ $json_row = array();
+ foreach( $row['column'] as $column)
+ {
+ if(isset($column['format']) &&
$column['format']== 'link' && $column['java_link']==true)
+ {
+
$json_row[$column['name']] = "<a href='#' id='{$column['link']}'
onclick='javascript:filter_data(this.id);'>{$column['value']}</a>";
+ }
+ else
if(isset($column['format']) && $column['format']== 'link')
+ {
+
$json_row[$column['name']] = "<a href='{$column['value']}' target='_blank'>"
.lang('link') . '</a>';
+ }
+ else
if(isset($column['format']) && $column['format']== 'text')
+ {
+
$json_row[$column['name']] = nl2br($column['value']);
+ }
+ else
+ {
+
$json_row[$column['name']] = $column['value'];
+ }
+ }
+ $json['records'][] = $json_row;
+ }
}
- if(!$this->allrows)
+ // right in datatable
+ if(isset($datatable['rowactions']['action']) &&
is_array($datatable['rowactions']['action']))
{
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ $json['rights'] =
$datatable['rowactions']['action'];
}
- else
+
+ if( phpgw::get_var('phpgw_return_as') == 'json' )
{
- $record_limit = $this->bo->total_records;
+ return $json;
}
- $link_data = array
- (
- 'menuaction' => 'demo.uidemo.index2',
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'cat_id' => $this->cat_id,
- 'filter' => $this->filter,
- 'query' => $this->query,
- 'output' => $output
- );
+ phpgwapi_yui::load_widget('dragdrop');
+ phpgwapi_yui::load_widget('datatable');
+ phpgwapi_yui::load_widget('menu');
+ phpgwapi_yui::load_widget('connection');
+ phpgwapi_yui::load_widget('loader');
+ phpgwapi_yui::load_widget('tabview');
+ phpgwapi_yui::load_widget('paginator');
+ phpgwapi_yui::load_widget('animation');
- $msgbox_data =
(isset($receipt)?$GLOBALS['phpgw']->common->msgbox_data($receipt):'');
+ $datatable['json_data'] = json_encode($json);
+ //-------------------- JSON CODE ----------------------
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'cat_filter'
=> $this->cats->formatted_xslt_list(array('select_name' =>
'cat_id','selected' => $this->cat_id,'globals' => true,'link_data' =>
$link_data)),
- 'filter_data'
=> $this->nextmatches->xslt_filter(array('filter' =>
$this->filter,'link_data' => $link_data)),
- 'allow_allrows'
=> true,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> ($demo_info?count($demo_info):0),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=>
$GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_searchfield_statustext'
=> lang('Enter the search string. To show all entries, empty this field and
press the SUBMIT button again'),
- 'lang_searchbutton_statustext'
=> lang('Submit the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header'
=> $table_header,
- 'table_add'
=> $table_add,
- 'values'
=> (isset($content)?$content:'')
- );
+ $template_vars = array();
+ $template_vars['datatable'] = $datatable;
+
$GLOBALS['phpgw']->xslttpl->add_file(array('datatable'));
+ $GLOBALS['phpgw']->xslttpl->set_var('phpgw',
$template_vars);
-//_debug_array($data);
- $function_msg= lang('list demo values');
+ if ( !isset($GLOBALS['phpgw']->css) ||
!is_object($GLOBALS['phpgw']->css) )
+ {
+ $GLOBALS['phpgw']->css =
createObject('phpgwapi.css');
+ }
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('demo'). ": {$function_msg}";
+ $GLOBALS['phpgw']->css->validate_file('datatable');
+ $GLOBALS['phpgw']->css->validate_file('property');
+
$GLOBALS['phpgw']->css->add_external_file('property/templates/base/css/property.css');
+
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/datatable/assets/skins/sam/datatable.css');
+
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/paginator/assets/skins/sam/paginator.css');
+
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/container/assets/skins/sam/container.css');
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array("list2_{$output}" => $data));
- $this->save_sessiondata();
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
$GLOBALS['phpgw']->translation->translate($this->location_info['acl_app'],
array(), false, $this->location_info['acl_app']) .
"::{$appname}::{$function_msg}";
+
+ $GLOBALS['phpgw']->js->validate_file( 'yahoo',
'demo.index', 'demo' );
}
@@ -625,6 +789,28 @@
'output' => $output
);
+ $generic_list_1 = array();
+ for ($i=1;$i<9;$i++)
+ {
+ $generic_list_1[] = array
+ (
+ 'id' => $i,
+ 'name' => "Element A {$i}"
+ );
+ }
+ $generic_list_1[2]['selected'] = 1;
+
+ $generic_list_2 = array();
+ for ($i=1;$i<4;$i++)
+ {
+ $generic_list_2[] = array
+ (
+ 'id' => $i,
+ 'name' => "Element B {$i}"
+ );
+ }
+
+
$msgbox_data =
(isset($receipt)?$GLOBALS['phpgw']->common->msgbox_data($receipt):'');
$data = array
@@ -636,35 +822,20 @@
'value_town'
=> (isset($values['town'])?$values['town']:''),
'value_remark'
=> (isset($values['remark'])?$values['remark']:''),
- 'lang_entry_date'
=> lang('Entry date'),
- 'lang_name'
=> lang('name'),
- 'lang_address'
=> lang('address'),
- 'lang_zip'
=> lang('zip'),
- 'lang_town'
=> lang('town'),
- 'lang_remark'
=> lang('remark'),
-
'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_id'
=> lang('training ID'),
- 'lang_save'
=> lang('save'),
- 'lang_cancel'
=> lang('cancel'),
'value_id'
=> $demo_id,
- 'lang_done_status_text' =>
lang('Back to the list'),
- 'lang_save_status_text' =>
lang('Save the training'),
- 'lang_apply'
=> lang('apply'),
- 'lang_apply_status_text' =>
lang('Apply the values'),
- 'lang_category'
=> lang('category'),
- 'lang_no_cat'
=> lang('no category'),
'cat_select'
=> $this->cats->formatted_xslt_list(array('select_name' =>
'values[cat_id]','selected' =>
(isset($values['cat_id'])?$values['cat_id']:''))),
'attributes_values'
=> $values['attributes'],
-
- 'lang_access'
=> lang('private'),
- 'value_access'
=> (isset($values['access'])?$values['access']:''),
- 'lang_access_off_statustext' => lang('The
note is public. If the note should be private, check this box'),
- 'lang_access_on_statustext' =>
lang('The note is private. If the note should be public, uncheck this box')
+ 'value_access'
=> isset($values['access'])?$values['access']:'',
+ 'generic_list_1'
=> array('options' => $generic_list_1),
+ 'generic_list_2'
=> array('options' => $generic_list_2),
);
+ $GLOBALS['phpgw']->richtext->replace_element('remark');
+ $GLOBALS['phpgw']->richtext->generate_script();
+
$appname = lang('demo');
$GLOBALS['phpgw_info']['flags']['app_header'] =
lang('demo') . " - {$appname}: {$function_msg}";
Added: trunk/demo/js/yahoo/demo.index.js
===================================================================
--- trunk/demo/js/yahoo/demo.index.js (rev 0)
+++ trunk/demo/js/yahoo/demo.index.js 2011-09-07 14:01:50 UTC (rev 7561)
@@ -0,0 +1,76 @@
+//--------------------------------------------------------
+// Declaration of location.index vars
+//--------------------------------------------------------
+ // define buttons
+ var oMenuButton_0;
+ var selectsButtons = [
+ {order:0,
var_URL:'cat_id',name:'btn_cat_id',style:'categorybutton',dependiente:[]}
+ ];
+
+
+ var oNormalButton_0,oNormalButton_1,oNormalButton_2,oNormalButton_3;
+ var normalButtons = [
+ {order:0, name:'btn_search', funct:"onSearchClick"},
+ {order:1, name:'btn_new', funct:"onNewClick"},
+ {order:2, name:'btn_done', funct:"onDoneClick"},
+ {order:3, name:'btn_export', funct:"onDownloadClick"}
+ ];
+
+ // define Text buttons
+ var textImput = [
+ {order:0, name:'query',id:'txt_query'}
+ ];
+
+ var toolTips =
+ [
+ {name:'btn_export', title:'download', description:'Download
table to your browser',ColumnDescription:''}
+ ]
+
+ // define the hidden column in datatable
+ var config_values =
+ {
+ date_search : 0, //if search has link "Data search"
+ particular_done : "property.uilocation.index"
+ }
+
+/********************************************************************************/
+ var FormatterRight = function(elCell, oRecord, oColumn, oData)
+ {
+ elCell.innerHTML = "<div align=\"right\">"+oData+"</div>";
+ }
+
+/****************************************************************************************/
+ this.particular_setting = function()
+ {
+ if(flag_particular_setting=='init')
+ {
+ }
+ else if(flag_particular_setting=='update')
+ {
+ }
+ }
+/****************************************************************************************/
+
+ this.myParticularRenderEvent = function()
+ {
+ //don't delete it
+ document.getElementById('txt_query').focus();
+ }
+/****************************************************************************************/
+ YAHOO.util.Event.addListener(window, "load", function()
+ {
+
YAHOO.util.Dom.getElementsByClassName('toolbar','div')[0].style.display =
'none';
+
+ var loader = new YAHOO.util.YUILoader();
+ loader.addModule({
+ name: "anyone", //module name; must be unique
+ type: "js", //can be "js" or "css"
+ fullpath: property_js //'property_js' have the path for
property.js, is render in HTML
+ });
+
+ loader.require("anyone");
+
+ //Insert JSON utility on the page
+
+ loader.insert();
+ });
Modified: trunk/demo/templates/base/demo.xsl
===================================================================
--- trunk/demo/templates/base/demo.xsl 2011-09-07 13:55:04 UTC (rev 7560)
+++ trunk/demo/templates/base/demo.xsl 2011-09-07 14:01:50 UTC (rev 7561)
@@ -284,11 +284,11 @@
<!-- add / edit -->
- <xsl:template match="edit">
+ <xsl:template match="edit" xmlns:php="http://php.net/xsl">
<div align="left">
<xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
<form method="post" action="{$form_action}">
- <table cellpadding="2" cellspacing="2" width="80%"
align="center">
+ <table cellpadding="2" cellspacing="2" width="90%"
align="center">
<xsl:choose>
<xsl:when test="msgbox_data != ''">
<tr>
@@ -301,8 +301,8 @@
<xsl:choose>
<xsl:when test="value_id != ''">
<tr>
- <td valign="top" width="30%">
- <xsl:value-of select="lang_id"/>
+ <td valign="top" width="40%">
+ <xsl:value-of
select="php:function('lang', 'id')" />
</td>
<td align="left">
<xsl:value-of
select="value_id"/>
@@ -310,7 +310,7 @@
</tr>
<tr>
<td valign="top">
- <xsl:value-of
select="lang_entry_date"/>
+ <xsl:value-of
select="php:function('lang', 'entry_date')" />
</td>
<td>
<xsl:value-of
select="value_entry_date"/>
@@ -320,7 +320,7 @@
</xsl:choose>
<tr>
<td>
- <xsl:value-of select="lang_category"/>
+ <xsl:value-of
select="php:function('lang', 'category')" />
</td>
<td>
<xsl:call-template name="categories"/>
@@ -328,64 +328,54 @@
</tr>
<tr>
<td valign="top" width="10%">
- <xsl:value-of select="lang_name"/>
+ <xsl:value-of
select="php:function('lang', 'name')" />
</td>
<td>
- <input type="text" size="60"
name="values[name]" value="{value_name}" onMouseout="window.status='';return
true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
+ <input type="text" size="60"
name="values[name]" value="{value_name}">
+ <xsl:attribute name="title">
<xsl:value-of
select="lang_name_status_text"/>
- <xsl:text>'; return
true;</xsl:text>
</xsl:attribute>
</input>
</td>
</tr>
<tr>
<td valign="top">
- <xsl:value-of select="lang_address"/>
+ <xsl:value-of
select="php:function('lang', 'address')" />
</td>
<td>
- <input type="text" size="60"
name="values[address]" value="{value_address}"
onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_address_status_text"/>
- <xsl:text>'; return
true;</xsl:text>
+ <input type="text" size="60"
name="values[address]" value="{value_address}">
+ <xsl:attribute name="title">
+ <xsl:value-of
select="lang_address_status_text"/>
</xsl:attribute>
</input>
</td>
</tr>
<tr>
<td valign="top">
- <xsl:value-of select="lang_zip"/>
+ <xsl:value-of
select="php:function('lang', 'zip')" />
</td>
<td>
- <input type="text" size="6"
name="values[zip]" value="{value_zip}" onMouseout="window.status='';return
true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_zip_status_text"/>
- <xsl:text>'; return
true;</xsl:text>
+ <input type="text" size="6"
name="values[zip]" value="{value_zip}">
+ <xsl:attribute name="title">
+ <xsl:value-of
select="lang_zip_status_text"/>
</xsl:attribute>
</input>
<xsl:value-of select="lang_town"/>
- <input type="text" size="40"
name="values[town]" value="{value_town}" onMouseout="window.status='';return
true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_town_status_text"/>
- <xsl:text>'; return
true;</xsl:text>
+ <input type="text" size="40"
name="values[town]" value="{value_town}">
+ <xsl:attribute name="title">
+ <xsl:value-of
select="lang_town_status_text"/>
</xsl:attribute>
</input>
</td>
</tr>
<tr>
<td valign="top">
- <xsl:value-of select="lang_remark"/>
+ <xsl:value-of
select="php:function('lang', 'remark')" />
</td>
<td>
- <textarea cols="60" rows="10"
name="values[remark]" wrap="virtual" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_remark_status_text"/>
- <xsl:text>'; return
true;</xsl:text>
+ <textarea cols="60" rows="10"
name="values[remark]" id="remark" wrap="virtual">
+ <xsl:attribute name="title">
+ <xsl:value-of
select="lang_remark_status_text"/>
</xsl:attribute>
<xsl:value-of
select="value_remark"/>
</textarea>
@@ -402,25 +392,21 @@
</xsl:choose>
<tr>
<td>
- <xsl:value-of select="lang_access"/>
+ <xsl:value-of
select="php:function('lang', 'private')" />
</td>
<td>
<xsl:choose>
<xsl:when
test="value_access = 'private'">
- <input
type="checkbox" name="values[access]" value="True" checked="checked"
onMouseout="window.status='';return true;">
-
<xsl:attribute name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
-
<xsl:value-of select="lang_access_on_statustext"/>
-
<xsl:text>'; return true;</xsl:text>
+ <input
type="checkbox" name="values[access]" value="True" checked="checked">
+
<xsl:attribute name="title">
+
<xsl:value-of select="php:function('lang', 'The note is private. If the note
should be public, uncheck this box')" />
</xsl:attribute>
</input>
</xsl:when>
<xsl:otherwise>
- <input
type="checkbox" name="values[access]" value="True"
onMouseout="window.status='';return true;">
-
<xsl:attribute name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
-
<xsl:value-of select="lang_access_off_statustext"/>
-
<xsl:text>'; return true;</xsl:text>
+ <input
type="checkbox" name="values[access]" value="True">
+
<xsl:attribute name="title">
+
<xsl:value-of select="php:function('lang', 'The note is public. If the note
should be private, check this box')" />
</xsl:attribute>
</input>
</xsl:otherwise>
@@ -428,35 +414,64 @@
</td>
</tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of
select="php:function('lang', 'generic list 1')" />
+ </td>
+ <td>
+ <select name="values[generic_list_1]" >
+ <xsl:attribute name="title">
+ <xsl:value-of
select="php:function('lang', 'Set a value')" />
+ </xsl:attribute>
+ <option value="0">
+ <xsl:value-of
select="php:function('lang', 'Set a value')" />
+ </option>
+ <xsl:apply-templates
select="generic_list_1/options"/>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of
select="php:function('lang', 'generic list 2')" />
+ </td>
+ <td>
+ <select name="values[generic_list_2]" >
+ <xsl:attribute name="title">
+ <xsl:value-of
select="php:function('lang', 'Set a value')" />
+ </xsl:attribute>
+ <option value="0">
+ <xsl:value-of
select="php:function('lang', 'Set a value')" />
+ </option>
+ <xsl:apply-templates
select="generic_list_2/options"/>
+ </select>
+ </td>
+ </tr>
+
+
<tr height="50">
<td colspan = "2" align = "center"><table><tr>
<td valign="bottom">
- <xsl:variable
name="lang_save"><xsl:value-of select="lang_save"/></xsl:variable>
- <input type="submit"
name="values[save]" value="{$lang_save}" onMouseout="window.status='';return
true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_save_status_text"/>
- <xsl:text>'; return
true;</xsl:text>
+ <xsl:variable
name="lang_save"><xsl:value-of select="php:function('lang', 'save')"
/></xsl:variable>
+ <input type="submit"
name="values[save]" value="{$lang_save}">
+ <xsl:attribute name="title">
+ <xsl:value-of
select="php:function('lang', 'save')" />
</xsl:attribute>
</input>
</td>
<td valign="bottom">
- <xsl:variable
name="lang_apply"><xsl:value-of select="lang_apply"/></xsl:variable>
- <input type="submit"
name="values[apply]" value="{$lang_apply}" onMouseout="window.status='';return
true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_apply_status_text"/>
- <xsl:text>'; return
true;</xsl:text>
+ <xsl:variable
name="lang_apply"><xsl:value-of select="php:function('lang', 'apply')"
/></xsl:variable>
+ <input type="submit"
name="values[apply]" value="{$lang_apply}">
+ <xsl:attribute name="title">
+ <xsl:value-of
select="php:function('lang', 'apply the values')" />
</xsl:attribute>
</input>
</td>
<td align="left" valign="bottom">
- <xsl:variable
name="lang_cancel"><xsl:value-of select="lang_cancel"/></xsl:variable>
- <input type="submit"
name="values[cancel]" value="{$lang_cancel}"
onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_cancel_status_text"/>
- <xsl:text>'; return
true;</xsl:text>
+ <xsl:variable
name="lang_cancel"><xsl:value-of select="php:function('lang', 'cancel')"
/></xsl:variable>
+ <input type="submit"
name="values[cancel]" value="{$lang_cancel}">
+ <xsl:attribute name="title">
+ <xsl:value-of
select="php:function('lang', 'Back to the list')" />
</xsl:attribute>
</input>
</td>
@@ -558,7 +573,7 @@
<tr height="50">
<td align="left" valign="bottom">
<xsl:variable
name="lang_cancel"><xsl:value-of select="lang_cancel"/></xsl:variable>
- <input type="submit"
name="values[cancel]" value="{$lang_cancel}"
onMouseout="window.status='';return true;">
+ <input type="submit"
name="values[cancel]" value="{$lang_cancel}">
<xsl:attribute
name="onMouseover">
<xsl:text>window.status='</xsl:text>
<xsl:value-of
select="lang_cancel_status_text"/>
@@ -571,3 +586,14 @@
</form>
</div>
</xsl:template>
+
+
+ <xsl:template match="options">
+ <option value="{id}">
+ <xsl:if test="selected != 0">
+ <xsl:attribute name="selected" value="selected"
/>
+ </xsl:if>
+ <xsl:value-of disable-output-escaping="yes"
select="name"/>
+ </option>
+ </xsl:template>
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [7561] demo: add YUI,
Sigurd Nes <=