uploader->setRecordID($this->form->recordID()); return $this->uploader; } /** * Список полей при построении запроса к БД * @return array */ public function fieldsList() { return [ $this->uploader->tableRecordCnt(), $this->uploader->tableRecordFav() ]; } protected function viewPrepare(&$data) { if (! $this->rotate) { return; } $data['rotate'] = $this->rotate; $uploader = $this->uploader(); foreach ($data['value'] as & $v) { $v['rotate'] = $uploader->rotateAvailable($v); } unset($v); } public function ajax() { # вращение изображения $this->ajaxHandler('rotate', function () { $filename = $this->input->post('filename', TYPE_STR); if (empty($filename)) { $this->errors->impossible(); return []; } $result = []; if ($this->recordID()) { $images = $this->uploader()->getData(); foreach ($images as $v) { if ($v['filename'] == $filename) { $result = $this->uploader()->rotate($v['id'], -90); } } } else { # повернем временное изображений $result = $this->uploader()->rotateTmp($filename, -90); } if (empty($result)) { if ($this->errors->no()) { $this->errors->impossible(); } return []; } $sizes = [$this->iO, $this->iS]; return array_merge($result, $this->uploader->getURL($result, $sizes, $this->uploader->isTmp())); }); return parent::ajax(); } public function limit() { return $this->uploader->getLimit(); } public function setLimit($limit) { $this->uploader->setLimit((int)$limit); } }