Index: branches/1.3.x/admin_templates/widgets/widget_edit.tpl =================================================================== diff -u -N -r15684 -r16396 --- branches/1.3.x/admin_templates/widgets/widget_edit.tpl (.../widget_edit.tpl) (revision 15684) +++ branches/1.3.x/admin_templates/widgets/widget_edit.tpl (.../widget_edit.tpl) (revision 16396) @@ -84,8 +84,9 @@ + - \ No newline at end of file + Index: branches/1.3.x/units/sections/sections_config.php =================================================================== diff -u -N -r16190 -r16396 --- branches/1.3.x/units/sections/sections_config.php (.../sections_config.php) (revision 16190) +++ branches/1.3.x/units/sections/sections_config.php (.../sections_config.php) (revision 16396) @@ -113,12 +113,12 @@ 'type' => stTREE, ), - 'custom:configuration_custom' => Array ( + 'custom:configuration_custom' => array( 'parent' => 'custom:setting_folder', - 'icon' => 'custom', + 'icon' => 'conf_output', 'label' => 'la_tab_ConfigOutput', - 'url' => Array('t' => 'config/config_universal', 'pass_section' => true, 'pass' => 'm'), - 'permissions' => Array('view', 'edit'), + 'url' => array('t' => 'config/config_universal', 'pass_section' => true, 'pass' => 'm'), + 'permissions' => array('view', 'edit'), 'priority' => 50, 'type' => stTREE, ), Index: branches/1.3.x/units/widgets/widget_eh.php =================================================================== diff -u -N -r16172 -r16396 --- branches/1.3.x/units/widgets/widget_eh.php (.../widget_eh.php) (revision 16172) +++ branches/1.3.x/units/widgets/widget_eh.php (.../widget_eh.php) (revision 16396) @@ -18,9 +18,10 @@ { parent::mapPermissions(); - $permissions = Array ( - 'OnItemBuild' => Array ('self' => true), - 'OnCustomEvent' => Array ('self' => true), + $permissions = array( + 'OnItemBuild' => array('self' => true), + 'OnRecalculatePriorities' => array('self' => 'add|edit'), + 'OnCustomEvent' => array('self' => true), ); $this->permMapping = array_merge($this->permMapping, $permissions); @@ -47,6 +48,65 @@ } /** + * Define alternative event processing method names + * + * @return void + */ + protected function mapEvents() + { + parent::mapEvents(); + + $events_map = array( + 'OnMassMoveUp' => 'OnChangePriority', + 'OnMassMoveDown' => 'OnChangePriority', + ); + + $this->eventMethods = array_merge($this->eventMethods, $events_map); + } + + /** + * Processes OnMassMoveUp, OnMassMoveDown events + * + * @param kEvent $event Event. + * + * @return void + */ + protected function OnChangePriority(kEvent $event) + { + $this->Application->SetVar('priority_prefix', $event->getPrefixSpecial()); + $event->CallSubEvent('priority:' . $event->Name); + } + + /** + * Completely recalculates priorities in current category + * + * @param kEvent $event Event. + * + * @return void + */ + protected function OnRecalculatePriorities(kEvent $event) + { + $this->Application->SetVar('priority_prefix', $event->getPrefixSpecial()); + $event->CallSubEvent('priority:' . $event->Name); + } + + /** + * [HOOK] Connects to priority unit. + * + * @param kEvent $event Event. + * + * @return void + */ + protected function OnModifyPrioritiesConfig(kEvent $event) + { + $config = $event->MasterEvent->getUnitConfig(); + + $prefixes = $config->getProcessPrefixes(); + $prefixes[] = $event->Prefix; + $config->setProcessPrefixes($prefixes); + } + + /** * Set custom query for the list * * @param kEvent $event Index: branches/1.3.x/install/install_schema.sql =================================================================== diff -u -N -r15496 -r16396 --- branches/1.3.x/install/install_schema.sql (.../install_schema.sql) (revision 15496) +++ branches/1.3.x/install/install_schema.sql (.../install_schema.sql) (revision 16396) @@ -12,6 +12,7 @@ BirthTime int(10) unsigned DEFAULT NULL, Image text, DataFile text, + Priority int(11) NOT NULL DEFAULT '0', PRIMARY KEY (WidgetId) ); Index: branches/1.3.x/install/upgrades.sql =================================================================== diff -u -N -r16214 -r16396 --- branches/1.3.x/install/upgrades.sql (.../upgrades.sql) (revision 16214) +++ branches/1.3.x/install/upgrades.sql (.../upgrades.sql) (revision 16396) @@ -71,6 +71,9 @@ # ===== v 1.2.1 ===== +# ===== v 1.2.2-B1 ===== +ALTER TABLE Widgets ADD `Priority` INT NOT NULL DEFAULT '0'; + # ===== v 1.3.0-B1 ===== UPDATE Modules SET ClassNamespace = 'InPortal\\Modules\\Custom' Index: branches/1.3.x/units/widgets/widgets_config.php =================================================================== diff -u -N -r16172 -r16396 --- branches/1.3.x/units/widgets/widgets_config.php (.../widgets_config.php) (revision 16172) +++ branches/1.3.x/units/widgets/widgets_config.php (.../widgets_config.php) (revision 16396) @@ -27,6 +27,19 @@ 5 => 'mode', ), + 'Hooks' => array( + array( + 'Mode' => hBEFORE, + 'Conditional' => false, + 'HookToPrefix' => 'priority', + 'HookToSpecial' => '*', + 'HookToEvent' => array('OnAfterConfigRead'), + 'DoPrefix' => '', + 'DoSpecial' => '*', + 'DoEvent' => 'OnModifyPrioritiesConfig', + ), + ), + 'IDField' => 'WidgetId', 'StatusField' => Array ('Status'), @@ -54,7 +67,7 @@ 'widget_list' => Array ( 'prefixes' => Array ('widget_List'), 'format' => '#section_label#', - 'toolbar_buttons' => Array ('new_item', 'edit', 'delete', 'approve', 'decline', 'export', 'import', 'view', 'dbl-click',), + 'toolbar_buttons' => array('new_item', 'edit', 'delete', 'approve', 'decline', 'move_up', 'move_down', 'refresh', 'export', 'import', 'view', 'dbl-click'), ), 'widget_edit' => Array ( @@ -87,8 +100,7 @@ 'ListSortings' => Array ( '' => Array ( -// 'ForcedSorting' => Array ('Priority' => 'desc'), - 'Sorting' => Array ('Title' => 'asc'), + 'Sorting' => array('Priority' => 'desc'), ) ), @@ -184,11 +196,22 @@ 'direct_links' => true, // use direct file urls or send files through wrapper (requires mod_mime_magic) 'default' => null ), + 'Priority' => array( + 'type' => 'int', + 'formatter' => 'kOptionsFormatter', 'options' => array(), + 'not_null' => 1, 'default' => 0, + ), ), 'Grids' => Array ( 'Default' => Array ( -// 'Icons' => Array ('default' => 'icon16_custom.gif'), + 'Icons' => array( + 'default' => 'icon16_item.png', + 1 => 'icon16_item.png', + 2 => 'icon16_pending.png', + 0 => 'icon16_disabled.png', + 'module' => 'core', + ), 'Fields' => Array ( 'WidgetId' => Array ('title' => 'column:la_fld_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter'), 'Title' => Array ('title' => 'column:la_fld_Name', 'data_block' => 'grid_custom_td'), @@ -202,6 +225,7 @@ 'CreatedOn' => Array ('filter_block' => 'grid_date_range_filter'), 'Description' => Array ('filter_block' => 'grid_like_filter'), 'VirtualActionField' => Array ('title' => 'column:la_fld_Action', 'data_block' => 'grid_delete_td'), + 'Priority' => array('filter_block' => 'grid_options_filter'), ), ), ), Index: branches/1.3.x/admin_templates/widgets/widget_list.tpl =================================================================== diff -u -N -r15496 -r16396 --- branches/1.3.x/admin_templates/widgets/widget_list.tpl (.../widget_list.tpl) (revision 15496) +++ branches/1.3.x/admin_templates/widgets/widget_list.tpl (.../widget_list.tpl) (revision 16396) @@ -70,6 +70,23 @@ a_toolbar.AddButton( new ToolBarSeparator('sep2') ); + a_toolbar.AddButton( new ToolBarButton('move_up', '', function() { + submit_event('', 'OnMassMoveUp'); + } + ) ); + + a_toolbar.AddButton( new ToolBarButton('move_down', '', function() { + submit_event('', 'OnMassMoveDown'); + } + ) ); + + a_toolbar.AddButton( new ToolBarButton('refresh', '', function() { + submit_event('', 'OnRecalculatePriorities'); + } + ) ); + + a_toolbar.AddButton( new ToolBarSeparator('sep3') ); + a_toolbar.AddButton( new ToolBarButton( 'export', @@ -90,7 +107,7 @@ ) ); - a_toolbar.AddButton( new ToolBarSeparator('sep3') ); + a_toolbar.AddButton( new ToolBarSeparator('sep4') ); a_toolbar.AddButton( new ToolBarButton( @@ -134,7 +151,7 @@ - \ No newline at end of file +