Skip to content
Snippets Groups Projects
Commit c81f6d30 authored by VladimirCherkasov's avatar VladimirCherkasov
Browse files

add Controller_Support_Image to receive support images

parent af0d7cf5
Branches
Tags
No related merge requests found
......@@ -275,6 +275,13 @@ Route::set('admin:common', 'admin(/<controller>(/<action>(/<param1>(:<param2>)))
'action' => 'index'
]);
Route::set('support:image', 'support/image(/<action>)/<id>')//, ['id' => '[0-9]+'])
->defaults([
'directory' => 'Support',
'controller' => 'Image',
'action' => 'view'
]);
// --------------- Java session provider --------------
Route::set('javaSessionProvider', 'java_authentication')
->defaults([
......
......@@ -10,4 +10,4 @@ class Controller_Environment_Admin extends Controller_Environment_User
$this->user->checkAccess(User::RIGHTS_ADMIN);
}
}
\ No newline at end of file
}
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Support_Image extends Controller_Environment_Admin
{
public function before() {
parent::before();
}
public function after() {
}
public function action_view() {
$filename = DOCROOT . SupportImageSaver::directoryToSave .
$this->request->param('id') . SupportImageSaver::imageExtension;
$this->responseImage($filename);
}
public function action_preview() {
$filename = DOCROOT . SupportImageSaver::directoryToSave .
SupportImageSaver::thumbPref . $this->request->param('id') . SupportImageSaver::imageExtension;
$this->responseImage($filename);
}
private function responseImage($filename) {
if (!file_exists($filename) OR !is_file($filename)) {
throw new HTTP_Exception_404('Picture not found');
}
$image = file_get_contents($filename);
$info = getimagesize($filename);
$mime = $info['mime'];
$this->response->headers('Content-Type', $mime)
->body($image);
}
}
......@@ -3,11 +3,14 @@
class SupportImageSaver
{
const savingStatusOk = true;
const directoryToSave = 'support/img/';
const imageExtension = '.jpg';
const thumbPref = 'thumb_';
private $_rootDir = DOCROOT;
private $_subDir = 'support/img/';
private $_fileExt = '.jpg';
private $_thumbSuf = 'thumb_';
private $_subDir = self::directoryToSave;
private $_fileExt = self::imageExtension;
private $_thumbPref = self::thumbPref;
private $_srcFilePath = null;
private $_targetFilePath = null;
......@@ -23,7 +26,7 @@ class SupportImageSaver
$this->_srcFilePath = $srcFilePath;
$this->_targetFilePath = $dir . $file;
$this->_targetPreviewPath = $dir . $this->_thumbSuf . $file;
$this->_targetPreviewPath = $dir . $this->_thumbPref . $file;
}
public function saveImage() {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment