Skip to content

Commit

Permalink
refactor(attach.lib.php): move params in config.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
J9rem committed Feb 9, 2022
1 parent c83bb04 commit c2b6eff
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 54 deletions.
14 changes: 14 additions & 0 deletions tools/attach/config.yaml
Expand Up @@ -113,6 +113,20 @@ parameters:
ots: 'opendocument spreadsheet-template'
otp: 'opendocument presentation-template'
otg: 'opendocument graphics-template'
attach_config:
ext_images: "gif|jpeg|png|jpg|svg|webp"
ext_audio: "mp3|aac"
ext_video: "mp4|webm|ogg"
ext_wma: "wma"
ext_pdf: "pdf"
ext_freemind: "mm"
ext_flashvideo: "flv"
ext_script: "php|php3|asp|asx|vb|vbs|js"
upload_path: "files"
update_symbole: ""
fmDelete_symbole: "Supr"
fmRestore_symbole: "Rest"
fmTrash_symbole: "Corbeille"
attach-video-config:
default_video_service: 'peertube'
default_peertube_instance: 'https://framatube.org/'
Expand Down
59 changes: 5 additions & 54 deletions tools/attach/libs/attach.lib.php
Expand Up @@ -34,6 +34,7 @@
# voir actions/attach.php ppour la documentation
# copyrigth Eric Feldstein 2003-2004

use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use YesWiki\Core\Service\LinkTracker;

if (!defined("WIKINI_VERSION")) {
Expand Down Expand Up @@ -62,74 +63,24 @@ class attach
public $pageId = 0; //identifiant de la page
public $isSafeMode = true; //indicateur du safe mode de PHP
public $data = ''; //indicateur du safe mode de PHP
private $params;
/**
* Constructeur. Met les valeurs par defaut aux parametres de configuration
*/
public function __construct(&$wiki)
{
$this->wiki = $wiki;
$this->attachConfig = $this->wiki->GetConfigValue("attach_config");
$this->params = $this->wiki->services->get(ParameterBagInterface::class);
$this->attachConfig = $this->params->get("attach_config");

if (!is_array($this->attachConfig)) {
$this->attachConfig = array();
}

if (empty($this->attachConfig["ext_images"])) {
$this->attachConfig["ext_images"] = "gif|jpeg|png|jpg|svg|webp";
}

if (empty($this->attachConfig["ext_audio"])) {
$this->attachConfig["ext_audio"] = "mp3|aac";
}

if (empty($this->attachConfig["ext_video"])) {
$this->attachConfig["ext_video"] = "mp4|webm|ogg";
}

if (empty($this->attachConfig["ext_wma"])) {
$this->attachConfig["ext_wma"] = "wma";
}

if (empty($this->attachConfig["ext_pdf"])) {
$this->attachConfig["ext_pdf"] = "pdf";
}

if (empty($this->attachConfig["ext_freemind"])) {
$this->attachConfig["ext_freemind"] = "mm";
}

if (empty($this->attachConfig["ext_flashvideo"])) {
$this->attachConfig["ext_flashvideo"] = "flv";
}

if (empty($this->attachConfig["ext_script"])) {
$this->attachConfig["ext_script"] = "php|php3|asp|asx|vb|vbs|js";
}

if (empty($this->attachConfig['upload_path'])) {
$this->attachConfig['upload_path'] = 'files';
}

if (empty($this->attachConfig['update_symbole'])) {
$this->attachConfig['update_symbole'] = '';
throw new Exception("attach_config should be an array in wakka.config.php");
}

if (empty($this->attachConfig['max_file_size'])) {
$this->attachConfig['max_file_size'] = $this->wiki->GetConfigValue("max_file_size") ? $this->wiki->GetConfigValue("max_file_size") : $this->file_upload_max_size();
}

if (empty($this->attachConfig['fmDelete_symbole'])) {
$this->attachConfig['fmDelete_symbole'] = 'Supr';
}

if (empty($this->attachConfig['fmRestore_symbole'])) {
$this->attachConfig['fmRestore_symbole'] = 'Rest';
}

if (empty($this->attachConfig['fmTrash_symbole'])) {
$this->attachConfig['fmTrash_symbole'] = 'Corbeille';
}

$safemode = $this->wiki->GetConfigValue("no_safe_mode");
if (empty($safemode)) {
if (version_compare(phpversion(), '5.3', '<')) {
Expand Down

0 comments on commit c2b6eff

Please sign in to comment.