356 lines
7.2 KiB
Text
Executable file
356 lines
7.2 KiB
Text
Executable file
#extends html
|
|
|
|
snippet action "SPIP action declenchee dans un lien"
|
|
<?php
|
|
if (!defined('_ECRIRE_INC_VERSION')) return;
|
|
|
|
function action_`!v vim_snippets#Filename()`_dist(){
|
|
|
|
include_spip('inc/autoriser');
|
|
if (! autoriser("etre","connecte")) {
|
|
return false;
|
|
}
|
|
|
|
$securiser_action = charger_fonction('securiser_action', 'inc');
|
|
$arg = $securiser_action();
|
|
$$1 = $arg;
|
|
list($${1:var1},$${2:var2}) = explode('-', $arg);
|
|
${0}
|
|
|
|
// Cache
|
|
include_spip('inc/invalideur');
|
|
suivre_invalideur("id='$1/$$1'");
|
|
|
|
// redirection sur la création d'un rapport
|
|
//$retour = "spip.php?page=";
|
|
//include_spip('inc/headers');
|
|
//redirige_par_entete($retour);
|
|
}
|
|
endsnippet
|
|
|
|
|
|
snippet action2 "SPIP action ajax à la mano"
|
|
<?php
|
|
if (!defined('_ECRIRE_INC_VERSION')) return;
|
|
|
|
function action_`!v vim_snippets#Filename()`_dist($arg=null){
|
|
|
|
include_spip('inc/autoriser');
|
|
if (! autoriser("etre","connecte")) {
|
|
return false;
|
|
}
|
|
|
|
if (is_null($arg)) {
|
|
// DEMI sécurité : s'il y a un hash, on teste la sécurité
|
|
if (_request('hash')) {
|
|
$securiser_action = charger_fonction('securiser_action', 'inc');
|
|
$arg = $securiser_action();
|
|
}
|
|
// Sinon, on prend l'arg direct
|
|
else {
|
|
$arg = _request('arg');
|
|
}
|
|
}
|
|
$${1:var} = $arg;
|
|
${0}
|
|
|
|
// on renvoit le test en variable js
|
|
$js = "var $1=$$1;";
|
|
header('Content-Type: text/javascript; charset=' . $GLOBALS['meta']['charset']);
|
|
echo $js;
|
|
}
|
|
endsnippet
|
|
|
|
snippet cvt "SPIP"
|
|
<?php
|
|
if (!defined('_ECRIRE_INC_VERSION')) return;
|
|
|
|
function formulaires_`!v vim_snippets#Filename()`_charger_dist($${1:variables}){
|
|
$valeurs = array(
|
|
"${2:nom_du_champ}" => ${3:""},
|
|
);
|
|
${0}
|
|
return $valeurs;
|
|
}
|
|
|
|
function formulaires_`!v vim_snippets#Filename()`_verifier_dist($$1){
|
|
$$2 = _request('$2');
|
|
|
|
$erreurs = array();
|
|
//champs obligatoire
|
|
foreach (array ('$2') as $obligatoire) {
|
|
if (!_request($obligatoire)) $erreurs[$obligatoire] = 'Ce champs est obligatoire';
|
|
}
|
|
|
|
//autres erreurs
|
|
$erreurs['$2'] = "Ce champ ne convient pas.";
|
|
|
|
//Il y a des erreurs
|
|
if (count($erreurs)) {
|
|
$erreurs['message_erreur'] = 'Votre saisie contient des erreurs !';
|
|
}
|
|
|
|
return $erreurs;
|
|
}
|
|
|
|
function formulaires_`!v vim_snippets#Filename()`_traiter_dist($$1){
|
|
$$2 = _request('$2');
|
|
|
|
$retour = array();
|
|
$retour['message_ok'] = "bravo";
|
|
$retour['redirect'] = "spip.php?page=perdu";
|
|
$retour['editable'] = true;
|
|
|
|
return $retour;
|
|
}
|
|
endsnippet
|
|
|
|
|
|
|
|
|
|
snippet bigint "SQL bigint(21)" w
|
|
'bigint(${1:21}) NOT NULL',${0}
|
|
endsnippet
|
|
|
|
snippet float "SQL float" w
|
|
'float NOT NULL',${0}
|
|
endsnippet
|
|
|
|
snippet tinyint "SQL tinyint(4)" w
|
|
'tinyint(4) NOT NULL',${0}
|
|
endsnippet
|
|
|
|
snippet decimal "SQL decimal(10,2)" w
|
|
'decimal(10,2) DEFAULT "0" NOT NULL',${0}
|
|
endsnippet
|
|
|
|
snippet text "SQL text NOT NULL" w
|
|
'text NOT NULL DEFAULT ""',${0}
|
|
endsnippet
|
|
|
|
snippet varchar "SQL varchar(25)" w
|
|
'varchar(${1:255}) NOT NULL DEFAULT ""',${0}
|
|
endsnippet
|
|
|
|
snippet datetime "SQL datetime" w
|
|
'datetime NOT NULL DEFAULT "0000-00-00 00:00:00"',${0}
|
|
endsnippet
|
|
|
|
|
|
snippet php
|
|
<?php
|
|
|
|
${0}
|
|
endsnippet
|
|
|
|
snippet php2 "SPIP php"
|
|
<?php
|
|
if (!defined('_ECRIRE_INC_VERSION')){
|
|
return;
|
|
}
|
|
|
|
|
|
${0}
|
|
endsnippet
|
|
|
|
snippet testauto "SPIP"
|
|
include_spip('inc/autoriser');
|
|
if (! autoriser("${1:action}","${2:objet}")) {
|
|
return false;
|
|
}
|
|
${0}
|
|
endsnippet
|
|
|
|
snippet creer_autorisation "cretion fonction autorisation"
|
|
function autoriser_${1:objet}_${2:action}_dist($faire, $type, $id, $qui, $opt) {
|
|
return in_array($qui['statut'], array('0minirezo'));
|
|
}
|
|
${0}
|
|
endsnippet
|
|
|
|
snippet id_auteur_session "$GLOBALS['visiteur_session']['id_auteur']"
|
|
$GLOBALS['visiteur_session']['id_auteur']${0}
|
|
endsnippet
|
|
|
|
snippet date_php "SPIP date('Y-m-d H:i:s')" w
|
|
date("Y-m-d H:i:s")${0}
|
|
endsnippet
|
|
|
|
snippet ll "SPIP chaine de langue" w
|
|
_T('${1:prefix}:${2}')${0}
|
|
endsnippet
|
|
|
|
snippet api_objet "SPIP API Objet"
|
|
// utilisation API editer_objet pour l'insertion en BDD'
|
|
// http://www.spip.net/fr_article5526.html
|
|
include_spip('action/editer_objet');
|
|
$objet = "${1:article}";
|
|
|
|
$set = array (
|
|
'${1:champs1}' => $${2:valeur_champs1},
|
|
'${3:champs2}' => $${4:valeur_champs2},
|
|
);
|
|
$id_objet = objet_inserer($objet, $id_parent);
|
|
//ou $id_objet=$ma_variable;
|
|
|
|
objet_modifier($objet, $id_objet, $set);
|
|
endsnippet
|
|
|
|
snippet api_lien "SPIP API Lien"
|
|
// utilisation API editier_liens
|
|
// http://www.spip.net/fr_article5477.html
|
|
include_spip('action/editer_liens');
|
|
|
|
$objets_source = array("${1:auteur}"=>${2:id_auteur ou array});
|
|
$objets_lies = array("${3:article}"=>${:id_article ou array});
|
|
${0}
|
|
|
|
objet_associer($objets_source, $objets_lies);
|
|
endsnippet
|
|
|
|
snippet cache "SPIP invalide cache"
|
|
include_spip('inc/invalideur');
|
|
suivre_invalideur("id='${1:id_objet}/1'");
|
|
${0}
|
|
endsnippet
|
|
|
|
snippet req "SPIP _request()" w
|
|
_request('${1}')${0}
|
|
endsnippet
|
|
|
|
snippet array "SPIP Array( X lignes)" w
|
|
array(
|
|
'${1}' => ${2},${0}
|
|
);
|
|
endsnippet
|
|
|
|
snippet array_ligne "SPIP Une ligne d'array"
|
|
'${1:var}' => $$1,${0}
|
|
endsnippet
|
|
|
|
snippet vd "var_dump()"
|
|
var_dump($${1:var});
|
|
${0}
|
|
endsnippet
|
|
|
|
snippet ec "Echo"
|
|
echo ${1};
|
|
${0}
|
|
endsnippet
|
|
|
|
snippet pre "<pre> print_r"
|
|
echo "<pre>";
|
|
print_r($${1});
|
|
echo "</pre>";
|
|
${0}
|
|
endsnippet
|
|
|
|
snippet include "SPIP include_spip"
|
|
include_spip('${1:fichier}');
|
|
${0}
|
|
endsnippet
|
|
|
|
snippet pipeline "SPIP Les pipelines de base"
|
|
/**
|
|
* Charger des styles CSS
|
|
*
|
|
* @pipeline insert_head_css
|
|
* @param string $flux Code html des styles CSS à charger
|
|
* @return string Code html complété
|
|
**/
|
|
function ${1:prefix}_insert_head_css($flux){
|
|
$flux .= '<link rel="stylesheet" href="' . produire_fond_statique('css/vignettes.css') . '" type="text/css" />' . "\n";
|
|
$flux .= '<link rel="stylesheet" href="' . timestamp(find_in_path('css/bigup.css')) . '" type="text/css" />' . "\n";
|
|
return $flux;
|
|
}
|
|
${0}
|
|
/**
|
|
* Charger des scripts jquery
|
|
*
|
|
* @pipeline jqueryui_plugins
|
|
* @param array $scripts Liste à charger
|
|
* @return array Liste complétée
|
|
**/
|
|
function $1_jquery_plugins($scripts){
|
|
$scripts[] = "aa";
|
|
$scripts[] = produire_fond_statique('javascript/bigup.js');
|
|
return $scripts;
|
|
}
|
|
|
|
/**
|
|
* Charger des scripts jquery ui
|
|
*
|
|
* @pipeline jqueryui_plugins
|
|
* @param array $scripts Liste à charger
|
|
* @return array Liste complétée
|
|
**/
|
|
function $1_jqueryui_plugins($scripts){
|
|
$scripts[] = "aa";
|
|
return $scripts;
|
|
}
|
|
endsnippet
|
|
|
|
snippet debugspip "SPIP define de debug"
|
|
function debug_spip(){
|
|
define('_DEBUG_SLOW_QUERIES', true);
|
|
define('_BOUCLE_PROFILER', 5000);
|
|
define('_LOG_FILTRE_GRAVITE', 8);
|
|
define('_LOG_FILELINE',true);
|
|
define('_DEBUG_AUTORISER', true);
|
|
define('_MAX_LOG', 500000);
|
|
|
|
error_reporting(E_ALL^E_NOTICE);
|
|
ini_set ("display_errors", "On");
|
|
ini_set("html_errors", "On");
|
|
ini_set("allow_url_fopen", "On");
|
|
define('SPIP_ERREUR_REPORT',E_ALL^E_NOTICE);
|
|
define('SPIP_ERREUR_REPORT_INCLUDE_PLUGINS',E_ALL^E_NOTICE);
|
|
|
|
|
|
define('_NO_CACHE', -1);
|
|
define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true);
|
|
}
|
|
|
|
if ( $_SERVER['SERVER_ADDR'] === "127.0.0.1") {
|
|
debug_spip();
|
|
}
|
|
|
|
if ( substr($_SERVER['SERVER_ADDR'],0,7) === "192.168") {
|
|
debug_spip();
|
|
}
|
|
endsnippet
|
|
|
|
snippet /*
|
|
/**
|
|
* ${0}
|
|
**/
|
|
endsnippet
|
|
|
|
snippet doc
|
|
/**
|
|
* ${1:function non documente}
|
|
*
|
|
* @param ${2}
|
|
* @return ${0}
|
|
* @author tofulm
|
|
**/
|
|
endsnippet
|
|
|
|
# Function doc
|
|
snippet fdoc
|
|
/**
|
|
* ${4:fonction non documente}
|
|
*
|
|
* @param ${5}
|
|
* @return ${3}
|
|
* @author tofulm
|
|
**/
|
|
function ${1}(${2}){
|
|
${6}
|
|
}
|
|
endsnippet
|
|
|
|
snippet spip_log "SPIP fctn spip_log()"
|
|
spip_log(${1},${2:"gamuza"});
|
|
${0}
|
|
endsnippet
|