Skip to content

Commit

Permalink
MINOR make widgetarea/editor more suitable for generic use (from r95086)
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@95654 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information
Sean Harvey committed Dec 16, 2009
1 parent 223dd0f commit e623c3d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
27 changes: 22 additions & 5 deletions code/WidgetAreaEditor.php
Expand Up @@ -5,7 +5,21 @@
* @subpackage content
*/
class WidgetAreaEditor extends FormField {
function __construct($name) {
/**
* 3 variables to hold titles for the template
*/
public $InUseTitle;
public $AvailableTitle;
public $ToAddTitle;

function __construct($name, $widgetClasses = array('Widget'), $maxWidgets = 0) {
$this->InUseTitle = _t('WidgetAreaEditor.ss', 'INUSE');
$this->AvailableTitle = _t('WidgetAreaEditor.ss', 'AVAILABLE');
$this->ToAddTitle = _t('WidgetAreaEditor.ss', 'TOADD');
$this->MaxWidgets = $maxWidgets;

$this->widgetClasses = $widgetClasses;

parent::__construct($name);
}

Expand All @@ -17,12 +31,15 @@ function FieldHolder() {
}

function AvailableWidgets() {
$classes = ClassInfo::subclassesFor('Widget');
array_shift($classes);

$widgets= new DataObjectSet();

foreach($classes as $class) {
$widgets->push(singleton($class));
foreach($this->widgetClasses as $widgetClass) {
$classes = ClassInfo::subclassesFor($widgetClass);
array_shift($classes);
foreach($classes as $class) {
$widgets->push(singleton($class));
}
}

return $widgets;
Expand Down
5 changes: 3 additions & 2 deletions javascript/lang/en_US.js
Expand Up @@ -32,6 +32,7 @@ if(typeof(ss) == 'undefined' || typeof(ss.i18n) == 'undefined') {
'AssetTableField.REALLYDELETE': 'Do you really want to delete the marked files?',
'AssetTableField.MOVING': 'Moving %s file(s)',
'SecurityAdmin.BATCHACTIONSDELETECONFIRM': "Do you really want to delete %s groups?",
'CMSMAIN.AddSearchCriteria': 'Add Criteria'
'CMSMAIN.AddSearchCriteria': 'Add Criteria',
'WidgetAreaEditor.TOOMANY': 'Sorry, you have reached the maximum number of widgets in this area'
});
}
}
8 changes: 4 additions & 4 deletions templates/WidgetAreaEditor.ss
@@ -1,7 +1,7 @@
<div class="WidgetAreaEditor" id="WidgetAreaEditor-$Name" name="$Name">
<div class="WidgetAreaEditor" id="WidgetAreaEditor-$Name" name="$Name"<% if MaxWidgets %> maxwidgets="$MaxWidgets"<% end_if %>>
<input type="hidden" id="$Name" name="$IdxField" value="$Value" />
<div class="availableWidgetsHolder">
<h2><% _t('AVAILABLE', 'Available Widgets') %></h2>
<h2>$AvailableTitle</h2>
<p>&nbsp;</p>
<div class="availableWidgets" id="availableWidgets-$Name">
<% if AvailableWidgets %>
Expand All @@ -16,8 +16,8 @@
</div>
</div>
<div class="usedWidgetsHolder">
<h2><% _t('INUSE', 'Widgets currently used') %></h2>
<p><% _t('TOADD', 'To add widgets, click on the purple header on the left') %></p>
<h2>$InUseTitle</h2>
<p>$ToAddTitle</p>

<div class="usedWidgets" id="usedWidgets-$Name">
<% if UsedWidgets %>
Expand Down

0 comments on commit e623c3d

Please sign in to comment.