[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [12549] class.uiasync.inc
From: |
Saul |
Subject: |
[Fmsystem-commits] [12549] class.uiasync.inc |
Date: |
Tue, 06 Jan 2015 23:32:45 +0000 |
Revision: 12549
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=12549
Author: psaul
Date: 2015-01-06 23:32:45 +0000 (Tue, 06 Jan 2015)
Log Message:
-----------
class.uiasync.inc
Modified Paths:
--------------
branches/dev-syncromind/property/inc/class.uiasync.inc.php
Modified: branches/dev-syncromind/property/inc/class.uiasync.inc.php
===================================================================
--- branches/dev-syncromind/property/inc/class.uiasync.inc.php 2015-01-06
23:32:15 UTC (rev 12548)
+++ branches/dev-syncromind/property/inc/class.uiasync.inc.php 2015-01-06
23:32:45 UTC (rev 12549)
@@ -26,14 +26,17 @@
* @subpackage admin
* @version $Id$
*/
- phpgw::import_class('phpgwapi.yui');
+ //phpgw::import_class('phpgwapi.yui');
/**
* Description
* @package property
*/
+
+ phpgw::import_class('phpgwapi.uicommon_jquery');
+ phpgw::import_class('phpgwapi.jquery');
- class property_uiasync
+ class property_uiasync extends phpgwapi_uicommon_jquery
{
var $grants;
var $start;
@@ -45,14 +48,17 @@
var $public_functions = array
(
+ 'query' => true,
'index' => true,
'view' => true,
'edit' => true,
'delete' => true
);
- function property_uiasync()
+ function __construct()
{
+ parent::__construct();
+
$GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
$GLOBALS['phpgw_info']['flags']['menu_selection'] =
'admin::property::async';
@@ -96,140 +102,74 @@
function index()
{
- $datatable = array();
-
- if( phpgw::get_var('phpgw_return_as') != 'json' )
- {
- $datatable['config']['base_url'] =
$GLOBALS['phpgw']->link('/index.php', array
- (
- 'menuaction' =>
'property.uiasync.index',
- 'order' =>
$this->order,
- 'query' => $this->query,
- 'sort' => $this->sort
- ));
-
- $datatable['config']['base_java_url'] =
"menuaction:'property.uiasync.index',"
- ."order:'{$this->order}',"
- ."query:'{$this->query}',"
- ."sort:'{$this->sort}'";
- $link_data = array
- (
- 'menuaction' =>
'property.uiasync.index',
- 'order' =>
$this->order,
- 'query' => $this->query,
- 'sort' => $this->sort
- );
-
- $datatable['config']['allow_allrows'] = true;
-
- $datatable['actions']['form'] = array
- (
- array
- (
- 'action' =>
$GLOBALS['phpgw']->link('/index.php',
- array
- (
- 'menuaction'
=> 'property.uiasync.index',
- 'order'
=> $this->order,
- 'query'
=> $this->query,
- 'sort'
=> $this->sort
- )
- ),
- 'fields' => array
- (
- 'field' => array
- (
- 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
- ( //boton
SEARCH
- 'id' =>
'btn_search',
- 'name'
=> 'search',
- 'value'
=> lang('search'),
- 'type'
=> 'button',
-
'tab_index' => 7
- ),
- array
- ( // TEXT INPUT
- 'name'
=> 'query',
- 'id'
=> 'txt_query',
- 'value'
=> '',//$query,
- 'type'
=> 'text',
-
'onkeypress' => 'return pulsar(event)',
- 'size'
=> 28,
-
'tab_index' => 6
- )
- )
- )
- )
- );
- }
-
- $method_list = $this->bo->read();
- $uicols['name'][0] = 'id';
- $uicols['descr'][0] = lang('method
ID');
- $uicols['className'][0] = 'rightClasss';
- $uicols['name'][1] = 'name';
- $uicols['descr'][1] = lang('Name');
- $uicols['name'][2] = 'data';
- $uicols['descr'][2] = lang('Data');
- $uicols['name'][3] = 'descr';
- $uicols['descr'][3] =
lang('Description');
- $uicols['name'][4] = 'url';
- $uicols['descr'][4] = lang('URL');
- $j = 0;
- $count_uicols_name = count($uicols['name']);
-
- if (isset($method_list) AND is_array($method_list))
- {
- foreach($method_list as $method_entry)
- {
- for ($k=0;$k<$count_uicols_name;$k++)
- {
-
if($uicols['input_type'][$k]!='hidden')
- {
-
$datatable['rows']['row'][$j]['column'][$k]['name'] =
$uicols['name'][$k];
-
$datatable['rows']['row'][$j]['column'][$k]['value']
= $method_entry[$uicols['name'][$k]];
- if($uicols['name'][$k]
== 'data')
- {
- $data_set =
unserialize($method_entry[$uicols['name'][$k]]);
-
$method_data=array();
- foreach
($data_set as $key => $value)
- {
-
$method_data[] = $key . '=' . $value;
- }
-
$datatable['rows']['row'][$j]['column'][$k]['name'] =
$uicols['name'][$k];
-
$datatable['rows']['row'][$j]['column'][$k]['value']
= @implode (',',$method_data);
- }
- if($uicols['name'][$k]
== 'url')
- {
-
$datatable['rows']['row'][$j]['column'][$k]['name'] =
$uicols['name'][$k];
- $run_link_data
= array();
-
$run_link_data['menuaction'] = $method_entry['name'];
-
$run_link_data['data'] = urlencode($method_entry['data']);
-
$datatable['rows']['row'][$j]['column'][$k]['value'] =
$run_link_data['menuaction']."&data=".urlencode($run_link_data['data']);
- }
- }
- }
- $j++;
- }
- }
-
- //_debug_array($datatable);die;
- $datatable['rowactions']['action'] = array();
-
+
+ if( phpgw::get_var('phpgw_return_as') == 'json' )
+ {
+ return $this->query();
+ }
+
+
self::add_javascript('phpgwapi','jquery','editable/jquery.jeditable.js');
+
self::add_javascript('phpgwapi','jquery','editable/jquery.dataTables.editable.js');
+
+ $appname = lang('method');
+ $function_msg = lang('list async method');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('property') . ' - ' . $appname . ': ' . $function_msg;
+
+ $data = array(
+ 'datatable_name' => $appname,
+ 'form' => array(
+ 'toolbar' => array(
+ 'item' => array(
+ array(
+ 'type' => 'link',
+ 'value' => lang('new'),
+ 'href' => self::link(array(
+ 'menuaction' =>
'property.uiasync.edit'
+ )),
+ 'class' => 'new_item'
+ )
+ )
+ )
+ ),
+ 'datatable' => array(
+ 'source' => self::link(array(
+ 'menuaction' => 'property.uiasync.index',
+ 'phpgw_return_as' => 'json'
+ )),
+ 'allrows' => true,
+ 'editor_action' => '',
+ 'field' => array(
+ array(
+ 'key' => 'id',
+ 'label' => lang('method ID'),
+ 'sortable' => true
+ ),
+ array(
+ 'key' => 'name',
+ 'label' => lang('Name'),
+ 'sortable' => true
+ ),
+ array(
+ 'key' => 'data',
+ 'label' => lang('Data'),
+ 'sortable' => false
+ ),
+ array(
+ 'key' => 'descr',
+ 'label' => lang('Description'),
+ 'sortable' => false
+ ),
+ array(
+ 'key' => 'url',
+ 'label' => lang('URL'),
+ 'sortable' => false,
+ 'hidden' => true
+ )
+ )
+ )
+ );
+
$parameters = array
(
'parameter' => array
@@ -267,7 +207,7 @@
);
- $datatable['rowactions']['action'][] = array
+ $data['datatable']['actions'][] = array
(
'my_name' =>
'run',
'statustext' => lang('Run Now'),
@@ -279,10 +219,10 @@
//'menuaction'
=> 'property.uiasync.edit'
)
),
- 'parameters' => $parameters
+ 'parameters' =>
json_encode($parameters)
);
- $datatable['rowactions']['action'][] = array
+ $data['datatable']['actions'][] = array
(
'my_name' =>
'schedule',
'statustext' => lang('Schedule'),
@@ -294,10 +234,10 @@
'menuaction'
=> 'property.uialarm.edit'
)
),
- 'parameters' => $parameters2
+ 'parameters' =>
json_encode($parameters2)
);
- $datatable['rowactions']['action'][] = array
+ $data['datatable']['actions'][] = array
(
'my_name' =>
'edit',
'statustext' => lang('Edit'),
@@ -309,10 +249,10 @@
'menuaction'
=> 'property.uiasync.edit'
)
),
- 'parameters' => $parameters3
+ 'parameters' =>
json_encode($parameters3)
);
- $datatable['rowactions']['action'][] = array
+ $data['datatable']['actions'][] = array
(
'my_name' =>
'delete',
'statustext' => lang('Delete'),
@@ -325,10 +265,10 @@
'menuaction'
=> 'property.uiasync.delete'
)
),
- 'parameters' => $parameters3
+ 'parameters' =>
json_encode($parameters3)
);
- $datatable['rowactions']['action'][] = array
+ /*$data['datatable']['actions'][] = array
(
'my_name' =>
'add',
'statustext' => lang('add'),
@@ -337,158 +277,49 @@
(
'menuaction' =>
'property.uiasync.edit'
))
- );
+ );*/
unset($parameters);
unset($parameters2);
unset($parameters3);
- 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]['className'] =
$uicols['className'][$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'] = false;
- if($uicols['name'][$i]=='url')
- {
-
$datatable['headers']['header'][$i]['visible'] = false;
- }
-
- if($uicols['name'][$i]=='id')
- {
-
$datatable['headers']['header'][$i]['sortable'] = true;
-
$datatable['headers']['header'][$i]['sort_field'] = 'id';
- }
-
- if($uicols['name'][$i]=='name')
- {
-
$datatable['headers']['header'][$i]['sortable'] = true;
-
$datatable['headers']['header'][$i]['sort_field'] = 'name';
- }
- }
- }
-
- //path for property.js
- $property_js = "/property/js/yahoo/property.js";
-
- if
(!isset($GLOBALS['phpgw_info']['server']['no_jscombine']) ||
!$GLOBALS['phpgw_info']['server']['no_jscombine'])
- {
- $cachedir =
urlencode($GLOBALS['phpgw_info']['server']['temp_dir']);
- $property_js =
"/phpgwapi/inc/combine.php?cachedir={$cachedir}&type=javascript&files=" .
str_replace('/', '--', ltrim($property_js,'/'));
- }
-
- $datatable['property_js'] =
$GLOBALS['phpgw_info']['server']['webserver_url'] . $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($method_list);
- $datatable['pagination']['records_total'] =
$this->bo->total_records;
-
- $appname = lang('method');
- $function_msg = lang('list async method');
-
- if ( (phpgw::get_var("start")== "") &&
(phpgw::get_var("order",'string')== ""))
- {
- $datatable['sorting']['order']
= 'id'; // name key Column in myColumnDef
- $datatable['sorting']['sort']
= 'asc'; // ASC / DESC
- }
- else
- {
- $datatable['sorting']['order']
= phpgw::get_var('order', 'string'); // name of column of Database
- $datatable['sorting']['sort']
= phpgw::get_var('sort', 'string'); // ASC / DESC
- }
-
- 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');
-
- //-- BEGIN----------------------------- JSON CODE
------------------------------
- //values for Pagination
- $json = array
- (
- '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['link']."'>"
.$column['value']."</a>";
- }
- else
- {
-
$json_row[$column['name']] = $column['value'];
- }
- }
- $json['records'][] = $json_row;
- }
- }
-
- // right in datatable
- if(isset($datatable['rowactions']['action']) &&
is_array($datatable['rowactions']['action']))
- {
- $json ['rights'] =
$datatable['rowactions']['action'];
- }
-
- if( phpgw::get_var('phpgw_return_as') == 'json' )
- {
- return $json;
- }
-
-
- $datatable['json_data'] = json_encode($json);
- //-------------------- JSON CODE ----------------------
-
- $template_vars = array();
- $template_vars['datatable'] = $datatable;
-
$GLOBALS['phpgw']->xslttpl->add_file(array('datatable'));
- $GLOBALS['phpgw']->xslttpl->set_var('phpgw',
$template_vars);
-
- if ( !isset($GLOBALS['phpgw']->css) ||
!is_object($GLOBALS['phpgw']->css) )
- {
- $GLOBALS['phpgw']->css =
createObject('phpgwapi.css');
- }
-
- $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_info']['flags']['app_header'] =
lang('property') . ' - ' . $appname . ': ' . $function_msg;
-
- $GLOBALS['phpgw']->js->validate_file( 'yahoo',
'uiasync.index', 'property' );
-
- $this->save_sessiondata();
-
+ self::render_template_xsl('datatable_jquery', $data);
}
+ public function query()
+ {
+ $search = phpgw::get_var('search');
+ $order = phpgw::get_var('order');
+ $draw = phpgw::get_var('draw', 'int');
+ $columns = phpgw::get_var('columns');
+
+ $params = array(
+ 'start' => phpgw::get_var('start', 'int', 'REQUEST', 0),
+ 'results' => phpgw::get_var('length', 'int',
'REQUEST', 0),
+ 'query' => $search['value'],
+ 'order' =>
$columns[$order[0]['column']]['data'],
+ 'sort' => $order[0]['dir'],
+ 'allrows' => phpgw::get_var('length', 'int') ==
-1
+ );
+
+ $result_objects = array();
+ $result_count = 0;
+
+ $values = $this->bo->read($params);
+
+ if( phpgw::get_var('export','bool'))
+ {
+ return $values;
+ }
+
+ $result_data = array('results' => $values);
+ $result_data['total_records'] = $this->bo->total_records;
+ $result_data['draw'] = $draw;
+
+ return $this->jquery_results($result_data);
+ }
+
function edit()
{
$id = phpgw::get_var('id', 'int');
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [12549] class.uiasync.inc,
Saul <=