Migration d'un squelette de SPIP2 vers SPIP3 - comments Migration d'un squelette de SPIP2 vers SPIP3 2019-01-04T15:10:35Z https://contrib.spip.net/Migration-d-un-squelette-de-SPIP2-vers-SPIP3#comment499287 2019-01-04T15:10:35Z <p>Suite à migration d'un nouveau site, j'ai révisité ou ajouté les dernières parties : <br />- Boucles avec jointures <br />- Tables de liens <br />- Jointures sans critère identifiant <br />- urls personnalisées</p> Migration d'un squelette de SPIP2 vers SPIP3 2013-01-29T17:48:14Z https://contrib.spip.net/Migration-d-un-squelette-de-SPIP2-vers-SPIP3#comment464832 2013-01-29T17:48:14Z <p>Bonjour<br class="autobr" /> j'ai le même souci d'utiliser la recherche multi-critère par mot clé sous spip3 du fait du changement de table de à . J'ai donc essayer de copier / coller ce que tu proposes, que j'ai mis dnas le fichier natif 'result_rec_mc.html'. <br class="autobr" /> La recherche se fait à partir de la page : <a href="http://www.infogm.org/spip.php?rubrique657" class="spip_url spip_out auto" rel="nofollow external">http://www.infogm.org/spip.php?rubrique657</a>.<br class="autobr" /> Quand je lance une recherche, j'ai droit au message d'erreur suivant : “Parse error: syntax error, unexpected T_VARIABLE in /homez.95/infogm/www/ecrire/public/evaluer_page.php(55) : eval()'d code on line 63”.<br class="autobr" /> J'ai aussi essayer de simplement faire rechercher / remplacer sur mon premier fichier tous les spip_mots_articles par spip_mots_liens et les .id_article par des id.objet...Mais cette solution ne me donnait tout simplement aucun résultat... Jamais. Or j'ai bien des articles liés à des mots clés. <br class="autobr" /> Merci pour vos lumières</p> Migration d'un squelette de SPIP2 vers SPIP3 2013-01-29T13:49:11Z https://contrib.spip.net/Migration-d-un-squelette-de-SPIP2-vers-SPIP3#comment464820 2013-01-29T13:49:11Z <p>Dans une rubrique, il est recommandé que soit il y ait des numéros à tous les articles, soit il n'y en ait pas du tout.</p> Migration d'un squelette de SPIP2 vers SPIP3 2012-11-15T15:59:53Z https://contrib.spip.net/Migration-d-un-squelette-de-SPIP2-vers-SPIP3#comment463170 2012-11-15T15:59:53Z <p>C'est pas si simple je crois: car je constate aussi que <code>{par num titre}</code> ne trie pas par <code>titre</code> quand les titres ne contiennent pas de numéro !</p> Migration d'un squelette de SPIP2 vers SPIP3 2012-11-02T23:32:18Z https://contrib.spip.net/Migration-d-un-squelette-de-SPIP2-vers-SPIP3#comment462804 2012-11-02T23:32:18Z <p>C'était ma prochaine suggestion (mais avant, s'assurer que la ré-écriture avec l'API ne casse rien) Mais ne pouvant pas tester, je n'étais pas certain que cette seule modification aurait suffit (je pensais qu'il aurait fallu rajouter dans votre cas que “<code>objet='article'</code>” en plus du lien sur <code>id_objet</code> (car la nouvelle structure permet de lier n'importe quel objet aux mots clés, pas que les articles... donc quand vous aurez des articles et des rubriques de même ID rattaché au même mot-clé...)</p> <div class="precode"><pre dir="ltr" style="text-align: left;" class="php"><code><div class="result_rm"> <span class="kw2"><?php</span> <span class="coMULTI">/********************************************************************* * RECHERCHE MULTI-CRITERES - MODELE AFFICHAGE DES RESULTATS * * @author * -2008-08: [Dominique (Dom) Lepaisant->www.tispip.etab.ac-caen.fr] * -2008-08: [Stéphanie De Nadaï->www.webdesigneuse.net] * - [Paul Sanchez->www.Netdeveloppeur.com] (contrib initiale) * * @copyright * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *********************************************************************/</span> <span class="re0">$url</span> <span class="sy0">=</span> <a href="http://www.php.net/parse_url" rel='nofollow'><span class="kw3">parse_url</span></a><span class="br0">&#40;</span><span class="re0">$_SERVER</span><span class="br0">&#91;</span><span class="st_h">'QUERY_STRING'</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="re0">$param</span> <span class="sy0">=</span> <span class="re0">$url</span><span class="br0">&#91;</span><span class="st_h">'path'</span><span class="br0">&#93;</span><span class="sy0">;</span> <span class="re0">$pos</span> <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> <span class="re0">$indice</span> <span class="sy0">=</span> <span class="nu0">255</span><span class="sy0">;</span> <span class="kw1">if</span> <span class="br0">&#40;</span>_request<span class="br0">&#40;</span><span class="st_h">'idmot'</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="co1">// Récupération du nombre de jours</span> <span class="co1">// pour periodicité de la rechercher</span> <span class="re0">$nbjour</span> <span class="sy0">=</span> <a href="http://www.php.net/intval" rel='nofollow'><span class="kw3">intval</span></a><span class="br0">&#40;</span>_request<span class="br0">&#40;</span><span class="st_h">'nbjour'</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// Récupération du nombre de jours</span> <span class="co1">// pour periodicité de la rechercher</span> <span class="kw1">if</span> <span class="br0">&#40;</span>_request<span class="br0">&#40;</span><span class="st_h">'onlyrub'</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$idonlyrub</span> <span class="sy0">=</span> <a href="http://www.php.net/intval" rel='nofollow'><span class="kw3">intval</span></a><span class="br0">&#40;</span>_request<span class="br0">&#40;</span><span class="st_h">'rubnum'</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="re0">$idonlyrub</span> <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> <span class="co1">// 1 = Tous les mots doivent être associés aux articles trouvés</span> <span class="re0">$allword</span> <span class="sy0">=</span> <a href="http://www.php.net/intval" rel='nofollow'><span class="kw3">intval</span></a><span class="br0">&#40;</span>_request<span class="br0">&#40;</span><span class="st_h">'allword'</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="re0">$sql_in_mot</span> <span class="sy0">=</span> <a href="http://www.php.net/implode" rel='nofollow'><span class="kw3">implode</span></a><span class="br0">&#40;</span><span class="st_h">','</span><span class="sy0">,</span> _request<span class="br0">&#40;</span><span class="st_h">'idmot'</span><span class="br0">&#41;</span> <span class="br0">&#41;</span><span class="sy0">;</span> <span class="re0">$nbmot</span> <span class="sy0">=</span> <a href="http://www.php.net/count" rel='nofollow'><span class="kw3">count</span></a><span class="br0">&#40;</span>_request<span class="br0">&#40;</span><span class="st_h">'idmot'</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="re0">$result</span> <span class="sy0">=</span> sql_select<span class="br0">&#40;</span><span class="st_h">'id_mot, titre'</span><span class="sy0">,</span> <span class="st_h">'spip_mots'</span><span class="sy0">,</span> <span class="st_h">'id_mot IN ('</span><span class="sy0">.</span><span class="re0">$sql_in_mot</span><span class="sy0">.</span><span class="st_h">')'</span><span class="sy0">,</span> <span class="st_h">''</span><span class="sy0">,</span> <span class="st_h">'id_mot,titre"'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="re0">$tabmot</span> <span class="sy0">=</span> <span class="st0">""</span><span class="sy0">;</span> <span class="re0">$nbcol</span> <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> <span class="re0">$nbcolmax</span> <span class="sy0">=</span> <span class="nu0">4</span><span class="sy0">;</span> <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$result</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$compt</span> <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> <span class="kw1">while</span> <span class="br0">&#40;</span><span class="re0">$row</span> <span class="sy0">=</span> sql_fetch<span class="br0">&#40;</span><span class="re0">$result</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <a href="http://www.php.net/extract" rel='nofollow'><span class="kw3">extract</span></a><span class="br0">&#40;</span><span class="re0">$row</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="re0">$titre</span> <span class="sy0">=</span> supprimer_numero<span class="br0">&#40;</span><span class="re0">$titre</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$nbcol</span> <span class="sy0">==</span> <span class="re0">$nbcolmax</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$nbcol</span> <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> <span class="br0">&#125;</span> <span class="re0">$tabmot</span> <span class="sy0">.=</span> <span class="st0">"<a class=<span class="es1">\"</span>spanblock txtgris<span class="es1">\"</span> href=<span class="es1">\"</span>./spip.php?page=mot&mots[]=<span class="es4">$id_mot</span><span class="es1">\"</span>><span class=<span class="es1">\"</span>cle<span class="es1">\"</span>><span class="es4">$titre</span></span></a>"</span><span class="sy0">;</span> <span class="re0">$nbcol</span> <span class="sy0">+=</span> <span class="nu0">1</span><span class="sy0">;</span> <span class="br0">&#125;</span> sql_free<span class="br0">&#40;</span><span class="re0">$result</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="br0">&#125;</span> <span class="re0">$sql_where</span><span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="st0">"spip_mots_liens.objet='article'"</span> <span class="re0">$sql_where</span><span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="st0">"spip_mots_liens.id_mot IN ("</span><span class="sy0">.</span><span class="re0">$sql_in_mot</span><span class="sy0">.</span><span class="st0">") "</span><span class="sy0">;</span> <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$nbjour</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$datedeb</span> <span class="sy0">=</span> <a href="http://www.php.net/date" rel='nofollow'><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="st0">"Y-m-d"</span><span class="sy0">,</span> <a href="http://www.php.net/mktime" rel='nofollow'><span class="kw3">mktime</span></a><span class="br0">&#40;</span><span class="nu0">0</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <a href="http://www.php.net/date" rel='nofollow'><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="st0">"m"</span><span class="br0">&#41;</span><span class="sy0">,</span> <span class="br0">&#40;</span><a href="http://www.php.net/date" rel='nofollow'><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="st0">"d"</span><span class="br0">&#41;</span> <span class="sy0">-</span> <span class="re0">$nbjour</span><span class="br0">&#41;</span><span class="sy0">,</span> <a href="http://www.php.net/date" rel='nofollow'><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="st0">"Y"</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="re0">$sql_where</span><span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="st0">"spip_articles.date >= '<span class="es4">$datedeb</span>' "</span><span class="sy0">;</span> <span class="br0">&#125;</span> <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$idonlyrub</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$sql_where</span><span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="st0">"spip_rubriques.id_rubrique = <span class="es4">$idonlyrub</span> "</span><span class="sy0">;</span> <span class="br0">&#125;</span> <span class="re0">$sql_where</span><span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="st0">"spip_articles.statut = 'publie' GROUP BY spip_articles.id_article"</span><span class="sy0">;</span> <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$order</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$sql_order</span> <span class="sy0">=</span> <span class="st0">"spip_rubriques.id_rubrique, num DESC, spip_mots_liens.id_mot, spip_articles.date DESC"</span><span class="sy0">;</span> <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span> <span class="re0">$sql_order</span> <span class="sy0">=</span> <span class="st0">"num DESC, spip_mots_liens.id_mot, spip_rubriques.id_rubrique, spip_articles.date DESC"</span><span class="sy0">;</span> <span class="br0">&#125;</span> <span class="re0">$result</span> <span class="sy0">=</span> sql_select<span class="br0">&#40;</span><span class="st_h">'COUNT(*) AS num, spip_articles.id_article, spip_rubriques.id_rubrique, spip_rubriques.titre AS titrerub'</span><span class="sy0">,</span> <span class="st_h">'spip_articles INNER JOIN spip_rubriques ON spip_rubriques.id_rubrique = spip_articles.id_rubrique INNER JOIN spip_mots_liens ON spip_mots_liens.id_objet = spip_articles.id_article'</span><span class="sy0">,</span> <span class="re0">$sql_where</span><span class="sy0">,</span> <span class="st_h">''</span><span class="sy0">,</span> <span class="re0">$sql_order</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="re0">$nbart</span> <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> <span class="re0">$resultataffiche</span> <span class="sy0">=</span> <span class="st0">""</span><span class="sy0">;</span> <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$result</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$titrerub</span> <span class="sy0">=</span> supprimer_numero<span class="br0">&#40;</span><span class="re0">$titrerub</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="re0">$idrub</span> <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> <span class="re0">$listidmot2</span> <span class="sy0">=</span> <span class="st0">""</span><span class="sy0">;</span> <span class="re0">$listidmotprec</span> <span class="sy0">=</span> <span class="st0">""</span><span class="sy0">;</span> <span class="kw1">while</span> <span class="br0">&#40;</span><span class="re0">$row</span> <span class="sy0">=</span> sql_fetch<span class="br0">&#40;</span><span class="re0">$result</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <a href="http://www.php.net/extract" rel='nofollow'><span class="kw3">extract</span></a><span class="br0">&#40;</span><span class="re0">$row</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="kw1">if</span> <span class="br0">&#40;</span><span class="br0">&#40;</span><span class="re0">$num</span> <span class="sy0">!=</span> <span class="re0">$nbmot</span><span class="br0">&#41;</span> <span class="sy0">&&</span> <span class="br0">&#40;</span><span class="re0">$allword</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="kw1">break</span><span class="sy0">;</span> <span class="br0">&#125;</span> <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$idrub</span> <span class="sy0">!=</span> <span class="re0">$id_rubrique</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="kw1">if</span> <span class="br0">&#40;</span><span class="br0">&#40;</span><span class="re0">$pospoint</span> <span class="sy0">=</span> <a href="http://www.php.net/strrpos" rel='nofollow'><span class="kw3">strrpos</span></a><span class="br0">&#40;</span><span class="re0">$titrerub</span><span class="sy0">,</span> <span class="st0">". "</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy0">===</span> <span class="kw4">FALSE</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$titrerub2</span><span class="sy0">=</span><span class="re0">$titrerub</span><span class="sy0">;</span> <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span> <span class="kw1">if</span> <span class="br0">&#40;</span><a href="http://www.php.net/is_numeric" rel='nofollow'><span class="kw3">is_numeric</span></a><span class="br0">&#40;</span><a href="http://www.php.net/substr" rel='nofollow'><span class="kw3">substr</span></a><span class="br0">&#40;</span><span class="re0">$titrerub</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="re0">$pospoint</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy0">==</span> <span class="kw4">false</span><span class="br0">&#41;</span> <span class="re0">$titrerub2</span> <span class="sy0">=</span> <span class="re0">$titrerub</span><span class="sy0">;</span> <span class="kw1">else</span> <span class="re0">$titrerub2</span> <span class="sy0">=</span> <a href="http://www.php.net/substr" rel='nofollow'><span class="kw3">substr</span></a><span class="br0">&#40;</span><span class="re0">$titrerub</span><span class="sy0">,</span> <span class="re0">$pospoint</span> <span class="sy0">+</span> <span class="nu0">2</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="br0">&#125;</span> <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$order</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$resultataffiche</span><span class="sy0">.=</span> <span class="st_h">'<p><a href="'</span><span class="sy0">.</span> generer_url_entite<span class="br0">&#40;</span><span class="re0">$id_rubrique</span><span class="sy0">,</span> <span class="st_h">'rubrique'</span><span class="br0">&#41;</span> <span class="sy0">.</span><span class="st0">"<span class="es1">\"</span>><span class="es4">$titrerub2</span> :</a></p>"</span><span class="sy0">;</span> <span class="br0">&#125;</span> <span class="br0">&#125;</span> <span class="re0">$result2</span> <span class="sy0">=</span> sql_select<span class="br0">&#40;</span><span class="st_h">'spip_articles.id_article AS artid,spip_articles.id_secteur AS id_secteur, spip_articles.titre AS titreart, spip_articles.date, spip_mots.id_mot, spip_mots.titre AS titremot'</span><span class="sy0">,</span> <span class="st_h">'spip_articles INNER JOIN spip_mots_liens ON spip_mots_liens.id_objet = spip_articles.id_article INNER JOIN spip_mots ON spip_mots.id_mot = spip_mots_liens.id_mot '</span><span class="sy0">,</span> <span class="st0">"spip_articles.id_article = <span class="es4">$id_article</span> AND spip_mots_liens.id_mot IN ("</span><span class="sy0">.</span><span class="re0">$sql_in_mot</span><span class="sy0">.</span><span class="st0">") AND statut = 'publie' AND spip_mots_liens.objet = 'article' "</span><span class="sy0">,</span> <span class="st_h">''</span><span class="sy0">,</span> <span class="st_h">'spip_mots.id_mot'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$result2</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$listmot</span> <span class="sy0">=</span> <span class="st0">"<h4 class=<span class="es1">\"</span>titremots_mc<span class="es1">\"</span>>"</span><span class="sy0">;</span> <span class="re0">$titrearticle</span> <span class="sy0">=</span> <span class="st0">""</span><span class="sy0">;</span> <span class="re0">$dataffich</span> <span class="sy0">=</span> <span class="st0">""</span><span class="sy0">;</span> <span class="re0">$idart</span> <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> <span class="kw1">while</span> <span class="br0">&#40;</span><span class="re0">$row2</span> <span class="sy0">=</span> sql_fetch<span class="br0">&#40;</span><span class="re0">$result2</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <a href="http://www.php.net/extract" rel='nofollow'><span class="kw3">extract</span></a><span class="br0">&#40;</span><span class="re0">$row2</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="re0">$listidmot2</span> <span class="sy0">.=</span> <span class="st0">"<span class="es4">$id_mot</span>,"</span><span class="sy0">;</span> <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$idart</span> <span class="sy0">==</span> <span class="nu0">0</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$titrearticle</span> <span class="sy0">=</span> supprimer_numero<span class="br0">&#40;</span><span class="re0">$titreart</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span><span class="br0">&#40;</span><span class="br0">&#40;</span><span class="re0">$pospoint</span> <span class="sy0">=</span> <a href="http://www.php.net/strpos" rel='nofollow'><span class="kw3">strpos</span></a><span class="br0">&#40;</span><span class="re0">$titrearticle</span><span class="sy0">,</span> <span class="st_h">'.'</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy0">===</span> <span class="kw4">FALSE</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="kw1">if</span> <span class="br0">&#40;</span><a href="http://www.php.net/is_numeric" rel='nofollow'><span class="kw3">is_numeric</span></a><span class="br0">&#40;</span><a href="http://www.php.net/substr" rel='nofollow'><span class="kw3">substr</span></a><span class="br0">&#40;</span><span class="re0">$titrearticle</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="re0">$pospoint</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy0">==</span> <span class="kw4">true</span><span class="br0">&#41;</span> <span class="re0">$titrearticle</span> <span class="sy0">=</span> <a href="http://www.php.net/substr" rel='nofollow'><span class="kw3">substr</span></a><span class="br0">&#40;</span><span class="re0">$titrearticle</span><span class="sy0">,</span> <span class="re0">$pospoint</span> <span class="sy0">+</span> <span class="nu0">2</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="br0">&#125;</span> <span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span><span class="br0">&#40;</span><span class="br0">&#40;</span><span class="re0">$pospoint</span> <span class="sy0">=</span> <a href="http://www.php.net/strpos" rel='nofollow'><span class="kw3">strpos</span></a><span class="br0">&#40;</span><span class="re0">$titremot</span><span class="sy0">,</span> <span class="st_h">'.'</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy0">===</span> <span class="kw4">FALSE</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="kw1">if</span> <span class="br0">&#40;</span><a href="http://www.php.net/is_numeric" rel='nofollow'><span class="kw3">is_numeric</span></a><span class="br0">&#40;</span><a href="http://www.php.net/substr" rel='nofollow'><span class="kw3">substr</span></a><span class="br0">&#40;</span><span class="re0">$titremot</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="re0">$pospoint</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy0">==</span> <span class="kw4">true</span><span class="br0">&#41;</span> <span class="re0">$titremot</span> <span class="sy0">=</span> <a href="http://www.php.net/substr" rel='nofollow'><span class="kw3">substr</span></a><span class="br0">&#40;</span><span class="re0">$titremot</span><span class="sy0">,</span> <span class="re0">$pospoint</span> <span class="sy0">+</span> <span class="nu0">2</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="br0">&#125;</span> <span class="re0">$dataffich</span> <span class="sy0">=</span> <a href="http://www.php.net/date" rel='nofollow'><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="st0">"d/m/Y"</span><span class="sy0">,</span> <a href="http://www.php.net/strtotime" rel='nofollow'><span class="kw3">strtotime</span></a><span class="br0">&#40;</span><span class="re0">$date</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$order</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$nbart</span> <span class="sy0">+=</span> <span class="nu0">1</span><span class="sy0">;</span> <span class="re0">$resultataffiche</span> <span class="sy0">.=</span> <span class="st_h">'<li><a class="titrearticle_mc" href="'</span><span class="sy0">.</span> generer_url_entite<span class="br0">&#40;</span><span class="re0">$artid</span><span class="sy0">,</span> <span class="st_h">'article'</span><span class="br0">&#41;</span> <span class="sy0">.</span><span class="st0">"<span class="es1">\"</span>><span class="es4">$titrearticle</span></a> <small><span class="es4">$dataffich</span> </small>"</span><span class="sy0">;</span> <span class="re0">$resultataffiche</span> <span class="sy0">.=</span> <span class="st0">"<span class="es4">$titremot</span>"</span><span class="sy0">;</span> <span class="br0">&#125;</span> <span class="re0">$listmot</span> <span class="sy0">.=</span> <span class="st0">"<a class=<span class="es1">\"</span>spanblock<span class="es1">\"</span> href=<span class="es1">\"</span>./spip.php?page=mot&mots[]=<span class="es4">$id_mot</span><span class="es1">\"</span>><span class=<span class="es1">\"</span>cle<span class="es1">\"</span>><span class="es4">$titremot</span></span></a>"</span><span class="sy0">;</span> <span class="re0">$idart</span> <span class="sy0">=</span> <span class="nu0">1</span><span class="sy0">;</span> <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span> <span class="re0">$listmot</span> <span class="sy0">.=</span> <span class="st0">"<a class=<span class="es1">\"</span>spanblock<span class="es1">\"</span> href=<span class="es1">\"</span>./spip.php?page=mot&mots[]=<span class="es4">$id_mot</span><span class="es1">\"</span>><span class=<span class="es1">\"</span>cle<span class="es1">\"</span>><span class="es4">$titremot</span></span></a>"</span><span class="sy0">;</span> <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$order</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$resultataffiche</span> <span class="sy0">.=</span> <span class="st0">"<a class=<span class="es1">\"</span>spanblock<span class="es1">\"</span> href=<span class="es1">\"</span>./spip.php?page=mot&mots[]=<span class="es4">$id_mot</span><span class="es1">\"</span>><span class=<span class="es1">\"</span>cle<span class="es1">\"</span>><span class="es4">$titremot</span></span></a>"</span><span class="sy0">;</span> <span class="br0">&#125;</span> <span class="br0">&#125;</span> <span class="br0">&#125;</span> <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$order</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$resultataffiche</span> <span class="sy0">.=</span> <span class="st0">"</li>"</span><span class="sy0">;</span> <span class="br0">&#125;</span> sql_free<span class="br0">&#40;</span><span class="re0">$result2</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span><span class="re0">$order</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$listidmot2</span> <span class="sy0">!=</span> <span class="re0">$listmodidprec</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$resultataffiche</span> <span class="sy0">.=</span> <span class="st0">" <span class="es4">$listmot</span> </h4>"</span><span class="sy0">;</span> <span class="br0">&#125;</span> <span class="re0">$nbart</span> <span class="sy0">+=</span> <span class="nu0">1</span><span class="sy0">;</span> <span class="kw1">switch</span> <span class="br0">&#40;</span><span class="re0">$id_secteur</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="kw1">case</span> <span class="nu0">1</span><span class="sy0">:</span> <span class="re0">$variable</span> <span class="sy0">=</span> <span class="nu0">63</span><span class="sy0">;</span> <span class="re0">$secteur</span> <span class="sy0">=</span> <span class="st0">"Ma classe"</span><span class="sy0">;</span> <span class="kw1">break</span><span class="sy0">;</span> <span class="kw1">case</span> <span class="nu0">3</span><span class="sy0">:</span> <span class="re0">$variable</span> <span class="sy0">=</span> <span class="nu0">66</span><span class="sy0">;</span> <span class="re0">$secteur</span> <span class="sy0">=</span> <span class="st0">"Applications"</span><span class="sy0">;</span> <span class="kw1">break</span><span class="sy0">;</span> <span class="kw1">case</span> <span class="nu0">4</span><span class="sy0">:</span> <span class="re0">$variable</span> <span class="sy0">=</span> <span class="nu0">65</span><span class="sy0">;</span> <span class="re0">$secteur</span> <span class="sy0">=</span> <span class="st0">"Tutoriels"</span><span class="sy0">;</span> <span class="kw1">break</span><span class="sy0">;</span> <span class="kw1">case</span> <span class="nu0">5</span><span class="sy0">:</span> <span class="re0">$variable</span> <span class="sy0">=</span> <span class="nu0">64</span><span class="sy0">;</span> <span class="re0">$secteur</span> <span class="sy0">=</span> <span class="st0">"Liens"</span><span class="sy0">;</span> <span class="kw1">break</span><span class="sy0">;</span> <span class="br0">&#125;</span> <span class="re0">$resultataffiche</span> <span class="sy0">.=</span> <span class="st_h">'<li class="br"><a class="titrearticle_mc" href="'</span><span class="sy0">.</span> generer_url_entite<span class="br0">&#40;</span><span class="re0">$id_article</span><span class="sy0">,</span> <span class="st_h">'article'</span><span class="br0">&#41;</span><span class="sy0">.</span> <span class="st0">"<span class="es1">\"</span>><span class="es4">$titrearticle</span></a><small>publié le : <em><span class="es4">$dataffich</span></em> , dans la rubrique <em><a href=<span class="es1">\"</span>"</span><span class="sy0">.</span> generer_url_entite<span class="br0">&#40;</span><span class="re0">$id_secteur</span><span class="sy0">,</span><span class="st_h">'rubrique'</span><span class="br0">&#41;</span> <span class="sy0">.</span><span class="st0">"&mots[]=<span class="es4">$variable</span><span class="es1">\"</span>><span class="es4">$secteur</span></a></em></small></li>"</span><span class="sy0">;</span> <span class="re0">$listmodidprec</span> <span class="sy0">=</span> <span class="re0">$listidmot2</span><span class="sy0">;</span> <span class="re0">$listidmot2</span> <span class="sy0">=</span> <span class="st0">""</span><span class="sy0">;</span> <span class="br0">&#125;</span> <span class="br0">&#125;</span> <span class="re0">$idrub</span> <span class="sy0">=</span> <span class="re0">$id_rubrique</span><span class="sy0">;</span> <span class="br0">&#125;</span> sql_free<span class="br0">&#40;</span><span class="re0">$result</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$nbart</span> <span class="sy0">==</span> <span class="nu0">0</span> <span class="sy0">||</span> <span class="re0">$nbart</span> <span class="sy0">==</span> <span class="nu0">1</span><span class="br0">&#41;</span> <span class="re0">$nbart_txt</span> <span class="sy0">=</span> <span class="st0">"<:rmc:article_trouve:>"</span><span class="sy0">;</span> <span class="kw1">else</span> <span class="re0">$nbart_txt</span> <span class="sy0">=</span> <span class="st0">"<:rmc:articles_trouves:>"</span><span class="sy0">;</span> <span class="kw1">echo</span> <span class="st0">"<div class=<span class="es1">\"</span>contre-encart<span class="es1">\"</span>>"</span><span class="sy0">;</span> <span class="kw1">echo</span> <span class="st0">"<p class=<span class="es1">\"</span>mots_mc<span class="es1">\"</span>><span class=<span class="es1">\"</span>spanblock <span class="es1">\"</span>>Mots séléctionnés : </span><br />"</span><span class="sy0">.</span><a href="http://www.php.net/substr" rel='nofollow'><span class="kw3">substr</span></a><span class="br0">&#40;</span><span class="re0">$tabmot</span><span class="sy0">,</span> <span class="nu0">0</span><span class="br0">&#41;</span><span class="sy0">.</span><span class="st0">" </p>"</span><span class="sy0">;</span> <span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$nbart</span> <span class="sy0">==</span> <span class="nu0">0</span> <span class="br0">&#41;</span> <span class="re0">$nbart_txt</span> <span class="sy0">=</span> <span class="st0">"Aucun article ne correspond à votre recherche"</span><span class="sy0">;</span> <span class="kw1">else</span> <span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$nbart</span> <span class="sy0">==</span> <span class="nu0">1</span> <span class="br0">&#41;</span> <span class="re0">$nbart_txt</span> <span class="sy0">=</span> <span class="st0">" article correspond à votre recherche"</span><span class="sy0">;</span> <span class="kw1">else</span> <span class="re0">$nbart_txt</span> <span class="sy0">=</span> <span class="st0">"articles correspondent à votre recherche"</span><span class="sy0">;</span> <span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$nbart</span> <span class="sy0">==</span> <span class="nu0">0</span> <span class="br0">&#41;</span> <span class="kw1">echo</span> <span class="st0">"<p class=<span class="es1">\"</span>mots_mc<span class="es1">\"</span>> <span class="es4">$nbart_txt</span><br /><a href=<span class="es1">\"</span>#SELF<span class="es1">\"</span>>Nouvelle recherche</a></p>"</span><span class="sy0">;</span> <span class="kw1">else</span> <span class="kw1">echo</span> <span class="st0">"<p class=<span class="es1">\"</span>mots_mc<span class="es1">\"</span>> <span class="es4">$nbart</span> <span class="es4">$nbart_txt</span><br /><a href=<span class="es1">\"</span>#SELF<span class="es1">\"</span>>Nouvelle recherche</a></p>"</span><span class="sy0">;</span> <span class="kw1">echo</span> <span class="st_h">'<div class="liste-articles">'</span><span class="sy0">.</span><span class="re0">$resultataffiche</span><span class="sy0">.</span><span class="st0">"</div></div>"</span><span class="sy0">;</span> <span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$nbart</span><span class="br0">&#41;</span> <span class="kw1">echo</span> <span class="st0">"<br class=<span class="es1">\"</span>dixpixels<span class="es1">\"</span> /><p class=<span class="es1">\"</span>mots_mc<span class="es1">\"</span>><a href=<span class="es1">\"</span>#SELF<span class="es1">\"</span>>Nouvelle recherche</a></p>"</span><span class="sy0">;</span> <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span> <span class="kw1">echo</span> <span class="st0">"<p class=<span class="es1">\"</span>mots_mc<span class="es1">\"</span>>Aucun article ne correspond à votre recherche</p>"</span><span class="sy0">;</span> <span class="br0">&#125;</span> <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span> <span class="kw1">echo</span> <span class="st0">"<div class=<span class="es1">\"</span>mots_mc<span class="es1">\"</span>><:rmc:selectionner_mot:></div>"</span><span class="sy0">;</span> <span class="co1">// inutile si form recherche inclus</span> <span class="co1">// echo "<br /><a href=\"".$_SERVER['HTTP_REFERER']."\" onclick=\"javascript:history.back(); return false;\">Retour</a></p>";</span> <span class="br0">&#125;</span> <span class="sy1">?></span> </div></code></pre></div> Migration d'un squelette de SPIP2 vers SPIP3 2012-11-02T19:34:53Z https://contrib.spip.net/Migration-d-un-squelette-de-SPIP2-vers-SPIP3#comment462797 2012-11-02T19:34:53Z <p>Bonsoir!</p> <p>Désolé je me suis trompé en postant tout à l'heure pour dire que c'était résolu et j'ai créé un autre post au lieu de répondre.</p> <p>C'était bien lié aux modifications de la base de données suite au passage en spip 3.</p> <p>La table <strong>spip_mot_articles</strong> est devenue <strong>spip_mots_liens</strong> et du coup <strong>spip_mots_articles.id_article</strong> devient <strong>spip_mots_liens.id_objet</strong></p> <p>Merci d'avoir pris le temps de regarder ! :)</p> <p>Maintenant c'est vrai qu'il faudrait que je recode tout ça directement en SPIP mais j'avoue que je ne sais pas trop par quel bout commencer. J'avais déjà passé pas mal de temps à bidouiller ce code en php (dont je ne suis pas l'auteur) pour l'adapter à mes besoins. Je pense que c'est au delà de mes compétences pour le moment!</p> <p>En tous cas merci du temps que vous m'avez accordé, d'autant plus que le code est plutôt indigeste présenté comme ça!<br class="autobr" /> Mike</p> Migration d'un squelette de SPIP2 vers SPIP3 2012-11-02T13:56:17Z https://contrib.spip.net/Migration-d-un-squelette-de-SPIP2-vers-SPIP3#comment462786 2012-11-02T13:56:17Z <p>Bonjour Mike.</p> <p>Dites-moi si ra ré-écriture suivante marche avec la 2.1 :</p> <div class="precode"><pre dir="ltr" style="text-align: left;"><code><div class="result_rm"> <?php /********************************************************************* * RECHERCHE MULTI-CRITERES - MODELE AFFICHAGE DES RESULTATS * * @author * -2008-08: [Dominique (Dom) Lepaisant->www.tispip.etab.ac-caen.fr] * -2008-08: [Stéphanie De Nadaï->www.webdesigneuse.net] * - [Paul Sanchez->www.Netdeveloppeur.com] (contrib initiale) * * @copyright * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *********************************************************************/ $url = parse_url($_SERVER['QUERY_STRING']); $param = $url['path']; $pos = 0; $indice = 255; if (_request('idmot')) { // Récupération du nombre de jours // pour periodicité de la rechercher $nbjour = intval(_request('nbjour')); // Récupération du nombre de jours // pour periodicité de la rechercher if (_request('onlyrub')) { $idonlyrub = intval(_request('rubnum')); } else $idonlyrub = 0; // 1 = Tous les mots doivent être associés aux articles trouvés $allword = intval(_request('allword')); $sql_in_mot = implode(',', _request('idmot') ); $nbmot = count(_request('idmot')); $result = sql_select('id_mot, titre', 'spip_mots', 'id_mot IN ('.$sql_in_mot.')', '', 'id_mot,titre"'); $tabmot = ""; $nbcol = 0; $nbcolmax = 4; if ($result) { $compt = 0; while ($row = sql_fetch($result)) { extract($row); $titre = supprimer_numero($titre); if ($nbcol == $nbcolmax) { $nbcol = 0; } $tabmot .= "<a class=\"spanblock txtgris\" href=\"./spip.php?page=mot&mots[]=$id_mot\"><span class=\"cle\">$titre</span></a>"; $nbcol += 1; } sql_free($result); } $sql_where[] = "spip_mots_articles.id_mot IN (".$sql_in_mot.") "; if ($nbjour) { $datedeb = date("Y-m-d", mktime(0, 0, 0, date("m"), (date("d") - $nbjour), date("Y"))); $sql_where[] = "spip_articles.date >= '$datedeb' "; } if ($idonlyrub) { $sql_where[] = "spip_rubriques.id_rubrique = $idonlyrub "; } $sql_where[] = "spip_articles.statut = 'publie' GROUP BY spip_articles.id_article"; if ($order) { $sql_order = "spip_rubriques.id_rubrique, NUM DESC, spip_mots_articles.id_mot, spip_articles.date DESC"; } else { $sql_order = "NUM DESC, spip_mots_articles.id_mot, spip_rubriques.id_rubrique, spip_articles.date DESC"; } $result = sql_select('COUNT(*) AS num, spip_articles.id_article, spip_rubriques.id_rubrique, spip_rubriques.titre AS titrerub', 'spip_articles INNER JOIN spip_rubriques ON spip_rubriques.id_rubrique = spip_articles.id_rubrique INNER JOIN spip_mots_articles ON spip_mots_articles.id_article = spip_articles.id_article', $sql_where, '', $sql_order); $nbart = 0; $resultataffiche = ""; if ($result) { $titrerub = supprimer_numero($titrerub); $idrub = 0; $listidmot2 = ""; $listidmotprec = ""; while ($row = sql_fetch($result)) { extract($row); if (($num != $nbmot) && ($allword)) { break; } if ($idrub != $id_rubrique) { if (($pospoint = strrpos($titrerub, ". ")) === FALSE) { $titrerub2=$titrerub; } else { if (is_numeric(substr($titrerub, 0, $pospoint)) == false) $titrerub2 = $titrerub; else $titrerub2 = substr($titrerub, $pospoint + 2); } if ($order) { $resultataffiche.= '<p><a href="'. generer_url_entite($id_rubrique, 'rubrique') ."\">$titrerub2 :</a></p>"; } } $result2 = sql_select('spip_articles.id_article AS artid,spip_articles.id_secteur AS id_secteur, spip_articles.titre AS titreart, spip_articles.date, spip_mots.id_mot, spip_mots.titre AS titremot', 'spip_articles INNER JOIN spip_mots_articles ON spip_mots_articles.id_article = spip_articles.id_article INNER JOIN spip_mots ON spip_mots.id_mot = spip_mots_articles.id_mot ', "spip_articles.id_article = $id_article AND spip_mots_articles.id_mot IN (".$sql_in_mot.") AND statut = 'publie' ", '', 'spip_mots.id_mot'); if ($result2) { $listmot = "<h4 class=\"titremots_mc\">"; $titrearticle = ""; $dataffich = ""; $idart = 0; while ($row2 = sql_fetch($result2)) { extract($row2); $listidmot2 .= "$id_mot,"; if ($idart == 0) { $titrearticle = supprimer_numero($titreart); if (!(($pospoint = strpos($titrearticle, '.')) === FALSE)) { if (is_numeric(substr($titrearticle, 0, $pospoint)) == true) $titrearticle = substr($titrearticle, $pospoint + 2); } if (!(($pospoint = strpos($titremot, '.')) === FALSE)) { if (is_numeric(substr($titremot, 0, $pospoint)) == true) $titremot = substr($titremot, $pospoint + 2); } $dataffich = date("d/m/Y", strtotime($date)); if ($order) { $nbart += 1; $resultataffiche .= '<li><a class="titrearticle_mc" href="'. generer_url_entite($artid, 'article') ."\">$titrearticle</a> <small>$dataffich </small>"; $resultataffiche .= "$titremot"; } $listmot .= "<a class=\"spanblock\" href=\"./spip.php?page=mot&mots[]=$id_mot\"><span class=\"cle\">$titremot</span></a>"; $idart = 1; } else { $listmot .= "<a class=\"spanblock\" href=\"./spip.php?page=mot&mots[]=$id_mot\"><span class=\"cle\">$titremot</span></a>"; if ($order) { $resultataffiche .= "<a class=\"spanblock\" href=\"./spip.php?page=mot&mots[]=$id_mot\"><span class=\"cle\">$titremot</span></a>"; } } } if ($order) { $resultataffiche .= "</li>"; } sql_free($result2); if (!$order) { if ($listidmot2 != $listmodidprec) { $resultataffiche .= " $listmot </h4>"; } $nbart += 1; switch ($id_secteur) { case 1: $variable = 63; $secteur = "Ma classe"; break; case 3: $variable = 66; $secteur = "Applications"; break; case 4: $variable = 65; $secteur = "Tutoriels"; break; case 5: $variable = 64; $secteur = "Liens"; break; } $resultataffiche .= '<li class="br"><a class="titrearticle_mc" href="'. generer_url_entite($id_article, 'article'). "\">$titrearticle</a><small>publié le : <em>$dataffich</em> , dans la rubrique <em><a href=\"". generer_url_entite($id_secteur,'rubrique') ."&mots[]=$variable\">$secteur</a></em></small></li>"; $listmodidprec = $listidmot2; $listidmot2 = ""; } } $idrub = $id_rubrique; } sql_free($result); if($nbart == 0 || $nbart == 1) $nbart_txt = "<:rmc:article_trouve:>"; else $nbart_txt = "<:rmc:articles_trouves:>"; echo "<div class=\"contre-encart\">"; echo "<p class=\"mots_mc\"><span class=\"spanblock \">Mots séléctionnés : </span><br />".substr($tabmot, 0)." </p>"; if($nbart == 0 ) $nbart_txt = "Aucun article ne correspond à votre recherche"; else if($nbart == 1 ) $nbart_txt = " article correspond à votre recherche"; else $nbart_txt = "articles correspondent à votre recherche"; if($nbart == 0 ) echo "<p class=\"mots_mc\"> $nbart_txt<br /><a href=\"#SELF\">Nouvelle recherche</a></p>"; else echo "<p class=\"mots_mc\"> $nbart $nbart_txt<br /><a href=\"#SELF\">Nouvelle recherche</a></p>"; echo '<div class="liste-articles">'.$resultataffiche."</div></div>"; if($nbart) echo "<br class=\"dixpixels\" /><p class=\"mots_mc\"><a href=\"#SELF\">Nouvelle recherche</a></p>"; } else { echo "<p class=\"mots_mc\">Aucun article ne correspond à votre recherche</p>"; } } else { echo "<div class=\"mots_mc\"><:rmc:selectionner_mot:></div>"; // inutile si form recherche inclus // echo "<br /><a href=\"".$_SERVER['HTTP_REFERER']."\" onclick=\"javascript:history.back(); return false;\">Retour</a></p>"; } ?> </div></code></pre></div> <p>Normalement c'est juste un portage qui utllise l'API SQL de SPIP : cela a pas mal d'avantages plus tard. Si ça marche, je peux adapter les requêtes (je soupçonne aussi les mots-clés)</p> <p>J'irai voir la page de recherche dans la soirée. Je pense que ça m'aidera à comprendre le code... Mais je pense aussi qu'il aurait été possible d'écrire cette page directement en langage de boucles SPIP avec ses bénéfices (lisibilité du HTML qui n'est pas mélangé à du PHP, portabilité et prise en main plus simples pour un non développeur, prise en charge automatique par le cache, etc.)</p> Migration d'un squelette de SPIP2 vers SPIP3 2012-11-02T10:53:45Z https://contrib.spip.net/Migration-d-un-squelette-de-SPIP2-vers-SPIP3#comment462780 2012-11-02T10:53:45Z <p>Problème résolu, je poste la réponse très simple qui pourra dépanner probablement d'autres personnes</p> <p> La table <strong>spip_mot_articles</strong> est devenue <strong>spip_mots_liens</strong> et du coup <strong>spip_mots_articles_.id_article</strong> devient <strong>spip_mots_liens.id_objet</strong></p> <p>Merci d'avoir pris le temps de regarder! Je suis conscient que comme ça le code php est un peu indigeste! Je pourrais d'ailleurs faire ça plus simplement maintenant sous Spip 3 mais bon!</p> <p>Mike</p> Migration d'un squelette de SPIP2 vers SPIP3 2012-11-02T10:29:31Z https://contrib.spip.net/Migration-d-un-squelette-de-SPIP2-vers-SPIP3#comment462778 2012-11-02T10:29:31Z <p>Je te mets un lien vers la version qui fonctionne sur SPIP 2.1</p> <p><a href="http://www.librairie-interactive.com/?page=recherche&type_rech=multi" class="spip_url spip_out auto" rel="nofollow external">http://www.librairie-interactive.com/?page=recherche&type_rech=multi</a></p> <p>Je pense savoir d'où vient le problème mais je ne suis pas assez compétent en SQL pour le résoudre. <br class="autobr" /> En effet, je viens de réaliser que dans la nouvelle structure de la base de SPIP 3, la table <strong>spip_mots_articles</strong> n'existe plus alors que dans mon fichier, il y est souvent fait appel en SQL. Du coup mon code se comporte comme si il n'y avait aucun mot clé dans le tableau <strong>idmot</strong> et me dit qu'il n'y a pas de résultats.</p> <p>Reste à comprendre les jointures de la nouvelle base pour modifier le SQL dans mon code.</p> Migration d'un squelette de SPIP2 vers SPIP3 2012-11-02T00:09:24Z https://contrib.spip.net/Migration-d-un-squelette-de-SPIP2-vers-SPIP3#comment462769 2012-11-02T00:09:24Z <p>pfiouuuu <br class="manualbr" />On peut voir la page de recherche ? <br class="manualbr" />Et aussi une petite description de comment les résultats sont affichés ?</p> Migration d'un squelette de SPIP2 vers SPIP3 2012-11-01T20:29:24Z https://contrib.spip.net/Migration-d-un-squelette-de-SPIP2-vers-SPIP3#comment462768 2012-11-01T20:29:24Z <p>Bonjour!</p> <p>Je travaille actuellement sur la migration de mon site en Spip 2.1 vers Spip 3. Il me reste malheureusement un problème que je n'arrive pas à résoudre. J'utilisais jusque là une partie d'un vieux plugin de recherche multicritères que je m'étais longtemps amusé à modifier et à adapter.</p> <p>Le fichier de résultat est entièrement en php mais depuis le passage à Spip 3, il ne me retourne plus aucun résultat. Je pense que suite aux modifications de la base sur la version 3, une requête SQL n'est plus bonne mais je n'ai pas réussi à savoir quelles étaient les changements.</p> <p>Si quelqu'un pouvait m'en dire plus ou jeter un œil à mon code, ce serait cool!</p> <div class="precode"><pre dir="ltr" style="text-align: left;"><code><div class="result_rm"> <?php ###################################################################### # RECHERCHE MULTI-CRITERES - MODELE AFFICHAGE DES RESULTATS # # # # Auteurs : Dominique (Dom) Lepaisant # # www.tispip.etab.ac-caen.fr # # Stéphanie De Nadaï - www.webdesigneuse.net # # - Fev 2008 # # # # Adaptation de la contrib de Paul Sanchez - www.Netdeveloppeur.com # # # # Ce programme est un logiciel libre distribue sous licence GNU/GPL. # # Pour plus de details voir le fichier COPYING.txt # ###################################################################### $url = parse_url($_SERVER['QUERY_STRING']); $param = $url['path']; $pos = 0; $indice = 255; if (isset($_POST['idmot'])) { // Récupération du nombre de jours // pour periodicité de la rechercher $nbjour = 0; if (isset($_POST['nbjour'])){ $nbjour = $_POST['nbjour']; } // Récupération du nombre de jours // pour periodicité de la rechercher $idonlyrub = 0; if (isset($_POST['onlyrub'])) { if (isset($_POST['rubnum'])) { $idonlyrub = $_POST['rubnum']; } } // 1 = Tous les mots doivent être associés aux articles trouvés $allword = 0; if (isset($_POST['allword'])) { $allword = 1; } $nbmot = count($_POST['idmot']); $sql = "SELECT id_mot, titre FROM spip_mots WHERE id_mot IN (". implode(",", $_POST['idmot']) .") GROUP BY id_mot,titre"; $result = mysql_query($sql); $tabmot = ""; $nbcol = 0; $nbcolmax = 4; if ($result) { $compt = 0; while ($row = mysql_fetch_assoc($result)) { extract($row); $titre = supprimer_numero($titre); if ($nbcol == $nbcolmax) { $nbcol = 0; } $tabmot .= "<a class=\"spanblock txtgris\" href=\"./spip.php?page=mot&mots[]=$id_mot\"><span class=\"cle\">$titre</span></a>"; $nbcol += 1; } mysql_free_result($result); } $sql = "SELECT COUNT(*) AS num, spip_articles.id_article, spip_rubriques.id_rubrique, spip_rubriques.titre AS titrerub "; $sql .= "FROM spip_articles INNER JOIN spip_rubriques ON spip_rubriques.id_rubrique = spip_articles.id_rubrique "; $sql .= "INNER JOIN spip_mots_articles ON spip_mots_articles.id_article = spip_articles.id_article "; $sql .= " WHERE spip_mots_articles.id_mot IN (". implode(",", $_POST['idmot']) .") "; $datedeb = date("Y-m-d", mktime(0, 0, 0, date("m"), (date("d") - $nbjour), date("Y"))); if ($nbjour != 0) { $sql .= "AND spip_articles.date >= '$datedeb' "; } if ($idonlyrub != 0) { $sql .= "AND spip_rubriques.id_rubrique = $idonlyrub "; } $sql .= "AND spip_articles.statut LIKE 'publie' GROUP BY spip_articles.id_article"; if ($order == 1) { $sql .= " ORDER BY spip_rubriques.id_rubrique, NUM DESC, spip_mots_articles.id_mot, spip_articles.date DESC"; } else { $sql .= " ORDER BY NUM DESC, spip_mots_articles.id_mot, spip_rubriques.id_rubrique, spip_articles.date DESC"; } $result = mysql_query($sql); //$nbart = mysql_num_rows($result); $nbart = 0; $resultataffiche = ""; if ($result) { $titrerub = supprimer_numero($titrerub); $idrub = 0; $listidmot2 = ""; $listidmotprec = ""; while ($row = mysql_fetch_assoc($result)) { extract($row); if (($num != $nbmot) && ($allword == 1)) { break; } if ($idrub != $id_rubrique) { if (($pospoint = strrpos($titrerub, ". ")) === FALSE) { $titrerub2=$titrerub; } else { if (is_numeric(substr($titrerub, 0, $pospoint)) == false) $titrerub2 = $titrerub; else $titrerub2 = substr($titrerub, $pospoint + 2); } if ($order == 1) { $resultataffiche.= "<p><a href=\"./spip.php?rubrique$id_rubrique\">$titrerub2 :</a></p>"; } } $sql2 = "SELECT spip_articles.id_article AS artid,spip_articles.id_secteur AS id_secteur, spip_articles.titre AS titreart, spip_articles.date, spip_mots.id_mot "; $sql2 .= ", spip_mots.titre AS titremot FROM spip_articles INNER JOIN spip_mots_articles ON spip_mots_articles.id_article = spip_articles.id_article "; $sql2 .= "INNER JOIN spip_mots ON spip_mots.id_mot = spip_mots_articles.id_mot "; $sql2 .= "WHERE spip_articles.id_article = $id_article AND spip_mots_articles.id_mot IN (". implode(",", $_POST['idmot']) .") AND statut LIKE 'publie' "; $sql2 .= "ORDER BY spip_mots.id_mot"; $result2 = mysql_query($sql2); if ($result2) { $listmot = "<h4 class=\"titremots_mc\">"; $titrearticle = ""; $dataffich = ""; $idart = 0; while ($row2 = mysql_fetch_assoc($result2)) { extract($row2); $listidmot2 .= "$id_mot,"; if ($idart == 0) { $titrearticle = supprimer_numero($titreart); if (!(($pospoint = strpos($titrearticle, '.')) === FALSE)) { if (is_numeric(substr($titrearticle, 0, $pospoint)) == true) $titrearticle = substr($titrearticle, $pospoint + 2); } if (!(($pospoint = strpos($titremot, '.')) === FALSE)) { if (is_numeric(substr($titremot, 0, $pospoint)) == true) $titremot = substr($titremot, $pospoint + 2); } $dataffich = date("d/m/Y", strtotime($date)); if ($order == 1) { $nbart += 1; $resultataffiche .= "<li> <a class=\"titrearticle_mc\" href=\"./spip.php?article$artid\">$titrearticle</a> <small>$dataffich </small>"; $resultataffiche .= "$titremot"; } $listmot .= "<a class=\"spanblock\" href=\"./spip.php?page=mot&mots[]=$id_mot\"><span class=\"cle\">$titremot</span></a>"; $idart = 1; } else { $listmot .= "<a class=\"spanblock\" href=\"./spip.php?page=mot&mots[]=$id_mot\"><span class=\"cle\">$titremot</span></a>"; if ($order == 1) { $resultataffiche .= "<a class=\"spanblock\" href=\"./spip.php?page=mot&mots[]=$id_mot\"><span class=\"cle\">$titremot</span></a>"; } } } if ($order == 1) { $resultataffiche .= "</li>"; } mysql_free_result($result2); if ($order == 0) { if ($listidmot2 != $listmodidprec) { $resultataffiche .= " $listmot </h4>"; } $nbart += 1; if ($id_secteur == 1) {$variable = 63; $secteur = "Ma classe";} if ($id_secteur == 3) {$variable = 66; $secteur = "Applications";} if ($id_secteur == 4) {$variable = 65; $secteur = "Tutoriels";} if ($id_secteur == 5) {$variable = 64; $secteur = "Liens";} $resultataffiche .= " <li class=\"br\"> <a class=\"titrearticle_mc\" href=\"./spip.php?article$id_article\">$titrearticle</a> <small>publié le : <em>$dataffich</em> , dans la rubrique <em><a href=\"./spip.php?rubrique$id_secteur&mots[]=$variable\">$secteur</a></em></small></li>"; $listmodidprec = $listidmot2; $listidmot2 = ""; } } $idrub = $id_rubrique; } mysql_free_result($result); if($nbart == 0 || $nbart == 1) $nbart_txt = "<:rmc:article_trouve:>"; else $nbart_txt = "<:rmc:articles_trouves:>"; echo "<div class=\"contre-encart\">"; echo "<p class=\"mots_mc\"><span class=\"spanblock \">Mots séléctionnés : </span><br />".substr($tabmot, 0)." </p>"; if($nbart == 0 ) $nbart_txt = "Aucun article ne correspond à votre recherche"; else if($nbart == 1 ) $nbart_txt = " article correspond à votre recherche"; else $nbart_txt = "articles correspondent à votre recherche"; if($nbart == 0 ) echo " <p class=\"mots_mc\"> $nbart_txt <br /> <a href=\"#SELF\">Nouvelle recherche</a></p>"; else echo " <p class=\"mots_mc\"> $nbart $nbart_txt <br /> <a href=\"#SELF\">Nouvelle recherche</a></p>"; echo " <div class=\"liste-articles\">" .$resultataffiche ." </div> </div>"; if($nbart != 0 ) echo " <br class=\"dixpixels\" /> <p class=\"mots_mc\"><a href=\"#SELF\">Nouvelle recherche</a></p>"; } else { echo "<p class=\"mots_mc\">Aucun article ne correspond à votre recherche</p>"; } } else { echo "<div class=\"mots_mc\"><:rmc:selectionner_mot:></div>"; # inutile si form recherche inclus # echo "<br /><a href=\"".$_SERVER['HTTP_REFERER']."\" onclick=\"javascript:history.back(); return false;\">Retour</a></p>"; } ?> </div></code></pre></div> Migration d'un squelette de SPIP2 vers SPIP3 2012-10-13T17:43:36Z https://contrib.spip.net/Migration-d-un-squelette-de-SPIP2-vers-SPIP3#comment462187 2012-10-13T17:43:36Z <p>Oui,<br class="autobr" /> Bravo et merci ! ^^</p> Migration d'un squelette de SPIP2 vers SPIP3 2012-10-13T13:19:07Z https://contrib.spip.net/Migration-d-un-squelette-de-SPIP2-vers-SPIP3#comment462179 2012-10-13T13:19:07Z <p>Salut Abel</p> <p>Comme j'ai pas testé.. mais vous avez trouvé la version qui fonctionne. L'idée était de forcer la jointure sur la table des mots clés ;-)</p> <p>Problème résolu donc. Bonne continuation.</p> Migration d'un squelette de SPIP2 vers SPIP3 2012-10-13T12:45:58Z https://contrib.spip.net/Migration-d-un-squelette-de-SPIP2-vers-SPIP3#comment462175 2012-10-13T12:45:58Z <p>Bonjour,</p> <p>Alors si je mets <code>{mots.id_groupe="9"}{mots.objet='breve'}</code> ça ne fonctionne pas. <br class="autobr" /> Mais si je ne mets que <code>{mots.id_groupe="9"}</code> alors cela semble fonctionner.</p> <p>Abel</p> Migration d'un squelette de SPIP2 vers SPIP3 2012-10-13T10:11:56Z https://contrib.spip.net/Migration-d-un-squelette-de-SPIP2-vers-SPIP3#comment462172 2012-10-13T10:11:56Z <p>Bonjour.</p> <p>Vous (Abel) écriviez :</p> <blockquote class="spip"> <p> le critère id_groupe semble ne plus fonctionner sur une boucle « breves » dans SPIP 3 (pour sélectionner les brèves liées à un groupe de mots-clés)</p> </blockquote> <p>Et je (gilcot) ai répondu</p> <blockquote class="spip"> <p>Est-ce que l'erreur persiste quand on enlève <code>{id_groupe="9"}</code> et qu'on recalcule la page ?</p> </blockquote> <p>Et vous (Abel) confirmez</p> <blockquote class="spip"> <p>Si j'enlève le critère ça marche sans problème.<br class="manualbr" />... mais c'est tout de même étrange.</p> </blockquote> <p>En fait, ce n'est pas si étrange que cela : le problème des mots-clés est un peu celui des forums, même si l'article ne le mentionne pas (mais c'est un poil plus complexe aussi) Mais l'essentiel (jointures automatiques) ayant été fait pour qu'on retombe sur ses pattes dans la plupart des cas (boucles simples de ce type), cette erreur n'aurait pas du se produire non ? <br class="manualbr" />A tout hasard (je ne peux pas tester là), remplacer <code>{id_groupe="9"}</code> par <code>{mots.id_groupe="9"}{mots.objet='breve'}</code> pour voir ce que ça donne</p> Migration d'un squelette de SPIP2 vers SPIP3 2012-10-12T14:15:54Z https://contrib.spip.net/Migration-d-un-squelette-de-SPIP2-vers-SPIP3#comment462152 2012-10-12T14:15:54Z <p>Bonjour,<br class="autobr" /> Voici l'erreur exacte :</p> <table class="table spip"> <caption>1 Erreur(s) dans le squelette</caption> <tbody> <tr class="row_odd odd"> <td>Numéro</td> <td>message</td> <td>squelette</td> <td>boucle</td> <td>Ligne</td></tr> <tr class="row_even even"> <td>1</td> <td>Critère inconnu =</td> <td>squelettes/inclure/coldroite.html</td> <td>_fromtheweb</td> <td>63</td></tr> </tbody> </table> <p>Et la boucle n'affiche rien.</p> <p>Si j'enlève le critère ça marche sans problème.<br class="autobr" /> Pour le moment j'ai trouvé un autre moyen d'afficher ce que je veux mais c'est tout de même étrange.</p> Migration d'un squelette de SPIP2 vers SPIP3 2012-10-07T06:15:06Z https://contrib.spip.net/Migration-d-un-squelette-de-SPIP2-vers-SPIP3#comment461952 2012-10-07T06:15:06Z <p>Bonjour.</p> <p>Quelle est l'erreur exacte ?</p> <p>Est-ce que l'erreur persiste quand on enlève <code>{id_groupe="9"}</code> et qu'on recalcule la page ?</p> Migration d'un squelette de SPIP2 vers SPIP3 2012-10-01T09:03:52Z https://contrib.spip.net/Migration-d-un-squelette-de-SPIP2-vers-SPIP3#comment461706 2012-10-01T09:03:52Z <p>Bonjour, <br class="autobr" /> Sauf erreur de ma part, le critère id_groupe semble ne plus fonctionner sur une boucle “breves” dans SPIP 3 (pour sélectionner les brèves liées à un groupe de mots-clés). <a href="http://www.spip.net/fr_article906.html" class="spip_url spip_out auto" rel="nofollow external">http://www.spip.net/fr_article906.html</a></p> <p>La boucle suivante qui fonctionnait très bien sous SPIP 2, n'affiche plus rien après une migration sur SPIP3, et affiche une “erreur dans le squelette” de type “critère inconnu” :<br class="autobr" /> <code><BOUCLE_nom_de_boucle(BREVES){id_groupe="9"}{0,5}{id_rubrique="1"}{!par date}{doublons}></code></p> <p>Je précise que la boucle se situe dans un “inclure”.</p> <p>Merci!</p> Migration d'un squelette de SPIP2 vers SPIP3 2012-09-26T12:51:50Z https://contrib.spip.net/Migration-d-un-squelette-de-SPIP2-vers-SPIP3#comment461559 2012-09-26T12:51:50Z <p>C'est fait</p> Migration d'un squelette de SPIP2 vers SPIP 3.0 2012-05-26T16:55:08Z https://contrib.spip.net/Migration-d-un-squelette-de-SPIP2-vers-SPIP3#comment457655 2012-05-26T16:55:08Z <p>Bonjour,</p> <p>il faudrait mettre cet article dans la rubrique “Suivre les versions de SPIP” : <br class="autobr" /> <a href="http://www.spip-contrib.net/Suivre-les-versions-de-SPIP" class="spip_url spip_out auto" rel="nofollow external">http://www.spip-contrib.net/Suivre-les-versions-de-SPIP</a></p> <p>Sinon on ne s'y retrouve pas, non ?</p> Migration d'un squelette de SPIP2 vers SPIP 3.0 2012-05-24T09:39:02Z https://contrib.spip.net/Migration-d-un-squelette-de-SPIP2-vers-SPIP3#comment457566 2012-05-24T09:39:02Z <p>Sisi, <code>{par num titre}</code> marche toujours... ce n'est que la balise #TITRE qui a le numéro supprimé d'office.</p> Migration d'un squelette de SPIP2 vers SPIP 3.0 2012-05-23T23:08:52Z https://contrib.spip.net/Migration-d-un-squelette-de-SPIP2-vers-SPIP3#comment457546 2012-05-23T23:08:52Z <p>le critere <i>par num titre, id_document</i> ne marche plus, car les numeros devant les titres sont maintenant ignore.</p> <p>c'est quoi le nouveau critere pour prendre en compte les numeros de titres ? la documentation n'est ps encore a jour :(</p> Migration d'un squelette de SPIP2 vers SPIP 3.0 2012-05-05T19:54:23Z https://contrib.spip.net/Migration-d-un-squelette-de-SPIP2-vers-SPIP3#comment456940 2012-05-05T19:54:23Z <p>Un chapitre majeur de modification de SPIP 3 reste a expliciter :<br class="autobr" /> la gestion des <strong>mots-clés</strong> est a refondre assez complètement si vous utilisez ce domaine...<br class="autobr" /> car les tables dsupport ont completement changé.</p> <p>Voir les articls descriptifs SPIP3 (actuellement seulement en interface privée, en attendant leur publication publique a la sortie officielle de SPIP3)</p>