%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
<?php
namespace mdm\widgets;
use yii\helpers\Html;
use yii\helpers\Json;
use yii\widgets\InputWidget;
/**
* Description of CropImage
*
* @author Misbahul D Munir <misbahuldmunir@gmail.com>
* @since 1.0
*/
class CropImage extends InputWidget
{
/**
* @var array the HTML attributes for the input tag.
* @see Html::renderTagAttributes() for details on how attributes are being rendered.
*/
public $imgOptions = [];
/**
*
* @var array
*/
public $clientOptions = [];
/**
*
* @var string
*/
public $cropParam = 'crop';
/**
* @inheritdoc
*/
public function init()
{
parent::init();
}
/**
* @inheritdoc
*/
public function run()
{
$id = $this->options['id'] = $this->getId();
Html::addCssClass($this->options, 'dcorpbox');
Html::addCssClass($this->imgOptions, 'content');
CropAsset::register($this->getView());
$clientOptions = $this->clientOptions;
$this->imgOptions['id'] = $id . '-img';
$clientOptions['imgTemplate'] = Html::tag('img', '',$this->imgOptions);
$opts = Json::encode($clientOptions);
$js = "jQuery('#{$id}').dCropBox($opts);";
$this->getView()->registerJs($js);
$inputOptions = ['style' => 'visibility:hidden;', 'class' => 'file-input', 'id' => $id . '-file'];
if ($this->hasModel()) {
$fileInput = Html::activeFileInput($this->model, $this->attribute, $inputOptions);
} else {
$fileInput = Html::fileInput($this->name, $this->value, $inputOptions);
}
return $this->render('crop-image', [
'options' => $this->options,
'fileInput' => $fileInput,
'cropParam' => $this->cropParam,
]);
}
}