implemented alt_folder and reorganized interface class code

This commit is contained in:
Chris
2018-12-23 11:59:31 +01:00
parent 3345eb399c
commit b6612cd838
15 changed files with 258 additions and 56 deletions

View File

@@ -0,0 +1,37 @@
<?php
/**
* Content controller interface for new content types
*/
interface ContentController
{
/** This method will return all file extensions that will be associated with this content type
* for example 'pdf' but it could be anything really. You just need a way later to confirm that a type is what it says it is
*
*
* @return array the extensions of files associated with this controller. eg. return array('pdf');
*/
public function getRegisteredExtensions();
/** This method will be called whenever the system has to find out if a user requested (existing) hash
* belongs to this controller.
* In here the content should be rendered or processed like resized or something.
* You can decide what it does by working with the $url array which gives you every element in the URL
* Does not need to return anything for example you can just set the header and print your data right away
*
* @param string $hash the hash (with extension eg '5saB2.pdf') of the file this controller will work with
* @param array $url contains all URL elements exploded with '/' so you can do your magic.
*/
public function handleHash($hash,$url);
/** This method will be called if the upload script detects the content of a newly uploaded file as one of the
* extensions registered at "getRegisteredExtensions".
* For Example if someone uploads a PDF and getRegisteredExtensions has registered "pdf", then this method of this
* controller will be called
*
* @param string $tmpfile is the location on disk of the temp file that was uploaded. It is your job to put it somewhere, your handleHash method will find it again
* @param array $hash (optional) if you want your upload to have a certain hash then add it here. This allows for user chosen hashes
*/
public function handleUpload($tmpfile,$hash=false);
}

View File

@@ -0,0 +1,60 @@
<?php
/**
* StorageController interface
*
* Must be implemented by all storage systems
*/
interface StorageController
{
/**
* Checks if this storage system is enabled.
* For example check if all depenencies are met
* or config vars are set
*
* @return bool
*/
function isEnabled();
/**
* Is fired whenever a hash is not found locally
* Use this to look in your storage system for the file
*
* @param string $hash is the hash of the file requested
*
* @return bool
*/
function hashExists($hash);
/**
* If a file does exist in this storage system, then this method should
* get the file and put it in the default data directory
*
* The file should be placed in /data/$hash/$hash where the first $hash is obviously
* a folder that you might have to create first before putting the file in
*
* @param string $hash is the hash of the file that should be pulled from this storage system
*
* @return bool true if successful
*/
function pullFile($hash);
/**
* Whenever a new file is uploaded this method will be called
* You should then upload it or do whatever your storage system is meant to do with new files
*
* @param string $hash is the hash of the new file. The file path of this file is always ROOT.DS.'data'.DS.$hash.DS.$hash
*
* @return bool true if successful
*/
function pushFile($hash);
/**
* If deletion of a file is requested, this method is called
*
* @param string $hash is the hash of the file. Delete this hash from your storage system
*
* @return bool true if successful
*/
function deleteFile($hash);
}