mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Cleanup trailing whitespace
This commit is contained in:
parent
016ea2efb1
commit
3dada00905
@ -111,7 +111,7 @@ if(!defined('TRUSTED_PROXY')) {
|
||||
*/
|
||||
if(!isset($_SERVER['HTTP_HOST'])) {
|
||||
// HTTP_HOST, REQUEST_PORT, SCRIPT_NAME, and PHP_SELF
|
||||
global $_FILE_TO_URL_MAPPING;
|
||||
global $_FILE_TO_URL_MAPPING;
|
||||
if(isset($_FILE_TO_URL_MAPPING)) {
|
||||
$fullPath = $testPath = realpath($_SERVER['SCRIPT_FILENAME']);
|
||||
while($testPath && $testPath != '/' && !preg_match('/^[A-Z]:\\\\$/', $testPath)) {
|
||||
@ -159,7 +159,7 @@ if(!isset($_SERVER['HTTP_HOST'])) {
|
||||
$trustedProxyHeader = (defined('SS_TRUSTED_PROXY_HOST_HEADER'))
|
||||
? SS_TRUSTED_PROXY_HOST_HEADER
|
||||
: 'HTTP_X_FORWARDED_HOST';
|
||||
|
||||
|
||||
if (TRUSTED_PROXY && !empty($_SERVER[$trustedProxyHeader])) {
|
||||
// Get the first host, in case there's multiple separated through commas
|
||||
$_SERVER['HTTP_HOST'] = strtok($_SERVER[$trustedProxyHeader], ',');
|
||||
|
@ -250,7 +250,7 @@ class SS_ConfigManifest {
|
||||
|
||||
// Keep track of all the modules we've seen
|
||||
$this->addModule(dirname(dirname($pathname)));
|
||||
|
||||
|
||||
$parser = new Parser();
|
||||
|
||||
// The base header
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* Base class for development tools.
|
||||
*
|
||||
*
|
||||
* Configured in framework/_config/dev.yml, with the config key registeredControllers being
|
||||
* used to generate the list of links for /dev.
|
||||
*
|
||||
@ -21,9 +21,9 @@ class DevelopmentAdmin extends Controller {
|
||||
'generatesecuretoken' => 'generatesecuretoken',
|
||||
'$Action' => 'runRegisteredController',
|
||||
);
|
||||
|
||||
private static $allowed_actions = array(
|
||||
'index',
|
||||
|
||||
private static $allowed_actions = array(
|
||||
'index',
|
||||
'buildDefaults',
|
||||
'runRegisteredController',
|
||||
'generatesecuretoken',
|
||||
@ -110,17 +110,17 @@ class DevelopmentAdmin extends Controller {
|
||||
|
||||
public function runRegisteredController(SS_HTTPRequest $request){
|
||||
$controllerClass = null;
|
||||
|
||||
|
||||
$baseUrlPart = $request->param('Action');
|
||||
$reg = Config::inst()->get(__CLASS__, 'registered_controllers');
|
||||
if(isset($reg[$baseUrlPart])){
|
||||
$controllerClass = $reg[$baseUrlPart]['controller'];
|
||||
}
|
||||
|
||||
|
||||
if($controllerClass && class_exists($controllerClass)){
|
||||
return $controllerClass::create();
|
||||
}
|
||||
|
||||
|
||||
$msg = 'Error: no controller registered in '.__CLASS__.' for: '.$request->param('Action');
|
||||
if(Director::is_cli()){
|
||||
// in CLI we cant use httpError because of a bug with stuff being in the output already, see DevAdminControllerTest
|
||||
@ -130,9 +130,9 @@ class DevelopmentAdmin extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Internal methods
|
||||
*/
|
||||
@ -142,7 +142,7 @@ class DevelopmentAdmin extends Controller {
|
||||
*/
|
||||
protected static function get_links(){
|
||||
$links = array();
|
||||
|
||||
|
||||
$reg = Config::inst()->get(__CLASS__, 'registered_controllers');
|
||||
foreach($reg as $registeredController){
|
||||
foreach($registeredController['links'] as $url => $desc){
|
||||
@ -154,18 +154,18 @@ class DevelopmentAdmin extends Controller {
|
||||
|
||||
protected function getRegisteredController($baseUrlPart){
|
||||
$reg = Config::inst()->get(__CLASS__, 'registered_controllers');
|
||||
|
||||
|
||||
if(isset($reg[$baseUrlPart])){
|
||||
$controllerClass = $reg[$baseUrlPart]['controller'];
|
||||
return $controllerClass;
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Unregistered (hidden) actions
|
||||
*/
|
||||
|
@ -4,42 +4,42 @@ use Symfony\Component\Yaml\Parser;
|
||||
|
||||
/**
|
||||
* Uses Symfony's YAML component to parse a YAML document (see http://yaml.org).
|
||||
* YAML is a simple markup languages that uses tabs and colons instead of the more verbose XML tags,
|
||||
* YAML is a simple markup languages that uses tabs and colons instead of the more verbose XML tags,
|
||||
* and because of this much better for developers creating files by hand.
|
||||
*
|
||||
*
|
||||
* The contents of the YAML file are broken into three levels:
|
||||
* - Top level: class names - Page and ErrorPage. This is the name of the dataobject class that should be created.
|
||||
* The fact that ErrorPage is actually a subclass is irrelevant to the system populating the database.
|
||||
* Each identifier you specify delimits a new database record.
|
||||
* - Top level: class names - Page and ErrorPage. This is the name of the dataobject class that should be created.
|
||||
* The fact that ErrorPage is actually a subclass is irrelevant to the system populating the database.
|
||||
* Each identifier you specify delimits a new database record.
|
||||
* This means that every record needs to have an identifier, whether you use it or not.
|
||||
* - Third level: fields - each field for the record is listed as a 3rd level entry.
|
||||
* In most cases, the field's raw content is provided.
|
||||
* - Third level: fields - each field for the record is listed as a 3rd level entry.
|
||||
* In most cases, the field's raw content is provided.
|
||||
* However, if you want to define a relationship, you can do so using "=>"
|
||||
*
|
||||
*
|
||||
* There are a couple of lines like this:
|
||||
* <code>
|
||||
* Parent: =>Page.about
|
||||
* </code>
|
||||
* This will tell the system to set the ParentID database field to the ID of the Page object with the identifier
|
||||
* 'about'. This can be used on any has-one or many-many relationship.
|
||||
* 'about'. This can be used on any has-one or many-many relationship.
|
||||
* Note that we use the name of the relationship (Parent), and not the name of the database field (ParentID)
|
||||
*
|
||||
* On many-many relationships, you should specify a comma separated list of values.
|
||||
* <code>
|
||||
* MyRelation: =>Class.inst1,=>Class.inst2,=>Class.inst3
|
||||
* </code>
|
||||
*
|
||||
* An crucial thing to note is that the YAML file specifies DataObjects, not database records.
|
||||
* The database is populated by instantiating DataObject objects, setting the fields listed, and calling write().
|
||||
* This means that any onBeforeWrite() or default value logic will be executed as part of the test.
|
||||
*
|
||||
* An crucial thing to note is that the YAML file specifies DataObjects, not database records.
|
||||
* The database is populated by instantiating DataObject objects, setting the fields listed, and calling write().
|
||||
* This means that any onBeforeWrite() or default value logic will be executed as part of the test.
|
||||
* This forms the basis of our testURLGeneration() test above.
|
||||
*
|
||||
* For example, the URLSegment value of Page.staffduplicate is the same as the URLSegment value of Page.staff.
|
||||
*
|
||||
* For example, the URLSegment value of Page.staffduplicate is the same as the URLSegment value of Page.staff.
|
||||
* When the fixture is set up, the URLSegment value of Page.staffduplicate will actually be my-staff-2.
|
||||
*
|
||||
* Finally, be aware that requireDefaultRecords() is not called by the database populator -
|
||||
*
|
||||
* Finally, be aware that requireDefaultRecords() is not called by the database populator -
|
||||
* so you will need to specify standard pages such as 404 and home in your YAML file.
|
||||
*
|
||||
*
|
||||
* <code>
|
||||
* Page:
|
||||
* home:
|
||||
@ -61,7 +61,7 @@ use Symfony\Component\Yaml\Parser;
|
||||
* Title: Page not Found
|
||||
* ErrorCode: 404
|
||||
* </code>
|
||||
*
|
||||
*
|
||||
* @package framework
|
||||
* @subpackage core
|
||||
*/
|
||||
@ -97,10 +97,10 @@ class YamlFixture extends Object {
|
||||
|
||||
$this->fixtureFile = $fixture;
|
||||
}
|
||||
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return String Absolute file path
|
||||
*/
|
||||
@ -119,7 +119,7 @@ class YamlFixture extends Object {
|
||||
* Persists the YAML data in a FixtureFactory,
|
||||
* which in turn saves them into the database.
|
||||
* Please use the passed in factory to access the fixtures afterwards.
|
||||
*
|
||||
*
|
||||
* @param FixtureFactory $factory
|
||||
*/
|
||||
public function writeInto(FixtureFactory $factory) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
/**
|
||||
* Mailer objects are responsible for actually sending emails.
|
||||
* The default Mailer class will use PHP's mail() function.
|
||||
*
|
||||
*
|
||||
* @package framework
|
||||
* @subpackage email
|
||||
*/
|
||||
@ -130,7 +130,7 @@ class Mailer extends Object {
|
||||
|
||||
/**
|
||||
* Send a plain-text email.
|
||||
*
|
||||
*
|
||||
* @param string $to Email recipient
|
||||
* @param string $from Email from
|
||||
* @param string $subject Subject text
|
||||
@ -179,7 +179,7 @@ class Mailer extends Object {
|
||||
|
||||
/**
|
||||
* Send an email of an arbitrary format
|
||||
*
|
||||
*
|
||||
* @param string $to To
|
||||
* @param string $from From
|
||||
* @param string $subject Subject
|
||||
@ -199,7 +199,7 @@ class Mailer extends Object {
|
||||
if($attachedFiles) {
|
||||
list($fullBody, $headers) = $this->encodeAttachments($attachedFiles, $headers, $fullBody);
|
||||
}
|
||||
|
||||
|
||||
// Get bounce email
|
||||
$bounceAddress = $this->getBounceEmail() ?: $from;
|
||||
if(preg_match('/^([^<>]*)<([^<>]+)> *$/', $bounceAddress, $parts)) $bounceAddress = $parts[2];
|
||||
@ -214,7 +214,7 @@ class Mailer extends Object {
|
||||
|
||||
/**
|
||||
* Send the actual email
|
||||
*
|
||||
*
|
||||
* @param string $to
|
||||
* @param string $subjectEncoded
|
||||
* @param string $fullBody
|
||||
@ -228,11 +228,11 @@ class Mailer extends Object {
|
||||
if(!$result) {
|
||||
$result = mail($to, $subjectEncoded, $fullBody, $headersEncoded);
|
||||
}
|
||||
|
||||
|
||||
if($result) {
|
||||
return array($to, $subjectEncoded, $fullBody, $headersEncoded, $bounceAddress);
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -271,7 +271,7 @@ class Mailer extends Object {
|
||||
*/
|
||||
protected function preparePlainSubmessage($plainContent, $htmlContent) {
|
||||
$plainEncoding = $this->getMessageEncoding();
|
||||
|
||||
|
||||
// Generate plain text version if not explicitly given
|
||||
if(!$plainContent) $plainContent = Convert::xml2raw($htmlContent);
|
||||
|
||||
@ -304,7 +304,7 @@ class Mailer extends Object {
|
||||
"\n</BODY>\n" .
|
||||
"</HTML>";
|
||||
}
|
||||
|
||||
|
||||
// Make the HTML part
|
||||
$headers["Content-Type"] = "text/html; charset=utf-8";
|
||||
$headers["Content-Transfer-Encoding"] = $this->getMessageEncoding();
|
||||
@ -366,36 +366,36 @@ class Mailer extends Object {
|
||||
|
||||
/**
|
||||
* Encode the contents of a file for emailing, including headers
|
||||
*
|
||||
*
|
||||
* $file can be an array, in which case it expects these members:
|
||||
* 'filename' - the filename of the file
|
||||
* 'contents' - the raw binary contents of the file as a string
|
||||
* and can optionally include these members:
|
||||
* 'mimetype' - the mimetype of the file (calculated from filename if missing)
|
||||
* 'contentLocation' - the 'Content-Location' header value for the file
|
||||
*
|
||||
*
|
||||
* $file can also be a string, in which case it is assumed to be the filename
|
||||
*
|
||||
*
|
||||
* h5. contentLocation
|
||||
*
|
||||
* Content Location is one of the two methods allowed for embedding images into an html email.
|
||||
*
|
||||
* Content Location is one of the two methods allowed for embedding images into an html email.
|
||||
* It's also the simplest, and best supported.
|
||||
*
|
||||
*
|
||||
* Assume we have an email with this in the body:
|
||||
*
|
||||
*
|
||||
* <img src="http://example.com/image.gif" />
|
||||
*
|
||||
* To display the image, an email viewer would have to download the image from the web every time
|
||||
* it is displayed. Due to privacy issues, most viewers will not display any images unless
|
||||
*
|
||||
* To display the image, an email viewer would have to download the image from the web every time
|
||||
* it is displayed. Due to privacy issues, most viewers will not display any images unless
|
||||
* the user clicks 'Show images in this email'. Not optimal.
|
||||
*
|
||||
* However, we can also include a copy of this image as an attached file in the email.
|
||||
* By giving it a contentLocation of "http://example.com/image.gif" most email viewers
|
||||
*
|
||||
* However, we can also include a copy of this image as an attached file in the email.
|
||||
* By giving it a contentLocation of "http://example.com/image.gif" most email viewers
|
||||
* will use this attached copy instead of downloading it. Better,
|
||||
* most viewers will show it without a 'Show images in this email' conformation.
|
||||
*
|
||||
*
|
||||
* Here is an example of passing this information through Email.php:
|
||||
*
|
||||
*
|
||||
* $email = new Email();
|
||||
* $email->attachments[] = array(
|
||||
* 'filename' => BASE_PATH . "/themes/mytheme/images/header.gif",
|
||||
@ -409,13 +409,13 @@ class Mailer extends Object {
|
||||
user_error("encodeFileForEmail: not passed a filename and/or data", E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (is_string($file)) {
|
||||
$file = array('filename' => $file);
|
||||
$fh = fopen($file['filename'], "rb");
|
||||
if ($fh) {
|
||||
$file['contents'] = "";
|
||||
while(!feof($fh)) $file['contents'] .= fread($fh, 10000);
|
||||
while(!feof($fh)) $file['contents'] .= fread($fh, 10000);
|
||||
fclose($fh);
|
||||
}
|
||||
}
|
||||
@ -427,7 +427,7 @@ class Mailer extends Object {
|
||||
$mimeType = !empty($file['mimetype']) ? $file['mimetype'] : HTTP::get_mime_type($file['filename']);
|
||||
if(!$mimeType) $mimeType = "application/unknown";
|
||||
if (empty($disposition)) $disposition = isset($file['contentLocation']) ? 'inline' : 'attachment';
|
||||
|
||||
|
||||
// Encode for emailing
|
||||
if (substr($mimeType, 0, 4) != 'text') {
|
||||
$encoding = "base64";
|
||||
@ -435,16 +435,16 @@ class Mailer extends Object {
|
||||
} else {
|
||||
// This mime type is needed, otherwise some clients will show it as an inline attachment
|
||||
$mimeType = 'application/octet-stream';
|
||||
$encoding = "quoted-printable";
|
||||
$encoding = "quoted-printable";
|
||||
$file['contents'] = quoted_printable_encode($file['contents']);
|
||||
}
|
||||
|
||||
$headers = "Content-type: $mimeType;\n\tname=\"$base\"\n".
|
||||
"Content-Transfer-Encoding: $encoding\n".
|
||||
"Content-Disposition: $disposition;\n\tfilename=\"$base\"\n";
|
||||
|
||||
|
||||
if ( isset($file['contentLocation']) ) $headers .= 'Content-Location: ' . $file['contentLocation'] . "\n" ;
|
||||
|
||||
|
||||
$headers .= $extraHeaders . "\n";
|
||||
|
||||
// Return completed packet
|
||||
@ -472,7 +472,7 @@ class Mailer extends Object {
|
||||
$emailAddress = str_replace('@', '', substr($emailAddress, 0, $openBracket))
|
||||
. substr($emailAddress, $openBracket);
|
||||
}
|
||||
|
||||
|
||||
return $emailAddress;
|
||||
}
|
||||
|
||||
|
@ -66,4 +66,4 @@ class AssetAdapterTest extends SapphireTest {
|
||||
// Test url
|
||||
$this->assertEquals('/assets/file.jpg', $adapter->getProtectedUrl('file.jpg'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ class File extends DataObject implements ShortcodeHandler, AssetContainer {
|
||||
"Parent" => "File",
|
||||
"Owner" => "Member"
|
||||
);
|
||||
|
||||
|
||||
private static $defaults = array(
|
||||
"ShowInSearch" => 1,
|
||||
);
|
||||
@ -205,7 +205,7 @@ class File extends DataObject implements ShortcodeHandler, AssetContainer {
|
||||
|
||||
/**
|
||||
* Replace"[file_link id=n]" shortcode with an anchor tag or link to the file.
|
||||
*
|
||||
*
|
||||
* @param array $arguments Arguments passed to the parser
|
||||
* @param string $content Raw shortcode
|
||||
* @param ShortcodeParser $parser Parser
|
||||
@ -491,7 +491,7 @@ class File extends DataObject implements ShortcodeHandler, AssetContainer {
|
||||
|
||||
// Check configured categories
|
||||
$appCategories = self::config()->app_categories;
|
||||
|
||||
|
||||
// Merge all categories into list of extensions
|
||||
$extensions = array();
|
||||
foreach(array_filter($categories) as $category) {
|
||||
@ -710,7 +710,7 @@ class File extends DataObject implements ShortcodeHandler, AssetContainer {
|
||||
if($parent && $parent->exists()) {
|
||||
return $this->join_paths($parent->getFilename(), $this->Name);
|
||||
}
|
||||
|
||||
|
||||
return $this->Name;
|
||||
}
|
||||
|
||||
@ -743,7 +743,7 @@ class File extends DataObject implements ShortcodeHandler, AssetContainer {
|
||||
if($parent && $parent->exists()) {
|
||||
$folder = $parent->Filename;
|
||||
}
|
||||
|
||||
|
||||
// Detect change in foldername
|
||||
$newFolder = ltrim(dirname(trim($filename, '/')), '.');
|
||||
if($folder !== $newFolder) {
|
||||
@ -894,7 +894,7 @@ class File extends DataObject implements ShortcodeHandler, AssetContainer {
|
||||
}
|
||||
return round($size/(1024*1024*1024)*10)/10 . ' GB';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert a php.ini value (eg: 512M) to bytes
|
||||
*
|
||||
@ -917,7 +917,7 @@ class File extends DataObject implements ShortcodeHandler, AssetContainer {
|
||||
|
||||
/**
|
||||
* Return file size in bytes.
|
||||
*
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getAbsoluteSize(){
|
||||
@ -995,7 +995,7 @@ class File extends DataObject implements ShortcodeHandler, AssetContainer {
|
||||
|
||||
public function setFromLocalFile($path, $filename = null, $hash = null, $variant = null, $config = array()) {
|
||||
$result = $this->File->setFromLocalFile($path, $filename, $hash, $variant, $config);
|
||||
|
||||
|
||||
// Update File record to name of the uploaded asset
|
||||
if($result) {
|
||||
$this->setFilename($result['Filename']);
|
||||
|
@ -94,7 +94,7 @@ class Folder extends File {
|
||||
* Override setting the Title of Folders to that Name and Title are always in sync.
|
||||
* Note that this is not appropriate for files, because someone might want to create a human-readable name
|
||||
* of a file that is different from its name on disk. But folders should always match their name on disk.
|
||||
*
|
||||
*
|
||||
* @param string $title
|
||||
* @return $this
|
||||
*/
|
||||
|
@ -144,7 +144,7 @@ class GDBackend extends Object implements Image_Backend, Flushable {
|
||||
$this->markFailed($filename, $hash, $variant);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
imagealphablending($image, false);
|
||||
imagesavealpha($image, true); // save alphablending setting (important)
|
||||
$this->setImageResource($image);
|
||||
@ -639,4 +639,4 @@ class GDBackend extends Object implements Image_Backend, Flushable {
|
||||
$cache->clean(Zend_Cache::CLEANING_MODE_ALL);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ trait ImageManipulation {
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function getIsImage();
|
||||
|
||||
|
||||
/**
|
||||
* @config
|
||||
* @var bool Force all images to resample in all cases
|
||||
@ -131,7 +131,7 @@ trait ImageManipulation {
|
||||
* @var int The width of an image thumbnail in a strip.
|
||||
*/
|
||||
private static $strip_thumbnail_width = 50;
|
||||
|
||||
|
||||
/**
|
||||
* @config
|
||||
* @var int The height of an image thumbnail in a strip.
|
||||
@ -577,7 +577,7 @@ trait ImageManipulation {
|
||||
if(!$this->getIsImage()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
$content = $this->getString();
|
||||
if(!$content) {
|
||||
return null;
|
||||
@ -597,7 +597,7 @@ trait ImageManipulation {
|
||||
if(is_numeric($dim)) {
|
||||
return $size[$dim];
|
||||
}
|
||||
|
||||
|
||||
return "$size[0]x$size[1]";
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ class ImagickBackend extends Imagick implements Image_Backend {
|
||||
*/
|
||||
public function __construct(AssetContainer $assetContainer = null) {
|
||||
parent::__construct();
|
||||
|
||||
|
||||
if($assetContainer) {
|
||||
$this->loadFromContainer($assetContainer);
|
||||
}
|
||||
@ -154,7 +154,7 @@ class ImagickBackend extends Imagick implements Image_Backend {
|
||||
if(!$this->valid()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
$new = $this->resizeRatio($width, $height);
|
||||
$new->setImageBackgroundColor("#".$backgroundColor);
|
||||
$w = $new->getImageWidth();
|
||||
|
@ -16,4 +16,4 @@ interface ProtectedAdapter extends AdapterInterface {
|
||||
* @return string|null
|
||||
*/
|
||||
public function getProtectedUrl($path);
|
||||
}
|
||||
}
|
||||
|
@ -55,4 +55,4 @@ class PublicAssetAdapter extends AssetAdapter implements PublicAdapter {
|
||||
// File outside of webroot can't be used
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -282,7 +282,7 @@ class DBFile extends CompositeDBField implements AssetContainer {
|
||||
->getStore()
|
||||
->getMimeType($this->Filename, $this->Hash, $this->Variant);
|
||||
}
|
||||
|
||||
|
||||
public function getValue() {
|
||||
if(!$this->exists()) {
|
||||
return null;
|
||||
@ -311,7 +311,7 @@ class DBFile extends CompositeDBField implements AssetContainer {
|
||||
->getStore()
|
||||
->exists($this->Filename, $this->Hash, $this->Variant);
|
||||
}
|
||||
|
||||
|
||||
public function getFilename() {
|
||||
return $this->getField('Filename');
|
||||
}
|
||||
@ -397,7 +397,7 @@ class DBFile extends CompositeDBField implements AssetContainer {
|
||||
if($allowed) {
|
||||
return in_array($extension, $allowed);
|
||||
}
|
||||
|
||||
|
||||
// If no extensions are configured, fallback to global list
|
||||
$globalList = File::config()->allowed_extensions;
|
||||
if(in_array($extension, $globalList)) {
|
||||
@ -459,7 +459,7 @@ class DBFile extends CompositeDBField implements AssetContainer {
|
||||
if($field === 'Filename' && $value) {
|
||||
$this->assertFilenameValid($value);
|
||||
}
|
||||
|
||||
|
||||
return parent::setField($field, $value, $markChanged);
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ class DefaultAssetNameGenerator implements AssetNameGenerator {
|
||||
|
||||
public function current() {
|
||||
$version = $this->version;
|
||||
|
||||
|
||||
// Initially suggest original name
|
||||
if($version === $this->first) {
|
||||
return $this->filename;
|
||||
|
@ -12,7 +12,7 @@ interface GeneratedAssetHandler {
|
||||
|
||||
/**
|
||||
* Returns a URL to a generated asset, if one is available.
|
||||
*
|
||||
*
|
||||
* Given a filename, determine if a file is available. If the file is unavailable,
|
||||
* and a callback is supplied, invoke it to regenerate the content.
|
||||
*
|
||||
@ -25,7 +25,7 @@ interface GeneratedAssetHandler {
|
||||
|
||||
/**
|
||||
* Returns the content for a generated asset, if one is available.
|
||||
*
|
||||
*
|
||||
* Given a filename, determine if a file is available. If the file is unavailable,
|
||||
* and a callback is supplied, invoke it to regenerate the content.
|
||||
*
|
||||
@ -43,12 +43,12 @@ interface GeneratedAssetHandler {
|
||||
* @param string $content Content to write to the backend
|
||||
*/
|
||||
public function setContent($filename, $content);
|
||||
|
||||
|
||||
/**
|
||||
* Remove any content under the given file.
|
||||
*
|
||||
*
|
||||
* If $filename is a folder, it should delete all files underneath it also.
|
||||
*
|
||||
*
|
||||
* @param string $filename
|
||||
*/
|
||||
public function removeContent($filename);
|
||||
|
@ -118,7 +118,7 @@ class AssetField extends FileField {
|
||||
* @var string
|
||||
*/
|
||||
'uploadTemplateName' => 'ss-uploadfield-uploadtemplate',
|
||||
|
||||
|
||||
/**
|
||||
* javascript template used to display already uploaded files
|
||||
*
|
||||
@ -238,7 +238,7 @@ class AssetField extends FileField {
|
||||
$this->record = $record;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the record to use as "Parent" for uploaded Files (eg a Page with a has_one to File) If none is set, it will
|
||||
* use Form->getRecord().
|
||||
@ -290,7 +290,7 @@ class AssetField extends FileField {
|
||||
// Set value using parent
|
||||
return parent::setValue($value, $record);
|
||||
}
|
||||
|
||||
|
||||
public function Value() {
|
||||
// Re-override FileField Value to use data value
|
||||
return $this->dataValue();
|
||||
@ -565,7 +565,7 @@ class AssetField extends FileField {
|
||||
|
||||
// Revalidate each file against nested validator
|
||||
$this->getUpload()->clearErrors();
|
||||
|
||||
|
||||
// Generate $_FILES style file attribute array for upload validator
|
||||
$store = $this->getAssetStore();
|
||||
$mime = $store->getMimeType($value['Filename'], $value['Hash'], $value['Variant']);
|
||||
@ -599,7 +599,7 @@ class AssetField extends FileField {
|
||||
protected function extractUploadedFileData($postVars) {
|
||||
// Note: Format of posted file parameters in php is a feature of using
|
||||
// <input name='{$Name}[Upload]' /> for multiple file uploads
|
||||
|
||||
|
||||
// Skip empty file
|
||||
if(empty($postVars['tmp_name'])) {
|
||||
return null;
|
||||
@ -712,7 +712,7 @@ class AssetField extends FileField {
|
||||
// Get form details
|
||||
$name = $this->getName();
|
||||
$postVars = $request->postVar($name);
|
||||
|
||||
|
||||
// Extract uploaded files from Form data
|
||||
$uploadedFile = $this->extractUploadedFileData($postVars);
|
||||
if(!$uploadedFile) {
|
||||
|
@ -56,13 +56,13 @@ class CheckboxSetField extends MultiSelectField {
|
||||
|
||||
/**
|
||||
* Gets the list of options to render in this formfield
|
||||
*
|
||||
*
|
||||
* @return ArrayList
|
||||
*/
|
||||
public function getOptions() {
|
||||
$selectedValues = $this->getValueArray();
|
||||
$defaultItems = $this->getDefaultItems();
|
||||
|
||||
|
||||
// Generate list of options to display
|
||||
$odd = 0;
|
||||
$formID = $this->ID();
|
||||
@ -72,7 +72,7 @@ class CheckboxSetField extends MultiSelectField {
|
||||
$odd = ($odd + 1) % 2;
|
||||
$extraClass = $odd ? 'odd' : 'even';
|
||||
$extraClass .= ' val' . preg_replace('/[^a-zA-Z0-9\-\_]/', '_', $itemValue);
|
||||
|
||||
|
||||
$itemChecked = in_array($itemValue, $selectedValues) || in_array($itemValue, $defaultItems);
|
||||
$itemDisabled = $this->isDisabled() || in_array($itemValue, $defaultItems);
|
||||
|
||||
|
@ -695,7 +695,7 @@ class Form extends RequestHandler {
|
||||
|
||||
/**
|
||||
* Set actions that are exempt from validation
|
||||
*
|
||||
*
|
||||
* @param array
|
||||
*/
|
||||
public function setValidationExemptActions($actions) {
|
||||
@ -705,7 +705,7 @@ class Form extends RequestHandler {
|
||||
|
||||
/**
|
||||
* Get a list of actions that are exempt from validation
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getValidationExemptActions() {
|
||||
|
@ -57,7 +57,7 @@ class ListboxField extends MultiSelectField {
|
||||
|
||||
/**
|
||||
* Returns a <select> tag containing all the appropriate <option> tags
|
||||
*
|
||||
*
|
||||
* @param array $properties
|
||||
* @return string
|
||||
*/
|
||||
@ -69,10 +69,10 @@ class ListboxField extends MultiSelectField {
|
||||
->customise($properties)
|
||||
->renderWith($this->getTemplates());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the list of options to render in this formfield
|
||||
*
|
||||
*
|
||||
* @return ArrayList
|
||||
*/
|
||||
public function getOptions() {
|
||||
@ -119,7 +119,7 @@ class ListboxField extends MultiSelectField {
|
||||
|
||||
/**
|
||||
* Sets the size of this dropdown in rows.
|
||||
*
|
||||
*
|
||||
* @param int $size The height in rows (e.g. 3)
|
||||
* @return $this Self reference
|
||||
*/
|
||||
|
@ -87,7 +87,7 @@ class MemberDatetimeOptionsetField extends OptionsetField {
|
||||
public function Type() {
|
||||
return 'optionset memberdatetimeoptionset';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @todo Put this text into a template?
|
||||
*/
|
||||
|
@ -60,10 +60,10 @@ abstract class MultiSelectField extends SelectField {
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load the value from the dataobject into this field
|
||||
*
|
||||
*
|
||||
* @param DataObjectInterface $record
|
||||
*/
|
||||
public function loadFrom(DataObjectInterface $record) {
|
||||
@ -117,10 +117,10 @@ abstract class MultiSelectField extends SelectField {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Encode a list of values into a string, or null if empty (to simplify empty checks)
|
||||
*
|
||||
*
|
||||
* @param array $value
|
||||
* @return string|null
|
||||
*/
|
||||
@ -129,10 +129,10 @@ abstract class MultiSelectField extends SelectField {
|
||||
? json_encode(array_values($value))
|
||||
: null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract a string value into an array of values
|
||||
*
|
||||
*
|
||||
* @param string $value
|
||||
* @return array
|
||||
*/
|
||||
@ -141,7 +141,7 @@ abstract class MultiSelectField extends SelectField {
|
||||
if(empty($value)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
// If json deserialisation fails, then fallover to legacy format
|
||||
$result = json_decode($value, true);
|
||||
if($result !== false) {
|
||||
@ -150,7 +150,7 @@ abstract class MultiSelectField extends SelectField {
|
||||
|
||||
throw new \InvalidArgumentException("Invalid string encoded value for multi select field");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate this field
|
||||
*
|
||||
@ -177,7 +177,7 @@ abstract class MultiSelectField extends SelectField {
|
||||
if(empty($invalidValues)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// List invalid items
|
||||
$validator->validationError(
|
||||
$this->getName(),
|
||||
|
@ -108,7 +108,7 @@ class OptionsetField extends SingleSelectField {
|
||||
public function Field($properties = array()) {
|
||||
$options = array();
|
||||
$odd = false;
|
||||
|
||||
|
||||
// Add all options striped
|
||||
foreach($this->getSourceEmpty() as $value => $title) {
|
||||
$odd = !$odd;
|
||||
|
@ -117,5 +117,5 @@ abstract class SingleSelectField extends SelectField {
|
||||
}
|
||||
return $field;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -877,7 +877,7 @@ class UploadField extends FileField {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param AssetContainer $file
|
||||
* @return string URL to thumbnail
|
||||
*/
|
||||
@ -919,7 +919,7 @@ class UploadField extends FileField {
|
||||
if($this->isReadonly()) {
|
||||
$this->addExtraClass('readonly');
|
||||
}
|
||||
|
||||
|
||||
return parent::extraClass();
|
||||
}
|
||||
|
||||
@ -998,7 +998,7 @@ class UploadField extends FileField {
|
||||
$config['errorMessages']['overwriteWarning'] =
|
||||
_t('UploadField.OVERWRITEWARNING', 'File with the same name already exists');
|
||||
}
|
||||
|
||||
|
||||
$mergedConfig = array_merge($config, $this->ufConfig);
|
||||
return $this->customise(array(
|
||||
'configString' => str_replace('"', """, Convert::raw2json($mergedConfig)),
|
||||
@ -1534,7 +1534,7 @@ class UploadField_SelectHandler extends RequestHandler {
|
||||
* @config
|
||||
* @var int
|
||||
*/
|
||||
private static $page_size = 11;
|
||||
private static $page_size = 11;
|
||||
|
||||
private static $url_handlers = array(
|
||||
'$Action!' => '$Action',
|
||||
@ -1619,7 +1619,7 @@ class UploadField_SelectHandler extends RequestHandler {
|
||||
'Created' => 'SS_Datetime->Nice'
|
||||
));
|
||||
|
||||
// Set configurable pagination for file list field
|
||||
// Set configurable pagination for file list field
|
||||
$pageSize = Config::inst()->get(get_class($this), 'page_size');
|
||||
$config->addComponent(new GridFieldPaginator($pageSize));
|
||||
|
||||
|
@ -58,7 +58,7 @@ class GridFieldExportButton implements GridField_HTMLProvider, GridField_ActionP
|
||||
$button->setAttribute('data-icon', 'download-csv');
|
||||
$button->addExtraClass('no-ajax');
|
||||
$button->addExtraClass('font-icon-down-circled');
|
||||
|
||||
|
||||
return array(
|
||||
$this->targetFragment => '<p class="grid-csv-button">' . $button->Field() . '</p>',
|
||||
);
|
||||
|
@ -56,7 +56,7 @@ class GridFieldPrintButton implements GridField_HTMLProvider, GridField_ActionPr
|
||||
$button->setAttribute('data-icon', 'grid_print');
|
||||
$button->addExtraClass('gridfield-button-print');
|
||||
$button->addExtraClass('font-icon-print');
|
||||
|
||||
|
||||
return array(
|
||||
$this->targetFragment => '<p class="grid-print-button">' . $button->Field() . '</p>',
|
||||
);
|
||||
|
@ -342,16 +342,16 @@ class HtmlEditorField_Toolbar extends RequestHandler {
|
||||
$computerUploadField->removeExtraClass('ss-uploadfield');
|
||||
$computerUploadField->setTemplate('HtmlEditorField_UploadField');
|
||||
$computerUploadField->setFolderName(Config::inst()->get('Upload', 'uploads_folder'));
|
||||
|
||||
|
||||
$defaultPanel = new CompositeField(
|
||||
$computerUploadField,
|
||||
$fromCMS
|
||||
);
|
||||
|
||||
|
||||
$fromWebPanel = new CompositeField(
|
||||
$fromWeb
|
||||
);
|
||||
|
||||
|
||||
$defaultPanel->addExtraClass('htmleditorfield-default-panel');
|
||||
$fromWebPanel->addExtraClass('htmleditorfield-web-panel');
|
||||
|
||||
@ -530,7 +530,7 @@ class HtmlEditorField_Toolbar extends RequestHandler {
|
||||
*/
|
||||
protected function getFiles($parentID = null) {
|
||||
$exts = $this->getAllowedExtensions();
|
||||
$dotExts = array_map(function($ext) {
|
||||
$dotExts = array_map(function($ext) {
|
||||
return ".{$ext}";
|
||||
}, $exts);
|
||||
$files = File::get()->filter('Name:EndsWith', $dotExts);
|
||||
@ -706,7 +706,7 @@ abstract class HtmlEditorField_File extends ViewableData {
|
||||
));
|
||||
}
|
||||
return $fields;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -722,7 +722,7 @@ abstract class HtmlEditorField_File extends ViewableData {
|
||||
|
||||
/**
|
||||
* Get file ID
|
||||
*
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getFileID() {
|
||||
@ -782,7 +782,7 @@ abstract class HtmlEditorField_File extends ViewableData {
|
||||
if($preview) {
|
||||
return $preview;
|
||||
}
|
||||
|
||||
|
||||
// Generate tag from preview
|
||||
$thumbnailURL = Convert::raw2att(
|
||||
Controller::join_links($this->getPreviewURL(), "?r=" . rand(1,100000))
|
||||
|
@ -747,7 +747,7 @@ class DataQuery {
|
||||
if(!$foreignClass || $foreignClass === 'DataObject') {
|
||||
throw new InvalidArgumentException("Could not find a has_many relationship {$localField} on {$localClass}");
|
||||
}
|
||||
|
||||
|
||||
// Skip if already joined
|
||||
if($this->query->isJoinedTo($foreignClass)) {
|
||||
return;
|
||||
@ -769,7 +769,7 @@ class DataQuery {
|
||||
"\"$foreignClass\".\"{$foreignKey}\" = \"{$ancestry[0]}\".\"ID\""
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* add join clause to the component's ancestry classes so that the search filter could search on
|
||||
* its ancestor fields.
|
||||
@ -864,7 +864,7 @@ class DataQuery {
|
||||
$query->setSelect(array());
|
||||
$query->selectField($fieldExpression, $field);
|
||||
$this->ensureSelectContainsOrderbyColumns($query, $originalSelect);
|
||||
|
||||
|
||||
return $query->execute()->column($field);
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
* @subpackage filesystem
|
||||
*/
|
||||
class Image extends File {
|
||||
public function __construct($record = null, $isSingleton = false, $model = null) {
|
||||
public function __construct($record = null, $isSingleton = false, $model = null) {
|
||||
parent::__construct($record, $isSingleton, $model);
|
||||
$this->File->setAllowedCategories('image/supported');
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ interface Image_Backend {
|
||||
|
||||
/**
|
||||
* Write the backend to a local path
|
||||
*
|
||||
*
|
||||
* @param string $path
|
||||
*/
|
||||
public function writeTo($path);
|
||||
|
@ -179,7 +179,7 @@ abstract class SS_Database {
|
||||
$message .= "\nparams: \"" . implode('", "', $parameters) . '"';
|
||||
}
|
||||
Debug::message("\n{$message}\n{$endtime}s\n", false);
|
||||
|
||||
|
||||
return $result;
|
||||
} else {
|
||||
return $callback($sql);
|
||||
|
@ -33,7 +33,7 @@ abstract class CompositeDBField extends DBField {
|
||||
|
||||
/**
|
||||
* Either the parent dataobject link, or a record of saved values for each field
|
||||
*
|
||||
*
|
||||
* @var array|DataObject
|
||||
*/
|
||||
protected $record = array();
|
||||
@ -61,7 +61,7 @@ abstract class CompositeDBField extends DBField {
|
||||
*/
|
||||
public function addToQuery(&$query) {
|
||||
parent::addToQuery($query);
|
||||
|
||||
|
||||
foreach($this->compositeDatabaseFields() as $field => $spec) {
|
||||
$table = $this->getTable();
|
||||
$key = $this->getName() . $field;
|
||||
@ -76,7 +76,7 @@ abstract class CompositeDBField extends DBField {
|
||||
/**
|
||||
* Return array in the format of {@link $composite_db}.
|
||||
* Used by {@link DataObject->hasOwnDatabaseField()}.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function compositeDatabaseFields() {
|
||||
@ -136,7 +136,7 @@ abstract class CompositeDBField extends DBField {
|
||||
*/
|
||||
public function setValue($value, $record = null, $markChanged = true) {
|
||||
$this->isChanged = $markChanged;
|
||||
|
||||
|
||||
// When given a dataobject, bind this field to that
|
||||
if($record instanceof DataObject) {
|
||||
$this->bindTo($record);
|
||||
@ -264,7 +264,7 @@ abstract class CompositeDBField extends DBField {
|
||||
return $fields[$field];
|
||||
}
|
||||
|
||||
|
||||
|
||||
parent::castingHelper($field);
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ class PolymorphicForeignKey extends CompositeDBField {
|
||||
'Class' => $value->class
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
parent::setValue($value, $record, $markChanged);
|
||||
}
|
||||
|
||||
|
@ -207,7 +207,7 @@ class Oembed implements ShortcodeHandler {
|
||||
* @property int $Width
|
||||
* @property int $Height
|
||||
* @property string $Info Descriptive text for this oembed
|
||||
*
|
||||
*
|
||||
* @package framework
|
||||
* @subpackage oembed
|
||||
*/
|
||||
|
@ -14,7 +14,7 @@ interface ShortcodeHandler {
|
||||
|
||||
/**
|
||||
* Generate content with a shortcode value
|
||||
*
|
||||
*
|
||||
* @param array $arguments Arguments passed to the parser
|
||||
* @param string $content Raw shortcode
|
||||
* @param ShortcodeParser $parser Parser
|
||||
|
@ -453,10 +453,10 @@ class Member extends DataObject implements TemplateGlobalProvider {
|
||||
$rememberLoginHash = RememberLoginHash::generate($this);
|
||||
$tokenExpiryDays = Config::inst()->get('RememberLoginHash', 'token_expiry_days');
|
||||
$deviceExpiryDays = Config::inst()->get('RememberLoginHash', 'device_expiry_days');
|
||||
Cookie::set('alc_enc', $this->ID . ':' . $rememberLoginHash->getToken(),
|
||||
Cookie::set('alc_enc', $this->ID . ':' . $rememberLoginHash->getToken(),
|
||||
$tokenExpiryDays, null, null, null, true);
|
||||
Cookie::set('alc_device', $rememberLoginHash->DeviceID, $deviceExpiryDays, null, null, null, true);
|
||||
} else {
|
||||
} else {
|
||||
Cookie::set('alc_enc', null);
|
||||
Cookie::set('alc_device', null);
|
||||
Cookie::force_expiry('alc_enc');
|
||||
@ -571,7 +571,7 @@ class Member extends DataObject implements TemplateGlobalProvider {
|
||||
if ($rememberLoginHash) {
|
||||
$rememberLoginHash->renew();
|
||||
$tokenExpiryDays = Config::inst()->get('RememberLoginHash', 'token_expiry_days');
|
||||
Cookie::set('alc_enc', $member->ID . ':' . $rememberLoginHash->getToken(),
|
||||
Cookie::set('alc_enc', $member->ID . ':' . $rememberLoginHash->getToken(),
|
||||
$tokenExpiryDays, null, null, false, true);
|
||||
}
|
||||
|
||||
@ -1483,7 +1483,7 @@ class Member extends DataObject implements TemplateGlobalProvider {
|
||||
|
||||
//need to be logged in and/or most checks below rely on $member being a Member
|
||||
if(!$member) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
// members can usually view their own record
|
||||
if($this->ID == $member->ID) {
|
||||
@ -1509,7 +1509,7 @@ class Member extends DataObject implements TemplateGlobalProvider {
|
||||
|
||||
//need to be logged in and/or most checks below rely on $member being a Member
|
||||
if(!$member) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// HACK: we should not allow for an non-Admin to edit an Admin
|
||||
@ -1539,12 +1539,12 @@ class Member extends DataObject implements TemplateGlobalProvider {
|
||||
|
||||
//need to be logged in and/or most checks below rely on $member being a Member
|
||||
if(!$member) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
// Members are not allowed to remove themselves,
|
||||
// since it would create inconsistencies in the admin UIs.
|
||||
if($this->ID && $member->ID == $this->ID) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// HACK: if you want to delete a member, you have to be a member yourself.
|
||||
@ -1552,7 +1552,7 @@ class Member extends DataObject implements TemplateGlobalProvider {
|
||||
// deleting a member who has more privileges (e.g. a non-Admin deleting an Admin)
|
||||
if(Permission::checkMember($this, 'ADMIN')) {
|
||||
if( ! Permission::checkMember($member, 'ADMIN')) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//standard check
|
||||
|
@ -4,7 +4,7 @@
|
||||
* feature when logging in.
|
||||
* By default, logging out will discard all existing tokens for this user
|
||||
* The device ID is a temporary ID associated with the device when the user logged in
|
||||
* and chose to get the login state remembered on this device. When logging out, the ID
|
||||
* and chose to get the login state remembered on this device. When logging out, the ID
|
||||
* is discarded as well.
|
||||
*
|
||||
* @package framework
|
||||
@ -90,9 +90,9 @@ class RememberLoginHash extends DataObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new random token and hashes it using the
|
||||
* Creates a new random token and hashes it using the
|
||||
* member information
|
||||
* @param Member The logged in user
|
||||
* @param Member The logged in user
|
||||
* @return string The hash to be stored in the database
|
||||
*/
|
||||
public function getNewHash(Member $member){
|
||||
@ -104,21 +104,21 @@ class RememberLoginHash extends DataObject {
|
||||
/**
|
||||
* Generates a new login hash associated with a device
|
||||
* The device is assigned a globally unique device ID
|
||||
* The returned login hash stores the hashed token in the
|
||||
* The returned login hash stores the hashed token in the
|
||||
* database, for this device and this member
|
||||
* @param Member The logged in user
|
||||
* @param Member The logged in user
|
||||
* @return RememberLoginHash The generated login hash
|
||||
*/
|
||||
public static function generate(Member $member) {
|
||||
if(!$member->exists()) { return; }
|
||||
if (Config::inst()->get('RememberLoginHash', 'force_single_token') == true) {
|
||||
$rememberLoginHash = RememberLoginHash::get()->filter('MemberID', $member->ID)->removeAll();
|
||||
}
|
||||
}
|
||||
$rememberLoginHash = RememberLoginHash::create();
|
||||
do {
|
||||
$deviceID = $rememberLoginHash->getNewDeviceID();
|
||||
} while (RememberLoginHash::get()->filter('DeviceID', $deviceID)->Count());
|
||||
|
||||
|
||||
$rememberLoginHash->DeviceID = $deviceID;
|
||||
$rememberLoginHash->Hash = $rememberLoginHash->getNewHash($member);
|
||||
$rememberLoginHash->MemberID = $member->ID;
|
||||
@ -155,10 +155,10 @@ class RememberLoginHash extends DataObject {
|
||||
$filter = array('MemberID'=>$member->ID);
|
||||
if ((Config::inst()->get('RememberLoginHash', 'logout_across_devices') == false) && $alcDevice) {
|
||||
$filter['DeviceID'] = $alcDevice;
|
||||
}
|
||||
}
|
||||
RememberLoginHash::get()
|
||||
->filter($filter)
|
||||
->removeAll();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,4 +23,4 @@ class CleanuPTestDatabasesTask extends BuildTask {
|
||||
SapphireTest::delete_all_temp_dbs();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -627,7 +627,7 @@ class AssetStoreTest_SpyStore extends FlysystemAssetStore {
|
||||
public function cleanFilename($filename) {
|
||||
return parent::cleanFilename($filename);
|
||||
}
|
||||
|
||||
|
||||
public function getFileID($filename, $hash, $variant = null) {
|
||||
return parent::getFileID($filename, $hash, $variant);
|
||||
}
|
||||
|
@ -96,4 +96,4 @@ class FileMigrationHelperTest_Extension extends DataExtension implements TestOnl
|
||||
// Ensure underlying filename field is written to the database
|
||||
$this->owner->setField('Filename', 'assets/' . $this->owner->getFilename());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ class FileTest extends SapphireTest {
|
||||
|
||||
// Set backend root to /ImageTest
|
||||
AssetStoreTest_SpyStore::activate('FileTest');
|
||||
|
||||
|
||||
// Create a test folders for each of the fixture references
|
||||
$folderIDs = $this->allFixtureIDs('Folder');
|
||||
foreach($folderIDs as $folderID) {
|
||||
@ -522,7 +522,7 @@ class FileTest extends SapphireTest {
|
||||
$this->objFromFixture('Member', 'admin')->logIn();
|
||||
$this->assertTrue($file->canEdit(), "Admins can edit files");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function testJoinPaths() {
|
||||
$this->assertEquals('name/file.jpg', File::join_paths('/name', 'file.jpg'));
|
||||
|
@ -78,7 +78,7 @@ class FolderTest extends SapphireTest {
|
||||
AssetStoreTest_SpyStore::getLocalPath($folder),
|
||||
'Empty folder does not have a filesystem record automatically'
|
||||
);
|
||||
|
||||
|
||||
$parentFolder = DataObject::get_one('Folder', array(
|
||||
'"File"."Name"' => 'parent'
|
||||
));
|
||||
@ -117,7 +117,7 @@ class FolderTest extends SapphireTest {
|
||||
// Check if the file in the folder moved along
|
||||
$file1 = DataObject::get_by_id('File', $this->idFromFixture('File', 'file1-folder1'), false);
|
||||
$this->assertFileExists(AssetStoreTest_SpyStore::getLocalPath($file1));
|
||||
|
||||
|
||||
$this->assertEquals(
|
||||
'FileTest-folder2/FileTest-folder1/File1.txt',
|
||||
$file1->Filename,
|
||||
|
@ -198,4 +198,4 @@ class ProtectedFileControllerTest extends FunctionalTest {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -193,14 +193,14 @@ class CheckboxSetFieldTest extends SapphireTest {
|
||||
$field->validate($validator),
|
||||
'Field validates values within source array'
|
||||
);
|
||||
|
||||
|
||||
// Non valid value should fail
|
||||
$field->setValue(array("Four" => "Four"));
|
||||
$this->assertFalse(
|
||||
$field->validate($validator),
|
||||
'Field does not validate values outside of source array'
|
||||
);
|
||||
|
||||
|
||||
// Non valid value, even if included with valid options, should fail
|
||||
$field->setValue(array("One", "Two", "Four"));
|
||||
$this->assertFalse(
|
||||
|
@ -80,7 +80,7 @@ class ConfirmedPasswordFieldTest extends SapphireTest {
|
||||
"Does not validate when passwords differ"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function testFormValidation() {
|
||||
$form = new Form(
|
||||
new Controller(),
|
||||
|
@ -12,7 +12,7 @@ class DBFileTest extends SapphireTest {
|
||||
'DBFileTest_Object',
|
||||
'DBFileTest_Subclass'
|
||||
);
|
||||
|
||||
|
||||
protected $usesDatabase = true;
|
||||
|
||||
public function setUp() {
|
||||
@ -53,7 +53,7 @@ class DBFileTest extends SapphireTest {
|
||||
|
||||
public function testValidation() {
|
||||
$obj = new DBFileTest_ImageOnly();
|
||||
|
||||
|
||||
// Test from image
|
||||
$fish = realpath(__DIR__ .'/../model/testimages/test-image-high-quality.jpg');
|
||||
$this->assertFileExists($fish);
|
||||
|
@ -269,7 +269,7 @@ class FormTest extends FunctionalTest {
|
||||
'Email' => 'test@test.com'
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// Firstly, assert that required fields still work when not using an exempt action
|
||||
$this->assertPartialMatchBySelector(
|
||||
'#Form_Form_SomeRequiredField_Holder .required',
|
||||
@ -299,7 +299,7 @@ class FormTest extends FunctionalTest {
|
||||
'Form->sessionMessage() shows up after reloading the form'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function testSessionValidationMessage() {
|
||||
$this->get('FormTest_Controller');
|
||||
|
||||
|
@ -103,7 +103,7 @@ class HtmlEditorFieldTest extends FunctionalTest {
|
||||
|
||||
$neededFilename
|
||||
= '/assets/HtmlEditorFieldTest/f5c7c2f814/HTMLEditorFieldTest-example__ResizedImageWzEwLDIwXQ.jpg';
|
||||
|
||||
|
||||
$this->assertEquals($neededFilename, (string)$xml[0]['src'], 'Correct URL of resized image is set.');
|
||||
$this->assertTrue(file_exists(BASE_PATH.DIRECTORY_SEPARATOR.$neededFilename), 'File for resized image exists');
|
||||
$this->assertEquals(false, $obj->HasBrokenFile, 'Referenced image file exists.');
|
||||
|
@ -83,7 +83,7 @@ class RequirementsTest extends SapphireTest {
|
||||
protected function setupCombinedRequirements($backend) {
|
||||
$basePath = $this->getCurrentRelativePath();
|
||||
$this->setupRequirements($backend);
|
||||
|
||||
|
||||
// require files normally (e.g. called from a FormField instance)
|
||||
$backend->javascript($basePath . '/RequirementsTest_a.js');
|
||||
$backend->javascript($basePath . '/RequirementsTest_b.js');
|
||||
|
@ -148,7 +148,7 @@ class GridFieldSortableHeaderTest extends SapphireTest {
|
||||
array('Melbourne', 'Wellington', 'Auckland', 'Cologne'),
|
||||
$relationListAdesc->column('City')
|
||||
);
|
||||
|
||||
|
||||
// Test subclasses of tables
|
||||
$state->SortColumn = 'CheerleadersMom.Hat.Colour';
|
||||
$state->SortDirection = 'asc';
|
||||
|
@ -367,7 +367,7 @@ class AssetFieldTest_Form extends Form implements TestOnly {
|
||||
if(empty($controller)) {
|
||||
$controller = new AssetFieldTest_Controller();
|
||||
}
|
||||
|
||||
|
||||
$fields = new FieldList(
|
||||
AssetField::create('File')
|
||||
->setFolderName('MyFiles'),
|
||||
|
@ -946,4 +946,4 @@ class SSObjectCreator extends InjectionCreator {
|
||||
return parent::create($class, $params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
class DBClassNameTest extends SapphireTest {
|
||||
|
||||
|
||||
protected $extraDataObjects = array(
|
||||
'DBClassNameTest_Object',
|
||||
'DBClassNameTest_ObjectSubClass',
|
||||
@ -145,4 +145,4 @@ class DBClassNameTest_CustomDefaultSubclass extends DBClassNameTest_CustomDefaul
|
||||
private static $db = array(
|
||||
'Content' => 'HTMLText'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class ImageTest extends SapphireTest {
|
||||
|
||||
public function testGetTagWithTitle() {
|
||||
Config::inst()->update('DBFile', 'force_resample', false);
|
||||
|
||||
|
||||
$image = $this->objFromFixture('Image', 'imageWithTitle');
|
||||
$expected = '<img src="/assets/ImageTest/folder/444065542b/test-image.png" alt="This is a image Title" />';
|
||||
$actual = trim($image->getTag());
|
||||
@ -57,7 +57,7 @@ class ImageTest extends SapphireTest {
|
||||
|
||||
public function testGetTagWithoutTitle() {
|
||||
Config::inst()->update('DBFile', 'force_resample', false);
|
||||
|
||||
|
||||
$image = $this->objFromFixture('Image', 'imageWithoutTitle');
|
||||
$expected = '<img src="/assets/ImageTest/folder/444065542b/test-image.png" alt="test image" />';
|
||||
$actual = trim($image->getTag());
|
||||
@ -67,7 +67,7 @@ class ImageTest extends SapphireTest {
|
||||
|
||||
public function testGetTagWithoutTitleContainingDots() {
|
||||
Config::inst()->update('DBFile', 'force_resample', false);
|
||||
|
||||
|
||||
$image = $this->objFromFixture('Image', 'imageWithoutTitleContainingDots');
|
||||
$expected = '<img src="/assets/ImageTest/folder/46affab704/test.image.with.dots.png" alt="test.image.with.dots" />';
|
||||
$actual = trim($image->getTag());
|
||||
@ -146,7 +146,7 @@ class ImageTest extends SapphireTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that a URL to a resampled image is provided when force_resample is
|
||||
* Tests that a URL to a resampled image is provided when force_resample is
|
||||
* set to true, if the resampled file is smaller than the original.
|
||||
*/
|
||||
public function testForceResample() {
|
||||
@ -194,7 +194,7 @@ class ImageTest extends SapphireTest {
|
||||
$this->assertTrue($fitMaxDn->isSize(100, 100));
|
||||
$fitMaxUp = $image->FitMax(500, 400);
|
||||
$this->assertTrue($fitMaxUp->isSize(300, 300));
|
||||
|
||||
|
||||
//Test ScaleMax
|
||||
$scaleMaxWDn = $image->ScaleMaxWidth(200);
|
||||
$this->assertTrue($scaleMaxWDn->isSize(200, 200));
|
||||
@ -210,7 +210,7 @@ class ImageTest extends SapphireTest {
|
||||
$this->assertTrue($cropMaxDn->isSize(200, 100));
|
||||
$cropMaxUp = $image->FillMax(400, 200);
|
||||
$this->assertTrue($cropMaxUp->isSize(300, 150));
|
||||
|
||||
|
||||
// Test Clip
|
||||
$clipWDn = $image->CropWidth(200);
|
||||
$this->assertTrue($clipWDn->isSize(200, 300));
|
||||
@ -241,7 +241,7 @@ class ImageTest extends SapphireTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that propertes from the source Image are inherited by resampled images
|
||||
* Test that propertes from the source Image are inherited by resampled images
|
||||
*/
|
||||
public function testPropertyInheritance() {
|
||||
$testString = 'This is a test';
|
||||
|
@ -7,7 +7,7 @@ class ImagickImageTest extends ImageTest {
|
||||
$this->markTestSkipped("The Imagick extension is not available.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Config::inst()->update('Injector', 'Image_Backend', 'ImagickBackend');
|
||||
}
|
||||
}
|
||||
|
@ -13,14 +13,14 @@ class SQLSelectTest extends SapphireTest {
|
||||
'SQLSelectTestBase',
|
||||
'SQLSelectTestChild'
|
||||
);
|
||||
|
||||
|
||||
protected $oldDeprecation = null;
|
||||
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->oldDeprecation = Deprecation::dump_settings();
|
||||
}
|
||||
|
||||
|
||||
public function tearDown() {
|
||||
Deprecation::restore_settings($this->oldDeprecation);
|
||||
parent::tearDown();
|
||||
|
@ -95,7 +95,7 @@ class URLSegmentFilterTest extends SapphireTest {
|
||||
$filter = new URLSegmentFilter();
|
||||
$this->assertEquals('url-has-trailing-dashes', $filter->filter('url-has-trailing-dashes--'));
|
||||
}
|
||||
|
||||
|
||||
public function testRemovesBadCharactersWithMultibyteAllowed() {
|
||||
$filter = new URLSegmentFilter();
|
||||
$filter->setAllowMultibyte(true);
|
||||
|
@ -118,4 +118,4 @@ class FulltextFilterTest_DataObject extends DataObject implements TestOnly {
|
||||
"MySQLDatabase" => "ENGINE=MyISAM",
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -813,9 +813,9 @@ class MemberTest extends FunctionalTest {
|
||||
$firstHash->write();
|
||||
|
||||
$response = $this->get(
|
||||
'Security/login',
|
||||
$this->session(),
|
||||
null,
|
||||
'Security/login',
|
||||
$this->session(),
|
||||
null,
|
||||
array(
|
||||
'alc_enc' => $m1->ID.':'.$token,
|
||||
'alc_device' => $firstHash->DeviceID
|
||||
@ -830,11 +830,11 @@ class MemberTest extends FunctionalTest {
|
||||
|
||||
$this->session()->inst_set('loggedInAs', null);
|
||||
|
||||
// A wrong token or a wrong device ID should not let us autologin
|
||||
// A wrong token or a wrong device ID should not let us autologin
|
||||
$response = $this->get(
|
||||
'Security/login',
|
||||
$this->session(),
|
||||
null,
|
||||
'Security/login',
|
||||
$this->session(),
|
||||
null,
|
||||
array(
|
||||
'alc_enc' => $m1->ID.':'.str_rot13($token),
|
||||
'alc_device' => $firstHash->DeviceID
|
||||
@ -843,9 +843,9 @@ class MemberTest extends FunctionalTest {
|
||||
$this->assertNotContains($message, $response->getBody());
|
||||
|
||||
$response = $this->get(
|
||||
'Security/login',
|
||||
$this->session(),
|
||||
null,
|
||||
'Security/login',
|
||||
$this->session(),
|
||||
null,
|
||||
array(
|
||||
'alc_enc' => $m1->ID.':'.$token,
|
||||
'alc_device' => str_rot13($firstHash->DeviceID)
|
||||
@ -853,10 +853,10 @@ class MemberTest extends FunctionalTest {
|
||||
);
|
||||
$this->assertNotContains($message, $response->getBody());
|
||||
|
||||
// Re-logging (ie 'alc_enc' has expired), and not checking the "Remember Me" option
|
||||
// Re-logging (ie 'alc_enc' has expired), and not checking the "Remember Me" option
|
||||
// should remove all previous hashes for this device
|
||||
$response = $this->post(
|
||||
'Security/LoginForm',
|
||||
'Security/LoginForm',
|
||||
array(
|
||||
'Email' => $m1->Email,
|
||||
'Password' => '1nitialPassword',
|
||||
@ -865,7 +865,7 @@ class MemberTest extends FunctionalTest {
|
||||
),
|
||||
null,
|
||||
$this->session(),
|
||||
null,
|
||||
null,
|
||||
array(
|
||||
'alc_device' => $firstHash->DeviceID
|
||||
)
|
||||
@ -890,9 +890,9 @@ class MemberTest extends FunctionalTest {
|
||||
SS_DateTime::set_mock_now('1999-12-31 23:59:59');
|
||||
|
||||
$response = $this->get(
|
||||
'Security/login',
|
||||
$this->session(),
|
||||
null,
|
||||
'Security/login',
|
||||
$this->session(),
|
||||
null,
|
||||
array(
|
||||
'alc_enc' => $m1->ID.':'.$token,
|
||||
'alc_device' => $firstHash->DeviceID
|
||||
@ -916,9 +916,9 @@ class MemberTest extends FunctionalTest {
|
||||
SS_DateTime::set_mock_now('2000-01-01 00:00:01');
|
||||
|
||||
$response = $this->get(
|
||||
'Security/login',
|
||||
$this->session(),
|
||||
null,
|
||||
'Security/login',
|
||||
$this->session(),
|
||||
null,
|
||||
array(
|
||||
'alc_enc' => $m1->ID.':'.$token,
|
||||
'alc_device' => $firstHash->DeviceID
|
||||
@ -960,9 +960,9 @@ class MemberTest extends FunctionalTest {
|
||||
|
||||
// Accessing the login page should show the user's name straight away
|
||||
$response = $this->get(
|
||||
'Security/login',
|
||||
$this->session(),
|
||||
null,
|
||||
'Security/login',
|
||||
$this->session(),
|
||||
null,
|
||||
array(
|
||||
'alc_enc' => $m1->ID.':'.$firstToken,
|
||||
'alc_device' => $firstHash->DeviceID
|
||||
@ -979,9 +979,9 @@ class MemberTest extends FunctionalTest {
|
||||
|
||||
// Accessing the login page from the second device
|
||||
$response = $this->get(
|
||||
'Security/login',
|
||||
$this->session(),
|
||||
null,
|
||||
'Security/login',
|
||||
$this->session(),
|
||||
null,
|
||||
array(
|
||||
'alc_enc' => $m1->ID.':'.$secondToken,
|
||||
'alc_device' => $secondHash->DeviceID
|
||||
@ -994,16 +994,16 @@ class MemberTest extends FunctionalTest {
|
||||
// Logging out from the second device - only one device being logged out
|
||||
Config::inst()->update('RememberLoginHash', 'logout_across_devices', false);
|
||||
$response = $this->get(
|
||||
'Security/logout',
|
||||
$this->session(),
|
||||
null,
|
||||
'Security/logout',
|
||||
$this->session(),
|
||||
null,
|
||||
array(
|
||||
'alc_enc' => $m1->ID.':'.$secondToken,
|
||||
'alc_device' => $secondHash->DeviceID
|
||||
)
|
||||
);
|
||||
$this->assertEquals(
|
||||
RememberLoginHash::get()->filter(array('MemberID'=>$m1->ID, 'DeviceID'=>$firstHash->DeviceID))->Count(),
|
||||
RememberLoginHash::get()->filter(array('MemberID'=>$m1->ID, 'DeviceID'=>$firstHash->DeviceID))->Count(),
|
||||
1
|
||||
);
|
||||
|
||||
@ -1012,7 +1012,7 @@ class MemberTest extends FunctionalTest {
|
||||
$m1->login(true);
|
||||
$response = $this->get('Security/logout', $this->session());
|
||||
$this->assertEquals(
|
||||
RememberLoginHash::get()->filter('MemberID', $m1->ID)->Count(),
|
||||
RememberLoginHash::get()->filter('MemberID', $m1->ID)->Count(),
|
||||
0
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user