mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-03 06:38:57 +02:00
Merge branch '3.0'
This commit is contained in:
commit
2d63729cfe
@ -78,7 +78,7 @@ class CMSBatchAction_Delete extends CMSBatchAction {
|
||||
|
||||
}
|
||||
|
||||
return Convert::raw2json($status);
|
||||
return $this->response(_t('CMSBatchActions.DELETED_DRAFT_PAGES', 'Deleted %d pages from draft site, %d failures'), $status);
|
||||
}
|
||||
|
||||
function applicablePages($ids) {
|
||||
@ -123,7 +123,7 @@ class CMSBatchAction_DeleteFromLive extends CMSBatchAction {
|
||||
|
||||
}
|
||||
|
||||
return Convert::raw2json($status);
|
||||
return $this->response(_t('CMSBatchActions.DELETED_PAGES', 'Deleted %d pages from published site, %d failures'), $status);
|
||||
}
|
||||
|
||||
function applicablePages($ids) {
|
||||
|
@ -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: <URLSegment>/widget/<Widget-ID>.
|
||||
*
|
||||
* @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
|
||||
|
@ -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;
|
||||
}
|
@ -24,6 +24,8 @@
|
||||
// Constructor: onmatch
|
||||
onmatch : function() {
|
||||
var self = this;
|
||||
|
||||
self.data('OrigVal', self.val());
|
||||
|
||||
var form = self.parents('form');
|
||||
var url_segment = $('.field.urlsegment', form).find(':text');
|
||||
@ -33,14 +35,18 @@
|
||||
|
||||
if(url_segment.length > 0) {
|
||||
this.bind('change', function(e) {
|
||||
var origTitle = self.data('OrigVal');
|
||||
var title = self.val();
|
||||
self.data('OrigVal', title);
|
||||
|
||||
// Criteria for defining a "new" page
|
||||
if ((url_segment.val().indexOf('new') == 0) && live_url_segment.val() == '') {
|
||||
self.updateRelatedFields(title);
|
||||
self.updateURLSegment(title);
|
||||
} else {
|
||||
$('.update', self.parent()).show();
|
||||
}
|
||||
|
||||
self.updateRelatedFields(title, origTitle);
|
||||
self.updateBreadcrumbLabel(title);
|
||||
});
|
||||
}
|
||||
@ -54,12 +60,20 @@
|
||||
/**
|
||||
* Function: updateRelatedFields
|
||||
*
|
||||
* Update the related fields
|
||||
* (String) title
|
||||
* Update the related fields if appropriate
|
||||
* (String) title The new title
|
||||
* (Stirng) origTitle The original title
|
||||
*/
|
||||
updateRelatedFields: function(title) {
|
||||
var form = this.parents('form');
|
||||
form.find('input[name=MetaTitle], input[name=MenuTitle]').val(title);
|
||||
updateRelatedFields: function(title, origTitle) {
|
||||
// Update these fields only if their value was originally the same as the title
|
||||
this.parents('form').find('input[name=MetaTitle], input[name=MenuTitle]').each(function() {
|
||||
var $this = $(this);
|
||||
if($this.val() == origTitle) {
|
||||
$this.val(title);
|
||||
// Onchange bubbling didn't work in IE8, so .trigger('change') couldn't be used
|
||||
if($this.updatedRelatedFields) $this.updatedRelatedFields();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
@ -122,6 +136,13 @@
|
||||
*/
|
||||
$('.cms-edit-form input[name=MenuTitle]').entwine({
|
||||
onchange: function() {
|
||||
this.updatedRelatedFields();
|
||||
},
|
||||
|
||||
/**
|
||||
* Same as the onchange handler but callable as a method
|
||||
*/
|
||||
updatedRelatedFields: function() {
|
||||
var menuTitle = this.val();
|
||||
this.updateTreeLabel(menuTitle);
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user