phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: etemplate/inc class.boetemplate.inc.php,1.2,1.3


From: Ralf Becker <address@hidden>
Subject: [Phpgroupware-cvs] CVS: etemplate/inc class.boetemplate.inc.php,1.2,1.3 class.db_tools.inc.php,1.2,1.3 class.editor.inc.php,1.2,1.3 class.uietemplate.inc.php,1.2,1.3
Date: Sun, 17 Feb 2002 14:09:18 -0500

Update of /cvsroot/phpgroupware/etemplate/inc
In directory subversions:/tmp/cvs-serv13536

Modified Files:
        class.boetemplate.inc.php class.db_tools.inc.php 
        class.editor.inc.php class.uietemplate.inc.php 
Log Message:
session->app_session used now for the sessiondata (not longer hidden vars)
the content of the form is now the first param. to the callback (no longer in 
HTTP_POST_VARS) 

Index: class.boetemplate.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/etemplate/inc/class.boetemplate.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** class.boetemplate.inc.php   14 Feb 2002 14:06:30 -0000      1.2
--- class.boetemplate.inc.php   17 Feb 2002 19:09:15 -0000      1.3
***************
*** 161,163 ****
--- 161,198 ----
                        return $Ok;
                }
+ 
+               /*!
+               @function save_appsession()
+               @abstract saves content,readonlys,template-keys, ... via the 
appsession function
+               @discussion As a user may open several windows with the same 
content/template wie generate a location-id from microtime
+               @discussion which is used as location for appsession to 
descriminate between the different windows. This location-id
+               @discussion is then saved as a hidden-var in the form. The 
above mentions session-id has nothing to do / is different
+               @discussion from the session-id which is constant for all 
windows opened in one session.
+               @returns the location-id
+               */
+               function save_appsession($data)
+               {
+                       list($msec,$sec) = explode(' ',microtime());
+                       $id = $GLOBALS['phpgw_info']['flags']['currentapp'] . 
(intval(1000000 * $msec) + 1000000 * ($sec % 100000));
+                       //echo "<p>microtime()=".microtime().", sec=$sec, 
msec=$msec, id=$id</p>\n";
+ 
+                       
$GLOBALS['phpgw']->session->appsession($id,'etemplate',$data);
+ 
+                       return $id;
+               }
+ 
+               /*!
+               @function get_appsession()
+               @abstract gets content,readonlys,template-keys, ... back from 
the appsession function
+               @param $id the location-id
+               @returns the session-data
+               */
+               function get_appsession($id)
+               {
+                       $data = 
$GLOBALS['phpgw']->session->appsession($id,'etemplate');
+ 
+                       //echo "<p>get_appsession('$id') data="; 
_debug_array($data);
+ 
+                       return $data;
+               }
        };

Index: class.db_tools.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/etemplate/inc/class.db_tools.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** class.db_tools.inc.php      14 Feb 2002 14:06:30 -0000      1.2
--- class.db_tools.inc.php      17 Feb 2002 19:09:15 -0000      1.3
***************
*** 33,37 ****
                        'select_one' => 'Select one ...',
                        'writen' => 'File writen',
!                       'error_writing' => 'Error: writing file !!!',
                        'give_table_name' => 'Please enter table-name first 
!!!',
                        'new_table' => 'New table created',
--- 33,37 ----
                        'select_one' => 'Select one ...',
                        'writen' => 'File writen',
!                       'error_writing' => 'Error: writing file (no 
write-permission for the webserver) !!!',
                        'give_table_name' => 'Please enter table-name first 
!!!',
                        'new_table' => 'New table created',
***************
*** 80,87 ****
  
                /*!
!               @function edit()
                @abstract this is the table editor (and the 
callback/submit-method too)
                */
!               function edit($msg = '')
                {
                        if (isset($GLOBALS['HTTP_GET_VARS']['app']))
--- 80,87 ----
  
                /*!
!               @function edit($content='',$msg='')
                @abstract this is the table editor (and the 
callback/submit-method too)
                */
!               function edit($content='',$msg = '')
                {
                        if (isset($GLOBALS['HTTP_GET_VARS']['app']))
***************
*** 89,108 ****
                                $this->app = $GLOBALS['HTTP_GET_VARS']['app'];
                        }
!                       if (isset($GLOBALS['HTTP_POST_VARS']['cont']))
                        {
-                               $content = $GLOBALS['HTTP_POST_VARS']['cont'];
                                if ($this->debug)
                                {
!                                       echo "HTTP_POST_VARS ="; 
_debug_array($GLOBALS['HTTP_POST_VARS']);
                                }
                                $this->app = $content['app'];   // this is what 
the user selected
                                $this->table = $content['table_name'];
!                               $posted_app = 
$GLOBALS['HTTP_POST_VARS']['posted_app']; // this is the old selection
!                               $posted_table = 
$GLOBALS['HTTP_POST_VARS']['posted_table'];
                        }
                        if ($posted_app && $posted_table &&             // user 
changed app or table
                                 ($posted_app != $this->app || $posted_table != 
$this->table))
                        {
!                               if 
($this->needs_save($posted_app,$posted_table,$this->content2table($content)))
                                {
                                        return;
--- 89,107 ----
                                $this->app = $GLOBALS['HTTP_GET_VARS']['app'];
                        }
!                       if (is_array($content))
                        {
                                if ($this->debug)
                                {
!                                       echo "content ="; 
_debug_array($content);
                                }
                                $this->app = $content['app'];   // this is what 
the user selected
                                $this->table = $content['table_name'];
!                               $posted_app = $content['posted_app'];   // this 
is the old selection
!                               $posted_table = $content['posted_table'];
                        }
                        if ($posted_app && $posted_table &&             // user 
changed app or table
                                 ($posted_app != $this->app || $posted_table != 
$this->table))
                        {
!                               if 
($this->needs_save('',$posted_app,$posted_table,$this->content2table($content)))
                                {
                                        return;
***************
*** 202,209 ****
                                $table_names[$this->table] = $this->table;
                        }
!    $sel_options = array(
                                'table_name' => $table_names,
                                'type' => $this->types,
!                               'app' => array('' => 
lang($this->messages['select_one'])) + $this->apps
                        );
                        if ($this->table != '' && 
isset($this->data[$this->table]))
--- 201,208 ----
                                $table_names[$this->table] = $this->table;
                        }
!                       $sel_options = array(
                                'table_name' => $table_names,
                                'type' => $this->types,
!                               'app' => array('' => 
$this->messages['select_one']) + $this->apps
                        );
                        if ($this->table != '' && 
isset($this->data[$this->table]))
***************
*** 225,230 ****
  
                /*!
!               @function needs_save($posted_app,$posted_table,$edited_table)
                @abstract checks if table was changed and if so offers user to 
save changes
                @param $posted_app the app the table is from
                @param $posted_table the table-name
--- 224,230 ----
  
                /*!
!               @function 
needs_save($cont='',$posted_app='',$posted_table='',$edited_table='')
                @abstract checks if table was changed and if so offers user to 
save changes
+               @param $cont the content of the form (if called by process_exec)
                @param $posted_app the app the table is from
                @param $posted_table the table-name
***************
*** 232,248 ****
                @returns only if no changes
                */
!               function 
needs_save($posted_app='',$posted_table='',$edited_table='')
                {
!                       if (!$posted_app && 
isset($GLOBALS['HTTP_POST_VARS']['cont']))
                        {
-                               $cont = $GLOBALS['HTTP_POST_VARS']['cont'];
-                               $preserv = 
unserialize(stripslashes($GLOBALS['HTTP_POST_VARS']['preserv']));
- 
                                if (isset($cont['yes']))
                                {
!                                       $this->app   = $preserv['app'];
!                                       $this->table = $preserv['table'];
                                        $this->read($this->app,$this->data);
!                                       $this->data[$this->table] = 
$preserv['edited_table'];
                                        $this->write($this->app,$this->data);
                                        $msg .= 
$this->messages[$this->write($this->app,$this->data) ?
--- 232,245 ----
                @returns only if no changes
                */
!               function 
needs_save($cont='',$posted_app='',$posted_table='',$edited_table='')
                {
!                       if (!$posted_app && is_array($cont))
                        {
                                if (isset($cont['yes']))
                                {
!                                       $this->app   = $cont['app'];
!                                       $this->table = $cont['table'];
                                        $this->read($this->app,$this->data);
!                                       $this->data[$this->table] = 
$cont['edited_table'];
                                        $this->write($this->app,$this->data);
                                        $msg .= 
$this->messages[$this->write($this->app,$this->data) ?
***************
*** 250,261 ****
                                }
                                // return to edit with everything set, so the 
user gets the table he asked for
!                               $GLOBALS['HTTP_POST_VARS'] = array(
!                                       'cont' => array(
!                                               'app' => $preserv['new_app'],
!                                               'table_name' => 
$preserv['app']==$preserv['new_app'] ? $preserv['new_table']:''
!                                       ),
!                                       'posted_app' => $preserv['new_app'],
!                               );
!                               $this->edit($msg);
                                return True;
                        }
--- 247,256 ----
                                }
                                // return to edit with everything set, so the 
user gets the table he asked for
!                               $this->edit(array(
!                                       'app' => $cont['new_app'],
!                                       'table_name' => 
$cont['app']==$cont['new_app'] ? $cont['new_table'] : '',
!                                       'posted_app' => $cont['new_app']
!                               ),$msg);
! 
                                return True;
                        }
***************
*** 285,290 ****
                        $tmpl = new etemplate('etemplate.db-tools.ask_save');
  
!                       
$tmpl->exec('etemplate.db_tools.needs_save',$content,array(),array(),
!                               array('preserv' => $preserv));
  
                        return True;    // dont continue in edit
--- 280,284 ----
                        $tmpl = new etemplate('etemplate.db-tools.ask_save');
  
!                       
$tmpl->exec('etemplate.db_tools.needs_save',$content,array(),array(),$preserv);
  
                        return True;    // dont continue in edit
***************
*** 479,484 ****
                                fclose($f);
  
!                               
rename($file,PHPGW_SERVER_ROOT."/$app/setup/tables_current.old.inc.php");
! 
                                while ($header[strlen($header)-1] == "\t")
                                {
--- 473,480 ----
                                fclose($f);
  
!                               if 
(is_writable(PHPGW_SERVER_ROOT."/$app/setup"))
!                               {
!                                       
rename($file,PHPGW_SERVER_ROOT."/$app/setup/tables_current.old.inc.php");
!                               }
                                while ($header[strlen($header)-1] == "\t")
                                {
***************
*** 490,494 ****
                                $header = "<?php\n\n";
                        }
!                       if (!($f = fopen($file,'w')))
                        {
                                return False;
--- 486,490 ----
                                $header = "<?php\n\n";
                        }
!                       if (!is_writeable($file) || !($f = fopen($file,'w')))
                        {
                                return False;
***************
*** 557,561 ****
                {
                        $m = new db_tools(False);       // no lang on messages
!                       
$this->tmpl->writeLangFile('etemplate','en',$m->messages);
                }
        };
--- 553,557 ----
                {
                        $m = new db_tools(False);       // no lang on messages
!                       
$this->editor->writeLangFile('etemplate','en',$m->messages);
                }
        };

Index: class.editor.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/etemplate/inc/class.editor.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** class.editor.inc.php        14 Feb 2002 14:06:30 -0000      1.2
--- class.editor.inc.php        17 Feb 2002 19:09:15 -0000      1.3
***************
*** 94,98 ****
                                                while(list($k,$v) = 
each($cell))                // so spanned (not shown) cells got
                                                {                               
    // reported back like regular one
!                                                       
$cols_spanned["cont[$col$row][$k]"] = $v;
                                                }
                                        }
--- 94,98 ----
                                                while(list($k,$v) = 
each($cell))                // so spanned (not shown) cells got
                                                {                               
    // reported back like regular one
!                                                       
$cols_spanned[$col.$row][$k] = $v;
                                                }
                                        }
***************
*** 135,141 ****
                }
  
!               function process_edit()
                {
!                       $content = $GLOBALS['HTTP_POST_VARS']['cont'];
  
                        if ($this->debug)
--- 135,141 ----
                }
  
!               function process_edit($content)
                {
!                       //$content = $GLOBALS['HTTP_POST_VARS']['cont'];
  
                        if ($this->debug)
***************
*** 319,329 ****
                }
  
!               function delete($back = 'edit')
                {
!                       if (isset($GLOBALS['HTTP_POST_VARS']['name']))
                        {
!                               $read_ok = 
$this->etemplate->read($GLOBALS['HTTP_POST_VARS']);
                        }
!                       if (isset($GLOBALS['HTTP_POST_VARS']['yes']))   // 
Delete
                        {
                                if ($read_ok)
--- 319,333 ----
                }
  
!               function delete($post_vars='',$back = 'edit')
                {
!                       if (!$post_vars)
                        {
!                               $post_vars = array();
                        }
!                       if (isset($post_vars['name']))
!                       {
!                               $read_ok = $this->etemplate->read($post_vars);
!                       }
!                       if (isset($post_vars['yes']))   // Delete
                        {
                                if ($read_ok)
***************
*** 334,340 ****
                                return;
                        }
!                       if (isset($GLOBALS['HTTP_POST_VARS']['no']))    // Back 
to ...
                        {
!                               if (($back = 
$GLOBALS['HTTP_POST_VARS']['back']) != 'show')
                                {
                                        $back = 'edit';
--- 338,344 ----
                                return;
                        }
!                       if (isset($post_vars['no']))    // Back to ...
                        {
!                               if (($back = $post_vars['back']) != 'show')
                                {
                                        $back = 'edit';
***************
*** 355,362 ****
                }
  
!               function show()
                {
!                       $post_vars = $GLOBALS['HTTP_POST_VARS'];
! 
                        if (isset($GLOBALS['HTTP_GET_VARS']['name']) && 
!$this->etemplate->read($GLOBALS['HTTP_GET_VARS']) ||
                            isset($post_vars['name']) && 
!$this->etemplate->read($post_vars))
--- 359,368 ----
                }
  
!               function show($post_vars='')
                {
!                       if (!$post_vars)
!                       {
!                               $post_vars = array();
!                       }
                        if (isset($GLOBALS['HTTP_GET_VARS']['name']) && 
!$this->etemplate->read($GLOBALS['HTTP_GET_VARS']) ||
                            isset($post_vars['name']) && 
!$this->etemplate->read($post_vars))
***************
*** 366,370 ****
                        if (!$msg && isset($post_vars['delete']))
                        {
!                               $this->delete('show');
                                return;
                        }
--- 372,376 ----
                        if (!$msg && isset($post_vars['delete']))
                        {
!                               $this->delete(array(),'show');
                                return;
                        }
***************
*** 377,386 ****
  
                        $show = new etemplate('etemplate.editor.show');
!                       $no_buttons = array('save' => True,'show' => 
True,'dump' => True,'langfile' => True,'size' => True);
! 
!                       if (!$msg && isset($post_vars['values']) && 
!isset($GLOBALS['HTTP_POST_VARS']['vals']))
                        {
!                               $cont = 
$this->etemplate->process_show($GLOBALS['HTTP_POST_VARS']);
!                               for ($r = 1; list($key,$val) = each($cont); 
++$r)
                                {
                                        $vals["A$r"] = $key;
--- 383,397 ----
  
                        $show = new etemplate('etemplate.editor.show');
!                       $no_buttons = array(
!                               'save' => True,
!                               'show' => True,
!                               'dump' => True,
!                               'langfile' => True,
!                               'size' => True
!                       );
!                       if (!$msg && isset($post_vars['values']) && 
!isset($post_vars['vals']))
                        {
!                               $cont = 
$this->etemplate->process_show($post_vars);
!                               for ($r = 1; list($key,$val) = @each($cont); 
++$r)
                                {
                                        $vals["A$r"] = $key;
***************
*** 394,399 ****
                        {
                                $show->data[$show->rows]['A']['name'] = 
$this->etemplate;
!                               $vals = $GLOBALS['HTTP_POST_VARS']['vals'];
!                               $olds = 
unserialize(stripslashes($GLOBALS['HTTP_POST_VARS']['olds']));
  
                                for ($r = 1; isset($vals["B$r"]); ++$r)
--- 405,410 ----
                        {
                                $show->data[$show->rows]['A']['name'] = 
$this->etemplate;
!                               $vals = $post_vars['vals'];
!                               $olds = 
unserialize(stripslashes($post_vars['olds']));
  
                                for ($r = 1; isset($vals["B$r"]); ++$r)

Index: class.uietemplate.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/etemplate/inc/class.uietemplate.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** class.uietemplate.inc.php   14 Feb 2002 14:06:30 -0000      1.2
--- class.uietemplate.inc.php   17 Feb 2002 19:09:15 -0000      1.3
***************
*** 76,83 ****
                @param            (eg. to implement ACL grants on field-level 
or to remove buttons not applicable)
                @param $preserv Array with vars which should be transported to 
the $method-call (eg. an id) array('id' => $id) sets $HTTP_POST_VARS['id'] for 
the $method-call
-               @param $cname Basename for the submitted content in 
$HTTP_POST_VARS (default = 'cont')
                @returns nothing
                */
!               function 
exec($method,$content,$sel_options='',$readonlys='',$preserv='',$cname='cont')
                {
                        if (!$sel_options)
--- 76,82 ----
                @param            (eg. to implement ACL grants on field-level 
or to remove buttons not applicable)
                @param $preserv Array with vars which should be transported to 
the $method-call (eg. an id) array('id' => $id) sets $HTTP_POST_VARS['id'] for 
the $method-call
                @returns nothing
                */
!               function 
exec($method,$content,$sel_options='',$readonlys='',$preserv='')
                {
                        if (!$sel_options)
***************
*** 96,109 ****
                        echo parse_navbar();
  
                        echo $this->html->nextMatchStyles($this->style)."\n\n". 
// so they get included once
!                               
$this->html->form($this->show($content,$sel_options,$readonlys,$cname),array(
!                                       'etemplate_exec[name]' => $this->name,
!                                       'etemplate_exec[template]' => 
$this->template,
!                                       'etemplate_exec[lang]' => $this->lang,
!                                       'etemplate_exec[group]' => $this->group,
!                                       'etemplate_exec[readonlys]' => 
$readonlys,
!                                       'etemplate_exec[cname]' => $cname,
!                                       'etemplate_exec[method]' => $method
!                               
)+$preserv,'/index.php?menuaction=etemplate.etemplate.process_exec');
                }
  
--- 95,113 ----
                        echo parse_navbar();
  
+                       $id = $this->save_appsession(array(
+                               'name' => $this->name,
+                               'template' => $this->template,
+                               'lang' => $this->lang,
+                               'group' => $this->group,
+                               'readonlys' => $readonlys,
+                               'content' => $content,
+                               'sel_options' => $sel_options,
+                               'preserv' => $preserv,
+                               'method' => $method
+                       ));
+ 
                        echo $this->html->nextMatchStyles($this->style)."\n\n". 
// so they get included once
!                               
$this->html->form($this->show($content,$sel_options,$readonlys,'exec'),
!                                       array('etemplate_exec_id' => 
$id),'/index.php?menuaction=etemplate.etemplate.process_exec');
                }
  
***************
*** 115,135 ****
                @discussion (via the global index.php and menuaction). It then 
calls process_show
                @discussion for the eTemplate (to adjust the content of the 
HTTP_POST_VARS) and
!               @discussion ExecMethod's the given callback from the app.
                */
                function process_exec()
                {
!                       $exec = $GLOBALS['HTTP_POST_VARS']['etemplate_exec'];
!                       //echo "<p>uietemplate.process_exec('${exec['name']}'): 
exec = "; _debug_array($exec);
  
!                       $this->read($exec);
!                       $readonlys = 
unserialize(stripslashes($exec['readonlys']));
!                       //echo "<p>uietemplate.process_exec: 
process_show(cname=${exec['cname']}): readonlys ="; _debug_array($readonlys);
!                       
$this->process_show($GLOBALS['HTTP_POST_VARS'][$exec['cname']],$readonlys);
  
                        // set application name so that lang, etc. works
!                       list($GLOBALS['phpgw_info']['flags']['currentapp']) = 
explode('.',$exec['method']);
  
                        //echo "<p>uietemplate.process_exec: 
ExecMethod('${exec['method']}')</p>\n";
!                       ExecMethod($exec['method']);
                }
  
--- 119,141 ----
                @discussion (via the global index.php and menuaction). It then 
calls process_show
                @discussion for the eTemplate (to adjust the content of the 
HTTP_POST_VARS) and
!               @discussion ExecMethod's the given callback from the app with 
the content of the form as first argument.
                */
                function process_exec()
                {
!                       $session_data = 
$this->get_appsession($GLOBALS['HTTP_POST_VARS']['etemplate_exec_id']);
  
!                       $content = $GLOBALS['HTTP_POST_VARS']['exec'];
!                       if (!is_array($content))
!                       {
!                               $content = array();
!                       }
!                       $this->read($session_data);
!                       
$this->process_show($content,$session_data['readonlys']);
  
                        // set application name so that lang, etc. works
!                       list($GLOBALS['phpgw_info']['flags']['currentapp']) = 
explode('.',$session_data['method']);
  
                        //echo "<p>uietemplate.process_exec: 
ExecMethod('${exec['method']}')</p>\n";
!                       
ExecMethod($session_data['method'],array_merge($content,$session_data['preserv']));
                }
  
***************
*** 589,597 ****
                                        if ($idx_cname == '' && $cell['type'] 
== 'template')    // only templates
                                        {
!                                               if ($readonly)                  
// can't unset whole content!!!
                                                {
                                                        $readonlys['__ALL__'] = 
True;
                                                }
-                                               
$this->process_show_cell($cell,$name,$c,$r,$readonlys,$content);
                                        }
                                        elseif 
(ereg('^([^[]*)\\[(.*)\\]$',$idx_cname,$regs))   // name contains array-index
--- 595,608 ----
                                        if ($idx_cname == '' && $cell['type'] 
== 'template')    // only templates
                                        {
!                                               if ($readonly && 
!isset($readonlys['__ALL__']))         // can't unset whole content!!!
                                                {
                                                        $readonlys['__ALL__'] = 
True;
+                                                       
$this->process_show_cell($cell,$name,$c,$r,$readonlys,$content);
+                                                       
unset($readonlys['__ALL__']);           // unset it after or everything gets 
set readonly
+                                               }
+                                               else
+                                               {
+                                                       
$this->process_show_cell($cell,$name,$c,$r,$readonlys,$content);
                                                }
                                        }
                                        elseif 
(ereg('^([^[]*)\\[(.*)\\]$',$idx_cname,$regs))   // name contains array-index




reply via email to

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