<commit_before># yii2-toolbox
Yii2-Toolbox is a collection of useful helpers, widgets etc. extending the basic functionality of Yii2


## Installation
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

	"asinfotrack/yii2-toolbox": "dev-master"


## Contents


### Components

###### PdfResponseFormatter
Additional response formatter for handling PDF-requests. You need to add the formatter to the config like this:
```php
'response' => [
	// ...
	'formatters'=>[
		'pdf'=>'asinfotrack\yii2\toolbox\components\PdfResponseFormatter',
		'pdf_download'=>[
			'class'=>'asinfotrack\yii2\toolbox\components\PdfResponseFormatter', 
			'forceDownload'=>true,
		],
	],
	// ...
],
```

After that you can use it to output PDFs via actions easily:

```php
public function actionPdf()
{
	//create pdf with some library (eg FPDF)
	$pdf = new FPDF();
	// ...

	$response = Yii::$app->response;
	$response->data = $pdf->Output();
	$response->format = 'pdf';
}
```

###### User
Extends `\yii\web\User` with the ability to check multiple rights at once (canAll, 
canAny, canOne).



### Widgets

###### Button
The button-widget extends the one provided by yii2. It adds functionality to specify an icon.
The Icons depend on font-awesome and hence require the yii2-extension `rmrevin/yii2-fontawesome`

###### Panel
Renders a Bootstrap-Panel. You can either set its body via attribute or between `begin()` and `end()`.
The attributes `heading`, `body` and `footer` support setting via string or via Closure returning a string.
Exemplary usage:

```php
<?php Panel::begin([
	'heading'=>Html::tag('h3', 'Welcome!'),
	'footer'=>function() {
		return Yii::$app->formatter->asDatetime(time());
	},
]); ?>
 	
 	<p>Hello world! This is a simple panel with a heading.</p>
 	 	
<?php Penel::end(); ?>
```

###### Grid column-types
The column types provided extend the functionality of the basic `\yii\grid\DataColumn`. The
class is `AdvancedDataColumn`. It has functionality to align text, set the column with with either
absolute or percent values etc.

Additionally there are three further column types:
* `BooleanColumn` optimized for rendering boolean values
*  `IdColumn` optimized for rendering id values eith with or without code-tags
* `LinkColumn` renders links (which can be generated using a closure)


### Helpers

###### Color
Makes working with HEX- or RGB-colors easy! It can translate between the two formats,
lighten or darken colors as well as creating steps between two colors. You can also
use it to get a colors luminance or validate color-values.
Short HEX-Formats are supported automatically.

###### Html
Extends the Html-helper of Yii2 with additional functionality

###### Migration
Helper for common tasks concerning migrations (eg checking if a migration was applied, etc).

###### ServerConfig
Provides functionality to fetch the most important server vars and to check if certain
extensions are loaded

###### Timestamp
This helper is responsible for common tasks associated with UNIX-Timestamps. It also has a
function to parse dates into timestamps (extracted functionality of the yii date validator)

###### Url
This helper extends the basic functionality of the Yii2-Url-helper. It provides functionality
to retrieve information about the currently requested url, such as TLD, subdomains, etc.


### Behaviors

###### ArchiveBehavior / ArchiveQueryBehavior
Enables a model to be archived or not. This is similiar to a soft-delete but with the idea of not
deleting a record but archive it instead.
The behavior is fully configurable and there is also a behavior for the corresponding query-class.



### Validators

###### SelectiveRequiredValidator
Validator to require a certain amount of fields out of a list to be required. To use the validator<commit_msg>fixed wrong naming of helper classes in readme<commit_after># yii2-toolbox
Yii2-Toolbox is a collection of useful helpers, widgets etc. extending the basic functionality of Yii2


## Installation
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

	"asinfotrack/yii2-toolbox": "dev-master"


## Contents


### Components

###### PdfResponseFormatter
Additional response formatter for handling PDF-requests. You need to add the formatter to the config like this:
```php
'response' => [
	// ...
	'formatters'=>[
		'pdf'=>'asinfotrack\yii2\toolbox\components\PdfResponseFormatter',
		'pdf_download'=>[
			'class'=>'asinfotrack\yii2\toolbox\components\PdfResponseFormatter', 
			'forceDownload'=>true,
		],
	],
	// ...
],
```

After that you can use it to output PDFs via actions easily:

```php
public function actionPdf()
{
	//create pdf with some library (eg FPDF)
	$pdf = new FPDF();
	// ...

	$response = Yii::$app->response;
	$response->data = $pdf->Output();
	$response->format = 'pdf';
}
```

###### User
Extends `\yii\web\User` with the ability to check multiple rights at once (canAll, 
canAny, canOne).



### Widgets

###### Button
The button-widget extends the one provided by yii2. It adds functionality to specify an icon.
The Icons depend on font-awesome and hence require the yii2-extension `rmrevin/yii2-fontawesome`

###### Panel
Renders a Bootstrap-Panel. You can either set its body via attribute or between `begin()` and `end()`.
The attributes `heading`, `body` and `footer` support setting via string or via Closure returning a string.
Exemplary usage:

```php
<?php Panel::begin([
	'heading'=>Html::tag('h3', 'Welcome!'),
	'footer'=>function() {
		return Yii::$app->formatter->asDatetime(time());
	},
]); ?>
 	
 	<p>Hello world! This is a simple panel with a heading.</p>
 	 	
<?php Penel::end(); ?>
```

###### Grid column-types
The column types provided extend the functionality of the basic `\yii\grid\DataColumn`. The
class is `AdvancedDataColumn`. It has functionality to align text, set the column with with either
absolute or percent values etc.

Additionally there are three further column types:
* `BooleanColumn` optimized for rendering boolean values
*  `IdColumn` optimized for rendering id values eith with or without code-tags
* `LinkColumn` renders links (which can be generated using a closure)


### Helpers

###### ColorHelper
Makes working with HEX- or RGB-colors easy! It can translate between the two formats,
lighten or darken colors as well as creating steps between two colors. You can also
use it to get a colors luminance or validate color-values.
Short HEX-Formats are supported automatically.

###### Html
Extends the Html-helper of Yii2 with additional functionality

###### MigrationHelper
Helper for common tasks concerning migrations (eg checking if a migration was applied, etc).

###### ServerConfig
Provides functionality to fetch the most important server vars and to check if certain
extensions are loaded

###### Timestamp
This helper is responsible for common tasks associated with UNIX-Timestamps. It also has a
function to parse dates into timestamps (extracted functionality of the yii date validator)

###### Url
This helper extends the basic functionality of the Yii2-Url-helper. It provides functionality
to retrieve information about the currently requested url, such as TLD, subdomains, etc.


### Behaviors

###### ArchiveBehavior / ArchiveQueryBehavior
Enables a model to be archived or not. This is similiar to a soft-delete but with the idea of not
deleting a record but archive it instead.
The behavior is fully configurable and there is also a behavior for the corresponding query-class.



### Validators

###### SelectiveRequiredValidator
Validator to require a certain amount of fields out of a list to be required. To use the validator
{'fraction_non_alphanumeric': 0.1057154016404114, 'fraction_numerical': 0.003124593151933342, 'mean_word_length': 4.623718887262079, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '993808', 'n_tokens_mistral': 2206, 'n_tokens_neox': 2088, 'n_words': 932}