From 3fbf57245c706ead38869ddb000e49cce1faea7b Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Fri, 22 Jun 2012 14:05:27 +1200 Subject: [PATCH] REMOVE: Remove action handler for widgets. (Trac #7174) The widget functionality has been moved into a module, and this URL handler was the last of the code still in the core app related to widgets. As well as this commit, there is a related change to the silverstripe-widgets module to add this feature there: https://github.com/silverstripe/silverstripe-widgets/commit/025ee424c4aa27f23513bad36cdaf136b3b9cb64 --- code/controllers/ContentController.php | 50 ------------------- css/_old/WidgetAreaEditor.css | 68 -------------------------- 2 files changed, 118 deletions(-) delete mode 100644 css/_old/WidgetAreaEditor.css diff --git a/code/controllers/ContentController.php b/code/controllers/ContentController.php index 8440bef8..847a54a8 100644 --- a/code/controllers/ContentController.php +++ b/code/controllers/ContentController.php @@ -22,10 +22,6 @@ class ContentController extends Controller { protected $dataRecord; - static $url_handlers = array( - 'widget/$ID!' => 'handleWidget' - ); - public static $allowed_actions = array( 'successfullyinstalled', 'deleteinstallfiles' // secured through custom code @@ -215,52 +211,6 @@ class ContentController extends Controller { throw new SS_HTTPResponse_Exception($response); } } - - /** - * Handles widgets attached to a page through one or more {@link WidgetArea} elements. - * Iterated through each $has_one relation with a {@link WidgetArea} - * and looks for connected widgets by their database identifier. - * Assumes URLs in the following format: /widget/. - * - * @return RequestHandler - */ - function handleWidget() { - $SQL_id = $this->request->param('ID'); - if(!$SQL_id) return false; - - // find WidgetArea relations - $widgetAreaRelations = array(); - $hasOnes = $this->dataRecord->has_one(); - if(!$hasOnes) return false; - foreach($hasOnes as $hasOneName => $hasOneClass) { - if($hasOneClass == 'WidgetArea' || is_subclass_of($hasOneClass, 'WidgetArea')) { - $widgetAreaRelations[] = $hasOneName; - } - } - - // find widget - $widget = null; - foreach($widgetAreaRelations as $widgetAreaRelation) { - if($widget) break; - $widget = $this->dataRecord->$widgetAreaRelation()->Widgets( - sprintf('"Widget"."ID" = %d', $SQL_id) - )->First(); - } - if(!$widget) user_error('No widget found', E_USER_ERROR); - - // find controller - $controllerClass = ''; - foreach(array_reverse(ClassInfo::ancestry($widget->class)) as $widgetClass) { - $controllerClass = "{$widgetClass}_Controller"; - if(class_exists($controllerClass)) break; - } - if(!$controllerClass) user_error( - sprintf('No controller available for %s', $widget->class), - E_USER_ERROR - ); - - return new $controllerClass($widget); - } /** * Get the project name diff --git a/css/_old/WidgetAreaEditor.css b/css/_old/WidgetAreaEditor.css deleted file mode 100644 index b84d0779..00000000 --- a/css/_old/WidgetAreaEditor.css +++ /dev/null @@ -1,68 +0,0 @@ -div.availableWidgetsHolder { - width: 30%; -} - -div.usedWidgetsHolder { - width: 66%; -} - -div.availableWidgetsHolder { - float: left; -} - -div.usedWidgetsHolder { - float: right; -} - -.NoWidgets { - padding: 50px; /* Make this nice and big and easily 'droppable' */ -} - -div.usedWidgets div.Widget, -div.availableWidgets div.Widget { - width: 98%; - border: 1px solid #ddd; - border-top: none; - margin-bottom: 5px; -} -div.widgetDescription p, -div.widgetFields { - padding: 0 8px; - color: #666; - font-size: 11px; -} - -p.deleteWidget { - margin: 0; - height: 22px; - line-height: 2.2; - font-size: 12px; -} -span.widgetDelete { - padding-left: 20px; - margin-right: 8px; - float: right; - background: url(../images/delete.gif) no-repeat left center; - cursor: pointer; -} -div.usedWidgets div.Widget h3, -div.availableWidgets div.Widget h3 { - font-size: 12px; - color: #fff; - line-height: 1.8; - padding: 0 5px; - margin: 0; -} - div.usedWidgets div.Widget h3 { - cursor: move; - background: #000 url(../images/handled-bg.png) right top; - } - div.availableWidgets div.Widget h3 { - cursor: pointer; - color: #444; - padding-right: 25px; - background: #ccc url(../images/add-bg.png) right center; - } - div.availableWidgets div.Widget h3:hover { - background: #ccc url(../images/add-bg-hover.png) right center; - }