diff options
Diffstat (limited to 'addmedia.php')
| -rw-r--r-- | addmedia.php | 72 |
1 files changed, 38 insertions, 34 deletions
diff --git a/addmedia.php b/addmedia.php index e268bd0785..7dcad4ce45 100644 --- a/addmedia.php +++ b/addmedia.php @@ -24,6 +24,10 @@ namespace Fisharebest\Webtrees; global $WT_TREE; use Fisharebest\Webtrees\Controller\SimpleController; +use Fisharebest\Webtrees\Functions\Functions; +use Fisharebest\Webtrees\Functions\FunctionsDb; +use Fisharebest\Webtrees\Functions\FunctionsEdit; +use Fisharebest\Webtrees\Functions\FunctionsPrint; use Fisharebest\Webtrees\Query\QueryMedia; define('WT_SCRIPT_NAME', 'addmedia.php'); @@ -184,7 +188,7 @@ case 'create': // Save the information from the “showcreateform” action FlashMessages::addMessage( I18N::translate('There was an error uploading your file.') . '<br>' . - file_upload_error_text($_FILES['mediafile']['error']) + Functions::fileUploadErrorText($_FILES['mediafile']['error']) ); $filename = ''; break; @@ -218,7 +222,7 @@ case 'create': // Save the information from the “showcreateform” action $newged .= "\n1 FILE " . $folderName . $fileName; } - $newged = handle_updates($newged); + $newged = FunctionsEdit::handleUpdates($newged); $new_media = $WT_TREE->createRecord($newged); if ($linktoid) { @@ -312,7 +316,7 @@ case 'update': // Save the information from the “editmedia” action $newFilename = $folderName . $fileName; // Cannot rename local to external or vice-versa - if (isFileExternal($oldFilename) != isFileExternal($filename)) { + if (Functions::isFileExternal($oldFilename) != Functions::isFileExternal($filename)) { FlashMessages::addMessage(I18N::translate('The media file %1$s could not be renamed to %2$s.', Html::filename($oldFilename), Html::filename($newFilename))); break; } @@ -331,7 +335,7 @@ case 'update': // Save the information from the “editmedia” action if ($oldServerFile !== $newServerFile) { //-- check if the file is used in more than one gedcom //-- do not allow it to be moved or renamed if it is - if (!$media->isExternal() && is_media_used_in_other_gedcom($media->getFilename(), $WT_TREE->getTreeId())) { + if (!$media->isExternal() && FunctionsDb::isMediaUsedInOtherTree($media->getFilename(), $WT_TREE->getTreeId())) { FlashMessages::addMessage(I18N::translate('This file is linked to another family tree on this server. It cannot be deleted, moved, or renamed until these links have been removed.')); break; } @@ -367,7 +371,7 @@ case 'update': // Save the information from the “editmedia” action } } - // Insert the 1 FILE xxx record into the arrays used by function handle_updates() + // Insert the 1 FILE xxx record into the arrays used by function FunctionsEdit::handle_updatesges() $glevels = array_merge(array('1'), $glevels); $tag = array_merge(array('FILE'), $tag); $islink = array_merge(array(0), $islink); @@ -375,7 +379,7 @@ case 'update': // Save the information from the “editmedia” action $record = GedcomRecord::getInstance($pid, $WT_TREE); $newrec = "0 @$pid@ OBJE\n"; - $newrec = handle_updates($newrec); + $newrec = FunctionsEdit::handleUpdates($newrec); $record->updateRecord($newrec, $update_CHAN); if ($pid && $linktoid) { @@ -415,15 +419,15 @@ if ($linktoid) { } echo '<table class="facts_table">'; echo '<tr><td class="topbottombar" colspan="2">'; -echo $controller->getPageTitle(), help_link('OBJE'); +echo $controller->getPageTitle(), FunctionsPrint::helpLink('OBJE'); echo '</td></tr>'; if (!$linktoid && $action == 'create') { echo '<tr><td class="descriptionbox wrap width25">'; echo I18N::translate('Enter an individual, family, or source ID'); echo '</td><td class="optionbox wrap"><input type="text" data-autocomplete-type="IFS" name="linktoid" id="linktoid" size="6" value="">'; - echo ' ', print_findindi_link('linktoid'); - echo ' ', print_findfamily_link('linktoid'); - echo ' ', print_findsource_link('linktoid'); + echo ' ', FunctionsPrint::printFindIndividualLink('linktoid'); + echo ' ', FunctionsPrint::printFindFamilyLink('linktoid'); + echo ' ', FunctionsPrint::printFindSourceLink('linktoid'); echo '<p class="small text-muted">', I18N::translate('Enter or search for the ID of the individual, family, or source to which this media item should be linked.'), '</p></td></tr>'; } @@ -454,10 +458,10 @@ if ($gedfile == 'FILE') { } // Filename on server -$isExternal = isFileExternal($gedfile); +$isExternal = Functions::isFileExternal($gedfile); if ($gedfile == 'FILE') { if (Auth::isManager($WT_TREE)) { - add_simple_tag( + FunctionsEdit::addSimpleTag( "1 $gedfile", '', I18N::translate('Filename on server'), @@ -545,7 +549,7 @@ if (preg_match('/\n(2 FORM .*)/', $gedrec, $match)) { } else { $gedform = '2 FORM'; } -$formid = add_simple_tag($gedform); +$formid = FunctionsEdit::addSimpleTag($gedform); // automatically set the format field from the filename $controller->addInlineJavascript(' @@ -569,7 +573,7 @@ if (preg_match('/\n(3 TYPE .*)/', $gedrec, $match)) { } else { $gedtype = '3 TYPE photo'; // default to ‘Photo’ } -add_simple_tag($gedtype); +FunctionsEdit::addSimpleTag($gedtype); // 1 FILE / 2 TITL if (preg_match('/\n(2 TITL .*)/', $gedrec, $match)) { @@ -577,7 +581,7 @@ if (preg_match('/\n(2 TITL .*)/', $gedrec, $match)) { } else { $gedtitl = '2 TITL'; } -add_simple_tag($gedtitl); +FunctionsEdit::addSimpleTag($gedtitl); // 1 FILE / 2 TITL / 3 _HEB if (strstr($WT_TREE->getPreference('ADVANCED_NAME_FACTS'), '_HEB') !== false) { @@ -586,7 +590,7 @@ if (strstr($WT_TREE->getPreference('ADVANCED_NAME_FACTS'), '_HEB') !== false) { } else { $gedtitl = '3 _HEB'; } - add_simple_tag($gedtitl); + FunctionsEdit::addSimpleTag($gedtitl); } // 1 FILE / 2 TITL / 3 ROMN @@ -596,7 +600,7 @@ if (strstr($WT_TREE->getPreference('ADVANCED_NAME_FACTS'), 'ROMN') !== false) { } else { $gedtitl = '3 ROMN'; } - add_simple_tag($gedtitl); + FunctionsEdit::addSimpleTag($gedtitl); } // 1 _PRIM @@ -605,7 +609,7 @@ if (preg_match('/\n(1 _PRIM .*)/', $gedrec, $match)) { } else { $gedprim = '1 _PRIM'; } -add_simple_tag($gedprim); +FunctionsEdit::addSimpleTag($gedprim); //-- print out editing fields for any other data in the media record $sourceLevel = 0; @@ -627,15 +631,15 @@ if (!empty($gedrec)) { $fact = trim($match[2]); $event = trim($match[3]); if ($fact === 'NOTE' || $fact === 'TEXT') { - $event .= get_cont($subLevel + 1, $subrec); + $event .= Functions::getCont($subLevel + 1, $subrec); } if ($sourceSOUR !== '' && $subLevel <= $sourceLevel) { // Get rid of all saved Source data - add_simple_tag($sourceLevel . ' SOUR ' . $sourceSOUR); - add_simple_tag(($sourceLevel + 1) . ' PAGE ' . $sourcePAGE); - add_simple_tag(($sourceLevel + 2) . ' TEXT ' . $sourceTEXT); - add_simple_tag(($sourceLevel + 2) . ' DATE ' . $sourceDATE, '', GedcomTag::getLabel('DATA:DATE')); - add_simple_tag(($sourceLevel + 1) . ' QUAY ' . $sourceQUAY); + FunctionsEdit::addSimpleTag($sourceLevel . ' SOUR ' . $sourceSOUR); + FunctionsEdit::addSimpleTag(($sourceLevel + 1) . ' PAGE ' . $sourcePAGE); + FunctionsEdit::addSimpleTag(($sourceLevel + 2) . ' TEXT ' . $sourceTEXT); + FunctionsEdit::addSimpleTag(($sourceLevel + 2) . ' DATE ' . $sourceDATE, '', GedcomTag::getLabel('DATA:DATE')); + FunctionsEdit::addSimpleTag(($sourceLevel + 1) . ' QUAY ' . $sourceQUAY); $sourceSOUR = ''; } @@ -672,18 +676,18 @@ if (!empty($gedrec)) { // Output anything that isn’t part of a source reference if (!empty($fact) && $fact !== 'CONC' && $fact !== 'CONT' && $fact !== 'DATA') { - add_simple_tag($subLevel . ' ' . $fact . ' ' . $event); + FunctionsEdit::addSimpleTag($subLevel . ' ' . $fact . ' ' . $event); } } } if ($sourceSOUR !== '') { // Get rid of all saved Source data - add_simple_tag($sourceLevel . ' SOUR ' . $sourceSOUR); - add_simple_tag(($sourceLevel + 1) . ' PAGE ' . $sourcePAGE); - add_simple_tag(($sourceLevel + 2) . ' TEXT ' . $sourceTEXT); - add_simple_tag(($sourceLevel + 2) . ' DATE ' . $sourceDATE, '', GedcomTag::getLabel('DATA:DATE')); - add_simple_tag(($sourceLevel + 1) . ' QUAY ' . $sourceQUAY); + FunctionsEdit::addSimpleTag($sourceLevel . ' SOUR ' . $sourceSOUR); + FunctionsEdit::addSimpleTag(($sourceLevel + 1) . ' PAGE ' . $sourcePAGE); + FunctionsEdit::addSimpleTag(($sourceLevel + 2) . ' TEXT ' . $sourceTEXT); + FunctionsEdit::addSimpleTag(($sourceLevel + 2) . ' DATE ' . $sourceDATE, '', GedcomTag::getLabel('DATA:DATE')); + FunctionsEdit::addSimpleTag(($sourceLevel + 1) . ' QUAY ' . $sourceQUAY); } } if (Auth::isAdmin()) { @@ -698,10 +702,10 @@ if (Auth::isAdmin()) { echo '</td></tr>'; } echo '</table>'; -print_add_layer('SOUR', 1); -print_add_layer('NOTE', 1); -print_add_layer('SHARED_NOTE', 1); -print_add_layer('RESN', 1); +FunctionsEdit::printAddLayer('SOUR', 1); +FunctionsEdit::printAddLayer('NOTE', 1); +FunctionsEdit::printAddLayer('SHARED_NOTE', 1); +FunctionsEdit::printAddLayer('RESN', 1); ?> <p id="save-cancel"> <input type="submit" class="save" value="<?php echo I18N::translate('save'); ?>"> |
