. */ namespace Fisharebest\Webtrees; /** * Defined in session.php * * @global Tree $WT_TREE */ global $WT_TREE; use Fisharebest\Webtrees\Controller\SimpleController; use Fisharebest\Webtrees\Functions\FunctionsPrint; define('WT_SCRIPT_NAME', 'inverselink.php'); require './includes/session.php'; $controller = new SimpleController; $controller ->restrictAccess(Auth::isEditor($WT_TREE)) ->setPageTitle(I18N::translate('Link to an existing media object')) ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL) ->addInlineJavascript('autocomplete();') ->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(array($mediaid, $WT_TREE->getTreeId())) ->fetchOne(); if ($title) { echo '', Filter::escapeHtml($title), ''; } else { echo '', $mediaid, ''; } } else { echo ''; echo ' ', FunctionsPrint::printFindMediaLink('mediaid', '1media'); echo '
'; if ($linkto == "person") { echo I18N::translate('Individual'), "'; if ($linktoid == "") { echo ' '; echo FunctionsPrint::printFindIndividualLink('linktopid'); } else { $record = Individual::getInstance($linktoid, $WT_TREE); echo $record->formatList('span', false, $record->getFullName()); } } if ($linkto == "family") { echo I18N::translate('Family'), ''; if ($linktoid == "") { echo ' '; echo FunctionsPrint::printFindFamilyLink('linktofamid'); } else { $record = Family::getInstance($linktoid, $WT_TREE); echo $record->formatList('span', false, $record->getFullName()); } } if ($linkto == "source") { echo I18N::translate('Source'), "'; if ($linktoid == "") { echo ' '; echo FunctionsPrint::printFindSourceLink('linktosid'); } 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 ''; }