. */ namespace Fisharebest\Webtrees; use Fisharebest\Webtrees\Controller\SimpleController; /** @global Tree $WT_TREE */ global $WT_TREE; require 'includes/session.php'; $controller = new SimpleController; $controller ->restrictAccess(Auth::isEditor($WT_TREE)) ->setPageTitle(I18N::translate('Link to an existing media object')) ->pageHeader(); //-- page parameters and checking $linktoid = Filter::get('linktoid', WT_REGEX_XREF); $mediaid = Filter::get('mediaid', WT_REGEX_XREF); $linkto = Filter::get('linkto', 'person|source|family|manage|repository|note'); $action = Filter::get('action', 'choose|update', 'choose'); // If GedFAct_assistant/_MEDIA/ installed ====================== if ($linkto == 'manage' && Module::getModuleByName('GEDFact_assistant')) { require WT_ROOT . WT_MODULES_DIR . 'GEDFact_assistant/_MEDIA/media_0_inverselink.php'; } else { //-- check for admin $paramok = true; if (!empty($linktoid)) { $paramok = GedcomRecord::getInstance($linktoid, $WT_TREE)->canShow(); } if ($action == 'choose' && $paramok) { echo '
'; echo ''; if (!empty($mediaid)) { echo ''; } if (!empty($linktoid)) { echo ''; } echo ''; echo ''; echo ''; echo ''; echo ''; } if (!isset($linktoid)) { $linktoid = ''; } echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'; echo I18N::translate('Link to an existing media object'); echo '
', I18N::translate('Media'), ''; if (!empty($mediaid)) { //-- Get the title of this existing Media item $title = Database::prepare("SELECT m_titl FROM `##media` where m_id=? AND m_file=?") ->execute([$mediaid, $WT_TREE->getTreeId()]) ->fetchOne(); if ($title) { echo '', Html::escape($title), ''; } else { echo '', $mediaid, ''; } } else { echo ''; echo '
'; if ($linkto == 'person') { echo I18N::translate('Individual'), ''; if ($linktoid == '') { echo ' '; } else { $record = Individual::getInstance($linktoid, $WT_TREE); echo $record->formatList('span', false, $record->getFullName()); } } if ($linkto == 'family') { echo I18N::translate('Family'), ''; if ($linktoid == '') { echo ' '; } else { $record = Family::getInstance($linktoid, $WT_TREE); echo $record->formatList('span', false, $record->getFullName()); } } if ($linkto == 'source') { echo I18N::translate('Source'), ''; if ($linktoid == '') { echo ' '; } else { $record = Source::getInstance($linktoid, $WT_TREE); echo $record->formatList('span', false, $record->getFullName()); } } if ($linkto == 'repository') { echo I18N::translate('Repository'), ''; if ($linktoid == '') { echo ''; } else { $record = Repository::getInstance($linktoid, $WT_TREE); echo $record->formatList('span', false, $record->getFullName()); } } if ($linkto == 'note') { echo I18N::translate('Shared note'), ''; if ($linktoid == '') { echo ''; } else { $record = Note::getInstance($linktoid, $WT_TREE); echo $record->formatList('span', false, $record->getFullName()); } } echo '
'; echo '
'; } elseif ($action == 'update' && $paramok) { $record = GedcomRecord::getInstance($linktoid, $WT_TREE); $record->createFact('1 OBJE @' . $mediaid . '@', true); $controller->addInlineJavascript('closePopupAndReloadParent();'); } echo ''; }