Namespaces | Functions

cms/upload.lib.php File Reference

Go to the source code of this file.

Namespaces

namespace  pragyan
 

Widget Framework for Pragyan CMS (c) 2010 Pragyan Team http://www.gnu.org/licenses/ GNU Public License For more details, see README Add support for File Upload/Download via the widget's configurations Reload Widgets ,Get Widget Instances. see bottom.


Functions

 upload ($moduleComponentId, $moduleName, $userId, $uploadFormName, $maxFileSizeInBytes=false, $uploadableFileTypesArray=false)
 saveUploadedFile ($moduleComponentId, $moduleName, $userId, $uploadFileName, $tempFileName, $uploadFileType, $uploadDir)
 getUploadedFiles ($moduleComponentId, $moduleName)
 fileCopy ($sourcePage_modulecomponentid, $sourcePage_module, $sourceFile_name, $destinationPage_modulecomponentid, $destinationPage_module, $destinationFile_name, $user_id)
 fileMove ($sourcePage_modulecomponentid, $sourcePage_module, $sourceFile_name, $destinationPage_modulecomponentid, $destinationPage_module, $destinationFile_name, $user_id)
 getFileName ($moduleComponentId, $page_module, $upload_fileid)
 deleteFile ($moduleComponentId, $page_module, $upload_filename)
 getUploadedFilePreviewDeleteForm ($moduleComponentId, $moduleName, $deleteFormAction= './+edit')
 submitFileUploadForm ($moduleComponentId, $moduleName, $userId, $maxFileSizeInBytes=false, $uploadableFileTypesArray=false, $uploadFieldName= 'fileUploadField')
 getFileUploadForm ($moduleComponentId, $moduleName, $uploadFormAction= './+edit', $maxFileSizeInBytes=false, $uploadFieldCount=5, $uploadFieldName= 'fileUploadField')
 getFileUploadField ($uploadFieldName, $moduleName, $maxFileSizeInBytes=false, $validCheck="")
 getMultipleFileUploadField ($uploadFieldName, $moduleName, $maxFileSizeInBytes=false, $validCheck="")
 getFileUploadError ($i)
 open_image ($file)
 createThumbs ($pathToImages, $pathToThumbs, $thumbWidth)

Function Documentation

createThumbs ( pathToImages,
pathToThumbs,
thumbWidth 
)

Create thumbnail for an image if the module is gallery

Parameters:
$pathToImages The path where the image that has to be converted is stored.
$pathToThumbs The path where the thumbnail that is created must be saved.
Returns:
true if the thumbnail creation is successful and false otherwise

Definition at line 623 of file upload.lib.php.

deleteFile ( moduleComponentId,
page_module,
upload_filename 
)

Deletes the file

Parameters:
$moduleComponentId page_modulecomponentid.
$moduleName The module which is calling this function.
$upload_filename The name of the file which has to be deleted.
Returns:
mixed: true if the file has been deleted and false if not.

Definition at line 307 of file upload.lib.php.

fileCopy ( sourcePage_modulecomponentid,
sourcePage_module,
sourceFile_name,
destinationPage_modulecomponentid,
destinationPage_module,
destinationFile_name,
user_id 
)

Copies the files uploaded in one page to another.

Parameters:
$sourcePage_modulecomponentid page_modulecomponentid of the page from which the file must be copied.
$sourcePage_module The module from which the files should be copied.
$sourceFile_name The name of the file that should be copied.
$destinationPage_modulecomponentid page_modulecomponentid of the page to which the file must be copied.
$destinationPage_module The module to which the files should be copied.
$destinationFile_name The name to which the file that should be copied.
$user_id The user who is performing the copy operation.
Returns:
$copied true if copied, false if not copied successfully.

Definition at line 224 of file upload.lib.php.

fileMove ( sourcePage_modulecomponentid,
sourcePage_module,
sourceFile_name,
destinationPage_modulecomponentid,
destinationPage_module,
destinationFile_name,
user_id 
)

Moves the files uploaded in one page to another.

Parameters:
$sourcePage_modulecomponentid page_modulecomponentid of the page from which the file must be moved.
$sourcePage_module The module from which the files should be moved.
$sourceFile_name The name of the file that should be moved.
$destinationPage_modulecomponentid page_modulecomponentid of the page to which the file must be moved.
$destinationPage_module The module to which the files should be moved.
$destinationFile_name The name to which the file that should be moved.
$user_id The user who is performing the move operation.

Definition at line 261 of file upload.lib.php.

getFileName ( moduleComponentId,
page_module,
upload_fileid 
)

Return file name, given a file id ---- will never get used --- a module is supposed to have no knowledge of the file id.

Parameters:
$moduleComponentId page_modulecomponentid.
$moduleName The module which is calling this function.
$upload_fileid The file id of the file whose name is begin requested.
Returns:
mixed: The name of the file if it exists and false if not.

Definition at line 288 of file upload.lib.php.

getFileUploadError ( i  ) 
Parameters:
$i The error number as issued by the $FILES

return $errorcodes The error that must be thrown for the specified error number

Definition at line 577 of file upload.lib.php.

getFileUploadField ( uploadFieldName,
moduleName,
maxFileSizeInBytes = false,
validCheck = "" 
)

Gets a only text box for file upload

Parameters:
$uploadFieldName The name of the variable used in forms to upload the file
$moduleName The module which is calling this function.
$maxFileSizeInBytes the maximum permissible size of the files that can be uploaded.
$validCheck Constratins that must be applied to the upload field.
Returns:
$uploadFormString The file upload field HTML in a string

Definition at line 546 of file upload.lib.php.

getFileUploadForm ( moduleComponentId,
moduleName,
uploadFormAction = './+edit',
maxFileSizeInBytes = false,
uploadFieldCount = 5,
uploadFieldName = 'fileUploadField' 
)

Formulates a file upload form which can be used in modules.

Parameters:
$moduleComponentId page_modulecomponentid.
$moduleName The module which is calling this function.
$uploadFormAction The action that must be processed in submitting the form.
$maxFileSizeInBytes the maximum permissible size of the files that can be uploaded.
$uploadFieldCount The maximum number of that that can be submitted in one form.
$uploadFieldName The name of the variable used in forms to upload the file
Returns:
$uploadFormString The file upload form HTML in a string

Definition at line 500 of file upload.lib.php.

getMultipleFileUploadField ( uploadFieldName,
moduleName,
maxFileSizeInBytes = false,
validCheck = "" 
)

HTML 5 MULTIPLE UPLOAD FILE

Parameters:
$uploadFieldName The name of the variable used in forms to upload the file
$moduleName The module which is calling this function.
$maxFileSizeInBytes the maximum permissible size of the files that can be uploaded.
$validCheck Constratins that must be applied to the upload field.
Returns:
$uploadFormString The file upload field HTML in a string

Definition at line 564 of file upload.lib.php.

getUploadedFilePreviewDeleteForm ( moduleComponentId,
moduleName,
deleteFormAction = './+edit' 
)

Returns a form which displays the list of files uploaded in that page and if the user has sufficient permissions option to delete files.

Parameters:
$moduleComponentId page_modulecomponentid.
$moduleName The module which is calling this function.
$deleteFormAction The page or action that must be taken on clicking the delete option in the final form,
Returns:
A variable that has the required form.

Definition at line 347 of file upload.lib.php.

getUploadedFiles ( moduleComponentId,
moduleName 
)

Return the files uploaded for this module with this module component id. Return an array of file names

Parameters:
$moduleComponentId page_modulecomponentid.
$moduleName The module which is calling this function.
Returns:
$fileArray An array of the names of the files that were uploaded into the page.

Definition at line 200 of file upload.lib.php.

open_image ( file  ) 
Parameters:
$file The file that has to be opened to be used by createThumbs
Returns:
$im The opened image

Definition at line 596 of file upload.lib.php.

saveUploadedFile ( moduleComponentId,
moduleName,
userId,
uploadFileName,
tempFileName,
uploadFileType,
uploadDir 
)

Saves the uploaded file.

Parameters:
$moduleComponentId page_modulecomponentid.
$moduleName The module which is calling this function.
$userId The user uploading the file.
$uploadFileName The name of the uploaded file.
$tempFileName The temporary file name of the uploaded file.
$uploadFileType The file type of the uploaded file.
Returns:
$uploadFilaName The name of the file uploaded.

Checking for inconsistency in the uploaded file names.

Checking for duplicate entry of the file.

If galery create thumbnail and store in the database.

Definition at line 141 of file upload.lib.php.

submitFileUploadForm ( moduleComponentId,
moduleName,
userId,
maxFileSizeInBytes = false,
uploadableFileTypesArray = false,
uploadFieldName = 'fileUploadField' 
)

Submits the file upload from

Parameters:
$moduleComponentId page_modulecomponentid.
$moduleName The module which is calling this function.
$userId The user who is uploading the files.
$maxFileSizeInBytes the maximum permissible size of the files that can be uploaded.
$uploadableFileTypesArray An array that contains the file types that has been permitted to be uploaded on that page.
$uploadableFieldName The name of the variable used in forms to upload the file
Returns:
mixed : true if any error is found in the upload otherwise array of filenames uploaded

Definition at line 470 of file upload.lib.php.

upload ( moduleComponentId,
moduleName,
userId,
uploadFormName,
maxFileSizeInBytes = false,
uploadableFileTypesArray = false 
)

Uploads the file

Parameters:
$moduleComponentId page_modulecomponentid
$moduleName The module which is calling this function
$uploadFormName The name of the variable used in forms to upload the file
$userId The user uploading the file
Returns:
$uploadedFiles An array of the names of the files uploaded. The file name is mysql_escaped and then uploaded

TODO : when called by a module check if it exists in enum field in DB if not give error.

Checking if the upload folder exists and creating it if doesn't exist

Checking for existing directory named as the module and creating it if doesn't exist

Checking if the uploaded file is of the permssible file types.

Checking if the uploaded file is below the maximum upload size.

Definition at line 27 of file upload.lib.php.