Beta 15完美支持版
请在在原修改版文件的基础上修改!
将 fof/upload/src/Providers/DownloadProvider.php 修改为如下
<?php
/*
* This file is part of fof/upload.
*
* Copyright (c) 2020 - 2021 FriendsOfFlarum.
* Copyright (c) 2016 - 2019 Flagrow
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
namespace FoF\Upload\Providers;
use Flarum\Foundation\AbstractServiceProvider;
use FoF\Upload\Commands\DownloadHandler;
use FoF\Upload\Downloader\DefaultDownloader;
use FoF\Upload\Helpers\Util;
use FoF\Upload\Templates\FileTemplate;
use FoF\Upload\Templates\ImagePreviewTemplate;
use FoF\Upload\Templates\ImageTemplate;
use FoF\Upload\Templates\JustUrlTemplate;
use FoF\Upload\Templates\VideoTemplate;
use FoF\Upload\Templates\AudioTemplate;
use FoF\Upload\Templates\TextTemplate;
use FoF\Upload\Templates\PdfTemplate;
class DownloadProvider extends AbstractServiceProvider
{
public function register()
{
DownloadHandler::addDownloader(
$this->app->make(DefaultDownloader::class)
);
$this->loadViewsFrom(__DIR__ . '/../../resources/templates', 'fof-upload.templates');
/** @var Util $util */
$util = $this->app->make(Util::class);
$util->addRenderTemplate($this->app->make(FileTemplate::class));
$util->addRenderTemplate($this->app->make(ImageTemplate::class));
$util->addRenderTemplate($this->app->make(ImagePreviewTemplate::class));
$util->addRenderTemplate($this->app->make(JustUrlTemplate::class));
$util->addRenderTemplate($this->app->make(VideoTemplate::class));
$util->addRenderTemplate($this->app->make(AudioTemplate::class));
$util->addRenderTemplate($this->app->make(TextTemplate::class));
$util->addRenderTemplate($this->app->make(PdfTemplate::class));
}
}
将 fof/upload/src/Templates/AudioTemplate.php 修改为如下
<?php
namespace FoF\Upload\Templates;
use FoF\Upload\File;
class AudioTemplate extends AbstractTextFormatterTemplate
{
/**
* @var string
*/
protected $tag = 'audio';
/**
* {@inheritdoc}
*/
public function name(): string
{
return 'MP3 Audio';
}
/**
* {@inheritdoc}
*/
public function description(): string
{
return 'MP3 Audio';
}
/**
* The xsl template to use with this tag.
*
* @return string
*/
public function template(): string
{
return $this->getView('fof-upload.templates::audio');
}
/**
* The bbcode to be parsed.
*
* @return string
*/
public function bbcode(): string
{
return '[upl-audio uuid={IDENTIFIER} size={SIMPLETEXT2} url={URL}]{SIMPLETEXT1}[/upl-audio]';
}
}
将 fof/upload/src/Templates/PdfTemplate.php 修改为如下
<?php
namespace FoF\Upload\Templates;
use FoF\Upload\File;
class PdfTemplate extends AbstractTextFormatterTemplate
{
/**
* @var string
*/
protected $tag = 'pdf';
/**
* {@inheritdoc}
*/
public function name(): string
{
return 'PDF View';
}
/**
* {@inheritdoc}
*/
public function description(): string
{
return 'PDF View';
}
/**
* The xsl template to use with this tag.
*
* @return string
*/
public function template(): string
{
return $this->getView('fof-upload.templates::pdf');
}
/**
* The bbcode to be parsed.
*
* @return string
*/
public function bbcode(): string
{
return '[upl-pdf uuid={IDENTIFIER} size={SIMPLETEXT2} url={URL}]{SIMPLETEXT1}[/upl-pdf]';
}
}
将 fof/upload/src/Templates/TextTemplate.php 修改为如下
<?php
namespace FoF\Upload\Templates;
use FoF\Upload\File;
class TextTemplate extends AbstractTextFormatterTemplate
{
/**
* @var string
*/
protected $tag = 'text';
/**
* {@inheritdoc}
*/
public function name(): string
{
return 'Plain Text';
}
/**
* {@inheritdoc}
*/
public function description(): string
{
return 'Plain Text';
}
/**
* The xsl template to use with this tag.
*
* @return string
*/
public function template(): string
{
return $this->getView('fof-upload.templates::text');
}
/**
* The bbcode to be parsed.
*
* @return string
*/
public function bbcode(): string
{
return '[upl-text uuid={IDENTIFIER} size={SIMPLETEXT2} url={URL}]{SIMPLETEXT1}[/upl-text]';
}
}
将 fof/upload/src/Templates/VideoTemplate.php 修改为如下
<?php
namespace FoF\Upload\Templates;
use FoF\Upload\File;
class VideoTemplate extends AbstractTextFormatterTemplate
{
/**
* @var string
*/
protected $tag = 'video';
/**
* {@inheritdoc}
*/
public function name(): string
{
return 'MP4 Video';
}
/**
* {@inheritdoc}
*/
public function description(): string
{
return 'MP4 Video';
}
/**
* The xsl template to use with this tag.
*
* @return string
*/
public function template(): string
{
return $this->getView('fof-upload.templates::video');
}
/**
* The bbcode to be parsed.
*
* @return string
*/
public function bbcode(): string
{
return '[upl-video uuid={IDENTIFIER} size={SIMPLETEXT2} url={URL}]{SIMPLETEXT1}[/upl-video]';
}
}
其他的按操作
操作完成后在根目录执行 composer dump-autoload 即可!