diff --git a/code/controllers/CMSMain.php b/code/controllers/CMSMain.php index 20b39eaa..9c00727d 100644 --- a/code/controllers/CMSMain.php +++ b/code/controllers/CMSMain.php @@ -303,6 +303,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr ->unsetValidator(); $form->loadDataFrom($this->request->getVars()); + $this->extend('updateSearchForm', $form); return $form; } @@ -700,6 +701,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr $columns->setFieldCasting(array( 'Created' => 'Datetime->Ago', 'LastEdited' => 'Datetime->Ago', + 'getTreeTitle' => 'HTMLText' )); $controller = $this; diff --git a/code/controllers/CMSPageHistoryController.php b/code/controllers/CMSPageHistoryController.php index 3f1e9606..3a076b65 100644 --- a/code/controllers/CMSPageHistoryController.php +++ b/code/controllers/CMSPageHistoryController.php @@ -97,8 +97,11 @@ class CMSPageHistoryController extends CMSMain { // Respect permission failures from parent implementation if(!($form instanceof Form)) return $form; + $nav = new SilverStripeNavigatorItem_ArchiveLink($record); + $form->setActions(new FieldList( - $revert = FormAction::create('doRollback', _t('CMSPageHistoryController.REVERTTOTHISVERSION', 'Revert to this version'))->setUseButtonTag(true) + $revert = FormAction::create('doRollback', _t('CMSPageHistoryController.REVERTTOTHISVERSION', 'Revert to this version'))->setUseButtonTag(true), + $navField = new LiteralField('ArchivedLink', $nav->getHTML()) )); $fields = $form->Fields(); @@ -106,8 +109,9 @@ class CMSPageHistoryController extends CMSMain { $fields->push(new HiddenField("ID")); $fields->push(new HiddenField("Version")); - $fields = $fields->makeReadonly(); - + $fields = $fields->makeReadonly(); + $navField->setAllowHTML(true); + foreach($fields->dataFields() as $field) { $field->dontEscape = true; $field->reserveNL = true; diff --git a/code/controllers/CMSSettingsController.php b/code/controllers/CMSSettingsController.php index 98afcd61..e0815272 100644 --- a/code/controllers/CMSSettingsController.php +++ b/code/controllers/CMSSettingsController.php @@ -5,6 +5,7 @@ class CMSSettingsController extends LeftAndMain { static $url_rule = '/$Action/$ID/$OtherID'; static $menu_priority = -1; static $menu_title = 'Settings'; + static $tree_class = 'SiteConfig'; public function getResponseNegotiator() { $neg = parent::getResponseNegotiator(); diff --git a/code/controllers/CMSSiteTreeFilter.php b/code/controllers/CMSSiteTreeFilter.php index e0ce0b92..d75ebfbe 100644 --- a/code/controllers/CMSSiteTreeFilter.php +++ b/code/controllers/CMSSiteTreeFilter.php @@ -173,46 +173,53 @@ class CMSSiteTreeFilter_Search extends CMSSiteTreeFilter { * * @return Array */ - function pagesIncluded() { + public function pagesIncluded() { + $sng = singleton('SiteTree'); $ids = array(); - $q = new SQLQuery(); - $q->setSelect(array('"ID"','"ParentID"')) - ->setFrom('"SiteTree"'); - $where = array(); - - $SQL_params = Convert::raw2sql($this->params); - foreach($SQL_params as $name => $val) { + + $query = new DataQuery('SiteTree'); + $query->setQueriedColumns(array('ID', 'ParentID')); + + foreach($this->params as $name => $val) { + $SQL_val = Convert::raw2sql($val); + switch($name) { - // Match against URLSegment, Title, MenuTitle & Content case 'Term': - if($val) $where[] = "\"URLSegment\" LIKE '%$val%' OR \"Title\" LIKE '%$val%' OR \"MenuTitle\" LIKE '%$val%' OR \"Content\" LIKE '%$val%'"; + $query->whereAny(array( + "\"URLSegment\" LIKE '%$SQL_val%'", + "\"Title\" LIKE '%$SQL_val%'", + "\"MenuTitle\" LIKE '%$SQL_val%'", + "\"Content\" LIKE '%$SQL_val%'" + )); break; - // Match against date + case 'LastEditedFrom': - if($val) $where[] = "\"LastEdited\" >= '$val'"; + $query->where("\"LastEdited\" >= '$SQL_val'"); break; + case 'LastEditedTo': - if($val) $where[] = "\"LastEdited\" <= '$val'"; + $query->where("\"LastEdited\" <= '$SQL_val'"); break; - // Match against exact ClassName + case 'ClassName': if($val && $val != 'All') { - $where[] = "\"ClassName\" = '$val'"; + $query->where("\"ClassName\" = '$SQL_val'"); } break; + default: - // Partial string match against a variety of fields - if(!empty($val) && singleton("SiteTree")->hasDatabaseField($name)) { - $where[] = "\"$name\" LIKE '%$val%'"; + if(!empty($val) && $sng->hasDatabaseField($name)) { + $filter = $sng->dbObject($name)->defaultSearchFilter(); + $filter->setValue($val); + $filter->apply($query); } } } - $q->setWhere(empty($where) ? '' : '(' . implode(') AND (',$where) . ')'); - foreach($q->execute() as $row) { - $ids[] = array('ID'=>$row['ID'],'ParentID'=>$row['ParentID']); + foreach($query->execute() as $row) { + $ids[] = array('ID' => $row['ID'], 'ParentID' => $row['ParentID']); } - + return $ids; } } diff --git a/code/controllers/ModelAsController.php b/code/controllers/ModelAsController.php index c1d260f8..c57bf45e 100644 --- a/code/controllers/ModelAsController.php +++ b/code/controllers/ModelAsController.php @@ -159,7 +159,11 @@ class ModelAsController extends Controller implements NestedController { 'SiteTree', "\"URLSegment\" = '$URLSegment'" . ($useParentIDFilter ? ' AND "ParentID" = ' . (int)$parentID : '') ); - if($pages && $pages->Count() == 1) return $pages->First(); + + if($pages && $pages->Count() == 1 && ($page = $pages->First())) { + $parent = $page->ParentID ? $page->Parent() : $page; + if($parent->isPublished()) return $page; + } } // Get an old version of a page that has been renamed. @@ -175,8 +179,9 @@ class ModelAsController extends Controller implements NestedController { $record = $query->execute()->first(); if($record && ($oldPage = DataObject::get_by_id('SiteTree', $record['RecordID']))) { + $oldParent = $oldPage->ParentID ? $oldPage->Parent() : $oldPage; // Run the page through an extra filter to ensure that all extensions are applied. - if(SiteTree::get_by_link($oldPage->RelativeLink())) return $oldPage; + if(SiteTree::get_by_link($oldPage->RelativeLink()) && $oldParent->isPublished()) return $oldPage; } } diff --git a/code/controllers/SilverStripeNavigator.php b/code/controllers/SilverStripeNavigator.php index 2241ddc2..e8e07ab8 100644 --- a/code/controllers/SilverStripeNavigator.php +++ b/code/controllers/SilverStripeNavigator.php @@ -308,10 +308,10 @@ class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem { function getHTML() { $this->recordLink = $this->record->AbsoluteLink(); - return "recordLink?archiveDate={$this->record->LastEdited}\" target=\"_blank\">". _t('ContentController.ARCHIVEDSITE', 'Archived Site') .""; + return "recordLink?archiveDate={$this->record->LastEdited}\" target=\"_blank\">". _t('ContentController.ARCHIVEDSITE', 'Preview version') .""; } - function getMessage() { + function getMessage() { if($date = Versioned::current_archived_date()) { $dateObj = Datetime::create(); $dateObj->setValue($date); diff --git a/code/model/SiteConfig.php b/code/model/SiteConfig.php index 758e0483..66da02cf 100644 --- a/code/model/SiteConfig.php +++ b/code/model/SiteConfig.php @@ -65,7 +65,8 @@ class SiteConfig extends DataObject implements PermissionProvider { $topLevelCreatorsGroupsField = ListboxField::create("CreateTopLevelGroups", _t('SiteTree.TOPLEVELCREATORGROUPS', "Top level creators")) ->setMultiple(true)->setSource($groupsMap) ) - ) + ), + new HiddenField('ID') ); $themeDropdownField->setEmptyString(_t('SiteConfig.DEFAULTTHEME', '(Use default theme)')); @@ -148,6 +149,13 @@ class SiteConfig extends DataObject implements PermissionProvider { return $actions; } + + /** + * @return String + */ + function CMSEditLink() { + return singleton('CMSSettingsController')->Link(); + } /** * Get the current sites SiteConfig, and creates a new one diff --git a/code/model/SiteTree.php b/code/model/SiteTree.php index a05cbda3..d10a1079 100644 --- a/code/model/SiteTree.php +++ b/code/model/SiteTree.php @@ -2712,16 +2712,10 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid if(isset($entities['Page.SINGULARNAME'])) $entities['Page.SINGULARNAME'][3] = FRAMEWORK_DIR; if(isset($entities['Page.PLURALNAME'])) $entities['Page.PLURALNAME'][3] = FRAMEWORK_DIR; - $types = ClassInfo::subclassesFor('SiteTree'); - foreach($types as $k => $type) { - $inst = singleton($type); - $entities[$type . '.DESCRIPTION'] = array( - $inst->stat('description'), - - 'Description of the page type (shown in the "add page" dialog)' - ); - } - + $entities[$this->class . '.DESCRIPTION'] = array( + $this->stat('description'), + 'Description of the page type (shown in the "add page" dialog)' + ); return $entities; } diff --git a/code/search/SearchForm.php b/code/search/SearchForm.php index 1b91f28b..579ebbc9 100644 --- a/code/search/SearchForm.php +++ b/code/search/SearchForm.php @@ -172,7 +172,8 @@ class SearchForm extends Form { // legacy usage: $data was defaulting to $_REQUEST, parameter not passed in doc.silverstripe.org tutorials if(!isset($data)) $data = $_REQUEST; - return Convert::raw2xml($data['Search']); + // The form could be rendered without the search being done, so check for that. + if (isset($data['Search'])) return Convert::raw2xml($data['Search']); } /** diff --git a/code/staticpublisher/FilesystemPublisher.php b/code/staticpublisher/FilesystemPublisher.php index e1d78e72..92a5082d 100644 --- a/code/staticpublisher/FilesystemPublisher.php +++ b/code/staticpublisher/FilesystemPublisher.php @@ -56,7 +56,7 @@ class FilesystemPublisher extends StaticPublisher { * with the filename 'index.html'. If you set the extension to PHP, then a simple PHP script will * be generated that can do appropriate cache & redirect header negotation. */ - function __construct($destFolder, $fileExtension = null) { + function __construct($destFolder = 'cache', $fileExtension = null) { // Remove trailing slash from folder if(substr($destFolder, -1) == '/') $destFolder = substr($destFolder, 0, -1); diff --git a/config.rb b/config.rb index 7838e4dc..f685460d 100644 --- a/config.rb +++ b/config.rb @@ -9,6 +9,7 @@ sass_dir = "scss" images_dir = "images" javascripts_dir = "javascript" output_style = :compact +line_comments = false # To enable relative paths to assets via compass helper functions. Uncomment: # relative_assets = true diff --git a/css/screen.css b/css/screen.css index 4d793a86..5b88d57d 100644 --- a/css/screen.css +++ b/css/screen.css @@ -18,7 +18,7 @@ .cms-content-tools #cms-content-treeview .cms-tree-expand-trigger { display: inline-block; margin: 0 0 2px 0; position: absolute; top: 8px; right: 4px; } .cms-content-tools #cms-content-treeview .cms-tree-expand-trigger span.ui-button-text { padding-right: 8px; } .cms-content-tools #cms-content-treeview .cms-tree .badge, .cms-content-tools #cms-content-treeview .cms-tree a > .jstree-icon { display: none; } -.cms-content-tools #cms-content-treeview .cms-tree a:hover > .text > .badge { display: inline-block; } +.cms-content-tools #cms-content-treeview .cms-tree a:hover > .text > .badge, .cms-content-tools #cms-content-treeview .cms-tree .jstree-clicked > .text > .badge { display: inline-block; } /** ------------------------------------------------------------------ URLSegment field ----------------------------------------------------------------- */ .field.urlsegment.disabled { color: #444; padding-left: 0px; margin-left: 0px; background: none; border-color: transparent; } diff --git a/javascript/SiteTreeURLSegmentField.js b/javascript/SiteTreeURLSegmentField.js index 83365a00..1d1a6e8f 100644 --- a/javascript/SiteTreeURLSegmentField.js +++ b/javascript/SiteTreeURLSegmentField.js @@ -160,7 +160,7 @@ // edit button editAction = $('