Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Firesphere committed Apr 1, 2014
2 parents 34f1e52 + 295bdc0 commit 86de350
Show file tree
Hide file tree
Showing 15 changed files with 1,831 additions and 145 deletions.
339 changes: 339 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions _config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
Name: dashboard
---
Member:
extensions:
extensions:
[DashboardMember]

SiteConfig:
extensions:
[DashboardSiteConfig]
extensions:
[DashboardSiteConfig]
GridFieldDetailForm_ItemRequest:
extensions:
[DashboardItemEditForm]
4 changes: 4 additions & 0 deletions code/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class Dashboard extends LeftAndMain implements PermissionProvider {


private static $menu_icon = "dashboard/images/dashboard.png";



private static $tree_class = 'DashboardPanel';



Expand Down
9 changes: 4 additions & 5 deletions code/DashboardChart.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class DashboardChart extends ViewableData {
public $FontSize = 10;




/**
* @var string The position of the text on the chart
Expand Down Expand Up @@ -84,7 +84,7 @@ public static function create($title = null, $x_label = null, $y_label = null, $
* @param string The title of the chart
* @param string The label of the X axis
* @param string The label for the Y axis
* @param array The chart data, in x/y pairs
* @param array The chart data, in x/y pairs
*/
public function __construct($title = null, $x_label = null, $y_label = null, $chartData = array ()) {
if(!is_array($chartData)) {
Expand Down Expand Up @@ -162,11 +162,10 @@ public function setData($data) {
* @return SSViewer
*/
public function forTemplate() {
Requirements::javascript("https://www.google.com/jsapi");
Requirements::javascript("https://www.google.com/uds/api/visualization/1.0/31f9974bf1146091ae320c1219fdf695/format+en,default,corechart.I.js");
Requirements::javascript("dashboard/javascript/thirdparty/google_jsapi_visualization.js");
Requirements::javascript("dashboard/javascript/dashboard-chart.js");
return $this->renderWith('DashboardChart');
}


}
14 changes: 14 additions & 0 deletions code/extensions/DashboardItemEditForm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php


class DashboardItemEditForm extends Extension
{


public function updateItemEditForm($form) {
if($id = $this->owner->request->getVar('ID')) {
Injector::inst()->get("CMSMain")->setCurrentPageID($id);
$form->Fields()->push(new HiddenField('ID','', $id));
}
}
}
29 changes: 15 additions & 14 deletions code/panels/DashboardGridFieldPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
* @package Dashboard
*/
class DashboardGridFieldPanel extends DashboardPanel {



private static $db = array (
'Count' => 'Int',
'Count' => 'Int',
'GridFieldName' => 'Varchar'
);

Expand All @@ -33,7 +33,7 @@ class DashboardGridFieldPanel extends DashboardPanel {


private static $configure_on_create = true;




Expand Down Expand Up @@ -66,9 +66,9 @@ public function getDescription() {
*/
public function getPrimaryActions() {
if(!$this->SubjectPageID || !$this->GridFieldName) return false;
$actions = parent::getPrimaryActions();
$actions = parent::getPrimaryActions();
$actions->push(DashboardPanelAction::create(
$this->CreateModelLink(),
$this->CreateModelLink(),
_t('Dashboard.CREATENEWGRIDFIELD','Create new'),
"good"
));
Expand All @@ -85,9 +85,9 @@ public function getPrimaryActions() {
*/
public function getSecondaryActions() {
if(!$this->SubjectPageID || !$this->GridFieldName) return false;
$actions = parent::getPrimaryActions();
$actions = parent::getPrimaryActions();
$actions->push(DashboardPanelAction::create(
$this->ViewAllLink(),
$this->ViewAllLink(),
_t('Dashboard.VIEWALLGRIDFIELD','View all')
));
return $actions;
Expand All @@ -114,6 +114,7 @@ public function getConfiguration() {
->addExtraClass('no-chzn')
->setAttribute('data-lookupurl', $this->Link("gridsforpage"))
->setEmptyString("--- "._t('Dashboard.PLEASESELECT','Please select')." ---")
->setTemplate("DashboardDropdownField")
);
$fields->push(DropdownField::create("GridFieldName", _t('Dashboard.GRIDFIELDNAME','GridField name'), $grids)
->addExtraClass('no-chzn')
Expand Down Expand Up @@ -141,7 +142,7 @@ protected function getHierarchy($parentID, $level = 0) {
if($children->exists()) {
foreach($children as $child) {
$indent="";
for($i=0;$i<$level;$i++) $indent .= "&nbsp;&nbsp;";
for($i=0;$i<$level;$i++) $indent .= "&nbsp;&nbsp;";
$text = $child->Title;
$options[$child->ID] = empty($text) ? "<em>$indent Untitled</em>" : $indent.$text;
$options += $this->getHierarchy($child->ID, $level+1);
Expand Down Expand Up @@ -227,7 +228,7 @@ public function getGridFieldsFor(SiteTree $page) {
*/
protected function getGrid() {
if($this->SubjectPage()->exists() && $this->GridFieldName) {
if($grid = $this->SubjectPage()->getCMSFields()->dataFieldByName($this->GridFieldName)) {
if($grid = $this->SubjectPage()->getCMSFields()->dataFieldByName($this->GridFieldName)) {
$grid->setForm($this->Form());
return $grid;
}
Expand Down Expand Up @@ -268,10 +269,10 @@ protected function getTabForGrid() {
* @return ArrayList
*/
public function GridFieldItems() {
if($grid = $this->getGrid()) {
if($grid = $this->getGrid()) {
$list = $grid->getList()
->limit($this->Count)
->sort("LastEdited DESC");
->sort("LastEdited DESC");
$ret = ArrayList::create(array());
foreach($list as $record) {
$ret->push(ArrayData::create(array(
Expand All @@ -288,7 +289,7 @@ public function GridFieldItems() {
'Title' => $record->getTitle()
)));
}
return $ret;
return $ret;
}
}

Expand Down Expand Up @@ -319,7 +320,7 @@ public function PanelHolder() {
* @package Dashbaord
*/
class DashboardGridField_PanelRequest extends Dashboard_PanelRequest {

private static $allowed_actions = array(
"gridsforpage"
);
Expand All @@ -336,6 +337,6 @@ public function gridsforpage(SS_HTTPRequest $r) {
return Convert::array2json($this->panel->getGridFieldsFor(SiteTree::get()->byID($pageid)));
}



}
4 changes: 4 additions & 0 deletions code/panels/DashboardModelAdminPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ public function PluralModelName() {
*/
public function ModelAdminItems() {
if($this->ModelAdminModel) {
$SNG= Injector::inst()->get($this->ModelAdminModel);
if($SNG->hasExtension("Versioned")) {
Versioned::reading_stage("Stage");
}
$records = DataList::create($this->ModelAdminModel)
->limit($this->Count)
->sort("LastEdited DESC");
Expand Down
32 changes: 17 additions & 15 deletions code/panels/DashboardSectionEditorPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Uncle Cheese <[email protected]>
*/
class DashboardSectionEditorPanel extends DashboardPanel {


private static $db = array (
'ParentID' => 'Int',
Expand All @@ -24,8 +24,8 @@ class DashboardSectionEditorPanel extends DashboardPanel {


private static $configure_on_create = true;




public function getLabel() {
Expand Down Expand Up @@ -78,7 +78,7 @@ protected function getHierarchy($parentID, $level = 0) {
if($children->exists()) {
foreach($children as $child) {
$indent="";
for($i=0;$i<$level;$i++) $indent .= "&nbsp;&nbsp;";
for($i=0;$i<$level;$i++) $indent .= "&nbsp;&nbsp;";
if($child->AllChildren()->exists()) {
$text = $child->Title;
$options[$child->ID] = empty($text) ? "<em>$indent Untitled</em>" : $indent.$text;
Expand Down Expand Up @@ -110,24 +110,26 @@ protected function getPageTypes() {

public function getConfiguration() {
$fields = parent::getConfiguration();
$fields->push(DropdownField::create("ParentID","Section", $this->getHierarchy(0))
->addExtraClass("no-chzn")
$fields->push(TreeDropdownField::create("ParentID","Section","SiteTree")
->setFilterFunction(function($node){
return SiteTree::get()->filter("ParentID", $node->ID)->exists();
})
);
$fields->push(DropdownField::create("Subject", "Page type", $this->getPageTypes())
->addExtraClass("no-chzn")
);
$fields->push(TextField::create("Count",_t('DashboardRecentEdits.COUNT','Number of pages to display')));
$fields->push(TextField::create("Count",_t('DashboardRecentEdits.COUNT','Number of pages to display')));
return $fields;
}



public function getPrimaryActions() {
if(!$this->Subject || !$this->ParentID) return false;
$actions = parent::getPrimaryActions();
$actions = parent::getPrimaryActions();
$actions->push(DashboardPanelAction::create(
$this->CreatePageLink(),
sprintf(_t('Dashboard.CREATENEW','Create new %s'),$this->SubjectSingularName()),
$this->CreatePageLink(),
sprintf(_t('Dashboard.CREATENEW','Create new %s'),$this->SubjectSingularName()),
"good"
));
return $actions;
Expand All @@ -140,10 +142,10 @@ public function getSecondaryActions() {
$actions = parent::getSecondaryActions();
$actions->push(DashboardPanelAction::create(
$this->ViewAllLink(),
sprintf(_t('Dashboard.VIEWALL','View all %s'),$this->SubjectPluralName())
sprintf(_t('Dashboard.VIEWALL','View all %s'),$this->SubjectPluralName())
));
return $actions;

}


Expand All @@ -155,15 +157,15 @@ public function SectionItems() {
'ClassName' => $this->Subject
))
->limit($this->Count)
->sort("LastEdited DESC");
->sort("LastEdited DESC");
$ret = ArrayList::create(array());
foreach($set as $r) {
$ret->push(ArrayData::create(array(
'Title' => $r->Title,
'EditLink' => Injector::inst()->get("CMSPagesController")->Link("edit/show/{$r->ID}")
)));
}
return $ret;
return $ret;
}


Expand All @@ -174,7 +176,7 @@ public function SubjectSingularName() {


public function SubjectPluralName() {
return Injector::inst()->get($this->Subject)->i18n_plural_name();
return Injector::inst()->get($this->Subject)->i18n_plural_name();
}


Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
],
"require":
{
"silverstripe/framework": ">=3.1.x-dev,<4.0",
"silverstripe/cms": ">=3.1.x-dev,<4.0"
"silverstripe/framework": "~3.1",
"silverstripe/cms": "~3.1"
},
"replace": {"silverstripe/dashboard": "*"},

Expand Down
Loading

0 comments on commit 86de350

Please sign in to comment.