setPageTitle(WT_I18N::translate('Media objects'))
->pageHeader();
$search = WT_Filter::get('search');
$sortby = WT_Filter::get('sortby', 'file|title', 'title');
if (!WT_USER_CAN_EDIT && !WT_USER_CAN_ACCEPT) {
$sortby='title';
}
$start = WT_Filter::getInteger('start');
$max = WT_Filter::get('max', '10|20|30|40|50|75|100|125|150|200', '20');
$folder = WT_Filter::get('folder', null, ''); // MySQL needs an empty string, not NULL
$reset = WT_Filter::get('reset');
$apply_filter = WT_Filter::get('apply_filter');
$filter = WT_Filter::get('filter', null, ''); // MySQL needs an empty string, not NULL
$columns = WT_Filter::getInteger('columns', 1, 2, 2);
$subdirs = WT_Filter::get('subdirs', 'on');
$currentdironly = ($subdirs=='on') ? false : true;
// reset all variables
if ($reset == 'Reset') {
$sortby = 'title';
$max = '20';
$folder = '';
$columns = '2';
$currentdironly = true;
$filter = '';
}
// A list of all subfolders used by this tree
$folders = WT_Query_Media::folderList();
// A list of all media objects matching the search criteria
$medialist = WT_Query_Media::mediaList(
$folder,
$currentdironly ? 'exclude' : 'include',
$sortby,
$filter
);
?>
getPageTitle(); ?>
$ct) {
$count = $ct - $start;
}
echo '
', WT_I18N::translate('Media objects found'), ' ', $ct, '
';
if ($ct>0) {
$currentPage = ((int) ($start / $max)) + 1;
$lastPage = (int) (($ct + $max - 1) / $max);
echo '
';
// Display controls twice - at the top and bottom of the table
foreach (array('thead', 'tfoot') as $tsection) {
echo '<', $tsection, '>';
echo '| ';
if ($TEXT_DIRECTION=='ltr') {
if ($ct>$max) {
if ($currentPage > 1) {
echo '';
}
if ($start>0) {
$newstart = $start-$max;
if ($start<0) $start = 0;
echo '';
}
}
} else {
if ($ct>$max) {
if ($currentPage < $lastPage) {
$lastStart = ((int) ($ct / $max)) * $max;
echo '';
}
if ($start+$max < $ct) {
$newstart = $start+$count;
if ($start<0) $start = 0;
echo '';
}
}
}
echo ' | ';
echo '', WT_I18N::translate('Page %s of %s', $currentPage, $lastPage), ' | ';
echo '';
if ($TEXT_DIRECTION=='ltr') {
if ($ct>$max) {
if ($start+$max < $ct) {
$newstart = $start+$count;
if ($start<0) $start = 0;
echo '';
}
if ($currentPage < $lastPage) {
$lastStart = ((int) ($ct / $max)) * $max;
echo '';
}
}
} else {
if ($ct>$max) {
if ($start>0) {
$newstart = $start-$max;
if ($start<0) $start = 0;
echo '';
}
if ($currentPage > 1) {
$lastStart = ((int) ($ct / $max)) * $max;
echo '';
}
}
}
echo ' | ';
echo ' |
', $tsection, '>';
}
echo '';
for ($i=$start, $n=0; $i<$start+$count; ++$i) {
$mediaobject = $medialist[$i];
if ($columns == '1') echo '| ';
if ($columns == '2') echo ' | ';
echo '| ';
echo $mediaobject->displayImage();
echo ' | ';
if (WT_USER_CAN_EDIT) {
echo WT_Controller_Media::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 WT_Gedcom_Tag::getLabelValue('TITL', $mediaobject->getFullName());
}
// Show file details
if ($mediaobject->isExternal()) {
echo WT_Gedcom_Tag::getLabelValue('URL', $mediaobject->getFilename());
} else {
if ($mediaobject->fileExists()) {
if (WT_USER_CAN_EDIT || WT_USER_CAN_ACCEPT) {
echo WT_Gedcom_Tag::getLabelValue('FILE', $mediaobject->getFilename());
}
echo WT_Gedcom_Tag::getLabelValue('FORM', $mediaobject->mimeType());
echo WT_Gedcom_Tag::getLabelValue('__FILE_SIZE__', $mediaobject->getFilesize());
$imgsize = $mediaobject->getImageAttributes();
if ($imgsize['WxH']) {
echo WT_Gedcom_Tag::getLabelValue('__IMAGE_SIZE__', $imgsize['WxH']);
}
} else {
echo '', /* I18N: %s is a filename */ WT_I18N::translate('The file “%s” does not exist.', $mediaobject->getFilename()), ' ';
}
}
echo ' ';
echo '';
echo print_fact_sources($mediaobject->getGedcom(), 1);
echo print_fact_notes($mediaobject->getGedcom(), 1);
echo ' ';
foreach ($mediaobject->linkedIndividuals('OBJE') as $individual) {
echo '' . WT_I18N::translate('View person') . ' — ' . $individual->getFullname().' ';
}
foreach ($mediaobject->linkedFamilies('OBJE') as $family) {
echo '' . WT_I18N::translate('View family') . ' — ' . $family->getFullname().' ';
}
foreach ($mediaobject->linkedSources('OBJE') as $source) {
echo '' . WT_I18N::translate('View source') . ' — ' . $source->getFullname().' ';
}
echo ' | ';
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 '
';
}
echo '
';