diff --git a/code/controllers/AssetAdmin.php b/code/controllers/AssetAdmin.php index 31be0c69..6cc34ac7 100644 --- a/code/controllers/AssetAdmin.php +++ b/code/controllers/AssetAdmin.php @@ -211,8 +211,8 @@ JS // List view $fields->addFieldsToTab('Root.ListView', array( - $actionsComposite = Object::create('CompositeField', - Object::create('CompositeField', + $actionsComposite = CompositeField::create( + CompositeField::create( $uploadBtn, $addFolderBtn, $syncButton //TODO: add this into a batch actions menu as in https://github.com/silverstripe/silverstripe-design/raw/master/Design/ss3-ui_files-manager-list-view.jpg @@ -255,7 +255,7 @@ JS 'EditForm' => $this->AddForm() )); - if($this->isAjax()) { + if($request->isAjax()) { // Rendering is handled by template, which will call EditForm() eventually $content = $obj->renderWith($this->getTemplatesWithSuffix('_Content')); } else { @@ -311,7 +311,7 @@ JS $fields = $context->getSearchFields(); $actions = new FieldList( - Object::create('ResetFormAction', 'clear', _t('CMSMain_left.ss.CLEAR', 'Clear')) + ResetFormAction::create('clear', _t('CMSMain_left.ss.CLEAR', 'Clear')) ->addExtraClass('ss-ui-action-minor'), FormAction::create('doSearch', _t('CMSMain_left.ss.SEARCH', 'Search')) ); diff --git a/code/controllers/CMSFileAddController.php b/code/controllers/CMSFileAddController.php index 28f2b735..4d4a6e58 100644 --- a/code/controllers/CMSFileAddController.php +++ b/code/controllers/CMSFileAddController.php @@ -9,7 +9,7 @@ class CMSFileAddController extends LeftAndMain { // public function upload($request) { // $formHtml = $this->renderWith(array('AssetAdmin_UploadContent')); -// if($this->isAjax()) { +// if($request->isAjax()) { // return $formHtml; // } else { // return $this->customise(array( @@ -57,7 +57,7 @@ class CMSFileAddController extends LeftAndMain { $folder = $this->currentPage(); - $uploadField = Object::create('UploadField', 'AssetUploadField', ''); + $uploadField = UploadField::create('AssetUploadField', ''); $uploadField->setConfig('previewMaxWidth', 40); $uploadField->setConfig('previewMaxHeight', 30); $uploadField->addExtraClass('ss-assetuploadfield'); diff --git a/code/controllers/CMSMain.php b/code/controllers/CMSMain.php index 52c5203a..8015988a 100644 --- a/code/controllers/CMSMain.php +++ b/code/controllers/CMSMain.php @@ -49,7 +49,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr public function init() { // set reading lang - if(Object::has_extension('SiteTree', 'Translatable') && !$this->isAjax()) { + if(Object::has_extension('SiteTree', 'Translatable') && !$this->request->isAjax()) { Translatable::choose_site_locale(array_keys(Translatable::get_existing_content_languages('SiteTree'))); } @@ -141,7 +141,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr // Include custom CSS for tree icons inline, as the tree might be loaded // via Ajax, in which case we can't inject it into the HTML header easily through the HTTP response. $css = $this->generateTreeStylingCSS(); - if($this->isAjax()) { + if($this->request->isAjax()) { $html .= "\n"; } else { Requirements::customCSS($css); @@ -202,7 +202,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr $dateTo->setConfig('showcalendar', true); $actions = new FieldList( - Object::create('ResetFormAction', 'clear', _t('CMSMain_left.ss.CLEAR', 'Clear')) + ResetFormAction::create('clear', _t('CMSMain_left.ss.CLEAR', 'Clear')) ->addExtraClass('ss-ui-action-minor'), FormAction::create('doSearch', _t('CMSMain_left.ss.SEARCH', 'Search')) ); @@ -243,7 +243,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr * @return String Serialized JSON */ public function SiteTreeHints() { - $classes = ClassInfo::subclassesFor( $this->stat('tree_class') ); + $classes = ClassInfo::subclassesFor( $this->stat('tree_class') ); $def['Root'] = array(); $def['Root']['disallowedParents'] = array(); @@ -257,6 +257,26 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr // SiteTree::allowedChildren() returns null rather than an empty array if SiteTree::allowed_chldren == 'none' if($allowedChildren == null) $allowedChildren = array(); + + // Exclude SiteTree from possible Children + $possibleChildren = array_diff($allowedChildren, array("SiteTree")); + + // Find i18n - names and build allowed children array + foreach($possibleChildren as $child) { + $instance = singleton($child); + + if($instance instanceof HiddenClass) continue; + + if(!$instance->canCreate()) continue; + + // skip this type if it is restricted + if($instance->stat('need_permission') && !$this->can(singleton($class)->stat('need_permission'))) continue; + + $title = $instance->i18n_singular_name(); + + $def[$class]['allowedChildren'][] = array("ssclass" => $child, "ssname" => $title); + } + $allowedChildren = array_keys(array_diff($classes, $allowedChildren)); if($allowedChildren) $def[$class]['disallowedChildren'] = $allowedChildren; @@ -266,6 +286,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr $def[$class]['defaultChild'] = $defaultChild; $defaultParent = $obj->defaultParent(); + $parent = SiteTree::get_by_link($defaultParent); $id = $parent ? $parent->id : null; @@ -370,7 +391,6 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr } $result->sort('AddAction'); - return $result; } @@ -685,20 +705,12 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr $record->Title ) ); - - // Reload form, data and actions might have changed - $form = $this->getEditForm($record->ID); } else { $this->response->addHeader('X-Status', _t('LeftAndMain.SAVEDUP')); - - // Reload form, data and actions might have changed - $form = $this->getEditForm($record->ID); } - - return $form->forTemplate(); - } - + return $this->getResponseNegotiator()->respond($this->request); + } /** * @uses LeftAndMainExtension->augmentNewSiteTreeItem() @@ -836,9 +848,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr ) ); - $form = $this->getEditForm($record->ID); - - return $form->forTemplate(); + return $this->getResponseNegotiator()->respond($this->request); } /** @@ -890,10 +900,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr sprintf(_t('CMSMain.REMOVEDPAGE',"Removed '%s' from the published site"),$record->Title) ); - // Reload form, data and actions might have changed - $form = $this->getEditForm($record->ID); - - return $form->forTemplate(); + return $this->getResponseNegotiator()->respond($this->request); } /** @@ -1042,10 +1049,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr ) ); - // Reload form, data and actions might have changed - $form = $this->getEditForm($restoredPage->ID); - - return $form->forTemplate(); + return $this->getResponseNegotiator()->respond($this->request); } function duplicate($request) { diff --git a/code/controllers/CMSPageAddController.php b/code/controllers/CMSPageAddController.php index 95cdbb03..2caa06a0 100644 --- a/code/controllers/CMSPageAddController.php +++ b/code/controllers/CMSPageAddController.php @@ -16,6 +16,18 @@ class CMSPageAddController extends CMSPageEditController { * @return Form */ function AddForm() { + // If request send from rightclick-submenu, directly add Page + if(($pageType = $this->request->getVar('Type')) && ($parentID = $this->request->getVar('ParentID'))) { + $data = array( + "PageType" => (string)$pageType, + "ParentID" => $parentID, + "ParentModeField" => "child" + ); + $this->doAdd($data, null); + return; + } + + $record = $this->currentPage(); $pageTypes = array(); @@ -89,7 +101,7 @@ class CMSPageAddController extends CMSPageEditController { if($parentID = $this->request->getVar('ParentID')) { $form->Fields()->dataFieldByName('ParentID')->setValue((int)$parentID); } - + return $form; } diff --git a/code/controllers/CMSPageHistoryController.php b/code/controllers/CMSPageHistoryController.php index e1306a54..25ad3e9f 100644 --- a/code/controllers/CMSPageHistoryController.php +++ b/code/controllers/CMSPageHistoryController.php @@ -27,7 +27,7 @@ class CMSPageHistoryController extends CMSMain { function show($request) { $form = $this->ShowVersionForm($request->param('VersionID')); - if($this->isAjax()) { + if($request->isAjax()) { if($form) $content = $form->forTemplate(); else $content = $this->renderWith($this->getTemplatesWithSuffix('_Content')); } else { @@ -44,7 +44,7 @@ class CMSPageHistoryController extends CMSMain { $request->param('VersionID'), $request->param('OtherVersionID') ); - if($this->isAjax()) { + if($request->isAjax()) { $content = $form->forTemplate(); } else { $content = $this->customise(array('EditForm' => $form))->renderWith($this->getViewer('show')); @@ -258,7 +258,7 @@ class CMSPageHistoryController extends CMSMain { $form = $this->CompareVersionsForm($version1, $version2); // javascript solution, render into template - if($this->isAjax()) { + if($this->request->isAjax()) { return $this->customise(array( "EditForm" => $form ))->renderWith(array( @@ -293,7 +293,7 @@ class CMSPageHistoryController extends CMSMain { if(!$versionID) return; - if($this->isAjax()) { + if($request->isAjax()) { return $this->customise(array( "EditForm" => $this->ShowVersionForm($versionID) ))->renderWith(array( diff --git a/code/controllers/CMSSettingsController.php b/code/controllers/CMSSettingsController.php index b73dbb7c..b0ab5519 100644 --- a/code/controllers/CMSSettingsController.php +++ b/code/controllers/CMSSettingsController.php @@ -9,7 +9,7 @@ class CMSSettingsController extends CMSMain { /** * @return Form */ - function getEditForm($id = null) { + function getEditForm($id = null, $fields = null) { $siteConfig = SiteConfig::current_site_config(); $fields = $siteConfig->getCMSFields(); @@ -54,7 +54,7 @@ class CMSSettingsController extends CMSMain { return false; } - function Breadcrumbs() { + function Breadcrumbs($unlinked = false) { return new ArrayList(array( new ArrayData(array( 'Title' => $this->SectionTitle(), @@ -63,4 +63,4 @@ class CMSSettingsController extends CMSMain { )); } -} \ No newline at end of file +} diff --git a/code/controllers/ContentController.php b/code/controllers/ContentController.php index 872f12cf..a4a49205 100644 --- a/code/controllers/ContentController.php +++ b/code/controllers/ContentController.php @@ -133,7 +133,7 @@ class ContentController extends Controller { * * @return SS_HTTPResponse */ - public function handleRequest(SS_HTTPRequest $request, DataModel $model) { + public function handleRequest(SS_HTTPRequest $request, DataModel $model = null) { $child = null; $action = $request->param('Action'); $this->setModel($model); @@ -376,7 +376,7 @@ HTML; } else { if($date = Versioned::current_archived_date()) { Requirements::css(CMS_DIR . '/css/SilverStripeNavigator.css'); - $dateObj = Object::create('Datetime', $date, null); + $dateObj = Datetime::create($date, null); // $dateObj->setVal($date); return "
". _t('ContentController.ARCHIVEDSITEFROM') ."
" . $dateObj->Nice() . "
"; } @@ -526,4 +526,4 @@ HTML "Content" => $content, ); } -} \ No newline at end of file +} diff --git a/code/controllers/RootURLController.php b/code/controllers/RootURLController.php index 4200afcf..b118da3e 100644 --- a/code/controllers/RootURLController.php +++ b/code/controllers/RootURLController.php @@ -104,7 +104,7 @@ class RootURLController extends Controller { * @param SS_HTTPRequest $request * @return SS_HTTPResponse */ - public function handleRequest(SS_HTTPRequest $request, DataModel $model) { + public function handleRequest(SS_HTTPRequest $request, DataModel $model = null) { self::$is_at_root = true; $this->setModel($model); diff --git a/code/controllers/SilverStripeNavigator.php b/code/controllers/SilverStripeNavigator.php index 1c3acb45..b3ba5802 100644 --- a/code/controllers/SilverStripeNavigator.php +++ b/code/controllers/SilverStripeNavigator.php @@ -193,7 +193,7 @@ class SilverStripeNavigatorItem_CMSLink extends SilverStripeNavigatorItem { return (Controller::curr() instanceof CMSMain); } - function canView() { + function canView($member = null) { // Don't show in CMS return !(Controller::curr() instanceof CMSMain); } @@ -223,7 +223,7 @@ class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem { return Controller::join_links($this->record->AbsoluteLink(), '?stage=Stage'); } - function canView() { + function canView($member = null) { return ($this->record->hasExtension('Versioned') && $this->getDraftPage()); } @@ -267,7 +267,7 @@ class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem { return Controller::join_links($this->record->AbsoluteLink(), '?stage=Live'); } - function canView() { + function canView($member = null) { return ($this->record->hasExtension('Versioned') && $this->getLivePage()); } @@ -299,7 +299,7 @@ class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem { function getMessage() { if($date = Versioned::current_archived_date()) { - $dateObj = Object::create('Datetime'); + $dateObj = Datetime::create(); $dateObj->setValue($date); return "
". _t('ContentController.ARCHIVEDSITEFROM', 'Archived site from') ."
" . $dateObj->Nice() . "
"; } @@ -309,7 +309,7 @@ class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem { return $this->record->AbsoluteLink() . '?archiveDate=' . $date; } - function canView() { + function canView($member = null) { return ($this->record->hasExtension('Versioned') && $this->isArchived()); } diff --git a/code/model/ErrorPage.php b/code/model/ErrorPage.php index 0cd7342d..d8973b92 100644 --- a/code/model/ErrorPage.php +++ b/code/model/ErrorPage.php @@ -22,6 +22,8 @@ class ErrorPage extends Page { "ShowInSearch" => 0 ); + static $allowed_children = array(); + static $description = 'Custom content for different error cases (e.g. "Page not found")'; protected static $static_filepath = ASSETS_PATH; @@ -50,7 +52,7 @@ class ErrorPage extends Page { $response = new SS_HTTPResponse(); $response->setStatusCode($statusCode); - $response->setBody(file_get_contents($cachedPath)); + $response->setBody(file_get_contents($cachedPath)); return $response; } @@ -127,8 +129,8 @@ class ErrorPage extends Page { } } - function getCMSFields() { - $fields = parent::getCMSFields(); + function getCMSFields($params = null) { + $fields = parent::getCMSFields($params); $fields->addFieldToTab( "Root.Main", diff --git a/code/model/RedirectorPage.php b/code/model/RedirectorPage.php index 1fe2082e..9d5c30fe 100644 --- a/code/model/RedirectorPage.php +++ b/code/model/RedirectorPage.php @@ -27,6 +27,8 @@ class RedirectorPage extends Page { static $many_many = array( ); + static $allowed_children = array(); + /** * Returns this page if the redirect is external, otherwise * returns the target page. @@ -115,7 +117,7 @@ class RedirectorPage extends Page { } } - function getCMSFields() { + function getCMSFields($params = null) { Requirements::javascript(SAPPHIRE_DIR . "/javascript/RedirectorPage.js"); $fields = parent::getCMSFields(); @@ -180,4 +182,4 @@ class RedirectorPage_Controller extends Page_Controller { _t('RedirectorPage.HASBEENSETUP', 'A redirector page has been set up without anywhere to redirect to.') . "

"; } -} \ No newline at end of file +} diff --git a/code/model/SiteConfig.php b/code/model/SiteConfig.php index 1d9d537b..0a9d2d12 100644 --- a/code/model/SiteConfig.php +++ b/code/model/SiteConfig.php @@ -41,7 +41,7 @@ class SiteConfig extends DataObject implements PermissionProvider { * * @return FieldList */ - function getCMSFields() { + function getCMSFields($params = null) { Requirements::javascript(CMS_DIR . "/javascript/SitetreeAccess.js"); $groupsMap = DataList::create('Group')->map('ID', 'Breadcrumbs')->toArray(); @@ -56,13 +56,13 @@ class SiteConfig extends DataObject implements PermissionProvider { ), $tabAccess = new Tab('Access', $viewersOptionsField = new OptionsetField("CanViewType", _t('SiteConfig.VIEWHEADER', "Who can view pages on this site?")), - $viewerGroupsField = Object::create('ListboxField', "ViewerGroups", _t('SiteTree.VIEWERGROUPS', "Viewer Groups")) + $viewerGroupsField = ListboxField::create("ViewerGroups", _t('SiteTree.VIEWERGROUPS', "Viewer Groups")) ->setMultiple(true)->setSource($groupsMap), $editorsOptionsField = new OptionsetField("CanEditType", _t('SiteConfig.EDITHEADER', "Who can edit pages on this site?")), - $editorGroupsField = Object::create('ListboxField', "EditorGroups", _t('SiteTree.EDITORGROUPS', "Editor Groups")) + $editorGroupsField = ListboxField::create("EditorGroups", _t('SiteTree.EDITORGROUPS', "Editor Groups")) ->setMultiple(true)->setSource($groupsMap), $topLevelCreatorsOptionsField = new OptionsetField("CanCreateTopLevelType", _t('SiteConfig.TOPLEVELCREATE', "Who can create pages in the root of the site?")), - $topLevelCreatorsGroupsField = Object::create('ListboxField', "CreateTopLevelGroups", _t('SiteTree.TOPLEVELCREATORGROUPS', "Top level creators")) + $topLevelCreatorsGroupsField = ListboxField::create("CreateTopLevelGroups", _t('SiteTree.TOPLEVELCREATORGROUPS', "Top level creators")) ->setMultiple(true)->setSource($groupsMap) ) ) diff --git a/code/model/SiteTree.php b/code/model/SiteTree.php index cbb98c38..533c8a97 100644 --- a/code/model/SiteTree.php +++ b/code/model/SiteTree.php @@ -1007,9 +1007,6 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid static function prepopulate_permission_cache($permission = 'CanEditType', $ids, $batchCallback = null) { if(!$batchCallback) $batchCallback = "SiteTree::can_{$permission}_multiple"; - //PHP 5.1 requires an array rather than a string for the call_user_func function - $batchCallback=explode('::', $batchCallback); - if(is_callable($batchCallback)) { call_user_func($batchCallback, $ids, Member::currentUserID(), false); } else { @@ -1377,7 +1374,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid if((!$this->URLSegment || $this->URLSegment == 'new-page') && $this->Title) { $this->URLSegment = $this->generateURLSegment($this->Title); } else if($this->isChanged('URLSegment')) { - $filter = Object::create('URLSegmentFilter'); + $filter = URLSegmentFilter::create(); $this->URLSegment = $filter->filter($this->URLSegment); // If after sanitising there is no URLSegment, give it a reasonable default if(!$this->URLSegment) $this->URLSegment = "page-$this->ID"; @@ -1586,7 +1583,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid * @return string Generated url segment */ function generateURLSegment($title){ - $filter = Object::create('URLSegmentFilter'); + $filter = URLSegmentFilter::create(); $t = $filter->filter($title); // Fallback to generic page name if path is empty (= no valid, convertable characters) @@ -1748,7 +1745,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid * * @return FieldList The fields to be displayed in the CMS. */ - function getCMSFields() { + function getCMSFields($params = null) { require_once("forms/Form.php"); // Status / message // Create a status message for multiple parents @@ -1909,13 +1906,13 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid "CanViewType", _t('SiteTree.ACCESSHEADER', "Who can view this page?") ), - $viewerGroupsField = Object::create('ListboxField', "ViewerGroups", _t('SiteTree.VIEWERGROUPS', "Viewer Groups")) + $viewerGroupsField = ListboxField::create("ViewerGroups", _t('SiteTree.VIEWERGROUPS', "Viewer Groups")) ->setMultiple(true)->setSource($groupsMap), $editorsOptionsField = new OptionsetField( "CanEditType", _t('SiteTree.EDITHEADER', "Who can edit this page?") ), - $editorGroupsField = Object::create('ListboxField', "EditorGroups", _t('SiteTree.EDITORGROUPS', "Editor Groups")) + $editorGroupsField = ListboxField::create("EditorGroups", _t('SiteTree.EDITORGROUPS', "Editor Groups")) ->setMultiple(true)->setSource($groupsMap) ) ) @@ -2025,7 +2022,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid * @return FieldList The available actions for this page. */ function getCMSActions() { - $minorActions = Object::create('CompositeField')->setTag('fieldset')->addExtraClass('ss-ui-buttonset'); + $minorActions = CompositeField::create()->setTag('fieldset')->addExtraClass('ss-ui-buttonset'); $actions = new FieldList($minorActions); // "readonly"/viewing version that isn't the current version of the record @@ -2441,6 +2438,36 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } } + /** + * A flag provides the user with additional data about the current page status, + * for example a "removed from draft" status. Each page can have more than one status flag. + * Returns a map of a unique key to a (localized) title for the flag. + * The unique key can be reused as a CSS class. + * Use the 'updateStatusFlags' extension point to customize the flags. + * Example: "deletedonlive" => "Deleted" + * + * @return array + */ + function getStatusFlags() { + $flags = array(); + if($this->IsDeletedFromStage) { + if($this->ExistsOnLive) { + $flags['removedfromdraft'] = _t('SiteTree.REMOVEDFROMDRAFTSHORT', 'Removed from draft'); + } else { + $flags['deletedonlive'] = _t('SiteTree.DELETEDPAGESHORT', 'Deleted'); + } + } else if($this->IsAddedToStage) { + $flags['addedtodraft'] = _t('SiteTree.ADDEDTODRAFTSHORT', 'New'); + } else if($this->IsModifiedOnStage) { + $flags['modified'] = _t('SiteTree.MODIFIEDONDRAFTSHORT', 'Modified'); + } + + $this->extend('updateStatusFlags', $flags); + + return $flags; + } + + /** * @deprecated 3.0 Use getTreeTitle() */ @@ -2457,29 +2484,27 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } /** - * TitleWithStatus will return the title in an , or - * tag depending on its publication status. + * getTreeTitle will return three html DOM elements, an empty with + * the class 'jstree-pageicon' in front, following by a wrapping around its + * MenutTitle, then following by a indicating its publication status. * - * @return string + * @return string a html string ready to be directly used in a template */ function getTreeTitle() { - $text = Convert::raw2xml(str_replace(array("\n","\r"),"",$this->MenuTitle)); - if($this->IsDeletedFromStage) { - if($this->ExistsOnLive) { - $tag ="{$text} " . _t('SiteTree.REMOVEDFROMDRAFTSHORT', 'Removed from draft') . ""; - } else { - $tag ="{$text} ". _t('SiteTree.DELETEDPAGESHORT', 'Deleted') . ""; - } - } elseif($this->IsAddedToStage) { - $tag = "{$text} ". _t('SiteTree.ADDEDTODRAFTSHORT', 'New') . ""; - } elseif($this->IsModifiedOnStage) { - $tag = "{$text} " . _t('SiteTree.MODIFIEDONDRAFTSHORT', 'Modified') . ""; - } else { - $tag = ''; + $flags = $this->getStatusFlags(); + $treeTitle = sprintf( + "%s", + Convert::raw2xml(str_replace(array("\n","\r"),"",$this->MenuTitle)) + ); + foreach($flags as $class => $title) { + $treeTitle .= sprintf( + "%s", + Convert::raw2xml($class), + Convert::raw2xml($title) + ); } - - - return ($tag) ? "". $tag : "". $text; + + return $treeTitle; } /** diff --git a/code/model/SiteTreeFileExtension.php b/code/model/SiteTreeFileExtension.php index 9289c2e7..955bec9f 100644 --- a/code/model/SiteTreeFileExtension.php +++ b/code/model/SiteTreeFileExtension.php @@ -5,7 +5,7 @@ */ class SiteTreeFileExtension extends DataExtension { - function extraStatics() { + function extraStatics($class = null, $extension = null) { return array( 'belongs_many_many' => array( "BackLinkTracking" => "SiteTree", @@ -95,4 +95,4 @@ class SiteTreeFileExtension extends DataExtension { if(class_exists('Subsite')) Subsite::disable_subsite_filter(false); } -} \ No newline at end of file +} diff --git a/code/model/SiteTreeFolderExtension.php b/code/model/SiteTreeFolderExtension.php index 7ad8233d..2cfac2ed 100644 --- a/code/model/SiteTreeFolderExtension.php +++ b/code/model/SiteTreeFolderExtension.php @@ -1,13 +1,6 @@ push(new Tab("UnusedFiles", _t('Folder.UNUSEDFILESTAB', "Unused files"), - // new Folder_UnusedAssetsField($this) - // )); - } - + /** * Looks for files used in system and create where clause which contains all ID's of files. * @@ -52,4 +45,4 @@ class SiteTreeFolderExtension extends DataExtension { } return $where; } -} \ No newline at end of file +} diff --git a/code/reports/Report.php b/code/reports/Report.php index d4407989..7bfbf488 100644 --- a/code/reports/Report.php +++ b/code/reports/Report.php @@ -376,11 +376,11 @@ class SS_Report_FakeQuery extends SQLQuery { $this->sortColMethod = $sortColMethod; } - function limit($limit) { + function limit($limit, $offset = 0) { $this->limit = $limit; } - function unlimitedRowCount() { + function unlimitedRowCount($column = null) { $source = $this->obj->{$this->method}($this->params, null, null); return $source ? $source->Count() : 0; } @@ -509,8 +509,8 @@ abstract class SS_ReportWrapper extends SS_Report { return $this->baseReport->description(); } - function canView() { - return $this->baseReport->canView(); + function canView($member = null) { + return $this->baseReport->canView($member); } } diff --git a/code/staticpublisher/FilesystemPublisher.php b/code/staticpublisher/FilesystemPublisher.php index 2f1809f9..4de5dcda 100644 --- a/code/staticpublisher/FilesystemPublisher.php +++ b/code/staticpublisher/FilesystemPublisher.php @@ -102,8 +102,8 @@ class FilesystemPublisher extends StaticPublisher { // perform similar transformations to SiteTree::generateURLSegment() $urlSegment = str_replace('&','-and-',$urlSegment); $urlSegment = str_replace('&','-and-',$urlSegment); - $urlSegment = ereg_replace('[^A-Za-z0-9\/-]+','-',$urlSegment); - $urlSegment = ereg_replace('-+','-',$urlSegment); + $urlSegment = preg_replace('/[^A-Za-z0-9\/-]+/', '-', $urlSegment); + $urlSegment = preg_replace('/-+/', '-', $urlSegment); $urlSegment = trim($urlSegment, '/'); $filename = $urlSegment ? "$urlSegment.$this->fileExtension" : "index.$this->fileExtension"; diff --git a/code/widgets/Widget.php b/code/widgets/Widget.php index e564b6f0..8b174ea3 100644 --- a/code/widgets/Widget.php +++ b/code/widgets/Widget.php @@ -34,7 +34,7 @@ class Widget extends DataObject { static $cmsTitle = "Name of this widget"; static $description = "Description of what this widget does."; - function getCMSFields() { + function getCMSFields($params = null) { $fields = new FieldList(); $this->extend('updateCMSFields', $fields); return $fields; @@ -226,7 +226,7 @@ class Widget_Controller extends Controller { * @subpackage widgets */ class Widget_TreeDropdownField extends TreeDropdownField { - function FieldHolder() {} - function Field() {} + function FieldHolder($properties = array()) {} + function Field($properties = array()) {} } diff --git a/javascript/CMSMain.Tree.js b/javascript/CMSMain.Tree.js index 3ba1fe35..4b352cec 100644 --- a/javascript/CMSMain.Tree.js +++ b/javascript/CMSMain.Tree.js @@ -1,35 +1,57 @@ (function($) { $.entwine('ss', function($){ - $('.cms-tree').entwine({ getTreeConfig: function() { var config = this._super(); + var hints = this.getHints(); config.plugins.push('contextmenu'); config.contextmenu = { - 'items': { - 'create': null, - "rename": null, - "remove": null, - "ccp": null, - 'edit': { - 'label': ss.i18n._t('Tree.EditPage'), - 'action': function(obj) { - // TODO Fix hardcoding of link - $('.cms-container').loadPanel('admin/page/edit/show/' + obj.data('id')); + 'items': function(node) { + // Build a list for allowed children as submenu entries + var ssclass = node.data('ssclass'); + var id = node.data('id'); + + var allowedChildren = new Object; + $(hints[ssclass].allowedChildren).each( + function(key, val){ + allowedChildren["allowedchildren-" + key ] = { + 'label': '' + val.ssname, + '_class': 'class-' + val.ssclass, + 'action': function(obj) { + // TODO Fix hardcoding of link + $('.cms-container').loadPanel('admin/page/add/?ParentID=' + id + '&Type=' + val.ssclass); + } + }; } - }, - 'addsubpage': { - 'label': ss.i18n._t('Tree.AddSubPage'), - 'action': function(obj) { - // TODO Fix hardcoding of link - $('.cms-container').loadPanel('admin/page/add/?ParentID=' + obj.data('id')); - } - } - } + ); + var menuitems = + { + 'edit': { + 'label': ss.i18n._t('Tree.EditPage'), + 'action': function(obj) { + // TODO Fix hardcoding of link + $('.cms-container').loadPanel('admin/page/add/show/' + obj.data('id')); + } + } + }; + // Test if there are any allowed Children and thus the possibility of adding some + if(allowedChildren.hasOwnProperty('allowedchildren-0')) { + menuitems['addsubpage'] = { + 'label': ss.i18n._t('Tree.AddSubPage'), + 'action': function(obj) { + // TODO Fix hardcoding of link + $('.cms-container').loadPanel('admin/page/add/?ParentID=' + obj.data('id')); + }, + 'submenu': allowedChildren + }; + } + return menuitems; + } }; return config; } }); }); + }(jQuery)); \ No newline at end of file diff --git a/tasks/RemoveOrphanedPagesTask.php b/tasks/RemoveOrphanedPagesTask.php index 5790032b..1363490b 100644 --- a/tasks/RemoveOrphanedPagesTask.php +++ b/tasks/RemoveOrphanedPagesTask.php @@ -106,7 +106,7 @@ in the other stage:
$orphan->ID, $orphan->Title, $orphan->ID, - DBField::create('Date', $orphan->LastEdited)->Nice(), + Date::create($orphan->LastEdited)->Nice(), ($latestAuthor) ? $latestAuthor->Title : 'unknown', ($liveRecord) ? 'is published' : 'not published' ); diff --git a/templates/CMSPageEditController_Tools.ss b/templates/CMSPageEditController_Tools.ss index b3ed137a..524daa59 100644 --- a/templates/CMSPageEditController_Tools.ss +++ b/templates/CMSPageEditController_Tools.ss @@ -4,7 +4,7 @@
-
+
$SiteTreeAsUL
diff --git a/tests/controller/CMSMainTest.php b/tests/controller/CMSMainTest.php index 0a4988af..312fbbb3 100644 --- a/tests/controller/CMSMainTest.php +++ b/tests/controller/CMSMainTest.php @@ -47,8 +47,8 @@ class CMSMainTest extends FunctionalTest { $response = Director::test("admin/cms/batchactions/publish", array('csvIDs' => implode(',', array($page1->ID, $page2->ID)), 'ajax' => 1), $this->session()); $responseData = Convert::json2array($response->getBody()); - $this->assertTrue(property_exists($responseData['modified'], $page1->ID)); - $this->assertTrue(property_exists($responseData['modified'], $page2->ID)); + $this->assertArrayHasKey($page1->ID, $responseData['modified']); + $this->assertArrayHasKey($page2->ID, $responseData['modified']); } // Get the latest version of the redirector page diff --git a/tests/model/SiteTreeBacklinksTest.php b/tests/model/SiteTreeBacklinksTest.php index 69c3a1d9..7835155e 100644 --- a/tests/model/SiteTreeBacklinksTest.php +++ b/tests/model/SiteTreeBacklinksTest.php @@ -243,7 +243,7 @@ class SiteTreeBacklinksTest extends SapphireTest { } class SiteTreeBacklinksTest_DOD extends DataExtension implements TestOnly { - function extraStatics() { + function extraStatics($class = null, $extension = null) { return array( 'db' => array( 'ExtraContent' => 'HTMLText', @@ -251,7 +251,7 @@ class SiteTreeBacklinksTest_DOD extends DataExtension implements TestOnly { ); } - function updateCMSFields(&$fields) { + function updateCMSFields(FieldList $fields) { $fields->addFieldToTab("Root.Content", new HTMLEditorField("ExtraContent")); } } diff --git a/tests/model/SiteTreeTest.php b/tests/model/SiteTreeTest.php index 04b446f7..abc65192 100644 --- a/tests/model/SiteTreeTest.php +++ b/tests/model/SiteTreeTest.php @@ -17,6 +17,7 @@ class SiteTreeTest extends SapphireTest { 'SiteTreeTest_ClassD', 'SiteTreeTest_ClassCext', 'SiteTreeTest_NotRoot', + 'SiteTreeTest_StageStatusInherit', ); /** @@ -866,7 +867,15 @@ class SiteTreeTest extends SapphireTest { } if(!$isDetected) $this->fail('Fails validation with $can_be_root=false'); + } + + function testModifyStatusFlagByInheritance(){ + $node = new SiteTreeTest_StageStatusInherit(); + $treeTitle = $node->getTreeTitle(); + $this->assertContains('InheritedTitle', $treeTitle); + $this->assertContains('inherited-class', $treeTitle); } + } /**#@+ @@ -928,4 +937,12 @@ class SiteTreeTest_ClassCext extends SiteTreeTest_ClassC implements TestOnly { class SiteTreeTest_NotRoot extends Page implements TestOnly { static $can_be_root = false; +} + +class SiteTreeTest_StageStatusInherit extends SiteTree implements TestOnly { + function getStatusFlags(){ + $flags = parent::getStatusFlags(); + $flags['inherited-class'] = "InheritedTitle"; + return $flags; + } } \ No newline at end of file diff --git a/tests/model/VirtualPageTest.php b/tests/model/VirtualPageTest.php index de44a1a3..d556b5ef 100644 --- a/tests/model/VirtualPageTest.php +++ b/tests/model/VirtualPageTest.php @@ -607,7 +607,7 @@ class VirtualPageTest_VirtualPageSub extends VirtualPage implements TestOnly { } class VirtualPageTest_PageExtension extends DataExtension implements TestOnly { - function extraStatics() { + function extraStatics($class = null, $extension = null) { return array( 'db' => array( // These fields are just on an extension to simulate shared properties between Page and VirtualPage. @@ -617,4 +617,4 @@ class VirtualPageTest_PageExtension extends DataExtension implements TestOnly { ) ); } -} \ No newline at end of file +} diff --git a/tests/widgets/WidgetAreaEditorTest.php b/tests/widgets/WidgetAreaEditorTest.php index 2d258f2e..81eb76b5 100644 --- a/tests/widgets/WidgetAreaEditorTest.php +++ b/tests/widgets/WidgetAreaEditorTest.php @@ -460,7 +460,7 @@ class WidgetAreaEditorTest_TestWidget extends Widget implements TestOnly { static $db = array( 'Title' => 'Varchar' ); - public function getCMSFields() { + public function getCMSFields($params = null) { $fields = new FieldList(); $fields->push(new TextField('Title')); return $fields; @@ -468,4 +468,4 @@ class WidgetAreaEditorTest_TestWidget extends Widget implements TestOnly { function Title() { return $this->Title ? $this->Title : self::$title; } -} \ No newline at end of file +}