Skip to content

Commit

Permalink
MINOR Reverted 'single instance only' feature from r79868, delayed un…
Browse files Browse the repository at this point in the history
…til later release (see #4277) (from r97182)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@102710 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information
chillu committed Apr 13, 2010
1 parent 88597e2 commit ffbcc5d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 62 deletions.
14 changes: 0 additions & 14 deletions code/CMSMain.php
Expand Up @@ -383,20 +383,6 @@ public function save($data, $form) {
$form->saveInto($record, true); $form->saveInto($record, true);
$record->write(); $record->write();


// if changed to a single_instance_only page type
if ($record->stat('single_instance_only')) {
FormResponse::add("jQuery('#sitetree li.{$record->ClassName}').addClass('{$record->stat('single_instance_only_css_class')}');");
FormResponse::add($this->hideSingleInstanceOnlyFromCreateFieldJS($record));
}
else {
FormResponse::add("jQuery('#sitetree li.{$record->ClassName}').removeClass('{$record->stat('single_instance_only_css_class')}');");
}
// if chnaged from a single_instance_only page type
$sampleOriginalClassObject = new $data['ClassName']();
if($sampleOriginalClassObject->stat('single_instance_only')) {
FormResponse::add($this->showSingleInstanceOnlyInCreateFieldJS($sampleOriginalClassObject));
}

// If the 'Save & Publish' button was clicked, also publish the page // If the 'Save & Publish' button was clicked, also publish the page
if (isset($data['publish']) && $data['publish'] == 1) { if (isset($data['publish']) && $data['publish'] == 1) {
$record->doPublish(); $record->doPublish();
Expand Down
48 changes: 0 additions & 48 deletions code/LeftAndMain.php
Expand Up @@ -589,54 +589,6 @@ public function save($data, $form) {


return $form->formHtmlContent(); return $form->formHtmlContent();
} }

/**
* Return a javascript snippet that hides a page type from Create dropdownfield
* if it's a single_instance_only page type and has been created in the site tree
*/
protected function hideSingleInstanceOnlyFromCreateFieldJS($createdPage) {
// Prepare variable to single_instance_only checking in javascript
$pageClassName = $createdPage->class;
$singleInstanceCSSClass = "";
$singleInstanceClassSelector = "." . $createdPage->stat('single_instance_only_css_class');
if ($createdPage->stat('single_instance_only')) {
$singleInstanceCSSClass = $createdPage->stat('single_instance_only_css_class');
}

return <<<JS
// if the current page type that was created is single_instance_only,
// hide it from the create dropdownlist afterward
singleSingleOnlyOfThisPageType = jQuery("#sitetree li.{$pageClassName}{$singleInstanceClassSelector}");
if (singleSingleOnlyOfThisPageType.length > 0) {
jQuery("#" + _HANDLER_FORMS.addpage + " option[@value={$pageClassName}]").remove();
}
JS;
}

/**
* Return a javascript snippet that that shows a single_instance_only page type
* in Create dropdownfield if there isn't any of its instance in the site tree
*/
protected function showSingleInstanceOnlyInCreateFieldJS($deletedPage) {
$className = $deletedPage->class;
$singularName = $deletedPage->singular_name();
$singleInstanceClassSelector = "." . $deletedPage->stat('single_instance_only_css_class');
return <<<JS
// show the hidden single_instance_only page type in the create dropdown field
singleSingleOnlyOfThisPageType = jQuery("#sitetree li.{$className}{$singleInstanceClassSelector}");
if (singleSingleOnlyOfThisPageType.length == 0) {
if(jQuery("#" + _HANDLER_FORMS.addpage + " option[@value={$className}]").length == 0) {
jQuery("#" + _HANDLER_FORMS.addpage + " select option").each(function(){
if ("{$singularName}".toLowerCase() >= jQuery(this).val().toLowerCase()) {
jQuery("<option value=\"{$className}\">{$singularName}</option>").insertAfter(this);
}
});
}
}
JS;
}


/** /**
* Ajax handler for updating the parent of a tree node * Ajax handler for updating the parent of a tree node
Expand Down

0 comments on commit ffbcc5d

Please sign in to comment.