Index: branches/1.2.x/admin_templates/widgets/widget_edit.tpl
===================================================================
diff -u -r14579 -r16265
--- branches/1.2.x/admin_templates/widgets/widget_edit.tpl (.../widget_edit.tpl) (revision 14579)
+++ branches/1.2.x/admin_templates/widgets/widget_edit.tpl (.../widget_edit.tpl) (revision 16265)
@@ -84,8 +84,9 @@
+
-
\ No newline at end of file
+
Index: branches/1.2.x/admin_templates/widgets/widget_list.tpl
===================================================================
diff -u -r14562 -r16265
--- branches/1.2.x/admin_templates/widgets/widget_list.tpl (.../widget_list.tpl) (revision 14562)
+++ branches/1.2.x/admin_templates/widgets/widget_list.tpl (.../widget_list.tpl) (revision 16265)
@@ -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
+
Index: branches/1.2.x/install/upgrades.sql
===================================================================
diff -u -r16079 -r16265
--- branches/1.2.x/install/upgrades.sql (.../upgrades.sql) (revision 16079)
+++ branches/1.2.x/install/upgrades.sql (.../upgrades.sql) (revision 16265)
@@ -70,3 +70,6 @@
# ===== v 1.2.1-RC1 =====
# ===== v 1.2.1 =====
+
+# ===== v 1.2.2-B1 =====
+ALTER TABLE Widgets ADD `Priority` INT NOT NULL DEFAULT '0';
Index: branches/1.2.x/units/widgets/widget_eh.php
===================================================================
diff -u -r15342 -r16265
--- branches/1.2.x/units/widgets/widget_eh.php (.../widget_eh.php) (revision 15342)
+++ branches/1.2.x/units/widgets/widget_eh.php (.../widget_eh.php) (revision 16265)
@@ -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,63 @@
}
/**
+ * 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)
+ {
+ $prefixes = $this->Application->getUnitOption($event->MasterEvent->Prefix, 'ProcessPrefixes');
+ $prefixes[] = $event->Prefix;
+ $this->Application->setUnitOption($event->MasterEvent->Prefix, 'ProcessPrefixes', $prefixes);
+ }
+
+ /**
* Set custom query for the list
*
* @param kEvent $event
@@ -316,4 +374,4 @@
return true;
}
-}
\ No newline at end of file
+}
Index: branches/1.2.x/units/widgets/widgets_config.php
===================================================================
diff -u -r15942 -r16265
--- branches/1.2.x/units/widgets/widgets_config.php (.../widgets_config.php) (revision 15942)
+++ branches/1.2.x/units/widgets/widgets_config.php (.../widgets_config.php) (revision 16265)
@@ -28,6 +28,19 @@
5 => 'mode',
),
+ 'Hooks' => array(
+ array(
+ 'Mode' => hBEFORE,
+ 'Conditional' => false,
+ 'HookToPrefix' => 'priority',
+ 'HookToSpecial' => '*',
+ 'HookToEvent' => array('OnAfterConfigRead'),
+ 'DoPrefix' => '',
+ 'DoSpecial' => '*',
+ 'DoEvent' => 'OnModifyPrioritiesConfig',
+ ),
+ ),
+
// in case, when one method does everything
'RewriteListener' => 'WidgetRewriteListener',
@@ -61,7 +74,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 (
@@ -99,8 +112,7 @@
'ListSortings' => Array (
'' => Array (
-// 'ForcedSorting' => Array ('Priority' => 'desc'),
- 'Sorting' => Array ('Title' => 'asc'),
+ 'Sorting' => array('Priority' => 'desc'),
)
),
@@ -196,11 +208,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'),
@@ -214,6 +237,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'),
),
),
),
@@ -222,4 +246,4 @@
'PerPage' => 'Perpage_Widgets',
'ShortListPerPage' => 'Perpage_Widgets_Short',
),*/
-);
\ No newline at end of file
+);
Index: branches/1.2.x/install/install_schema.sql
===================================================================
diff -u -r14579 -r16265
--- branches/1.2.x/install/install_schema.sql (.../install_schema.sql) (revision 14579)
+++ branches/1.2.x/install/install_schema.sql (.../install_schema.sql) (revision 16265)
@@ -12,6 +12,7 @@
BirthTime int(10) unsigned DEFAULT NULL,
Image text,
DataFile text,
+ Priority int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (WidgetId)
);