PSR et indentation
parent
9a35f7e923
commit
e159bfcc66
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0"?>
|
||||
<ruleset>
|
||||
<file>.</file>
|
||||
<exclude-pattern>vendor/*</exclude-pattern>
|
||||
<exclude-pattern>lib/*</exclude-pattern>
|
||||
<exclude-pattern>codemirror/*</exclude-pattern>
|
||||
<exclude-pattern>lang/*</exclude-pattern>
|
||||
<rule ref="SPIP40"/>
|
||||
<rule ref="PSR1"/>
|
||||
|
||||
<config name="ignore_warnings_on_exit" value="1"/>
|
||||
<arg name="cache" value=".php_cs.cache"/>
|
||||
<arg name="report-full" value=".php_cs.txt"/>
|
||||
<arg name="report-summary"/>
|
||||
<arg value="s"/>
|
||||
</ruleset>
|
@ -1,212 +1,216 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin SkelEditor
|
||||
* Editeur de squelette en ligne
|
||||
* (c) depuis 2007 Collectif SPIP
|
||||
* Licence GPL-v3
|
||||
*/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')){
|
||||
return;
|
||||
}
|
||||
|
||||
include_spip('inc/skeleditor_codemiror');
|
||||
|
||||
function skeleditor_dossier(){
|
||||
include_spip('inc/skeleditor');
|
||||
return skeleditor_path_editable();
|
||||
}
|
||||
|
||||
|
||||
// build select menu to choose directory
|
||||
function editor_form_directory($path, $depth = ""){
|
||||
$output = "";
|
||||
foreach ($path as $dir){
|
||||
$tdir = explode('/', $dir);
|
||||
$myfile = array_pop($tdir);
|
||||
$depth = "";
|
||||
while (array_pop($tdir)) $depth .= " ";
|
||||
$output .= "<option value='$dir'>$depth$myfile</option>\n";
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
// add file form
|
||||
function skeleditor_addfile($path_list){
|
||||
//$output = bouton_block_invisible('editor_newfile');
|
||||
$output .= "<img src='" . _DIR_PLUGIN_SKELEDITOR . "images/action_add.png' alt='new' />" . _T("skeleditor:fichier_nouveau");
|
||||
//$output .= debut_block_invisible('editor_newfile');
|
||||
$output .= "<form method='get'>\n";
|
||||
$output .= "<input type='hidden' name='exec' value='skeleditor' />";
|
||||
$output .= "<input type='hidden' name='operation' value='new' />";
|
||||
//$output .= "nom du fichier:<br />\n";
|
||||
$output .= "<input type='text' name='f' value='untitled.html' onfocus=\"this.value=''\" />";
|
||||
$output .= _T("skeleditor:target") . "<br />\n";
|
||||
$output .= "<select name='target'><br />\n";
|
||||
$output .= editor_form_directory($path_list);
|
||||
$output .= "</select><br /><input type='submit' name='sub' value='" . _T("skeleditor:creer") . "' />";
|
||||
$output .= "</form>\n";
|
||||
$output .= fin_block();
|
||||
return $output;
|
||||
}
|
||||
|
||||
// upload file form
|
||||
function skeleditor_uploadfile($path_list){
|
||||
//$output = "<br />".bouton_block_invisible('editor_uploadfile');
|
||||
$output .= "<img src='" . _DIR_PLUGIN_SKELEDITOR . "images/action_add.png' alt='new' />" . _T("skeleditor:fichier_upload");
|
||||
//$output .= debut_block_invisible('editor_uploadfile');
|
||||
|
||||
$output .= "<form method='post' enctype='multipart/form-data' >\n";
|
||||
$output .= "<input type='hidden' name='exec' value='skeleditor' />";
|
||||
$output .= "<input type='hidden' name='operation' value='upload' />";
|
||||
$output .= "<input type='hidden' name='MAX_FILE_SIZE' value='200000' />";
|
||||
$output .= "<input type='file' name='upf'/>";
|
||||
$output .= _T("skeleditor:target") . "<br />\n";
|
||||
$output .= "<select name='target'><br />\n";
|
||||
$output .= editor_form_directory($path_list);
|
||||
$output .= "</select><br /><input type='submit' name='sub' value='" . _T("skeleditor:upload") . "' />";
|
||||
$output .= "</form>\n";
|
||||
|
||||
$output .= fin_block();
|
||||
return $output;
|
||||
}
|
||||
|
||||
// skeleton parsing (more details: public/phrase_html)
|
||||
function skel_parser($skel_str){
|
||||
include_spip("public/interfaces");
|
||||
include_spip("public/phraser_html");
|
||||
//include_spip("public/debug");
|
||||
|
||||
//$output .= _T('skeleditor:parseur_titre');
|
||||
$output .= "<div style='background: #eef; border:1px solid #eee;padding:10px;font-size:0.82em;font-family:Verdana'>";
|
||||
|
||||
$boucles = array();
|
||||
$b = public_phraser_html($skel_str, 0, $boucles, 'skel_editor');
|
||||
$boucles = array_reverse($boucles, TRUE);
|
||||
|
||||
/* parse outside boucles */
|
||||
//$output .= bouton_block_invisible("hors_boucle")._T("skeleditor:parseur_horsboucle");
|
||||
//$output .= debut_block_invisible("hors_boucle");
|
||||
$output .= "<div style='background: #fff;padding:10px;'>";
|
||||
foreach ($b as $k => $val){
|
||||
if ($val->type=="champ"){
|
||||
$output .= "<span style='color:#c30;background:#eee'>#" . $val->nom_champ . "</span>";
|
||||
} else {
|
||||
if ($val->type=="texte"){
|
||||
$output .= "<pre style='background:#ddd;margin:0;display:inline;'> " . htmlspecialchars($val->texte) . "</pre>";
|
||||
} else {
|
||||
if ($val->type=="include"){
|
||||
$output .= "<span style='color:#30c;background:#cff;'>(INCLURE)</span>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$output .= "</div>\n";
|
||||
$output .= fin_block() . "<br />";
|
||||
|
||||
/* parse boucles */
|
||||
foreach ($boucles as $k => $val){
|
||||
/* version gentle */
|
||||
//$output .= bouton_block_invisible("skel_parser_$k")." BOUCLE$k";
|
||||
$output .= " <span style='color:#888'>(" . strtoupper($val->type_requete) . ")</span>";
|
||||
//$output .= debut_block_invisible("skel_parser_$k");
|
||||
$output .= "<div style='background: #fff;padding:10px;'>";
|
||||
if ($val->id_parent){
|
||||
$output .= "<strong>id_parent:</strong> BOUCLE$val->id_parent<br />";
|
||||
}
|
||||
if ($val->param){
|
||||
$output .= "<strong>" . _T('skeleditor:parseur_param') . "</strong>" . skel_parser_param($val->param) . "<br />";
|
||||
}
|
||||
$output .= "<strong>" . _T('skeleditor:parseur_contenu') . "</strong><br />";
|
||||
$output .= skel_parser_affiche(_T('skeleditor:parseur_avant'), $val->avant, '#cc9');
|
||||
$output .= skel_parser_affiche(_T('skeleditor:parseur_milieu'), $val->milieu, '#fc6');
|
||||
$output .= skel_parser_affiche(_T('skeleditor:parseur_apres'), $val->apres, '#fcc');
|
||||
$output .= skel_parser_affiche(_T('skeleditor:parseur_altern'), $val->altern, '#cfc');
|
||||
$output .= "</div>\n";
|
||||
$output .= fin_block() . "<br />";
|
||||
|
||||
/* version brute */
|
||||
/*
|
||||
$output .= "<strong>BOUCLE$k</strong><br />\n";
|
||||
foreach (get_object_vars($val) as $prop => $val2) {
|
||||
$output .= "\t<br />$prop = $val2\n";
|
||||
if (is_array($val2)) {
|
||||
foreach($val2 as $k3=>$val3) {
|
||||
$output .= "\t\t<br>........................$k3 = $val3\n";
|
||||
if (is_object($val3)) {
|
||||
foreach (get_object_vars($val3) as $prop4 => $val4) {
|
||||
$output .= "\t\t<br>+++........................( $prop4 = $val4 )\n";
|
||||
if (is_array($val4 )) {
|
||||
foreach($val4 as $k5=>$val5) {
|
||||
$output .= "\t\t<br>++++++...............$k5 = $val5 )\n";
|
||||
foreach($val5 as $k6=>$val6) {
|
||||
$output .= "\t\t<br>+++++++++++.........$k6 = $val6 )\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
$output .= "</div>";
|
||||
return $output;
|
||||
}
|
||||
|
||||
// affiche le code pour le parseur
|
||||
function skel_parser_affiche($titre, $content, $bgcolor = '#fc6'){
|
||||
$output = "";
|
||||
$output .= "<div style='background:$bgcolor'>$titre</div>";
|
||||
foreach ($content as $k => $str){
|
||||
if ($str->type=="champ"){
|
||||
$output .= "<span style='color:#c30;background:#eee'>#" . $str->nom_champ . "</span>";
|
||||
} else {
|
||||
if ($str->type=="texte"){
|
||||
$output .= "<pre style='background:#ddd;margin:0;display:inline;'> " . htmlspecialchars($str->texte) . "</pre>";
|
||||
} else {
|
||||
if ($str->type=="include"){
|
||||
$output .= "<span style='color:#30c;background:#cff;'>(INCLUDE)</span>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
// parse param value
|
||||
function skel_parser_param($str, $output = ''){
|
||||
$output = "";
|
||||
if (is_array($str)){
|
||||
foreach ($str as $k2 => $val2){
|
||||
//$output .= ".....$k2=>$val2 ($c)<br />";
|
||||
$output .= skel_parser_param($val2, $output); // recursive
|
||||
}
|
||||
} else {
|
||||
if (is_object($str)){
|
||||
$output .= " {" . $str->texte . "} ";
|
||||
/*foreach (get_object_vars($str) as $prop4 => $val4) {
|
||||
$output .= "\t\t<br>...........( $prop4 = $val4 )\n";
|
||||
} */
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
// recupere les plugins de type squelette
|
||||
function get_plugin_squelette(){
|
||||
// alternative 1: liste des plugins squelettes manuelle (blip, sarka, ...?)
|
||||
// alternative 2: on scanne les plugins: si article.html et sommaire.html present ? sans doute un plugin squelette
|
||||
$plugin_squelette = array();
|
||||
if ($GLOBALS['plugins']){
|
||||
foreach ($GLOBALS['plugins'] as $k){
|
||||
if (@is_file(_DIR_PLUGINS . "$k/article.html") && @is_file(_DIR_PLUGINS . "$k/sommaire.html")){
|
||||
$plugin_squelette[] = _DIR_PLUGINS . $k . "/";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $plugin_squelette;
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Plugin SkelEditor
|
||||
* Editeur de squelette en ligne
|
||||
* (c) depuis 2007 Collectif SPIP
|
||||
* Licence GPL-v3
|
||||
*/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) {
|
||||
return;
|
||||
}
|
||||
|
||||
include_spip('inc/skeleditor_codemiror');
|
||||
function skeleditor_dossier() {
|
||||
|
||||
include_spip('inc/skeleditor');
|
||||
return skeleditor_path_editable();
|
||||
}
|
||||
|
||||
|
||||
// build select menu to choose directory
|
||||
function editor_form_directory($path, $depth = '') {
|
||||
|
||||
$output = '';
|
||||
foreach ($path as $dir) {
|
||||
$tdir = explode('/', $dir);
|
||||
$myfile = array_pop($tdir);
|
||||
$depth = '';
|
||||
while (array_pop($tdir)) {
|
||||
$depth .= ' ';
|
||||
}
|
||||
$output .= "<option value='$dir'>$depth$myfile</option>\n";
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
// add file form
|
||||
function skeleditor_addfile($path_list) {
|
||||
|
||||
//$output = bouton_block_invisible('editor_newfile');
|
||||
$output .= "<img src='" . _DIR_PLUGIN_SKELEDITOR . "images/action_add.png' alt='new' />" . _T('skeleditor:fichier_nouveau');
|
||||
//$output .= debut_block_invisible('editor_newfile');
|
||||
$output .= "<form method='get'>\n";
|
||||
$output .= "<input type='hidden' name='exec' value='skeleditor' />";
|
||||
$output .= "<input type='hidden' name='operation' value='new' />";
|
||||
//$output .= "nom du fichier:<br />\n";
|
||||
$output .= "<input type='text' name='f' value='untitled.html' onfocus=\"this.value=''\" />";
|
||||
$output .= _T('skeleditor:target') . "<br />\n";
|
||||
$output .= "<select name='target'><br />\n";
|
||||
$output .= editor_form_directory($path_list);
|
||||
$output .= "</select><br /><input type='submit' name='sub' value='" . _T('skeleditor:creer') . "' />";
|
||||
$output .= "</form>\n";
|
||||
$output .= fin_block();
|
||||
return $output;
|
||||
}
|
||||
|
||||
// upload file form
|
||||
function skeleditor_uploadfile($path_list) {
|
||||
|
||||
//$output = "<br />".bouton_block_invisible('editor_uploadfile');
|
||||
$output .= "<img src='" . _DIR_PLUGIN_SKELEDITOR . "images/action_add.png' alt='new' />" . _T('skeleditor:fichier_upload');
|
||||
//$output .= debut_block_invisible('editor_uploadfile');
|
||||
|
||||
$output .= "<form method='post' enctype='multipart/form-data' >\n";
|
||||
$output .= "<input type='hidden' name='exec' value='skeleditor' />";
|
||||
$output .= "<input type='hidden' name='operation' value='upload' />";
|
||||
$output .= "<input type='hidden' name='MAX_FILE_SIZE' value='200000' />";
|
||||
$output .= "<input type='file' name='upf'/>";
|
||||
$output .= _T('skeleditor:target') . "<br />\n";
|
||||
$output .= "<select name='target'><br />\n";
|
||||
$output .= editor_form_directory($path_list);
|
||||
$output .= "</select><br /><input type='submit' name='sub' value='" . _T('skeleditor:upload') . "' />";
|
||||
$output .= "</form>\n";
|
||||
$output .= fin_block();
|
||||
return $output;
|
||||
}
|
||||
|
||||
// skeleton parsing (more details: public/phrase_html)
|
||||
function skel_parser($skel_str) {
|
||||
|
||||
include_spip('public/interfaces');
|
||||
include_spip('public/phraser_html');
|
||||
//include_spip("public/debug");
|
||||
|
||||
//$output .= _T('skeleditor:parseur_titre');
|
||||
$output .= "<div style='background: #eef; border:1px solid #eee;padding:10px;font-size:0.82em;font-family:Verdana'>";
|
||||
$boucles = [];
|
||||
$b = public_phraser_html($skel_str, 0, $boucles, 'skel_editor');
|
||||
$boucles = array_reverse($boucles, true);
|
||||
/* parse outside boucles */
|
||||
//$output .= bouton_block_invisible("hors_boucle")._T("skeleditor:parseur_horsboucle");
|
||||
//$output .= debut_block_invisible("hors_boucle");
|
||||
$output .= "<div style='background: #fff;padding:10px;'>";
|
||||
foreach ($b as $k => $val) {
|
||||
if ($val->type == 'champ') {
|
||||
$output .= "<span style='color:#c30;background:#eee'>#" . $val->nom_champ . '</span>';
|
||||
} else {
|
||||
if ($val->type == 'texte') {
|
||||
$output .= "<pre style='background:#ddd;margin:0;display:inline;'> " . htmlspecialchars($val->texte) . '</pre>';
|
||||
} else {
|
||||
if ($val->type == 'include') {
|
||||
$output .= "<span style='color:#30c;background:#cff;'>(INCLURE)</span>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$output .= "</div>\n";
|
||||
$output .= fin_block() . '<br />';
|
||||
/* parse boucles */
|
||||
foreach ($boucles as $k => $val) {
|
||||
/* version gentle */
|
||||
//$output .= bouton_block_invisible("skel_parser_$k")." BOUCLE$k";
|
||||
$output .= " <span style='color:#888'>(" . strtoupper($val->type_requete) . ')</span>';
|
||||
//$output .= debut_block_invisible("skel_parser_$k");
|
||||
$output .= "<div style='background: #fff;padding:10px;'>";
|
||||
if ($val->id_parent) {
|
||||
$output .= "<strong>id_parent:</strong> BOUCLE$val->id_parent<br />";
|
||||
}
|
||||
if ($val->param) {
|
||||
$output .= '<strong>' . _T('skeleditor:parseur_param') . '</strong>' . skel_parser_param($val->param) . '<br />';
|
||||
}
|
||||
$output .= '<strong>' . _T('skeleditor:parseur_contenu') . '</strong><br />';
|
||||
$output .= skel_parser_affiche(_T('skeleditor:parseur_avant'), $val->avant, '#cc9');
|
||||
$output .= skel_parser_affiche(_T('skeleditor:parseur_milieu'), $val->milieu, '#fc6');
|
||||
$output .= skel_parser_affiche(_T('skeleditor:parseur_apres'), $val->apres, '#fcc');
|
||||
$output .= skel_parser_affiche(_T('skeleditor:parseur_altern'), $val->altern, '#cfc');
|
||||
$output .= "</div>\n";
|
||||
$output .= fin_block() . '<br />';
|
||||
/* version brute */
|
||||
/*
|
||||
$output .= "<strong>BOUCLE$k</strong><br />\n";
|
||||
foreach (get_object_vars($val) as $prop => $val2) {
|
||||
$output .= "\t<br />$prop = $val2\n";
|
||||
if (is_array($val2)) {
|
||||
foreach($val2 as $k3=>$val3) {
|
||||
$output .= "\t\t<br>........................$k3 = $val3\n";
|
||||
if (is_object($val3)) {
|
||||
foreach (get_object_vars($val3) as $prop4 => $val4) {
|
||||
$output .= "\t\t<br>+++........................( $prop4 = $val4 )\n";
|
||||
if (is_array($val4 )) {
|
||||
foreach($val4 as $k5=>$val5) {
|
||||
$output .= "\t\t<br>++++++...............$k5 = $val5 )\n";
|
||||
foreach($val5 as $k6=>$val6) {
|
||||
$output .= "\t\t<br>+++++++++++.........$k6 = $val6 )\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
$output .= '</div>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
// affiche le code pour le parseur
|
||||
function skel_parser_affiche($titre, $content, $bgcolor = '#fc6') {
|
||||
|
||||
$output = '';
|
||||
$output .= "<div style='background:$bgcolor'>$titre</div>";
|
||||
foreach ($content as $k => $str) {
|
||||
if ($str->type == 'champ') {
|
||||
$output .= "<span style='color:#c30;background:#eee'>#" . $str->nom_champ . '</span>';
|
||||
} else {
|
||||
if ($str->type == 'texte') {
|
||||
$output .= "<pre style='background:#ddd;margin:0;display:inline;'> " . htmlspecialchars($str->texte) . '</pre>';
|
||||
} else {
|
||||
if ($str->type == 'include') {
|
||||
$output .= "<span style='color:#30c;background:#cff;'>(INCLUDE)</span>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
// parse param value
|
||||
function skel_parser_param($str, $output = '') {
|
||||
|
||||
$output = '';
|
||||
if (is_array($str)) {
|
||||
foreach ($str as $k2 => $val2) {
|
||||
//$output .= ".....$k2=>$val2 ($c)<br />";
|
||||
$output .= skel_parser_param($val2, $output);
|
||||
// recursive
|
||||
}
|
||||
} else {
|
||||
if (is_object($str)) {
|
||||
$output .= ' {' . $str->texte . '} ';
|
||||
/*foreach (get_object_vars($str) as $prop4 => $val4) {
|
||||
$output .= "\t\t<br>...........( $prop4 = $val4 )\n";
|
||||
} */
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
// recupere les plugins de type squelette
|
||||
function get_plugin_squelette() {
|
||||
|
||||
// alternative 1: liste des plugins squelettes manuelle (blip, sarka, ...?)
|
||||
// alternative 2: on scanne les plugins: si article.html et sommaire.html present ? sans doute un plugin squelette
|
||||
$plugin_squelette = [];
|
||||
if ($GLOBALS['plugins']) {
|
||||
foreach ($GLOBALS['plugins'] as $k) {
|
||||
if (@is_file(_DIR_PLUGINS . "$k/article.html") && @is_file(_DIR_PLUGINS . "$k/sommaire.html")) {
|
||||
$plugin_squelette[] = _DIR_PLUGINS . $k . '/';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $plugin_squelette;
|
||||
}
|
||||
|
@ -1,136 +1,124 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin SkelEditor
|
||||
* Editeur de squelette en ligne
|
||||
* (c) depuis 2007 Collectif SPIP
|
||||
* Licence GPL-v3
|
||||
*/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')){
|
||||
return;
|
||||
}
|
||||
|
||||
include_spip('prive/squelettes/contenu/skeleditor_fonctions');
|
||||
|
||||
/**
|
||||
* Afficher l'arborescence du dossier squelette
|
||||
*
|
||||
* @param string $path_base
|
||||
* @param string $current_file
|
||||
* @return string
|
||||
*/
|
||||
function skeleditor_afficher_arborescence($path_base, $current_file){
|
||||
include_spip('inc/skeleditor');
|
||||
|
||||
$icons = [];
|
||||
foreach (['file', 'image'] as $quoi){
|
||||
$icons[$quoi] = chemin_image("se-{$quoi}-16.svg");
|
||||
}
|
||||
$icons['cadenas'] = chemin_image("cadenas-12.svg");
|
||||
|
||||
$balise_img = chercher_filtre('balise_img');
|
||||
|
||||
$file_list = skeleditor_files_editables($path_base);
|
||||
$file_list = skeleditor_sort_directory_first($file_list, $path_base);
|
||||
|
||||
$current_file = substr($current_file, strlen($path_base));
|
||||
|
||||
$output = "<div id='file-browser'><ul class='item-files'>\n";
|
||||
$init_dir = $current_dir = "";
|
||||
|
||||
foreach ($file_list as $file){
|
||||
$dir = substr(dirname($file), strlen($path_base));
|
||||
$file = substr($file, strlen($path_base));
|
||||
|
||||
if ($dir!=$current_dir){
|
||||
$output .= skeleditor_tree_open_close_dir($current_dir, $dir, $current_file);
|
||||
}
|
||||
|
||||
$class = "";
|
||||
|
||||
$icon = "file";
|
||||
if (preg_match(',(' . _SE_EXTENSIONS_IMG . ')$,', $file)){
|
||||
$icon = "image";
|
||||
}
|
||||
|
||||
$class .= " $icon";
|
||||
|
||||
$readonly = false;
|
||||
if (!is_writable($path_base . $dir) or !is_writable($path_base . $file)){
|
||||
$readonly = true;
|
||||
$class .= " readonly";
|
||||
}
|
||||
|
||||
$class .= ($file==$current_file ? " on" : '');
|
||||
|
||||
$cadenas = ($readonly ? " " . (inserer_attribut($balise_img($icons['cadenas'], '16x16'), 'title', attribut_html(_T('texte_inc_meta_2')))) : "");
|
||||
$url = generer_url_ecrire('skeleditor', 'f=' . urlencode($f = $path_base . $file));
|
||||
if ($icon === 'image') {
|
||||
$url .= '&nomediabox';
|
||||
}
|
||||
|
||||
$output .=
|
||||
"<li class='item-file$class'>"
|
||||
. "<a href='$url' onclick=\"jQuery('#contenu > :first').ajaxReload({history:true,args:{f:'$f'}});jQuery('.item-file.on').removeClass('on');jQuery(this).parent().addClass('on');return false;\">"
|
||||
. $balise_img($icons[$icon], $icon, 'picto ' . $icon)
|
||||
. basename($file)
|
||||
. $cadenas
|
||||
. "</a></li>";
|
||||
}
|
||||
|
||||
$output .= skeleditor_tree_open_close_dir($current_dir, $init_dir, $current_file);
|
||||
$output .= "</ul></div>\n";
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gestion de l'ouverture/fermeture des repertoires dans le browser de fichiers
|
||||
* @param string $current
|
||||
* @param string $target
|
||||
* @param string $current_file
|
||||
* @return string
|
||||
*/
|
||||
function skeleditor_tree_open_close_dir(&$current, $target, $current_file){
|
||||
static $icon_folder;
|
||||
if (empty($icon_folder)){
|
||||
$balise_img = chercher_filtre('balise_img');
|
||||
$icon_folder = chemin_image("se-folder-16.svg");
|
||||
$icon_folder = $balise_img($icon_folder, 'directory', 'picto directory');
|
||||
}
|
||||
|
||||
if ($current==$target){
|
||||
return "";
|
||||
}
|
||||
$tcur = explode("/", $current);
|
||||
$ttarg = explode("/", $target);
|
||||
$tcom = array();
|
||||
$output = "";
|
||||
// la partie commune
|
||||
while (reset($tcur)==reset($ttarg)){
|
||||
$tcom[] = array_shift($tcur);
|
||||
array_shift($ttarg);
|
||||
}
|
||||
// fermer les repertoires courant jusqu'au point de fork
|
||||
while ($close = array_pop($tcur)){
|
||||
$output .= "</ul></li>";
|
||||
}
|
||||
|
||||
$chemin = implode("/", $tcom) . "/";
|
||||
|
||||
// ouvrir les repertoires jusqu'a la cible
|
||||
while ($open = array_shift($ttarg)){
|
||||
$chemin .= $open . "/";
|
||||
$closed = ((strncmp($current_file, ltrim($chemin, '/'), strlen(ltrim($chemin, '/')))==0) ? "" : " closed");
|
||||
|
||||
$class = "folder" . ($closed ? '' : ' open');
|
||||
|
||||
$output .=
|
||||
"<li class='item-file directory'>"
|
||||
. "<button class='btn btn_link $class' onclick='jQuery(this).toggleClass(\"open\");'><b class='caret'></b>$icon_folder $open</button>"
|
||||
. "<ul class='item-files'>\n";
|
||||
}
|
||||
$current = $target;
|
||||
return $output;
|
||||
}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Plugin SkelEditor
|
||||
* Editeur de squelette en ligne
|
||||
* (c) depuis 2007 Collectif SPIP
|
||||
* Licence GPL-v3
|
||||
*/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) {
|
||||
return;
|
||||
}
|
||||
|
||||
include_spip('prive/squelettes/contenu/skeleditor_fonctions');
|
||||
/**
|
||||
* Afficher l'arborescence du dossier squelette
|
||||
*
|
||||
* @param string $path_base
|
||||
* @param string $current_file
|
||||
* @return string
|
||||
*/
|
||||
function skeleditor_afficher_arborescence($path_base, $current_file) {
|
||||
|
||||
include_spip('inc/skeleditor');
|
||||
$icons = [];
|
||||
foreach (['file', 'image'] as $quoi) {
|
||||
$icons[$quoi] = chemin_image("se-{$quoi}-16.svg");
|
||||
}
|
||||
$icons['cadenas'] = chemin_image('cadenas-12.svg');
|
||||
$balise_img = chercher_filtre('balise_img');
|
||||
$file_list = skeleditor_files_editables($path_base);
|
||||
$file_list = skeleditor_sort_directory_first($file_list, $path_base);
|
||||
$current_file = substr($current_file, strlen($path_base));
|
||||
$output = "<div id='file-browser'><ul class='item-files'>\n";
|
||||
$init_dir = $current_dir = '';
|
||||
foreach ($file_list as $file) {
|
||||
$dir = substr(dirname($file), strlen($path_base));
|
||||
$file = substr($file, strlen($path_base));
|
||||
if ($dir != $current_dir) {
|
||||
$output .= skeleditor_tree_open_close_dir($current_dir, $dir, $current_file);
|
||||
}
|
||||
|
||||
$class = '';
|
||||
$icon = 'file';
|
||||
if (preg_match(',(' . _SE_EXTENSIONS_IMG . ')$,', $file)) {
|
||||
$icon = 'image';
|
||||
}
|
||||
|
||||
$class .= " $icon";
|
||||
$readonly = false;
|
||||
if (!is_writable($path_base . $dir) or !is_writable($path_base . $file)) {
|
||||
$readonly = true;
|
||||
$class .= ' readonly';
|
||||
}
|
||||
|
||||
$class .= ($file == $current_file ? ' on' : '');
|
||||
$cadenas = ($readonly ? ' ' . (inserer_attribut($balise_img($icons['cadenas'], '16x16'), 'title', attribut_html(_T('texte_inc_meta_2')))) : '');
|
||||
$url = generer_url_ecrire('skeleditor', 'f=' . urlencode($f = $path_base . $file));
|
||||
if ($icon === 'image') {
|
||||
$url .= '&nomediabox';
|
||||
}
|
||||
|
||||
$output .=
|
||||
"<li class='item-file$class'>"
|
||||
. "<a href='$url' onclick=\"jQuery('#contenu > :first').ajaxReload({history:true,args:{f:'$f'}});jQuery('.item-file.on').removeClass('on');jQuery(this).parent().addClass('on');return false;\">"
|
||||
. $balise_img($icons[$icon], $icon, 'picto ' . $icon)
|
||||
. basename($file)
|
||||
. $cadenas
|
||||
. '</a></li>';
|
||||
}
|
||||
|
||||
$output .= skeleditor_tree_open_close_dir($current_dir, $init_dir, $current_file);
|
||||
$output .= "</ul></div>\n";
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gestion de l'ouverture/fermeture des repertoires dans le browser de fichiers
|
||||
* @param string $current
|
||||
* @param string $target
|
||||
* @param string $current_file
|
||||
* @return string
|
||||
*/
|
||||
function skeleditor_tree_open_close_dir(&$current, $target, $current_file) {
|
||||
|
||||
static $icon_folder;
|
||||
if (empty($icon_folder)) {
|
||||
$balise_img = chercher_filtre('balise_img');
|
||||
$icon_folder = chemin_image('se-folder-16.svg');
|
||||
$icon_folder = $balise_img($icon_folder, 'directory', 'picto directory');
|
||||
}
|
||||
|
||||
if ($current == $target) {
|
||||
return '';
|
||||
}
|
||||
$tcur = explode('/', $current);
|
||||
$ttarg = explode('/', $target);
|
||||
$tcom = [];
|
||||
$output = '';
|
||||
// la partie commune
|
||||
while (reset($tcur) == reset($ttarg)) {
|
||||
$tcom[] = array_shift($tcur);
|
||||
array_shift($ttarg);
|
||||
}
|
||||
// fermer les repertoires courant jusqu'au point de fork
|
||||
while ($close = array_pop($tcur)) {
|
||||
$output .= '</ul></li>';
|
||||
}
|
||||
|
||||
$chemin = implode('/', $tcom) . '/';
|
||||
// ouvrir les repertoires jusqu'a la cible
|
||||
while ($open = array_shift($ttarg)) {
|
||||
$chemin .= $open . '/';
|
||||
$closed = ((strncmp($current_file, ltrim($chemin, '/'), strlen(ltrim($chemin, '/'))) == 0) ? '' : ' closed');
|
||||
$class = 'folder' . ($closed ? '' : ' open');
|
||||
$output .=
|
||||
"<li class='item-file directory'>"
|
||||
. "<button class='btn btn_link $class' onclick='jQuery(this).toggleClass(\"open\");'><b class='caret'></b>$icon_folder $open</button>"
|
||||
. "<ul class='item-files'>\n";
|
||||
}
|
||||
$current = $target;
|
||||
return $output;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||