A Joomla System plugin for JCE Filesystem Events
Click here to download, or the Download Zip button on the right.
Install using the Joomla Extensions Installer
https://docs.joomla.org/Installing_an_extension
This plugin provides a sample of JPlugin event methods for responding to JCE Filesystem Events.
The events currently available are:
- onWfFileSystemBeforeGetPathVariables
- onWfFileSystemGetPathVariables
- onWfFileSystemBeforeGetRootDir
- onWfFileSystemGetRootDir
- onWfFileSystemBeforeDelete
- onWfFileSystemAfterDelete
- onWfFileSystemCreateFolder
- onWfFileSystemBeforeRename
- onWfFileSystemAfterRename
- onWfFileSystemBeforeCopy
- onWfFileSystemAfterCopy
- onWfFileSystemBeforeMove
- onWfFileSystemAfterMove
- onWfFileSystemBeforeUpload
- onWfFileSystemAfterUpload
- onWfFileSystemBeforeWrite
- onWfFileSystemAfterWrite
This plugin can be used as a blueprint for your own plugin, or you can edit the methods and add code to respond to each event.
This method would respond to an upload event, and resize the image using the Joomla JImage class.
public function onWfFileSystemAfterUpload(&$result) {
// upload was a success
if ($result->state) {
jimport('joomla.image.image');
$image = new JImage($result->path);
// resize image to fit 800 x 600
$image->resize(800, 600, false)->toFile($result->path);
// destroy handle
$image->destroy();
}
}
This method would respond to a folder create, and add an htaccess file to the folder.
public function onWfFileSystemCreateFolder($path, $state) {
// create folder was a success
if ($state) {
$data = "order allow deny\rdeny from all\rallow from 127.0.0.1";
file_put_contents($path . '/.htaccess', $data);
}
}
This method will use a speficic folder when performing an inline (drag & drop) upload.
public function onWfFileSystemGetRootDir(&$root)
{
if (JFactory::getApplication()->input->getInt('inline', 0) === 1) {
$year = date('Y');
$month = date('m');
$day = date('d');
$root = 'images/uploads/' . $year;
}
}