freed102 Arayashiki | omega2 a écrit :
Moi, même si je ne vérifie qu'une fois un formulaire donnée, à partir du moment où il y a un certain nombre de valeur à vérifier, je fais une fonction de vérification.
Je trouve moins dur de suivre des fonctions de ce genre que comprendre des séries de if sur plusieurs milliers de lignes. Quand au code en dehors des fonctions, je le limite au strict minimum avec jsute ce qu'il faut pour savoir dans quel cas je me trouve et appeller la fonction qui correspond.
|
oui je comprends ce que tu veux dire.. mais parfois je peux pas creer des fonctions quand c trop complexe... par exemple avec cette creation de fichier XML... j'ai deja fait des fonctions pour simplifier mais je pense pas pouvoir simplifier d'avantage :
Code :
- $dom=& domxml_new_doc("1.0" );
- $firstchildName="document";
- $firstchild =& $dom->create_element($firstchildName);
- $firstchild->set_attribute("pagewidth",$_SESSION['pagewidth']);
- $firstchild->set_attribute("pageheight",$_SESSION['pageheight']);
- $firstchild->set_attribute("orientation",$_SESSION['pageorientation']);
- $firstchild->set_attribute("mode_couleur",$_SESSION['mode_couleur']);
- $firstchild->set_attribute("type",$_SESSION['type_modele']);
- $firstchild->set_attribute("famille",$_SESSION['famille_modele']);
- $dom->append_child($firstchild);
- CreateDOMFilledRectangle($dom,$firstchildName,"background",$_SESSION['pos_x_fond'],$_SESSION['pos_y_fond'],$_SESSION['width_fond'],$_SESSION['height_fond'],$_SESSION['couleur_fond'],$_SESSION['angle_fond']);
- CreateDOMTextEntity($dom,$firstchildName,"entite",$_SESSION['pos_x_nom'],$_SESSION['pos_y_nom'],$_SESSION['width_nom'],$_SESSION['height_nom'],$_SESSION['fonte_nom'],$_SESSION['couleur_nom'],$_SESSION['size_nom'],$_SESSION['align_nom'],"middle",$_SESSION['interlignage_nom'],$_SESSION['angle_nom'],$_SESSION['interlettrage_nom']);
- CreateDOMTextItem($dom,"entite","nom",$_SESSION['CVnom']);
- CreateDOMTextItem($dom,"entite","prenom",$_SESSION['CVprenom']);
- CreateDOMTextElement($dom,$firstchildName,"titre",$_SESSION['pos_x_titre'],$_SESSION['pos_y_titre'],$_SESSION['width_titre'],$_SESSION['height_titre'],$_SESSION['fonte_titre'],$_SESSION['couleur_titre'],$_SESSION['size_titre'],$_SESSION['align_titre'],"middle",$_SESSION['interlignage_titre'],$_SESSION['angle_titre'],$_SESSION['interlettrage_titre'],tagsForPDF($_SESSION['CVtitre']));
- CreateDOMTextEntity($dom,$firstchildName,"coordonnees",$_SESSION['pos_x_adresse'],$_SESSION['pos_y_adresse'],$_SESSION['width_adresse'],$_SESSION['height_adresse'],$_SESSION['fonte_adresse'],$_SESSION['couleur_adresse'],$_SESSION['size_adresse'],$_SESSION['align_adresse'],"middle",$_SESSION['interlignage_adresse'],$_SESSION['angle_adresse'],$_SESSION['interlettrage_adresse']);
- CreateDOMTextItem($dom,"coordonnees","adresse",tagsForPDF($_SESSION['CVadresse2']),$_SESSION['br_adresse']);
- //logo
- CreateDOMPictureElement($dom,$firstchildName,"logo1",$_SESSION['pos_x_logo'],$_SESSION['pos_y_logo'],$_SESSION['width_logo'],$_SESSION['height_logo'],$_SESSION['uploaddir'],$_SESSION['CVlogo_filename']);
- //echo $dom->dump_mem(true, 'UTF-8' );
- $_SESSION['xml_file']=$_SESSION['CVbase_filename'].".xml";
- $_SESSION['xml_path_file']=$_SESSION['client_folder'].$_SESSION['xml_file'];
- $xmlcontent=$dom->dump_mem(true, 'utf-8');
- if(file_exists($_SESSION['xml_path_file']))
- {
- unlink($_SESSION['xml_path_file']);
- }
- $handle=fopen($_SESSION['xml_path_file'],'x+');
- fwrite($handle,$xmlcontent,strlen($xmlcontent));
- fclose($handle);
|
---------------
Freed102
|