original_string: protected static function export_used_files($context, $subwikiid, $alltexts) {
          if (!self::text_has_files($alltexts)) {
              return;
          }
          $fs = get_file_storage();
          $files = $fs->get_area_files($context->id, 'mod_wiki', 'attachments', $subwikiid,
              'filepath, filename', false);
          if (empty($files)) {
              return;
          }
          usort($files, function($file1, $file2) {
              return strcmp($file2->get_filepath(), $file1->get_filename());
          });
          foreach ($files as $file) {
              $filepath = $file->get_filepath() . $file->get_filename();
              $needles = ['@@PLUGINFILE@@' . s($filepath),
                  '@@PLUGINFILE@@' . $filepath,
                  '@@PLUGINFILE@@' . str_replace(' ', '%20', $filepath),
                  '@@PLUGINFILE@@' . s($filepath),
                  '@@PLUGINFILE@@' . s(str_replace(' ', '%20', $filepath))
              ];
              $needles = array_unique($needles);
              $newtext = str_replace($needles, '', $alltexts);
              if ($newtext !== $alltexts) {
                  $alltexts = $newtext;
                  writer::with_context($context)->export_file([$subwikiid], $file);
                  if (!self::text_has_files($alltexts)) {
                      return;
                  }
              }
          }
      }
code: protected static function export_used_files($context, $subwikiid, $alltexts) {
          if (!self::text_has_files($alltexts)) {
              return;
          }
          $fs = get_file_storage();
          $files = $fs->get_area_files($context->id, 'mod_wiki', 'attachments', $subwikiid,
              'filepath, filename', false);
          if (empty($files)) {
              return;
          }
          usort($files, function($file1, $file2) {
              return strcmp($file2->get_filepath(), $file1->get_filename());
          });
          foreach ($files as $file) {
              $filepath = $file->get_filepath() . $file->get_filename();
              $needles = ['@@PLUGINFILE@@' . s($filepath),
                  '@@PLUGINFILE@@' . $filepath,
                  '@@PLUGINFILE@@' . str_replace(' ', '%20', $filepath),
                  '@@PLUGINFILE@@' . s($filepath),
                  '@@PLUGINFILE@@' . s(str_replace(' ', '%20', $filepath))
              ];
              $needles = array_unique($needles);
              $newtext = str_replace($needles, '', $alltexts);
              if ($newtext !== $alltexts) {
                  $alltexts = $newtext;
                  writer::with_context($context)->export_file([$subwikiid], $file);
                  if (!self::text_has_files($alltexts)) {
                      return;
                  }
              }
          }
      }
code_tokens: protected static function export_used_files ( $ context , $ subwikiid , $ alltexts ) { if ( ! self :: text_has_files ( $ alltexts ) ) { return ; } $ fs = get_file_storage ( ) ; $ files = $ fs -> get_area_files ( $ context -> id , 'mod_wiki' , 'attachments' , $ subwikiid , 'filepath, filename' , false ) ; if ( empty ( $ files ) ) { return ; } usort ( $ files , function ( $ file1 , $ file2 ) { return strcmp ( $ file2 -> get_filepath ( ) , $ file1 -> get_filename ( ) ) ; } ) ; foreach ( $ files as $ file ) { $ filepath = $ file -> get_filepath ( ) . $ file -> get_filename ( ) ; $ needles = [ '@@PLUGINFILE@@' . s ( $ filepath ) , '@@PLUGINFILE@@' . $ filepath , '@@PLUGINFILE@@' . str_replace ( ' ' , '%20' , $ filepath ) , '@@PLUGINFILE@@' . s ( $ filepath ) , '@@PLUGINFILE@@' . s ( str_replace ( ' ' , '%20' , $ filepath ) ) ] ; $ needles = array_unique ( $ needles ) ; $ newtext = str_replace ( $ needles , '' , $ alltexts ) ; if ( $ newtext !== $ alltexts ) { $ alltexts = $ newtext ; writer :: with_context ( $ context ) -> export_file ( [ $ subwikiid ] , $ file ) ; if ( ! self :: text_has_files ( $ alltexts ) ) { return ; } } } }
docstring: Analyze which files are used in the texts and export
  @param context $context
  @param int $subwikiid
  @param string $alltexts
  @return int|void
docstring_tokens: Analyze which files are used in the texts and export