Index: branches/unlabeled/unlabeled-1.75.2/core/kernel/db/db_event_handler.php =================================================================== diff -u -r6547 -r6575 --- branches/unlabeled/unlabeled-1.75.2/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 6547) +++ branches/unlabeled/unlabeled-1.75.2/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 6575) @@ -116,9 +116,10 @@ 'OnPreCreate' => Array('self' => 'add|add.pending'), 'OnEdit' => Array('self' => 'edit|edit.pending'), + 'OnExport' => Array('self' => 'view|advanced:export'), + 'OnExportBegin' => Array('self' => 'view|advanced:export'), - // theese event do not harm, but just in case check them too :) 'OnCancelEdit' => Array('self' => true, 'subitem' => true), 'OnCancel' => Array('self' => true, 'subitem' => true), @@ -1831,13 +1832,13 @@ $virtual_fields['cust_'.$custom_name] = array_merge_recursive2($field_options, $virtual_fields['cust_'.$custom_name]); $custom_fields[$custom_id] = $custom_name; } - + $config_calculated_fields = $this->Application->getUnitOption($main_prefix, 'CalculatedFields', Array()); foreach ($config_calculated_fields as $special => $special_fields) { $config_calculated_fields[$special] = array_merge_recursive2($config_calculated_fields[$special], $calculated_fields); } $this->Application->setUnitOption($main_prefix, 'CalculatedFields', $config_calculated_fields); - + $this->Application->setUnitOption($main_prefix, 'CustomFields', $custom_fields); $this->Application->setUnitOption($main_prefix, 'VirtualFields', $virtual_fields); } @@ -1881,6 +1882,100 @@ $this->finalizePopup($event); } + +/** EXPORT RELATED **/ + + /** + * Shows export dialog + * + * @param kEvent $event + */ + function OnExport(&$event) + { + $this->StoreSelectedIDs($event); + $selected_ids = $this->getSelectedIDs($event); + + if (implode(',', $selected_ids) == '') { + // K4 fix when no ids found bad selected ids array is formed + $selected_ids = false; + } + + $this->Application->StoreVar($event->Prefix.'_export_ids', $selected_ids ? implode(',', $selected_ids) : '' ); + + $export_t = $this->Application->GetVar('export_template'); + $this->Application->LinkVar('export_finish_t'); + $this->Application->LinkVar('export_progress_t'); + $this->Application->StoreVar('export_oroginal_special', $event->Special); + $export_helper =& $this->Application->recallObject('CatItemExportHelper'); + $event->redirect = $export_t ? $export_t : $export_helper->getModuleFolder($event).'/export'; + + $redirect_params = Array( 'm_opener' => 'd', + $this->Prefix.'.export_event' => 'OnNew', + 'pass' => 'all,'.$this->Prefix.'.export'); + + $event->setRedirectParams($redirect_params); + } + + /** + * Apply some special processing to + * object beeing recalled before using + * it in other events that call prepareObject + * + * @param Object $object + * @param kEvent $event + * @access protected + */ + function prepareObject(&$object, &$event) + { + if ($event->Special == 'export' || $event->Special == 'import') + { + $export_helper =& $this->Application->recallObject('CatItemExportHelper'); + $export_helper->prepareExportColumns($event); + } + } + + /** + * Returns specific to each item type columns only + * + * @param kEvent $event + * @return Array + */ + function getCustomExportColumns(&$event) + { + return Array(); + } + + /** + * Export form validation & processing + * + * @param kEvent $event + */ + function OnExportBegin(&$event) + { + $export_helper =& $this->Application->recallObject('CatItemExportHelper'); + $export_helper->OnExportBegin($event); + } + + /** + * Enter description here... + * + * @param kEvent $event + */ + function OnExportCancel(&$event) + { + $this->OnGoBack($event); + } + + /** + * Allows configuring export options + * + * @param kEvent $event + */ + function OnBeforeExportBegin(&$event) + { + + } + }