2222output_header ($ title , NO_STATSBAR , $ extra_args );
2323echo "<h1> " . $ title . "</h1> \n" ;
2424
25- echo "<p> " . _ ("This tool will allow you to copy pages from one project to another. " ) . "</p> " ;
25+ echo "<p> " . _ ("This tool will allow you to copy pages from one project to another. " ) . " " ;
26+ echo sprintf (_ ("It no longer renames pages, use the <a href='%s'>Rename Pages</a> script if there are page name collisions. " ), "rename_pages.php " ) . "</p> " ;
2627// Validate the $projectid_ and $from_image_ 'by hand'
2728$ projectid_ = $ _POST ['projectid_ ' ] ?? null ;
2829if (is_array ($ projectid_ )) {
4041}
4142
4243$ action = get_enumerated_param ($ _POST , 'action ' , 'showform ' , ['showform ' , 'showagain ' , 'check ' , 'docopy ' ]);
43- $ page_name_handling = get_enumerated_param ($ _POST , 'page_name_handling ' , null , ['PRESERVE_PAGE_NAMES ' , 'RENUMBER_PAGES ' ], true );
4444$ transfer_notifications = get_bool_param ($ _POST , 'transfer_notifications ' , false );
4545$ add_deletion_reason = get_bool_param ($ _POST , 'add_deletion_reason ' , false );
4646$ merge_wordcheck_data = get_bool_param ($ _POST , 'merge_wordcheck_data ' , false );
5151 display_copy_pages_form (
5252 $ projectid_ ,
5353 $ from_image_ ,
54- $ page_name_handling ,
5554 $ transfer_notifications ,
5655 $ add_deletion_reason ,
5756 $ merge_wordcheck_data ,
6463 display_copy_pages_form (
6564 $ projectid_ ,
6665 $ from_image_ ,
67- $ page_name_handling ,
6866 $ transfer_notifications ,
6967 $ add_deletion_reason ,
7068 $ merge_wordcheck_data ,
7775 copy_pages (
7876 $ projectid_ ,
7977 $ from_image_ ,
80- $ page_name_handling ,
8178 $ transfer_notifications ,
8279 $ add_deletion_reason ,
8380 $ merge_wordcheck_data ,
8885 display_hiddens (
8986 $ projectid_ ,
9087 $ from_image_ ,
91- $ page_name_handling ,
9288 $ transfer_notifications ,
9389 $ add_deletion_reason ,
9490 $ merge_wordcheck_data
10399 copy_pages (
104100 $ projectid_ ,
105101 $ from_image_ ,
106- $ page_name_handling ,
107102 $ transfer_notifications ,
108103 $ add_deletion_reason ,
109104 $ merge_wordcheck_data ,
127122 display_hiddens (
128123 $ projectid_ ,
129124 $ from_image_ ,
130- $ page_name_handling ,
131125 $ transfer_notifications ,
132126 $ add_deletion_reason ,
133127 $ merge_wordcheck_data
148142function display_copy_pages_form (
149143 ?array $ projectid_ ,
150144 ?array $ from_image_ ,
151- ?string $ page_name_handling ,
152145 bool $ transfer_notifications ,
153146 bool $ add_deletion_reason ,
154147 bool $ merge_wordcheck_data ,
@@ -180,27 +173,6 @@ function display_copy_pages_form(
180173 echo "<tr><th> " . _ ("Destination Project: " ) . "</th> \n" ;
181174 echo "<td><input type='text' name='projectid_[to]' size='28' $ val required> (projectid)</td></tr> \n" ;
182175
183- // If we are repeating, we want the same buttons to be checked
184- echo "<tr><td></td><td> \n" ;
185- echo "<fieldset> \n" ;
186- echo "<legend> " . _ ("Page number handling: " ) . "</legend> " ;
187-
188- if (!$ repeating || $ page_name_handling == 'PRESERVE_PAGE_NAMES ' ) {
189- $ checked1 = 'CHECKED ' ;
190- $ checked2 = '' ;
191- } else {
192- $ checked1 = '' ;
193- $ checked2 = 'CHECKED ' ;
194- }
195-
196- echo "<input type='radio' name='page_name_handling' id='pnh-1' value='PRESERVE_PAGE_NAMES' $ checked1> \n" ;
197- echo "<label for='pnh-1'> " . _ ("Preserve page numbers " ) . "</label> " ;
198-
199- echo "<input type='radio' name='page_name_handling' id='pnh-2' value='RENUMBER_PAGES' $ checked2> \n" ;
200- echo "<label for='pnh-2'> " . _ ("Renumber pages " ) . "</label> \n" ;
201- echo "</fieldset> \n" ;
202- echo "</td></tr> \n" ;
203-
204176 do_radio_button_pair (
205177 _ ("Transfer event notifications: " ),
206178 "transfer_notifications " ,
@@ -259,7 +231,6 @@ function do_radio_button_pair(string $prompt, string $input_name, bool $repeatin
259231function display_hiddens (
260232 array $ projectid_ ,
261233 array $ from_image_ ,
262- string $ page_name_handling ,
263234 bool $ transfer_notifications ,
264235 bool $ add_deletion_reason ,
265236 bool $ merge_wordcheck_data
@@ -268,7 +239,6 @@ function display_hiddens(
268239 echo "\n<input type='hidden' name='from_image_[hi]' value=' " . attr_safe ($ from_image_ ['hi ' ]) . "'> " ;
269240 echo "\n<input type='hidden' name='projectid_[from]' value=' " . attr_safe ($ projectid_ ['from ' ]) . "'> " ;
270241 echo "\n<input type='hidden' name='projectid_[to]' value=' " . attr_safe ($ projectid_ ['to ' ]) . "'> " ;
271- echo "\n<input type='hidden' name='page_name_handling' value=' " . attr_safe ($ page_name_handling ) . "'> " ;
272242 echo "\n<input type='hidden' name='transfer_notifications' value=' " . ($ transfer_notifications ? 1 : 0 ) . "'> " ;
273243 echo "\n<input type='hidden' name='add_deletion_reason' value=' " . ($ add_deletion_reason ? 1 : 0 ) . "'> " ;
274244 echo "\n<input type='hidden' name='merge_wordcheck_data' value=' " . ($ merge_wordcheck_data ? 1 : 0 ) . "'> " ;
@@ -277,7 +247,6 @@ function display_hiddens(
277247function copy_pages (
278248 ?array $ projectid_ ,
279249 ?array $ from_image_ ,
280- string $ page_name_handling ,
281250 bool $ transfer_notifications ,
282251 bool $ add_deletion_reason ,
283252 bool $ merge_wordcheck_data ,
@@ -459,28 +428,6 @@ function ($a, $b) {
459428
460429 // ----------------------------------------------------
461430
462- if ($ page_name_handling == 'PRESERVE_PAGE_NAMES ' ) {
463- // fine
464- } elseif ($ page_name_handling == 'RENUMBER_PAGES ' ) {
465- if (count ($ all_fileid_values_ ['to ' ]) == 0 ) {
466- $ c_dst_format = '%03d ' ;
467- $ c_dst_start_b = 1 ;
468- } else {
469- $ max_dst_fileid = str_max ($ all_fileid_values_ ['to ' ]);
470- $ max_dst_image = str_max ($ all_image_values_ ['to ' ]);
471- $ max_dst_image_base = preg_replace ('/\.[^.]+$/ ' , '' , $ max_dst_image );
472- $ max_dst_base = (
473- strcmp ($ max_dst_fileid , $ max_dst_image_base ) > 0
474- ? $ max_dst_fileid
475- : $ max_dst_image_base
476- );
477- $ c_dst_format = '%0 ' . strlen ($ max_dst_base ) . 'd ' ;
478- $ c_dst_start_b = 1 + intval ($ max_dst_base );
479- }
480- } else {
481- throw new ValueError ("Bad \$page_name_handling " );
482- }
483-
484431 // The c_ prefix means that it only pertains to *copied* pages.
485432
486433 $ c_src_image_ = [];
@@ -491,18 +438,8 @@ function ($a, $b) {
491438 for ($ i = $ lo_i ; $ i <= $ hi_i ; $ i ++) {
492439 $ c_src_image = $ all_image_values_ ['from ' ][$ i ];
493440 $ c_src_fileid = $ all_fileid_values_ ['from ' ][$ i ];
494-
495- if ($ page_name_handling == 'PRESERVE_PAGE_NAMES ' ) {
496- $ c_dst_fileid = $ c_src_fileid ;
497- $ c_dst_image = $ c_src_image ;
498- } elseif ($ page_name_handling == 'RENUMBER_PAGES ' ) {
499- $ c_src_image_ext = preg_replace ('/.*\./ ' , '' , $ c_src_image );
500- $ c_dst_b = ($ i - $ lo_i + $ c_dst_start_b );
501- $ c_dst_fileid = sprintf ($ c_dst_format , $ c_dst_b );
502- $ c_dst_image = "$ c_dst_fileid. $ c_src_image_ext " ;
503- } else {
504- throw new UnexpectedValueException ("Unexpected page_name_handling $ page_name_handling " );
505- }
441+ $ c_dst_fileid = $ c_src_fileid ;
442+ $ c_dst_image = $ c_src_image ;
506443
507444 $ c_src_image_ [] = $ c_src_image ;
508445 $ c_src_fileid_ [] = $ c_src_fileid ;
@@ -538,23 +475,11 @@ function ($a, $b) {
538475 throw new RuntimeException (_ ("Aborting due to page name collisions! " ));
539476 }
540477
541- echo "<p> " ;
542- if ($ page_name_handling == 'PRESERVE_PAGE_NAMES ' ) {
543- echo _ ("There don't appear to be any page name collisions. " );
544- } elseif ($ page_name_handling == 'RENUMBER_PAGES ' ) {
545- echo _ ("As expected, there aren't any page name collisions. " );
546- }
547- echo "</p> " ;
548-
549478 // Report the settings/selections that were chosen
550479
551480 echo "<h3> " . _ ("Per your request: " ) . "</h3> " ;
552481
553482 echo "<ul> " ;
554- echo "<li> " . _ ("Page Name Handling: " );
555- echo " <code> " . html_safe ($ page_name_handling ) . "</code> " ;
556- echo "</li> \n" ;
557-
558483 echo "<li> " ;
559484 if ($ transfer_notifications ) {
560485 echo _ ("Event notifications WILL be transferred " );
0 commit comments