Ejemplo n.º 1
0
function media_object_info(WT_Media $media)
{
    $xref = $media->getXref();
    $gedcom = WT_Tree::getNameFromId($media->getGedcomId());
    $name = $media->getFullName();
    $html = '<b>' . $name . '</b>' . '<div><i>' . WT_Filter::escapeHtml($media->getNote()) . '</i></div>' . '<br>' . '<a href="' . $media->getHtmlUrl() . '">' . WT_I18N::translate('View') . '</a>';
    $html .= ' - ' . '<a onclick="window.open(\'addmedia.php?action=editmedia&amp;pid=' . $xref . '&ged=' . WT_Filter::escapeJs($gedcom) . '\', \'_blank\', edit_window_specs)" href="#">' . WT_I18N::Translate('Edit') . '</a>' . ' - ' . '<a onclick="return delete_media(\'' . WT_Filter::escapeJs(WT_I18N::translate('Are you sure you want to delete “%s”?', strip_tags($media->getFullName()))) . '\', \'' . $media->getXref() . '\', \'' . WT_Filter::escapeJs($gedcom) . '\');" href="#">' . WT_I18N::Translate('Delete') . '</a>' . ' - ';
    if (array_key_exists('GEDFact_assistant', WT_Module::getActiveModules())) {
        $html .= '<a onclick="return ilinkitem(\'' . $xref . '\', \'manage\', \'' . $gedcom . '\')" href="#">' . WT_I18N::Translate('Manage links') . '</a>';
    } else {
        global $TEXT_DIRECTION;
        $classSuffix = $TEXT_DIRECTION == 'rtl' ? '_rtl' : '';
        $menu = new WT_Menu();
        $menu->addLabel(WT_I18N::translate('Set link'));
        $menu->addClass('', 'submenu');
        $submenu = new WT_Menu(WT_I18N::translate('To individual'));
        $submenu->addClass("submenuitem" . $classSuffix);
        $submenu->addOnClick("return ilinkitem('{$xref}', 'person', '{$gedcom}')");
        $menu->addSubMenu($submenu);
        $submenu = new WT_Menu(WT_I18N::translate('To family'));
        $submenu->addClass("submenuitem" . $classSuffix);
        $submenu->addOnClick("return ilinkitem('{$xref}', 'family', '{$gedcom}')");
        $menu->addSubMenu($submenu);
        $submenu = new WT_Menu(WT_I18N::translate('To source'));
        $submenu->addClass("submenuitem" . $classSuffix);
        $submenu->addOnClick("return ilinkitem('{$xref}', 'source', '{$gedcom}')");
        $menu->addSubMenu($submenu);
        $html .= '<div style="display:inline-block;">' . $menu->getMenu() . '</div>';
    }
    $html .= '<br><br>';
    $linked = array();
    foreach ($media->linkedIndividuals('OBJE') as $link) {
        $linked[] = '<a href="' . $link->getHtmlUrl() . '">' . $link->getFullName() . '</a>';
    }
    foreach ($media->linkedFamilies('OBJE') as $link) {
        $linked[] = '<a href="' . $link->getHtmlUrl() . '">' . $link->getFullName() . '</a>';
    }
    foreach ($media->linkedSources('OBJE') as $link) {
        $linked[] = '<a href="' . $link->getHtmlUrl() . '">' . $link->getFullName() . '</a>';
    }
    foreach ($media->linkedNotes('OBJE') as $link) {
        // Invalid GEDCOM - you cannot link a NOTE to an OBJE
        $linked[] = '<a href="' . $link->getHtmlUrl() . '">' . $link->getFullName() . '</a>';
    }
    foreach ($media->linkedRepositories('OBJE') as $link) {
        // Invalid GEDCOM - you cannot link a REPO to an OBJE
        $linked[] = '<a href="' . $link->getHtmlUrl() . '">' . $link->getFullName() . '</a>';
    }
    if ($linked) {
        $html .= '<ul>';
        foreach ($linked as $link) {
            $html .= '<li>' . $link . '</li>';
        }
        $html .= '</ul>';
    } else {
        $html .= '<div class="error">' . WT_I18N::translate('This media object is not linked to any other record.') . '</div>';
    }
    return $html;
}