Exemplo n.º 1
0
function controleurs_article_intro3_dist($regs) {
    list(,$crayon,$type,$champ,$id) = $regs;
    $valeur = valeur_colonne_table($type, array('descriptif', 'chapo', 'texte'), $id);
    if ($valeur === false) {
	    return array("$type $id $champ: " . _U('crayons:pas_de_valeur'), 6);
    }

	$n = new Crayon('article-intro3-' . $id, $valeur,
			array('hauteurMini' => 234));
    
    $return = array(
    	// html
	    $n->formulaire(
	    	// champs et attributs propres
	    	array(
	    	'descriptif' => array('type' => 'texte', 'attrs' => array(
		        'style' => 'height:' . ceil($n->hauteur*2/13) . 'px;' .
					        'width:' . $n->largeur . 'px;')),
			'chapo' =>  array('type' => 'texte', 'attrs' => array(
		        'style' => 'height:' . ceil($n->hauteur*4/13) . 'px;' .
					        'width:' . $n->largeur . 'px;')),
			'texte' =>  array('type' => 'texte', 'attrs' => array(
		        'style' => 'height:' . ceil($n->hauteur*4/13) . 'px;' .
					        'width:' . $n->largeur . 'px;'))) //,
		    // attributs communs :( marche pas pour style , pas 2 fois ?
//	    	array('style' => 'width:' . $n->largeur . 'px;')
    	),
    	// status
    	null);

	return $return;
}
Exemplo n.º 2
0
/**
 * Le controlleur de CFG
 *
 * @param Array $regs
 * @return Array
 */
function controleurs_config_dist($regs) {
    list(,$crayon,$type,$champ,$id) = $regs;
	// evidemment, pour CFG, on recupere pas tout a fait ce qu'on souhaite...
	// retraduire depot___plugin__casier__cle en depot::plugin/casier/cle
	include_spip('cfg_fonctions');
	$config = cfg_crayon2config($champ);
	$val = lire_config($config);
    if ($val === null) {
	    return array("$type $config: " . _U('crayons:pas_de_valeur'), 6);
    }
    
    $valeur = array('config' => $val);
	$n = new Crayon($crayon, $valeur);
	
	$contexte = array();
    if (is_string($val) and preg_match(",[\n\r],", $val))
		$contexte['config'] = array('type'=>'texte');
	else
		$contexte['config'] = array('type'=>'ligne');
		
    $html = $n->formulaire($contexte);
    include_spip('action/crayon_html');
    $html = crayons_formulaire($html, 'crayons_config_store');
    $status = NULL;

	return array($html, $status);

}
Exemplo n.º 3
0
function controleurs_article_intro3_dist($regs)
{
    list(, $crayon, $type, $champ, $id) = $regs;
    $valeur = valeur_colonne_table($type, array('descriptif', 'chapo', 'texte'), $id);
    if ($valeur === false) {
        return array("{$type} {$id} {$champ}: " . _U('crayons:pas_de_valeur'), 6);
    }
    $n = new Crayon('article-intro3-' . $id, $valeur, array('hauteurMini' => 234));
    $return = array($n->formulaire(array('descriptif' => array('type' => 'texte', 'attrs' => array('style' => 'height:' . ceil($n->hauteur * 2 / 13) . 'px;' . 'width:' . $n->largeur . 'px;')), 'chapo' => array('type' => 'texte', 'attrs' => array('style' => 'height:' . ceil($n->hauteur * 4 / 13) . 'px;' . 'width:' . $n->largeur . 'px;')), 'texte' => array('type' => 'texte', 'attrs' => array('style' => 'height:' . ceil($n->hauteur * 4 / 13) . 'px;' . 'width:' . $n->largeur . 'px;')))), null);
    return $return;
}
function controleurs_article_introduction_dist($regs)
{
    list(, $crayon, $type, $champ, $id) = $regs;
    $valeur = valeur_colonne_table($type, array('descriptif', 'chapo', 'texte'), $id);
    if ($valeur === false) {
        return array("{$type} {$id} {$champ}: " . _U('crayons:pas_de_valeur'), 6);
    }
    $n = new Crayon('article-introduction-' . $id, $valeur, array('hauteurMini' => 234, 'controleur' => 'controleurs/article_introduction'));
    $contexte = array('h_descriptif' => (int) ceil($n->hauteur * 2 / 13), 'h_chapo' => (int) ceil($n->hauteur * 4 / 13), 'h_texte' => (int) ceil($n->hauteur * 4 / 13));
    $html = $n->formulaire($contexte);
    $status = NULL;
    return array($html, $status);
}
Exemplo n.º 5
0
function controleur_dist($regs, $c=null) {
	list( , $nomcrayon, $type, $champ, $id, $class) = $regs;
	$options = array(
		'class' => $class
	);
	list($distant,$table) = distant_table($type);

	// Si le controleur est un squelette html, on va chercher
	// les champs qu'il lui faut dans la table demandee
	// Attention, un controleur multi-tables ne fonctionnera
	// que si les champs ont le meme nom dans toutes les tables
	// (par exemple: hyperlien est ok, mais pas nom)
	if (($fichier = find_in_path(
	($controleur = 'controleurs/' . $type . '_' . $champ) . '.html'))
	|| ($fichier = find_in_path(
	($controleur = 'controleurs/' . $champ) .'.html'))) {
		if (!lire_fichier($fichier, $controldata))
			die('erreur lecture controleur');
		if (preg_match_all('/\bname=(["\'])#ENV\{name_(\w+)\}\1/',
		$controldata, $matches, PREG_PATTERN_ORDER)) {
			$champ = $matches[2];
		}
	} else {
		$controleur = '';
	}

	$valeur = valeur_colonne_table($type, $champ, $id);

	#spip_log("$valeur = valeur_colonne_table($type, $champ, $id);");
	#spip_log($champ);

	if ($valeur === false) {
		return array("$type $id $champ: " . _U('crayons:pas_de_valeur'), 6);
	}
/*	if (is_scalar($valeur)) {
		$valeur = array($champ => $valeur);
	}*/

	// type du crayon (a revoir quand le core aura type ses donnees)
	$inputAttrs = array();
	if ($controleur) {
		$options['hauteurMini'] = 80; // base de hauteur mini
		$option['inmode'] = 'controleur';
		$options['controleur'] = $controleur;
	} else
	// si la valeur fait plusieurs lignes on doit mettre un textarea
	// derogation specifique pour descriptif_site de spip_metas
	if (
	preg_match(",[\n\r],", $valeur[$champ])
		OR (($champ == 'valeur') && ($id == 'descriptif_site'))
		OR
	// on regarde le type tel que defini dans serial
	// (attention il y avait des blob dans les vieux spip)
	($sqltype = colonne_table($type, $champ)) &&
	   ( in_array($sqltype['type'] , array('mediumtext', 'longblob', 'longtext')) ||
	   (($sqltype['type'] == 'text' || $sqltype['type'] == 'blob') && in_array($champ, array('descriptif', 'bio'))))) {
		$options['hauteurMini'] = 80; // hauteur mini d'un textarea
		$option['inmode'] = 'texte';
	} else { // ligne, hauteur naturelle
		$options['hauteurMaxi'] = 0;
		$option['inmode'] = 'ligne';
		if ($sqltype['long']) {
			$inputAttrs['maxlength'] = is_array($sqltype['long']) ?
					$sqltype['long'][0] : $sqltype['long'];
		}
	}

	$crayon = new Crayon($nomcrayon, $valeur, $options, $c);
	$inputAttrs['style'] = join($crayon->styles);

	if (!$controleur) {
		$inputAttrs['style'] .= 'width:' . $crayon->largeur . 'px;' .
		 ($crayon->hauteur ? ' height:' . $crayon->hauteur . 'px;' : '');
	}

	$html = $controleur ? $crayon->formulaire(null, $inputAttrs) :
					$crayon->formulaire($option['inmode'], $inputAttrs);
	$status = NULL;

	return array($html,$status);
}