@@ -192,12 +192,28 @@
- ">
-
+
|
+
+
+ class="filter" name="" value=""/>
+ |
+
+
+
+ class="filter" name="" value=""/>
+ |
+
+
+
+ class="filter" name="" value="" size="5" />
+ class="filter" name="" value="" size="5" />
+ |
+
$Menus[''+'_sorting_menu'].addMenuItem('','direct_sort_grid("","","", null, );','2');
Index: branches/unlabeled/unlabeled-1.1.2/core/units/general/helpers/col_picker_helper.php
===================================================================
diff -u
--- branches/unlabeled/unlabeled-1.1.2/core/units/general/helpers/col_picker_helper.php (revision 0)
+++ branches/unlabeled/unlabeled-1.1.2/core/units/general/helpers/col_picker_helper.php (revision 6848)
@@ -0,0 +1,116 @@
+Application->RecallVar('user_id');
+ $var_name = 'new_'.$this->Prefix;
+ $q = "SELECT value FROM persistent_session WHERE var='$var_name' and user_id = $user_id";
+ $conn =& $this->Application->GetADODBConnection();
+ $val = $conn->GetOne($q);
+
+ if ($val == '') {
+ $this->PickerData = $this->RebuildColumns();
+ }
+ else {
+ $cols = unserialize($val);
+ $current_cols = $this->GetColumns();
+
+ if ($cols === false || $cols['crc'] != $current_cols['crc'])
+ {
+ $this->PickerData = $this->RebuildColumns($cols);
+ }
+ else {
+ $this->PickerData = $cols;
+ }
+ }
+ $fields =& $this->Application->NConfig[ $this->Owner->NKey ]['Fields'];
+ uksort($fields, array($this, 'CmpElems'));
+ $this->RemoveHiddenColumns($fields);
+ }
+
+ function CmpElems($a, $b)
+ {
+ $a_index = array_search($a, $this->PickerData['order']);
+ $b_index = array_search($b, $this->PickerData['order']);
+
+ if ($a_index == $b_index) {
+ return 0;
+ }
+ return ($a_index < $b_index) ? -1 : 1;
+ }
+
+ function RebuildColumns($current=null)
+ {
+ $cols = $this->GetColumns();
+
+ if (is_array($current)) {
+ //get common fields both in db and xml
+ $common = array_intersect($current['order'], $cols['order']);
+
+ //get added columns - present in xml, but not in db
+ $added = array_diff($cols['order'], $current['order']);
+
+ $cols['order'] = array_merge($common, $added);
+ $cols['hidden_fields'] = array_intersect($current['order'], $current['hidden_fields']);
+ $this->SetCRC($cols);
+ }
+
+ $conn =& $this->Application->GetADODBConnection();
+ $user_id = $this->Application->RecallVar('user_id');
+ $var_name = 'new_'.$this->Prefix;
+ $data = $conn->qstr(serialize($cols));
+ $q = "REPLACE INTO persistent_session (user_id, var, value) VALUES ($user_id, '$var_name', $data)";
+ $conn->Execute($q);
+ return $cols;
+ }
+
+ function GetColumns()
+ {
+ $conf_fields = $this->Application->NConfig[ $this->Owner->NKey ]['Fields'];
+
+ $counter = 0;
+ $hidden = array();
+ foreach ($conf_fields as $name => $options) {
+ $fields[$counter] = $name;
+ $titles[$name] = $options['title'];
+ if (isset($options['hidden']) && $options['hidden'])
+ {
+ $hidden[$counter] = $name;
+ }
+ $counter++;
+ }
+ $sorted_fields = $fields;
+ sort($sorted_fields);
+ $cols = array(
+ 'order' => $fields,
+ 'titles' => $titles,
+ 'hidden_fields' => $hidden
+ );
+ $this->SetCRC($cols);
+ return $cols;
+ }
+
+ function SetCRC(&$cols)
+ {
+ $sorted_fields = $cols['order'];
+ $sorted_titles = $cols['titles'];
+ asort($sorted_fields);
+ asort($sorted_titles);
+ $cols['crc'] = crc32(implode(',', $sorted_fields).implode(',', $sorted_titles));
+ }
+
+ function RemoveHiddenColumns(&$fields)
+ {
+ $to_remove = array();
+ foreach ($fields as $name => $options) {
+ if (array_search($name, $this->PickerData['hidden_fields']) !== false) {
+ $to_remove[] = $name;
+ }
+ }
+ foreach ($to_remove as $name) {
+ unset($fields[$name]);
+ }
+ }
+}
\ No newline at end of file