Example #1
0
function affiche_diff($id_article, $id_version, $format = 'complet')
{
    include_spip('inc/suivi_versions');
    $textes = revision_comparee($id_article, $id_version, $format);
    $ret = '';
    foreach ($textes as $champ => $texte) {
        $texte = propre_diff($texte);
        if ($champ == 'titre') {
            $texte = "<h1>{$texte}</h1>";
        } else {
            $texte = "<div class='{$k}'>{$texte}</div>";
        }
        $ret .= "\n<hr/>\n" . $texte;
    }
    return $ret;
}
Example #2
0
/**
 * Afficher un diff correspondant a une revision d'un objet
 * 
 * @param int $id_objet
 * @param string $objet
 * @param int $id_version
 * @param bool $court
 * @return string
 */
function revisions_diff($id_objet, $objet, $id_version, $court = false)
{
    $textes = revision_comparee($id_objet, $objet, $id_version, 'diff');
    if (!is_array($textes)) {
        return $textes;
    }
    $rev = '';
    $nb = 0;
    foreach ($textes as $var => $t) {
        if ($n = strlen($t)) {
            if ($court) {
                $nb += $n;
            } else {
                $aff = propre_diff($t);
                if ($GLOBALS['les_notes']) {
                    $aff .= '<p>' . $GLOBALS['les_notes'] . '</p>';
                    $GLOBALS['les_notes'] = '';
                }
                $rev .= "<blockquote>{$aff}</blockquote>";
            }
        }
    }
    return $court ? _T('taille_octets', array('taille' => $nb)) : $rev;
}
Example #3
0
function exec_articles_versions_args($id_article, $id_version, $id_diff)
{
	global $spip_lang_left, $spip_lang_right;

	if (!autoriser('voirrevisions', 'article', $id_article) 
	OR !$row = sql_fetsel("*", "spip_articles", "id_article=".sql_quote($id_article))){
		include_spip('inc/minipres');
		echo minipres();
		return;
	}

	include_spip('inc/suivi_versions');
	include_spip('inc/presentation');
	include_spip('inc/revisions');

	// recuperer les donnees actuelles de l'article
	$id_article = $row["id_article"];
	$id_rubrique = $row["id_rubrique"];
	$titre = $row["titre"];
	$statut_article = $row["statut"];
	$lang = $row["lang"];

	// Afficher le debut de la page (y compris rubrique)
	$commencer_page = charger_fonction('commencer_page', 'inc');
	echo $commencer_page(_T('info_historique')." &laquo; $titre &raquo;", "naviguer", "articles", $id_rubrique);

	echo debut_grand_cadre(true);

	echo afficher_hierarchie($id_rubrique);

	echo fin_grand_cadre(true);


//////////////////////////////////////////////////////
// Affichage de la colonne de gauche
//

	echo debut_gauche('', true);

	echo bloc_des_raccourcis(icone_horizontale(_T('icone_retour_article'), generer_url_ecrire("articles","id_article=$id_article"), "article-24.gif","rien.gif", false) .
				 icone_horizontale(_T('icone_suivi_revisions'), generer_url_ecrire("suivi_revisions",""), "historique-24.gif","rien.gif", false));



//////////////////////////////////////////////////////
// Affichage de la colonne de droite
//

	echo debut_droite('', true);

	$lang_dir = lang_dir(changer_typo($lang));



//
// recuperer les donnees versionnees
//
	$last_version = false;
	if (!$id_version) {
		$id_version = $row['id_version'];
		$last_version = true;
	}
	$textes = revision_comparee($id_article, $id_version, 'complet', $id_diff);

	unset($id_rubrique); # on n'en n'aura besoin que si on affiche un diff


//
// Titre, surtitre, sous-titre
//

	$debut = $corps = '';

	if (is_array($textes))
	foreach ($textes as $var => $t) {
		switch ($var) {
			case 'id_rubrique':
				$debut .= "<div dir='$lang_dir' class='arial1 spip_x-small'>"
					. $t
					. "</div>\n";
				break;

			case 'surtitre':
			case 'soustitre':
				$debut .= "<div  dir='$lang_dir' class='arial1 spip_medium'><b>" . propre_diff($t) . "</b></div>\n";
				break;

			case 'titre':
				$debut .= gros_titre(propre_diff($t),
					puce_statut($statut_article, " style='vertical-align: center'"), false);
				break;

			// trois champs a affichage combine
			case 'descriptif':
			case 'url_site':
			case 'nom_site':
				if (!$vudesc++) {
					$debut .= "<div style='text-align: $spip_lang_left; padding: 5px; border: 1px dashed #aaaaaa; background-color: #e4e4e4;'  dir='$lang_dir'>";
					$texte_case = ($textes['descriptif']) ? "{{"._T('info_descriptif')."}} ".$textes['descriptif']."\n\n" : '';
					$texte_case .= ($textes['nom_site'].$textes['url_site']) ? "{{"._T('info_urlref')."}} [".$textes['nom_site']."->".$textes['url_site']."]" : '';
					$debut .= "<span class='verdana1 spip_small'>"
					. propre($texte_case). "</span>";
					$debut .= "</div>";
				}
				break;

			default:
				$corps .= "<div dir='$lang_dir' class='champ contenu_$var'>"
					. "<div class='label'>$var</div>"
					. "<div class='$var'>"
					. propre_diff($t)
					. "</div></div>\n";
				break;
		}
	}

	echo '<div id="contenu">';

	echo debut_cadre_relief('', true);

	echo "\n<table id='diff' cellpadding='0' cellspacing='0' border='0' width='100%'>";
	echo "<tr><td style='width: 100%' valign='top'>";
	echo $debut;
	echo "</td><td>";

// Icone de modification
	if (autoriser('modifier', 'article', $id_article))
		echo icone_inline(
		_T('icone_modifier_article').'<br />('._T('version')." $id_version)",
		generer_url_ecrire("articles_edit",
			"id_article=$id_article".((!$last_version)?"&id_version=$id_version":"")),
		"article-24.gif",
		"edit.gif",
		$spip_lang_right
		);

	echo "</td>";

	echo "</tr></table>";

	echo fin_cadre_relief(true);


	//////////////////////////////////////////////////////
	// Affichage des versions
	//
	$result = sql_select("id_version, titre_version, date, id_auteur",
		"spip_versions",
		"id_article=".sql_quote($id_article)." AND  id_version>0",
		"", "id_version DESC");

	echo debut_cadre_relief('', true);

	$zapn = 0;
	$lignes = array();
	$points = '...';
	$tranches = 10;
	while ($row = sql_fetch($result)) {

		$res = '';
		// s'il y en a trop on zappe a partir de la 10e
		// et on s'arrete juste apres celle cherchee
		if ($zapn++ > $tranches
		AND abs($id_version - $row['id_version']) > $tranches<<1) {
			if ($points) {
				$lignes[]= $points;
				$points = '';
			}
			if ($id_version > $row['id_version']) break;
			continue;
		}

		$date = affdate_heure($row['date']);
		$version_aff = $row['id_version'];
		$titre_version = typo($row['titre_version']);
		$titre_aff = $titre_version ? $titre_version : $date;
		if ($version_aff != $id_version) {
			$lien = parametre_url(self(), 'id_version', $version_aff);
			$lien = parametre_url($lien, 'id_diff', '');
			$res .= "<a href='".($lien.'#diff')."' title=\""._T('info_historique_affiche')."\">$titre_aff</a>";
		} else {
			$res .= "<b>$titre_aff</b>";
		}

		if (is_numeric($row['id_auteur'])
		AND $t = sql_getfetsel('nom', 'spip_auteurs', "id_auteur=" . intval($row['id_auteur']))) {
				$res .= " (".typo($t).")";
			} else {
				$res .= " (".$row['id_auteur'].")"; #IP edition anonyme
		}
		
		if ($version_aff != $id_version) {
		  $res .= " <span class='verdana2'>";
		  if ($version_aff == $id_diff) {
			$res .= "<b>("._T('info_historique_comparaison').")</b>";
		  } else {
			$lien = parametre_url(self(), 'id_version', $id_version);
			$lien = parametre_url($lien, 'id_diff', $version_aff);
			$res .= "(<a href='".($lien.'#diff').
			"'>"._T('info_historique_comparaison')."</a>)";
		  }
		$res .= "</span>";
		}
		$lignes[]= $res;
	}
	if ($lignes) {
		echo "<ul class='verdana3'><li>\n";
		echo join("\n</li><li>\n", $lignes);
		echo "</li></ul>\n";
	}

	//////////////////////////////////////////////////////
	// Corps de la version affichee
	//
	echo "\n\n<div id='wysiwyg' style='text-align: justify;'>$corps";

	// notes de bas de page
	if (strlen($GLOBALS['les_notes']))
		echo "<div class='champ contenu_notes'>
			<div class='label'>"._T('info_notes')."</div>
			<div class='notes' dir='$lang_dir'>"
			.$GLOBALS['les_notes']
			."</div></div>\n";

	echo "</div>\n";

	echo fin_cadre_relief(true);

	echo '</div>'; // /#contenu


	echo  fin_gauche(), fin_page();

}
Example #4
0
function revisions_diff ($id_article, $id_version, $court=true)
{
	$textes = revision_comparee($id_article, $id_version, 'diff');
	if (!is_array($textes)) return $textes;
	$rev = '';
	$nb = 0;
	foreach ($textes as $var => $t) {
		if ($n=strlen($t)) {
			if ($court)
				$nb += $n;
			else {
				$aff = propre_diff($t);
				if ($GLOBALS['les_notes']) {
					$aff .= '<p>'.$GLOBALS['les_notes'].'</p>';
					$GLOBALS['les_notes'] = '';
				}
				$rev .= "<blockquote class='serif1'>$aff</blockquote>";
			}
		}
	}
	return $court ? _T('taille_octets', array('taille' => $nb)) : $rev;
}
Example #5
0
function signaler_conflits_edition($conflits, $redirect='') {
	include_spip('inc/minipres');
	include_spip('inc/revisions');
	include_spip('inc/suivi_versions');
	include_spip('inc/diff');
	foreach ($conflits as $champ=>$a) {
		// probleme de stockage ou conflit d'edition ?
		$base = isset($a['save']) ? $a['save'] : $a['base'];

		$diff = new Diff(new DiffTexte);
		$n = preparer_diff($a['post']);
		$o = preparer_diff($base);
		$d = propre_diff(
			afficher_para_modifies(afficher_diff($diff->comparer($n,$o))));

		$titre = isset($a['save']) ? _L('Echec lors de l\'enregistrement du champ @champ@', array('champ' => $champ)) : $champ;

		$diffs[] = "<h2>$titre</h2>\n"
			. "<h3>"._T('info_conflit_edition_differences')."</h3>\n"
			. "<div style='max-height:8em; overflow: auto; width:99%;'>".$d."</div>\n"
			. "<h4>"._T('info_conflit_edition_votre_version')."</h4>"
			. display_conflit_champ($a['post'])
			. "<h4>"._T('info_conflit_edition_version_enregistree')."</h4>"
			. display_conflit_champ($base);
	}

	if ($redirect) {
		$id = uniqid(rand());
		$redirect = "<form action='$redirect' method='get'
			id='$id'
			style='float:".$GLOBALS['spip_lang_right']."; margin-top:2em;'>\n"
		.form_hidden($redirect)
		."<input type='submit' value='"._T('icone_retour')."' />
		</form>\n";

		// pour les documents, on est probablement en ajax : il faut ajaxer
		if (_AJAX)
			$redirect .= '<script type="text/javascript">'
			.'setTimeout(function(){$("#'.$id.'")
			.ajaxForm({target:$("#'.$id.'").parent()});
			}, 200);'
			."</script>\n";

	}

	echo minipres(
		_T('titre_conflit_edition'),

		'<style>
.diff-para-deplace { background: #e8e8ff; }
.diff-para-ajoute { background: #d0ffc0; color: #000; }
.diff-para-supprime { background: #ffd0c0; color: #904040; text-decoration: line-through; }
.diff-deplace { background: #e8e8ff; }
.diff-ajoute { background: #d0ffc0; }
.diff-supprime { background: #ffd0c0; color: #802020; text-decoration: line-through; }
.diff-para-deplace .diff-ajoute { background: #b8ffb8; border: 1px solid #808080; }
.diff-para-deplace .diff-supprime { background: #ffb8b8; border: 1px solid #808080; }
.diff-para-deplace .diff-deplace { background: #b8b8ff; border: 1px solid #808080; }
</style>'
		.'<p>'._T('info_conflit_edition_avis_non_sauvegarde').'</p>'
		.'<p>'._T('texte_conflit_edition_correction').'</p>'
		."<div style='text-align:".$GLOBALS['spip_lang_left'].";'>"
		. join("\n",$diffs)
		."</div>\n"

		. $redirect
	);
}