mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT Replaced locations of sapphire with $ModulePath(framework) in templates, based off Controller which implements TemplateGlobalProvider
This commit is contained in:
parent
b755ab62e5
commit
8949dfa691
@ -1,6 +1,6 @@
|
||||
<div class="ss-loading-screen">
|
||||
<div class="loading-logo">
|
||||
<img class="loading-animation" src="$FrameworkAdminDir/images/spinner.gif" alt="<% _t('LOADING','Loading...',PR_HIGH) %>" />
|
||||
<img class="loading-animation" src="$ModulePath(frameworkadmin)/images/spinner.gif" alt="<% _t('LOADING','Loading...',PR_HIGH) %>" />
|
||||
<noscript><p class="nojs-warning"><span class="message notice"><% _t('REQUIREJS','The CMS requires that you have JavaScript enabled.',PR_HIGH) %></span></p></noscript>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -7,7 +7,7 @@
|
||||
<title>$Title</title>
|
||||
</head>
|
||||
|
||||
<body class="loading cms" lang="$Locale.RFC1766" data-frameworkpath="$FrameworkDir">
|
||||
<body class="loading cms" lang="$Locale.RFC1766" data-frameworkpath="$ModulePath(framework)">
|
||||
|
||||
<% include CMSLoadingScreen %>
|
||||
|
||||
|
@ -405,6 +405,32 @@ class Controller extends RequestHandler implements TemplateGlobalProvider {
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Given some pre-defined modules, return the filesystem path of the module.
|
||||
* @param string $name Name of module to find path of
|
||||
* @return string
|
||||
*/
|
||||
function ModulePath($name) {
|
||||
switch($name) {
|
||||
case 'framework':
|
||||
$path = FRAMEWORK_DIR;
|
||||
break;
|
||||
case 'frameworkadmin':
|
||||
$path = FRAMEWORK_ADMIN_DIR;
|
||||
break;
|
||||
case 'thirdparty':
|
||||
$path = THIRDPARTY_DIR;
|
||||
break;
|
||||
case 'assets':
|
||||
$path = ASSETS_DIR;
|
||||
break;
|
||||
default:
|
||||
throw InvalidArgumentException($name . ' is not a supported argument. Possible values: framework, frameworkadmin, thirdparty, assets');
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a date object for use within a template
|
||||
* Usage: $Now.Year - Returns 2006
|
||||
|
@ -23,7 +23,7 @@ Existing code bases can retain `sapphire` as the framework directory name, and a
|
||||
transitions if you want to rename the framework directory.
|
||||
|
||||
In your templates, `$ModulePath(framework)` gives whatever directory the SilverStripe framework resides in.
|
||||
It takes the value from the FRAMEWORK_PATH constant, which is automatically worked out based on where the
|
||||
It takes the value from the FRAMEWORK_DIR constant, which is automatically worked out based on where the
|
||||
framework directory is, but can be set manually by defining FRAMEWORK_DIR in your _ss_environment.php file.
|
||||
|
||||
### New ORM: More flexible and expressive querying via `DataList` ###
|
||||
|
@ -1,7 +1,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<% base_tag %>
|
||||
<link rel="stylesheet" href="$FrameworkDir/css/CodeViewer.css" />
|
||||
<link rel="stylesheet" href="$ModulePath(framework)/css/CodeViewer.css" />
|
||||
</head>
|
||||
<body>
|
||||
$Content
|
||||
|
@ -17,9 +17,9 @@
|
||||
<span class="sortLink <% if SortBy %><% else %>sortLinkHidden<% end_if %>">
|
||||
<a href="$SortLink">
|
||||
<% if SortDirection = desc %>
|
||||
<img src="$FrameworkDir/images/bullet_arrow_up.png" alt="<% _t('SORTASC', 'Sort ascending') %>" />
|
||||
<img src="$ModulePath(framework)/images/bullet_arrow_up.png" alt="<% _t('SORTASC', 'Sort ascending') %>" />
|
||||
<% else %>
|
||||
<img src="$FrameworkDir/images/bullet_arrow_down.png" alt="<% _t('SORTDESC', 'Sort descending') %>" />
|
||||
<img src="$ModulePath(framework)/images/bullet_arrow_down.png" alt="<% _t('SORTDESC', 'Sort descending') %>" />
|
||||
<% end_if %>
|
||||
</a>
|
||||
|
||||
@ -49,7 +49,7 @@
|
||||
<td colspan="$ItemCount">
|
||||
<input type="hidden" id="{$id}_PopupHeight" value="$PopupHeight" disabled="disabled">
|
||||
<input type="hidden" id="{$id}_PopupWidth" value="$PopupWidth" disabled="disabled">
|
||||
<a class="popuplink addlink" href="$AddLink" alt="add"><img src="$FrameworkDir/images/add.gif" alt="<% _t('ADDITEM', 'add') %>" />
|
||||
<a class="popuplink addlink" href="$AddLink" alt="add"><img src="$ModulePath(framework)/images/add.gif" alt="<% _t('ADDITEM', 'add') %>" />
|
||||
<% sprintf(_t('ADDITEM', 'Add %s', PR_MEDIUM, 'Add [name]'),$Title) %>
|
||||
</a>
|
||||
</td>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<tr>
|
||||
<% if Paginator.PrevLink %>
|
||||
<td id="ComplexTableField_Pagination_Previous">
|
||||
<a href="$Paginator.PrevLink"><img src="$FrameworkDir/images/pagination/record-prev.png" /><% _t('PREVIOUS', 'Previous') %></a>
|
||||
<a href="$Paginator.PrevLink"><img src="$ModulePath(framework)/images/pagination/record-prev.png" /><% _t('PREVIOUS', 'Previous') %></a>
|
||||
</td>
|
||||
<% end_if %>
|
||||
<% if xdsfdsf %>
|
||||
@ -32,7 +32,7 @@
|
||||
<% end_if %>
|
||||
<% if Paginator.NextLink %>
|
||||
<td id="ComplexTableField_Pagination_Next">
|
||||
<a href="$Paginator.NextLink"><% _t('NEXT', 'Next') %><img src="$FrameworkDir/images/pagination/record-next.png" /></a>
|
||||
<a href="$Paginator.NextLink"><% _t('NEXT', 'Next') %><img src="$ModulePath(framework)/images/pagination/record-next.png" /></a>
|
||||
</td>
|
||||
<% end_if %>
|
||||
</tr>
|
||||
|
@ -1,17 +1,17 @@
|
||||
<% if ShowPagination %>
|
||||
<% if TotalCount %>
|
||||
<div class="PageControls">
|
||||
<% if FirstLink %><a class="First" href="$FirstLink" title="<% _t('VIEWFIRST', 'View first') %> $PageSize"><img src="$FrameworkDir/images/pagination/record-first.png" alt="<% _t('VIEWFIRST', 'View first') %> $PageSize" /></a>
|
||||
<% else %><span class="First"><img src="$FrameworkDir/images/pagination/record-first-g.png" alt="<% _t('VIEWFIRST', 'View first') %> $PageSize" /></span><% end_if %>
|
||||
<% if PrevLink %><a class="Prev" href="$PrevLink" title="<% _t('VIEWPREVIOUS', 'View previous') %> $PageSize"><img src="$FrameworkDir/images/pagination/record-prev.png" alt="<% _t('VIEWPREVIOUS', 'View previous') %> $PageSize" /></a>
|
||||
<% else %><img class="Prev" src="$FrameworkDir/images/pagination/record-prev-g.png" alt="<% _t('VIEWPREVIOUS', 'View previous') %> $PageSize" /><% end_if %>
|
||||
<% if FirstLink %><a class="First" href="$FirstLink" title="<% _t('VIEWFIRST', 'View first') %> $PageSize"><img src="$ModulePath(framework)/images/pagination/record-first.png" alt="<% _t('VIEWFIRST', 'View first') %> $PageSize" /></a>
|
||||
<% else %><span class="First"><img src="$ModulePath(framework)/images/pagination/record-first-g.png" alt="<% _t('VIEWFIRST', 'View first') %> $PageSize" /></span><% end_if %>
|
||||
<% if PrevLink %><a class="Prev" href="$PrevLink" title="<% _t('VIEWPREVIOUS', 'View previous') %> $PageSize"><img src="$ModulePath(framework)/images/pagination/record-prev.png" alt="<% _t('VIEWPREVIOUS', 'View previous') %> $PageSize" /></a>
|
||||
<% else %><img class="Prev" src="$ModulePath(framework)/images/pagination/record-prev-g.png" alt="<% _t('VIEWPREVIOUS', 'View previous') %> $PageSize" /><% end_if %>
|
||||
<span class="Count">
|
||||
<% _t('DISPLAYING', 'Displaying') %> $FirstItem <% _t('TO', 'to') %> $LastItem <% _t('OF', 'of') %> $TotalCount
|
||||
</span>
|
||||
<% if NextLink %><a class="Next" href="$NextLink" title="<% _t('VIEWNEXT', 'View next') %> $PageSize"><img src="$FrameworkDir/images/pagination/record-next.png" alt="<% _t('VIEWNEXT', 'View next') %> $PageSize" /></a>
|
||||
<% else %><img class="Next" src="$FrameworkDir/images/pagination/record-next-g.png" alt="<% _t('VIEWNEXT', 'View next') %> $PageSize" /><% end_if %>
|
||||
<% if LastLink %><a class="Last" href="$LastLink" title="<% _t('VIEWLAST', 'View last') %> $PageSize"><img src="$FrameworkDir/images/pagination/record-last.png" alt="<% _t('VIEWLAST', 'View last') %> $PageSize" /></a>
|
||||
<% else %><span class="Last"><img src="$FrameworkDir/images/pagination/record-last-g.png" alt="<% _t('VIEWLAST', 'View last') %> $PageSize" /></span><% end_if %>
|
||||
<% if NextLink %><a class="Next" href="$NextLink" title="<% _t('VIEWNEXT', 'View next') %> $PageSize"><img src="$ModulePath(framework)/images/pagination/record-next.png" alt="<% _t('VIEWNEXT', 'View next') %> $PageSize" /></a>
|
||||
<% else %><img class="Next" src="$ModulePath(framework)/images/pagination/record-next-g.png" alt="<% _t('VIEWNEXT', 'View next') %> $PageSize" /><% end_if %>
|
||||
<% if LastLink %><a class="Last" href="$LastLink" title="<% _t('VIEWLAST', 'View last') %> $PageSize"><img src="$ModulePath(framework)/images/pagination/record-last.png" alt="<% _t('VIEWLAST', 'View last') %> $PageSize" /></a>
|
||||
<% else %><span class="Last"><img src="$ModulePath(framework)/images/pagination/record-last-g.png" alt="<% _t('VIEWLAST', 'View last') %> $PageSize" /></span><% end_if %>
|
||||
|
||||
</div>
|
||||
<% end_if %>
|
||||
|
@ -34,7 +34,7 @@
|
||||
<td colspan="$ItemCount">
|
||||
<input type="hidden" id="{$id}_PopupHeight" value="$PopupHeight" disabled="disabled">
|
||||
<input type="hidden" id="{$id}_PopupWidth" value="$PopupWidth" disabled="disabled">
|
||||
<a class="popuplink addlink" href="$AddLink" alt="<% _t('ADD', 'Add') %>"><img src="$FrameworkDir/images/add.gif" alt="<% _t('ADD', 'Add') %>" /><% _t('ADD', 'Add') %> $Title</a>
|
||||
<a class="popuplink addlink" href="$AddLink" alt="<% _t('ADD', 'Add') %>"><img src="$ModulePath(framework)/images/add.gif" alt="<% _t('ADD', 'Add') %>" /><% _t('ADD', 'Add') %> $Title</a>
|
||||
</td>
|
||||
<% if Can(show) %><td width="18"> </td><% end_if %>
|
||||
<% if Can(edit) %><td width="18"> </td><% end_if %>
|
||||
|
@ -30,7 +30,7 @@
|
||||
<% if Can(add) %>
|
||||
<tr>
|
||||
<td colspan="$ItemCount">
|
||||
<a href="#" class="addrow" title="<% _t('ADD', 'Add a new row') %>"><img src="$FrameworkDir/images/add.gif" alt="<% _t('ADD','Add a new row') %>" />
|
||||
<a href="#" class="addrow" title="<% _t('ADD', 'Add a new row') %>"><img src="$ModulePath(framework)/images/add.gif" alt="<% _t('ADD','Add a new row') %>" />
|
||||
<% sprintf(_t('ADDITEM','Add %s'),$Title) %>
|
||||
</a>
|
||||
</td>
|
||||
@ -47,7 +47,7 @@
|
||||
<td class="$FieldClass $extraClass $ClassName $Title tablecolumn">$Field</td>
|
||||
<% end_control %>
|
||||
<td style="display: none">$ExtraData</td>
|
||||
<% if Can(delete) %><td width="18"><a class="deletelink" href="$DeleteLink" title="<% _t('DELETEROW') %>"><img src="$FrameworkDir/images/delete.gif" alt="<% _t('DELETE') %>" /></a></td><% end_if %>
|
||||
<% if Can(delete) %><td width="18"><a class="deletelink" href="$DeleteLink" title="<% _t('DELETEROW') %>"><img src="$ModulePath(framework)/images/delete.gif" alt="<% _t('DELETE') %>" /></a></td><% end_if %>
|
||||
</tr>
|
||||
<% end_control %>
|
||||
<% else %>
|
||||
|
@ -24,9 +24,9 @@
|
||||
</span>
|
||||
<span class="sortLink <% if SortBy %><% else %>sortLinkHidden<% end_if %>">
|
||||
<% if SortDirection = desc %>
|
||||
<a href="$SortLink"><img src="$FrameworkDir/images/bullet_arrow_up.png" alt="<% _t('SORTDESC', 'Sort in descending order') %>" /></a>
|
||||
<a href="$SortLink"><img src="$ModulePath(framework)/images/bullet_arrow_up.png" alt="<% _t('SORTDESC', 'Sort in descending order') %>" /></a>
|
||||
<% else %>
|
||||
<a href="$SortLink"><img src="$FrameworkDir/images/bullet_arrow_down.png" alt="<% _t('SORTASC', 'Sort in ascending order') %>" /></a>
|
||||
<a href="$SortLink"><img src="$ModulePath(framework)/images/bullet_arrow_down.png" alt="<% _t('SORTASC', 'Sort in ascending order') %>" /></a>
|
||||
<% end_if %>
|
||||
</a>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<% base_tag %>
|
||||
<link rel="stylesheet" href="$FrameworkDir/css/TestViewer.css" />
|
||||
<link rel="stylesheet" href="$ModulePath(framework)/css/TestViewer.css" />
|
||||
</head>
|
||||
<body>
|
||||
$Content
|
||||
|
@ -1,7 +1,7 @@
|
||||
<div id="$Name" class="$Type $extraClass">
|
||||
<h$HeadingLevel style="cursor: pointer;" class="trigger$ClosedClass">
|
||||
<img class="triggerClosed" src="$FrameworkDir/images/toggle-closed.gif" alt="+" style="display:none;" title="<% _t('SHOW', 'Show') %>" />
|
||||
<img class="triggerOpened" src="$FrameworkDir/images/toggle-open.gif" alt="-" style="display:none;" title="<% _t('HIDE', 'Hide') %>" />
|
||||
<img class="triggerClosed" src="$ModulePath(framework)/images/toggle-closed.gif" alt="+" style="display:none;" title="<% _t('SHOW', 'Show') %>" />
|
||||
<img class="triggerOpened" src="$ModulePath(framework)/images/toggle-open.gif" alt="-" style="display:none;" title="<% _t('HIDE', 'Hide') %>" />
|
||||
$Title
|
||||
</h$HeadingLevel>
|
||||
<div class="contentMore">
|
||||
|
@ -35,6 +35,16 @@ class DataDifferencerTest extends SapphireTest {
|
||||
$relobj1 = $this->objFromFixture('DataDifferencerTest_HasOneRelationObject', 'relobj1');
|
||||
$relobj2 = $this->objFromFixture('DataDifferencerTest_HasOneRelationObject', 'relobj2');
|
||||
|
||||
// in order to ensure the Filename path is correct, append the correct FRAMEWORK_DIR to the start
|
||||
// this is only really necessary to make the test pass when FRAMEWORK_DIR is not "framework"
|
||||
$image1->Filename = FRAMEWORK_DIR . substr($image1->Filename, 9);
|
||||
$image2->Filename = FRAMEWORK_DIR . substr($image2->Filename, 9);
|
||||
$origUpdateFilesystem = File::$update_filesystem;
|
||||
File::$update_filesystem = false; // we don't want the filesystem being updated on write, as we're only dealing with mock files
|
||||
$image1->write();
|
||||
$image2->write();
|
||||
File::$update_filesystem = $origUpdateFilesystem;
|
||||
|
||||
// create a new version
|
||||
$obj1->ImageID = $image2->ID;
|
||||
$obj1->HasOneRelationID = $relobj2->ID;
|
||||
@ -43,6 +53,7 @@ class DataDifferencerTest extends SapphireTest {
|
||||
$obj1v2 = Versioned::get_version('DataDifferencerTest_Object', $obj1->ID, $obj1->Version);
|
||||
$differ = new DataDifferencer($obj1v1, $obj1v2);
|
||||
$obj1Diff = $differ->diffedData();
|
||||
|
||||
$this->assertContains($image1->Filename, $obj1Diff->getField('Image'));
|
||||
$this->assertContains($image2->Filename, $obj1Diff->getField('Image'));
|
||||
$this->assertContains('<ins>obj2</ins><del>obj1</del>', str_replace(' ','',$obj1Diff->getField('HasOneRelationID')));
|
||||
|
@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
class GenericTemplateGlobalProvider implements TemplateGlobalProvider {
|
||||
/**
|
||||
* @return array Returns an array of strings of the method names of methods on the call that should be exposed
|
||||
* as global variables in the templates.
|
||||
*/
|
||||
public static function get_template_global_variables() {
|
||||
return array(
|
||||
'FrameworkDir',
|
||||
'FrameworkAdminDir',
|
||||
'ThirdpartyDir',
|
||||
'AssetsDir',
|
||||
);
|
||||
}
|
||||
|
||||
public static function FrameworkDir() {
|
||||
return FRAMEWORK_DIR;
|
||||
}
|
||||
|
||||
public static function FrameworkAdminDir() {
|
||||
return FRAMEWORK_ADMIN_DIR;
|
||||
}
|
||||
|
||||
public static function ThirdpartyDir() {
|
||||
return THIRDPARTY_DIR;
|
||||
}
|
||||
|
||||
public static function AssetsDir() {
|
||||
return ASSETS_DIR;
|
||||
}
|
||||
}
|
||||
|
@ -32,4 +32,3 @@ interface TemplateGlobalProvider {
|
||||
public static function get_template_global_variables();
|
||||
}
|
||||
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user