mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX: Don’t treat URLs as root relative when FRAMEWORK_DIR = “”
Code was assuming that FRAMEWORK_DIR would always have a value. If it doesn’t (because you’re running a test instance of a naked framework) This caused URLs to be treated as root relative, which creates some duplicate-inclusion bugs. The use of ltrim() works, but is a bit clumsy. A more flexible approach to including front-end assets of given modules would be preferable; ideally something that also let you keep your code outside of the web root.
This commit is contained in:
parent
cebcf7fb8c
commit
93a0122c0f
@ -119,7 +119,7 @@ class GridFieldPrintButton implements GridField_HTMLProvider, GridField_ActionPr
|
||||
public function handlePrint($gridField, $request = null) {
|
||||
set_time_limit(60);
|
||||
Requirements::clear();
|
||||
Requirements::css(FRAMEWORK_DIR . '/client/dist/styles/GridField_print.css');
|
||||
Requirements::css(ltrim(FRAMEWORK_DIR . '/client/dist/styles/GridField_print.css', '/'));
|
||||
|
||||
if($data = $this->generatePrintData($gridField)){
|
||||
return $data->renderWith(get_class($gridField)."_print");
|
||||
|
@ -250,7 +250,7 @@ class HTMLEditorField_Toolbar extends RequestHandler
|
||||
$remoteURL->addExtraClass('remoteurl');
|
||||
$fromWeb->addExtraClass('content ss-uploadfield htmleditorfield-from-web');
|
||||
|
||||
Requirements::css(FRAMEWORK_ADMIN_DIR . '/client/dist/styles/AssetUploadField.css');
|
||||
Requirements::css(ltrim(FRAMEWORK_ADMIN_DIR . '/client/dist/styles/AssetUploadField.css', '/'));
|
||||
$computerUploadField = UploadField::create('AssetUploadField', '');
|
||||
$computerUploadField->setConfig('previewMaxWidth', 40);
|
||||
$computerUploadField->setConfig('previewMaxHeight', 30);
|
||||
|
@ -147,7 +147,7 @@ class UploadField_ItemHandler extends RequestHandler
|
||||
return $this->httpError(403);
|
||||
}
|
||||
|
||||
Requirements::css(FRAMEWORK_ADMIN_DIR . '/client/dist/styles/UploadField.css');
|
||||
Requirements::css(ltrim(FRAMEWORK_ADMIN_DIR . '/client/dist/styles/UploadField.css', '/'));
|
||||
|
||||
return $this->customise(array(
|
||||
'Form' => $this->EditForm()
|
||||
|
@ -60,7 +60,7 @@ class UploadField_SelectHandler extends RequestHandler
|
||||
public function index()
|
||||
{
|
||||
// Requires a separate JS file, because we can't reach into the iframe with entwine.
|
||||
Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/client/dist/js/UploadField_select.js');
|
||||
Requirements::javascript(ltrim(FRAMEWORK_ADMIN_DIR . '/client/dist/js/UploadField_select.js', '/'));
|
||||
return $this->renderWith('SilverStripe\\Admin\\CMSDialog');
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
* @var array
|
||||
*/
|
||||
private static $admin_themes = [
|
||||
'/framework/admin/themes/cms-forms',
|
||||
'silverstripe/framework:/admin/themes/cms-forms',
|
||||
SSViewer::DEFAULT_THEME,
|
||||
];
|
||||
|
||||
@ -536,12 +536,12 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
window.ss.config = " . $this->getCombinedClientConfig() . ";
|
||||
");
|
||||
|
||||
Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/client/dist/js/bundle-lib.js');
|
||||
Requirements::css(FRAMEWORK_ADMIN_DIR . '/client/dist/styles/bundle.css');
|
||||
Requirements::javascript(ltrim(FRAMEWORK_ADMIN_DIR . '/client/dist/js/bundle-lib.js', '/'));
|
||||
Requirements::css(ltrim(FRAMEWORK_ADMIN_DIR . '/client/dist/styles/bundle.css', '/'));
|
||||
|
||||
Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/client/dist/js/bundle-legacy.js');
|
||||
Requirements::javascript(ltrim(FRAMEWORK_ADMIN_DIR . '/client/dist/js/bundle-legacy.js', '/'));
|
||||
|
||||
Requirements::add_i18n_javascript(FRAMEWORK_DIR . '/client/lang', false, true);
|
||||
Requirements::add_i18n_javascript(ltrim(FRAMEWORK_DIR . '/client/lang', '/'), false, true);
|
||||
Requirements::add_i18n_javascript(FRAMEWORK_ADMIN_DIR . '/client/lang', false, true);
|
||||
|
||||
if ($this->config()->session_keepalive_ping) {
|
||||
|
@ -71,7 +71,7 @@ class MemberImportForm extends Form {
|
||||
|
||||
parent::__construct($controller, $name, $fields, $actions, $validator);
|
||||
|
||||
Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/client/dist/js/bundle-lib.js');
|
||||
Requirements::javascript(ltrim(FRAMEWORK_ADMIN_DIR . '/client/dist/js/bundle-lib.js', '/'));
|
||||
Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/client/dist/js/MemberImportForm.js');
|
||||
Requirements::css(FRAMEWORK_ADMIN_DIR . '/client/dist/styles/bundle.css');
|
||||
|
||||
|
@ -233,9 +233,9 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
||||
|
||||
public function memberimport() {
|
||||
Requirements::clear();
|
||||
Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/client/dist/js/bundle-lib.js');
|
||||
Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/client/dist/js/MemberImportForm.js');
|
||||
Requirements::css(FRAMEWORK_ADMIN_DIR . '/client/dist/styles/bundle.css');
|
||||
Requirements::javascript(ltrim(FRAMEWORK_ADMIN_DIR . '/client/dist/js/bundle-lib.js', '/'));
|
||||
Requirements::javascript(ltrim(FRAMEWORK_ADMIN_DIR . '/client/dist/js/MemberImportForm.js', '/'));
|
||||
Requirements::css(ltrim(FRAMEWORK_ADMIN_DIR . '/client/dist/styles/bundle.css', '/'));
|
||||
|
||||
return $this->renderWith('BlankPage', array(
|
||||
'Form' => $this->MemberImportForm()->forTemplate(),
|
||||
@ -267,9 +267,9 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
||||
|
||||
public function groupimport() {
|
||||
Requirements::clear();
|
||||
Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/client/dist/js/bundle-lib.js');
|
||||
Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/client/dist/js/MemberImportForm.js');
|
||||
Requirements::css(FRAMEWORK_ADMIN_DIR . '/client/dist/styles/bundle.css');
|
||||
Requirements::javascript(ltrim(FRAMEWORK_ADMIN_DIR . '/client/dist/js/bundle-lib.js', '/'));
|
||||
Requirements::javascript(ltrim(FRAMEWORK_ADMIN_DIR . '/client/dist/js/MemberImportForm.js', '/'));
|
||||
Requirements::css(ltrim(FRAMEWORK_ADMIN_DIR . '/client/dist/styles/bundle.css', '/'));
|
||||
|
||||
return $this->renderWith('BlankPage', array(
|
||||
'Content' => ' ',
|
||||
|
@ -327,8 +327,9 @@ class HTTPTest extends FunctionalTest {
|
||||
|
||||
public function testFilename2url() {
|
||||
$this->withBaseURL('http://www.silverstripe.org/', function($test) {
|
||||
$frameworkTests = ltrim(FRAMEWORK_DIR . '/tests', '/');
|
||||
$test->assertEquals(
|
||||
'http://www.silverstripe.org/framework/tests/control/HTTPTest.php',
|
||||
"http://www.silverstripe.org/$frameworkTests/control/HTTPTest.php",
|
||||
HTTP::filename2url(__FILE__)
|
||||
);
|
||||
});
|
||||
|
@ -78,7 +78,7 @@ class ClassInfoTest extends SapphireTest {
|
||||
//$baseFolder = Director::baseFolder() . '/' . FRAMEWORK_DIR . '/tests/_ClassInfoTest';
|
||||
//$manifestInfo = ManifestBuilder::get_manifest_info($baseFolder);
|
||||
|
||||
$classes = ClassInfo::classes_for_folder(FRAMEWORK_DIR . '/tests');
|
||||
$classes = ClassInfo::classes_for_folder(ltrim(FRAMEWORK_DIR . '/tests', '/'));
|
||||
$this->assertContains(
|
||||
'classinfotest',
|
||||
$classes,
|
||||
|
Loading…
Reference in New Issue
Block a user