fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [13637] manual: convert to jquery


From: Sigurd Nes
Subject: [Fmsystem-commits] [13637] manual: convert to jquery
Date: Mon, 13 Jul 2015 11:41:51 +0000

Revision: 13637
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=13637
Author:   sigurdne
Date:     2015-07-13 11:41:46 +0000 (Mon, 13 Jul 2015)
Log Message:
-----------
manual: convert to jquery

Modified Paths:
--------------
    branches/dev-syncromind/manual/inc/class.uidocuments.inc.php
    branches/dev-syncromind/manual/js/portico/documents.add.js
    branches/dev-syncromind/manual/js/portico/documents.view.js
    branches/dev-syncromind/manual/templates/base/documents_add.xsl

Modified: branches/dev-syncromind/manual/inc/class.uidocuments.inc.php
===================================================================
--- branches/dev-syncromind/manual/inc/class.uidocuments.inc.php        
2015-07-12 13:36:10 UTC (rev 13636)
+++ branches/dev-syncromind/manual/inc/class.uidocuments.inc.php        
2015-07-13 11:41:46 UTC (rev 13637)
@@ -1,5 +1,4 @@
 <?php
-
        /**
         * phpGroupWare - property: a part of a Facilities Management System.
         *
@@ -27,72 +26,51 @@
         * @subpackage logistic
         * @version $Id$
         */
-       phpgw::import_class('phpgwapi.uicommon');
+       phpgw::import_class('phpgwapi.uicommon_jquery');
        phpgw::import_class('phpgwapi.jquery');
 
-       class manual_uidocuments extends phpgwapi_uicommon
+       class manual_uidocuments extends phpgwapi_uicommon_jquery
        {
 
-               private $bo;
-               private $receipt = array();
-               public $public_functions = array
-               (
-                       'query'                                         => true,
-                       'index'                                         => true,
-                       'view'                                          => true,
-                       'add'                                           => true,
-                       'edit'                                          => true,
-                       'save'                                          => true,
-                       'get_files'                                     => true,
-                       'view_file'                                     => true,
+               private
+                       $bocommon,
+                       $acl_location,
+                       $acl_read,
+                       $acl_add,
+                       $acl_edit,
+                       $acl_delete,
+                       $acl_manage,
+                       $receipt = array();
+
+               public
+                       $public_functions = array
+                       (
+                       'index'          => true,
+                       'view'           => true,
+                       'add'            => true,
+                       'edit'           => true,
+                       'save'           => true,
+                       'get_files'      => true,
+                       'view_file'      => true,
                );
 
                public function __construct()
                {
                        parent::__construct();
 
-                       $this->bo                                       = 
CreateObject('property.bocondition_survey');
-                       $this->bocommon                         = & 
$this->bo->bocommon;
-                       $this->acl                                      = & 
$GLOBALS['phpgw']->acl;
-                       $this->acl_location                     = '.documents';
-                       $this->acl_read                         = 
$this->acl->check($this->acl_location, PHPGW_ACL_READ, 'manual');
-                       $this->acl_add                          = 
$this->acl->check($this->acl_location, PHPGW_ACL_ADD, 'manual');
-                       $this->acl_edit                         = 
$this->acl->check($this->acl_location, PHPGW_ACL_EDIT, 'manual');
-                       $this->acl_delete                       = 
$this->acl->check($this->acl_location, PHPGW_ACL_DELETE, 'manual');
-                       $this->acl_manage                       = 
$this->acl->check($this->acl_location, 16, 'manual');
+                       $acl                             = & 
$GLOBALS['phpgw']->acl;
+                       $this->acl_location      = '.documents';
+                       $this->acl_read          = 
$acl->check($this->acl_location, PHPGW_ACL_READ, 'manual');
+                       $this->acl_add           = 
$acl->check($this->acl_location, PHPGW_ACL_ADD, 'manual');
+                       $this->acl_edit          = 
$acl->check($this->acl_location, PHPGW_ACL_EDIT, 'manual');
+                       $this->acl_delete        = 
$acl->check($this->acl_location, PHPGW_ACL_DELETE, 'manual');
+                       $this->acl_manage        = 
$acl->check($this->acl_location, 16, 'manual');
 
+                       $this->bocommon                         = 
CreateObject('property.bocommon');
+
                        $GLOBALS['phpgw_info']['flags']['menu_selection'] = 
"manual";
                }
 
-
-               public function download()
-               {
-                       if(!$this->acl_read)
-                       {
-                               $this->bocommon->no_access();
-                               return;
-                       }
-
-                       $values = $this->query();
-
-                       $descr = array();
-                       $columns = array();
-                       $columns[]      = 'id';
-                       $columns[]      = 'title';
-                       $columns[]      = 'descr';
-                       $columns[]      = 'address';
-                       $columns[]      = 'cnt';
-
-                       foreach($columns as $_column)
-                       {
-                               $descr[] = lang(str_replace('_', ' ', 
$_column));
-                       }
-
-                       $this->bocommon->download($values,$columns,$descr);
-
-               }
-
-
                public function index()
                {
                        if(!$this->acl_read)
@@ -100,227 +78,14 @@
                                $this->bocommon->no_access();
                                return;
                        }
-
-                       if (phpgw::get_var('phpgw_return_as') == 'json')
-                       {
-                               return $this->query();
-                       }
-
-                       self::add_javascript('phpgwapi', 'yahoo', 
'datatable.js');
-                       phpgwapi_yui::load_widget('datatable');
-                       phpgwapi_yui::load_widget('paginator');
-
-                       $categories = $this->_get_categories();
-
-
-                       $data = array(
-                               'datatable_name'        => lang('condition 
survey'),
-                               'form' => array(
-                                       'toolbar' => array(
-                                               'item' => array(
-                                                       array('type' => 
'filter',
-                                                               'name' => 
'cat_id',
-                                                               'text' => 
lang('category') . ':',
-                                                               'list' => 
$categories,
-                                                       ),
-                                                       array('type' => 'text',
-                                                               'text' => 
lang('search'),
-                                                               'name' => 
'query'
-                                                       ),
-                                                       array(
-                                                               'type' => 
'submit',
-                                                               'name' => 
'search',
-                                                               'value' => 
lang('Search')
-                                                       ),
-                                                       array(
-                                                               'type' => 
'link',
-                                                               'value' => 
lang('new'),
-                                                               'href' => 
self::link(array('menuaction' => 'property.uicondition_survey.add')),
-                                                               'class' => 
'new_item'
-                                                       ),
-                                                       array(
-                                                               'type' => 
'link',
-                                                               'value' => 
lang('download'),
-                                                               'href' => 
'javascript:window.open("'. self::link(array('menuaction' => 
'property.uicondition_survey.download', 'export' => true, 'allrows' => true)) . 
'","window")',
-                                                               'class' => 
'new_item'
-                                                       ),
-                                                       array(
-                                                               'type' => 
'link',
-                                                               'value' => 
$_SESSION['allrows'] ? lang('Show only active') : lang('Show all'),
-                                                               'href' => 
self::link(array('menuaction' => 'property.uicondition_survey.index', 'allrows' 
=> true))
-                                                       ),
-
-                                               ),
-                                       ),
-                               ),
-                               'datatable' => array(
-                                       'source' => 
self::link(array('menuaction' => 'property.uicondition_survey.index', 
'phpgw_return_as' => 'json')),
-                                       'editor_action' => 
'property.uicondition_survey.edit_survey_title',
-                                       'field' => array(
-                                               array(
-                                                       'key' => 'id',
-                                                       'label' => lang('ID'),
-                                                       'sortable' => true,
-                                                       'formatter' => 
'YAHOO.portico.formatLink'
-                                               ),
-               /*                              array(
-                                                       'key' => 'title',
-                                                       'label' => 
lang('title'),
-                                                       'sortable' => true,
-                                                       'editor' => 'new 
YAHOO.widget.TextboxCellEditor({disableBtns:false})'
-                                               ),
-                                               array(
-                                                       'key' => 'descr',
-                                                       'label' => 
lang('description'),
-                                                       'sortable' => false,
-                                               ),*/
-                                               array(
-                                                       'key' => 'address',
-                                                       'label' => 
lang('buildingname'),
-                                                       'sortable' => true
-                                               ),
-                                               array(
-                                                       'key' => 'vendor',
-                                                       'label' => 
lang('vendor'),
-                                                       'sortable' => true
-                                               ),
-                                               array(
-                                                       'key' => 'year',
-                                                       'label' => lang('year'),
-                                                       'sortable' => true,
-                                               ),
-                                               array(
-                                                       'key' => 'multiplier',
-                                                       'label' => 
lang('multiplier'),
-                                                       'sortable' => false,
-                                               ),
-                                               array(
-                                                       'key' => 'cnt',
-                                                       'label' => 
lang('count'),
-                                                       'sortable' => false,
-                                               ),
-                                               array(
-                                                       'key' => 'link',
-                                                       'hidden' => true
-                                               )
-                                       )
-                               ),
-                       );
-
-                       $parameters = array
-                               (
-                                       'parameter' => array
-                                       (
-                                               array
-                                               (
-                                                       'name'          => 'id',
-                                                       'source'        => 'id'
-                                               ),
-                                       )
-                               );
-
-                       $data['datatable']['actions'][] = array
-                                       (
-                                               'my_name'               => 
'view_survey',
-                                               'text'                  => 
lang('view'),
-                                               'action'                => 
$GLOBALS['phpgw']->link('/index.php',array
-                                               (
-                                                       'menuaction'    => 
'property.uicondition_survey.view'
-                                               )),
-                                               'parameters'    => 
json_encode($parameters)
-                                       );
-
-                       $data['datatable']['actions'][] = array
-                                       (
-                                               'my_name'               => 
'edit_survey',
-                                               'text'                  => 
lang('edit'),
-                                               'action'                => 
$GLOBALS['phpgw']->link('/index.php',array
-                                               (
-                                                       'menuaction'    => 
'property.uicondition_survey.edit'
-                                               )),
-                                               'parameters'    => 
json_encode($parameters)
-                                       );
-
-                       $data['datatable']['actions'][] = array
-                                       (
-                                               'my_name'               => 
'import_survey',
-                                               'text'                  => 
lang('import'),
-                                               'action'                => 
$GLOBALS['phpgw']->link('/index.php',array
-                                               (
-                                                       'menuaction'    => 
'property.uicondition_survey.import'
-                                               )),
-                                               'parameters'    => 
json_encode($parameters)
-                                       );
-
-
-                       if($GLOBALS['phpgw']->acl->check('.admin', 
PHPGW_ACL_DELETE, 'property'))
-                       {
-                               $data['datatable']['actions'][] = array
-                                       (
-                                               'my_name'               => 
'delete_imported_records',
-                                               'text'                  => 
lang('delete imported records'),
-                                               'confirm_msg'   => lang('do you 
really want to delete this entry') . '?',
-                                               'action'                => 
$GLOBALS['phpgw']->link('/index.php',array
-                                               (
-                                                       'menuaction'    => 
'property.uicondition_survey.delete_imported_records'
-                                               )),
-                                               'parameters'    => 
json_encode($parameters)
-                                       );
-                       }
-
-                       if($GLOBALS['phpgw']->acl->check('.admin', 
PHPGW_ACL_DELETE, 'property'))
-                       {
-                               $data['datatable']['actions'][] = array
-                                       (
-                                               'my_name'               => 
'delete_survey',
-                                               'text'                  => 
lang('delete'),
-                                               'confirm_msg'   => lang('do you 
really want to delete this entry') . '?',
-                                               'action'                => 
$GLOBALS['phpgw']->link('/index.php',array
-                                               (
-                                                       'menuaction'    => 
'property.uicondition_survey.delete'
-                                               )),
-                                               'parameters'    => 
json_encode($parameters)
-                                       );
-                       }
-
-                       self::render_template_xsl('datatable_common', $data);
+                       $this->edit(null, $mode = 'view');
                }
 
-
                public function query()
                {
-                       $params = array(
-                               'start' => phpgw::get_var('startIndex', 'int', 
'REQUEST', 0),
-                               'results' => phpgw::get_var('results', 'int', 
'REQUEST', 0),
-                               'query' => phpgw::get_var('query'),
-                               'sort' => phpgw::get_var('sort'),
-                               'dir' => phpgw::get_var('dir'),
-                               'cat_id' => phpgw::get_var('cat_id', 'int', 
'REQUEST', 0),
-                               'allrows' => phpgw::get_var('allrows', 'bool')
-                       );
-
-                       $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['start'] = $params['start'];
-                       $result_data['sort'] = $params['sort'];
-                       $result_data['dir'] = $params['dir'];
-
-                       array_walk(     $result_data['results'], array($this, 
'_add_links'), "property.uicondition_survey.view" );
-
-                       return $this->yui_results($result_data);
+                       
                }
 
-
                public function view()
                {
                        if(!$this->acl_read)
@@ -338,14 +103,13 @@
                }
 
                /**
-               * Prepare data for view and edit - depending on mode
-               *
-               * @param int    $cat_id  type of documents
-               * @param string $mode    edit or view
-               *
-               * @return void
-               */
-
+                * Prepare data for view and edit - depending on mode
+                *
+                * @param int    $cat_id  type of documents
+                * @param string $mode    edit or view
+                *
+                * @return void
+                */
                public function edit($cat_id = 0, $mode = 'edit')
                {
                        if(!$cat_id)
@@ -355,13 +119,14 @@
 
                        if(!$this->acl_add && !$this->acl_edit)
                        {
-                               
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'manual.uidocuments.view', 'cat_id'=> $cat_id));
+                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'manual.uidocuments.view',
+                                       'cat_id' => $cat_id));
                        }
 
                        if($mode == 'view')
                        {
                                
$GLOBALS['phpgw_info']['flags']['menu_selection'] = "manual::view";
-                               if( !$this->acl_read)
+                               if(!$this->acl_read)
                                {
                                        $this->bocommon->no_access();
                                        return;
@@ -382,66 +147,72 @@
                        $msgbox_data = 
$this->bocommon->msgbox_data($this->receipt);
 
                        $file_def = array
-                       (
-                               array('key' => 
'file_name','label'=>lang('Filename'),'sortable'=>false,'resizeable'=>true),
+                               (
+                               array('key' => 'file_name', 'label' => 
lang('Filename'), 'sortable' => false),
                        );
                        if($mode == 'edit')
                        {
-                               $file_def[1]= array('key' => 
'delete_file','label'=>lang('Delete 
file'),'sortable'=>false,'resizeable'=>true);
+                               $file_def[1] = array('key' => 'delete_file', 
'label' => lang('Delete file'),
+                                       'sortable' => false, 'className' => 
'center');
                        }
 
-                       $datatable_def = array();
+                       $datatable_def   = array();
                        $datatable_def[] = array
-                       (
-                               'container'             => 
'datatable-container_0',
-                               'requestUrl'    => 
json_encode(self::link(array('menuaction' => 'manual.uidocuments.get_files', 
'cat_id' => $cat_id,'phpgw_return_as'=>'json'))),
-                               'ColumnDefs'    => $file_def,
-
+                               (
+                               'container'      => 'datatable-container_0',
+                               'requestUrl' => 
json_encode(self::link(array('menuaction' => 'manual.uidocuments.get_files',
+                                       'cat_id' => $cat_id, 'phpgw_return_as' 
=> 'json'))),
+                               'ColumnDefs' => $file_def,
+                               'config'         => array(
+                                       array('disableFilter' => true),
+                                       array('disablePagination' => true)
+                               )
                        );
 
+                       $tabs                    = array();
+                       $tabs['generic'] = array('label' => lang('documents'), 
'link' => '#documents');
+                       $active_tab              = 'generic';
+
                        $data = array
-                       (
-                               'datatable_def'                                 
=> $datatable_def,
-                               'msgbox_data'                                   
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
-                               'categories'                                    
=> array('options' => $categories),
-                               'editable'                                      
        => $mode == 'edit',
-                               'multiple_uploader'                             
=> $mode == 'edit' ? true : '',
+                               (
+                               'datatable_def'          => $datatable_def,
+                               'msgbox_data'            => 
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
+                               'categories'             => array('options' => 
$categories),
+                               'editable'                       => $mode == 
'edit',
+                               'multiple_uploader'      => $mode == 'edit' ? 
true : '',
+                               'tabs'                           => 
phpgwapi_jquery::tabview_generate($tabs, $active_tab),
                        );
 
                        $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('manual') . '::' . lang('documents');
 
                        if($mode == 'edit')
                        {
-                               phpgwapi_jquery::load_widget('core');
-                               self::add_javascript('phpgwapi', 'yui3', 
'yui/yui-min.js');
-                               self::add_javascript('phpgwapi', 
'yui3-gallery', 'gallery-formvalidator/gallery-formvalidator-min.js');
+                               
phpgwapi_jquery::formvalidator_generate(array('location', 'date', 'security',
+                                       'file'));
                                
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yui3-gallery/gallery-formvalidator/validatorCss.css');
-                               self::add_javascript('phpgwapi', 'tinybox2', 
'packed.js');      
+                               self::add_javascript('phpgwapi', 'tinybox2', 
'packed.js');
                                
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/tinybox2/style.css');
                                self::add_javascript('manual', 'portico', 
'documents.add.js');
                        }
 
                        self::add_javascript('manual', 'portico', 
'documents.view.js');
 
-//                     $GLOBALS['phpgw_info']['server']['no_jscombine'] = true;
 
-                       self::render_template_xsl(array('documents_add'), 
$data);
+                       self::render_template_xsl(array('documents_add', 
'datatable_inline'), $data);
                }
 
-
                /**
-               * Saves an entry to the database for new/edit - redirects to 
view
-               *
-               * @param int  $id  entity id - no id means 'new'
-               *
-               * @return void
-               */
-
+                * Saves an entry to the database for new/edit - redirects to 
view
+                *
+                * @param int  $id  entity id - no id means 'new'
+                *
+                * @return void
+                */
                public function save()
                {
                        $cat_id = phpgw::get_var('cat_id', 'int');
 
-                       if( !$cat_id )
+                       if(!$cat_id)
                        {
                                $this->edit();
                        }
@@ -451,35 +222,34 @@
                                {
                                        $this->_handle_files($cat_id);
                                }
-
                                catch(Exception $e)
                                {
-                                       if ( $e )
+                                       if($e)
                                        {
-                                               
phpgwapi_cache::message_set($e->getMessage(), 'error'); 
-                                               $this->edit( $values );
+                                               
phpgwapi_cache::message_set($e->getMessage(), 'error');
+                                               $this->edit($values);
                                                return;
                                        }
                                }
 
-                               phpgwapi_cache::message_set('ok!', 'message'); 
-                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'manual.uidocuments.edit', 'cat_id' => $cat_id));
+                               phpgwapi_cache::message_set('ok!', 'message');
+                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'manual.uidocuments.edit',
+                                       'cat_id' => $cat_id));
                        }
                }
 
                /**
-               * Fetch a list of files to be displayed in view/edit
-               *
-               * @param int  $id  entity id
-               *
-               * @return array $ResultSet json resultset
-               */
-
+                * Fetch a list of files to be displayed in view/edit
+                *
+                * @param int  $id  entity id
+                *
+                * @return array $ResultSet json resultset
+                */
                public function get_files()
                {
-                       $cat_id         = phpgw::get_var('cat_id', 'int', 
'REQUEST');
+                       $cat_id = phpgw::get_var('cat_id', 'int', 'REQUEST');
 
-                       if( !$this->acl_read)
+                       if(!$this->acl_read)
                        {
                                return;
                        }
@@ -487,40 +257,40 @@
                        $cat_filter = array();
                        if($cat_id)
                        {
-                               $cats   = CreateObject('phpgwapi.categories', 
-1, 'manual', $this->acl_location);
-                               $cats->supress_info     = true;
-                               $cat_list_files = $cats->return_sorted_array(0, 
false, '', '', '', false, $cat_id, false);
-                               $cat_filter[] = $cat_id;
-                               foreach ($cat_list_files as $_category)
+                               $cats                            = 
CreateObject('phpgwapi.categories', -1, 'manual', $this->acl_location);
+                               $cats->supress_info      = true;
+                               $cat_list_files          = 
$cats->return_sorted_array(0, false, '', '', '', false, $cat_id, false);
+                               $cat_filter[]            = $cat_id;
+                               foreach($cat_list_files as $_category)
                                {
                                        $cat_filter[] = $_category['id'];
                                }
                        }
 
                        $link_file_data = array
-                       (
-                               'menuaction'    => 
'manual.uidocuments.view_file'
+                               (
+                               'menuaction' => 'manual.uidocuments.view_file'
                        );
 
                        $files = array();
 
                        $link_view_file = self::link($link_file_data);
 
-                       $vfs = CreateObject('phpgwapi.vfs');
-                       $vfs->override_acl = 1;
+                       $vfs                             = 
CreateObject('phpgwapi.vfs');
+                       $vfs->override_acl       = 1;
 
-                       foreach ($cat_filter as $_cat_id)
+                       foreach($cat_filter as $_cat_id)
                        {
                                $_files = $vfs->ls(array(
-                                       'string' => "/manual/{$_cat_id}",
-                                       'relatives' => array(RELATIVE_NONE)));
-                                       
-                               foreach ($_files as &$_file)
+                                       'string'         => 
"/manual/{$_cat_id}",
+                                       'relatives'      => 
array(RELATIVE_NONE)));
+
+                               foreach($_files as &$_file)
                                {
                                        $_file['path'] = 
"{$_cat_id}/{$_file['name']}";
                                }
-                                       
-                               $files = array_merge($files,$_files);
+
+                               $files = array_merge($files, $_files);
                        }
 
                        $vfs->override_acl = 0;
@@ -528,10 +298,10 @@
 
 //------ Start pagination
 
-                       $start = phpgw::get_var('startIndex', 'int', 'REQUEST', 
0);
-                       $total_records = count($files);
+                       $start                   = phpgw::get_var('startIndex', 
'int', 'REQUEST', 0);
+                       $total_records   = count($files);
 
-                       $num_rows = 
isset($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']) && 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] ? (int) 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] : 15;
+                       $num_rows = 
isset($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']) && 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] ? 
(int)$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] : 15;
 
                        if($allrows)
                        {
@@ -539,53 +309,43 @@
                        }
                        else
                        {
-                       //      $page = ceil( ( $start / $total_records ) * 
($total_records/ $num_rows) );
-                               $page = ceil( ( $start / $num_rows) );
-                               $files_part = array_chunk($files, $num_rows);
-                               $out = $files_part[$page];
+                               //      $page = ceil( ( $start / $total_records 
) * ($total_records/ $num_rows) );
+                               $page            = ceil(( $start / $num_rows));
+                               $files_part      = array_chunk($files, 
$num_rows);
+                               $out             = $files_part[$page];
                        }
 
 //------ End pagination
 
 
-                       $lang_view = lang('click to view file');
+                       $lang_view       = lang('click to view file');
                        $lang_delete = lang('click to delete file');
 
                        $values = array();
-                       foreach($out as $_entry )
+                       foreach($out as $_entry)
                        {
                                $values[] = array
-                               (
-                                       'file_name' => "<a 
href='{$link_view_file}&amp;file_name={$_entry['path']}' target='_blank' 
title='{$lang_view}'>{$_entry['name']}</a>",
-                                       'delete_file' => "<input 
type='checkbox' name='file_action[]' value='{$_entry['name']}' 
title='$lang_delete'>",
+                                       (
+                                       'file_name'              => "<a 
href='{$link_view_file}&amp;file_name={$_entry['path']}' target='_blank' 
title='{$lang_view}'>{$_entry['name']}</a>",
+                                       'delete_file'    => "<input 
type='checkbox' name='file_action[]' value='{$_entry['name']}' 
title='$lang_delete'>",
                                );
                        }
 
-                       $data = array(
-                                'ResultSet' => array(
-                                       'totalResultsAvailable' => 
$total_records,
-                                       'startIndex' => $start,
-                                       'sortKey' => 'file_name', 
-                                       'sortDir' => "ASC", 
-                                       'Result' => $values,
-                                       'pageSize' => $num_rows,
-                                       'activePage' => floor($start / 
$num_rows) + 1
-                               )
+                       return array(
+                               'recordsTotal'           => $total_records,
+                               'recordsFiltered'        => $total_records,
+                               'draw'                           => 
phpgw::get_var('draw', 'int'),
+                               'data'                           => $values,
                        );
-                       return $data;
-
                }
 
-
-
                /**
-               * Dowloads a single file to the browser
-               *
-               * @param int  $id  entity id
-               *
-               * @return file
-               */
-
+                * Dowloads a single file to the browser
+                *
+                * @param int  $id  entity id
+                *
+                * @return file
+                */
                function view_file()
                {
                        if(!$this->acl_read)
@@ -593,21 +353,20 @@
                                return lang('no access');
                        }
 
-                       $bofiles        = CreateObject('property.bofiles', 
'/manual');
+                       $bofiles = CreateObject('property.bofiles', '/manual');
 
-                       $file_name      = 
html_entity_decode(urldecode(phpgw::get_var('file_name')));
-                       $file           = "{$bofiles->fakebase}/{$file_name}";
-                       $bofiles->view_file('',$file);
+                       $file_name       = 
html_entity_decode(urldecode(phpgw::get_var('file_name')));
+                       $file            = "{$bofiles->fakebase}/{$file_name}";
+                       $bofiles->view_file('', $file);
                }
 
-
                /**
-               * Store and / or delete files related to an entity
-               *
-               * @param int  $cat_id  entity id
-               *
-               * @return void
-               */
+                * Store and / or delete files related to an entity
+                *
+                * @param int  $cat_id  entity id
+                *
+                * @return void
+                */
                private function _handle_files($cat_id)
                {
                        $cat_id = (int)$cat_id;
@@ -615,13 +374,13 @@
                        {
                                throw new 
Exception('uidocuments::_handle_files() - missing cat_id');
                        }
-                       $bofiles        = CreateObject('property.bofiles', 
'/manual');
+                       $bofiles = CreateObject('property.bofiles', '/manual');
 
                        if(isset($_POST['file_action']) && 
is_array($_POST['file_action']))
                        {
                                $bofiles->delete_file("/{$cat_id}/", 
array('file_action' => $_POST['file_action']));
                        }
-                       $file_name=str_replace(' ','_',$_FILES['file']['name']);
+                       $file_name = str_replace(' ', '_', 
$_FILES['file']['name']);
 
                        if($file_name)
                        {
@@ -633,43 +392,43 @@
 
                                $to_file = 
"{$bofiles->fakebase}/{$cat_id}/{$file_name}";
                                if($bofiles->vfs->file_exists(array(
-                                       'string' => $to_file,
-                                       'relatives' => Array(RELATIVE_NONE)
+                                       'string'         => $to_file,
+                                       'relatives'      => Array(RELATIVE_NONE)
                                )))
                                {
-                                       phpgwapi_cache::message_set(lang('This 
file already exists !'), 'error'); 
+                                       phpgwapi_cache::message_set(lang('This 
file already exists !'), 'error');
                                }
                                else
                                {
-               //                      $bofiles->create_document_dir($cat_id);
+                                       //                      
$bofiles->create_document_dir($cat_id);
                                        $bofiles->vfs->override_acl = 1;
 
-                                       if(!$bofiles->vfs->cp (array (
-                                               'from'  => 
$_FILES['file']['tmp_name'],
-                                               'to'    => $to_file,
-                                               'relatives'     => array 
(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL))))
+                                       if(!$bofiles->vfs->cp(array(
+                                               'from'           => 
$_FILES['file']['tmp_name'],
+                                               'to'             => $to_file,
+                                               'relatives'      => 
array(RELATIVE_NONE | VFS_REAL, RELATIVE_ALL))))
                                        {
-                                               
phpgwapi_cache::message_set(lang('Failed to upload file !'), 'error'); 
+                                               
phpgwapi_cache::message_set(lang('Failed to upload file !'), 'error');
                                        }
                                        $bofiles->vfs->override_acl = 0;
                                }
                        }
                }
 
-
                private function _get_categories($selected = 0)
                {
-                       $cats   = CreateObject('phpgwapi.categories', -1, 
'manual', $this->acl_location);
-                       $cats->supress_info     = true;
-                       $categories = 
$cats->formatted_xslt_list(array('format'=>'filter','selected' => 
$selected,'globals' => true,'use_acl' => $this->_category_acl));
-                       $default_value = array ('cat_id'=>'','name'=> lang('no 
category'));
-                       array_unshift ($categories['cat_list'],$default_value);
+                       $cats                            = 
CreateObject('phpgwapi.categories', -1, 'manual', $this->acl_location);
+                       $cats->supress_info      = true;
+                       $categories                      = 
$cats->formatted_xslt_list(array('format' => 'filter', 'selected' => $selected,
+                               'globals' => true, 'use_acl' => 
$this->_category_acl));
+                       $default_value           = array('cat_id' => '', 'name' 
=> lang('no category'));
+                       array_unshift($categories['cat_list'], $default_value);
 
-                       foreach ($categories['cat_list'] as & $_category)
+                       foreach($categories['cat_list'] as & $_category)
                        {
                                $_category['id'] = $_category['cat_id'];
                        }
 
                        return $categories['cat_list'];
                }
-       }
+       }
\ No newline at end of file

Modified: branches/dev-syncromind/manual/js/portico/documents.add.js
===================================================================
--- branches/dev-syncromind/manual/js/portico/documents.add.js  2015-07-12 
13:36:10 UTC (rev 13636)
+++ branches/dev-syncromind/manual/js/portico/documents.add.js  2015-07-13 
11:41:46 UTC (rev 13637)
@@ -1,44 +1,6 @@
 var cat_id = 0;
 var fileuploader_action;
 
-var arURLParts = strBaseURL.split('?');
-var comboBase = arURLParts[0] + 'phpgwapi/inc/yui-combo-master/combo.php?';
-
-YUI_config = {
-    //Don't combine the files
-    combine: true,
-    //Ignore things that are already loaded (in this process)
-    ignoreRegistered: false,
-    //Set the base path
-       comboBase: comboBase,
-    base: '',
-    //And the root
-    root: '',
-    //Require your deps
-    require: [ ]
-};
-
-
-YUI({
-}).use(
-       'gallery-formvalidator', 
-               function(Y) {   
-                Y.on("domready", function () {
-                   var form = new Y.Validator(
-                        {
-                            form:'form',
-                                                       checkOnSubmit:false,
-                            defaultIncorrectIndicatorCss:'validator',
-                            defaultCorrectIndicatorCss:'indicator',
-                            createCorrectIndicator:true,
-                            createIncorrectIndicator:true
-                        }
-                    );
-
-                });
-
-});
-
        this.update_fileuploader_action = function()
        {
           cat_id = document.getElementById("cat_id").value;
@@ -77,7 +39,7 @@
        {
                var oArgs = {menuaction:'manual.uidocuments.get_files', 
cat_id:cat_id};
                var strURL = phpGWLink('index.php', oArgs, true);
-               YAHOO.portico.updateinlineTableHelper('datatable-container_0', 
strURL);
+               JqueryPortico.updateinlineTableHelper('datatable-container_0', 
strURL);
        }
        
        function lightbox_hide()

Modified: branches/dev-syncromind/manual/js/portico/documents.view.js
===================================================================
--- branches/dev-syncromind/manual/js/portico/documents.view.js 2015-07-12 
13:36:10 UTC (rev 13636)
+++ branches/dev-syncromind/manual/js/portico/documents.view.js 2015-07-13 
11:41:46 UTC (rev 13637)
@@ -3,5 +3,5 @@
                var cat_id = document.getElementById("cat_id").value;
                var oArgs = {menuaction:'manual.uidocuments.get_files', 
cat_id:cat_id};
                var strURL = phpGWLink('index.php', oArgs, true);
-               YAHOO.portico.updateinlineTableHelper('datatable-container_0', 
strURL);
+               JqueryPortico.updateinlineTableHelper('datatable-container_0', 
strURL);
        }

Modified: branches/dev-syncromind/manual/templates/base/documents_add.xsl
===================================================================
--- branches/dev-syncromind/manual/templates/base/documents_add.xsl     
2015-07-12 13:36:10 UTC (rev 13636)
+++ branches/dev-syncromind/manual/templates/base/documents_add.xsl     
2015-07-13 11:41:46 UTC (rev 13637)
@@ -1,181 +1,122 @@
 <!-- $Id$ -->
 
-<func:function name="phpgw:conditional">
-       <xsl:param name="test"/>
-       <xsl:param name="true"/>
-       <xsl:param name="false"/>
-
-       <func:result>
-               <xsl:choose>
-                       <xsl:when test="$test">
-                       <xsl:value-of select="$true"/>
-                       </xsl:when>
-                       <xsl:otherwise>
-                               <xsl:value-of select="$false"/>
-                       </xsl:otherwise>
-               </xsl:choose>
-       </func:result>
-</func:function>
-
-       <!-- add / edit -->
-<xsl:template match="data" xmlns:formvalidator="http://www.w3.org/TR/html4/"; 
xmlns:php="http://php.net/xsl";>
-               <xsl:call-template name="yui_phpgw_i18n"/>
-
-               <div class="yui-navset" id="survey_edit_tabview">
-
-               <h1>
-                       <xsl:value-of select="php:function('lang', 
'documents')" />
-               </h1>
-
-
+<!-- add / edit -->
+<xsl:template match="data" xmlns:php="http://php.net/xsl";>
+       <xsl:call-template name="jquery_phpgw_i18n"/>
+       <div>
                <xsl:variable name="action_url">
                        <xsl:value-of select="php:function('get_phpgw_link', 
'/index.php', 'menuaction:manual.uidocuments.save')" />
                </xsl:variable>
 
-                       <form name="form" id="form" action="{$action_url}" 
method="post" ENCTYPE="multipart/form-data">
-                       <dl>
-                                       <xsl:choose>
-                                               <xsl:when test="msgbox_data != 
''">
-                                                               <dt>
-                                                                       
<xsl:call-template name="msgbox"/>
-                                                               </dt>
-                                               </xsl:when>
-                                       </xsl:choose>
-                               </dl>
+               <form name="form" id="form" action="{$action_url}" 
method="post" ENCTYPE="multipart/form-data">
+                       <dl>
+                               <xsl:choose>
+                                       <xsl:when test="msgbox_data != ''">
+                                               <dt>
+                                                       <xsl:call-template 
name="msgbox"/>
+                                               </dt>
+                                       </xsl:when>
+                               </xsl:choose>
+                       </dl>
 
-                               <div class="yui-content">
-                               <div id="generic" class="content-wrp">
+                       <div id="tab-content">
 
-                               <dl class="proplist-col">
+                               <xsl:value-of disable-output-escaping="yes" 
select="tabs"/>
 
-                                       <dt>
-                                               <label 
for="category"><xsl:value-of select="php:function('lang', 'category')" 
/></label>
-                                       </dt>
-                                       <dd>
+                               <div id="documents">
+
+                                       <div class="pure-control-group">
+                                               <label for="category">
+                                                       <xsl:value-of 
select="php:function('lang', 'category')" />
+                                               </label>
                                                <xsl:choose>
                                                        <xsl:when 
test="editable = 1">
-                                                               <select 
id="cat_id" name="cat_id" onChange="update_fileuploader_action();" 
-                                                                       
formvalidator:FormField="yes"
-                                                                       
formvalidator:Type="SelectField">
+                                                               <select 
id="cat_id" name="cat_id" onChange="update_fileuploader_action();">
+                                                                       
<xsl:attribute name="data-validation">
+                                                                               
<xsl:text>required</xsl:text>
+                                                                       
</xsl:attribute>
+                                                                       
<xsl:attribute name="data-validation-error-msg">
+                                                                               
<xsl:value-of select="php:function('lang', 'Please enter a category !')"/>
+                                                                       
</xsl:attribute>
                                                                        
<xsl:apply-templates select="categories/options"/>
                                                                </select>
                                                        </xsl:when>
                                                        <xsl:otherwise>
-                                                               <select 
id="cat_id" name="cat_id" onChange="refresh_files();"> 
+                                                               <select 
id="cat_id" name="cat_id" onChange="refresh_files();">
                                                                        
<xsl:apply-templates select="categories/options"/>
                                                                </select>
-                                                       </xsl:otherwise>
+                                                       </xsl:otherwise>
                                                </xsl:choose>
-                                       </dd>
-
-                               </dl>
+                                       </div>
+                                       <div class="pure-control-group">
+                                               <label>
+                                                       <xsl:value-of 
select="php:function('lang', 'files')"/>
+                                               </label>
+                                               <xsl:for-each 
select="datatable_def">
+                                                       <xsl:if test="container 
= 'datatable-container_0'">
+                                                               
<xsl:call-template name="table_setup">
+                                                                       
<xsl:with-param name="container" select ='container'/>
+                                                                       
<xsl:with-param name="requestUrl" select ='requestUrl' />
+                                                                       
<xsl:with-param name="ColumnDefs" select ='ColumnDefs' />
+                                                                       
<xsl:with-param name="tabletools" select ='tabletools' />
+                                                                       
<xsl:with-param name="config" select ='config' />
+                                                               
</xsl:call-template>
+                                                       </xsl:if>
+                                               </xsl:for-each>
+                                               <xsl:choose>
+                                                       <xsl:when 
test="editable = 1">
+                                                               
<xsl:call-template name="file_upload"/>
+                                                       </xsl:when>
+                                               </xsl:choose>
+                                       </div>
+                               </div>
                        </div>
-
-                       <div id="documents">
-                               <xsl:call-template name="datasource-definition" 
/>
-
-                               <dl class="proplist-col">
-
-                                               <dt>
-                                                       <label><xsl:value-of 
select="php:function('lang', 'files')"/></label>
-                                               </dt>
-                                               <dd>
-                                                       <div 
style="clear:both;" id="datatable-container_0"></div>
-                                               </dd>
-
-                                       <xsl:choose>
-                                               <xsl:when test="editable = 1">
-                                                       <xsl:call-template 
name="file_upload"/>
-                                               </xsl:when>
-                                       </xsl:choose>
-                               </dl>
-                       </div>
-                       </div>
                        <xsl:choose>
                                <xsl:when test="editable = 1">
                                        <dl class="proplist-col">
-                                                       <div 
class="form-buttons">
-                                                               <xsl:variable 
name="lang_cancel"><xsl:value-of select="php:function('lang', 'cancel')" 
/></xsl:variable>
-                                                               <xsl:choose>
-                                                                       
<xsl:when test="editable = 1">
-                                                                               
<xsl:variable name="lang_save"><xsl:value-of select="php:function('lang', 
'save')" /></xsl:variable>
-                                                                               
<input type="submit" name="save_project" value="{$lang_save}" title = 
"{$lang_save}" />
-                                                                               
<input class="button" type="button" name="cancelButton" id ='cancelButton' 
value="{$lang_cancel}" title = "{$lang_cancel}" 
onClick="document.cancel_form.submit();"/>
-                                                                       
</xsl:when>
-                                                                       
<xsl:otherwise>
-                                                                               
<xsl:variable name="lang_edit"><xsl:value-of select="php:function('lang', 
'edit')" /></xsl:variable>
-                                                                               
<xsl:variable name="lang_new_survey"><xsl:value-of select="php:function('lang', 
'new')" /></xsl:variable>
-                                                                               
<input type="button" name="edit_survey" value="{$lang_edit}" title = 
"{$lang_edit}"  onClick="document.load_edit_form.submit();"/>
-                                                                               
<input type="button" name="new_survey" value="{$lang_new_survey}" title = 
"{$lang_new_survey}" onClick="document.new_form.submit();"/>
-                                                                               
<input class="button" type="button" name="cancelButton" id ='cancelButton' 
value="{$lang_cancel}" title = "{$lang_cancel}" 
onClick="document.cancel_form.submit();"/>
-                                                                       
</xsl:otherwise>
-                                                               </xsl:choose>
-                                                       </div>
-                                               </dl>
-                                       </xsl:when>
-                               </xsl:choose>
-
-                       </form>
-               </div>
-
-               <xsl:variable name="cancel_url">
-                       <xsl:value-of select="php:function('get_phpgw_link', 
'/index.php', 'menuaction:manual.uidocuments.index')" />
-               </xsl:variable>
-
-               <form name="cancel_form" id="cancel_form" 
action="{$cancel_url}" method="post">
+                                               <div class="form-buttons">
+                                                       <xsl:variable 
name="lang_cancel">
+                                                               <xsl:value-of 
select="php:function('lang', 'cancel')" />
+                                                       </xsl:variable>
+                                                       <xsl:choose>
+                                                               <xsl:when 
test="editable = 1">
+                                                                       
<xsl:variable name="lang_save">
+                                                                               
<xsl:value-of select="php:function('lang', 'save')" />
+                                                                       
</xsl:variable>
+                                                                       <input  
class="pure-button pure-button-primary" type="submit" name="save_project" 
value="{$lang_save}" title = "{$lang_save}" />
+                                                                       <input  
class="pure-button pure-button-primary" type="button" name="cancelButton" id 
='cancelButton' value="{$lang_cancel}" title = "{$lang_cancel}" 
onClick="document.cancel_form.submit();"/>
+                                                               </xsl:when>
+                                                       </xsl:choose>
+                                               </div>
+                                       </dl>
+                               </xsl:when>
+                               <xsl:otherwise>
+                                       <xsl:variable name="lang_add">
+                                               <xsl:value-of 
select="php:function('lang', 'add')" />
+                                       </xsl:variable>
+                                               <input  class="pure-button 
pure-button-primary" type="button" name="edit_survey" value="{$lang_add}" title 
= "{$lang_add}"  onClick="document.load_edit_form.submit();"/>
+                               </xsl:otherwise>
+                       </xsl:choose>
                </form>
-               <xsl:variable name="new_url">
-                       <xsl:value-of select="php:function('get_phpgw_link', 
'/index.php', 'menuaction:manual.uidocuments.add')" />
-               </xsl:variable>
-               <form name="new_form" id="new_form" action="{$new_url}" 
method="post">
-               </form>
+       </div>
 
-               <xsl:variable name="edit_params">
-                       <xsl:text>menuaction:manual.uidocuments.edit</xsl:text>
-               </xsl:variable>
-               <xsl:variable name="edit_url">
-                               <xsl:value-of 
select="php:function('get_phpgw_link', '/index.php', $edit_params )" />
-               </xsl:variable>
+       <xsl:variable name="cancel_url">
+               <xsl:value-of select="php:function('get_phpgw_link', 
'/index.php', 'menuaction:manual.uidocuments.index')" />
+       </xsl:variable>
 
-               <form name="load_edit_form" id="load_edit_form" 
action="{$edit_url}" method="post">
-               </form>
+       <form name="cancel_form" id="cancel_form" action="{$cancel_url}" 
method="post">
+       </form>
 
-       </xsl:template>
+       <xsl:variable name="edit_params">
+               <xsl:text>menuaction:manual.uidocuments.add</xsl:text>
+       </xsl:variable>
+       <xsl:variable name="edit_url">
+               <xsl:value-of select="php:function('get_phpgw_link', 
'/index.php', $edit_params )" />
+       </xsl:variable>
 
-<xsl:template name="datasource-definition">
-       <script>
-               var columnDefs = [];
-               YAHOO.util.Event.onDOMReady(function(){
-                       <xsl:for-each select="datatable_def">
-                               columnDefs = [
-                                       <xsl:for-each select="ColumnDefs">
-                                       {
-                                               resizeable: true,
-                                               key: "<xsl:value-of 
select="key"/>",
-                                               <xsl:if test="label">
-                                               label: "<xsl:value-of 
select="label"/>",
-                                               </xsl:if>
-                                               sortable: <xsl:value-of 
select="phpgw:conditional(not(sortable = 0), 'true', 'false')"/>,
-                                               <xsl:if test="hidden">
-                                               hidden: true,
-                                               </xsl:if>
-                                               <xsl:if test="formatter">
-                                               formatter: <xsl:value-of 
select="formatter"/>,
-                                               </xsl:if>
-                                               <xsl:if test="editor">
-                                               editor: <xsl:value-of 
select="editor"/>,
-                                           </xsl:if>
-                                               className: "<xsl:value-of 
select="className"/>"
-                                       }<xsl:value-of 
select="phpgw:conditional(not(position() = last()), ',', '')"/>
-                               </xsl:for-each>
-                               ];
-                       
-                       YAHOO.portico.inlineTableHelper("<xsl:value-of 
select="container"/>", <xsl:value-of select="requestUrl"/>, columnDefs);
-               </xsl:for-each>
+       <form name="load_edit_form" id="load_edit_form" action="{$edit_url}" 
method="post">
+       </form>
 
-       });
-  </script>
-
 </xsl:template>
 
 
@@ -189,28 +130,32 @@
        </option>
 </xsl:template>
 
-       <xsl:template xmlns:php="http://php.net/xsl"; name="file_upload">
-               <dt>
-                       <label><xsl:value-of select="php:function('lang', 
'upload file')"/></label>
-               </dt>
-               <dd>
-                       <input type="file" name="file" size="40">
-                               <xsl:attribute name="title">
-                                       <xsl:value-of 
select="php:function('lang', 'Select file to upload')"/>
-                               </xsl:attribute>
-                       </input>
-               </dd>
-               <xsl:choose>
-                       <xsl:when test="multiple_uploader!=''">
-                               <dt>
-                                       <label><a 
href="javascript:fileuploader()">
+<xsl:template xmlns:php="http://php.net/xsl"; name="file_upload">
+       <dt>
+               <label>
+                       <xsl:value-of select="php:function('lang', 'upload 
file')"/>
+               </label>
+       </dt>
+       <dd>
+               <input type="file" name="file" size="40">
+                       <xsl:attribute name="title">
+                               <xsl:value-of select="php:function('lang', 
'Select file to upload')"/>
+                       </xsl:attribute>
+               </input>
+       </dd>
+       <xsl:choose>
+               <xsl:when test="multiple_uploader!=''">
+                       <dt>
+                               <label>
+                                       <a href="javascript:fileuploader()">
                                                <xsl:attribute name="title">
                                                        <xsl:value-of 
select="php:function('lang', 'upload multiple files')"/>
                                                </xsl:attribute>
                                                <xsl:value-of 
select="php:function('lang', 'upload multiple files')"/>
-                                       </a></label>
-                               </dt>
-                       </xsl:when>
-               </xsl:choose>
-       </xsl:template>
+                                       </a>
+                               </label>
+                       </dt>
+               </xsl:when>
+       </xsl:choose>
+</xsl:template>
 




reply via email to

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