<?php
namespace App\Smarty\Functions; class DocumentLabel { static public function create($params, $smarty) { $defaultOutput = ''; if ($params['default']) { $defaultOutput = $params['default']; } if (is_object($params['ref']) and get_class($params['ref']) == 'Entity\Document') { $document = $params['ref']; } elseif (is_numeric($params['ref']) and $params['ref'] > 0) { $document = \Entity\Document::select($params['ref']); if (!$document->recordExists()) { return $defaultOutput; } } else { return $defaultOutput; } if ($params['assign']) { $smarty->assign($params['assign'], $document); return ''; } if (!$params['format']) { if ($params['hideLink']) { return "#{$document->getId()}"; } else{ $documentLabel = sprintf("<span class=\"remoteLoadLink\" onclick=\"RemoteLoad.load(this, MVC.appUrl('RemoteData/InfoBox', '%s', { 'id': '%s'}), null); return false;\">%s</span>", 'document', $document->getId(), ($document->getId() ? "#{$document->getId()}" : $defaultOutput)); return $documentLabel; } } return ''; } }