From 2ee0c0991b1eb231e5d01411152835ff46924da3 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Tue, 18 Nov 2008 01:48:50 +0000 Subject: [PATCH] Merged branches/2.3 git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@66109 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- _config.php | 1 + code/CMSMain.php | 32 +++++++++++++++++++-------- code/CMSMenu.php | 13 ++++++++--- code/LeftAndMain.php | 22 ++++++++++++------ css/cms_left.css | 20 ++++++++++++----- javascript/AssetAdmin.js | 2 +- javascript/LeftAndMain_right.js | 2 +- javascript/tinymce.template.js | 5 +++-- templates/Includes/AssetTableField.ss | 26 +++++++++++++--------- templates/Includes/ModelAdmin_left.ss | 4 +++- 10 files changed, 87 insertions(+), 40 deletions(-) diff --git a/_config.php b/_config.php index f6332bae..6f8f5b47 100644 --- a/_config.php +++ b/_config.php @@ -1,4 +1,5 @@ stat('url_base', true), + $this->stat('url_segment', true), // in case we want to change the segment + '/', // trailing slash needed if $action is null! + "$action" + ); + } + /** * Return the entire site tree as a nested set of ULs */ @@ -443,9 +457,9 @@ JS; public function addpage() { - $className = $_REQUEST['PageType'] ? $_REQUEST['PageType'] : "Page"; - $parent = $_REQUEST['ParentID'] ? $_REQUEST['ParentID'] : 0; - $suffix = $_REQUEST['Suffix'] ? "-" . $_REQUEST['Suffix'] : null; + $className = isset($_REQUEST['PageType']) ? $_REQUEST['PageType'] : "Page"; + $parent = isset($_REQUEST['ParentID']) ? $_REQUEST['ParentID'] : 0; + $suffix = isset($_REQUEST['Suffix']) ? "-" . $_REQUEST['Suffix'] : null; if(is_numeric($parent)) $parentObj = DataObject::get_by_id("SiteTree", $parent); @@ -465,7 +479,7 @@ JS; * @uses LeftAndMainDecorator->augmentNewSiteTreeItem() */ public function getNewItem($id, $setID = true) { - list($dummy, $className, $parentID, $suffix) = explode('-',$id); + list($dummy, $className, $parentID, $suffix) = array_pad(explode('-',$id),4,null); if(Translatable::is_enabled()) { if (!Translatable::is_default_lang()) { $originalItem = Translatable::get_original($className,Session::get("{$id}_originalLangID")); @@ -564,12 +578,12 @@ JS; public function revert($urlParams, $form) { $id = $_REQUEST['ID']; - $obj = DataObject::get_by_id("SiteTree", $id); + $record = DataObject::get_by_id("SiteTree", $id); if(isset($record) && $record && !$record->canEdit()) return Security::permissionFailure($this); - $obj->doRevertToLive(); + $record->doRevertToLive(); - $title = Convert::raw2js($obj->Title); + $title = Convert::raw2js($record->Title); FormResponse::get_page($id); FormResponse::add("$('sitetree').setNodeTitle($id, '$title');"); FormResponse::status_message(sprintf(_t('CMSMain.RESTORED',"Restored '%s' successfully",PR_MEDIUM,'Param %s is a title'),$title),'good'); @@ -793,7 +807,7 @@ HTML; FormResponse::add("\$('sitetree').setNodeTitle($page->ID, '$JS_title');"); } else { FormResponse::add("var node = $('sitetree').getTreeNodeByIdx('$page->ID');"); - FormResponse::add("if(node.parentTreeNode) node.parentTreeNode.removeTreeNode(node);"); + FormResponse::add("if(node && node.parentTreeNode) node.parentTreeNode.removeTreeNode(node);"); FormResponse::add("$('Form_EditForm').reloadIfSetTo($page->ID);"); } @@ -1069,7 +1083,7 @@ HTML; FormResponse::add("$('Form_EditForm').reloadIfSetTo($record->OldID);"); } else { FormResponse::add("var node = $('sitetree').getTreeNodeByIdx('$id');"); - FormResponse::add("if(node.parentTreeNode) node.parentTreeNode.removeTreeNode(node);"); + FormResponse::add("if(node && node.parentTreeNode) node.parentTreeNode.removeTreeNode(node);"); FormResponse::add("$('Form_EditForm').reloadIfSetTo($record->OldID);"); } } diff --git a/code/CMSMenu.php b/code/CMSMenu.php index 57141bc8..60c00419 100644 --- a/code/CMSMenu.php +++ b/code/CMSMenu.php @@ -60,7 +60,7 @@ class CMSMenu extends Object implements Iterator * @param string $code A unique identifier (used to create a CSS ID and as it's key in {@link $menu_items} * @param string $menuTitle The link's title in the CMS menu * @param string $url The url of the link - * @param integer $priority The menu priority (sorting order) of the menu item + * @param integer $priority The menu priority (sorting order) of the menu item. Higher priorities will be further left. * @return boolean The result of the operation. */ public static function add_link($code, $menuTitle, $url, $priority = -1) { @@ -82,8 +82,10 @@ class CMSMenu extends Object implements Iterator * @return boolean Success */ public static function add_menu_item($code, $menuTitle, $url, $controllerClass = null, $priority = -1) { + // If a class is defined, then force the use of that as a code. This helps prevent menu item duplication + if($controllerClass) $code = $controllerClass; + $menuItems = self::$menu_items; - if(isset($menuItems[$code])) return false; return self::replace_menu_item($code, $menuTitle, $url, $controllerClass, $priority); @@ -145,8 +147,13 @@ class CMSMenu extends Object implements Iterator public static function replace_menu_item($code, $menuTitle, $url, $controllerClass = null, $priority = -1) { $menuItems = self::$menu_items; $menuItems[$code] = new CMSMenuItem($menuTitle, $url, $controllerClass, $priority); + + $menuPriority = array(); + $i = 0; foreach($menuItems as $key => $menuItem) { - $menuPriority[$key] = $menuItem->priority; + $i++; + // This funny litle formula ensures that the first item added with the same priority will be left-most. + $menuPriority[$key] = $menuItem->priority*100 - $i; } array_multisort($menuPriority, SORT_DESC, $menuItems); diff --git a/code/LeftAndMain.php b/code/LeftAndMain.php index 524dc200..2273d23d 100644 --- a/code/LeftAndMain.php +++ b/code/LeftAndMain.php @@ -200,6 +200,9 @@ class LeftAndMain extends Controller { * @return string */ public function Link($action = null) { + // Handle missing url_segments + if(!$this->stat('url_segment', true)) + self::$url_segment = $this->class; return Controller::join_links( $this->stat('url_base', true), $this->stat('url_segment', true), @@ -287,11 +290,14 @@ class LeftAndMain extends Controller { $linkingmode = ""; - if(!(strpos($this->Link(), $menuItem->url) === false)) { + if(strpos($this->Link(), $menuItem->url) !== false) { + if($this->Link() == $menuItem->url) { + $linkingmode = "current"; + // default menu is the one with a blank {@link url_segment} - if(singleton($menuItem->controller)->stat('url_segment') == '') { - if($this->Link() == $this->stat('url_base').'/') - $linkingmode = "current"; + } else if(singleton($menuItem->controller)->stat('url_segment') == '') { + if($this->Link() == $this->stat('url_base').'/') $linkingmode = "current"; + } else { $linkingmode = "current"; } @@ -317,7 +323,6 @@ class LeftAndMain extends Controller { // if no current item is found, assume that first item is shown //if(!isset($foundCurrent)) - return $menu; } @@ -410,9 +415,12 @@ class LeftAndMain extends Controller { newNode.selectTreeNode(); JS; FormResponse::add($response); + + return FormResponse::respond(); + } else { + Director::redirect("admin/show/" . $p->ID); } - return FormResponse::respond(); } @@ -715,7 +723,7 @@ JS; $script = "st = \$('sitetree'); \n"; foreach($ids as $id) { if(is_numeric($id)) { - $record = DataObject::get_by_id($id); + $record = DataObject::get_by_id($this->stat('tree_class'), $id); if($record && !$record->canDelete()) return Security::permissionFailure($this); DataObject::delete_by_id($this->stat('tree_class'), $id); diff --git a/css/cms_left.css b/css/cms_left.css index 63d80471..855398af 100644 --- a/css/cms_left.css +++ b/css/cms_left.css @@ -121,6 +121,12 @@ ul.tree.multiselect li.selected span.a.unexpanded span.b { cursor: default; } + +ul.tree span.a a.notinmenu, ul.tree span.a a.notinmenu * { + color: #77A; +} + + ul.tree span.a a.disabled { color: #999; cursor: pointer; @@ -153,17 +159,17 @@ ul.tree .deleted { } /* Created on stage, never published */ -ul.tree ins, +ul.tree span.a a ins, ul.tree span.a a.notinmenu ins, #publication_key ins { color: orange; text-decoration : none; } /* Deleted on stage */ -ul.tree del, +ul.tree span.a a del, ul.tree span.a a.notinmenu del, #publication_key del { color: red; } -ul.tree span.modified, +ul.tree span.a span.modified, #publication_key span.modified { color: green; text-decoration : none; @@ -342,12 +348,16 @@ ul.tree li.untranslated a:visited { width: 70%; } -#right ins * { +#right ins, #right ins * { background-color: green; + color: white; + text-decoration: none; } -#right del *{ +#right del, #right del *{ background-color: red; + color: white; + text-decoration: strikethough; } #sitetree a.contents { diff --git a/javascript/AssetAdmin.js b/javascript/AssetAdmin.js index aff28727..5623a8b9 100755 --- a/javascript/AssetAdmin.js +++ b/javascript/AssetAdmin.js @@ -228,7 +228,7 @@ DragFileItem.prototype = { this.draggable = null; } } -DragFileItem.applyTo('#Form_EditForm_Files tr td.markingcheckbox div.dragfile'); +DragFileItem.applyTo('#Form_EditForm_Files tr .dragfile'); // Set up folder drop target DropFileItem = Class.create(); diff --git a/javascript/LeftAndMain_right.js b/javascript/LeftAndMain_right.js index a2375f12..36dd40f9 100755 --- a/javascript/LeftAndMain_right.js +++ b/javascript/LeftAndMain_right.js @@ -195,7 +195,7 @@ CMSForm.prototype = { } statusMessage(ss.i18n._t('CMSMAIN.SAVING'), null, true); - console.log(this.action+"?"+data); + new Ajax.Request(this.action, { method : this.method, postBody: data, diff --git a/javascript/tinymce.template.js b/javascript/tinymce.template.js index e22b21db..eee141c7 100755 --- a/javascript/tinymce.template.js +++ b/javascript/tinymce.template.js @@ -15,6 +15,7 @@ if((typeof tinyMCE != 'undefined')) { auto_resize : false, theme : "advanced", content_css : "$ContentCSS", + body_class : 'typography', document_base_url: "$BaseURL", urlconverter_callback : "nullConverter", @@ -25,10 +26,10 @@ if((typeof tinyMCE != 'undefined')) { theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_toolbar_parent : "right", - plugins : "template,contextmenu,table,emotions,paste,../../tinymce_ssbuttons,spellchecker", + plugins : "template,contextmenu,table,emotions,paste,../../tinymce_ssbuttons,../../tinymce_advcode,spellchecker", table_inline_editing : true, theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,separator,bullist,numlist,outdent,indent,hr,charmap", - theme_advanced_buttons2 : "undo,redo,separator,cut,copy,paste,pastetext,pasteword,spellchecker,separator,ssimage,ssflash,sslink,unlink,anchor,separator,template,code,separator,search,replace,selectall,visualaid,separator,tablecontrols", + theme_advanced_buttons2 : "undo,redo,separator,cut,copy,paste,pastetext,pasteword,spellchecker,separator,ssimage,ssflash,sslink,unlink,anchor,separator,template,advcode,separator,search,replace,selectall,visualaid,separator,tablecontrols", theme_advanced_buttons3 : "", spellchecker_languages : "$SpellcheckLangs", diff --git a/templates/Includes/AssetTableField.ss b/templates/Includes/AssetTableField.ss index be7bb622..2c6f195a 100755 --- a/templates/Includes/AssetTableField.ss +++ b/templates/Includes/AssetTableField.ss @@ -6,7 +6,8 @@ - <% if Markable %><% end_if %> + + <% if Markable %><% end_if %> <% control Headings %> <% end_control %> @@ -17,21 +18,24 @@ <% control Items %> - <% if Markable %><% end_if %> + <% end_if %> <% control Fields %> <% end_control %> <% if Can(show) %> - - <% end_if %> + + <% end_if %> <% if Can(edit) %> - - <% end_if %> - <% if Can(delete) %> + + <% end_if %> + <% if Can(delete) %> diff --git a/templates/Includes/ModelAdmin_left.ss b/templates/Includes/ModelAdmin_left.ss index 9a69d714..eb776446 100755 --- a/templates/Includes/ModelAdmin_left.ss +++ b/templates/Includes/ModelAdmin_left.ss @@ -1,3 +1,5 @@ +<% require javascript(jsparty/tabstrip/tabstrip.js) %> +<% require css(jsparty/tabstrip/tabstrip.css) %>
@@ -13,7 +15,7 @@

Search for:

   $Title
Drag
$MarkingCheckbox
+ Drag + + <% if Markable %>$MarkingCheckbox$Value - <% _t('SHOW', 'Show asset') %> - + <% _t('SHOW', 'Show asset') %> + - <% _t('EDIT', 'Edit asset') %> - + <% _t('EDIT', 'Edit asset') %> + <% _t('DELFILE', 'Delete this file') %>