summaryrefslogtreecommitdiff
path: root/medialist.php
diff options
context:
space:
mode:
Diffstat (limited to 'medialist.php')
-rw-r--r--medialist.php303
1 files changed, 126 insertions, 177 deletions
diff --git a/medialist.php b/medialist.php
index d1a728ff2a..ca04d34c48 100644
--- a/medialist.php
+++ b/medialist.php
@@ -2,7 +2,7 @@
// Displays a list of the media objects
//
// webtrees: Web based Family History software
-// Copyright (C) 2013 webtrees development team.
+// Copyright (C) 2014 webtrees development team.
//
// Derived from PhpGedView
// Copyright (C) 2002 to 2010 PGV Development Team. All rights reserved.
@@ -19,7 +19,7 @@
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
define('WT_SCRIPT_NAME', 'medialist.php');
require './includes/session.php';
@@ -41,7 +41,7 @@ $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');
+$subdirs = WT_Filter::get('subdirs', 'on');
$currentdironly = ($subdirs=='on') ? false : true;
// reset all variables
@@ -128,7 +128,7 @@ $controller->pageHeader();
<?php echo WT_I18N::translate('Search filters'); ?>
</td>
<td class="optionbox wrap width25">
- <input id="filter" name="filter" value="<?php echo $filter; ?>" size="14" dir="auto">
+ <input id="filter" name="filter" value="<?php echo WT_Filter::escapeHtml($filter); ?>" size="14" dir="auto">
</td>
<td class="descriptionbox wrap width25">
<?php echo WT_I18N::translate('Columns per page'); ?>
@@ -171,197 +171,146 @@ if ($search) {
$ct = '0';
}
- echo '<div align="center">', WT_I18N::translate('Media Objects found'), ' ', $ct, ' <br><br>';
+ echo '<div><p style="text-align:center">', WT_I18N::translate('Media Objects found'), ' ', $ct, '</p>';
if ($ct>0) {
- $currentPage = ((int) ($start / $max)) + 1;
- $lastPage = (int) (($ct + $max - 1) / $max);
+ $currentPage = ((int) ($start / $max)) + 1;
+ $lastPage = (int) (($ct + $max - 1) / $max);
- echo '<table class="list_table">';
- // echo page back, page number, page forward controls
- echo '<tr><td colspan="2">';
- echo '<table class="list_table_controls">';
- echo '<tr>';
- echo '<td>';
- if ($TEXT_DIRECTION=='ltr') {
- if ($ct>$max) {
- if ($currentPage > 1) {
- echo '<a href="medialist.php?action=no&amp;search=no&amp;folder=', rawurlencode($folder), '&amp;sortby=', $sortby, '&amp;subdirs=', $subdirs, '&amp;filter=', rawurlencode($filter), '&amp;columns=', $columns, '&amp;apply_filter=', $apply_filter, '&amp;start=0&amp;max=', $max, '" class="icon-ldarrow"></a>';
- }
- if ($start>0) {
- $newstart = $start-$max;
- if ($start<0) $start = 0;
- echo '<a href="medialist.php?action=no&amp;search=no&amp;folder=', rawurlencode($folder), '&amp;sortby=', $sortby, '&amp;subdirs=', $subdirs, '&amp;filter=', rawurlencode($filter), '&amp;;columns=', $columns, '&amp;apply_filter=', $apply_filter, '&amp;start=', $newstart, '&amp;max=', $max, '" class="icon-larrow"></a>';
- }
- }
- } else {
- if ($ct>$max) {
- if ($currentPage < $lastPage) {
- $lastStart = ((int) ($ct / $max)) * $max;
- echo '<a href="medialist.php?action=no&amp;search=no&amp;folder=', rawurlencode($folder), '&amp;sortby=', $sortby, '&amp;subdirs=', $subdirs, '&amp;filter=', rawurlencode($filter), '&amp;columns=', $columns, '&amp;apply_filter=', $apply_filter, '&amp;start=', $lastStart, '&amp;max=', $max, '" class="icon-rdarrow"></a>';
- }
- if ($start+$max < $ct) {
- $newstart = $start+$count;
- if ($start<0) $start = 0;
- echo '<a href="medialist.php?action=no&amp;search=no&amp;folder=', rawurlencode($folder), '&amp;sortby=', $sortby, '&amp;subdirs=', $subdirs, '&amp;filter=', rawurlencode($filter), '&amp;columns=', $columns, '&amp;apply_filter=', $apply_filter, '&amp;start=', $newstart, '&amp;max=', $max, '" class="icon-rarrow"></a>';
- }
- }
- }
- echo '</td>';
- echo '<td>', WT_I18N::translate('Page %s of %s', $currentPage, $lastPage), '</td>';
- echo '<td>';
- if ($TEXT_DIRECTION=='ltr') {
- if ($ct>$max) {
- if ($start+$max < $ct) {
- $newstart = $start+$count;
- if ($start<0) $start = 0;
- echo '<a href="medialist.php?action=no&amp;search=no&amp;folder=', rawurlencode($folder), '&amp;sortby=', $sortby, '&amp;subdirs=', $subdirs, '&amp;filter=', rawurlencode($filter), '&amp;columns=', $columns, '&amp;apply_filter=', $apply_filter, '&amp;start=', $newstart, '&amp;max=', $max, '"class="icon-rarrow"></a>';
- }
- if ($currentPage < $lastPage) {
- $lastStart = ((int) ($ct / $max)) * $max;
- echo '<a href="medialist.php?action=no&amp;search=no&amp;folder=', rawurlencode($folder), '&amp;sortby=', $sortby, '&amp;subdirs=', $subdirs, '&amp;filter=', rawurlencode($filter), '&amp;columns=', $columns, '&amp;apply_filter=', $apply_filter, '&amp;start=', $lastStart, '&amp;max=', $max, '" class="icon-rdarrow"></a>';
- }
- }
- } else {
- if ($ct>$max) {
- if ($start>0) {
- $newstart = $start-$max;
- if ($start<0) $start = 0;
- echo '<a href="medialist.php?action=no&amp;search=no&amp;folder=', rawurlencode($folder), '&amp;sortby=', $sortby, '&amp;subdirs=', $subdirs, '&amp;filter=', rawurlencode($filter), '&amp;columns=', $columns, '&amp;apply_filter=', $apply_filter, '&amp;start=', $newstart, '&amp;max=', $max, '" class="icon-larrow"></a>';
- }
- if ($currentPage > 1) {
- $lastStart = ((int) ($ct / $max)) * $max;
- echo '<a href="medialist.php?action=no&amp;search=no&amp;folder=', rawurlencode($folder), '&amp;sortby=', $sortby, '&amp;subdirs=', $subdirs, '&amp;filter=', rawurlencode($filter), '&amp;columns=', $columns, '&amp;apply_filter=', $apply_filter, '&amp;start=0&amp;max=', $max, '" class="icon-ldarrow"></a>';
- }
- }
- }
- echo '</td>';
- echo '</tr></table></td></tr>';
-
- echo '<tr>';
- for ($i=$start, $n=0; $i<$start+$count; ++$i) {
- $mediaobject = $medialist[$i];
-
- if ($columns == '1') echo '<td class="list_value_wrap" width="80%">';
- if ($columns == '2') echo '<td class="list_value_wrap" width="50%">';
+ echo '<table class="list_table width100">';
+ // Display controls twice - at the top and bottom of the table
+ foreach (array('thead', 'tfoot') as $tsection) {
+ echo '<', $tsection, '><tr><td colspan="2">';
- echo '<table><tr><td valign="top" style="white-space:normal;">';
- echo $mediaobject->displayImage();
- echo '</td><td class="list_value_wrap" style="border:none;" width="100%">';
- 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 '<p><b><a href="', $mediaobject->getHtmlUrl(), '">';
- echo $mediaobject->getFullName();
- echo '</a></b></p>';
- } else {
- echo '<p><b><a href="', $mediaobject->getHtmlUrl(), '">';
- echo basename($mediaobject->getFilename());
- echo '</a></b></p>';
- 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 '<table class="list_table_controls"><tr><td>';
+ if ($TEXT_DIRECTION=='ltr') {
+ if ($ct>$max) {
+ if ($currentPage > 1) {
+ echo '<a href="medialist.php?action=no&amp;search=no&amp;folder=', rawurlencode($folder), '&amp;sortby=', $sortby, '&amp;subdirs=', $subdirs, '&amp;filter=', rawurlencode($filter), '&amp;columns=', $columns, '&amp;apply_filter=', $apply_filter, '&amp;start=0&amp;max=', $max, '" class="icon-ldarrow"></a>';
+ }
+ if ($start>0) {
+ $newstart = $start-$max;
+ if ($start<0) $start = 0;
+ echo '<a href="medialist.php?action=no&amp;search=no&amp;folder=', rawurlencode($folder), '&amp;sortby=', $sortby, '&amp;subdirs=', $subdirs, '&amp;filter=', rawurlencode($filter), '&amp;;columns=', $columns, '&amp;apply_filter=', $apply_filter, '&amp;start=', $newstart, '&amp;max=', $max, '" class="icon-larrow"></a>';
+ }
+ }
+ } else {
+ if ($ct>$max) {
+ if ($currentPage < $lastPage) {
+ $lastStart = ((int) ($ct / $max)) * $max;
+ echo '<a href="medialist.php?action=no&amp;search=no&amp;folder=', rawurlencode($folder), '&amp;sortby=', $sortby, '&amp;subdirs=', $subdirs, '&amp;filter=', rawurlencode($filter), '&amp;columns=', $columns, '&amp;apply_filter=', $apply_filter, '&amp;start=', $lastStart, '&amp;max=', $max, '" class="icon-rdarrow"></a>';
+ }
+ if ($start+$max < $ct) {
+ $newstart = $start+$count;
+ if ($start<0) $start = 0;
+ echo '<a href="medialist.php?action=no&amp;search=no&amp;folder=', rawurlencode($folder), '&amp;sortby=', $sortby, '&amp;subdirs=', $subdirs, '&amp;filter=', rawurlencode($filter), '&amp;columns=', $columns, '&amp;apply_filter=', $apply_filter, '&amp;start=', $newstart, '&amp;max=', $max, '" class="icon-rarrow"></a>';
+ }
}
- 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']);
+ }
+ echo '</td>';
+ echo '<td>', WT_I18N::translate('Page %s of %s', $currentPage, $lastPage), '</td>';
+ echo '<td>';
+ if ($TEXT_DIRECTION=='ltr') {
+ if ($ct>$max) {
+ if ($start+$max < $ct) {
+ $newstart = $start+$count;
+ if ($start<0) $start = 0;
+ echo '<a href="medialist.php?action=no&amp;search=no&amp;folder=', rawurlencode($folder), '&amp;sortby=', $sortby, '&amp;subdirs=', $subdirs, '&amp;filter=', rawurlencode($filter), '&amp;columns=', $columns, '&amp;apply_filter=', $apply_filter, '&amp;start=', $newstart, '&amp;max=', $max, '" class="icon-rarrow"></a>';
+ }
+ if ($currentPage < $lastPage) {
+ $lastStart = ((int) ($ct / $max)) * $max;
+ echo '<a href="medialist.php?action=no&amp;search=no&amp;folder=', rawurlencode($folder), '&amp;sortby=', $sortby, '&amp;subdirs=', $subdirs, '&amp;filter=', rawurlencode($filter), '&amp;columns=', $columns, '&amp;apply_filter=', $apply_filter, '&amp;start=', $lastStart, '&amp;max=', $max, '" class="icon-rdarrow"></a>';
+ }
}
} else {
- echo '<p class="ui-state-error">', /* I18N: %s is a filename */ WT_I18N::translate('The file “%s” does not exist.', $mediaobject->getFilename()), '</p>';
+ if ($ct>$max) {
+ if ($start>0) {
+ $newstart = $start-$max;
+ if ($start<0) $start = 0;
+ echo '<a href="medialist.php?action=no&amp;search=no&amp;folder=', rawurlencode($folder), '&amp;sortby=', $sortby, '&amp;subdirs=', $subdirs, '&amp;filter=', rawurlencode($filter), '&amp;columns=', $columns, '&amp;apply_filter=', $apply_filter, '&amp;start=', $newstart, '&amp;max=', $max, '" class="icon-larrow"></a>';
+ }
+ if ($currentPage > 1) {
+ $lastStart = ((int) ($ct / $max)) * $max;
+ echo '<a href="medialist.php?action=no&amp;search=no&amp;folder=', rawurlencode($folder), '&amp;sortby=', $sortby, '&amp;subdirs=', $subdirs, '&amp;filter=', rawurlencode($filter), '&amp;columns=', $columns, '&amp;apply_filter=', $apply_filter, '&amp;start=0&amp;max=', $max, '" class="icon-ldarrow"></a>';
+ }
+ }
}
+ echo '</td></tr></table>';
+
+ echo '</td></tr></', $tsection, '>';
}
- echo '<br>';
- echo '<div style="white-space: normal; width: 95%;">';
- echo print_fact_sources($mediaobject->getGedcom(), 1);
- echo print_fact_notes($mediaobject->getGedcom(), 1);
- echo '</div>';
- foreach ($mediaobject->linkedIndividuals('OBJE') as $individual) {
- echo '<a href="' . $individual->getHtmlUrl() . '">' . WT_I18N::translate('View person') . ' — ' . $individual->getFullname().'</a><br>';
- }
- foreach ($mediaobject->linkedFamilies('OBJE') as $family) {
- echo '<a href="' . $family->getHtmlUrl() . '">' . WT_I18N::translate('View family') . ' — ' . $family->getFullname().'</a><br>';
- }
- foreach ($mediaobject->linkedSources('OBJE') as $source) {
- echo '<a href="' . $source->getHtmlUrl() . '">' . WT_I18N::translate('View source') . ' — ' . $source->getFullname().'</a><br>';
- }
- echo '</td></tr></table>';
- echo '</td>';
- if ((++$n) % $columns == 0) {
- echo '</tr><tr>';
- }
- } // end media loop
- echo '</tr>';
- // echo page back, page number, page forward controls
- echo '<tr><td colspan="2">';
- echo '<table class="list_table width100">';
- echo '<tr>';
- echo '<td class="width30">';
- if ($TEXT_DIRECTION=='ltr') {
- if ($ct>$max) {
- if ($currentPage > 1) {
- echo '<a href="medialist.php?action=no&amp;search=no&amp;folder=', rawurlencode($folder), '&amp;sortby=', $sortby, '&amp;subdirs=', $subdirs, '&amp;filter=', rawurlencode($filter), '&amp;columns=', $columns, '&amp;apply_filter=', $apply_filter, '&amp;start=0&amp;max=', $max, '" class="icon-ldarrow"></a>';
- }
- if ($start>0) {
- $newstart = $start-$max;
- if ($start<0) $start = 0;
- echo '<a href="medialist.php?action=no&amp;search=no&amp;folder=', rawurlencode($folder), '&amp;sortby=', $sortby, '&amp;subdirs=', $subdirs, '&amp;filter=', rawurlencode($filter), '&amp;columns=', $columns, '&amp;apply_filter=', $apply_filter, '&amp;start=', $newstart, '&amp;max=', $max, '" class="icon-larrow"></a>';
+
+ echo '<tbody><tr>';
+ for ($i=$start, $n=0; $i<$start+$count; ++$i) {
+ $mediaobject = $medialist[$i];
+
+ if ($columns == '1') echo '<td class="list_value_wrap width80">';
+ if ($columns == '2') echo '<td class="list_value_wrap width50">';
+
+ echo '<table><tr><td style="vertical-align:top; white-space:normal;">';
+ echo $mediaobject->displayImage();
+ echo '</td><td class="list_value_wrap width100" style="border:none; padding-left:5px">';
+ if (WT_USER_CAN_EDIT) {
+ echo WT_Controller_Media::getMediaListMenu($mediaobject);
}
- }
- } else {
- if ($ct>$max) {
- if ($currentPage < $lastPage) {
- $lastStart = ((int) ($ct / $max)) * $max;
- echo '<a href="medialist.php?action=no&amp;search=no&amp;folder=', rawurlencode($folder), '&amp;sortby=', $sortby, '&amp;subdirs=', $subdirs, '&amp;filter=', rawurlencode($filter), '&amp;columns=', $columns, '&amp;apply_filter=', $apply_filter, '&amp;start=', $lastStart, '&amp;max=', $max, '" class="icon-rdarrow"></a>';
+ // If sorting by title, highlight the title. If sorting by filename, highlight the filename
+ if ($sortby=='title') {
+ echo '<p><b><a href="', $mediaobject->getHtmlUrl(), '">';
+ echo $mediaobject->getFullName();
+ echo '</a></b></p>';
+ } else {
+ echo '<p><b><a href="', $mediaobject->getHtmlUrl(), '">';
+ echo basename($mediaobject->getFilename());
+ echo '</a></b></p>';
+ echo WT_Gedcom_Tag::getLabelValue('TITL', $mediaobject->getFullName());
}
- if ($start+$max < $ct) {
- $newstart = $start+$count;
- if ($start<0) $start = 0;
- echo '<a href="medialist.php?action=no&amp;search=no&amp;folder=', rawurlencode($folder), '&amp;sortby=', $sortby, '&amp;subdirs=', $subdirs, '&amp;filter=', rawurlencode($filter), '&amp;columns=', $columns, '&amp;apply_filter=', $apply_filter, '&amp;start=', $newstart, '&amp;max=', $max, '" class="icon-rarrow"></a>';
+ // 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 '<p class="ui-state-error">', /* I18N: %s is a filename */ WT_I18N::translate('The file “%s” does not exist.', $mediaobject->getFilename()), '</p>';
+ }
}
- }
- }
- echo '</td>';
- echo '<td align="center">', WT_I18N::translate('Page %s of %s', $currentPage, $lastPage), '</td>';
- echo '<td class="width30">';
- if ($TEXT_DIRECTION=='ltr') {
- if ($ct>$max) {
- if ($start+$max < $ct) {
- $newstart = $start+$count;
- if ($start<0) $start = 0;
- echo '<a href="medialist.php?action=no&amp;search=no&amp;folder=', rawurlencode($folder), '&amp;sortby=', $sortby, '&amp;subdirs=', $subdirs, '&amp;filter=', rawurlencode($filter), '&amp;columns=', $columns, '&amp;apply_filter=', $apply_filter, '&amp;start=', $newstart, '&amp;max=', $max, '" class="icon-rarrow"></a>';
+ echo '<br>';
+ echo '<div style="white-space: normal; width: 95%;">';
+ echo print_fact_sources($mediaobject->getGedcom(), 1);
+ echo print_fact_notes($mediaobject->getGedcom(), 1);
+ echo '</div>';
+ foreach ($mediaobject->linkedIndividuals('OBJE') as $individual) {
+ echo '<a href="' . $individual->getHtmlUrl() . '">' . WT_I18N::translate('View person') . ' — ' . $individual->getFullname().'</a><br>';
}
- if ($currentPage < $lastPage) {
- $lastStart = ((int) ($ct / $max)) * $max;
- echo '<a href="medialist.php?action=no&amp;search=no&amp;folder=', rawurlencode($folder), '&amp;sortby=', $sortby, '&amp;subdirs=', $subdirs, '&amp;filter=', rawurlencode($filter), '&amp;columns=', $columns, '&amp;apply_filter=', $apply_filter, '&amp;start=', $lastStart, '&amp;max=', $max, '" class="icon-rdarrow"></a>';
+ foreach ($mediaobject->linkedFamilies('OBJE') as $family) {
+ echo '<a href="' . $family->getHtmlUrl() . '">' . WT_I18N::translate('View family') . ' — ' . $family->getFullname().'</a><br>';
}
- }
- } else {
- if ($ct>$max) {
- if ($start>0) {
- $newstart = $start-$max;
- if ($start<0) $start = 0;
- echo '<a href="medialist.php?action=no&amp;search=no&amp;folder=', rawurlencode($folder), '&amp;sortby=', $sortby, '&amp;subdirs=', $subdirs, '&amp;filter=', rawurlencode($filter), '&amp;columns=', $columns, '&amp;apply_filter=', $apply_filter, '&amp;start=', $newstart, '&amp;max=', $max, '" class="icon-larrow"></a>';
+ foreach ($mediaobject->linkedSources('OBJE') as $source) {
+ echo '<a href="' . $source->getHtmlUrl() . '">' . WT_I18N::translate('View source') . ' — ' . $source->getFullname().'</a><br>';
}
- if ($currentPage > 1) {
- $lastStart = ((int) ($ct / $max)) * $max;
- echo '<a href="medialist.php?action=no&amp;search=no&amp;folder=', rawurlencode($folder), '&amp;sortby=', $sortby, '&amp;subdirs=', $subdirs, '&amp;filter=', rawurlencode($filter), '&amp;columns=', $columns, '&amp;apply_filter=', $apply_filter, '&amp;start=0&amp;max=', $max, '" class="icon-ldarrow"></a>';
+ echo '</td></tr></table>';
+ echo '</td>';
+ if ((++$n) % $columns == 0 && $n < $count) {
+ echo '</tr><tr>';
}
+ } // end media loop
+
+ // An odd number of media objects in two columns requires an empty cell
+ if ($columns == 2 && $n%2 == 1) {
+ echo '<td>&nbsp;</td>';
}
+
+ echo '</tr></tbody>';
+ echo '</table>';
}
- echo '</td>';
- echo '</tr></table></td></tr>';
- echo '</table><br>';
- }
echo '</div>
</div>';
}