| Línea 33... |
Línea 33... |
| 33 |
use LeadersLinked\Mapper\ContentReactionMapper;
|
33 |
use LeadersLinked\Mapper\ContentReactionMapper;
|
| 34 |
use LeadersLinked\Model\ContentReaction;
|
34 |
use LeadersLinked\Model\ContentReaction;
|
| 35 |
use LeadersLinked\Mapper\KnowledgeAreaCategoryJobDescriptionMapper;
|
35 |
use LeadersLinked\Mapper\KnowledgeAreaCategoryJobDescriptionMapper;
|
| 36 |
use LeadersLinked\Mapper\OrganizationPositionMapper;
|
36 |
use LeadersLinked\Mapper\OrganizationPositionMapper;
|
| 37 |
use LeadersLinked\Model\User;
|
37 |
use LeadersLinked\Model\User;
|
| - |
|
38 |
use LeadersLinked\Library\Storage;
|
| Línea 38... |
Línea 39... |
| 38 |
|
39 |
|
| 39 |
class KnowledgeAreaController extends AbstractActionController
|
40 |
class KnowledgeAreaController extends AbstractActionController
|
| 40 |
{
|
41 |
{
|
| 41 |
/**
|
42 |
/**
|
| Línea 193... |
Línea 194... |
| 193 |
$category_ids = [$categoryFilter->id];
|
194 |
$category_ids = [$categoryFilter->id];
|
| 194 |
} else {
|
195 |
} else {
|
| 195 |
$category_ids = [];
|
196 |
$category_ids = [];
|
| 196 |
}
|
197 |
}
|
| 197 |
}
|
198 |
}
|
| - |
|
199 |
|
| - |
|
200 |
$storage = Storage::getInstance($this->config);
|
| - |
|
201 |
$path = $storage->getPathKnowledgeArea();
|
| Línea 198... |
Línea 202... |
| 198 |
|
202 |
|
| 199 |
$knowledgeAreaContentMapper = KnowledgeAreaContentMapper::getInstance($this->adapter);
|
203 |
$knowledgeAreaContentMapper = KnowledgeAreaContentMapper::getInstance($this->adapter);
|
| Línea 224... |
Línea 228... |
| 224 |
if (strlen($description) > 120) {
|
228 |
if (strlen($description) > 120) {
|
| 225 |
$description = substr($description, 0, 120) . '...';
|
229 |
$description = substr($description, 0, 120) . '...';
|
| 226 |
}
|
230 |
}
|
| Línea 227... |
Línea 231... |
| 227 |
|
231 |
|
| 228 |
$item = [
|
232 |
$item = [
|
| 229 |
'image' => $this->url()->fromRoute('storage', ['type' => 'knowledge-area', 'code' => $record->uuid, 'filename' => $record->image],['force_canonical' => true]),
|
233 |
'image' => $storage->getGenericImage($path, $record->uuid, $record->image),
|
| 230 |
'title' => $record->title,
|
234 |
'title' => $record->title,
|
| 231 |
'description' => $description,
|
235 |
'description' => $description,
|
| 232 |
'category' => $categories[$record->category_id]['name'],
|
236 |
'category' => $categories[$record->category_id]['name'],
|
| Línea 344... |
Línea 348... |
| 344 |
|
348 |
|
| 345 |
$knowledgeAreaContentMapper = KnowledgeAreaContentMapper::getInstance($this->adapter);
|
349 |
$knowledgeAreaContentMapper = KnowledgeAreaContentMapper::getInstance($this->adapter);
|
| 346 |
if ($knowledgeAreaContentMapper->insert($knowledgeAreaContent)) {
|
350 |
if ($knowledgeAreaContentMapper->insert($knowledgeAreaContent)) {
|
| Línea 347... |
Línea 351... |
| 347 |
$knowledgeAreaContent = $knowledgeAreaContentMapper->fetchOne($knowledgeAreaContent->id);
|
351 |
$knowledgeAreaContent = $knowledgeAreaContentMapper->fetchOne($knowledgeAreaContent->id);
|
| 348 |
|
352 |
|
| Línea 349... |
Línea -... |
| 349 |
$target_size = $this->config['leaderslinked.image_sizes.knowledge_area'];
|
- |
|
| 350 |
list($target_width, $target_height) = explode('x', $target_size);
|
353 |
//$target_size = $this->config['leaderslinked.image_sizes.knowledge_area'];
|
| 351 |
|
354 |
//list($target_width, $target_height) = explode('x', $target_size);
|
| 352 |
|
- |
|
| - |
|
355 |
|
| Línea 353... |
Línea 356... |
| 353 |
$target_path = $this->config['leaderslinked.fullpath.knowledge_area'] . $knowledgeAreaContent->uuid;
|
356 |
|
| Línea 354... |
Línea 357... |
| 354 |
if (!file_exists($target_path)) {
|
357 |
$image = Image::getInstance($this->config);
|
| 355 |
mkdir($target_path, 0755, true);
|
358 |
$target_path = $image->getStorage()->getPathKnowledgeArea();
|
| 356 |
}
|
359 |
|
| 357 |
|
360 |
|
| - |
|
361 |
|
| Línea 358... |
Línea -... |
| 358 |
|
- |
|
| 359 |
$files = $this->getRequest()->getFiles()->toArray();
|
- |
|
| 360 |
|
- |
|
| 361 |
|
362 |
$files = $this->getRequest()->getFiles()->toArray();
|
| 362 |
if (isset($files['image']) && empty($files['image']['error'])) {
|
363 |
|
| 363 |
$tmp_filename = $files['image']['tmp_name'];
|
364 |
|
| 364 |
$filename = explode('.', $files['image']['name']);
|
365 |
if (isset($files['image']) && empty($files['image']['error'])) {
|
| 365 |
$filename = Functions::normalizeString(uniqid() . '-' . $filename[0] . '.png');
|
366 |
$tmp_filename = $files['image']['tmp_name'];
|
| Línea 366... |
Línea 367... |
| 366 |
|
367 |
$filename = explode('.', $files['image']['name']);
|
| 367 |
//$crop_to_dimensions = true;
|
368 |
$filename = Functions::normalizeString(uniqid() . '-' . $filename[0] . '.png');
|
| 368 |
|
369 |
$unlink_source = true;
|
| 369 |
if(Image::uploadFile($tmp_filename, $target_path, $filename)) {
|
- |
|
| 370 |
// if (Image::uploadImage($tmp_filename, $target_path, $filename, $target_width, $target_height, $crop_to_dimensions)) {
|
370 |
|
| 371 |
$knowledgeAreaContent->image = $filename;
|
371 |
if($image->uploadImageRaw($tmp_filename, $target_path, $knowledgeAreaCategory->uuid, $filename, $unlink_source)) {
|
| 372 |
$knowledgeAreaContentMapper->update($knowledgeAreaContent);
|
372 |
$knowledgeAreaContent->image = $filename;
|
| 373 |
}
|
373 |
$knowledgeAreaContentMapper->update($knowledgeAreaContent);
|
| 374 |
}
|
374 |
}
|
| 375 |
|
375 |
}
|
| 376 |
if (isset($files['attachment']) && empty($files['attachment']['error'])) {
|
376 |
|
| Línea 473... |
Línea 473... |
| 473 |
|
473 |
|
| 474 |
$result = $knowledgeAreaContentMapper->delete($knowledgeAreaContent);
|
474 |
$result = $knowledgeAreaContentMapper->delete($knowledgeAreaContent);
|
| 475 |
if ($result) {
|
475 |
if ($result) {
|
| Línea -... |
Línea 476... |
| - |
|
476 |
$this->logger->info('Se borro el cotenido : ' . $knowledgeAreaContent->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
|
| - |
|
477 |
|
| - |
|
478 |
|
| - |
|
479 |
$storage = Storage::getInstance($this->config);
|
| - |
|
480 |
$target_path = $storage->getPathKnowledgeArea();
|
| - |
|
481 |
|
| - |
|
482 |
|
| - |
|
483 |
if($knowledgeAreaContent->attachment) {
|
| - |
|
484 |
$storage->deleteFile($target_path, $knowledgeAreaContent->uuid, $knowledgeAreaContent->attachment);
|
| - |
|
485 |
}
|
| - |
|
486 |
|
| 476 |
$this->logger->info('Se borro el cotenido : ' . $knowledgeAreaContent->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
|
487 |
|
| 477 |
|
- |
|
| 478 |
if ($knowledgeAreaContent->image) {
|
488 |
|
| 479 |
|
- |
|
| 480 |
$target_path = $this->config['leaderslinked.fullpath.knowledge_area'] . $knowledgeAreaContent->uuid;
|
- |
|
| 481 |
if (file_exists($target_path)) {
|
- |
|
| 482 |
Functions::rmDirRecursive($target_path);
|
489 |
if ($knowledgeAreaContent->image) {
|
| Línea 483... |
Línea 490... |
| 483 |
}
|
490 |
$storage->deleteFile($target_path, $knowledgeAreaContent->uuid, $knowledgeAreaContent->image);
|
| 484 |
}
|
491 |
}
|
| 485 |
|
492 |
|
| Línea 629... |
Línea 636... |
| 629 |
$knowledgeAreaContent->description = $dataPost['description'];
|
636 |
$knowledgeAreaContent->description = $dataPost['description'];
|
| Línea 630... |
Línea 637... |
| 630 |
|
637 |
|
| Línea 631... |
Línea 638... |
| 631 |
|
638 |
|
| 632 |
if ($knowledgeAreaContentMapper->update($knowledgeAreaContent)) {
|
639 |
if ($knowledgeAreaContentMapper->update($knowledgeAreaContent)) {
|
| 633 |
|
- |
|
| Línea 634... |
Línea -... |
| 634 |
$target_size = $this->config['leaderslinked.image_sizes.knowledge_area'];
|
- |
|
| 635 |
list($target_width, $target_height) = explode('x', $target_size);
|
- |
|
| 636 |
|
- |
|
| 637 |
|
- |
|
| Línea -... |
Línea 640... |
| - |
|
640 |
|
| - |
|
641 |
//$target_size = $this->config['leaderslinked.image_sizes.knowledge_area'];
|
| Línea 638... |
Línea 642... |
| 638 |
$target_path = $this->config['leaderslinked.fullpath.knowledge_area'] . $knowledgeAreaContent->uuid;
|
642 |
//list($target_width, $target_height) = explode('x', $target_size);
|
| Línea 639... |
Línea 643... |
| 639 |
if (!file_exists($target_path)) {
|
643 |
|
| Línea -... |
Línea 644... |
| - |
|
644 |
|
| 640 |
mkdir($target_path, 0755, true);
|
645 |
$image = Image::getInstance($this->config);
|
| 641 |
}
|
646 |
$target_path = $image->getStorage()->getPathKnowledgeArea();
|
| 642 |
|
647 |
|
| Línea -... |
Línea 648... |
| - |
|
648 |
$files = $this->getRequest()->getFiles()->toArray();
|
| 643 |
|
649 |
|
| 644 |
$files = $this->getRequest()->getFiles()->toArray();
|
650 |
|
| 645 |
|
651 |
if (isset($files['image']) && empty($files['image']['error'])) {
|
| 646 |
|
- |
|
| 647 |
if (isset($files['image']) && empty($files['image']['error'])) {
|
652 |
|
| 648 |
|
653 |
|
| 649 |
if ($knowledgeAreaContent->image) {
|
- |
|
| 650 |
@unlink($target_path . DIRECTORY_SEPARATOR . $knowledgeAreaContent->image);
|
654 |
if ($knowledgeAreaContent->image) {
|
| 651 |
}
|
655 |
$image->getStorage()->deleteFile($target_path, $knowledgeAreaContent->uuid, $knowledgeAreaContent->image);
|
| 652 |
|
656 |
}
|
| 653 |
$tmp_filename = $files['image']['tmp_name'];
|
657 |
|
| 654 |
$filename = explode('.', $files['image']['name']);
|
658 |
|
| Línea 655... |
Línea 659... |
| 655 |
$filename = Functions::normalizeString(uniqid() . '-' . $filename[0] . '.png');
|
659 |
$tmp_filename = $files['image']['tmp_name'];
|
| 656 |
|
660 |
$filename = explode('.', $files['image']['name']);
|
| 657 |
// $crop_to_dimensions = true;
|
661 |
$filename = Functions::normalizeString(uniqid() . '-' . $filename[0] . '.png');
|
| 658 |
|
- |
|
| 659 |
if(Image::uploadFile($tmp_filename, $target_path, $filename)) {
|
662 |
$unlink_source = true;
|
| 660 |
// if (Image::uploadImage($tmp_filename, $target_path, $filename, $target_width, $target_height, $crop_to_dimensions)) {
|
663 |
|
| 661 |
$knowledgeAreaContent->image = $filename;
|
664 |
if($image->uploadImageRaw($tmp_filename, $target_path, $knowledgeAreaCategory->uuid, $filename, $unlink_source)) {
|
| 662 |
$knowledgeAreaContentMapper->update($knowledgeAreaContent);
|
665 |
$knowledgeAreaContent->image = $filename;
|
| Línea 663... |
Línea -... |
| 663 |
}
|
- |
|
| 664 |
}
|
666 |
$knowledgeAreaContentMapper->update($knowledgeAreaContent);
|
| 665 |
|
667 |
}
|
| 666 |
if (isset($files['attachment']) && empty($files['attachment']['error'])) {
|
668 |
}
|
| 667 |
$tmp_filename = $files['attachment']['tmp_name'];
|
669 |
|
| 668 |
$filename = Functions::normalizeString($files['attachment']['name']);
|
670 |
if (isset($files['attachment']) && empty($files['attachment']['error'])) {
|
| Línea 772... |
Línea 774... |
| 772 |
|
774 |
|
| 773 |
$contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
|
775 |
$contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
|
| Línea -... |
Línea 776... |
| - |
|
776 |
$contentReaction = $contentReactionMapper->fetchOneByKnowledgeAreaIdAndUserId($knowledgeAreaContent->id, $currentUser->id);
|
| - |
|
777 |
|
| Línea 774... |
Línea 778... |
| 774 |
$contentReaction = $contentReactionMapper->fetchOneByKnowledgeAreaIdAndUserId($knowledgeAreaContent->id, $currentUser->id);
|
778 |
|
| 775 |
|
779 |
$storage = Storage::getInstance($this->config);
|
| 776 |
|
780 |
$path = $storage->getPathKnowledgeArea();
|
| 777 |
|
781 |
|
| 778 |
return new JsonModel([
|
782 |
return new JsonModel([
|
| 779 |
'success' => true,
|
783 |
'success' => true,
|
| 780 |
'data' => [
|
784 |
'data' => [
|
| 781 |
'category' => $knowledgeAreaCategory->name,
|
785 |
'category' => $knowledgeAreaCategory->name,
|
| 782 |
'title' => $knowledgeAreaContent->title,
|
786 |
'title' => $knowledgeAreaContent->title,
|
| 783 |
'description' => $knowledgeAreaContent->description,
|
787 |
'description' => $knowledgeAreaContent->description,
|
| 784 |
'link' => $knowledgeAreaContent->link,
|
788 |
'link' => $knowledgeAreaContent->link,
|
| 785 |
'image' => $this->url()->fromRoute('storage', ['type' => 'knowledge-area', 'code' => $knowledgeAreaContent->uuid, 'filename' => $knowledgeAreaContent->image],['force_canonical' => true]),
|
789 |
'image' => $storage->getGenericImage($path, $knowledgeAreaContent->uuid, $knowledgeAreaContent->image),
|
| 786 |
'attachment' => $knowledgeAreaContent->attachment ? $this->url()->fromRoute('storage', ['type' => 'knowledge-area', 'code' => $knowledgeAreaContent->uuid, 'filename' => $knowledgeAreaContent->attachment],['force_canonical' => true]) : '',
|
790 |
'attachment' => $knowledgeAreaContent->attachment ? $storage->getGenericFile($path, $knowledgeAreaContent->uuid, $knowledgeAreaContent->attachment) : '',
|
| 787 |
'reaction' => $contentReaction ? $contentReaction->reaction : '',
|
791 |
'reaction' => $contentReaction ? $contentReaction->reaction : '',
|
| Línea 829... |
Línea 833... |
| 829 |
|
833 |
|
| Línea 830... |
Línea 834... |
| 830 |
$userMapper = UserMapper::getInstance($this->adapter);
|
834 |
$userMapper = UserMapper::getInstance($this->adapter);
|
| Línea -... |
Línea 835... |
| - |
|
835 |
|
| - |
|
836 |
$items = [];
|
| - |
|
837 |
|
| 831 |
|
838 |
$storage = Storage::getInstance($this->config);
|
| 832 |
$items = [];
|
839 |
$path = $storage->getPathKnowledgeArea();
|
| Línea 833... |
Línea 840... |
| 833 |
|
840 |
|
| 834 |
$contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
|
841 |
$contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
|
| Línea 841... |
Línea 848... |
| 841 |
|
848 |
|
| 842 |
array_push($items, [
|
849 |
array_push($items, [
|
| 843 |
'first_name' => $user->first_name,
|
850 |
'first_name' => $user->first_name,
|
| 844 |
'last_name' => $user->last_name,
|
851 |
'last_name' => $user->last_name,
|
| 845 |
'email' => $user->email,
|
852 |
'email' => $user->email,
|
| 846 |
'image' => $this->url()->fromRoute('storage', ['type' => 'user', 'code' => $user->uuid, 'filename' => $user->image], ['force_canonical' => true]),
|
853 |
'image' => $storage->getGenericImage($path, $user->uuid, $user->image),
|
| 847 |
'reaction' => $record->reaction,
|
854 |
'reaction' => $record->reaction,
|
| 848 |
]);
|
855 |
]);
|
| 849 |
}
|
856 |
}
|
| Línea 1226... |
Línea 1233... |
| 1226 |
$record = $commentMapper->fetchOne($comment_id);
|
1233 |
$record = $commentMapper->fetchOne($comment_id);
|
| Línea 1227... |
Línea 1234... |
| 1227 |
|
1234 |
|
| 1228 |
$knowledgeAreaContentMapper = KnowledgeAreaContentMapper::getInstance($this->adapter);
|
1235 |
$knowledgeAreaContentMapper = KnowledgeAreaContentMapper::getInstance($this->adapter);
|
| Línea -... |
Línea 1236... |
| - |
|
1236 |
$knowledgeAreaContent = $knowledgeAreaContentMapper->fetchOne($record->knowledge_area_id);
|
| - |
|
1237 |
|
| 1229 |
$knowledgeAreaContent = $knowledgeAreaContentMapper->fetchOne($record->knowledge_area_id);
|
1238 |
|
| - |
|
1239 |
|
| - |
|
1240 |
if ($record) {
|
| - |
|
1241 |
$storage = Storage::getInstance($this->config);
|
| 1230 |
|
1242 |
|
| Línea 1231... |
Línea 1243... |
| 1231 |
if ($record) {
|
1243 |
|
| Línea 1232... |
Línea 1244... |
| 1232 |
$userMapper = UserMapper::getInstance($this->adapter);
|
1244 |
$userMapper = UserMapper::getInstance($this->adapter);
|
| 1233 |
|
1245 |
|
| 1234 |
$user = $userMapper->fetchOne($record->user_id);
|
1246 |
$user = $userMapper->fetchOne($record->user_id);
|
| 1235 |
|
1247 |
|
| 1236 |
$item['unique'] = uniqid();
|
1248 |
$item['unique'] = uniqid();
|
| 1237 |
$item['user_image'] = $this->url()->fromRoute('storage', ['type' => 'user', 'code' => $user->uuid, 'filename' => $user->image],['force_canonical' => true]);
|
1249 |
$item['user_image'] = $storage->getUserImage($user);
|
| 1238 |
$item['user_url'] = $this->url()->fromRoute('profile/view', ['id' => $user->uuid]);
|
1250 |
$item['user_url'] = $this->url()->fromRoute('profile/view', ['id' => $user->uuid]);
|