API-CHANGE: refactoring static methods to adhere to coding conventions.

This commit is contained in:
Julian Seidenberg 2012-08-07 11:14:23 +12:00
parent 6fa0cc5a32
commit 043bfb98f6
3 changed files with 16 additions and 16 deletions

View File

@ -19,11 +19,11 @@ class DMS implements DMSInterface {
* @return DMSInterface An instance of the Document Management System
*/
static function inst() {
$dmsPath = self::get_DMS_path();
$dmsPath = self::get_dms_path();
$dms = new DMS();
if (!is_dir($dmsPath)) {
self::createStorageFolder($dmsPath);
self::create_storage_folder($dmsPath);
}
if (!file_exists($dmsPath . DIRECTORY_SEPARATOR . '.htaccess')) {
@ -34,11 +34,11 @@ class DMS implements DMSInterface {
return $dms;
}
static function get_DMS_path() {
static function get_dms_path() {
return BASE_PATH . DIRECTORY_SEPARATOR . self::$dmsFolder;
}
static function transformFileToFilePath($file) {
static function transform_file_to_file_path($file) {
//confirm we have a file
$filePath = null;
if (is_string($file)) $filePath = $file;
@ -56,7 +56,7 @@ class DMS implements DMSInterface {
*/
function storeDocument($file) {
$filePath = self::transformFileToFilePath($file);
$filePath = self::transform_file_to_file_path($file);
//create a new document and get its ID
$modelClass = self::$modelClass;
@ -105,7 +105,7 @@ class DMS implements DMSInterface {
* Creates a storage folder for the given path
* @param $path Path to create a folder for
*/
static function createStorageFolder($path) {
static function create_storage_folder($path) {
if (!is_dir($path)) {
mkdir($path, 0777);
}
@ -114,7 +114,7 @@ class DMS implements DMSInterface {
/**
* Calculates the storage path from a database DMSDocument ID
*/
static function getStorageFolder($id) {
static function get_storage_folder($id) {
$folderName = intval($id / self::$dmsFolderSize);
return $folderName;
}

View File

@ -314,7 +314,7 @@ class DMSDocument extends DataObject implements DMSDocumentInterface {
* @return string
*/
function getFullPath() {
return DMS::get_DMS_path() . DIRECTORY_SEPARATOR . $this->Folder . DIRECTORY_SEPARATOR . $this->Filename;
return DMS::get_dms_path() . DIRECTORY_SEPARATOR . $this->Folder . DIRECTORY_SEPARATOR . $this->Filename;
}
/**
@ -327,7 +327,7 @@ class DMSDocument extends DataObject implements DMSDocumentInterface {
//delete the file (and previous versions of files)
$filesToDelete = array();
$storageFolder = DMS::get_DMS_path() . DIRECTORY_SEPARATOR . DMS::getStorageFolder($this->ID);
$storageFolder = DMS::get_dms_path() . DIRECTORY_SEPARATOR . DMS::get_storage_folder($this->ID);
if ($handle = opendir($storageFolder)) { //Open directory
//List files in the directory
while (false !== ($entry = readdir($handle))) {
@ -360,9 +360,9 @@ class DMSDocument extends DataObject implements DMSDocumentInterface {
//calculate all the path to copy the file to
$fromFilename = basename($filePath);
$toFilename = $this->ID. '~' . $fromFilename; //add the docID to the start of the Filename
$toFolder = DMS::getStorageFolder($this->ID);
$toPath = DMS::get_DMS_path() . DIRECTORY_SEPARATOR . $toFolder . DIRECTORY_SEPARATOR . $toFilename;
DMS::createStorageFolder(DMS::get_DMS_path() . DIRECTORY_SEPARATOR . $toFolder);
$toFolder = DMS::get_storage_folder($this->ID);
$toPath = DMS::get_dms_path() . DIRECTORY_SEPARATOR . $toFolder . DIRECTORY_SEPARATOR . $toFilename;
DMS::create_storage_folder(DMS::get_dms_path() . DIRECTORY_SEPARATOR . $toFolder);
//copy the file into place
$fromPath = BASE_PATH . DIRECTORY_SEPARATOR . $filePath;
@ -386,7 +386,7 @@ class DMSDocument extends DataObject implements DMSDocumentInterface {
* @return DMSDocumentInstance Document object that we replaced the file in
*/
function replaceDocument($file) {
$filePath = DMS::transformFileToFilePath($file);
$filePath = DMS::transform_file_to_file_path($file);
$doc = $this->storeDocument($filePath); //replace the document
return $doc;
}

View File

@ -68,7 +68,7 @@ class DMSTest extends FunctionalTest {
$document = $dms->storeDocument($file);
$this->assertNotNull($document, "Document object created");
$this->assertTrue(file_exists(DMS::get_DMS_path() . DIRECTORY_SEPARATOR . $document->Folder . DIRECTORY_SEPARATOR . $document->Filename),"Document file copied into DMS folder");
$this->assertTrue(file_exists(DMS::get_dms_path() . DIRECTORY_SEPARATOR . $document->Folder . DIRECTORY_SEPARATOR . $document->Filename),"Document file copied into DMS folder");
//$title = $document->getTag('title');
}
@ -97,7 +97,7 @@ class DMSTest extends FunctionalTest {
//test we created 4 folder to contain the 17 files
foreach($folders as $f) {
$this->assertTrue(is_dir(DMS::get_DMS_path() . DIRECTORY_SEPARATOR . $f),"Document folder '$f' exists");
$this->assertTrue(is_dir(DMS::get_dms_path() . DIRECTORY_SEPARATOR . $f),"Document folder '$f' exists");
}
}
@ -114,7 +114,7 @@ class DMSTest extends FunctionalTest {
$document = $document->replaceDocument(self::$testFile2);
$this->assertNotNull($document, "Document object created");
$this->assertTrue(file_exists(DMS::get_DMS_path() . DIRECTORY_SEPARATOR . $document->Folder . DIRECTORY_SEPARATOR . $document->Filename),"Document file copied into DMS folder");
$this->assertTrue(file_exists(DMS::get_dms_path() . DIRECTORY_SEPARATOR . $document->Folder . DIRECTORY_SEPARATOR . $document->Filename),"Document file copied into DMS folder");
$this->assertContains("DMS-test-document-2",$document->Filename, "Original document filename is contain in the new filename");
$this->assertEquals("My custom title", $document->Title , "Custom title not modified");
$this->assertEquals("My custom description", $document->Description, "Custom description not modified");