. */ namespace Fisharebest\Webtrees; /** * Defined in session.php * * @global Tree $WT_TREE */ global $WT_TREE; use Fisharebest\Webtrees\Controller\MediaController; use Fisharebest\Webtrees\Controller\PageController; use Fisharebest\Webtrees\Functions\FunctionsEdit; use Fisharebest\Webtrees\Functions\FunctionsPrint; use Fisharebest\Webtrees\Functions\FunctionsPrintFacts; use Fisharebest\Webtrees\Query\QueryMedia; define('WT_SCRIPT_NAME', 'medialist.php'); require './includes/session.php'; $controller = new PageController; $controller ->setPageTitle(I18N::translate('Media objects')) ->pageHeader(); $action = Filter::get('action'); $sortby = Filter::get('sortby', 'file|title', 'title'); if (!Auth::isEditor($WT_TREE)) { $sortby = 'title'; } $page = Filter::getInteger('page'); $max = Filter::get('max', '10|20|30|40|50|75|100|125|150|200', '20'); $folder = Filter::get('folder', null, ''); // MySQL needs an empty string, not NULL $filter = Filter::get('filter', null, ''); // MySQL needs an empty string, not NULL $columns = Filter::getInteger('columns', 1, 2, 2); $subdirs = Filter::get('subdirs', 'on'); $form_type = Filter::get('form_type', implode('|', array_keys(GedcomTag::getFileFormTypes()))); $currentdironly = ($subdirs === 'on') ? false : true; // reset all variables if ($action === 'reset') { $sortby = 'title'; $max = '20'; $folder = ''; $columns = '2'; $currentdironly = true; $filter = ''; $form_type = ''; } // A list of all subfolders used by this tree $folders = QueryMedia::folderList(); // A list of all media objects matching the search criteria $medialist = QueryMedia::mediaList( $folder, $currentdironly ? 'exclude' : 'include', $sortby, $filter, $form_type ); ?>

getPageTitle(); ?>

>
getNameHtml() . '&folder=' . Filter::escapeUrl($folder) . '&sortby=' . Filter::escapeUrl($sortby) . '&subdirs=' . Filter::escapeUrl($subdirs) . '&filter=' . Filter::escapeUrl($filter) . '&form_type=' . Filter::escapeUrl($form_type) . '&columns=' . Filter::escapeUrl($columns) . '&max=' . Filter::escapeUrl($max); $count = count($medialist); $pages = (int) (($count + $max - 1) / $max); $page = max(min($page, $pages), 1); if ($page === $pages && $count % $max !== 0) { // Last page may have fewer than $max pages $number_on_page = $count % $max; } else { $number_on_page = $max; } if (I18N::direction() === 'ltr') { $icons = array('first' => 'ldarrow', 'previous' => 'larrow', 'next' => 'rarrow', 'last' => 'rdarrow'); } else { $icons = array('first' => 'rdarrow', 'previous' => 'rarrow', 'next' => 'larrow', 'last' => 'ldarrow'); } echo '

', I18N::translate('Media objects found'), ' ', $count, '

'; if ($count > 0) { echo ''; // Display controls twice - at the top and bottom of the table foreach (array('thead', 'tfoot') as $tsection) { echo '<', $tsection, '>'; } echo ''; for ($i = 0, $n = 0; $i < $number_on_page; ++$i) { $mediaobject = $medialist[($page - 1) * $max + $i]; if ($columns === 1) { echo ''; if ((++$n) % $columns == 0 && $n < $count) { echo ''; } } // end media loop // An odd number of media objects in two columns requires an empty cell if ($columns == 2 && $n % 2 == 1) { echo ''; } echo ''; echo '
'; echo '
'; if ($page > 1) { echo ''; echo ''; } echo '', I18N::translate('Page %s of %s', $page, $pages), ''; if ($page < $pages) { echo ''; echo ''; } echo '
'; echo '
'; } if ($columns === 2) { echo ''; } echo '
'; echo $mediaobject->displayImage(); echo ''; if (Auth::isEditor($WT_TREE)) { echo MediaController::getMediaListMenu($mediaobject); } // If sorting by title, highlight the title. If sorting by filename, highlight the filename if ($sortby === 'title') { echo '

'; echo $mediaobject->getFullName(); echo '

'; } else { echo '

'; echo basename($mediaobject->getFilename()); echo '

'; echo GedcomTag::getLabelValue('TITL', $mediaobject->getFullName()); } // Show file details if ($mediaobject->isExternal()) { echo GedcomTag::getLabelValue('URL', $mediaobject->getFilename()); } else { if ($mediaobject->fileExists()) { if (Auth::isEditor($WT_TREE)) { echo GedcomTag::getLabelValue('FILE', $mediaobject->getFilename()); $mediatype = $mediaobject->getMediaType(); if ($mediatype) { echo GedcomTag::getLabelValue('TYPE', GedcomTag::getFileFormTypeValue($mediatype)); } } echo GedcomTag::getLabelValue('FORM', $mediaobject->mimeType()); echo GedcomTag::getLabelValue('__FILE_SIZE__', $mediaobject->getFilesize()); $imgsize = $mediaobject->getImageAttributes(); if ($imgsize['WxH']) { echo GedcomTag::getLabelValue('__IMAGE_SIZE__', $imgsize['WxH']); } } else { echo '

', /* I18N: %s is a filename */ I18N::translate('The file “%s” does not exist.', $mediaobject->getFilename()), '

'; } } echo '
'; echo '
'; echo FunctionsPrintFacts::printFactSources($mediaobject->getGedcom(), 1); echo FunctionsPrint::printFactNotes($mediaobject->getGedcom(), 1); echo '
'; foreach ($mediaobject->linkedIndividuals('OBJE') as $individual) { echo '' . I18N::translate('View this individual') . ' — ' . $individual->getFullName() . '
'; } foreach ($mediaobject->linkedFamilies('OBJE') as $family) { echo '' . I18N::translate('View this family') . ' — ' . $family->getFullName() . '
'; } foreach ($mediaobject->linkedSources('OBJE') as $source) { echo '' . I18N::translate('View this source') . ' — ' . $source->getFullName() . '
'; } echo '
'; echo '
'; } echo '
'; } echo '
';