Skip to content
Extraits de code Groupes Projets
Bifurcation depuis spip / spip
15746 validations de retard le dépôt en amont.
revisions.php 19,54 Kio
<?php

/***************************************************************************\
 *  SPIP, Systeme de publication pour l'internet                           *
 *                                                                         *
 *  Copyright (c) 2001-2006                                                *
 *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
 *                                                                         *
 *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
 *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
\***************************************************************************/

if (!defined("_ECRIRE_INC_VERSION")) return;

$GLOBALS['agregation_versions'] = 10;

// http://doc.spip.org/@separer_paras
function separer_paras($texte, $paras = "") {
	if (!$paras) $paras = array();
	while (preg_match("/(\r\n?){2,}|\n{2,}/", $texte, $regs)) {
		$p = strpos($texte, $regs[0]) + strlen($regs[0]);
		$paras[] = substr($texte, 0, $p);
		$texte = substr($texte, $p);
	}
	if ($texte) $paras[] = $texte;
	return $paras;
}

// http://doc.spip.org/@replace_fragment
function replace_fragment($id_article, $version_min, $version_max, $id_fragment, $fragment) {
	global $flag_gz;

	$fragment = serialize($fragment);
	$compress = 0;
	if ($flag_gz) {
		$s = gzcompress($fragment);
		if (strlen($s) < strlen($fragment)) {
			//spip_log("gain gz: ".(100 - 100 * strlen($s) / strlen($fragment)));
			$compress = 1;
			$fragment = $s;
		}
	}
	// Attention a bien echapper le $fragment qui est en binaire
	return "($id_article, $version_min, $version_max, $id_fragment, $compress, '"
		.mysql_escape_string($fragment)."')";
}

// http://doc.spip.org/@exec_replace_fragments
function exec_replace_fragments($replaces) {
	if (count($replaces)) {
		spip_query("REPLACE spip_versions_fragments (id_article, version_min, version_max, id_fragment, compress, fragment) VALUES ".join(", ", $replaces));

	}
}
// http://doc.spip.org/@exec_delete_fragments
function exec_delete_fragments($id_article, $deletes) {
	if (count($deletes)) {
		spip_query("DELETE FROM spip_versions_fragments WHERE id_article=$id_article AND ((".	join(") OR (", $deletes)."))");

	}
}


//
// Ajouter les fragments de la derniere version (tableau associatif id_fragment => texte)
//
// http://doc.spip.org/@ajouter_fragments
function ajouter_fragments($id_article, $id_version, $fragments) {
	global $flag_gz, $agregation_versions;