Permalink
Browse files

Added Composer.json

Removed unused code in DOAP.php
  • Loading branch information...
1 parent 73b61aa commit d72681fa08112d168d2ed6c02acd91e25f103ae8 Aram Balakjian committed Nov 9, 2012
Showing with 55 additions and 60 deletions.
  1. +37 −59 code/DataObjects/DataObjectAsPage.php
  2. +1 −1 code/ModelAdmin/DataObjectAsPageAdmin.php
  3. +17 −0 composer.json
@@ -24,6 +24,10 @@ class DataObjectAsPage extends DataObject{
'Title' => 'Title',
'URLSegment' => 'URLSegment'
);
+
+ public static $indexes = array(
+ "URLSegment" => true
+ );
public static $default_sort = 'Created DESC';
@@ -71,80 +75,54 @@ public function getCMSActions()
if($this->ID)
{
- if($this->isVersioned)
- {
- if($this->isPublished() && $this->canPublish() && $this->canDeleteFromLive()) {
- // "unpublish"
+ if($this->isPublished() && $this->canPublish() && $this->canDeleteFromLive()) {
+ // "unpublish"
+ $minorActions->push(
+ FormAction::create('unpublish', _t('SiteTree.BUTTONUNPUBLISH', 'Unpublish'), 'delete')
+ ->setDescription(_t('SiteTree.BUTTONUNPUBLISHDESC', 'Remove this page from the published site'))
+ ->addExtraClass('ss-ui-action-destructive')->setAttribute('data-icon', 'unpublish')
+ );
+ }
+
+ if($this->canEdit()) {
+
+ if($this->canDelete()) {
+ // "delete"
$minorActions->push(
- FormAction::create('unpublish', _t('SiteTree.BUTTONUNPUBLISH', 'Unpublish'), 'delete')
- ->setDescription(_t('SiteTree.BUTTONUNPUBLISHDESC', 'Remove this page from the published site'))
- ->addExtraClass('ss-ui-action-destructive')->setAttribute('data-icon', 'unpublish')
+ FormAction::create('delete','Delete')->addExtraClass('delete ss-ui-action-destructive')
+ ->setAttribute('data-icon', 'decline')
);
- }
-
- if($this->canEdit()) {
-
- if($this->canDelete()) {
- // "delete"
+ }
+
+ if($this->hasChangesOnStage()) {
+ if($this->isPublished() && $this->canEdit()) {
+ // "rollback"
$minorActions->push(
- FormAction::create('delete','Delete')->addExtraClass('delete ss-ui-action-destructive')
- ->setAttribute('data-icon', 'decline')
+ FormAction::create('rollback', _t('SiteTree.BUTTONCANCELDRAFT', 'Cancel draft changes'), 'delete')
+ ->setDescription(_t('SiteTree.BUTTONCANCELDRAFTDESC', 'Delete your draft and revert to the currently published page'))
);
}
-
- if($this->hasChangesOnStage()) {
- if($this->isPublished() && $this->canEdit()) {
- // "rollback"
- $minorActions->push(
- FormAction::create('rollback', _t('SiteTree.BUTTONCANCELDRAFT', 'Cancel draft changes'), 'delete')
- ->setDescription(_t('SiteTree.BUTTONCANCELDRAFTDESC', 'Delete your draft and revert to the currently published page'))
- );
- }
- }
-
- if ($this->canCreate())
- {
- //Create the Duplicate action
- $minorActions->push( FormAction::create('duplicate', 'Duplicate')
- ->setDescription("Duplicate this item")
- );
- }
- // "save"
- $minorActions->push(
- FormAction::create('doSave',_t('CMSMain.SAVEDRAFT','Save Draft'))->setAttribute('data-icon', 'addpage')
- );
}
- if($this->canPublish()) {
- // "publish"
- $actions->push(
- FormAction::create('publish', _t('SiteTree.BUTTONSAVEPUBLISH', 'Save & Publish'))
- ->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')
- );
- }
- }
- else
- {
- if($this->canDelete()) {
- // "delete"
- $minorActions->push(
- FormAction::create('delete','Delete')->addExtraClass('delete ss-ui-action-destructive')
- ->setAttribute('data-icon', 'decline')
- );
- }
-
if ($this->canCreate())
{
//Create the Duplicate action
$minorActions->push( FormAction::create('duplicate', 'Duplicate')
->setDescription("Duplicate this item")
);
- }
-
+ }
// "save"
+ $minorActions->push(
+ FormAction::create('doSave',_t('CMSMain.SAVEDRAFT','Save Draft'))->setAttribute('data-icon', 'addpage')
+ );
+ }
+
+ if($this->canPublish()) {
+ // "publish"
$actions->push(
- FormAction::create('doSave',_t('CMSMain.SAVE','Save'))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'addpage')
- );
+ FormAction::create('publish', _t('SiteTree.BUTTONSAVEPUBLISH', 'Save & Publish'))
+ ->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')
+ );
}
}
@@ -27,7 +27,7 @@ function getEditForm($id = null, $fields = null) {
$gridFieldConfig->removeComponentsByType('GridFieldDeleteAction');
$gridFieldConfig->addComponent(new VersionedGridFieldDeleteAction());
}
-
+
return $form;
}
View
@@ -0,0 +1,17 @@
+{
+ "name": "silverstripe/dataobjectaspage",
+ "description": "Manage DataObjects through model admin but display them as pages on the site",
+ "type": "silverstripe-module",
+ "keywords": ["silverstripe", "dataobjectasapage"],
+ "authors": [
+ {
+ "name": "Aram Balakjian",
+ "email": "aram@aabweb.co.uk"
+ }
+ ],
+ "require":
+ {
+ "silverstripe/framework": "3.*",
+ "silverstripe/cms": "3.*"
+ }
+}

0 comments on commit d72681f

Please sign in to comment.