Fisharebest\Webtrees\Functions\FunctionsPrintLists::mediaTable PHP Method

mediaTable() public static method

Print a table of media objects
public static mediaTable ( Fisharebest\Webtrees\Media[] $media_objects ) : string
$media_objects Fisharebest\Webtrees\Media[]
return string
    public static function mediaTable($media_objects)
    {
        global $WT_TREE, $controller;
        $html = '';
        $table_id = 'table-obje-' . Uuid::uuid4();
        // lists requires a unique ID in case there are multiple lists per page
        $controller->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)->addInlineJavascript('
				jQuery.fn.dataTableExt.oSort["text-asc"] = textCompareAsc;
				jQuery.fn.dataTableExt.oSort["text-desc"] = textCompareDesc;
				jQuery("#' . $table_id . '").dataTable({
					dom: \'<"H"pf<"dt-clear">irl>t<"F"pl>\',
					' . I18N::datatablesI18N() . ',
					jQueryUI: true,
					autoWidth:false,
					processing: true,
					columns: [
						/* Thumbnail   */ { sortable: false },
						/* Title       */ { type: "text" },
						/* Individuals */ { type: "num" },
						/* Families    */ { type: "num" },
						/* Sources     */ { type: "num" },
						/* Last change */ { visible: ' . ($WT_TREE->getPreference('SHOW_LAST_CHANGE') ? 'true' : 'false') . ' },
					],
					displayLength: 20,
					pagingType: "full_numbers"
				});
				jQuery(".media-list").css("visibility", "visible");
				jQuery(".loading-image").css("display", "none");
			');
        $html .= '<div class="loading-image"></div>';
        $html .= '<div class="media-list">';
        $html .= '<table id="' . $table_id . '"><thead><tr>';
        $html .= '<th>' . I18N::translate('Media') . '</th>';
        $html .= '<th>' . GedcomTag::getLabel('TITL') . '</th>';
        $html .= '<th>' . I18N::translate('Individuals') . '</th>';
        $html .= '<th>' . I18N::translate('Families') . '</th>';
        $html .= '<th>' . I18N::translate('Sources') . '</th>';
        $html .= '<th>' . GedcomTag::getLabel('CHAN') . '</th>';
        $html .= '</tr></thead>';
        $html .= '<tbody>';
        foreach ($media_objects as $media_object) {
            if ($media_object->canShow()) {
                $name = $media_object->getFullName();
                if ($media_object->isPendingAddtion()) {
                    $class = ' class="new"';
                } elseif ($media_object->isPendingDeletion()) {
                    $class = ' class="old"';
                } else {
                    $class = '';
                }
                $html .= '<tr' . $class . '>';
                // Media object thumbnail
                $html .= '<td>' . $media_object->displayImage() . '</td>';
                // Media object name(s)
                $html .= '<td data-sort="' . Filter::escapeHtml($media_object->getSortName()) . '">';
                $html .= '<a href="' . $media_object->getHtmlUrl() . '" class="list_item name2">';
                $html .= FunctionsPrint::highlightSearchHits($name) . '</a>';
                if (Auth::isEditor($media_object->getTree())) {
                    $html .= '<br><a href="' . $media_object->getHtmlUrl() . '">' . basename($media_object->getFilename()) . '</a>';
                }
                $html .= '</td>';
                // Count of linked individuals
                $num = count($media_object->linkedIndividuals('OBJE'));
                $html .= '<td class="center" data-sort="' . $num . '">' . I18N::number($num) . '</td>';
                // Count of linked families
                $num = count($media_object->linkedFamilies('OBJE'));
                $html .= '<td class="center" data-sort="' . $num . '">' . I18N::number($num) . '</td>';
                // Count of linked sources
                $num = count($media_object->linkedSources('OBJE'));
                $html .= '<td class="center" data-sort="' . $num . '">' . I18N::number($num) . '</td>';
                // Last change
                $html .= '<td data-sort="' . $media_object->lastChangeTimestamp(true) . '">' . $media_object->lastChangeTimestamp() . '</td>';
                $html .= '</tr>';
            }
        }
        $html .= '</tbody></table></div>';
        return $html;
    }

Usage Example

Exemplo n.º 1
0
    ?>
			<div id="linked-families">
				<?php 
    echo FunctionsPrintLists::familyTable($linked_fam);
    ?>
			</div>
		<?php 
}
?>

		<?php 
if ($linked_obje) {
    ?>
			<div id="linked-media">
				<?php 
    echo FunctionsPrintLists::mediaTable($linked_obje);
    ?>
			</div>
		<?php 
}
?>

		<?php 
if ($linked_sour) {
    ?>
			<div id="linked-sources">
				<?php 
    echo FunctionsPrintLists::sourceTable($linked_sour);
    ?>
			</div>
		<?php 
All Usage Examples Of Fisharebest\Webtrees\Functions\FunctionsPrintLists::mediaTable