function occindex($content = null) { if (is_array($content)) { if ($content['nm']['rows']['delete']) { list($id) = each($content['nm']['rows']['delete']); unset($content['nm']['rows']['delete']); if ($this->occ->delete(array('cp_occ_id' => $id))) { $content['msg'] = lang('Occurence deleted'); } else { $content['msg'] = lang('Delete failed!'); } } } else { $content['msg'] = $_GET['msg']; } // initializing of thwe nextmatch widget, through reading of stored sessiondata $content['nm'] = $GLOBALS['egw']->session->appsession('occ_session_data', 'courseprotocol'); $content['nm'] = array('get_rows' => 'courseprotocol.uicourseprotocol.get_rows_occ', 'filter_label' => '', 'filter_help' => '', 'no_filter' => True, 'no_filter2' => True, 'never_hide' => True, 'lettersearch' => False, 'searchletter' => '', 'start' => 0, 'order' => 'cp_occ_date', 'sort' => 'DESC', 'col_filter' => array(), 'default_cols' => '!cp_occ_analy'); $content['msg'] = $_GET['msg']; //_debug_array($content); $this->tmpl->read('courseprotocol.occindex'); $this->tmpl->set_cell_attribute('debuginfo', 'disabled', !$debug); $this->tmpl->set_cell_attribute('myhrule', 'disabled', !$separator); $this->tmpl->exec('courseprotocol.uicourseprotocol.occindex', $content, array('cp_occ_type' => $this->oc_types), array(), $preserv); // the debug info will be displayed at the very end of the page //_debug_array($content); }
function pre_process($name, &$value, &$cell, &$readonlys, &$extension_data, &$tmpl) { $nm_global =& $GLOBALS['phpgw_info']['etemplate']['nextmatch']; //echo "<p>nextmatch_widget.pre_process(name='$name',type='$cell[type]'): value = "; _debug_array($value); //echo "<p>nextmatch_widget.pre_process(name='$name',type='$cell[type]'): nm_global = "; _debug_array($nm_global); $extension_data = array('type' => $cell['type']); switch ($cell['type']) { case 'nextmatch-sortheader': $cell['type'] = 'button'; $cell['onchange'] = True; if (!$cell['help']) { $cell['help'] = 'click to order after that criteria'; } if ($this->last_part($name) == $nm_global['order']) { $cell[1] = $cell; $cell[1]['span'] .= ',activ_sortcolumn'; $cell[2] = $tmpl->empty_cell('image', $nm_global['sort'] != 'DESC' ? 'down' : 'up'); $cell['type'] = 'hbox'; $cell['size'] = '2,0,0'; $cell['name'] = $cell['label'] = ''; } else { $cell['span'] .= ',inactiv_sortcolumn'; } return True; case 'nextmatch-filterheader': $cell['type'] = 'select'; if (!$cell['size']) { $cell['size'] = 'All'; } if (!$cell['help']) { $cell['help'] = 'select which values to show'; } $cell['onchange'] = True; $extension_data['old_value'] = $value = $nm_global['col_filter'][$this->last_part($name)]; return True; } list($app, $class, $method) = explode('.', $value['get_rows']); $obj = CreateObject($app . '.' . $class); if (!is_object($obj) || !method_exists($obj, $method)) { echo "<p>nextmatch_widget::pre_process({$name}): '{$value['get_rows']}' is no valid method !!!</p>\n"; //return; } else { $total = $value['total'] = $obj->{$method}($value, $value['rows'], $readonlys['rows']); } if ($value['start'] > $total) { $value['start'] = 0; $total = $obj->{$method}($value, $value['rows'], $readonlys['rows']); } list($template, $options) = explode(',', $cell['size']); if ($template) { $value['template'] = $template; } if (!is_object($value['template'])) { $value['template'] = new etemplate($value['template'], $tmpl->as_array()); } if ($total < 1) { $value['template']->data[0]['h2'] = ',1'; // disable the data row } $max = $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']; if ($total <= $max && $options && $value['search'] == '' && ($value['no_cat'] || !$value['cat_id']) && ($value['no_filter'] || !$value['filter'] || $value['filter'] == 'none') && ($value['no_filter2'] || !$value['filter2'] || $value['filter2'] == 'none')) { // disable whole nextmatch line if no scrolling necessary if ($value['header_left'] || $value['header_right']) { $nextmatch = new etemplate('etemplate.nextmatch_widget.header_only'); $cell['size'] = $cell['name']; $cell['obj'] =& $nextmatch; $cell['name'] = $nextmatch->name; } else { $cell['size'] = $cell['name'] . '[rows]'; $cell['obj'] =& $value['template']; $cell['name'] = $value['template']->name; } } else { $nextmatch = new etemplate('etemplate.nextmatch_widget'); if ($value['no_cat']) { $nextmatch->disable_cells('cat_id'); } if ($value['no_filter']) { $nextmatch->disable_cells('filter'); } if ($value['no_filter2']) { $nextmatch->disable_cells('filter2'); } $start = $value['start']; $end = $start + $max > $total ? $total : $start + $max; $value['range'] = $total ? 1 + $start . ' - ' . $end : '0'; $nextmatch->set_cell_attribute('first', 'readonly', $start <= 0); $nextmatch->set_cell_attribute('left', 'readonly', $start <= 0); $nextmatch->set_cell_attribute('right', 'readonly', $start + $max >= $total); $nextmatch->set_cell_attribute('last', 'readonly', $start + $max >= $total); $cell['size'] = $cell['name']; $cell['obj'] =& $nextmatch; $cell['name'] = $nextmatch->name; } $cell['type'] = 'template'; $cell['label'] = $cell['help'] = ''; // save values in persistent extension_data to be able use it in post_process $extension_data += $value; foreach (array('sort', 'order', 'col_filter') as $n) { $nm_global[$n] = $value[$n]; } $value['bottom'] = $value; // copy the values for the bottom-bar return False; // NO extra Label }
function pre_process($form_name, &$value, &$cell, &$readonlys, &$extension_data, &$tmpl) { $dom_enabled = 0; //$GLOBALS['phpgw_info']['etemplate']['dom_enabled']; $labels = explode('|', $cell['label']); $helps = explode('|', $cell['help']); $names = explode('|', $cell['name']); $tab = new etemplate('etemplate.tab_widget.tab' . ($dom_enabled ? '_dom' : '')); $tab_active = new etemplate('etemplate.tab_widget.tab_active'); $tabs = new etemplate(); $tabs->init('*** generated tabs', '', '', 0, '', 0, 0); // make an empty template foreach ($names as $k => $name) { if (!strstr($name, '.')) { $name = $names[$k] = $tmpl->name . '.' . $name; } if ($extension_data == $name) { $selected_tab = $name; } } if (empty($selected_tab)) { $extension_data = $selected_tab = $names[0]; } $tab_row = array(); // generate the tab row while (list($k, $name) = each($names)) { if (!strstr($name, '.')) { $name = $names[$k] = $tmpl->name . '.' . $name; } $tcell = $tabs->empty_cell(); if ($extension_data == $name) { // save selected tab in persistent extension_data to use it in post_process $selected_tab = $name; $tcell['obj'] = $tab_active; $tcell['name'] = $tab_active->name; } else { $tcell['obj'] = $tab; $tcell['name'] = $tab->name; } if ($dom_enabled) { $tcell['obj']->set_cell_attribute('tab', 'onclick', "activate_tab('{$name}','{$cell['name']}');"); $tcell['obj']->set_cell_attribute('tab', 'id', $name . '-tab'); } $tcell['type'] = 'template'; $tcell['size'] = $cell['name'] . '[' . $name . ']'; $value[$name] = array('name' => $name, 'label' => $labels[$k], 'help' => $helps[$k]); $tab_row[$tabs->num2chrs($k)] = $tcell; } // add one empty cell to take all the space of the row $tab_row[$k = $tabs->num2chrs(sizeof($tab_row))] = $tabs->empty_cell(); $tabs->data[0][$k] = '99%'; // width $tabs->data[0]['c1'] = ',bottom'; $tabs->data[1] = $tab_row; $tabs->set_rows_cols(); $tabs->size = "{$cell['width']},,,0,0"; $tab_widget = new etemplate('etemplate.tab_widget'); $tab_widget->set_cell_attribute('@tabs', 'obj', $tabs); if ($dom_enabled) { $tab_widget->set_cell_attribute('@body', 'type', 'deck'); $tab_widget->set_cell_attribute('@body', 'width', $cell['width']); $tab_widget->set_cell_attribute('@body', 'height', $cell['height']); $tab_widget->set_cell_attribute('@body', 'size', count($names)); $tab_widget->set_cell_attribute('@body', 'class', $cell['class']); foreach ($names as $n => $name) { $bcell = $tab_widget->empty_cell(); $bcell['type'] = 'template'; $bcell['obj'] = new etemplate($name, $tmpl->as_array()); $bcell['name'] = $name; $tab_widget->set_cell_attribute('@body', $n + 1, $bcell); } $tab_widget->set_cell_attribute('@body', 'name', $cell['name']); } else { $stab = new etemplate($selected_tab, $tmpl->as_array()); $options = array_pad(explode(',', $stab->size), 3, ''); $options[3] = ($options[3] != '' ? $options[3] . ' ' : '') . 'tab_body'; $stab->size = implode(',', $options); $tab_widget->set_cell_attribute('@body', 'obj', $stab); } $tab_widget->set_cell_attribute('@body', 'name', $selected_tab); $cell['type'] = 'template'; $cell['obj'] =& $tab_widget; $cell['label'] = $cell['help'] = ''; return False; // NO extra Label }
function pre_process($name, &$value, &$cell, &$readonlys, &$extension_data, &$tmpl) { if ($cell['type'] == 'link-to' && ($cell['readonly'] || $readonlys)) { // readonly ==> omit the whole widget $cell = $tmpl->empty_cell(); return; } if ($cell['type'] == 'link-string') { $str = ''; if (is_array($value)) { foreach ($value as $link) { $str .= ($str !== '' ? ', ' : '') . $tmpl->html->a_href($tmpl->html->htmlspecialchars($this->link->title($link['app'], $link['id'])), $this->link->view($link['app'], $link['id'], $link)); } } $cell['type'] = 'html'; $cell['readonly'] = True; // is allways readonly $value = $str; return True; } if (!is_array($value)) { $value = array('to_id' => $value, 'to_app' => $GLOBALS['phpgw_info']['flags']['currentapp']); } if ($this->debug) { echo "<p>start: {$cell['type']}[{$name}]::pre_process: value ="; _debug_array($value); echo "extension_data[{$cell['type']}][{$name}] ="; _debug_array($extension_data); } switch ($type = $cell['type']) { case 'link-to': if ($value['button'] == 'upload' && !empty($value['file']) && $value['file']['tmp_name'] != 'none') { $value = $extension_data; $value['remark'] = ''; $tpl = new etemplate('etemplate.link_widget.attach'); } elseif ($value['button'] == 'search' && count($ids = $this->link->query($value['app'], $value['query']))) { $extension_data['app'] = $value['app']; $value = $extension_data; $value['options-id'] = $ids; $value['remark'] = ''; $tpl = new etemplate('etemplate.link_widget.create'); } else { if (!$value['button']) { $extension_data = $value; } $value = array_merge($extension_data, $value); $value['options-app'] = $this->link->app_list(); $tpl = new etemplate('etemplate.link_widget.search'); $tpl->set_cell_attribute('msg', 'disabled', $value['button'] != 'search'); } break; case 'link-list': $app = $value['to_app']; $id = isset($extension_data['to_id']) ? $extension_data['to_id'] : $value['to_id']; if ($this->debug) { echo "<p>link-list-widget[{$name}].preprocess: value="; _debug_array($value); } if (!isset($value['title'])) { $value['title'] = $this->link->title($app, $id); } $links = $this->link->get_links($app, $id); $value['anz_links'] = count($links); $extension_data = $value; if (!count($links)) { $cell = $tmpl->empty_cell(); $value = ''; return True; } $tpl = new etemplate('etemplate.link_widget.list'); $tpl->data[0]['A'] = $tmpl->data[0]['A']; // set width of first col like the tmpl. calling us for ($row = $tpl->rows - 1; list(, $link) = each($links); ++$row) { $value[$row] = $link; $value[$row]['title'] = $this->link->title($link['app'], $link['id'], $link); if (!is_array($link['id'])) { $value[$row]['view'] = $this->link->view($link['app'], $link['id'], $link); } } break; } $cell['size'] = $cell['name']; $cell['type'] = 'template'; $cell['name'] = $tpl->name; $cell['obj'] =& $tpl; if ($this->debug) { echo "<p>end: {$type}" . "[{$name}]::pre_process: value ="; _debug_array($value); } return True; // extra Label is ok }