<?php
namespace App\Smarty\Functions; class ImportedDocumentLabel { static public function create($params, $smarty) { $defaultOutput = ''; if ($params['default']) { $defaultOutput = $params['default']; } if (is_object($params['ref']) and get_class($params['ref']) == 'Entity\ImportedDocument') { $importedDocument = $params['ref']; } elseif (is_numeric($params['ref']) and $params['ref'] > 0) { $importedDocument = \Entity\ImportedDocument::select($params['ref']); if (!$importedDocument->recordExists()) { return $defaultOutput; } } else { return $defaultOutput; } if ($params['assign']) { $smarty->assign($params['assign'], $importedDocument); return ''; } if (!$params['format']) { if ($params['hideLink']) { return "#{$importedDocument->getId()}"; } else{ $importedDocLabel = sprintf( "<span class=\"remoteLoadLink\" onclick=\"RemoteLoad.loadEntity(this, '%s', '%s');\">%s</span>" , 'importedDocument' , $importedDocument->getId() , ($importedDocument->getId() ? "#{$importedDocument->getId()}" : $defaultOutput) ); return $importedDocLabel; } } } }