23 $configureActions = [];
25 $configureActions[
'preview'] = [
27 ActionFilter\Csrf::class,
28 ActionFilter\HttpMethod::class,
36 $configureActions[
'download'] = [
38 ActionFilter\Csrf::class,
39 ActionFilter\HttpMethod::class,
46 return $configureActions;
74 UploaderController::class,
76 function ($className,
string $controller,
string $controllerOptions =
null) {
79 $options = empty($controllerOptions) ? [] : Json::decode($controllerOptions);
80 $options = is_array($options) ? $options : [];
90 if ($availableControllers ===
null)
93 'You have to override "getAvailableControllers" method for your custom ajax controller.'
100 $className = strtolower(ltrim($className,
'\\'));
102 $availableNames = array_map(
function($name) {
103 return strtolower(ltrim($name,
'\\'));
104 }, $availableControllers);
107 !in_array(strtolower($controller), $availableNames)
108 && !in_array($className, $availableNames)
117 return ControllerResolver::createController($controller, $options);
122 function ($className) use (
$request) {
124 if ($result->isSuccess())
126 return $result->getData()[
'chunk'];
215 $uploader =
new Uploader($controller);
216 $loadResults = $uploader->load([$fileId]);
217 $loadResult = $loadResults->getAll()[0] ??
null;
219 if ($loadResult ===
null)
223 else if ($loadResult->isSuccess())
225 $imageId = $loadResult->getFile() ? $loadResult->getFile()->getFileId() : 0;
226 $imageData = \CFile::getFileArray($imageId);
228 if (is_array($imageData))
231 $response =
new Response\ResizedImage($imageData, 300, 300);
232 $response->setResizeType(BX_RESIZE_IMAGE_PROPORTIONAL);
233 $response->setCacheTime(86400);
244 $this->
addErrors($loadResult->getErrors());