Merged branches/2.3

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@66109 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2008-11-18 01:48:50 +00:00
parent fe0ac4e990
commit 2ee0c0991b
10 changed files with 87 additions and 40 deletions

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Extended URL rules for the CMS module * Extended URL rules for the CMS module
* *

View File

@ -128,6 +128,20 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
//------------------------------------------------------------------------------------------// //------------------------------------------------------------------------------------------//
// Main UI components // Main UI components
/**
* Override {@link LeftAndMain} Link to allow blank URL segment for CMSMain.
*
* @return string
*/
public function Link($action = null) {
return Controller::join_links(
$this->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 * Return the entire site tree as a nested set of ULs
*/ */
@ -443,9 +457,9 @@ JS;
public function addpage() { public function addpage() {
$className = $_REQUEST['PageType'] ? $_REQUEST['PageType'] : "Page"; $className = isset($_REQUEST['PageType']) ? $_REQUEST['PageType'] : "Page";
$parent = $_REQUEST['ParentID'] ? $_REQUEST['ParentID'] : 0; $parent = isset($_REQUEST['ParentID']) ? $_REQUEST['ParentID'] : 0;
$suffix = $_REQUEST['Suffix'] ? "-" . $_REQUEST['Suffix'] : null; $suffix = isset($_REQUEST['Suffix']) ? "-" . $_REQUEST['Suffix'] : null;
if(is_numeric($parent)) $parentObj = DataObject::get_by_id("SiteTree", $parent); if(is_numeric($parent)) $parentObj = DataObject::get_by_id("SiteTree", $parent);
@ -465,7 +479,7 @@ JS;
* @uses LeftAndMainDecorator->augmentNewSiteTreeItem() * @uses LeftAndMainDecorator->augmentNewSiteTreeItem()
*/ */
public function getNewItem($id, $setID = true) { 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_enabled()) {
if (!Translatable::is_default_lang()) { if (!Translatable::is_default_lang()) {
$originalItem = Translatable::get_original($className,Session::get("{$id}_originalLangID")); $originalItem = Translatable::get_original($className,Session::get("{$id}_originalLangID"));
@ -564,12 +578,12 @@ JS;
public function revert($urlParams, $form) { public function revert($urlParams, $form) {
$id = $_REQUEST['ID']; $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); 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::get_page($id);
FormResponse::add("$('sitetree').setNodeTitle($id, '$title');"); 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'); 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');"); FormResponse::add("\$('sitetree').setNodeTitle($page->ID, '$JS_title');");
} else { } else {
FormResponse::add("var node = $('sitetree').getTreeNodeByIdx('$page->ID');"); 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);"); FormResponse::add("$('Form_EditForm').reloadIfSetTo($page->ID);");
} }
@ -1069,7 +1083,7 @@ HTML;
FormResponse::add("$('Form_EditForm').reloadIfSetTo($record->OldID);"); FormResponse::add("$('Form_EditForm').reloadIfSetTo($record->OldID);");
} else { } else {
FormResponse::add("var node = $('sitetree').getTreeNodeByIdx('$id');"); 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);"); FormResponse::add("$('Form_EditForm').reloadIfSetTo($record->OldID);");
} }
} }

View File

@ -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 $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 $menuTitle The link's title in the CMS menu
* @param string $url The url of the link * @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. * @return boolean The result of the operation.
*/ */
public static function add_link($code, $menuTitle, $url, $priority = -1) { public static function add_link($code, $menuTitle, $url, $priority = -1) {
@ -82,8 +82,10 @@ class CMSMenu extends Object implements Iterator
* @return boolean Success * @return boolean Success
*/ */
public static function add_menu_item($code, $menuTitle, $url, $controllerClass = null, $priority = -1) { public static function add_menu_item($code, $menuTitle, $url, $controllerClass = null, $priority = -1) {
$menuItems = self::$menu_items; // 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; if(isset($menuItems[$code])) return false;
return self::replace_menu_item($code, $menuTitle, $url, $controllerClass, $priority); 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) { public static function replace_menu_item($code, $menuTitle, $url, $controllerClass = null, $priority = -1) {
$menuItems = self::$menu_items; $menuItems = self::$menu_items;
$menuItems[$code] = new CMSMenuItem($menuTitle, $url, $controllerClass, $priority); $menuItems[$code] = new CMSMenuItem($menuTitle, $url, $controllerClass, $priority);
$menuPriority = array();
$i = 0;
foreach($menuItems as $key => $menuItem) { 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); array_multisort($menuPriority, SORT_DESC, $menuItems);

View File

@ -200,6 +200,9 @@ class LeftAndMain extends Controller {
* @return string * @return string
*/ */
public function Link($action = null) { public function Link($action = null) {
// Handle missing url_segments
if(!$this->stat('url_segment', true))
self::$url_segment = $this->class;
return Controller::join_links( return Controller::join_links(
$this->stat('url_base', true), $this->stat('url_base', true),
$this->stat('url_segment', true), $this->stat('url_segment', true),
@ -287,11 +290,14 @@ class LeftAndMain extends Controller {
$linkingmode = ""; $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} // default menu is the one with a blank {@link url_segment}
if(singleton($menuItem->controller)->stat('url_segment') == '') { } else if(singleton($menuItem->controller)->stat('url_segment') == '') {
if($this->Link() == $this->stat('url_base').'/') if($this->Link() == $this->stat('url_base').'/') $linkingmode = "current";
$linkingmode = "current";
} else { } else {
$linkingmode = "current"; $linkingmode = "current";
} }
@ -317,7 +323,6 @@ class LeftAndMain extends Controller {
// if no current item is found, assume that first item is shown // if no current item is found, assume that first item is shown
//if(!isset($foundCurrent)) //if(!isset($foundCurrent))
return $menu; return $menu;
} }
@ -410,9 +415,12 @@ class LeftAndMain extends Controller {
newNode.selectTreeNode(); newNode.selectTreeNode();
JS; JS;
FormResponse::add($response); 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"; $script = "st = \$('sitetree'); \n";
foreach($ids as $id) { foreach($ids as $id) {
if(is_numeric($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); if($record && !$record->canDelete()) return Security::permissionFailure($this);
DataObject::delete_by_id($this->stat('tree_class'), $id); DataObject::delete_by_id($this->stat('tree_class'), $id);

View File

@ -121,6 +121,12 @@ ul.tree.multiselect li.selected span.a.unexpanded span.b {
cursor: default; cursor: default;
} }
ul.tree span.a a.notinmenu, ul.tree span.a a.notinmenu * {
color: #77A;
}
ul.tree span.a a.disabled { ul.tree span.a a.disabled {
color: #999; color: #999;
cursor: pointer; cursor: pointer;
@ -153,17 +159,17 @@ ul.tree .deleted {
} }
/* Created on stage, never published */ /* Created on stage, never published */
ul.tree ins, ul.tree span.a a ins, ul.tree span.a a.notinmenu ins,
#publication_key ins { #publication_key ins {
color: orange; color: orange;
text-decoration : none; text-decoration : none;
} }
/* Deleted on stage */ /* Deleted on stage */
ul.tree del, ul.tree span.a a del, ul.tree span.a a.notinmenu del,
#publication_key del { #publication_key del {
color: red; color: red;
} }
ul.tree span.modified, ul.tree span.a span.modified,
#publication_key span.modified { #publication_key span.modified {
color: green; color: green;
text-decoration : none; text-decoration : none;
@ -342,12 +348,16 @@ ul.tree li.untranslated a:visited {
width: 70%; width: 70%;
} }
#right ins * { #right ins, #right ins * {
background-color: green; background-color: green;
color: white;
text-decoration: none;
} }
#right del *{ #right del, #right del *{
background-color: red; background-color: red;
color: white;
text-decoration: strikethough;
} }
#sitetree a.contents { #sitetree a.contents {

View File

@ -228,7 +228,7 @@ DragFileItem.prototype = {
this.draggable = null; 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 // Set up folder drop target
DropFileItem = Class.create(); DropFileItem = Class.create();

View File

@ -195,7 +195,7 @@ CMSForm.prototype = {
} }
statusMessage(ss.i18n._t('CMSMAIN.SAVING'), null, true); statusMessage(ss.i18n._t('CMSMAIN.SAVING'), null, true);
console.log(this.action+"?"+data);
new Ajax.Request(this.action, { new Ajax.Request(this.action, {
method : this.method, method : this.method,
postBody: data, postBody: data,

View File

@ -15,6 +15,7 @@ if((typeof tinyMCE != 'undefined')) {
auto_resize : false, auto_resize : false,
theme : "advanced", theme : "advanced",
content_css : "$ContentCSS", content_css : "$ContentCSS",
body_class : 'typography',
document_base_url: "$BaseURL", document_base_url: "$BaseURL",
urlconverter_callback : "nullConverter", urlconverter_callback : "nullConverter",
@ -25,10 +26,10 @@ if((typeof tinyMCE != 'undefined')) {
theme_advanced_toolbar_location : "top", theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left", theme_advanced_toolbar_align : "left",
theme_advanced_toolbar_parent : "right", 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, 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_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 : "", theme_advanced_buttons3 : "",
spellchecker_languages : "$SpellcheckLangs", spellchecker_languages : "$SpellcheckLangs",

View File

@ -6,7 +6,8 @@
<table class="data"> <table class="data">
<thead> <thead>
<tr> <tr>
<% if Markable %><th width="36">&nbsp;</th><% end_if %> <th width="18">&nbsp;</th>
<% if Markable %><th width="18">&nbsp;</th><% end_if %>
<% control Headings %> <% control Headings %>
<th class="$Name">$Title</th> <th class="$Name">$Title</th>
<% end_control %> <% end_control %>
@ -17,21 +18,24 @@
<tbody> <tbody>
<% control Items %> <% control Items %>
<tr id="record-$Parent.Name-$ID"> <tr id="record-$Parent.Name-$ID">
<% if Markable %><td width="36" class="markingcheckbox"><div class="dragfile" id="drag-$Parent.Name-$ID"><img id="drag-img-$Parent.Name-$ID" alt="Drag" title="<% _t('DRAGTOFOLDER','Drag to folder on left to move file') %>" src="sapphire/images/drag.gif" /></div> $MarkingCheckbox</td><% end_if %> <td class="dragfile" id="drag-$Parent.Name-$ID">
<img id="drag-img-$Parent.Name-$ID" alt="Drag" title="<% _t('DRAGTOFOLDER','Drag to folder on left to move file') %>" src="sapphire/images/drag.gif" />
</div>
<% if Markable %><td class="markingcheckbox">$MarkingCheckbox</td><% end_if %>
<% control Fields %> <% control Fields %>
<td>$Value</td> <td>$Value</td>
<% end_control %> <% end_control %>
<% if Can(show) %> <% if Can(show) %>
<td width="18"> <td width="18">
<a class="popuplink showlink" href="$ShowLink" target="_blank" title="<% _t('SHOW', 'Show asset') %>"><img src="cms/images/show.png" alt="<% _t('SHOW', 'Show asset') %>" /></a> <a class="popuplink showlink" href="$ShowLink" target="_blank" title="<% _t('SHOW', 'Show asset') %>"><img src="cms/images/show.png" alt="<% _t('SHOW', 'Show asset') %>" /></a>
</td> </td>
<% end_if %> <% end_if %>
<% if Can(edit) %> <% if Can(edit) %>
<td width="18"> <td width="18">
<a class="popuplink editlink" href="$EditLink" target="_blank" title="<% _t('EDIT', 'Edit asset') %>"><img src="cms/images/edit.gif" alt="<% _t('EDIT', 'Edit asset') %>" /></a> <a class="popuplink editlink" href="$EditLink" target="_blank" title="<% _t('EDIT', 'Edit asset') %>"><img src="cms/images/edit.gif" alt="<% _t('EDIT', 'Edit asset') %>" /></a>
</td> </td>
<% end_if %> <% end_if %>
<% if Can(delete) %> <% if Can(delete) %>
<td width="18"> <td width="18">
<a class="deletelink" href="admin/assets/removefile/$ID" title="<% _t('DELFILE', 'Delete this file') %>"><img src="cms/images/delete.gif" alt="<% _t('DELFILE', 'Delete this file') %>" title="<% _t('DELFILE','Delete this file') %>" /></a> <a class="deletelink" href="admin/assets/removefile/$ID" title="<% _t('DELFILE', 'Delete this file') %>"><img src="cms/images/delete.gif" alt="<% _t('DELFILE', 'Delete this file') %>" title="<% _t('DELFILE','Delete this file') %>" /></a>
</td> </td>

View File

@ -1,3 +1,5 @@
<% require javascript(jsparty/tabstrip/tabstrip.js) %>
<% require css(jsparty/tabstrip/tabstrip.css) %>
<div id="LeftPane"> <div id="LeftPane">
<!-- <h2><% _t('SEARCHLISTINGS','Search Listings') %></h2> --> <!-- <h2><% _t('SEARCHLISTINGS','Search Listings') %></h2> -->
<div id="SearchForm_holder" class="leftbottom"> <div id="SearchForm_holder" class="leftbottom">
@ -13,7 +15,7 @@
<p id="ModelClassSelector"> <p id="ModelClassSelector">
Search for: Search for:
<select> <select>
<% control SearchForms %> <% control ModelForms %>
<option value="{$Form.Name}_$ClassName">$Title</option> <option value="{$Form.Name}_$ClassName">$Title</option>
<% end_control %> <% end_control %>
</select> </select>