Browse Source

trunk / branches

v1
bruno@eliaz.fr 4 years ago
commit
e89f27692f
  1. 38
      .gitattributes
  2. 150
      action/editer_legende.php
  3. 19
      action/supprimer_legende.php
  4. 41
      base/legendes.php
  5. 3
      editer_legende.html
  6. 12
      fonds/cfg_legendes.html
  7. 36
      formulaires/configurer_legendes.html
  8. 44
      formulaires/editer_legende.html
  9. 62
      formulaires/editer_legende.php
  10. BIN
      images/edit-note.png
  11. BIN
      images/legendes-128.png
  12. BIN
      images/legendes-24.png
  13. BIN
      images/loader.gif
  14. BIN
      images/new.png
  15. 519
      javascript/jquery.annotate.js
  16. 10
      lang/legendes.xml
  17. 40
      lang/legendes_en.php
  18. 38
      lang/legendes_fr.php
  19. 40
      lang/legendes_pt_br.php
  20. 9
      lang/paquet-legendes.xml
  21. 16
      lang/paquet-legendes_en.php
  22. 14
      lang/paquet-legendes_fr.php
  23. 16
      lang/paquet-legendes_pt_br.php
  24. 38
      legendes.css
  25. 32
      legendes.html
  26. 25
      legendes_administrations.php
  27. 82
      legendes_autoriser.php
  28. 7
      legendes_fonctions.php
  29. 5
      legendes_get.html
  30. 5
      legendes_get_edit.html
  31. 63
      legendes_pipelines.php
  32. 6
      liste_legende.html
  33. 8
      modeles/emb_legendes.html
  34. 62
      modeles/image_legendes.html
  35. 2
      modeles/legende_auteur.html
  36. 29
      paquet.xml
  37. 61
      plugin.xml
  38. 6
      prive/squelettes/contenu/configurer_legendes.html

38
.gitattributes vendored

@ -0,0 +1,38 @@
* text=auto !eol
action/editer_legende.php -text
action/supprimer_legende.php -text
base/legendes.php -text
/editer_legende.html -text
fonds/cfg_legendes.html -text
formulaires/configurer_legendes.html -text
formulaires/editer_legende.html -text
formulaires/editer_legende.php -text
images/edit-note.png -text
images/legendes-128.png -text
images/legendes-24.png -text
images/loader.gif -text
images/new.png -text
javascript/jquery.annotate.js -text
lang/legendes.xml -text
lang/legendes_en.php -text
lang/legendes_fr.php -text
lang/legendes_pt_br.php -text
lang/paquet-legendes.xml -text
lang/paquet-legendes_en.php -text
lang/paquet-legendes_fr.php -text
lang/paquet-legendes_pt_br.php -text
/legendes.css -text
/legendes.html -text
/legendes_administrations.php -text
/legendes_autoriser.php -text
/legendes_fonctions.php -text
/legendes_get.html -text
/legendes_get_edit.html -text
/legendes_pipelines.php -text
/liste_legende.html -text
modeles/emb_legendes.html -text
modeles/image_legendes.html -text
modeles/legende_auteur.html -text
/paquet.xml -text
/plugin.xml -text
prive/squelettes/contenu/configurer_legendes.html -text

150
action/editer_legende.php

@ -0,0 +1,150 @@
<?php
/**
* Plugin Canevas pour Spip 2.0
* Licence GPL
*
*
*/
if (!defined("_ECRIRE_INC_VERSION")) return;
function action_editer_legende_dist(){
$securiser_action = charger_fonction('securiser_action', 'inc');
$arg = $securiser_action();
// si id_legende n'est pas un nombre, c'est une creation
if (!$id_legende = intval($arg)) {
$id_document = _request('id_document');
if (!$id_legende = legendes_action_insert_legende($id_document))
return array(false,_L('echec'));
}
$err = action_legende_set($id_legende);
return array($id_legende,$err);
}
function action_legende_set($id_legende){
$err = '';
$c = array();
$c['posy'] = _request('top');
$c['posx'] = _request('left');
$c['width'] = _request('width');
$c['height'] = _request('height');
$c['texte'] = _request('texte');
$c['id_document'] = _request('id_document');
include_spip('inc/modifier');
$err .= legendes_action_revision_legende($id_legende, $c);
return $err;
}
// creer une nouvelle legende
function legendes_action_insert_legende($id_document){
include_spip('inc/autoriser');
if (!autoriser('creerdans','legende',$id_document))
return false;
$champs = array(
'id_document' => $id_document,
'id_auteur' => $GLOBALS['visiteur_session']['id_auteur'],
'date' => date('Y-m-d H:i:s'));
// Envoyer aux plugins
$champs = pipeline('pre_insertion',
array(
'args' => array(
'table' => 'spip_legendes',
),
'data' => $champs
)
);
$id_legende = sql_insertq("spip_legendes", $champs);
if (!$id_legende){
spip_log("legendes action insert legende : impossible d'ajouter une legende");
return false;
}
return $id_legende;
}
// enregistrer une revision de legende
function legendes_action_revision_legende ($id_legende, $c=false) {
include_spip('inc/autoriser');
if (!autoriser('modifier', 'legende', $id_legende)){
spip_log("editer_legende $id_legende refus " . join(' ', $c));
return false;
}
modifier_contenu('legende', $id_legende, array(
'invalideur' => "id='id_legende/$id_legende'"
), $c);
return ''; // pas d'erreur
}
// supprimer une legende
function legendes_action_supprime_legende($id_legende){
include_spip('inc/autoriser');
if (!autoriser('supprimer','legende',$id_legende))
return false;
if (intval($id_legende)){
sql_delete("spip_legendes", "id_legende=".intval($id_legende));
}
$id_legende = 0;
return $id_legende;
}
// tourner une legende
function legendes_action_tourner_legende($id_legende,$angle){
// recuperer les infos dela note à tourner
$legende = sql_fetsel('*','spip_legendes','id_legende='.intval($id_legende));
$c = array();
foreach($legende as $key=>$val)
$c[$key] = $val;
$n = array();
// recuperer les infos de l'image associee
$image = sql_fetsel('*','spip_documents','id_document='.intval($c['id_document']));
$largeur = $image['largeur'];
$hauteur = $image['hauteur'];
include_spip('inc/modifier');
if($angle==0){
return '';
}
if($angle==-90){
$n['posx'] = $c['posy'];
$n['posy'] = $hauteur - ($c['posx'] + $c['width']);
$n['width'] = $c['height'];
$n['height'] = $c['width'];
$err .= legendes_action_revision_legende($id_legende, $n);
}
if($angle==90){
$n['posx'] = $largeur - ($c['posy'] + $c['height']);
$n['posy'] = $c['posx'];
$n['width'] = $c['height'];
$n['height'] = $c['width'];
$err .= legendes_action_revision_legende($id_legende, $n);
}
if($angle==180){
$n['posx'] = $largeur - ($c['posx'] + $c['width']);
$n['posy'] = $hauteur - ($c['posy'] + $c['height']);
$n['width'] = $c['width'];
$n['height'] = $c['height'];
$err .= legendes_action_revision_legende($id_legende, $n);
}
return $err;
}
?>

19
action/supprimer_legende.php

@ -0,0 +1,19 @@
<?php
if (!defined("_ECRIRE_INC_VERSION")) return;
function action_supprimer_legende_dist(){
$securiser_action = charger_fonction('securiser_action', 'inc');
$arg = $securiser_action();
list($id_legende) = preg_split(',[^0-9],',$arg);
include_spip('inc/autoriser');
if (intval($id_legende) AND autoriser('supprimer','legende',$id_legende,null,null)){
include_spip("action/editer_legende");
legendes_action_supprime_legende($id_legende);
}
}
?>

41
base/legendes.php

@ -0,0 +1,41 @@
<?php
if (!defined("_ECRIRE_INC_VERSION")) return;
function legendes_declarer_tables_interfaces($interface){
// 'spip_' dans l'index de $tables_principales
// pour pouvoir faires des BOUCLES(LEGENDES)
$interface['table_des_tables']['legendes']='legendes';
return $interface;
}
function legendes_declarer_tables_principales($tables_principales){
//-- Table LEGENDES ------------------------------------------
$legendes = array(
"id_legende" => "bigint(21) NOT NULL",
"id_document" => "bigint(21) NOT NULL DEFAULT '0'",
"id_auteur" => "bigint(21) NOT NULL DEFAULT '0'",
"posx" => "bigint(21) NOT NULL DEFAULT '0'",
"posy" => "bigint(21) NOT NULL DEFAULT '0'",
"width" => "bigint(21) NOT NULL DEFAULT '0'",
"height"=> "bigint(21) NOT NULL DEFAULT '0'",
"texte" => "text NOT NULL",
"date" => "datetime NOT NULL DEFAULT '0000-00-00 00:00:00'"
);
$legendes_key = array(
"PRIMARY KEY" => "id_legende",
"KEY id_document"=> "id_document",
"KEY id_auteur" => "id_auteur"
);
$tables_principales['spip_legendes'] = array(
'field' => &$legendes,
'key' => &$legendes_key
);
return $tables_principales;
}
?>

3
editer_legende.html

@ -0,0 +1,3 @@
#CACHE{0}
#HTTP_HEADER{Content-Type: text/html; charset=#CHARSET}
#FORMULAIRE_EDITER_LEGENDE{#ENV{id_legende,nouveau},#ENV{id_document},#ENV{retour}}

12
fonds/cfg_legendes.html

@ -0,0 +1,12 @@
<!-- titre=<:legendes:cfg_titre_legendes:> -->
<!-- descriptif=<:legendes:cfg_descr_legendes:> -->
<!-- boite=<:legendes:cfg_titre_legendes:> -->
<!-- autoriser=webmestre -->
<!-- refus=<:cfg:refus_configuration_webmestre:> -->
<!-- logo=images/legendes-128.png -->
<!-- icone=images/legendes-24.png -->
#CACHE{0}
<div class="ajax">
#FORMULAIRE_CONFIGURER_LEGENDES
</div>

36
formulaires/configurer_legendes.html

@ -0,0 +1,36 @@
<!-- autoriser=webmestre -->
<!-- refus=<:cfg:refus_configuration_webmestre:> -->
<!-- nom=legendes -->
<div class="formulaire_spip formulaire_config formulaire_configurer formulaire_#FORM">
[<p class="reponse_formulaire reponse_formulaire_ok">(#ENV*{message_ok})</p>]
[<p class="reponse_formulaire reponse_formulaire_erreur">(#ENV*{message_erreur})</p>]
<form method="post" action="#SELF">
<div>
#ACTION_FORMULAIRE{SELF}
<ul>
<li class="fieldset">
<fieldset>
<h3 class="legend"><:legendes:cfg_legend_statuts:></h3>
<p class="explication"><:legendes:explications_statuts_general:></p>
<ul>
[(#SAISIE{statuts_auteurs,statuts_creerdans,
cacher_option_intro=oui,
label=<:legendes:autoriser_creerdans:>})]
[(#SAISIE{statuts_auteurs,statuts_modifier,
cacher_option_intro=oui,
label=<:legendes:autoriser_modifier:>})]
[(#SAISIE{statuts_auteurs,statuts_supprimer,
cacher_option_intro=oui,
label=<:legendes:autoriser_supprimer:>})]
</ul>
</fieldset>
</li>
</ul>
<p class="boutons">
<input type="submit" value="<:bouton_enregistrer:>" class="submit" />
</p>
</div>
</form>
</div>

44
formulaires/editer_legende.html

@ -0,0 +1,44 @@
<div class="ajax formulaire_spip formulaire_editer_legende" id="formulaire_editer_legende#ENV{id_legende,nouveau}">
<br class="bugajaxie" />
[<p class="reponse_formulaire reponse_formulaire_ok">(#ENV*{message_ok})</p>]
[<p class="reponse_formulaire reponse_formulaire_erreur">(#ENV*{message_erreur})</p>]
[(#ENV{editable})
<form method="post" action="#ENV{action}">
[(#REM) declarer les hidden qui declencheront le service du formulaire parametre : url d'action ]
#ACTION_FORMULAIRE{#ENV{action}}
<input type="hidden" name="top" value="#ENV{posy}" />
<input type="hidden" name="left" value="#ENV{posx}" />
<input type="hidden" name="width" value="#ENV{width}" />
<input type="hidden" name="height" value="#ENV{height}" />
[<input type="hidden" name="id_legende" value="(#ENV*{id_legende})" />]
[<input type="hidden" name="id_document" value="(#ENV*{id_document})" />]
<fieldset>
<legend><:legendes:editer_legende:></legend>
<ul class="editer-groupe">
<li class="editer saisie_texte obligatoire[ (#ENV*{erreurs}|table_valeur{texte}|oui)erreur]">
<label for="texte#ENV{id_legende}"><:legendes:texte_legende:></label>
[<span class="erreur_message">(#ENV*{erreurs}|table_valeur{texte_legende})</span>]
<textarea name="texte" id="texte#ENV{id_legende}" class="no_barre" rows="8" cols="60">#ENV{texte}</textarea>
</li>
</ul>
</fieldset>
<p class="boutons">
<input type="submit" class="submit" name="valider" value="<:bouton_enregistrer:>" />[
(#ENV{id_legende}|intval|oui)
[(#AUTORISER{supprimer,legende,#ENV{id_legende}}|oui)
<input type="submit" class="submit" name="effacer" value="<:legendes:bouton_supprimer:>" />]]
<input type="reset" class="submit" name="annuler" value="<:bouton_annuler:>" />
</p>
</form>]
</div>
[(#ENV*{message_ok}|oui)
<script type="text/javascript">
if (window.jQuery)
(function($){
$(function(){
var annotateEdit = $('#legende_[(#ENV*{id_document})]').getannotateEdit();
annotateEdit.image.mode = 'view';
annotateEdit.destroy();
});
})(jQuery);
</script>]

62
formulaires/editer_legende.php

@ -0,0 +1,62 @@
<?php
if (!defined("_ECRIRE_INC_VERSION")) return;
include_spip('inc/actions');
include_spip('inc/editer');
include_spip('inc/autoriser');
function formulaires_editer_legende_charger_dist($id_legende='new', $id_document='', $retour=''){
$row = sql_fetsel('*','spip_legendes','id_legende='.intval($id_legende));
$valeurs = formulaires_editer_objet_charger('legende',$id_legende,0,0,$retour,'',$row,$hidden);
if (intval($id_legende)){
foreach($row as $key=>$val)
$valeurs[$key] = $val;
}else{
$valeurs['id_document'] = $id_document;
}
$valeurs['editable'] = true;
return $valeurs;
}
function formulaires_editer_legende_verifier_dist($id_legende='new', $id_document='', $retour=''){
$erreurs = array();
return $erreurs;
}
function formulaires_editer_legende_traiter_dist($id_legende='new', $id_document='', $retour=''){
$message = array('editable'=>true, 'message_ok'=>'');
if (_request('effacer')) {
include_spip("action/editer_legende");
legendes_action_supprime_legende($id_legende);
$message['message_ok'] = _T("legendes:legende_supprimer_ok");
}
if (_request('valider')) {
$action_editer = charger_fonction("editer_legende",'action');
list($id,$err) = $action_editer();
$message['message_ok'] = _T("legendes:legende_enregistrer_ok");
set_request('id_legende',$id);
if ($err){
$message .= $err;
}
elseif ($retour) {
include_spip('inc/headers');
//$retour = parametre_url($retour,'id_legende',$id);
$message .= redirige_formulaire($retour);
}
}
return $message;
}
?>

BIN
images/edit-note.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 487 B

BIN
images/legendes-128.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
images/legendes-24.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

BIN
images/loader.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 847 B

BIN
images/new.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

519
javascript/jquery.annotate.js

@ -0,0 +1,519 @@
/// <reference path="jquery-1.2.6-vsdoc.js" />
(function($) {
$.fn.annotateImage = function(options) {
/// <summary>
/// Creates annotations on the given image.
/// Images are loaded from the "getUrl" propety passed into the options.
/// </summary>
var opts = $.extend({}, $.fn.annotateImage.defaults, options);
var image = this;
this.image = this;
this.mode = 'view';
// Add a reverse reference to the DOM object
var $annotateImage = $(this);
$annotateImage.data("annotateImage", this);
// Assign defaults
this.getUrl = opts.getUrl;
this.editUrl = opts.editUrl;
this.listUrl = opts.listUrl;
this.listtarget = opts.listtarget;
this.addButton = opts.addButton;
this.id_document = opts.id_document;
this.echelle = opts.echelle;
this.editable = opts.editable;
this.useAjax = opts.useAjax;
this.notes = opts.notes;
// Add the canvas
this.canvas = $('<div class="image-annotate-canvas"><div class="image-annotate-view"></div><div class="image-annotate-edit"><div class="image-annotate-edit-area"><div class="inner"></div></div></div></div>');
this.canvas.children('.image-annotate-edit').hide();
this.canvas.children('.image-annotate-view').hide();
this.image.after(this.canvas);
// Give the canvas and the container their size and background
this.canvas.height(this.height());
this.canvas.width(this.width());
this.canvas.css('background-image', 'url("' + this.attr('src') + '")');
this.canvas.children('.image-annotate-view, .image-annotate-edit').height(this.height());
this.canvas.children('.image-annotate-view, .image-annotate-edit').width(this.width());
// Add the behavior: hide/show the notes when hovering the picture
this.canvas.hover(function() {
if ($(this).children('.image-annotate-edit').css('display') == 'none') {
$(this).children('.image-annotate-view').show();
}
}, function() {
$(this).children('.image-annotate-view').hide();
});
this.canvas.children('.image-annotate-view').hover(function() {
$(this).show();
}, function() {
$(this).hide();
});
// load the notes
if (this.useAjax) {
$.fn.annotateImage.ajaxLoad(this);
} else {
$.fn.annotateImage.load(this);
}
// Add the "Add a note" button
if (this.editable) {
if (!this.addButton) {
this.button = $('<a class="image-annotate-add" id="image-annotate-add" href="#">Ajouter une note</a>');
this.canvas.after(this.button);
}else{
this.button = $(this.addButton);
}
this.button.click(function() {
$.fn.annotateImage.add(image);
return false;
});
}
if(this.listtarget){
if(($(this.listtarget).html().length == 0) && ($(this.listtarget).not(':hidden'))){
$(this.listtarget).addClass('annotate-hide').hide();
}
}
// Hide the original
this.hide();
return this;
};
/// This function breaks the chain, but returns
/// the annotateImage if it has been attached to the object.
$.fn.getannotateImage = function(){
return this.data("annotateImage");
}
/**
* Plugin Defaults
**/
$.fn.annotateImage.defaults = {
getUrl: '',
editUrl: '',
listUrl: '',
listtarget:null,
addButton: '',
id_document: '0',
echelle: '1',
editable: true,
useAjax: true,
notes: new Array()
};
$.fn.annotateImage.clear = function(image) {
/// <summary>
/// Clears all existing annotations from the image.
/// </summary>
image.canvas.children('.image-annotate-view').children('.image-annotate-area').remove();
image.notes = new Array();
};
$.fn.annotateImage.ajaxLoad = function(image) {
/// <summary>
/// Loads the annotations from the "getUrl" property passed in on the
/// options object.
/// </summary>
$.getJSON(image.getUrl, function(data) {
if (data)
image.notes = data;
$.fn.annotateImage.load(image);
});
};
$.fn.annotateImage.ajaxDestroy = function(image){
/// <summary>
/// Loads an html content from the "listUrl" inside an jQuery selector target "listtarget"
/// </summary>
if(image.listUrl && image.listtarget){
$.get(image.listUrl, function(data) {
image.listtarget.html(data);
if($(image.listtarget).hasClass('annotate-hide')){
$(image.listtarget).removeClass('annotate-hide').slideDown();
}else if((data.length == 0) && ($(image.listtarget).not(':hidden'))){
$(image.listtarget).addClass('annotate-hide').slideUp();
}
});
}
}
$.fn.annotateImage.load = function(image) {
/// <summary>
/// Loads the annotations from the notes property passed in on the
/// options object.
/// </summary>
for (var i = 0; i < image.notes.length; i++) {
image.notes[image.notes[i]] = new $.fn.annotateView(image, image.notes[i]);
}
};
$.fn.annotateImage.add = function(image) {
/// <summary>
/// Adds a note to the image.
/// </summary>
if (image.mode == 'view') {
image.mode = 'edit';
// Create/prepare the editable note elements
var editable = new $.fn.annotateEdit(image);
$.fn.annotateImage.saveForm(editable, image);
$.fn.annotateImage.cancelForm(editable, image);
}
};
$.fn.annotateImage.saveForm = function(editable, image, note) {
/// <summary>
/// valider le formulaire de la legende
/// </summary>
var ok = $('#image-annotate-edit-form form input[name=valider]');
ok.click(function() {
var form = $('#image-annotate-edit-form form');
var text = $('#image-annotate-edit-form form textarea[name=texte]').val();
$.fn.annotateImage.updatePosition(form, editable);
// destroy est appelé depuis le formulaire CVT après son rechargement ajax
// on recharge aussi les notes au retour du formulaire
});
};
$.fn.annotateImage.cancelForm = function(editable, image) {
/// <summary>
/// annuler le formulaire de la legende
/// </summary>
var cancel = $('#image-annotate-edit-form form input[name=annuler]');
cancel.click(function() {
editable.destroy('cancel');
image.mode = 'view';
});
};
// recuperer le formulaire en ajax synchrone
$.fn.annotateGetForm = function(editurl,id,id_document) {
var ret;
$.ajax({
url: editurl,
data:{id_legende: id,id_document: id_document},
dataType: "html",
async: false,
success:function(c) {
ret = c;
}
});
return ret;
};
$.fn.annotateEdit = function(image, note) {
/// <summary>
/// Defines an editable annotation area.
/// </summary>
this.image = image;
// Add a reverse reference to the DOM object
var $annotateEdit = $(image);
$annotateEdit.data("annotateEdit", this);
if (note) {
this.note = note;
} else {
var newNote = new Object();
newNote.id = "new";
newNote.top = parseInt((this.image.height()/5)/this.image.echelle);
newNote.left = parseInt((this.image.width()/5)/this.image.echelle);
newNote.width = parseInt((this.image.width()/5)/this.image.echelle);
newNote.height = parseInt((this.image.height()/5)/this.image.echelle);
newNote.text = "";
newNote.id_document = this.image.id_document;
this.note = newNote;
}
// Set area
var area = image.canvas.children('.image-annotate-edit').children('.image-annotate-edit-area');
this.area = area;
this.area.css('height', parseInt(this.note.height*this.image.echelle) + 'px');
this.area.css('width', parseInt(this.note.width*this.image.echelle) + 'px');
this.area.css('left', parseInt(this.note.left*this.image.echelle) + 'px');
this.area.css('top', parseInt(this.note.top*this.image.echelle) + 'px');
// Show the edition canvas and hide the view canvas
image.canvas.children('.image-annotate-view').hide();
image.canvas.children('.image-annotate-edit').show();
// on indique que ça charge
this.area.addClass('loading').css('opacity',0.8);
// Add the note (which we'll load with the form afterwards)
//var form = $('<div id="image-annotate-edit-form"><form><textarea id="image-annotate-text" name="text" rows="3" cols="30">' + this.note.text + '</textarea></form></div>');
var form = $('<div id="image-annotate-edit-form"></div>');
this.form = form;
this.form.css('left', this.area.offset().left + 'px');
this.form.css('top', (parseInt(this.area.offset().top) + parseInt(this.area.height()) + 2) + 'px');
// Set the area as a draggable/resizable element contained in the image canvas.
// Would be better to use the containment option for resizable but buggy
area.resizable({
handles: 'all',
resize: function(e, ui) {
if (parseInt(area.position().top) + parseInt(area.height()) + 2 > parseInt(image.canvas.height())) {
area.height(parseInt(image.canvas.height()) - parseInt(area.position().top) - 2);
}
if (parseInt(area.position().left) + parseInt(area.width()) + 2 > parseInt(image.canvas.width())) {
area.width(parseInt(image.canvas.width()) - parseInt(area.position().left) - 2);
}
if (parseInt(area.position().top) < 0) {
area.height(parseInt(image.canvas.height())).css('top', 0);
}
if (parseInt(area.position().left) < 0) {
area.width(parseInt(image.canvas.width())).css('left', 0);
}
form.css('left', area.offset().left + 'px');
form.css('top', (parseInt(area.offset().top) + parseInt(area.height()) + 2) + 'px');
},
stop: function(e, ui) {
form.css('left', area.offset().left + 'px');
form.css('top', (parseInt(area.offset().top) + parseInt(area.height()) + 2) + 'px');
}
})
.draggable({
containment: image.canvas,
drag: function(e, ui) {
form.css('left', ui.offset.left + 'px');
form.css('top', (parseInt(ui.offset.top) + parseInt(area.height()) + 2) + 'px');
},
stop: function(e, ui) {
form.css('left', ui.offset.left + 'px');
form.css('top', (parseInt(ui.offset.top) + parseInt(area.height()) + 2) + 'px');
}
});
// on aplique formulaire_dyn_ajax() de ajaxcallback.js pour activer l'ajax du CVT
this.form.append($.fn.annotateGetForm(this.image.editUrl, this.note.id, this.note.id_document))
.children('div.ajax').formulaire_dyn_ajax();
$('body').append(this.form);
// chargement terminé on vire la classe css et l'opacité
this.area.removeClass('loading').css('opacity',1);
return this;
};
/// This function breaks the chain, but returns
/// the annotateEdit if it has been attached to the object.
$.fn.getannotateEdit = function(){
return this.data("annotateEdit");
}
$.fn.annotateEdit.prototype.destroy = function(e) {
/// <summary>
/// Destroys an editable annotation area.
/// e is the action, only used for cancel, permit to not load any content
/// and fall back to the old state
/// </summary>
this.image.canvas.children('.image-annotate-edit').hide();
this.area.resizable('destroy');
this.area.draggable('destroy');
this.area.css('height', '');
this.area.css('width', '');
this.area.css('left', '');
this.area.css('top', '');
this.form.remove();
// destroy est appele au retour du formulaire, donc si creation ou suppression
// on efface donc toutes les notes et on recharge
if(e != 'cancel'){
$.fn.annotateImage.clear(this.image);
$.fn.annotateImage.ajaxLoad(this.image);
$.fn.annotateImage.ajaxDestroy(this.image);
}
}
$.fn.annotateView = function(image, note) {
/// <summary>
/// Defines a annotation area.
/// </summary>
this.image = image;
this.note = note;
this.note.id_document = this.image.id_document;
this.editable = (note.editable && image.editable);
// Add the area
this.area = $('<div class="image-annotate-area' + (this.editable ? ' image-annotate-area-editable' : '') + '"><div class="inner"></div></div>');
image.canvas.children('.image-annotate-view').prepend(this.area);
// Add the note
this.form = $('<div class="image-annotate-note"><div class="note-text">' + note.text + '</div></div>');
this.form.hide();
this.area.append(this.form);
this.form.children('span.actions').hide();
// Set the position and size of the note
this.setPosition();
// Add the behavior: hide/display the note when hovering the area
var annotation = this;
this.area.hover(function() {
annotation.show();
}, function() {
annotation.hide();
});
// Edit a note feature
if (this.editable) {
var form = this;
this.area.children('.inner').click(function() {
form.edit();
});
}
};
$.fn.annotateView.prototype.setPosition = function() {
/// <summary>
/// Sets the position of an annotation.
/// </summary>
this.area.children('.inner').height((parseInt((this.note.height*this.image.echelle)) - 2) + 'px');
this.area.children('.inner').width((parseInt((this.note.width*this.image.echelle)) - 2) + 'px');
this.area.css('left', (parseInt(this.note.left*this.image.echelle)) + 'px');
this.area.css('top', (parseInt(this.note.top*this.image.echelle)) + 'px');
this.form.css('left', '0');
this.form.css('top', '100%');
};
$.fn.annotateView.prototype.show = function() {
/// <summary>
/// Highlights the annotation
/// </summary>
this.form.fadeIn(250);
if (!this.editable) {
this.area.addClass('image-annotate-area-hover');
} else {
this.area.addClass('image-annotate-area-editable-hover');
}
};
$.fn.annotateView.prototype.hide = function() {
/// <summary>
/// Removes the highlight from the annotation.
/// </summary>
this.form.fadeOut(250);
this.area.removeClass('image-annotate-area-hover');
this.area.removeClass('image-annotate-area-editable-hover');
};
$.fn.annotateView.prototype.destroy = function() {
/// <summary>
/// Destroys the annotation.
/// </summary>
this.area.remove();
this.form.remove();
}
$.fn.annotateView.prototype.edit = function() {
/// <summary>
/// Edits the annotation.
/// </summary>
if (this.image.mode == 'view') {
this.image.mode = 'edit';
var annotation = this;
// Create/prepare the editable note elements
var editable = new $.fn.annotateEdit(this.image, this.note);
$.fn.annotateImage.saveForm(editable, this.image, annotation);
$.fn.annotateImage.cancelForm(editable, this.image);
// Add the delete button
var del = $('#image-annotate-edit-form form input[name=effacer]');
del.click(function() {
var form = $('#image-annotate-edit-form form');
$.fn.annotateImage.updatePosition(form, editable)
annotation.image.mode = 'view';
// destroy est appelé depuis le formulaire CVT après son rechargement ajax
//editable.destroy();
annotation.destroy();
});
}
};
$.fn.annotateImage.updatePosition = function(form, editable) {
/// <summary>
/// modifier les coordonnees de l'annotation dans les champs du formulaire
/// </summary>
form.children('input[name=height]').val(parseInt(editable.area.height()/editable.image.echelle));
form.children('input[name=width]').val(parseInt(editable.area.width()/editable.image.echelle));
form.children('input[name=top]').val(parseInt(editable.area.position().top/editable.image.echelle));
form.children('input[name=left]').val(parseInt(editable.area.position().left/editable.image.echelle));
}
$.fn.annotateView.prototype.resetPosition = function(editable, text) {
/// <summary>
/// Sets the position of an annotation.
/// </summary>
this.form.html(text);
this.form.hide();
// Resize
this.area.children('div').height(editable.area.height() + 'px');
this.area.children('div').width((editable.area.width() - 2) + 'px');
this.area.css('left', (editable.area.position().left) + 'px');
this.area.css('top', (editable.area.position().top) + 'px');
this.form.css('left', (editable.area.position().left) + 'px');
this.form.css('top', (parseInt(editable.area.position().top) + parseInt(editable.area.height()) + 7) + 'px');
// Save new position to note
this.note.top = parseInt(editable.area.position().top/editable.image.echelle);
this.note.left = parseInt(editable.area.position().left/editable.image.echelle);
this.note.height = parseInt(editable.area.height()/editable.image.echelle);
this.note.width = parseInt(editable.area.width()/editable.image.echelle);
this.note.text = text;
this.note.id = editable.note.id;
this.editable = true;
};
})(jQuery);
/*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license */
/*! source https://github.com/paulirish/matchMedia.js */
window.matchMedia = window.matchMedia || (function( doc, undefined ) {
"use strict";
var bool,
docElem = doc.documentElement,
refNode = docElem.firstElementChild || docElem.firstChild,
// fakeBody required for <FF4 when executed in <head>
fakeBody = doc.createElement( "body" ),
div = doc.createElement( "div" );
div.id = "mq-test-1";
div.style.cssText = "position:absolute;top:-100em";
fakeBody.style.background = "none";
fakeBody.appendChild(div);
return function(q){
div.innerHTML = "&shy;<style media=\"" + q + "\"> #mq-test-1 { width: 42px; }</style>";
docElem.insertBefore( fakeBody, refNode );
bool = div.offsetWidth === 42;
docElem.removeChild( fakeBody );
return {
matches: bool,
media: q
};
};
}( document ));

10
lang/legendes.xml

@ -0,0 +1,10 @@
<traduction module="legendes" gestionnaire="salvatore" url="https://trad.spip.net" source="svn://zone.spip.org/spip-zone/_plugins_/legendes/lang/" reference="fr">
<langue code="en" url="https://trad.spip.net/tradlang_module/legendes?lang_cible=en" total="15" traduits="15" relire="0" modifs="0" nouveaux="0" pourcent="100.00">
</langue>
<langue code="fr" url="https://trad.spip.net/tradlang_module/legendes?lang_cible=fr" total="15" traduits="15" relire="0" modifs="0" nouveaux="0" pourcent="100.00">
</langue>
<langue code="pt_br" url="https://trad.spip.net/tradlang_module/legendes?lang_cible=pt_br" total="15" traduits="15" relire="0" modifs="0" nouveaux="0" pourcent="100.00">
<traducteur nom="filipaun" lien="https://trad.spip.net/auteur/filipaun" />
<traducteur nom="Ricardo Porto" lien="https://trad.spip.net/auteur/ricardo-porto" />
</langue>
</traduction>

40
lang/legendes_en.php

@ -0,0 +1,40 @@
<?php
// This is a SPIP language file -- Ceci est un fichier langue de SPIP
// extrait automatiquement de https://trad.spip.net/tradlang_module/legendes?lang_cible=en
// ** ne pas modifier le fichier **
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
$GLOBALS[$GLOBALS['idx_lang']] = array(
// A
'ajouter_legende' => 'Add a caption',
'autoriser_creerdans' => 'Create captions',
'autoriser_modifier' => 'Modify captions',
'autoriser_supprimer' => 'Delete captions',
// B
'bouton_supprimer' => 'Delete',
// C
'cfg_descr_legendes' => 'The plugin "Captions" allows you to add annotations to images. This form allows you to configure its use.',
'cfg_legend_statuts' => 'Status',
'cfg_titre_legendes' => 'Captions',
// E
'editer_legende' => 'Edit a caption',
'explications_statuts_general' => 'Each selector below set the minimum status of a user to perform a particular action.',
// L
'legende_enregistrer_ok' => 'Caption saved',
'legende_supprimer_ok' => 'Caption deleted',
// M
'msg_yadesnotes' => '@nb@ captions are linked to this image. Hover it to view the captions.',
'msg_yaunenote' => 'A caption is linked to this image. Hover it to view the caption.',
// T
'texte_legende' => 'Text of the caption'
);

38
lang/legendes_fr.php

@ -0,0 +1,38 @@
<?php
// This is a SPIP language file -- Ceci est un fichier langue de SPIP
// Fichier source, a modifier dans svn://zone.spip.org/spip-zone/_plugins_/legendes/lang/
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
$GLOBALS[$GLOBALS['idx_lang']] = array(
// A
'ajouter_legende' => 'Ajouter une note',
'autoriser_creerdans' => 'Créer des légendes',
'autoriser_modifier' => 'Modifier des légendes',
'autoriser_supprimer' => 'Supprimer des légendes',
// B
'bouton_supprimer' => 'Supprimer',
// C
'cfg_descr_legendes' => 'Le plugin « Légendes » permet d’ajouter des annotations sur des images. Ce formulaire permet de configurer son utilisation.',
'cfg_legend_statuts' => 'Statuts',
'cfg_titre_legendes' => 'Légendes',
// E
'editer_legende' => 'Éditer une note',
'explications_statuts_general' => 'Chaque sélecteur ci-dessous défini le statut minimal d’un utilisateur pour réaliser une action particulière.',
// L
'legende_enregistrer_ok' => 'Note enregistrée',
'legende_supprimer_ok' => 'Note supprimée',
// M
'msg_yadesnotes' => '@nb@ notes sont associées à l’image. Survolez l’image pour afficher les notes.',
'msg_yaunenote' => 'Une note est associée à l’image. Survolez l’image pour afficher la note.',
// T
'texte_legende' => 'Texte de la note'
);

40
lang/legendes_pt_br.php

@ -0,0 +1,40 @@
<?php
// This is a SPIP language file -- Ceci est un fichier langue de SPIP
// extrait automatiquement de https://trad.spip.net/tradlang_module/legendes?lang_cible=pt_br
// ** ne pas modifier le fichier **
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
$GLOBALS[$GLOBALS['idx_lang']] = array(
// A
'ajouter_legende' => 'Incluir uma nota',
'autoriser_creerdans' => 'Criar as legendas',
'autoriser_modifier' => 'Alterar as legendas',
'autoriser_supprimer' => 'Excluir as legendas',
// B
'bouton_supprimer' => 'Excluir',
// C
'cfg_descr_legendes' => 'O plugin «Legendas» permite incluir anotações em imagens. Este formulário permite configurar a sua utilização.',
'cfg_legend_statuts' => 'Status',
'cfg_titre_legendes' => 'Legendas',
// E
'editer_legende' => 'Editar uma nota',
'explications_statuts_general' => 'Cada seletor abaixo define o status mínimo de um usuário para realizar uma ação específica.',
// L
'legende_enregistrer_ok' => 'Nota gravada',
'legende_supprimer_ok' => 'Nota excluída',
// M
'msg_yadesnotes' => '@nb@ notas estão vinculadas à imagem. Passe o mouse sobre a imagem para exibir as notas.',
'msg_yaunenote' => 'Uma nota está vinculada à imagem. Passe o mouse sobre a imagem para exibir a nota.',
// T
'texte_legende' => 'Texto da nota'
);

9
lang/paquet-legendes.xml

@ -0,0 +1,9 @@
<traduction module="paquet-legendes" gestionnaire="salvatore" url="https://trad.spip.net" source="svn://zone.spip.org/spip-zone/_plugins_/legendes/lang/" reference="fr">
<langue code="en" url="https://trad.spip.net/tradlang_module/paquet-legendes?lang_cible=en" total="3" traduits="3" relire="0" modifs="0" nouveaux="0" pourcent="100.00">
</langue>
<langue code="fr" url="https://trad.spip.net/tradlang_module/paquet-legendes?lang_cible=fr" total="3" traduits="3" relire="0" modifs="0" nouveaux="0" pourcent="100.00">
</langue>
<langue code="pt_br" url="https://trad.spip.net/tradlang_module/paquet-legendes?lang_cible=pt_br" total="3" traduits="3" relire="0" modifs="0" nouveaux="0" pourcent="100.00">
<traducteur nom="Ricardo Porto" lien="https://trad.spip.net/auteur/ricardo-porto" />
</langue>
</traduction>

16
lang/paquet-legendes_en.php

@ -0,0 +1,16 @@
<?php
// This is a SPIP language file -- Ceci est un fichier langue de SPIP
// extrait automatiquement de https://trad.spip.net/tradlang_module/paquet-legendes?lang_cible=en
// ** ne pas modifier le fichier **
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
$GLOBALS[$GLOBALS['idx_lang']] = array(
// L
'legendes_description' => 'A plugin to add captions on pictures as Flickr. inspired from [Fotonotes->http://www.fotonotes.net/] and based on the script [jQuery Image Annotation->http://www.flipbit.co.uk/jquery-image-annotation.html].',
'legendes_nom' => 'Captions',
'legendes_slogan' => 'Add captions on photos'
);

14
lang/paquet-legendes_fr.php

@ -0,0 +1,14 @@
<?php
// This is a SPIP language file -- Ceci est un fichier langue de SPIP
// Fichier source, a modifier dans svn://zone.spip.org/spip-zone/_plugins_/legendes/lang/
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
$GLOBALS[$GLOBALS['idx_lang']] = array(
// L
'legendes_description' => 'Un plugin pour ajouter des légendes à ses images comme sur Flickr. Inspiré de [Fotonotes->http://www.fotonotes.net/] et basé sur le script [jQuery Image Annotation->http://www.flipbit.co.uk/jquery-image-annotation.html].',
'legendes_nom' => 'Légendes',
'legendes_slogan' => 'Légender ses photos'
);

16
lang/paquet-legendes_pt_br.php

@ -0,0 +1,16 @@
<?php
// This is a SPIP language file -- Ceci est un fichier langue de SPIP
// extrait automatiquement de https://trad.spip.net/tradlang_module/paquet-legendes?lang_cible=pt_br
// ** ne pas modifier le fichier **
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
$GLOBALS[$GLOBALS['idx_lang']] = array(
// L
'legendes_description' => 'Um plugin para incluir legendas nas imagens, como no Flickr. Inspirado em [Fotonotes->http://www.fotonotes.net/] e baseado no script [jQuery Image Annotation->http://www.flipbit.co.uk/jquery-image-annotation.html].',
'legendes_nom' => 'Legendas',
'legendes_slogan' => 'Legendar as suas fotos'
);

38
legendes.css

@ -0,0 +1,38 @@
/* hop */
.image-annotate-add { background: #fff url(images/new.png) no-repeat 3px 3px; border: solid 1px #ccc !important; color: #000 !important; display: block; font-family: Verdana, Sans-Serif; font-size: 12px; height: 18px; line-height: 18px; padding: 2px 0 2px 24px; margin: 5px 5px 5px 0; width: 110px; text-decoration: none; }
.image-annotate-add:hover { background-color: #eee }
.image-annotate-canvas { border: solid 1px #ccc; background-position: left top; background-repeat: no-repeat; display: block; margin: 0; position: relative; }
.image-annotate-view { display: none; position: absolute; left: 0; top: 0; }
.image-annotate-area { border: 1px solid #999; position: absolute; left: 0; top: 0; }
.inner { border: 1px solid #fff; display: block; height: 100%; }
.image-annotate-area-editable { cursor: pointer }
.image-annotate-area-editable-hover .inner { background: transparent url(images/edit-note.png) center 50% no-repeat }
.image-annotate-note { width: 210px; position: absolute; z-index: 3000; display: none; padding-top: 5px; }
.image-annotate-note .note-text { display: table; background: #f5f5f5 none repeat scroll 0 0; border: 1px solid #ddd; color: #000; font-family: Verdana, Sans-Serif; font-size: 12px; max-width: 200px; padding: 3px 7px; box-shadow: 1px 1px 10px #333; -webkit-box-shadow: 1px 1px 10px #333; -moz-box-shadow: 1px 1px 10px #333; }
.image-annotate-note .note-text p { margin: 2px auto }
.image-annotate-note .note-text .author { font-style: italic; color: #666; }
.image-annotate-note .actions { display: block; font-size: 80%; }
.nb_notes { margin-top: 5px }
.image-annotate-edit { display: none; position: absolute; top: 0; left: 0; }
.image-annotate-edit .loading { background: #333 url(images/loader.gif) center 50% no-repeat }
#image-annotate-edit-form { position: absolute; width: 300px; background: #fff; border: 1px solid #ddd; margin-top: 5px; padding: 5px; box-shadow: 1px 1px 10px #333; -webkit-box-shadow: 1px 1px 10px #333; -moz-box-shadow: 1px 1px 10px #333; left: 0; top: 0; }
#image-annotate-edit-form form { z-index: 999 }
#image-annotate-edit-form .formulaire_spip,
#image-annotate-edit-form form fieldset { margin: 0 }
#image-annotate-edit-form form legend,
#image-annotate-edit-form form label { display: none }
#image-annotate-edit-form form .boutons { font-size: 85% }
.image-annotate-edit-area { display: block; margin: 0; padding: 0 0 2px 0; width: 60px; height: 60px; border: 1px solid #999; position: absolute; top: 10px; left: 10px; cursor: move; }
.image-annotate-edit-area .ui-resizable-handle { opacity: 0.8 }
.image-annotate-edit .ui-resizable { position: inherit }
.ui-resizable-handle { position: absolute; font-size: .1px; z-index: 99999; display: block; }
.ui-resizable-disabled .ui-resizable-handle,
.ui-resizable-autohide .ui-resizable-handle { display: block }
.ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0; }
.ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0; }
.ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0; height: 100%; }
.ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0; height: 100%; }
.ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; }
.ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; }
.ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; }
.ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px; }

32
legendes.html

@ -0,0 +1,32 @@
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
<html dir="#LANG_DIR" lang="#LANG" xml:lang="#LANG" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>[(#NOM_SITE_SPIP|textebrut)]</title>
[<meta name="description" content="(#DESCRIPTIF_SITE_SPIP|couper{150}|textebrut)" />]
<INCLURE{fond=inc-head} />
</head>
<body class="page_sommaire">
<div id="page">
[(#REM) Entete de la page + titre du site ]
<INCLURE{fond=inc-entete} />
<div id="conteneur">
[(#REM) Contenu principal : derniers articles publies ]
<div id="contenu">
<h1 class="invisible">#NOM_SITE_SPIP</h1>
[<div class="chapo">(#DESCRIPTIF_SITE_SPIP)</div>]
[(#INCLURE{fond=modeles/image_legendes}
{id_document=1}
{largeur=560}
{class=media}{editable})]
</div><!-- fin contenu -->
</div><!-- fin conteneur -->
<div id="navigation">
</div>
</div><!-- fin page -->
</body>
</html>

25
legendes_administrations.php

@ -0,0 +1,25 @@
<?php
if (!defined("_ECRIRE_INC_VERSION")) return;
include_spip('inc/meta');
function legendes_upgrade($nom_meta_base_version,$version_cible){
$current_version = "0.0";
if ( (!isset($GLOBALS['meta'][$nom_meta_base_version]))
|| (($current_version = $GLOBALS['meta'][$nom_meta_base_version])!=$version_cible)){
include_spip('base/legendes');
if ($current_version==0.0){
include_spip('base/create');
include_spip('base/abstract_sql');
creer_base();
ecrire_meta($nom_meta_base_version,$current_version=$version_cible,'non');
}
}
}
function legendes_vider_tables($nom_meta_base_version) {
sql_drop_table("spip_legendes");
effacer_meta($nom_meta_base_version);
}
?>

82
legendes_autoriser.php

@ -0,0 +1,82 @@
<?php
if (!defined("_ECRIRE_INC_VERSION")) return;
/* pour que le pipeline ne rale pas ! */
function legendes_autoriser(){}
/**
* Autorisation d'ajout d'une legende a un document
*
* @param string $faire
* @param string $quoi
* @param int $id du document
* @param int $qui
* @param array $options
* @return bool
*/
function autoriser_legende_creerdans_dist($faire,$quoi,$id,$qui,$options){
if (!$id) return false; // interdit de creer une legende sur un document vide !
// autorisation personnalisee par config
if(lire_config('legendes/statuts_creerdans') && $qui['statut'])
return ($qui['statut']<=lire_config('legendes/statuts_creerdans','0minirezo'));
// ou autorisation du document associe
return autoriser('modifier','document',$id,$qui);
}
/**
* Autorisation de modifier une legende
*
* @param string $faire
* @param string $quoi
* @param int $id de la legende
* @param int $qui
* @param array $options
* @return bool
*/
function autoriser_legende_modifier_dist($faire,$quoi,$id,$qui,$options){
if (!isset($options['id_document']) OR !$id_document=$options['id_document'])
$legende = sql_fetsel('*','spip_legendes','id_legende='.intval($id));
if (!$legende['id_document']) return false;
// autorisation personnalisee par config
if (lire_config('legendes/statuts_modifier') && $qui['statut']){
if ($qui['statut'] <= lire_config('legendes/statuts_modifier','0minirezo')){
if (($qui['statut'] != '0minirezo') AND ($qui['id_auteur'] != $legende['id_auteur'])) {
return false;
}
return true;
}
}
// ou autorisation du document associe
return autoriser('modifier','document',$legende['id_document'],$qui);
}
/**
* Autorisation de supprimer une legende
*
* @param string $faire
* @param string $quoi
* @param int $id de la legende
* @param int $qui
* @param array $options
* @return bool
*/
function autoriser_legende_supprimer_dist($faire,$quoi,$id,$qui,$options){
if (!isset($options['id_document']) OR !$id_document=$options['id_document'])
$id_document = sql_getfetsel('id_document','spip_legendes','id_legende='.intval($id));
// autorisation personnalisee par config
if (lire_config('legendes/statuts_supprimer') && $qui['statut']){
if ($qui['statut'] <= lire_config('legendes/statuts_supprimer','0minirezo')){
$legende = sql_getfetsel('id_auteur','spip_legendes','id_legende='.intval($id));
if (($qui['statut'] != '0minirezo') AND ($qui['id_auteur'] != $legende['id_auteur'])) {
return false;
}
return true;
}
}
// ou autorisation du document associe
return autoriser('modifier','document',$id_document,$qui);
}
?>

7
legendes_fonctions.php

@ -0,0 +1,7 @@
<?php
if (!defined("_ECRIRE_INC_VERSION")) return;
include_spip('inc/json');
?>

5
legendes_get.html

@ -0,0 +1,5 @@
#CACHE{0}
#HTTP_HEADER{Content-Type: text/plain; charset=#CHARSET}
<B_legendes>[<BOUCLE_legendes(LEGENDES){id_document}{tout}{","}>
{ "top": "#POSY", "left": "#POSX", "width": "#WIDTH", "height": "#HEIGHT", "text": [(#TEXTE|PtoBR|concat{[(#SESSION{id_auteur}|=={#ID_AUTEUR}|non)[ - (#MODELE{legende_auteur,id_auteur=#ID_AUTEUR})]]}|json_encode)], "id": "#ID_LEGENDE", "editable": false }</BOUCLE_legendes>
]</B_legendes>

5
legendes_get_edit.html

@ -0,0 +1,5 @@
#CACHE{0}
#HTTP_HEADER{Content-Type: text/plain; charset=#CHARSET}
<B_legendes>[<BOUCLE_legendes(LEGENDES){id_document}{tout}{","}>
{ "top": "#POSY", "left": "#POSX", "width": "#WIDTH", "height": "#HEIGHT", "text": [(#TEXTE|PtoBR|concat{[(#SESSION{id_auteur}|=={#ID_AUTEUR}|non)[ - (#MODELE{legende_auteur,id_auteur=#ID_AUTEUR})]]}|json_encode)], "id": "#ID_LEGENDE", "editable": [(#AUTORISER{modifier,legende,#ID_LEGENDE}|?{'true','false'})] }</BOUCLE_legendes>
]</B_legendes>

63
legendes_pipelines.php

@ -0,0 +1,63 @@
<?php
if (!defined("_ECRIRE_INC_VERSION")) return;
function legendes_insert_head($flux){
$flux .='<script src="'._DIR_PLUGIN_LEGENDES.'javascript/jquery.annotate.js" type="text/javascript"></script>';
$flux .= '<link rel="stylesheet" href="'._DIR_PLUGIN_LEGENDES.'legendes.css" type="text/css" media="screen" />';
return $flux;
}
function legendes_jqueryui_plugins($plugins){
$plugins[] = "jquery.ui.core";
$plugins[] = "jquery.ui.widget";
$plugins[] = "jquery.ui.mouse";
$plugins[] = "jquery.ui.draggable";
$plugins[] = "jquery.ui.resizable";
return $plugins;
}
function legendes_jqueryui_forcer($plugins){
return legendes_jqueryui_plugins($plugins);
}
function legendes_post_edition($flux){
// si on tourne un document, tourner les legendes associees
if($flux['args']['action']=='tourner'){
$id_document = $flux['args']['id_objet'];
$angle = $flux['args']['champs']['rotation'];
$res = sql_select("id_legende", "spip_legendes", "id_document=".intval($id_document));
while ($row = sql_fetch($res)){
$id_legende = $row['id_legende'];
include_spip("action/editer_legende");
legendes_action_tourner_legende($id_legende,$angle);
}
// Invalider les caches
include_spip('inc/invalideur');
suivre_invalideur("id='id_document/$id_document'");
}
/**