Skip to content

Commit

Permalink
moveEntryOverwriteTarget debugged
Browse files Browse the repository at this point in the history
  • Loading branch information
SourcePot committed Nov 4, 2024
1 parent a757387 commit 08db4c5
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 69 deletions.
4 changes: 3 additions & 1 deletion src/php/AdminApps/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,12 @@ public function run(array|bool $arr=TRUE):array{
private function settingsOverviewHtml():string
{
$template=array();
$template['Logger']=array('selector'=>array('app'=>__CLASS__,'Source'=>'logger'),'description'=>'Here you find all the logs.');
$template['Logger']=array('selector'=>array('app'=>__CLASS__,'Source'=>'logger'),'description'=>'Here you will find all the logs.');
$template['Logger errors']=array('selector'=>array('app'=>__CLASS__,'Source'=>'logger','Group'=>'error'),'description'=>'Error logs can be found here.');
$template['Job processing timimg']=array('selector'=>array('app'=>__CLASS__,'Source'=>'settings','Group'=>'Job processing','Folder'=>'All jobs','Name'=>'Timing'),'description'=>'Here you can access the timing of the job processing. Use "✎" (Edit) → Content to change the timing of a specific job');
$template['Entry presentation']=array('selector'=>array('app'=>__CLASS__,'Source'=>'settings','Group'=>'Presentation'),'description'=>'Here you can adjust the entry presentation which is based on the Class and Method used to present the entry. The method presemnting an entry is typically run() or for javascript calls presentEntry().');
$template['Definitions']=array('selector'=>array('app'=>__CLASS__,'Source'=>'definitions','Group'=>'Templates'),'description'=>'Here you can adjust the entry definitions.');
$template['Remote client definitions']=array('selector'=>array('app'=>__CLASS__,'Source'=>'remoteclient','EntryId'=>'%_definition'),'description'=>'Here you can delete the remote client definitions. It will be renewed when the client is connected');
// create html
$matrix=array();
foreach($template as $key=>$def){
Expand Down
55 changes: 15 additions & 40 deletions src/php/Foundation/DataExplorer.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,50 +41,18 @@ class DataExplorer{
),
);

private $tags=array('run'=>array('tag'=>'button','element-content'=>'✖','keep-element-content'=>TRUE,'style'=>array('font-size'=>'24px','color'=>'#fff;','background-color'=>'#0a0'),'showEditMode'=>TRUE,'type'=>'Cntr','Read'=>'ALL_CONTENTADMIN_R','title'=>'Close canvas editor'),
'edit'=>array('tag'=>'button','element-content'=>'✎','keep-element-content'=>TRUE,'style'=>array('font-size'=>'24px','color'=>'#fff','background-color'=>'#a00'),'showEditMode'=>FALSE,'type'=>'Cntr','Read'=>'ALL_CONTENTADMIN_R','title'=>'Edit canvas'),
private $tags=array('run'=>array('tag'=>'button','element-content'=>'✖','keep-element-content'=>TRUE,'style'=>array('font-size'=>'24px','color'=>'#fff;','background-color'=>'#0a0'),'showEditMode'=>TRUE,'type'=>'Control','Read'=>'ALL_CONTENTADMIN_R','title'=>'Close canvas editor'),
'edit'=>array('tag'=>'button','element-content'=>'✎','keep-element-content'=>TRUE,'style'=>array('font-size'=>'24px','color'=>'#fff','background-color'=>'#a00'),'showEditMode'=>FALSE,'type'=>'Control','Read'=>'ALL_CONTENTADMIN_R','title'=>'Edit canvas'),
'⚙'=>array('tag'=>'button','element-content'=>'⚙','keep-element-content'=>TRUE,'class'=>'canvas-processor','showEditMode'=>TRUE,'type'=>'Elements','Read'=>'ALL_CONTENTADMIN_R','title'=>'Step processing'),
'Select'=>array('tag'=>'button','element-content'=>'Select','keep-element-content'=>TRUE,'class'=>'canvas-std','showEditMode'=>TRUE,'type'=>'Elements','Read'=>'ALL_CONTENTADMIN_R','title'=>'Database view'),
'Text'=>array('tag'=>'div','element-content'=>'Text','keep-element-content'=>TRUE,'class'=>'canvas-text','showEditMode'=>TRUE,'type'=>'Elements','Read'=>'ALL_CONTENTADMIN_R','title'=>'Text box'),
//
'⭠'=>array('tag'=>'div','element-content'=>'⭠','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Connectors','Read'=>'ALL_CONTENTADMIN_R'),
'⭡'=>array('tag'=>'div','element-content'=>'⭡','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Connectors','Read'=>'ALL_CONTENTADMIN_R'),
'⭢'=>array('tag'=>'div','element-content'=>'⭢','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Connectors','Read'=>'ALL_CONTENTADMIN_R'),
'⭣'=>array('tag'=>'div','element-content'=>'⭣','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Connectors','Read'=>'ALL_CONTENTADMIN_R'),
'⭤'=>array('tag'=>'div','element-content'=>'⭤','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Connectors','Read'=>'ALL_CONTENTADMIN_R'),
'⭥'=>array('tag'=>'div','element-content'=>'⭥','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Connectors','Read'=>'ALL_CONTENTADMIN_R'),
'⭦'=>array('tag'=>'div','element-content'=>'⭦','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Connectors','Read'=>'ALL_CONTENTADMIN_R'),
'⭧'=>array('tag'=>'div','element-content'=>'⭧','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Connectors','Read'=>'ALL_CONTENTADMIN_R'),
'⭨'=>array('tag'=>'div','element-content'=>'⭨','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Connectors','Read'=>'ALL_CONTENTADMIN_R'),
'⭩'=>array('tag'=>'div','element-content'=>'⭩','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Connectors','Read'=>'ALL_CONTENTADMIN_R'),
'⭪'=>array('tag'=>'div','element-content'=>'⭪','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Connectors','Read'=>'ALL_CONTENTADMIN_R'),
'⭫'=>array('tag'=>'div','element-content'=>'⭫','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Connectors','Read'=>'ALL_CONTENTADMIN_R'),
'⭬'=>array('tag'=>'div','element-content'=>'⭬','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Connectors','Read'=>'ALL_CONTENTADMIN_R'),
'⭭'=>array('tag'=>'div','element-content'=>'⭭','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Connectors','Read'=>'ALL_CONTENTADMIN_R'),
'&#10137'=>array('tag'=>'div','element-content'=>'&#10137','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Connectors','Read'=>'ALL_CONTENTADMIN_R'),
'&#10154'=>array('tag'=>'div','element-content'=>'&#10154','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Connectors','Read'=>'ALL_CONTENTADMIN_R'),
'&#10140'=>array('tag'=>'div','element-content'=>'&#10140','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Connectors','Read'=>'ALL_CONTENTADMIN_R'),
//
'⮠'=>array('tag'=>'div','element-content'=>'⮠','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Misc','Read'=>'ALL_CONTENTADMIN_R'),
'⮡'=>array('tag'=>'div','element-content'=>'⮡','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Misc','Read'=>'ALL_CONTENTADMIN_R'),
'⮢'=>array('tag'=>'div','element-content'=>'⮢','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Misc','Read'=>'ALL_CONTENTADMIN_R'),
'⮣'=>array('tag'=>'div','element-content'=>'⮣','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Misc','Read'=>'ALL_CONTENTADMIN_R'),
'⮤'=>array('tag'=>'div','element-content'=>'⮤','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Misc','Read'=>'ALL_CONTENTADMIN_R'),
'⮥'=>array('tag'=>'div','element-content'=>'⮥','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Misc','Read'=>'ALL_CONTENTADMIN_R'),
'⮦'=>array('tag'=>'div','element-content'=>'⮦','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Misc','Read'=>'ALL_CONTENTADMIN_R'),
'⮧'=>array('tag'=>'div','element-content'=>'⮧','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Misc','Read'=>'ALL_CONTENTADMIN_R'),
'|'=>array('tag'=>'div','element-content'=>'|','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Misc','Read'=>'ALL_CONTENTADMIN_R'),
'&#9601'=>array('tag'=>'div','element-content'=>'&#9601','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Misc','Read'=>'ALL_CONTENTADMIN_R'),
'&#9675'=>array('tag'=>'div','element-content'=>'&#9675','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Misc','Read'=>'ALL_CONTENTADMIN_R'),
'&#9679'=>array('tag'=>'div','element-content'=>'&#9679','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Misc','Read'=>'ALL_CONTENTADMIN_R'),
'&#9711'=>array('tag'=>'div','element-content'=>'&#9711','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Misc','Read'=>'ALL_CONTENTADMIN_R'),
'&#9476'=>array('tag'=>'div','element-content'=>'&#9476','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Misc','Read'=>'ALL_CONTENTADMIN_R'),
'&#9482'=>array('tag'=>'div','element-content'=>'&#9482','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Misc','Read'=>'ALL_CONTENTADMIN_R'),
'&#9552'=>array('tag'=>'div','element-content'=>'&#9552','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Misc','Read'=>'ALL_CONTENTADMIN_R'),
'&#9553'=>array('tag'=>'div','element-content'=>'&#9553','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Misc','Read'=>'ALL_CONTENTADMIN_R'),
'⮽'=>array('tag'=>'div','element-content'=>'⮽','keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>'Misc','Read'=>'ALL_CONTENTADMIN_R'),
);

private $graphicElemnts=array('Connectors'=>array('❘','⟵','⟶','⟷','←','↑','→','↓','↔','↕','↖','↗','↘','↙','↩','↪','↺','↻','⇵','➜'),
'Symbols'=>array('♪','♥','♦','♣','♯','♺','⚑','⚠','⚝','✂','✈','✉','✎','✔','✘','✚','❑','❖'),
'Math'=>array('∅','∇','∄','∋','∈','∉','∑','∏','∐','∘','√','∝','∞','∟','∡','∩','∫','≈','≪','≫','⋘','⋙','≡'),
);

private $processorOptions=array();

public function __construct(array $oc)
Expand All @@ -102,6 +70,11 @@ public function __construct(array $oc)
public function init()
{
$this->entryTemplate=$this->oc['SourcePot\Datapool\Foundation\Database']->getEntryTemplateCreateTable($this->entryTable,__CLASS__);
foreach($this->graphicElemnts as $category=>$htmlEntities){
foreach($htmlEntities as $htmlEntity){
$this->tags[$htmlEntity]=array('tag'=>'div','element-content'=>$htmlEntity,'keep-element-content'=>TRUE,'class'=>'canvas-symbol','showEditMode'=>TRUE,'type'=>$category,'Read'=>'ALL_CONTENTADMIN_R');
}
}
$this->completeDefintion();
}

Expand Down Expand Up @@ -277,7 +250,9 @@ private function getCntrHtml(string $callingClass):array
$matrix[$tag['type']]['Btn'].=$this->oc['SourcePot\Datapool\Foundation\Element']->element($btn);
}
$htmlArr=array('cntr'=>'','processor'=>'');
$htmlArr['cntr']=$this->oc['SourcePot\Datapool\Tools\HTMLbuilder']->table(array('matrix'=>$matrix,'keep-element-content'=>TRUE,'hideHeader'=>TRUE,'caption'=>'Canvas'));
$tableArr=array('matrix'=>$matrix,'keep-element-content'=>TRUE,'hideHeader'=>TRUE,'caption'=>'Canvas');
if ($isEditMode){$tableArr['style']=array('min-width'=>'550px');}
$htmlArr['cntr']=$this->oc['SourcePot\Datapool\Tools\HTMLbuilder']->table($tableArr);
$selectedCanvasElement=$this->oc['SourcePot\Datapool\Tools\NetworkTools']->getPageStateByKey(__CLASS__,'selectedCanvasElement');
$canvasElement=$this->oc['SourcePot\Datapool\Foundation\Database']->entryById($selectedCanvasElement);
if ($isEditMode){
Expand Down
44 changes: 19 additions & 25 deletions src/php/Foundation/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -942,43 +942,37 @@ public function moveEntryOverwriteTarget($sourceEntry,$targetSelector,$isSystemC
}
} else {
// move or copy attached file to target
$fileRenameSuccess=TRUE;
$context['fileError']=FALSE;
$sourceFile=$this->oc['SourcePot\Datapool\Foundation\Filespace']->selector2file($sourceEntry);
$targetFile=$this->oc['SourcePot\Datapool\Foundation\Filespace']->selector2file($targetEntry);
if (is_file($sourceFile) && !$isTestRun){
if ($keepSource){
$fileRenameSuccess=@copy($sourceFile,$targetFile);
$context['copyAttachedFile']=TRUE;
} else {
$fileRenameSuccess=@rename($sourceFile,$targetFile);
$context['movedAttachedFile']=TRUE;
try{
$this->oc['SourcePot\Datapool\Foundation\Filespace']->addStatistic('inserted files',intval(copy($sourceFile,$targetFile)));
} catch(\Exception $e){
$context['fileError']=$e->getMessage();
}
}
// create target entry
if ($fileRenameSuccess){
if (!$isTestRun){
if (!$keepSource){
$this->deleteEntries(array('Source'=>$sourceEntry['Source'],'EntryId'=>$sourceEntry['EntryId']),$isSystemCall);
}
$targetEntry=$this->updateEntry($targetEntry,$isSystemCall,FALSE,FALSE,$targetFile);
$context['attachedFileProcessed']=TRUE;
}
// update entry and delete source file if source is not kept
if ($isTestRun){
$targetEntry=$sourceEntry;
} else if ($context['fileError']){
$context['Name']=$targetEntry['Name'];
$context['sourceFile']=$sourceFile;
$context['action']=($keepSource)?'to copy':'to move';
$this->oc['logger']->log('notice','Failed {action} file "{sourceFile}" with "{fileError}". The entry "{Name}" was not updated.',$context);
} else {
// copying or renaming of attached file failed
if ($isTestRun){
$targetEntry=$sourceEntry;
$targetEntry=$this->updateEntry($targetEntry,$isSystemCall);
if ($keepSource){
$context['copyAttachedFile']=TRUE;
} else {
$targetEntry=$this->updateEntry($sourceEntry,$isSystemCall);
$context['movedAttachedFile']=TRUE;
$this->deleteEntries(array('Source'=>$sourceEntry['Source'],'EntryId'=>$sourceEntry['EntryId']),$isSystemCall);
}
}
}
} else {
// no write access
if ($isTestRun){
$targetEntry=$sourceEntry;
} else {
$targetEntry=$this->updateEntry($sourceEntry,TRUE);
}
$targetEntry=$sourceEntry;
$context['noWriteAccess']=TRUE;
}
$targetEntry[__FUNCTION__]=$context;
Expand Down
6 changes: 4 additions & 2 deletions src/php/Tools/FileContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ public function enrichEntry(array $entry):array
if (isset($entry['Date'])){
$pageTimeZone=$this->oc['SourcePot\Datapool\Foundation\Backbone']->getSettings('pageTimeZone');
$dateWebPageTimeZone=\DateTime::createFromFormat('Y-m-d H:i:s',$entry['Date'],new \DateTimeZone(\SourcePot\Datapool\Root::DB_TIMEZONE));
$dateWebPageTimeZone->setTimeZone(new \DateTimeZone($pageTimeZone));
$entry['Date ('.$pageTimeZone.')']=$dateWebPageTimeZone->format('Y-m-d H:i:s');
if ($dateWebPageTimeZone){
$dateWebPageTimeZone->setTimeZone(new \DateTimeZone($pageTimeZone));
$entry['Date ('.$pageTimeZone.')']=$dateWebPageTimeZone->format('Y-m-d H:i:s');
}
}
$entry['currentUserId']=$currentUser['EntryId'];
$entry['currentUser']=$currentUser['Content']['Contact details']['First name'].' '.$currentUser['Content']['Contact details']['Family name'];
Expand Down
2 changes: 1 addition & 1 deletion src/php/Tools/PdfTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ public function attachments2arrSmalot($file,array $entry=array()):array

$pdfParser= new \Smalot\PdfParser\Parser();
$pdfContent=$pdfContent = file_get_contents($file);
$pdfParsed = $pdfParser->parseContent($pdfContent);
try {
$context['attachmentsFailed']=array();
$pdfParsed = $pdfParser->parseContent($pdfContent);
$filespecIndex=0;
$filespecs = $pdfParsed->getObjectsByType('Filespec');
foreach ($filespecs as $filespec){
Expand Down

0 comments on commit 08db4c5

Please sign in to comment.