[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare - eTemplate Extension - Select Widgets * 4 * http://www.egroupware.org * 5 * Written by Ralf Becker <RalfBecker@outdoor-training.de> * 6 * -------------------------------------------- * 7 * This program is free software; you can redistribute it and/or modify it * 8 * under the terms of the GNU General Public License as published by the * 9 * Free Software Foundation; either version 2 of the License, or (at your * 10 * option) any later version. * 11 \**************************************************************************/ 12 13 /* $Id: class.path_widget.inc.php 21298 2006-04-09 08:19:24Z ralfbecker $ */ 14 15 /** 16 * eTemplate Extension: widget to display a path with clickable components 17 * 18 * The value is an array with id => label pairs. 19 * Returned will be the id of the clicked component or nothing at all. 20 * 21 * @package etemplate 22 * @subpackage extensions 23 * @author RalfBecker-AT-outdoor-training.de 24 * @license GPL 25 */ 26 class path_widget 27 { 28 /** 29 * exported methods of this class 30 * @var array 31 */ 32 var $public_functions = array( 33 'pre_process' => True, 34 'post_process' => True, 35 ); 36 /** 37 * availible extensions and there names for the editor 38 * @var string 39 */ 40 var $human_name = 'clickable path'; 41 42 /** 43 * Constructor of the extension 44 * 45 * @param string $ui '' for html 46 */ 47 function select_widget($ui) 48 { 49 $this->ui = $ui; 50 } 51 52 /** 53 * pre-processing of the extension 54 * 55 * This function is called before the extension gets rendered 56 * 57 * @param string $name form-name of the control 58 * @param mixed &$value value / existing content, can be modified 59 * @param array &$cell array with the widget, can be modified for ui-independent widgets 60 * @param array &$readonlys names of widgets as key, to be made readonly 61 * @param mixed &$extension_data data the extension can store persisten between pre- and post-process 62 * @param object &$tmpl reference to the template we belong too 63 * @return boolean true if extra label is allowed, false otherwise 64 */ 65 function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl) 66 { 67 $seperator = $cell['size'] ? $cell['size'] : '/'; 68 $extension_data = (array) $value; 69 70 if (!is_array($value) || !count($value)) 71 { 72 $cell = soetemplate::empty_cell(); 73 $cell['label'] = $seperator; 74 return true; 75 } 76 $cell_name = $cell['name']; 77 $cell['name'] = ''; 78 $cell['type'] = 'hbox'; 79 $cell['size'] = 0; 80 81 foreach ($value as $id => $label) 82 { 83 $sep = soetemplate::empty_cell(); 84 $sep['label'] = $seperator; 85 soetemplate::add_child($cell,$sep); 86 unset($sep); 87 88 $button = soetemplate::empty_cell('button',$cell_name.'['.$id.']'); 89 $button['label'] = $label; 90 $button['onchange'] = 1; // display as link 91 $button['no_lang'] = $cell['no_lang']; 92 $button['help'] = $cell['help'] ? $cell['help'] : lang($label)."($i)"; 93 soetemplate::add_child($cell,$button); 94 unset($button); 95 } 96 return True; // extra Label Ok 97 } 98 99 /** 100 * postprocessing method, called after the submission of the form 101 * 102 * It has to copy the allowed/valid data from $value_in to $value, otherwise the widget 103 * will return no data (if it has a preprocessing method). The framework insures that 104 * the post-processing of all contained widget has been done before. 105 * 106 * Only used by select-dow so far 107 * 108 * @param string $name form-name of the widget 109 * @param mixed &$value the extension returns here it's input, if there's any 110 * @param mixed &$extension_data persistent storage between calls or pre- and post-process 111 * @param boolean &$loop can be set to true to request a re-submision of the form/dialog 112 * @param object &$tmpl the eTemplate the widget belongs too 113 * @param mixed &value_in the posted values (already striped of magic-quotes) 114 * @return boolean true if $value has valid content, on false no content will be returned! 115 */ 116 function post_process($name,&$value,&$extension_data,&$loop,&$tmpl,$value_in) 117 { 118 $value = ''; 119 120 foreach((array)$value_in as $id => $pressed) 121 { 122 if ($pressed && isset($extension_data[$id])) 123 { 124 $value = $id; 125 break; 126 } 127 } 128 //echo "<p>select_widget::post_process('$name',value=".print_r($value,true).",".print_r($extension_data,true).",,,value_in=".print_r($value_in,true).")</p>\n"; 129 return true; 130 } 131 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |