ENHANCEMENT Introduced constants for system paths like /sapphire in preparation for a more flexible directory reorganisation. Instead of hardcoding your path, please use the following constants: BASE_PATH, BASE_URL, SAPPHIRE_DIR, SAPPHIRE_PATH, CMS_DIR, CMS_PATH, THIRDPARTY_DIR, THIRDPARTY_PATH, ASSETS_DIR, ASSETS_PATH, THEMES_DIR, THEMES_PATH

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@63154 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-09-27 16:02:38 +00:00
parent 12a73455ac
commit 9371f4688b
47 changed files with 273 additions and 234 deletions

View File

@ -44,6 +44,24 @@ if(isset($_SERVER['argv'][2])) {
$_SERVER['SCRIPT_FILENAME'] = __FILE__; $_SERVER['SCRIPT_FILENAME'] = __FILE__;
chdir(dirname($_SERVER['SCRIPT_FILENAME'])); chdir(dirname($_SERVER['SCRIPT_FILENAME']));
/**
* Define system paths
*/
define('BASE_PATH', dirname(dirname($_SERVER['SCRIPT_FILENAME'])));
define('BASE_URL', dirname(dirname($_SERVER['SCRIPT_NAME'])));
define('MODULES_DIR', 'modules');
define('MODULES_PATH', BASE_PATH . '/' . MODULES_DIR);
define('THIRDPARTY_DIR', 'jsparty');
define('THIRDPARTY_PATH', BASE_PATH . '/' . THIRDPARTY_DIR);
define('THEMES_DIR', 'themes');
define('THEMES_PATH', BASE_PATH . '/' . THEMES_DIR);
define('SAPPHIRE_DIR', 'sapphire');
define('SAPPHIRE_PATH', BASE_PATH . '/' . SAPPHIRE_DIR);
define('CMS_DIR', 'cms');
define('CMS_PATH', BASE_PATH . '/' . CMS_DIR);
define('ASSETS_DIR', 'assets');
define('ASSETS_PATH', BASE_PATH . '/' . ASSETS_DIR);
/** /**
* Include Sapphire's core code * Include Sapphire's core code
*/ */
@ -92,8 +110,6 @@ if( preg_match( '/(test\.totallydigital\.co\.nz|dev\.totallydigital\.co\.nz\/tes
// set request method (doesn't allow POST through cli) // set request method (doesn't allow POST through cli)
$_SERVER['REQUEST_METHOD'] = "GET"; $_SERVER['REQUEST_METHOD'] = "GET";
$baseURL = dirname( dirname( $_SERVER['SCRIPT_NAME'] ) );
if($_REQUEST && get_magic_quotes_gpc()) { if($_REQUEST && get_magic_quotes_gpc()) {
stripslashes_recursively($_REQUEST); stripslashes_recursively($_REQUEST);
} }
@ -153,7 +169,6 @@ DB::connect($databaseConfig);
// Get the request URL // Get the request URL
// $baseURL = dirname(dirname($_SERVER[SCRIPT_NAME]));
$url = $_SERVER['argv'][1]; $url = $_SERVER['argv'][1];
$_SERVER['REQUEST_URI'] = "/$url"; $_SERVER['REQUEST_URI'] = "/$url";

View File

@ -17,7 +17,7 @@ function getTempFolder() {
$cachefolder = "silverstripe-cache"; $cachefolder = "silverstripe-cache";
} }
$ssTmp = dirname(dirname($_SERVER['SCRIPT_FILENAME'])) . "/silverstripe-cache"; $ssTmp = BASE_PATH . "/silverstripe-cache";
if(@file_exists($ssTmp)) { if(@file_exists($ssTmp)) {
return $ssTmp; return $ssTmp;
} }
@ -38,7 +38,7 @@ function getTempFolder() {
@$worked = mkdir($ssTmp); @$worked = mkdir($ssTmp);
} }
if(!$worked) { if(!$worked) {
$ssTmp = dirname(dirname($_SERVER['SCRIPT_FILENAME'])) . "/silverstripe-cache"; $ssTmp = BASE_PATH . "/silverstripe-cache";
$worked = true; $worked = true;
if(!@file_exists($ssTmp)) { if(!@file_exists($ssTmp)) {
@$worked = mkdir($ssTmp); @$worked = mkdir($ssTmp);

View File

@ -184,10 +184,10 @@ class ContentController extends Controller {
$member = Member::currentUser(); $member = Member::currentUser();
if(Director::isDev() || Permission::check('CMS_ACCESS_CMSMain')) { if(Director::isDev() || Permission::check('CMS_ACCESS_CMSMain')) {
Requirements::css('sapphire/css/SilverStripeNavigator.css'); Requirements::css(SAPPHIRE_DIR . '/css/SilverStripeNavigator.css');
Requirements::javascript('jsparty/behaviour.js'); Requirements::javascript(THIRDPARTY_DIR . '/behaviour.js');
// Requirements::javascript('jsparty/prototype.js'); // Requirements::javascript(THIRDPARTY_DIR . 'jsparty/prototype.js');
Requirements::customScript(<<<JS Requirements::customScript(<<<JS
Behaviour.register({ Behaviour.register({
'#switchView a' : { '#switchView a' : {
@ -278,7 +278,7 @@ HTML;
// On live sites we should still see the archived message // On live sites we should still see the archived message
} else { } else {
if($date = Versioned::current_archived_date()) { if($date = Versioned::current_archived_date()) {
Requirements::css('sapphire/css/SilverStripeNavigator.css'); Requirements::css(SAPPHIRE_DIR . '/css/SilverStripeNavigator.css');
$dateObj = Object::create('Datetime', $date, null); $dateObj = Object::create('Datetime', $date, null);
// $dateObj->setVal($date); // $dateObj->setVal($date);
return "<div id=\"SilverStripeNavigatorMessage\">Archived site from<br>" . $dateObj->Nice() . "</div>"; return "<div id=\"SilverStripeNavigatorMessage\">Archived site from<br>" . $dateObj->Nice() . "</div>";

View File

@ -272,7 +272,9 @@ class Director {
* @todo Document how relativeToSiteBase works * @todo Document how relativeToSiteBase works
*/ */
static function absoluteURL($url, $relativeToSiteBase = false) { static function absoluteURL($url, $relativeToSiteBase = false) {
if(strpos($url,'/') === false && !$relativeToSiteBase) $url = dirname($_SERVER['REQUEST_URI'] . 'x') . '/' . $url; if(strpos($url,'/') === false && !$relativeToSiteBase && !self::$alternateBaseURL) {
$url = dirname($_SERVER['REQUEST_URI'] . 'x') . '/' . $url;
}
if(substr($url,0,4) != "http") { if(substr($url,0,4) != "http") {
if($url[0] != "/") $url = Director::baseURL() . $url; if($url[0] != "/") $url = Director::baseURL() . $url;
@ -374,12 +376,14 @@ class Director {
/** /**
* Returns the root URL for the site. * Returns the root URL for the site.
* It will be automatically calculated unless it is overridden with {@link setBaseURL()}. * It will be automatically determined from the current script URL
* unless it is overridden with {@link setBaseURL()}.
*/ */
static function baseURL() { static function baseURL() {
if(self::$alternateBaseURL) return self::$alternateBaseURL; if(self::$alternateBaseURL) {
else { return self::$alternateBaseURL;
$base = dirname(dirname($_SERVER['SCRIPT_NAME'])); } else {
$base = BASE_URL;
if($base == '/' || $base == '/.' || $base == '\\') return '/'; if($base == '/' || $base == '/.' || $base == '\\') return '/';
else return $base . '/'; else return $base . '/';
} }
@ -388,6 +392,7 @@ class Director {
/** /**
* Sets the root URL for the website. * Sets the root URL for the website.
* If the site isn't accessible from the URL you provide, weird things will happen. * If the site isn't accessible from the URL you provide, weird things will happen.
* Set to false if you want to undo the base url override.
*/ */
static function setBaseURL($baseURL) { static function setBaseURL($baseURL) {
self::$alternateBaseURL = $baseURL; self::$alternateBaseURL = $baseURL;
@ -399,7 +404,7 @@ class Director {
*/ */
static function baseFolder() { static function baseFolder() {
if(self::$alternateBaseFolder) return self::$alternateBaseFolder; if(self::$alternateBaseFolder) return self::$alternateBaseFolder;
else return dirname(dirname($_SERVER['SCRIPT_FILENAME'])); else return BASE_PATH;
} }
/** /**
@ -466,6 +471,8 @@ class Director {
/** /**
* Returns the Absolute URL of the site root, embedding the current basic-auth credentials into the URL. * Returns the Absolute URL of the site root, embedding the current basic-auth credentials into the URL.
*
* @todo allow override by self::$alternateBaseURL
*/ */
static function absoluteBaseURLWithAuth() { static function absoluteBaseURLWithAuth() {
$s = ""; $s = "";
@ -484,6 +491,8 @@ class Director {
* <code> * <code>
* if(Director::isLive()) Director::forceSSL(); * if(Director::isLive()) Director::forceSSL();
* </code> * </code>
*
* @todo allow override by self::$alternateBaseURL
*/ */
static function forceSSL() { static function forceSSL() {
if(!isset($_SERVER['HTTPS']) && !Director::isDev()) { if(!isset($_SERVER['HTTPS']) && !Director::isDev()) {
@ -496,6 +505,8 @@ class Director {
/** /**
* Force a redirect to a domain starting with "www." * Force a redirect to a domain starting with "www."
*
* @todo allow override by self::$alternateBaseURL
*/ */
static function forceWWW() { static function forceWWW() {
if(!Director::isDev() && !Director::isTest() && strpos( $_SERVER['SERVER_NAME'], 'www') !== 0 ){ if(!Director::isDev() && !Director::isTest() && strpos( $_SERVER['SERVER_NAME'], 'www') !== 0 ){

View File

@ -96,11 +96,11 @@ class ErrorPage extends Page {
$controller = new ErrorPage_Controller($this); $controller = new ErrorPage_Controller($this);
$errorContent = $controller->handleRequest(new HTTPRequest('GET',''))->getBody(); $errorContent = $controller->handleRequest(new HTTPRequest('GET',''))->getBody();
if(!file_exists("../assets")) { if(!file_exists(ASSETS_PATH)) {
mkdir("../assets", 02775); mkdir(ASSETS_PATH, 02775);
} }
if($fh = fopen("../assets/error-$this->ErrorCode.html", "w")) { if($fh = fopen(ASSETS_PATH . "/error-$this->ErrorCode.html", "w")) {
fwrite($fh, $errorContent); fwrite($fh, $errorContent);
fclose($fh); fclose($fh);
} }

View File

@ -130,16 +130,15 @@ class Image extends File {
return; return;
} }
$base = dirname(dirname($_SERVER['SCRIPT_FILENAME']));
$class = $this->class; $class = $this->class;
// Create a folder // Create a folder
if(!file_exists("$base/assets")) { if(!file_exists(ASSETS_PATH)) {
mkdir("$base/assets", Filesystem::$folder_create_mask); mkdir(ASSETS_PATH, Filesystem::$folder_create_mask);
} }
if(!file_exists("$base/assets/$class")) { if(!file_exists(ASSETS_PATH . "/$class")) {
mkdir("$base/assets/$class", Filesystem::$folder_create_mask); mkdir(ASSETS_PATH . "/$class", Filesystem::$folder_create_mask);
} }
// Generate default filename // Generate default filename
@ -150,16 +149,16 @@ class Image extends File {
$file = "file.jpg"; $file = "file.jpg";
} }
$file = "assets/$class/$file"; $file = ASSETS_PATH . "/$class/$file";
while(file_exists("$base/$file")) { while(file_exists(BASE_PATH . "/$file")) {
$i = $i ? ($i+1) : 2; $i = $i ? ($i+1) : 2;
$oldFile = $file; $oldFile = $file;
$file = ereg_replace('[0-9]*(\.[^.]+$)',$i . '\\1', $file); $file = ereg_replace('[0-9]*(\.[^.]+$)',$i . '\\1', $file);
if($oldFile == $file && $i > 2) user_error("Couldn't fix $file with $i", E_USER_ERROR); if($oldFile == $file && $i > 2) user_error("Couldn't fix $file with $i", E_USER_ERROR);
} }
if(file_exists($tmpFile['tmp_name']) && copy($tmpFile['tmp_name'], "$base/$file")) { if(file_exists($tmpFile['tmp_name']) && copy($tmpFile['tmp_name'], BASE_PATH . "/$file")) {
// Remove the old images // Remove the old images
$this->deleteFormattedImages(); $this->deleteFormattedImages();
@ -272,7 +271,7 @@ class Image extends File {
* @return string * @return string
*/ */
function cacheFilename($format, $arg1 = null, $arg2 = null) { function cacheFilename($format, $arg1 = null, $arg2 = null) {
$folder = $this->ParentID ? $this->Parent()->Filename : "assets/"; $folder = $this->ParentID ? $this->Parent()->Filename : ASSETS_DIR . "/";
$format = $format.$arg1.$arg2; $format = $format.$arg1.$arg2;
@ -480,7 +479,7 @@ class Image_Uploader extends Controller {
function iframe() { function iframe() {
if(!Permission::check('CMS_ACCESS_CMSMain')) Security::permissionFailure($this); if(!Permission::check('CMS_ACCESS_CMSMain')) Security::permissionFailure($this);
Requirements::css("cms/css/Image_iframe.css"); Requirements::css(CMS_DIR . "/css/Image_iframe.css");
return array(); return array();
} }
@ -774,7 +773,7 @@ class Image_Uploader extends Controller {
foreach($images as $image) { foreach($images as $image) {
if(($className = $image['ClassName']) && $image['Filename']) { if(($className = $image['ClassName']) && $image['Filename']) {
echo "<li>Importing $image[Filename]"; echo "<li>Importing $image[Filename]";
$folderName = str_replace('assets/','',dirname($image['Filename'])); $folderName = str_replace(ASSETS_DIR . '/','',dirname($image['Filename']));
$name = basename($image['Filename']); $name = basename($image['Filename']);
$folderObj = Folder::findOrMake($folderName); $folderObj = Folder::findOrMake($folderName);
$fileObj = new $className(); $fileObj = new $className();

View File

@ -45,7 +45,7 @@ class RedirectorPage extends Page {
} }
function getCMSFields() { function getCMSFields() {
Requirements::javascript("sapphire/javascript/RedirectorPage.js"); Requirements::javascript(SAPPHIRE_DIR . "/javascript/RedirectorPage.js");
$fields = new FieldSet( $fields = new FieldSet(
new TabSet("Root", new TabSet("Root",

View File

@ -1020,7 +1020,7 @@ class SiteTree extends DataObject {
*/ */
function getCMSFields() { function getCMSFields() {
require_once("forms/Form.php"); require_once("forms/Form.php");
Requirements::javascript("cms/javascript/SitetreeAccess.js"); Requirements::javascript(CMS_DIR . "/javascript/SitetreeAccess.js");
// Backlink report // Backlink report
if($this->hasMethod('BackLinkTracking')) { if($this->hasMethod('BackLinkTracking')) {

View File

@ -258,8 +258,8 @@ class Debug {
echo "There has been an error"; echo "There has been an error";
} else { } else {
if(file_exists('../assets/error-500.html')) { if(file_exists(ASSETS_PATH . '/error-500.html')) {
include('../assets/error-500.html'); include(ASSETS_PATH . '/error-500.html');
} else { } else {
echo "<h1>Error</h1><p>The website server has not been able to respond to your request.</p>\n"; echo "<h1>Error</h1><p>The website server has not been able to respond to your request.</p>\n";
} }

View File

@ -150,10 +150,10 @@ class TestRunner extends Controller {
$results->collectCodeCoverageInformation(true); $results->collectCodeCoverageInformation(true);
$suite->run($results); $suite->run($results);
if(!file_exists('../assets/coverage-report')) mkdir('../assets/coverage-report'); if(!file_exists(ASSETS_PATH . '/coverage-report')) mkdir(ASSETS_PATH . '/coverage-report');
PHPUnit_Util_Report::render($results, '../assets/coverage-report/'); PHPUnit_Util_Report::render($results, ASSETS_PATH . '/coverage-report/');
$coverageApp = Director::baseURL() . 'assets/coverage-report/' . preg_replace('/[^A-Za-z0-9]/','_',preg_replace('/(\/$)|(^\/)/','',Director::baseFolder())) . '.html'; $coverageApp = ASSETS_PATH . '/coverage-report/' . preg_replace('/[^A-Za-z0-9]/','_',preg_replace('/(\/$)|(^\/)/','',Director::baseFolder())) . '.html';
$coverageTemplates = Director::baseURL() . 'assets/coverage-report/' . preg_replace('/[^A-Za-z0-9]/','_',preg_replace('/(\/$)|(^\/)/','',realpath(TEMP_FOLDER))) . '.html'; $coverageTemplates = ASSETS_PATH . '/coverage-report/' . preg_replace('/[^A-Za-z0-9]/','_',preg_replace('/(\/$)|(^\/)/','',realpath(TEMP_FOLDER))) . '.html';
echo "<p>Coverage reports available here:<ul> echo "<p>Coverage reports available here:<ul>
<li><a href=\"$coverageApp\">Coverage report of the application</a></li> <li><a href=\"$coverageApp\">Coverage report of the application</a></li>
<li><a href=\"$coverageTemplates\">Coverage report of the templates</a></li> <li><a href=\"$coverageTemplates\">Coverage report of the templates</a></li>

View File

@ -134,15 +134,15 @@ class File extends DataObject {
*/ */
function Icon() { function Icon() {
$ext = $this->Extension; $ext = $this->Extension;
if(!Director::fileExists("sapphire/images/app_icons/{$ext}_32.gif")) { if(!Director::fileExists(SAPPHIRE_DIR . "/images/app_icons/{$ext}_32.gif")) {
$ext = $this->appCategory(); $ext = $this->appCategory();
} }
if(!Director::fileExists("sapphire/images/app_icons/{$ext}_32.gif")) { if(!Director::fileExists(SAPPHIRE_DIR . "/images/app_icons/{$ext}_32.gif")) {
$ext = "generic"; $ext = "generic";
} }
return "sapphire/images/app_icons/{$ext}_32.gif"; return SAPPHIRE_DIR . "/images/app_icons/{$ext}_32.gif";
} }
/** /**
@ -366,13 +366,13 @@ class File extends DataObject {
$p = DataObject::get_one('Folder', "ID={$this->ParentID}"); $p = DataObject::get_one('Folder', "ID={$this->ParentID}");
if($p->ID) return $p->getRelativePath() . $this->getField("Name"); if($p->ID) return $p->getRelativePath() . $this->getField("Name");
else return "assets/" . $this->getField("Name"); else return ASSETS_DIR . "/" . $this->getField("Name");
} else if($this->getField("Name")) { } else if($this->getField("Name")) {
return "assets/" . $this->getField("Name"); return ASSETS_DIR . "/" . $this->getField("Name");
} else { } else {
return "assets"; return ASSETS_DIR;
} }
} }
@ -384,7 +384,7 @@ class File extends DataObject {
if($this->getField('Filename')) { if($this->getField('Filename')) {
return $this->getField('Filename'); return $this->getField('Filename');
} else { } else {
return 'assets/'; return ASSETS_DIR . '/';
} }
} }

View File

@ -218,7 +218,7 @@ class Folder extends File {
return; return;
} }
$base = dirname(dirname($_SERVER['SCRIPT_FILENAME'])); $base = BASE_PATH;
// $parentFolder = Folder::findOrMake("Uploads"); // $parentFolder = Folder::findOrMake("Uploads");
// Generate default filename // Generate default filename

View File

@ -97,11 +97,11 @@ class Upload extends Controller {
$parentFolder = Folder::findOrMake($folderPath); $parentFolder = Folder::findOrMake($folderPath);
// Create a folder for uploading. // Create a folder for uploading.
if(!file_exists("$base/assets")){ if(!file_exists(ASSETS_PATH)){
mkdir("$base/assets", Filesystem::$folder_create_mask); mkdir(ASSETS_PATH, Filesystem::$folder_create_mask);
} }
if(!file_exists("$base/assets/" . $folderPath)){ if(!file_exists(ASSETS_PATH . "/" . $folderPath)){
mkdir("$base/assets/" . $folderPath, Filesystem::$folder_create_mask); mkdir(ASSETS_PATH . "/" . $folderPath, Filesystem::$folder_create_mask);
} }
// Generate default filename // Generate default filename
@ -110,7 +110,7 @@ class Upload extends Controller {
$fileName = ereg_replace('-+', '-',$fileName); $fileName = ereg_replace('-+', '-',$fileName);
$fileName = basename($fileName); $fileName = basename($fileName);
$relativeFilePath = "assets/" . $folderPath . "/$fileName"; $relativeFilePath = ASSETS_DIR . "/" . $folderPath . "/$fileName";
// if filename already exists, version the filename (e.g. test.gif to test1.gif) // if filename already exists, version the filename (e.g. test.gif to test1.gif)
while(file_exists("$base/$relativeFilePath")) { while(file_exists("$base/$relativeFilePath")) {

View File

@ -29,7 +29,7 @@ class AjaxUniqueTextField extends TextField {
} }
function Field() { function Field() {
Requirements::javascript("sapphire/javascript/UniqueFields.js"); Requirements::javascript(SAPPHIRE_DIR . "/javascript/UniqueFields.js");
$this->jsValidation(); $this->jsValidation();

View File

@ -16,11 +16,11 @@ HTML;
} }
function Field() { function Field() {
Requirements::javascript("jsparty/calendar/calendar.js"); Requirements::javascript(THIRDPARTY_DIR . "/calendar/calendar.js");
Requirements::javascript("jsparty/calendar/lang/calendar-en.js"); Requirements::javascript(THIRDPARTY_DIR . "/calendar/lang/calendar-en.js");
Requirements::javascript("jsparty/calendar/calendar-setup.js"); Requirements::javascript(THIRDPARTY_DIR . "/calendar/calendar-setup.js");
Requirements::css("sapphire/css/CalendarDateField.css"); Requirements::css(SAPPHIRE_DIR . "/css/CalendarDateField.css");
Requirements::css("jsparty/calendar/calendar-win2k-1.css"); Requirements::css(THIRDPARTY_DIR . "/calendar/calendar-win2k-1.css");
$field = parent::Field(); $field = parent::Field();

View File

@ -15,7 +15,7 @@ class CheckboxSetField extends OptionsetField {
function __construct($name, $title = "", $source = array(), $value = "", $form = null) { function __construct($name, $title = "", $source = array(), $value = "", $form = null) {
parent::__construct($name, $title, $source, $value, $form); parent::__construct($name, $title, $source, $value, $form);
Requirements::css('sapphire/css/CheckboxSetField.css'); Requirements::css(SAPPHIRE_DIR . '/css/CheckboxSetField.css');
} }
/** /**

View File

@ -169,12 +169,12 @@ class ComplexTableField extends TableListField {
$this->controller = $controller; $this->controller = $controller;
$this->pageSize = 10; $this->pageSize = 10;
Requirements::javascript("jsparty/greybox/AmiJS.js"); Requirements::javascript(THIRDPARTY_DIR . "/greybox/AmiJS.js");
Requirements::javascript("jsparty/greybox/greybox.js"); Requirements::javascript(THIRDPARTY_DIR . "/greybox/greybox.js");
Requirements::javascript('sapphire/javascript/TableListField.js'); Requirements::javascript(SAPPHIRE_DIR . '/javascript/TableListField.js');
Requirements::javascript("sapphire/javascript/ComplexTableField.js"); Requirements::javascript(SAPPHIRE_DIR . "/javascript/ComplexTableField.js");
Requirements::css("jsparty/greybox/greybox.css"); Requirements::css(THIRDPARTY_DIR . "/greybox/greybox.css");
Requirements::css("sapphire/css/ComplexTableField.css"); Requirements::css(SAPPHIRE_DIR . "/css/ComplexTableField.css");
parent::__construct($name, $sourceClass, $fieldList, $sourceFilter, $sourceSort, $sourceJoin); parent::__construct($name, $sourceClass, $fieldList, $sourceFilter, $sourceSort, $sourceJoin);
@ -895,25 +895,25 @@ class ComplexTableField_Popup extends Form {
* WARNING: DO NOT CHANGE THE ORDER OF THESE JS FILES * WARNING: DO NOT CHANGE THE ORDER OF THESE JS FILES
* Some have special requirements. * Some have special requirements.
*/ */
//Requirements::css('cms/css/layout.css'); //Requirements::css(CMS_DIR . '/css/layout.css');
Requirements::css('jsparty/tabstrip/tabstrip.css'); Requirements::css(THIRDPARTY_DIR . '/tabstrip/tabstrip.css');
Requirements::css('sapphire/css/Form.css'); Requirements::css(SAPPHIRE_DIR . '/css/Form.css');
Requirements::css('sapphire/css/ComplexTableField_popup.css'); Requirements::css(SAPPHIRE_DIR . '/css/ComplexTableField_popup.css');
Requirements::css('cms/css/typography.css'); Requirements::css(CMS_DIR . '/css/typography.css');
Requirements::css('cms/css/cms_right.css'); Requirements::css(CMS_DIR . '/css/cms_right.css');
Requirements::javascript("jsparty/prototype.js"); Requirements::javascript(THIRDPARTY_DIR . "/prototype.js");
Requirements::javascript("jsparty/behaviour.js"); Requirements::javascript(THIRDPARTY_DIR . "/behaviour.js");
Requirements::javascript("jsparty/prototype_improvements.js"); Requirements::javascript(THIRDPARTY_DIR . "/prototype_improvements.js");
Requirements::javascript("jsparty/loader.js"); Requirements::javascript(THIRDPARTY_DIR . "/loader.js");
Requirements::javascript("jsparty/tabstrip/tabstrip.js"); Requirements::javascript(THIRDPARTY_DIR . "/tabstrip/tabstrip.js");
Requirements::javascript("jsparty/scriptaculous/scriptaculous.js"); Requirements::javascript(THIRDPARTY_DIR . "/scriptaculous/scriptaculous.js");
Requirements::javascript("jsparty/scriptaculous/controls.js"); Requirements::javascript(THIRDPARTY_DIR . "/scriptaculous/controls.js");
Requirements::javascript("jsparty/layout_helpers.js"); Requirements::javascript(THIRDPARTY_DIR . "/layout_helpers.js");
Requirements::javascript("cms/javascript/LeftAndMain.js"); Requirements::javascript(CMS_DIR . "/javascript/LeftAndMain.js");
Requirements::javascript("cms/javascript/LeftAndMain_right.js"); Requirements::javascript(CMS_DIR . "/javascript/LeftAndMain_right.js");
Requirements::javascript("sapphire/javascript/TableField.js"); Requirements::javascript(SAPPHIRE_DIR . "/javascript/TableField.js");
Requirements::javascript("sapphire/javascript/ComplexTableField.js"); Requirements::javascript(SAPPHIRE_DIR . "/javascript/ComplexTableField.js");
Requirements::javascript("sapphire/javascript/ComplexTableField_popup.js"); Requirements::javascript(SAPPHIRE_DIR . "/javascript/ComplexTableField_popup.js");
if($this->dataObject->hasMethod('getRequirementsForPopup')) { if($this->dataObject->hasMethod('getRequirementsForPopup')) {
$this->dataObject->getRequirementsForPopup(); $this->dataObject->getRequirementsForPopup();

View File

@ -86,10 +86,10 @@ class ConfirmedPasswordField extends FormField {
} }
function Field() { function Field() {
Requirements::javascript('jsparty/prototype.js'); Requirements::javascript(THIRDPARTY_DIR . '/prototype.js');
Requirements::javascript('jsparty/behaviour.js'); Requirements::javascript(THIRDPARTY_DIR . '/behaviour.js');
Requirements::javascript('jsparty/prototype_improvements.js'); Requirements::javascript(THIRDPARTY_DIR . '/prototype_improvements.js');
Requirements::javascript('sapphire/javascript/ConfirmedPasswordField.js'); Requirements::javascript(SAPPHIRE_DIR . '/javascript/ConfirmedPasswordField.js');
$content = ''; $content = '';

View File

@ -8,12 +8,12 @@
class DMYCalendarDateField extends CalendarDateField { class DMYCalendarDateField extends CalendarDateField {
function Field() { function Field() {
Requirements::javascript("jsparty/calendar/calendar.js"); Requirements::javascript(THIRDPARTY_DIR . "/calendar/calendar.js");
Requirements::javascript("jsparty/calendar/lang/calendar-en.js"); Requirements::javascript(THIRDPARTY_DIR . "/calendar/lang/calendar-en.js");
Requirements::javascript("jsparty/calendar/calendar-setup.js"); Requirements::javascript(THIRDPARTY_DIR . "/calendar/calendar-setup.js");
Requirements::css("sapphire/css/CalendarDateField.css"); Requirements::css(SAPPHIRE_DIR . "/css/CalendarDateField.css");
Requirements::css("jsparty/calendar/calendar-win2k-1.css"); Requirements::css(THIRDPARTY_DIR . "/calendar/calendar-win2k-1.css");
Requirements::javascript("sapphire/javascript/CalendarDateField.js"); Requirements::javascript(SAPPHIRE_DIR . "/javascript/CalendarDateField.js");
$field = DateField::Field(); $field = DateField::Field();

View File

@ -17,12 +17,12 @@ class DMYDateField extends CalendarDateField {
} }
function Field() { function Field() {
Requirements::javascript("jsparty/calendar/calendar.js"); Requirements::javascript(THIRDPARTY_DIR . "/calendar/calendar.js");
Requirements::javascript("jsparty/calendar/lang/calendar-en.js"); Requirements::javascript(THIRDPARTY_DIR . "/calendar/lang/calendar-en.js");
Requirements::javascript("jsparty/calendar/calendar-setup.js"); Requirements::javascript(THIRDPARTY_DIR . "/calendar/calendar-setup.js");
Requirements::css("sapphire/css/CalendarDateField.css"); Requirements::css(SAPPHIRE_DIR . "/css/CalendarDateField.css");
Requirements::css("jsparty/calendar/calendar-win2k-1.css"); Requirements::css(THIRDPARTY_DIR . "/calendar/calendar-win2k-1.css");
Requirements::javascript("sapphire/javascript/CalendarDateField.js"); Requirements::javascript(SAPPHIRE_DIR . "/javascript/CalendarDateField.js");
$field = DateField::Field(); $field = DateField::Field();

View File

@ -109,10 +109,10 @@ class DropdownField_WithAdd extends DropdownField {
function Field() { function Field() {
//Add these js file so that the DropdownField_WithAdd can work alone (in a webpage, rather than CMS). //Add these js file so that the DropdownField_WithAdd can work alone (in a webpage, rather than CMS).
Requirements::javascript('jsparty/prototype.js'); Requirements::javascript(THIRDPARTY_DIR . 'jsparty/prototype.js');
Requirements::javascript('jsparty/behaviour.js'); Requirements::javascript(THIRDPARTY_DIR . 'jsparty/behaviour.js');
Requirements::javascript('jsparty/prototype_improvements.js'); Requirements::javascript(THIRDPARTY_DIR . 'jsparty/prototype_improvements.js');
Requirements::Javascript("sapphire/javascript/DropdownField_WithAdd.js"); Requirements::Javascript(SAPPHIRE_DIR . "/javascript/DropdownField_WithAdd.js");
$dropdown = parent::Field(); $dropdown = parent::Field();
if($this->addLink) $addLink = <<<HTML if($this->addLink) $addLink = <<<HTML

View File

@ -11,8 +11,8 @@ class DropdownTimeField extends TimeField {
} }
static function Requirements() { static function Requirements() {
Requirements::javascript( 'sapphire/javascript/DropdownTimeField.js' ); Requirements::javascript( SAPPHIRE_DIR . '/javascript/DropdownTimeField.js' );
Requirements::css( 'sapphire/css/DropdownTimeField.css' ); Requirements::css( SAPPHIRE_DIR . '/css/DropdownTimeField.css' );
} }
static function HTMLField( $id, $name, $val ) { static function HTMLField( $id, $name, $val ) {

View File

@ -22,9 +22,9 @@ class ImageFormAction extends FormAction {
parent::__construct($action, $title, $form); parent::__construct($action, $title, $form);
} }
function Field() { function Field() {
Requirements::javascript('jsparty/prototype.js'); Requirements::javascript(THIRDPARTY_DIR . '/prototype.js');
Requirements::javascript('jsparty/behaviour.js'); Requirements::javascript(THIRDPARTY_DIR . '/behaviour.js');
Requirements::javascript('sapphire/javascript/ImageFormAction.js'); Requirements::javascript(SAPPHIRE_DIR . '/javascript/ImageFormAction.js');
$classClause = ''; $classClause = '';
if($this->className) $classClause = $this->className . ' '; if($this->className) $classClause = $this->className . ' ';

View File

@ -26,7 +26,7 @@ class InlineFormAction extends FormField {
function Field() { function Field() {
if($this->includeDefaultJS) { if($this->includeDefaultJS) {
Requirements::javascriptTemplate('sapphire/javascript/InlineFormAction.js',array('ID'=>$this->id())); Requirements::javascriptTemplate(SAPPHIRE_DIR . '/javascript/InlineFormAction.js',array('ID'=>$this->id()));
} }
return "<input type=\"submit\" name=\"action_{$this->name}\" value=\"{$this->title}\" id=\"{$this->id()}\" class=\"action{$this->extraClass}\" />"; return "<input type=\"submit\" name=\"action_{$this->name}\" value=\"{$this->title}\" id=\"{$this->id()}\" class=\"action{$this->extraClass}\" />";

View File

@ -8,7 +8,7 @@ class PopupDateTimeField extends CalendarDateField {
function Field() { function Field() {
Requirements::css( 'sapphire/css/PopupDateTimeField.css' ); Requirements::css( SAPPHIRE_DIR . '/css/PopupDateTimeField.css' );
$field = parent::Field(); $field = parent::Field();

View File

@ -21,7 +21,7 @@ class RelatedDataEditor extends FormField {
* @param fields The fields to show * @param fields The fields to show
*/ */
function __construct($name, $dropdownField, $fields = null, $dropdownClass = 'relatedDataKey', $showKeyDropdown = true) { function __construct($name, $dropdownField, $fields = null, $dropdownClass = 'relatedDataKey', $showKeyDropdown = true) {
Requirements::css("sapphire/css/RelatedDataEditor.css"); Requirements::css(SAPPHIRE_DIR . "/css/RelatedDataEditor.css");
parent::__construct($name); parent::__construct($name);
$this->dropdownField = $dropdownField; $this->dropdownField = $dropdownField;
$this->children = $fields; $this->children = $fields;

View File

@ -85,7 +85,7 @@ class ReportField extends FormField{
function FieldHolder() { function FieldHolder() {
Requirements::javascript("sapphire/javascript/ReportField.js"); Requirements::javascript(SAPPHIRE_DIR . "/javascript/ReportField.js");
$headerHTML = $this->columnheaders(); $headerHTML = $this->columnheaders();
$dataCellHTML = $this->datacells(); $dataCellHTML = $this->datacells();

View File

@ -14,7 +14,7 @@ class RestrictedTextField extends TextField {
} }
function Field() { function Field() {
Requirements::javascript( 'sapphire/javascript/UniqueFields.js' ); Requirements::javascript( SAPPHIRE_DIR . '/javascript/UniqueFields.js' );
if($this->maxLength){ if($this->maxLength){
$field = "<input class=\"text restricted\" type=\"text\" id=\"" . $this->id() . "\" name=\"{$this->name}\" value=\"" . $this->attrValue() . "\" maxlength=\"$this->maxLength\" />"; $field = "<input class=\"text restricted\" type=\"text\" id=\"" . $this->id() . "\" name=\"{$this->name}\" value=\"" . $this->attrValue() . "\" maxlength=\"$this->maxLength\" />";

View File

@ -20,36 +20,36 @@ class ScaffoldingComplexTableField_Popup extends Form {
* WARNING: DO NOT CHANGE THE ORDER OF THESE JS FILES * WARNING: DO NOT CHANGE THE ORDER OF THESE JS FILES
* Some have special requirements. * Some have special requirements.
*/ */
//Requirements::css('cms/css/layout.css'); //Requirements::css(CMS_DIR . 'css/layout.css');
Requirements::css('jsparty/tabstrip/tabstrip.css'); Requirements::css(THIRDPARTY_DIR . '/tabstrip/tabstrip.css');
Requirements::css('sapphire/css/Form.css'); Requirements::css(SAPPHIRE_DIR . '/css/Form.css');
Requirements::css('sapphire/css/ComplexTableField_popup.css'); Requirements::css(SAPPHIRE_DIR . '/css/ComplexTableField_popup.css');
Requirements::css('cms/css/typography.css'); Requirements::css(CMS_DIR . '/css/typography.css');
Requirements::css('cms/css/cms_right.css'); Requirements::css(CMS_DIR . '/css/cms_right.css');
Requirements::css('jsparty/jquery/plugins/autocomplete/jquery.ui.autocomplete.css'); Requirements::css(THIRDPARTY_DIR . '/jquery/plugins/autocomplete/jquery.ui.autocomplete.css');
Requirements::javascript("jsparty/prototype.js"); Requirements::javascript(THIRDPARTY_DIR . "/prototype.js");
Requirements::javascript("jsparty/behaviour.js"); Requirements::javascript(THIRDPARTY_DIR . "/behaviour.js");
Requirements::javascript("jsparty/prototype_improvements.js"); Requirements::javascript(THIRDPARTY_DIR . "/prototype_improvements.js");
Requirements::javascript("jsparty/loader.js"); Requirements::javascript(THIRDPARTY_DIR . "/loader.js");
Requirements::javascript("jsparty/tabstrip/tabstrip.js"); Requirements::javascript(THIRDPARTY_DIR . "/tabstrip/tabstrip.js");
Requirements::javascript("jsparty/scriptaculous/scriptaculous.js"); Requirements::javascript(THIRDPARTY_DIR . "/scriptaculous/scriptaculous.js");
Requirements::javascript("jsparty/scriptaculous/controls.js"); Requirements::javascript(THIRDPARTY_DIR . "/scriptaculous/controls.js");
Requirements::javascript("jsparty/layout_helpers.js"); Requirements::javascript(THIRDPARTY_DIR . "/layout_helpers.js");
Requirements::javascript("cms/javascript/LeftAndMain.js"); Requirements::javascript(CMS_DIR . "/javascript/LeftAndMain.js");
Requirements::javascript("cms/javascript/LeftAndMain_right.js"); Requirements::javascript(CMS_DIR . "/javascript/LeftAndMain_right.js");
Requirements::javascript("sapphire/javascript/TableField.js"); Requirements::javascript(SAPPHIRE_DIR . "/javascript/TableField.js");
Requirements::javascript("sapphire/javascript/ComplexTableField.js"); Requirements::javascript(SAPPHIRE_DIR . "/javascript/ComplexTableField.js");
Requirements::javascript("sapphire/javascript/ComplexTableField_popup.js"); Requirements::javascript(SAPPHIRE_DIR . "/javascript/ComplexTableField_popup.js");
// jQuery requirements (how many of these are actually needed?) // jQuery requirements (how many of these are actually needed?)
Requirements::javascript('jsparty/jquery/jquery.js'); Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
Requirements::javascript('jsparty/jquery/plugins/livequery/jquery.livequery.js'); Requirements::javascript(THIRDPARTY_DIR . '/jquery/plugins/livequery/jquery.livequery.js');
Requirements::javascript('jsparty/jquery/ui/ui.core.js'); Requirements::javascript(THIRDPARTY_DIR . '/jquery/ui/ui.core.js');
Requirements::javascript('jsparty/jquery/ui/ui.tabs.js'); Requirements::javascript(THIRDPARTY_DIR . '/jquery/ui/ui.tabs.js');
Requirements::javascript('jsparty/jquery/plugins/form/jquery.form.js'); Requirements::javascript(THIRDPARTY_DIR . '/jquery/plugins/form/jquery.form.js');
Requirements::javascript('jsparty/jquery/plugins/dimensions/jquery.dimensions.js'); Requirements::javascript(THIRDPARTY_DIR . '/jquery/plugins/dimensions/jquery.dimensions.js');
Requirements::javascript('jsparty/jquery/plugins/autocomplete/jquery.ui.autocomplete.js'); Requirements::javascript(THIRDPARTY_DIR . '/jquery/plugins/autocomplete/jquery.ui.autocomplete.js');
Requirements::javascript('sapphire/javascript/ScaffoldComplexTableField.js'); Requirements::javascript(SAPPHIRE_DIR . '/javascript/ScaffoldComplexTableField.js');
Requirements::javascript('cms/javascript/ModelAdmin.js'); Requirements::javascript(CMS_DIR . '/javascript/ModelAdmin.js');
if($this->dataObject->hasMethod('getRequirementsForPopup')) { if($this->dataObject->hasMethod('getRequirementsForPopup')) {
$this->dataObject->getRequirementsForPopup(); $this->dataObject->getRequirementsForPopup();

View File

@ -22,7 +22,7 @@ class SelectionGroup extends CompositeField {
parent::__construct($items); parent::__construct($items);
Requirements::css('sapphire/css/SelectionGroup.css'); Requirements::css(SAPPHIRE_DIR . '/css/SelectionGroup.css');
} }
/** /**
@ -78,10 +78,10 @@ class SelectionGroup extends CompositeField {
} }
function FieldHolder() { function FieldHolder() {
Requirements::javascript('jsparty/prototype.js'); Requirements::javascript(THIRDPARTY_DIR . '/prototype.js');
Requirements::javascript('jsparty/behaviour.js'); Requirements::javascript(THIRDPARTY_DIR . '/behaviour.js');
Requirements::javascript('jsparty/prototype_improvements.js'); Requirements::javascript(THIRDPARTY_DIR . '/prototype_improvements.js');
Requirements::javascript('sapphire/javascript/SelectionGroup.js'); Requirements::javascript(SAPPHIRE_DIR . '/javascript/SelectionGroup.js');
return $this->renderWith("SelectionGroup"); return $this->renderWith("SelectionGroup");

View File

@ -114,7 +114,7 @@ class TableField extends TableListField {
} }
parent::__construct($name, $sourceClass, $fieldList, $sourceFilter, $sourceSort, $sourceJoin); parent::__construct($name, $sourceClass, $fieldList, $sourceFilter, $sourceSort, $sourceJoin);
Requirements::javascript('sapphire/javascript/TableField.js'); Requirements::javascript(SAPPHIRE_DIR . '/javascript/TableField.js');
} }
/** /**

View File

@ -239,12 +239,12 @@ class TableListField extends FormField {
parent::__construct($name); parent::__construct($name);
Requirements::javascript('jsparty/prototype.js'); Requirements::javascript(THIRDPARTY_DIR . 'jsparty/prototype.js');
Requirements::javascript('jsparty/behaviour.js'); Requirements::javascript(THIRDPARTY_DIR . 'jsparty/behaviour.js');
Requirements::javascript('jsparty/prototype_improvements.js'); Requirements::javascript(THIRDPARTY_DIR . 'jsparty/prototype_improvements.js');
Requirements::javascript('jsparty/scriptaculous/effects.js'); Requirements::javascript(THIRDPARTY_DIR . 'jsparty/scriptaculous/effects.js');
Requirements::javascript('sapphire/javascript/TableListField.js'); Requirements::javascript(SAPPHIRE_DIR . '/javascript/TableListField.js');
Requirements::css('sapphire/css/TableListField.css'); Requirements::css(SAPPHIRE_DIR . '/css/TableListField.css');
} }
/** /**
@ -944,9 +944,9 @@ JS
function printall() { function printall() {
Requirements::clear(); Requirements::clear();
Requirements::css('cms/css/typography.css'); Requirements::css(CMS_DIR . '/css/typography.css');
Requirements::css('cms/css/cms_right.css'); Requirements::css(CMS_DIR . '/css/cms_right.css');
Requirements::css('sapphire/css/TableListField_print.css'); Requirements::css(SAPPHIRE_DIR . '/css/TableListField_print.css');
$vd = new ViewableData(); $vd = new ViewableData();
return $vd->customise(array( return $vd->customise(array(
'Content' => $this->customise(array( 'Content' => $this->customise(array(

View File

@ -21,10 +21,10 @@ class ToggleCompositeField extends CompositeField {
} }
public function FieldHolder() { public function FieldHolder() {
Requirements::javascript("jsparty/prototype.js"); Requirements::javascript(THIRDPARTY_DIR . "/prototype.js");
Requirements::javascript("jsparty/behaviour.js"); Requirements::javascript(THIRDPARTY_DIR . "/behaviour.js");
Requirements::javascript("jsparty/prototype_improvements.js"); Requirements::javascript(THIRDPARTY_DIR . "/prototype_improvements.js");
Requirements::javascript("sapphire/javascript/ToggleCompositeField.js"); Requirements::javascript(SAPPHIRE_DIR . "/javascript/ToggleCompositeField.js");
return $this->renderWith("ToggleCompositeField"); return $this->renderWith("ToggleCompositeField");
} }

View File

@ -48,10 +48,10 @@ class ToggleField extends ReadonlyField {
function Field() { function Field() {
$content = ''; $content = '';
Requirements::javascript("jsparty/prototype.js"); Requirements::javascript(THIRDPARTY_DIR . "/prototype.js");
Requirements::javascript("jsparty/behaviour.js"); Requirements::javascript(THIRDPARTY_DIR . "/behaviour.js");
Requirements::javascript("jsparty/prototype_improvements.js"); Requirements::javascript(THIRDPARTY_DIR . "/prototype_improvements.js");
Requirements::javascript("sapphire/javascript/ToggleField.js"); Requirements::javascript(SAPPHIRE_DIR . "/javascript/ToggleField.js");
if($this->startClosed) $this->addExtraClass('startClosed'); if($this->startClosed) $this->addExtraClass('startClosed');

View File

@ -21,7 +21,7 @@ class TreeDropdownField extends FormField {
$this->keyField = $keyField; $this->keyField = $keyField;
$this->labelField = $labelField; $this->labelField = $labelField;
Requirements::css('sapphire/css/TreeDropdownField.css'); Requirements::css(SAPPHIRE_DIR . '/css/TreeDropdownField.css');
parent::__construct($name, $title); parent::__construct($name, $title);
} }
@ -37,9 +37,9 @@ class TreeDropdownField extends FormField {
} }
function Field() { function Field() {
Requirements::javascript("jsparty/tree/tree.js"); Requirements::javascript(THIRDPARTY_DIR . "/tree/tree.js");
Requirements::css("jsparty/tree/tree.css"); Requirements::css(THIRDPARTY_DIR . "/tree/tree.css");
Requirements::javascript("sapphire/javascript/TreeSelectorField.js"); Requirements::javascript(SAPPHIRE_DIR . "/javascript/TreeSelectorField.js");
if($this->value) { if($this->value) {
$record = DataObject::get_by_id($this->sourceObject, $this->value); $record = DataObject::get_by_id($this->sourceObject, $this->value);

View File

@ -29,7 +29,7 @@ class TreeMultiselectField extends TreeDropdownField {
function Field() { function Field() {
$value = ''; $value = '';
$itemList = ''; $itemList = '';
Requirements::javascript("sapphire/javascript/TreeSelectorField.js"); Requirements::javascript(SAPPHIRE_DIR . "/javascript/TreeSelectorField.js");
$items = $this->getItems(); $items = $this->getItems();
if($items) { if($items) {

View File

@ -13,7 +13,7 @@ class TreeSelectorField extends FormField {
} }
function Field() { function Field() {
Requirements::javascript("sapphire/javascript/TreeSelectorField.js"); Requirements::javascript(SAPPHIRE_DIR . "/javascript/TreeSelectorField.js");
$fieldName = $this->name; $fieldName = $this->name;
if($this->form) { if($this->form) {

View File

@ -23,7 +23,7 @@ class UniqueTextField extends TextField {
} }
function Field() { function Field() {
Requirements::javascript("sapphire/javascript/UniqueFields.js"); Requirements::javascript(SAPPHIRE_DIR . "/javascript/UniqueFields.js");
/* /*
$restrictedValues = array(); $restrictedValues = array();

View File

@ -55,7 +55,7 @@ abstract class Validator extends Object {
if(self::$javascript_validation_handler) $this->setJavascriptValidationHandler(self::$javascript_validation_handler); if(self::$javascript_validation_handler) $this->setJavascriptValidationHandler(self::$javascript_validation_handler);
if($this->javascriptValidationHandler) { if($this->javascriptValidationHandler) {
Requirements::javascript('sapphire/javascript/Validator.js'); Requirements::javascript(SAPPHIRE_DIR . '/javascript/Validator.js');
} }
parent::__construct(); parent::__construct();
} }
@ -110,10 +110,10 @@ abstract class Validator extends Object {
function includeJavascriptValidation() { function includeJavascriptValidation() {
if($this->javascriptValidationHandler == 'prototype') { if($this->javascriptValidationHandler == 'prototype') {
Requirements::javascript("jsparty/prototype.js"); Requirements::javascript(THIRDPARTY_DIR . "/prototype.js");
Requirements::javascript("jsparty/behaviour.js"); Requirements::javascript(THIRDPARTY_DIR . "/behaviour.js");
Requirements::javascript("jsparty/prototype_improvements.js"); Requirements::javascript(THIRDPARTY_DIR . "/prototype_improvements.js");
Requirements::javascript("sapphire/javascript/Validator.js"); Requirements::javascript(SAPPHIRE_DIR . "/javascript/Validator.js");
$code = $this->javascript(); $code = $this->javascript();
$formID = $this->form->FormName(); $formID = $this->form->FormName();

View File

@ -26,8 +26,8 @@ class FieldEditor extends FormField {
} }
function Fields() { function Fields() {
Requirements::css("sapphire/css/FieldEditor.css"); Requirements::css(SAPPHIRE_DIR . "/css/FieldEditor.css");
Requirements::javascript("sapphire/javascript/FieldEditor.js"); Requirements::javascript(SAPPHIRE_DIR . "/javascript/FieldEditor.js");
$relationName = $this->name; $relationName = $this->name;

View File

@ -14,7 +14,7 @@ class SubmittedFormReportField extends FormField {
} }
function Field() { function Field() {
Requirements::css("sapphire/css/SubmittedFormReportField.css"); Requirements::css(SAPPHIRE_DIR . "/css/SubmittedFormReportField.css");
return $this->renderWith("SubmittedFormReportField"); return $this->renderWith("SubmittedFormReportField");
} }

View File

@ -46,6 +46,24 @@ foreach ($envFiles as $envFile) {
} }
} }
/**
* Define system paths
*/
define('BASE_PATH', dirname(dirname($_SERVER['SCRIPT_FILENAME'])));
define('BASE_URL', dirname(dirname($_SERVER['SCRIPT_NAME'])));
define('MODULES_DIR', 'modules');
define('MODULES_PATH', BASE_PATH . '/' . MODULES_DIR);
define('THIRDPARTY_DIR', 'jsparty');
define('THIRDPARTY_PATH', BASE_PATH . '/' . THIRDPARTY_DIR);
define('THEMES_DIR', 'themes');
define('THEMES_PATH', BASE_PATH . '/' . THEMES_DIR);
define('SAPPHIRE_DIR', 'sapphire');
define('SAPPHIRE_PATH', BASE_PATH . '/' . SAPPHIRE_DIR);
define('CMS_DIR', 'cms');
define('CMS_PATH', BASE_PATH . '/' . CMS_DIR);
define('ASSETS_DIR', 'assets');
define('ASSETS_PATH', BASE_PATH . '/' . ASSETS_DIR);
/** /**
* Include Sapphire's core code * Include Sapphire's core code
*/ */
@ -154,11 +172,7 @@ if (isset($_GET['debug_profile'])) Profiler::unmark('DB::connect');
// Get the request URL // Get the request URL
$baseURL = dirname(dirname($_SERVER['SCRIPT_NAME'])); if (substr($url, 0, strlen(BASE_URL)) == BASE_URL) $url = substr($url, strlen(BASE_URL));
if (substr($url, 0, strlen($baseURL)) == $baseURL) $url = substr($url, strlen($baseURL));
// Direct away - this is the "main" function, that hands control to the appropriate controller // Direct away - this is the "main" function, that hands control to the appropriate controller
if (isset($_GET['debug_profile'])) Profiler::unmark('main.php init'); if (isset($_GET['debug_profile'])) Profiler::unmark('main.php init');

View File

@ -1248,20 +1248,20 @@ class Member_ProfileForm extends Form {
function __construct($controller, $name, $member) { function __construct($controller, $name, $member) {
Requirements::clear(); Requirements::clear();
Requirements::css('jsparty/tabstrip/tabstrip.css'); Requirements::css(THIRDPARTY_DIR . '/tabstrip/tabstrip.css');
Requirements::css('cms/css/typography.css'); Requirements::css(CMS_DIR . '/css/typography.css');
Requirements::css('cms/css/cms_right.css'); Requirements::css(CMS_DIR . '/css/cms_right.css');
Requirements::javascript("jsparty/prototype.js"); Requirements::javascript(THIRDPARTY_DIR . "/prototype.js");
Requirements::javascript("jsparty/behaviour.js"); Requirements::javascript(THIRDPARTY_DIR . "/behaviour.js");
Requirements::javascript("jsparty/prototype_improvements.js"); Requirements::javascript(THIRDPARTY_DIR . "/prototype_improvements.js");
Requirements::javascript("jsparty/loader.js"); Requirements::javascript(THIRDPARTY_DIR . "/loader.js");
Requirements::javascript("jsparty/tabstrip/tabstrip.js"); Requirements::javascript(THIRDPARTY_DIR . "/tabstrip/tabstrip.js");
Requirements::javascript("jsparty/scriptaculous/scriptaculous.js"); Requirements::javascript(THIRDPARTY_DIR . "/scriptaculous/scriptaculous.js");
Requirements::javascript("jsparty/scriptaculous/controls.js"); Requirements::javascript(THIRDPARTY_DIR . "/scriptaculous/controls.js");
Requirements::javascript("jsparty/layout_helpers.js"); Requirements::javascript(THIRDPARTY_DIR . "/layout_helpers.js");
Requirements::css("sapphire/css/Form.css"); Requirements::css(SAPPHIRE_DIR . "/css/Form.css");
Requirements::css("sapphire/css/MemberProfileForm.css"); Requirements::css(SAPPHIRE_DIR . "/css/MemberProfileForm.css");
$fields = singleton('Member')->getCMSFields(); $fields = singleton('Member')->getCMSFields();

View File

@ -296,14 +296,14 @@ class Security extends Controller {
// only display tabs when more than one authenticator is provided // only display tabs when more than one authenticator is provided
// to save bandwidth and reduce the amount of custom styling needed // to save bandwidth and reduce the amount of custom styling needed
if(count($forms) > 1) { if(count($forms) > 1) {
Requirements::javascript("jsparty/loader.js"); Requirements::javascript(THIRDPARTY_DIR . "/loader.js");
Requirements::javascript("jsparty/prototype.js"); Requirements::javascript(THIRDPARTY_DIR . "/prototype.js");
Requirements::javascript("jsparty/behaviour.js"); Requirements::javascript(THIRDPARTY_DIR . "/behaviour.js");
Requirements::javascript("jsparty/prototype_improvements.js"); Requirements::javascript(THIRDPARTY_DIR . "/prototype_improvements.js");
Requirements::javascript("jsparty/tabstrip/tabstrip.js"); Requirements::javascript(THIRDPARTY_DIR . "/tabstrip/tabstrip.js");
Requirements::javascript("jsparty/scriptaculous/effects.js"); Requirements::javascript(THIRDPARTY_DIR . "/scriptaculous/effects.js");
Requirements::css("jsparty/tabstrip/tabstrip.css"); Requirements::css(THIRDPARTY_DIR . "/tabstrip/tabstrip.css");
Requirements::css("sapphire/css/Form.css"); Requirements::css(SAPPHIRE_DIR . "/css/Form.css");
// Needed because the <base href=".."> in the template makes problems // Needed because the <base href=".."> in the template makes problems
// with the tabstrip library otherwise // with the tabstrip library otherwise
@ -360,11 +360,11 @@ class Security extends Controller {
* @return string Returns the "lost password" page as HTML code. * @return string Returns the "lost password" page as HTML code.
*/ */
public function lostpassword() { public function lostpassword() {
Requirements::javascript('jsparty/prototype.js'); Requirements::javascript(THIRDPARTY_DIR . 'jsparty/prototype.js');
Requirements::javascript('jsparty/behaviour.js'); Requirements::javascript(THIRDPARTY_DIR . 'jsparty/behaviour.js');
Requirements::javascript('jsparty/loader.js'); Requirements::javascript(THIRDPARTY_DIR . 'jsparty/loader.js');
Requirements::javascript('jsparty/prototype_improvements.js'); Requirements::javascript(THIRDPARTY_DIR . 'jsparty/prototype_improvements.js');
Requirements::javascript('jsparty/scriptaculous/effects.js'); Requirements::javascript(THIRDPARTY_DIR . 'jsparty/scriptaculous/effects.js');
$tmpPage = new Page(); $tmpPage = new Page();
$tmpPage->Title = _t('Security.LOSTPASSWORDHEADER', 'Lost Password'); $tmpPage->Title = _t('Security.LOSTPASSWORDHEADER', 'Lost Password');
@ -410,11 +410,11 @@ class Security extends Controller {
* @return string Returns the "password sent" page as HTML code. * @return string Returns the "password sent" page as HTML code.
*/ */
public function passwordsent($request) { public function passwordsent($request) {
Requirements::javascript('jsparty/behaviour.js'); Requirements::javascript(THIRDPARTY_DIR . 'jsparty/behaviour.js');
Requirements::javascript('jsparty/loader.js'); Requirements::javascript(THIRDPARTY_DIR . 'jsparty/loader.js');
Requirements::javascript('jsparty/prototype.js'); Requirements::javascript(THIRDPARTY_DIR . 'jsparty/prototype.js');
Requirements::javascript('jsparty/prototype_improvements.js'); Requirements::javascript(THIRDPARTY_DIR . 'jsparty/prototype_improvements.js');
Requirements::javascript('jsparty/scriptaculous/effects.js'); Requirements::javascript(THIRDPARTY_DIR . 'jsparty/scriptaculous/effects.js');
$tmpPage = new Page(); $tmpPage = new Page();
$tmpPage->Title = _t('Security.LOSTPASSWORDHEADER'); $tmpPage->Title = _t('Security.LOSTPASSWORDHEADER');

View File

@ -135,7 +135,7 @@ class ManifestBuilderTest extends SapphireTest {
// Kill the folder after we're done // Kill the folder after we're done
$baseFolder = TEMP_FOLDER . '/manifest-test/'; $baseFolder = TEMP_FOLDER . '/manifest-test/';
Filesystem::removeFolder($baseFolder); //Filesystem::removeFolder($baseFolder);
} }
} }

View File

@ -8,8 +8,8 @@ class FileTest extends SapphireTest {
function testLinkAndRelativeLink() { function testLinkAndRelativeLink() {
$file = $this->objFromFixture('File', 'asdf'); $file = $this->objFromFixture('File', 'asdf');
$this->assertEquals('assets/asdfjkl.txt', $file->RelativeLink()); $this->assertEquals(ASSETS_DIR . '/asdfjkl.txt', $file->RelativeLink());
$this->assertEquals(Director::baseURL() . 'assets/asdfjkl.txt', $file->Link()); $this->assertEquals(Director::baseURL() . ASSETS_DIR . '/asdfjkl.txt', $file->Link());
} }
function testNameAndTitleGeneration() { function testNameAndTitleGeneration() {
@ -20,7 +20,7 @@ class FileTest extends SapphireTest {
/* However, if Name is set instead of Filename, then Title is set */ /* However, if Name is set instead of Filename, then Title is set */
$file = $this->objFromFixture('File', 'setfromname'); $file = $this->objFromFixture('File', 'setfromname');
$this->assertEquals('assets/asdfjkl.png', $file->Filename); $this->assertEquals(ASSETS_DIR . '/asdfjkl.png', $file->Filename);
$this->assertEquals('asdfjkl', $file->Title); $this->assertEquals('asdfjkl', $file->Title);
} }
@ -30,27 +30,27 @@ class FileTest extends SapphireTest {
/* If you alter the Name attribute of a file, then the filesystem is also affected */ /* If you alter the Name attribute of a file, then the filesystem is also affected */
$file->Name = 'asdfjkl2.txt'; $file->Name = 'asdfjkl2.txt';
clearstatcache(); clearstatcache();
$this->assertFileNotExists("../assets/asdfjkl.txt"); $this->assertFileNotExists(ASSETS_PATH . "/asdfjkl.txt");
$this->assertFileExists("../assets/asdfjkl2.txt"); $this->assertFileExists(ASSETS_PATH . "/asdfjkl2.txt");
/* The Filename field is also updated */ /* The Filename field is also updated */
$this->assertEquals('assets/asdfjkl2.txt', $file->Filename); $this->assertEquals(ASSETS_DIR . '/asdfjkl2.txt', $file->Filename);
/* However, if you alter the Filename attribute, the the filesystem isn't affected. Altering Filename directly isn't /* However, if you alter the Filename attribute, the the filesystem isn't affected. Altering Filename directly isn't
recommended */ recommended */
$file->Filename = 'assets/asdfjkl3.txt'; $file->Filename = ASSETS_DIR . '/asdfjkl3.txt';
clearstatcache(); clearstatcache();
$this->assertFileExists("../assets/asdfjkl2.txt"); $this->assertFileExists(ASSETS_PATH . "/asdfjkl2.txt");
$this->assertFileNotExists("../assets/asdfjkl3.txt"); $this->assertFileNotExists(ASSETS_PATH . "/asdfjkl3.txt");
$file->Filename = 'assets/asdfjkl2.txt'; $file->Filename = ASSETS_DIR . '/asdfjkl2.txt';
$file->write(); $file->write();
/* Instead, altering Name and ParentID is the recommended way of changing the name and location of a file */ /* Instead, altering Name and ParentID is the recommended way of changing the name and location of a file */
$file->ParentID = $this->idFromFixture('Folder', 'subfolder'); $file->ParentID = $this->idFromFixture('Folder', 'subfolder');
clearstatcache(); clearstatcache();
$this->assertFileExists("../assets/subfolder/asdfjkl2.txt"); $this->assertFileExists(ASSETS_PATH . "/subfolder/asdfjkl2.txt");
$this->assertFileNotExists("../assets/asdfjkl2.txt"); $this->assertFileNotExists(ASSETS_PATH . "/asdfjkl2.txt");
$this->assertEquals('assets/subfolder/asdfjkl2.txt', $file->Filename); $this->assertEquals(ASSETS_DIR . '/subfolder/asdfjkl2.txt', $file->Filename);
$file->write(); $file->write();
} }

View File

@ -125,16 +125,16 @@ class RequirementsTest extends SapphireTest {
Requirements::delete_combined_files('bc.js'); Requirements::delete_combined_files('bc.js');
// require files normally (e.g. called from a FormField instance) // require files normally (e.g. called from a FormField instance)
Requirements::javascript('sapphire/tests/forms/a.js'); Requirements::javascript(SAPPHIRE_DIR . '/tests/forms/a.js');
Requirements::javascript('sapphire/tests/forms/b.js'); Requirements::javascript(SAPPHIRE_DIR . '/tests/forms/b.js');
Requirements::javascript('sapphire/tests/forms/c.js'); Requirements::javascript(SAPPHIRE_DIR . '/tests/forms/c.js');
// require two of those files as combined includes // require two of those files as combined includes
Requirements::combine_files( Requirements::combine_files(
'bc.js', 'bc.js',
array( array(
'sapphire/tests/forms/b.js', SAPPHIRE_DIR . '/tests/forms/b.js',
'sapphire/tests/forms/c.js' SAPPHIRE_DIR . '/tests/forms/c.js'
) )
); );
} }