mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-24 22:11:01 -06:00
Merge pull request #903 from openclassify/muammertop
#3002 maabir pdf.rar
This commit is contained in:
commit
fbb2b36c57
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Anomaly\Streams\Platform\Database\Migration\Migration;
|
||||||
|
|
||||||
|
class VisiosoftModuleAdvsAddDocFilesField extends Migration
|
||||||
|
{
|
||||||
|
protected $delete = false;
|
||||||
|
|
||||||
|
protected $stream = [
|
||||||
|
'slug' => 'advs',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $fields = [
|
||||||
|
'doc_files' => [
|
||||||
|
'type' => 'visiosoft.field_type.media',
|
||||||
|
'config' => [
|
||||||
|
'folders' => ["ads_documents"],
|
||||||
|
'mode' => 'upload',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $assignments = [
|
||||||
|
'doc_files'
|
||||||
|
];
|
||||||
|
}
|
||||||
@ -319,6 +319,7 @@ return [
|
|||||||
'congratulations' => 'Congratulations',
|
'congratulations' => 'Congratulations',
|
||||||
'ad_desc' => 'Ad Description',
|
'ad_desc' => 'Ad Description',
|
||||||
'upload_photos' => 'Upload Photos',
|
'upload_photos' => 'Upload Photos',
|
||||||
|
'upload_files' => 'Upload Files',
|
||||||
'additional_fields' => 'Additional Fields',
|
'additional_fields' => 'Additional Fields',
|
||||||
'ad_location' => 'Ad Location',
|
'ad_location' => 'Ad Location',
|
||||||
|
|
||||||
|
|||||||
@ -36,6 +36,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<!--detail-ad -->
|
<!--detail-ad -->
|
||||||
|
|
||||||
|
<ul class="docs list-unstyled">
|
||||||
|
{% for doc in adv.doc_files %}
|
||||||
|
<li><a class="text-dark small" href="{{ doc.url }}"><i class="fa fa-lg fa-download small"></i> {{ doc.name }}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
|
||||||
{% if setting_value('visiosoft.theme.base::ad_details_tab') %}
|
{% if setting_value('visiosoft.theme.base::ad_details_tab') %}
|
||||||
|
|
||||||
{% if blocks('ad-item-content-block-area') is null %}
|
{% if blocks('ad-item-content-block-area') is null %}
|
||||||
|
|||||||
@ -178,6 +178,15 @@
|
|||||||
<div class="row form-group images">
|
<div class="row form-group images">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
{{ form.fields.files.input |raw }}
|
{{ form.fields.files.input |raw }}
|
||||||
|
<input name="doc_files" value="{{ form.fields.doc_files.value.pluck('id').all()|join(',') }}" hidden>
|
||||||
|
{% for docs in form.fields.doc_files.value %}
|
||||||
|
<div class="doc_list small">
|
||||||
|
{{ docs.name }}
|
||||||
|
<a id="{{ docs.id }}" href="javascript:void(0)" onclick="deleteDocs({{ docs.id }})" class="text-dark">
|
||||||
|
<i class="fa fa-trash text-danger"></i>
|
||||||
|
</a><br>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -53,7 +53,8 @@ class AdvFormBuilder extends FormBuilder
|
|||||||
'class' => 'hidden d-none mapVal'
|
'class' => 'hidden d-none mapVal'
|
||||||
],
|
],
|
||||||
'files',
|
'files',
|
||||||
'popular_adv',
|
'doc_files',
|
||||||
|
'popular_adv',
|
||||||
'adv_day',
|
'adv_day',
|
||||||
'product_options_value'
|
'product_options_value'
|
||||||
];
|
];
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<?php namespace Visiosoft\AdvsModule\Http\Controller;
|
<?php namespace Visiosoft\AdvsModule\Http\Controller;
|
||||||
|
|
||||||
|
use Anomaly\FilesModule\File\Contract\FileRepositoryInterface;
|
||||||
use Anomaly\SettingsModule\Setting\Contract\SettingRepositoryInterface;
|
use Anomaly\SettingsModule\Setting\Contract\SettingRepositoryInterface;
|
||||||
use Anomaly\Streams\Platform\Http\Controller\PublicController;
|
use Anomaly\Streams\Platform\Http\Controller\PublicController;
|
||||||
use Anomaly\Streams\Platform\Message\MessageBag;
|
use Anomaly\Streams\Platform\Message\MessageBag;
|
||||||
|
|||||||
@ -3,6 +3,7 @@ Dropzone.autoDiscover = false;
|
|||||||
$("div#myDrop").dropzone({url: "/file/post"});
|
$("div#myDrop").dropzone({url: "/file/post"});
|
||||||
|
|
||||||
var uploaded = $('input[name="files"]').val().split(',').map(Number);
|
var uploaded = $('input[name="files"]').val().split(',').map(Number);
|
||||||
|
var docsUploaded = $('input[name="doc_files"]').val().split(',').map(Number);
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
|
|
||||||
@ -67,23 +68,28 @@ $(function () {
|
|||||||
dropzone.on('success', function (file) {
|
dropzone.on('success', function (file) {
|
||||||
|
|
||||||
var response = JSON.parse(file.xhr.response);
|
var response = JSON.parse(file.xhr.response);
|
||||||
|
var mimeType = response.mime_type.split('/')
|
||||||
|
if (mimeType[0] === 'image'){
|
||||||
|
uploaded.push(response.id);
|
||||||
|
|
||||||
uploaded.push(response.id);
|
$('.media-selected-wrapper').load(
|
||||||
|
REQUEST_ROOT_PATH + '/streams/media-field_type/selected?uploaded=' + uploaded.join(','),
|
||||||
|
function () {
|
||||||
|
$('input[name="files"]').val(uploaded.join(','))
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
$('.media-selected-wrapper').load(
|
file.previewElement.querySelector('[data-dz-uploadprogress]').setAttribute('class', 'progress progress-success');
|
||||||
REQUEST_ROOT_PATH + '/streams/media-field_type/selected?uploaded=' + uploaded.join(','),
|
|
||||||
function () {
|
|
||||||
$('input[name="files"]').val(uploaded.join(','))
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
file.previewElement.querySelector('[data-dz-uploadprogress]').setAttribute('class', 'progress progress-success');
|
setTimeout(function () {
|
||||||
|
|
||||||
setTimeout(function () {
|
addAppendByData(uploaded[0])
|
||||||
|
file.previewElement.remove();
|
||||||
addAppendByData(uploaded[0])
|
}, 500);
|
||||||
file.previewElement.remove();
|
} else {
|
||||||
}, 500);
|
docsUploaded.push(response.id);
|
||||||
|
$('input[name="doc_files"]').val(docsUploaded.join(','))
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// When file fails to upload.
|
// When file fails to upload.
|
||||||
@ -109,6 +115,13 @@ function deleteImage(e, id) {
|
|||||||
$('.imageList').find('div[data-id="' + id + '"]').remove()
|
$('.imageList').find('div[data-id="' + id + '"]').remove()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deleteDocs(id) {
|
||||||
|
var key_item = $.inArray(id, docsUploaded);
|
||||||
|
docsUploaded.splice(key_item, 1);
|
||||||
|
$('input[name="doc_files"]').val(docsUploaded.join(','))
|
||||||
|
$('.doc_list').find('#' + id).remove()
|
||||||
|
}
|
||||||
|
|
||||||
function rotateImage(e, id) {
|
function rotateImage(e, id) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
|
|||||||
@ -50,94 +50,104 @@ class UploadController extends AdminController
|
|||||||
|
|
||||||
public function upload()
|
public function upload()
|
||||||
{
|
{
|
||||||
$file = $this->uploader->upload($this->request->file('upload'), $this->folders->find($this->request->get('folder')));
|
$doc_folder = app(FolderRepositoryInterface::class)->findBySlug('ads_documents')->id;
|
||||||
|
$mimes = explode('/', $this->request->file('upload')->getMimeType());
|
||||||
|
|
||||||
|
if ($mimes[0] == 'image'){
|
||||||
|
$file = $this->uploader->upload($this->request->file('upload'), $this->folders->find($this->request->get('folder')));
|
||||||
|
} else {
|
||||||
|
$file = $this->uploader->upload($this->request->file('upload'), $this->folders->find($doc_folder));
|
||||||
|
}
|
||||||
|
|
||||||
if ($file) {
|
if ($file) {
|
||||||
|
if ($mimes[0] == 'image'){
|
||||||
|
|
||||||
$settings_key = [
|
$settings_key = [
|
||||||
'image_resize_backend',
|
'image_resize_backend',
|
||||||
'full_image_width',
|
'full_image_width',
|
||||||
'full_image_height',
|
'full_image_height',
|
||||||
'medium_image_width',
|
'medium_image_width',
|
||||||
'medium_image_height',
|
'medium_image_height',
|
||||||
'thumbnail_width',
|
'thumbnail_width',
|
||||||
'thumbnail_height',
|
'thumbnail_height',
|
||||||
'add_canvas',
|
'add_canvas',
|
||||||
'image_canvas_width',
|
'image_canvas_width',
|
||||||
'image_canvas_height',
|
'image_canvas_height',
|
||||||
'watermark_type',
|
'watermark_type',
|
||||||
'watermark_text',
|
'watermark_text',
|
||||||
'watermark_image',
|
'watermark_image',
|
||||||
'watermark_position'
|
'watermark_position'
|
||||||
];
|
];
|
||||||
|
|
||||||
$settings_value = array();
|
$settings_value = array();
|
||||||
|
|
||||||
foreach ($settings_key as $key) {
|
foreach ($settings_key as $key) {
|
||||||
$settings_value[$key] = setting_value('visiosoft.module.advs::' . $key);
|
$settings_value[$key] = setting_value('visiosoft.module.advs::' . $key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$fullImg = WaterMark::make($this->request->file('upload')->getRealPath());
|
$fullImg = WaterMark::make($this->request->file('upload')->getRealPath());
|
||||||
|
|
||||||
if ($settings_value['image_resize_backend']) {
|
if ($settings_value['image_resize_backend']) {
|
||||||
$fullImg = $fullImg->resize(null, $settings_value['full_image_height'],
|
$fullImg = $fullImg->resize(null, $settings_value['full_image_height'],
|
||||||
function ($constraint) {
|
function ($constraint) {
|
||||||
$constraint->aspectRatio();
|
$constraint->aspectRatio();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$mdImg = WaterMark::make($this->request->file('upload')->getRealPath())
|
$mdImg = WaterMark::make($this->request->file('upload')->getRealPath())
|
||||||
->resize(null, $settings_value['medium_image_height'], function ($constraint) {
|
->resize(null, $settings_value['medium_image_height'], function ($constraint) {
|
||||||
$constraint->aspectRatio();
|
$constraint->aspectRatio();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if ($settings_value['add_canvas']) {
|
if ($settings_value['add_canvas']) {
|
||||||
|
|
||||||
$fullImg->resizeCanvas(
|
$fullImg->resizeCanvas(
|
||||||
$settings_value['image_canvas_width'], $settings_value['image_canvas_height'],
|
$settings_value['image_canvas_width'], $settings_value['image_canvas_height'],
|
||||||
'center', false, 'fff'
|
'center', false, 'fff'
|
||||||
);
|
);
|
||||||
|
|
||||||
$mdImg->resizeCanvas(
|
$mdImg->resizeCanvas(
|
||||||
$settings_value['medium_image_width'], $settings_value['medium_image_height'],
|
$settings_value['medium_image_width'], $settings_value['medium_image_height'],
|
||||||
'center', false, 'fff'
|
'center', false, 'fff'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$image_types = array('full' => $fullImg, 'medium' => $mdImg);
|
$image_types = array('full' => $fullImg, 'medium' => $mdImg);
|
||||||
|
|
||||||
foreach ($image_types as $key => $image) {
|
foreach ($image_types as $key => $image) {
|
||||||
|
|
||||||
if ($settings_value['watermark_type'] == 'image') {
|
if ($settings_value['watermark_type'] == 'image') {
|
||||||
|
|
||||||
if ($watermarkimage = $this->files->find($settings_value['watermark_image'])) {
|
if ($watermarkimage = $this->files->find($settings_value['watermark_image'])) {
|
||||||
$watermark = WaterMark::make(app_storage_path() . '/files-module/local/' . $watermarkimage->path());
|
$watermark = WaterMark::make(app_storage_path() . '/files-module/local/' . $watermarkimage->path());
|
||||||
$image->insert($watermark, $settings_value['watermark_position']);
|
$image->insert($watermark, $settings_value['watermark_position']);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$v = "top";
|
$v = "top";
|
||||||
$h = "center";
|
$h = "center";
|
||||||
$w = $image->width() / 2;
|
$w = $image->width() / 2;
|
||||||
$h1 = $image->height() / 2;
|
$h1 = $image->height() / 2;
|
||||||
$font_size = $w / 20;
|
$font_size = $w / 20;
|
||||||
$image->text($settings_value['watermark_text'], $w, $h1, function ($font) use ($v, $h, $font_size) {
|
$image->text($settings_value['watermark_text'], $w, $h1, function ($font) use ($v, $h, $font_size) {
|
||||||
$font->file(public_path('Antonio-Bold.ttf'));
|
$font->file(public_path('Antonio-Bold.ttf'));
|
||||||
$font->size($font_size);
|
$font->size($font_size);
|
||||||
$font->align($h);
|
$font->align($h);
|
||||||
$font->valign($v);
|
$font->valign($v);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if ($key === "full") {
|
if ($key === "full") {
|
||||||
$fileName = $file->getAttributes()['name'];
|
$fileName = $file->getAttributes()['name'];
|
||||||
} else {
|
} else {
|
||||||
$fileName = 'md-' . $file->getAttributes()['name'];
|
$fileName = 'md-' . $file->getAttributes()['name'];
|
||||||
|
|
||||||
$this->createFile($this->request->get('folder'),$fileName,$image);
|
$this->createFile($this->request->get('folder'),$fileName,$image);
|
||||||
}
|
}
|
||||||
$image->save(app_storage_path() . '/files-module/local/images/' . $fileName);
|
$image->save(app_storage_path() . '/files-module/local/images/' . $fileName);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return $this->response->json($file->getAttributes());
|
return $this->response->json($file->getAttributes());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,15 +183,15 @@ class UploadController extends AdminController
|
|||||||
return response()->json(['status' => 'error']);
|
return response()->json(['status' => 'error']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createFile($folder, $filename, $image)
|
public function createFile($folder, $filename, $image = null)
|
||||||
{
|
{
|
||||||
$this->files->create([
|
$this->files->create([
|
||||||
'folder_id' => $folder,
|
'folder_id' => $folder,
|
||||||
'name' => $filename,
|
'name' => $filename,
|
||||||
'disk_id' => 1,
|
'disk_id' => 1,
|
||||||
'size' => $image->filesize(),
|
'size' => $image->filesize(),
|
||||||
'mime_type' => $image->mime,
|
'mime_type' => $image->mime,
|
||||||
'extension' => $image->extension,
|
'extension' => $image->extension,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -174,5 +174,23 @@ class DatabaseSeeder extends Seeder
|
|||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//Create Ads Documents Folder
|
||||||
|
if (!$this->folders->findBySlug('ads_documents')) {
|
||||||
|
$disk = $this->disks->findBySlug('local');
|
||||||
|
|
||||||
|
$this->folders->create([
|
||||||
|
'en' => [
|
||||||
|
'name' => 'Ads Documents',
|
||||||
|
'description' => 'A folder for Ads Documents.',
|
||||||
|
],
|
||||||
|
'slug' => 'ads_documents',
|
||||||
|
'disk' => $disk,
|
||||||
|
'allowed_types' => [
|
||||||
|
'pdf', 'doc', 'docx', 'xls', 'xlsx',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user