<commit_before># FileStorage plugin for CakePHP 2.x

This is work in progress, the code might and very likely will change for some more time.

So please do not ask yet or create issue tickets.

## Installation

To be able to simple autoload Gaufrette load the plugin with bootstrap enabled. The bootstrap file will register the SPL classloader.

	CakePlugin::load('FileStorage', array('bootstrap' => true));

This plugin depends on the Gaufrette library (https://github.com/KnpLabs/Gaufrette), init the submodule, the plugin depends on it.

	git submodule update --init

If you want to use S3 upload Gaufrette has also submodules to initialize. Here is the whole story to get everything initialized:

	git clone git://github.com/burzum/FileStorage.git
	cd FileStorage
	git submodule update --init
	cd Vendor/Gaufrette
	git submodule update --init

## Usage

You can configure as many file storage adapters as you want with different settings via Configure:

	Configure::write('FileStorage.adapters', array(
		'Local' => array(
			'adapterOptions' => array(TMP, true),
			'adapterClass' => '\Gaufrette\Adapter\Local',
			'class' => '\Gaufrette\Filesystem')));

To invoke a new instace using a configuration call:

	$FileStorage->storageAdapter('Local');

Alternativly you can pass a config array as first argument.

### Image Versioning

You can set up automatic image processing for the FileStorage.Image model.

All you need to do is basically use the image model and configure versions on a per model basis. When you save an Image model record it is important to have the 'model' field filled so that the script can find the correct versions for that model.

	Configure::write('Media', array(
		'imageSizes' => array(
			'GalleryImage' => array(
				'c50' => array(
					'crop' => array(
						'width' => 50, 'height' => 50)),
				't120' => array(
					'thumbnail' => array(
						'width' => 120, 'height' => 120))),
				't800' => array(
					'thumbnail' => array(
						'width' => 800, 'height' => 600))),
			'User' => array(
				'c50' => array(
					'crop' => array(
						'width' => 50, 'height' => 50)),
				't150' => array(
					'crop' => array(
						'width' => 150, 'height' => 150))),
			)
		)
	);
	ClassRegistry::init('FileStorage.Image')->generateHashes();

Calling generateHashes is important, it will create the hash values for each versioned image.

If you do not want to have the script generated the hashes each time its execute it is up to you to store it persistant. This plugin just provides you the tools.

## Requirements<commit_msg>Correcting typos in readme.md<commit_after># FileStorage plugin for CakePHP 2.x

This is work in progress, the code might and very likely will change for some more time.

So please do not ask yet or create issue tickets.

## Installation

To be able to simply autoload Gaufrette load the plugin with bootstrap enabled. The bootstrap file will register the SPL classloader.

	CakePlugin::load('FileStorage', array('bootstrap' => true));

This plugin depends on the Gaufrette library (https://github.com/KnpLabs/Gaufrette), init the submodule, the plugin depends on it.

	git submodule update --init

If you want to use S3 upload Gaufrette has also submodules to initialize. Here is the whole story to get everything initialized:

	git clone git://github.com/burzum/FileStorage.git
	cd FileStorage
	git submodule update --init
	cd Vendor/Gaufrette
	git submodule update --init

## Usage

You can configure as many file storage adapters as you want with different settings via Configure:

	Configure::write('FileStorage.adapters', array(
		'Local' => array(
			'adapterOptions' => array(TMP, true),
			'adapterClass' => '\Gaufrette\Adapter\Local',
			'class' => '\Gaufrette\Filesystem')));

To invoke a new instance using a configuration call:

	$FileStorage->storageAdapter('Local');

Alternativly you can pass a config array as first argument.

### Image Versioning

You can set up automatic image processing for the FileStorage.Image model.

All you need to do is basically use the image model and configure versions on a per model basis. When you save an Image model record it is important to have the 'model' field filled so that the script can find the correct versions for that model.

	Configure::write('Media', array(
		'imageSizes' => array(
			'GalleryImage' => array(
				'c50' => array(
					'crop' => array(
						'width' => 50, 'height' => 50)),
				't120' => array(
					'thumbnail' => array(
						'width' => 120, 'height' => 120))),
				't800' => array(
					'thumbnail' => array(
						'width' => 800, 'height' => 600))),
			'User' => array(
				'c50' => array(
					'crop' => array(
						'width' => 50, 'height' => 50)),
				't150' => array(
					'crop' => array(
						'width' => 150, 'height' => 150))),
			)
		)
	);
	ClassRegistry::init('FileStorage.Image')->generateHashes();

Calling generateHashes is important, it will create the hash values for each versioned image and store them in Media.imageHashes in the configuration.

If you do not want to have the script generated the hashes each time its execute it is up to you to store it persistant. This plugin just provides you the tools.

## Requirements
{'fraction_non_alphanumeric': 0.10648148148148148, 'fraction_numerical': 0.015817901234567902, 'mean_word_length': 3.8457943925233646, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 63, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1907255', 'n_tokens_mistral': 1739, 'n_tokens_neox': 1477, 'n_words': 648}