Changeset 3065
- Timestamp:
- Jan 14, 2013, 2:14:09 AM (8 years ago)
- Location:
- cpc/trunk/project
- Files:
-
- 3 added
- 16 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
cpc/trunk/project/apps/frontend/config/routing.yml.example
r2798 r3065 43 43 param: {module: commentaire, action: json} 44 44 45 loi_ section:46 url: /%LEGISLATURE%/loi/:loi/section/: chapitre/:section45 loi_level4: 46 url: /%LEGISLATURE%/loi/:loi/section/:level1/:level2/:level3/:level4 47 47 param: {module: loi, action: section} 48 48 49 loi_chapitre: 50 url: /%LEGISLATURE%/loi/:loi/section/:chapitre 51 param: {module: loi, action: section, section: "0"} 49 loi_level3: 50 url: /%LEGISLATURE%/loi/:loi/section/:level1/:level2/:level3 51 param: {module: loi, action: section, level4: "0"} 52 53 loi_level2: 54 url: /%LEGISLATURE%/loi/:loi/section/:level1/:level2 55 param: {module: loi, action: section, level3: "0", level4: "0"} 56 57 loi_level1: 58 url: /%LEGISLATURE%/loi/:loi/section/:level1 59 param: {module: loi, action: section, level2: "0", level3: "0", level4: "0"} 52 60 53 61 loi_rss_commentaires: -
cpc/trunk/project/apps/frontend/modules/loi/actions/actions.class.php
r1374 r3065 49 49 ->where('t.texteloi_id = ?', $loi_id) 50 50 ->andWhere('t.id != t.titre_loi_id') 51 ->orderBy('t. chapitre, t.section')51 ->orderBy('t.level1, t.level2, t.level3, t.level4') 52 52 ->execute(); 53 53 $this->articles = Doctrine::getTable('ArticleLoi')->createquery('a') … … 59 59 ->andWhere('a.sort <> ?', 'Rectifié') 60 60 ->execute()); 61 $this->dossier = $this->loi->getDossier()->id;62 63 $this->response->setTitle( strip_tags($this->loi->titre).' - NosDéputés.fr');61 if ($this->loi->getDossier()) 62 $this->dossier = $this->loi->getDossier()->id; 63 $this->response->setTitle("Simplifions la loi - ".strip_tags($this->loi->titre).' - NosDéputés.fr'); 64 64 $request->setParameter('rss', array(array('link' => '@loi_rss_commentaires?loi='.$loi_id, 'title'=>'Les commentaires sur '.$this->loi->titre))); 65 66 65 } 67 66 … … 69 68 { 70 69 $loi_id = $this->getLoi($request, 1); 71 $n_chapitre = $request->getParameter('chapitre'); 72 $this->chapitre = Doctrine::getTable('TitreLoi')->findChapitre($loi_id, $n_chapitre); 73 $this->forward404Unless($this->chapitre); 74 $n_section = $request->getParameter('section'); 75 $artquery = Doctrine::getTable('ArticleLoi')->createquery('a'); 76 if ($n_section && $n_section != 0) { 77 $this->section = Doctrine::getTable('TitreLoi')->findSection($loi_id, $n_chapitre, $n_section); 78 $this->forward404Unless($this->section); 79 $artquery->where('a.titre_loi_id = ?', $this->section->id); 80 } else { 81 $this->soussections = Doctrine::getTable('TitreLoi')->createquery('t') 82 ->where('t.texteloi_id = ?', $loi_id) 83 ->andWhere('t.chapitre = ?', $n_chapitre) 84 ->andWhere('t.section IS NOT NULL') 85 ->orderBy('t.section') 86 ->execute(); 87 $ids = array(); 88 $ids[] = $this->chapitre->id; 89 if ($this->soussections) foreach ($this->soussections as $ss) $ids[] = $ss->id; 90 $artquery->whereIn('a.titre_loi_id', $ids); 91 } 92 $artquery->andWhere('a.texteloi_id = ?', $loi_id) 93 ->orderBy('a.ordre'); 94 $this->articles = $artquery->execute(); 70 $levels = array(); 71 for ($i = 1; $i < 5; $i++) 72 $levels[] = $request->getParameter('level'.$i, 0); 73 $this->section = Doctrine::getTable('TitreLoi')->identifyAndFindLevel($loi_id, $levels); 74 $this->forward404Unless($this->section); 75 $this->level = $this->section->getLevel(); 76 $qss = Doctrine::getTable('TitreLoi')->createquery('t') 77 ->where('t.texteloi_id = ?', $loi_id); 78 for ($i = 1; $i <= $this->level; $i++) 79 $qss->andWhere('t.level'.$i.' = ?', $levels[$i-1]); 80 if($this->level < 4) 81 $qss->andWhere('t.level'.($this->level+1).' IS NOT NULL'); 82 $this->soussections = $qss->orderBy('t.level1, t.level2, t.level3, t.level4') 83 ->execute(); 84 $ids = array($this->section->id); 85 if ($this->soussections) foreach ($this->soussections as $ss) $ids[] = $ss->id; 86 $this->articles = Doctrine::getTable('ArticleLoi') 87 ->createquery('a') 88 ->whereIn('a.titre_loi_id', $ids) 89 ->andWhere('a.texteloi_id = ?', $loi_id) 90 ->orderBy('a.ordre') 91 ->execute(); 95 92 if (count($this->articles) == 1) 96 93 $this->redirect('@loi_article?loi='.$loi_id.'&article='.$this->articles[0]->slug); 97 94 $this->amendements = $this->getAmendements($loi_id, $this->articles); 98 if (isset($this->section)) { 99 $titre = $this->section->getLargeTitre(); 100 if (preg_match('/^(\d+)\s+bis$/',$n_section, $match)) { 101 $this->precedent = $match[1]; 102 if (Doctrine::getTable('TitreLoi')->findSection($loi_id, $n_chapitre, $match[1]+1)) 103 $this->suivant = $match[1] + 1; 104 } else { 105 $pre = $n_section - 1; 106 $voisins = Doctrine::getTable('TitreLoi')->createQuery('c') 107 ->select('c.section') 108 ->where('c.texteloi_id = ?', $loi_id) 109 ->andWhere('c.chapitre = ?', $n_chapitre) 110 ->andWhereIn('c.section', array($pre, $pre." bis", $n_section." bis", $n_section+1)) 111 ->orderBy('c.section') 112 ->fetchArray(); 113 $ct = count($voisins); 114 if ($ct == 1) { 115 if ($n_section == 1) $this->suivant = $voisins[0]['section']; 116 else $this->precedent = $voisins[0]['section']; 117 } else if ($ct == 2) { 118 if ($n_section == 1) 119 $this->suivant = $voisins[0]['section']; 120 else if (preg_match('/^(\d+)\s+bis$/', $voisins[1]['section'], $match) && $match[1] < $n_section) 121 $this->precedent = $voisins[1]['section']; 122 else { 123 $this->precedent = $voisins[0]['section']; 124 $this->suivant = $voisins[1]['section']; 125 } 126 } else if ($ct > 2) { 127 if (preg_match('/bis/', $voisins[1]['section']) && preg_match('/bis/', $voisins[2]['section'])) { 128 $this->precedent = $voisins[1]['section']; 129 $this->suivant = $voisins[2]['section']; 130 } else { 131 $this->precedent = $voisins[0]['section']; 132 if (preg_match('/'.$n_section.'/', $voisins[1]['section'])) { 133 $this->precedent = $voisins[0]['section']; 134 $this->suivant = $voisins[1]['section']; 135 } else { 136 $this->precedent = $voisins[1]['section']; 137 $this->suivant = $voisins[2]['section']; 138 } 139 } 140 } 141 } 142 } else { 143 $titre = $this->chapitre->getLargeTitre(); 144 if (preg_match('/^(\d+)\s+bis$/',$n_chapitre, $match)) { 145 $this->precedent = $match[1]; 146 if (Doctrine::getTable('TitreLoi')->findChapitre($loi_id, $match[1]+1)) $this->suivant = $match[1]+1; 147 } else { 148 $pre = $n_chapitre - 1; 149 $voisins = Doctrine::getTable('TitreLoi')->createQuery('c') 150 ->select('c.chapitre') 151 ->where('c.texteloi_id = ?', $loi_id) 152 ->andWhere('c.section is NULL') 153 ->andWhereIn('c.chapitre', array($pre, $pre." bis", $n_chapitre." bis", $n_chapitre+1)) 154 ->orderBy('c.chapitre') 155 ->fetchArray(); 156 $ct = count($voisins); 157 if ($ct == 1) { 158 if ($n_chapitre == 1) $this->suivant = $voisins[0]['chapitre']; 159 else $this->precedent = $voisins[0]['chapitre']; 160 } else if ($ct == 2) { 161 if ($n_chapitre == 1) 162 $this->suivant = $voisins[0]['chapitre']; 163 else if (preg_match('/^(\d+)\s+bis$/', $voisins[1]['chapitre'], $match) && $match[1] < $n_chapitre) 164 $this->precedent = $voisins[1]['chapitre']; 165 else { 166 $this->precedent = $voisins[0]['chapitre']; 167 $this->suivant = $voisins[1]['chapitre']; 168 } 169 } else if ($ct > 2) { 170 if (preg_match('/bis/', $voisins[1]['chapitre']) && preg_match('/bis/', $voisins[2]['chapitre'])) { 171 $this->precedent = $voisins[1]['chapitre']; 172 $this->suivant = $voisins[2]['chapitre']; 173 } else { 174 $this->precedent = $voisins[0]['chapitre']; 175 if (preg_match('/'.$n_chapitre.'/', $voisins[1]['chapitre'])) { 176 $this->precedent = $voisins[0]['chapitre']; 177 $this->suivant = $voisins[1]['chapitre']; 178 } else { 179 $this->precedent = $voisins[1]['chapitre']; 180 $this->suivant = $voisins[2]['chapitre']; 181 } 182 } 183 } 184 } 185 } 186 $this->response->setTitle(strip_tags($this->loi->titre.' - '.$titre)); 95 $this->voisins = $this->section->getVoisins(); 96 $this->titre = $this->section->getHierarchie()." : ".$this->section->titre; 97 $this->response->setTitle(strip_tags($this->loi->titre.' - '.$this->titre)); 187 98 } 188 99 … … 233 144 $this->forward404Unless(count($this->alineas)); 234 145 $this->section = $this->article->getTitreLoi(); 146 $titre = strip_tags($this->loi->titre); 147 if ($this->section->getHierarchie()) 148 $titre .= " (".strip_tags($this->section->getHierarchie()).") "; 235 149 $this->titre = 'Article '.$this->article->titre; 236 if (isset($this->section->chapitre) && $this->section->chapitre != 0) 237 $this->titre .= ' ('.$this->section->getLargeTitre().')'; 238 $this->response->setTitle(strip_tags($this->loi->titre.' - '.$this->titre)); 150 $this->response->setTitle($titre.' - '.$this->titre); 239 151 if (isset($this->article->expose) && $this->article->expose != "") $this->expose = $this->article->expose; 240 152 else $this->expose = $this->section->expose; -
cpc/trunk/project/apps/frontend/modules/loi/templates/articleSuccess.php
r2365 r3065 1 1 <div class="loi"> 2 2 <h1><?php echo link_to($loi->titre, '@loi?loi='.$loi->texteloi_id); ?></h1> 3 <h2><?php if (preg_match('/@loi_chapitre/', $titre)) { 4 $url = url_for('@loi_chapitre?loi='.$loi->texteloi_id.'&chapitre='.$section->chapitre); 5 $titre = preg_replace('/@loi_chapitre/', $url, $titre); 6 if (preg_match('/@loi_section/', $titre)) { 7 $url = url_for('@loi_section?loi='.$loi->texteloi_id.'&chapitre='.$section->chapitre.'§ion='.$section->section); 8 $titre = preg_replace('/@loi_section/', $url, $titre); 9 } 10 } 11 echo $titre; ?></h2> 3 <h2><?php echo $titre; ?></h2> 4 <h3><?php echo "(".$section->getHierarchie()." : ".link_to(ucfirst($section->titre), $section->getUrl()).")"; ?></h3> 12 5 <div class="pagerloi"> 13 6 <?php if ($article->precedent) { -
cpc/trunk/project/apps/frontend/modules/loi/templates/loiSuccess.php
r2062 r3065 1 <?php if ( $dossier) echo '<div class="source">'.link_to('Dossier relatif', '@section?id='.$dossier)."</div>"; ?>1 <?php if (isset($dossier)) echo '<div class="source">'.link_to('Dossier relatif', '@section?id='.$dossier)."</div>"; ?> 2 2 <div class="loi"><h1><?php echo $loi->titre; ?></h1></div> 3 3 <?php if ($loi->source) echo '<p class="source"><a href="'.$loi->source.'" rel="nofollow">Source</a></p><div class="clear"></div>'; 4 if ($loi->parlementaire_id && $loi->expose && !($loi->texteloi_id == 2760)) { ?>4 if ($loi->parlementaire_id && $loi->expose) { ?> 5 5 <div class="loi"><div class="intervenant"> 6 6 <?php $perso = $loi->getParlementaire(); … … 17 17 <?php $nart = 0; $nbart = 0; 18 18 if (isset($soussections)) { 19 $chapitre = 0; 20 $section = 0; 19 $level = 0; 21 20 foreach ($soussections as $ss) { 22 if ( ($section != 0 || $chapitre != 0) && ($ss->chapitre != $chapitre || $ss->section > 1)) {21 if ($ss->level <= $level) { 23 22 echo '<br/><small> Article'; 24 if ($nbart > 1) echo 's ';25 echo ' :';23 if ($nbart > 1) echo 's :'; 24 echo ' '; 26 25 for ($i=$nart;$i<$nart+$nbart;$i++) { 27 26 echo link_to($articles[$i]['titre'], '@loi_article?loi='.$loi->texteloi_id.'&article='.$articles[$i]['slug']); … … 30 29 $nart += $nbart; 31 30 echo '</small>'; 31 if ($ss->level < $level) for ($i=0; $i < $level-$ss->level; $i++) 32 echo "</li></ul>"; 33 else echo "</li>"; 34 } else echo "<ul>"; 35 echo '<li class="level'.$ss->getLevel().'">'.link_to($ss->getLevelTitre(), $ss->getUrl()); 36 $level = $ss->getLevel(); 37 $nbart = $ss->nb_articles; 38 if ($ss->nb_commentaires > 0) { 39 echo '(<span class="coms_loi_txt">'.$ss->nb_commentaires.' commentaire'; 40 if ($ss->nb_commentaires > 1) echo 's'; 41 echo '</span>)'; 32 42 } 33 $nbart = $ss->nb_articles;34 if (isset($ss->chapitre) && $ss->chapitre != $chapitre && (!($ss->section) || $ss->section == 0)) {35 if ($section != 0) echo '</li></ul>';36 $section = 0;37 if ($chapitre != 0) echo '</li>';38 else echo '<ul>';39 $chapitre = $ss->chapitre;40 echo '<li><b><a href="'.url_for('@loi_chapitre?loi='.$loi->texteloi_id.'&chapitre='.$chapitre).'">';41 echo 'Chapitre '.$chapitre;42 } else if (isset($ss->section) && $ss->section != $section) {43 if ($section != 0) echo '</li>';44 else echo '<ul>';45 $section = $ss->section;46 echo '<li><a href="'.url_for('@loi_section?loi='.$loi->texteloi_id.'&chapitre='.$chapitre.'§ion='.$section).'">';47 echo 'Section '.$section;48 }49 echo ' : '.$ss->titre.'</a>';50 if ($section == 0) echo '</b>';51 echo ' ('.$ss->nb_articles.' article';52 if ($ss->nb_articles > 1) echo 's';53 if ($ss->nb_commentaires > 0) {54 echo ', <span class="coms_loi_txt">'.$ss->nb_commentaires.' commentaire';55 if ($ss->nb_commentaires > 1) echo 's';56 }57 echo '</span>)';58 43 } 59 44 echo '<br/><small> Article'; … … 65 50 } 66 51 echo '</small>'; 67 if ($s ection != 0) echo '</li></ul>';68 if ($chapitre != 0) echo '</li></ul>';52 if ($ss->level < $level) for ($i=0; $i < $level-$ss->level; $i++) 53 echo "</li></ul>"; 69 54 if ($amendements) { 70 55 echo '<p class="suivant">'.link_to('Voir les '.$amendements.' amendements déposés sur ce texte', '@find_amendements_by_loi_and_numero?loi='.$loi->texteloi_id.'&numero=all'); … … 85 70 </div> 86 71 <br/> 87 <?php if ( (!$loi->parlementaire_id && $loi->expose) || $loi->texteloi_id == 2760) {72 <?php if (!$loi->parlementaire_id && $loi->expose) { 88 73 echo '<div class="loi"><h2>Exposé des motifs :</h2>'; 89 74 if ($loi->parlementaire_id && $perso = $loi->getParlementaire()) -
cpc/trunk/project/apps/frontend/modules/loi/templates/sectionSuccess.php
r2062 r3065 2 2 <div class="loi"> 3 3 <h1><?php echo link_to($loi->titre, '@loi?loi='.$loi->texteloi_id); ?></h1> 4 <h2><?php if (isset($section)) echo '<a href="'.url_for('@loi_chapitre?loi='.$loi->texteloi_id.'&chapitre='.$chapitre->chapitre).'">'; 5 echo 'Chapitre '.$chapitre->chapitre.' : '.$chapitre->titre; 6 if (isset($section)) echo '</a>'; ?></h2> 4 <h2><?php echo $titre; ?></h2> 7 5 <?php $expose = ''; 8 if (isset($section)) { 9 echo '<h3>Section '.$section->section.' : '.$section->titre.'</h3>'; 10 echo '<div class="pagerloi">'; 11 if (isset($precedent)) { 12 echo '<div class="precedent">'.link_to('Section '.$precedent, '@loi_section?loi='.$loi->texteloi_id.'&chapitre='.$chapitre->chapitre.'§ion='.$precedent).'</div>'; 6 echo '<div class="pagerloi">'; 7 $baseurl = '@loi_level'.$level.'?loi='.$loi->texteloi_id; 8 for ($i = 1; $i < $level; $i++) 9 $baseurl .= "&level".$i."=".$section->getLevelValue($i); 10 if ($voisins[0]) echo '<div class="precedent">'.link_to(ucfirst($section->leveltype).' '.$voisins[0], $baseurl."&level".$level.'='.$voisins[0]).'</div>'; 11 if ($voisins[1]) echo '<div class="suivant">'.link_to(ucfirst($section->leveltype).' '.$voisins[1], $baseurl."&level".$level.'='.$voisins[1]).'</div>'; 12 echo '</div>'; 13 if (isset($section->expose)) { 14 $expose = $section->expose; 15 echo myTools::escape_blanks($expose); 16 } ?> 17 <div class="sommaireloi"> 18 <?php if (isset($soussections)) { 19 $idx_sec = array(); $ct = 0; 20 foreach ($soussections as $ss) { 21 $idx_sec[$ss->id] = $ct; 22 $ct++; 13 23 } 14 if (isset($suivant))15 echo '<div class="suivant">'.link_to('Section '.$suivant, '@loi_section?loi='.$loi->texteloi_id.'&chapitre='.$chapitre->chapitre.'§ion='.$suivant).'</div>';16 echo '</div>';17 if (isset($section->expose)) {18 $expose = $section->expose;19 echo myTools::escape_blanks($expose);20 }21 } else {22 echo '<div class="pagerloi">';23 if (isset($precedent)) {24 echo '<div class="precedent">'.link_to('Chapitre '.$precedent, '@loi_chapitre?loi='.$loi->texteloi_id.'&chapitre='.$precedent).'</div>';25 }26 if (isset($suivant))27 echo '<div class="suivant">'.link_to('Chapitre '.$suivant, '@loi_chapitre?loi='.$loi->texteloi_id.'&chapitre='.$suivant).'</div>';28 echo '</div>';29 if (isset($chapitre->expose)) {30 $expose = $chapitre->expose;31 echo myTools::escape_blanks($expose);32 }33 24 } 34 if (isset($soussections)) {35 $sections = array();36 foreach ($soussections as $ss) {37 $sections[$ss->id] = array('numero' => $ss->section, 'titre' => $ss->titre, 'expose' => $ss->expose);38 }39 unset($soussections);40 }41 42 25 $nart = 0; 43 26 $changesec = 0; 44 if (isset($sections)) $nsec = 0; 27 $cursec = 0; 28 $nsec = 0; 29 $level = 0; 45 30 foreach ($articles as $a) { 46 if (isset($sections) && isset($sections[$a->titre_loi_id])) { 47 $section = $sections[$a->titre_loi_id]; 48 if ($section['numero'] != $nsec) { 49 if ($nsec != 0) echo '</ul></li>'; 50 else echo '<ul>'; 51 $nsec = $section['numero']; 52 $changesec = 1; 53 echo '<li><b><a href="'.url_for('@loi_section?loi='.$loi->texteloi_id.'&chapitre='.$chapitre->chapitre.'§ion='.$nsec).'">'; 54 echo 'Section '.$nsec.' : '.$section['titre']; 55 if (isset($section['expose']) && $section['expose'] != "") { 31 if (isset($soussections) && isset($idx_sec[$a->titre_loi_id]) && $soussections[$idx_sec[$a->titre_loi_id]]->id != $cursec) { 32 $section = $soussections[$idx_sec[$a->titre_loi_id]]; 33 $cursec = $section->id; 34 $changesec = 1; 35 echo "</ul>"; 36 if ($section->level < $level) { 37 echo "</li>"; 38 for ($i=1; $i < $level-$section->level+1; $i++) 39 echo "</ul></li>"; 40 } elseif ($section->level == $level) 41 echo "</li>"; 42 for ($i = $nsec; $i <= $idx_sec[$cursec]; $i++) { 43 $parsec = $soussections[$i]; 44 if ($parsec->level > $level) { 45 echo "<ul>"; 46 } 47 $level = $parsec->level; 48 echo '<li class="level'.$parsec->level.'"><a href="'.url_for($parsec->getUrl()).'">'.$parsec->getLevelTitre(); 49 if (isset($parsec->expose) && $parsec->expose != "") { 56 50 $expose = myTools::escape_blanks(truncate_text(html_entity_decode(strip_tags($section['expose']), ENT_NOQUOTES, "UTF-8"), 250)); 57 echo '</b><blockquote>'.$expose.'</blockquote></a>'; 58 } else echo '</b></a>'; 51 echo '</b><blockquote>'.$expose.'</blockquote>'; 52 } 53 echo '</a>'; 59 54 } 55 $nsec = $idx_sec[$cursec]+1; 60 56 } 61 57 if ($nart != 0 && $changesec == 0) echo '</li>'; 62 58 else { 63 echo '<ul>';59 echo "<ul>"; 64 60 $changesec = 0; 65 61 } … … 73 69 } 74 70 $nart = $a->ordre; 75 echo '<li><a href="'.url_for('@loi_article?loi='.$loi->texteloi_id.'&article='.$a->slug).'">'; 76 echo '<b>Article '.$a->titre.'</b></a>'; 71 echo '<li class="articleloi"><a href="'.url_for('@loi_article?loi='.$loi->texteloi_id.'&article='.$a->slug).'"><u>Article '.$a->titre.'</u></a>'; 77 72 if ($a->nb_commentaires > 0 || isset($amendements[$atitre])) echo ' ('; 78 73 if ($a->nb_commentaires > 0) { … … 105 100 } 106 101 } 107 if ($nart != 0) echo '</ul>'; ?> 102 if ($nart != 0) echo '</ul>'; 103 for ($i = 0; $i < $level; $i++) 104 echo "</li></ul>"; ?> 108 105 </div> 106 </div> -
cpc/trunk/project/apps/frontend/modules/section/actions/actions.class.php
r2935 r3065 78 78 ->from('TitreLoi t') 79 79 ->whereIn('t.texteloi_id', $lois) 80 ->andWhere('t.chapitre IS NULL') 81 ->andWhere('t.section is NULL') 80 ->andWhere('t.leveltype = ?', 'loi') 82 81 ->orderBy('t.texteloi_id') 83 82 ->fetchArray(); -
cpc/trunk/project/apps/frontend/modules/section/actions/components.class.php
r2687 r3065 4 4 { 5 5 public function executeSimplifions() { 6 $this->lois = Doctrine_Query::create()->select('l.texteloi_id, l.titre, l.nb_commentaires')->from('TitreLoi l')->where('l. chapitre IS NULL')->andWhere('l.section IS NULL')->andWhere('l.nb_commentaires >= 5')->orderBy('l.date DESC')->fetchArray();6 $this->lois = Doctrine_Query::create()->select('l.texteloi_id, l.titre, l.nb_commentaires')->from('TitreLoi l')->where('l.leveltype = ?', 'loi')->orderBy('l.date DESC')->fetchArray(); //->andWhere('l.nb_commentaires >= 5') 7 7 } 8 8 -
cpc/trunk/project/batch/loi/parse_loi.pl
r3064 r3065 2 2 3 3 $file = $source = shift; 4 $titre_chap = shift;5 4 6 5 $source =~ s/^[^\/]+\///; … … 15 14 $present = 0; 16 15 } else { 17 $present = 1; 18 } 16 $present = 0; 17 } 18 use HTML::Entities; 19 19 20 20 open(FILE, $file) ; … … 50 50 } 51 51 52 sub checkout_chapitre { 53 if ($present == 0 && $chapitre == 1) { 52 $accents = '[ÀÉÈÊËÎÏÔÙÛÜÇ]'; 53 $upcases = "([A-Z]|$accents)"; 54 sub name_lowerize { 55 my $name = shift; 56 utf8::decode($name); 57 $name = decode_entities($name); 58 $name =~ s/ ($upcases\w{1,4}+ )/ \L$1/g; 59 $name =~ s/ ($upcases\w{1,4}+ )/ \L$1/g; 60 $name =~ s/($upcases')/\L$1/g; 61 $name =~ s/$upcases(\w+ ?)/$1\L$2/g; 62 $name =~ s/(([^' ]|$accents))(\w+)/$1\L$3/g; 63 utf8::encode($name); 64 $name =~ s/\s+/ /g; 65 return ucfirst($name); 66 } 67 68 sub checkout_level { 69 $level = shift; 70 if ($level == 0) { 71 return; 72 } 73 if ($present == 0 && $level == 1 && $levels[0] == 1) { 54 74 checkout_loi(); 55 75 } 56 if ($chapitre != 0) { 57 print '{"type": "chapitre", "loi": "'.$loi.'", "chapitre": "'.$chapitre.'", "titre": "'.$titre.'", "expose": "'.$exposechapitre."\"}\n"; 58 } 59 $exposechapitre = ""; 60 $exposesection = ""; 61 $exposearticle = ""; 62 $titre = ""; 63 $section = 0; 64 } 65 66 sub checkout_section { 67 if ($section != 0) { 68 print '{"type": "section", "loi": "'.$loi.'", "chapitre": "'.$chapitre.'", "section": "'.$section.'", "titre": "'.$titre.'", "expose": "'.$exposesection."\"}\n"; 69 } 70 $exposesection = ""; 76 if ($levels[$level-1] != 0) { 77 print '{"type": "section", "loi": "'.$loi.'", "level": "'.$level.'", "leveltype": "'.$leveltype.'", "level1": "'.$levels[0].'", "level2": "'.$levels[1].'", "level3": "'.$levels[2].'", "level4": "'.$levels[3].'", "titre": "'.name_lowerize($titre).'", "expose": "'.$exposelevels[$level-1]."\"}\n"; 78 } 79 for ($i = $level - 1; $i < 4; $i++) { 80 $exposelevels[$i] = ""; 81 } 71 82 $exposearticle = ""; 72 83 $titre = ""; … … 77 88 $exposearticle =~ s/<a href=["']([^"']*);([^"']*)["']>/<a href='\1.\2'>/gi; 78 89 } 79 if ($ chapitre != 0 && $num_article != 0) { if (!(($loi == 1890 && ($chapitre == 5 || $num_article == 101)) || ($loi == 1697 && ($chapitre == 3 && $section >= 2 && $num_article == 9) ))) {90 if ($levels[0] != 0 && $num_article != 0) { 80 91 if (!($exposearticle =~ /^$/)) { 81 92 # $exposearticle =~ s/\s*$/<\/p>/; … … 85 96 $num_article_titre = $num_article; 86 97 } 87 print '{"type": "article", "loi": "'.$loi.'", " chapitre": "'.$chapitre.'", "section": "'.$section.'", "article": "'.$num_article_titre.'", "ordre": "", "expose": "'.$exposearticle."\"}\n";88 } }$exposearticle = "";98 print '{"type": "article", "loi": "'.$loi.'", "level": "'.$level.'", "leveltype": "'.$leveltype.'", "level1": "'.$levels[0].'", "level2": "'.$levels[1].'", "level3": "'.$levels[2].'", "level4": "'.$levels[3].'", "article": "'.$num_article_titre.'", "ordre": "", "expose": "'.$exposearticle."\"}\n"; 99 } $exposearticle = ""; 89 100 } 90 101 } … … 92 103 sub checkout_article { 93 104 if ($num_article != 0 && $titre_article != '') { 94 print '{"type": "article", "loi": "'.$loi.'", " chapitre": "'.$chapitre.'", "section": "'.$section.'", "article": "'.$titre_article.'", "ordre": "'.$num_article.'", "expose": ""}'."\n";105 print '{"type": "article", "loi": "'.$loi.'", "level1": "'.$levels[0].'", "level2": "'.$levels[1].'", "level3": "'.$levels[2].'", "level4": "'.$levels[3].'", "article": "'.$titre_article.'", "ordre": "'.$num_article.'", "expose": ""}'."\n"; 95 106 } 96 107 } 97 108 98 109 sub checkout_alinea { 99 print '{"type": "alinea", "loi": "'.$loi.'", " chapitre": "'.$chapitre.'", "section": "'.$section.'", "article": "'.$titre_article.'", "alinea": "'.$num_alinea.'", "texte": "'.$texte."\"}\n";110 print '{"type": "alinea", "loi": "'.$loi.'", "level1": "'.$levels[0].'", "level2": "'.$levels[1].'", "level3": "'.$levels[2].'", "level4": "'.$levels[3].'", "article": "'.$titre_article.'", "alinea": "'.$num_alinea.'", "texte": "'.$texte."\"}\n"; 100 111 $texte = ""; 101 112 } 102 113 114 # Convert from roman numbers 115 %romans_map = ('M' => 1000, 'CM' => 900, 'D' => 500, 'CD' => 400, 'C' => 100, 'XC' => 90, 'L' => 50, 'XL' => 40, 'X' => 10, 'IX' => 9, 'V' => 5, 'IV' => 4, 'I' => 1); 116 sub romans { 117 $num = shift; 118 $res = 0; 119 while (($r, $d) = each(%romans_map)) { 120 while ($num =~ s/^$r//i) { 121 $res += $d; 122 } 123 } 124 $res += $num; 125 return $res; 126 } 127 128 sub set_level { 129 $leveltype = lc(shift); 130 $levelvalue = romans(shift); 131 $oldlevel = $curlevel; 132 if (!$hierarchy{$leveltype}) { 133 $curlevel += 1; 134 $hierarchy{$leveltype} = $curlevel; 135 } else { 136 $curlevel = $hierarchy{$leveltype}; 137 } 138 $levels[$curlevel-1] = $levelvalue; 139 for ($i=$curlevel; $i<4; $i++) { 140 $levels[$i] = 0; 141 } 142 #print "TEST $leveltype ; $levelvalue ; $curlevel ; $hierarchy ; $levels\n"; 143 } 144 103 145 sub handle_text { 104 if ($deftitre =~ /^none$/) { 105 if (($titre_chap =~ /^titre$/ && $content =~ /^\s*(T|t)(itre|ITRE)\s+(\d+|[IVX]+)(ER|er)?/) || (!($titre_chap =~ /^titre$/) && $content =~ /^\s*(T|CHAP|Chap)(itre|ITRE)\s+(\d+|[IVXivx]+)(ER|er)?/)) { 106 $chapitre++; 107 $section = 0; 108 $deftitre = 'chapitre'; 109 } elsif (($titre_chap =~ /^titre$/ && $content =~ /^\s*(C|c)(HAPITRE|hapitre)\s+(\d+|[IVXivx]+)(ER|er)?/) || (!($titre_chap =~ /^titre$/) && $content =~ /^\s*section\s+\d+/i)) { 110 $section++; 111 $deftitre = 'section'; 146 if ($deftitre == 0) { 147 if ($content =~ /^\s*((chap|t)itre|volume|livre|tome|(sous-)?section)\s+(\d+|[ivx]+)(er?)?/i) { 148 set_level($1, $4); 149 $deftitre = 1; 112 150 } elsif ($align =~ /center/ && $content =~ /<b>\s*Article/) { 113 151 $content_art = $content; … … 138 176 $content =~ s/<\/?[a-z]+>//ig; 139 177 $titre = $content; 140 if ($deftitre =~ /^chapitre$/) { 141 checkout_chapitre(); 142 } elsif ($deftitre =~ /^section$/) { 143 checkout_section(); 144 } 145 $deftitre = 'none'; 178 checkout_level($curlevel); 179 $deftitre = 0; 146 180 } 147 181 } 148 182 149 183 sub reset_vars { 150 $chapitre = 0; 151 $section = 0; 184 $levels = [0,0,0,0]; 185 $exposelevels = ["","","",""]; 186 $curlevel = 0; 187 $leveltype = ""; 152 188 $article = 0; 153 189 $num_article = 0; … … 155 191 $texte = ""; 156 192 $expose = ""; 157 $exposechapitre = "";158 $exposesection = "";159 193 $exposearticle = ""; 160 194 $titre = ""; 161 195 $titrearticle = ""; 196 $hierarchy = {}; 197 $deftitre = 0; 162 198 } 163 199 164 200 $auteur = ""; 165 201 $zone = 0; 166 $deftitre = 'none';167 202 reset_vars(); 168 if ($loi =~ /ta376/) {169 $date = "2009-12-02";170 $auteur = "M. Jean-Luc Warsmann";171 }172 203 173 204 foreach $line (split /\n/, $string) { … … 196 227 if ($content =~ /(PRO.*DE\s+LOI|EXPOS.*MOTIF)/) { 197 228 if ($zone == 2) { 198 if ($ chapitre== 0) {229 if ($levels[0] == 0) { 199 230 checkout_loi(); 200 231 $titre = ""; 201 } elsif ($loi == 1697) {202 while ($num_article < 47) {203 $tmp_expose = $exposearticle;204 checkout_present_article();205 $num_article ++;206 $exposearticle = $tmp_expose;207 }208 } elsif ($loi == 2760) {209 checkout_present_article();210 checkout_chapitre();211 232 } 212 233 } … … 218 239 if ($zone == 2) { 219 240 220 if ($content =~ /(\*\*\*|<b>.*( chap|t)itre\s+(premier|[IVX]+[eE]?[rR]?).*<\/b>)/) {241 if ($content =~ /(\*\*\*|<b>.*((chap|t)itre)\s+(premier|[ivxIVX]+[eE]?[rR]?).*<\/b>)/) { 221 242 checkout_present_article(); 222 checkout_section(); 223 checkout_chapitre(); 243 for ($i == 4; $i > 0; $i++) { 244 checkout_level($i); 245 } 224 246 $check = 1; 225 247 if ($content =~ /\*\*\*/) { … … 227 249 } 228 250 } 229 if ($check == 1 && $content =~ /( chap|t)itre\s+(premier|[IVX]+[eE]?[rR]?),?(<|\s+)/) {230 if ($ chapitre== 0) {251 if ($check == 1 && $content =~ /((chap|t)itre|volume|livre|tome)\s+(\d+|premi|[ivx]+)e?r?,?(<|\s+)/) { 252 if ($levels[0] == 0) { 231 253 checkout_loi(); 232 254 } 233 $chapitre++; 234 $exposechapitre .= '<p>'.$content.'</p>'; 235 $section = 0; 255 if ($levels[$curlevel-1] != 0) { 256 checkout_present_article(); 257 checkout_level($curlevel); 258 } 259 set_level($1, $3); 260 $exposelevels[$curlevel-1] .= '<p>'.$content.'</p>'; 236 261 $check = 0; 237 if ($loi == 1890) { 238 if ($num_article == 88) { 239 $num_article = 101; 240 } elsif ($num_article == 101) { 241 $num_article = 135; 242 } 243 } elsif ($loi == 1697) { 244 if ($num_article == 4) { 245 $num_article = 8; 246 } elsif ($num_article == 9) { 247 $num_article = 18; 248 } 249 } 250 } elsif ($content =~ /la(\s+|\s*<[a-z]*>\s*)?section\s+(\d+)/i && ($section + 1 == $2)) { 251 if ($section != 0) { 262 } elsif ($content =~ /la(\s+|\s*<[a-z]*>\s*)?((sous-)?section)\s+(\d+|[ivx]+)/i) { 263 if ($levels[$curlevel-1] != 0) { 252 264 checkout_present_article(); 253 checkout_section(); 254 } 255 # $exposesection = '<p>'.$content.'</p>'; 256 $section = $2; 257 } 258 259 if ($chapitre == 0) { 265 checkout_level($curlevel); 266 } 267 set_level($2, $4); 268 } 269 270 if ($levels[0] == 0) { 260 271 $expose .= '<p>'.$content.'</p>'; 261 272 } else { … … 267 278 } 268 279 foreach $phrase (split /\.\s*/, $content) { 269 if ($phrase =~ /la\s+section\s+(\d+)/i) { 270 $exposesection = '<p>'.$phrase.'.</p>'; 280 if ($phrase =~ /la\s+((sous-)?section)\s+(\d+|[ivx]+)/i) { 281 set_level($1, $3); 282 $exposelevels[$curlevel-1] = '<p>'.$phrase.'.</p>'; 271 283 if (!($phrase =~ /article\s+(\d+)/i)) { 272 284 next; 273 285 } 274 286 } 275 if ($phrase =~ /<b>.*articles?\s+(\d+).*<\/b>/i && (($num_article + 1 == $1) || ($loi == 2760 && $num_article == 6))) {287 if ($phrase =~ /<b>.*articles?\s+(\d+).*<\/b>/i && $num_article + 1 == $1) { 276 288 checkout_present_article(); 277 289 $num_article = $1; 278 if ($loi == 2760 && $num_article == 6) {279 $num_article = 7;280 }281 290 } 282 291 if ($num_article != 0) { … … 295 304 # } 296 305 # } 297 } elsif ($ section != 0 && !($exposesection=~ /$content/)) {298 $expose section.= '<p>'.$content.'</p>';306 } elsif ($levels[$curlevel-1] != 0 && !($exposelevels[$curlevel-1] =~ /$content/)) { 307 $exposelevels[$curlevel-1] .= '<p>'.$content.'</p>'; 299 308 # } elsif (!($exposearticle =~ /article\s+($num_article)/) && !($exposechapitre =~ /$content/)) { 300 309 # $exposechapitre .= '<p>'.$content.'</p>'; -
cpc/trunk/project/config/doctrine/schema.yml
r3037 r3065 582 582 columns: 583 583 texteloi_id: string(16) 584 chapitre: string(8) 585 section: string(8) 584 leveltype: string(16) 585 level1: string(8) 586 level2: string(8) 587 level3: string(8) 588 level4: string(8) 586 589 titre: string(512) 587 590 expose: -
cpc/trunk/project/lib/model/doctrine/Alinea.class.php
r977 r3065 29 29 "code de déontologie des professionnels de l'expertise comptable" => "LEGITEXT000006074510", 30 30 "code disciplinaire et pénal de la marine marchande" => "LEGITEXT000006071188", 31 "code des transports" => "LEGITEXT000023086525", 31 32 "code du domaine de l'état et des collectivités publiques applicable à la collectivité territoriale de mayotte" => "LEGITEXT000006074235", 32 33 "code du domaine de l'état" => "LEGITEXT000006070208", … … 66 67 "code des pensions civiles et militaires de retraite" => "LEGITEXT000006070302", 67 68 "code des pensions de retraite des marins français du commerce, de pêche ou de plaisance" => "LEGITEXT000006074066", 69 "code des pensions militaires d'invalidité et des victimes de guerre" => "LEGITEXT000006074068", 68 70 "code des pensions militaires d'invalidité et des victimes de la guerre" => "LEGITEXT000006074068", 69 71 "code des ports maritimes" => "LEGITEXT000006074233", -
cpc/trunk/project/lib/model/doctrine/AlineaTable.class.php
r964 r3065 6 6 { 7 7 8 public function findOrCreate($loi, $article, $numero, $ chapitre = 0, $section = 0) {9 $art = Doctrine::getTable('ArticleLoi')->findOrCreate($loi, $article, $ chapitre, $section);8 public function findOrCreate($loi, $article, $numero, $levels = array(0, 0, 0, 0)) { 9 $art = Doctrine::getTable('ArticleLoi')->findOrCreate($loi, $article, $levels); 10 10 $query = $this->createQuery('a') 11 11 ->where('a.texteloi_id = ?', $loi) -
cpc/trunk/project/lib/model/doctrine/ArticleLoiTable.class.php
r967 r3065 20 20 } 21 21 22 public function findOrCreate($loi, $article, $chapitre = 0, $section = 0) { 22 private static function getArticleTitreLoi($loi, $levels = array(0, 0, 0, 0)) { 23 $titreloi = $loi; 24 for ($i = 0; $i < 4; $i++) { 25 if ($levels[$i] != 0) { 26 $par = Doctrine::getTable('TitreLoi')->findLevelOrCreate($loi->texteloi_id, $i+1, $levels); 27 $par->nb_articles += 1; 28 $par->save(); 29 $titreloi = $par; 30 } else return $titreloi; 31 } 32 return $titreloi; 33 } 34 35 public function findOrCreate($loi, $article, $levels = array(0, 0, 0, 0)) { 23 36 $art = $this->findOneByLoiTitre($loi, $article); 24 37 if (!$art) { … … 30 43 $loiobj->nb_articles += 1; 31 44 $loiobj->save(); 32 if ($chapitre != 0) { 33 $chap = Doctrine::getTable('TitreLoi')->findChapitreOrCreate($loi, $chapitre); 34 $chap->nb_articles += 1; 35 $chap->save(); 36 if ($section != 0) { 37 $sec = Doctrine::getTable('TitreLoi')->findSectionOrCreate($loi, $chapitre, $section); 38 $sec->nb_articles++; 39 $art->setTitreLoi($sec); 40 $sec->save(); 41 } else { 42 $art->setTitreLoi($chap); 43 } 44 } else { 45 $art->setTitreLoi($loiobj); 46 } 45 $art->setTitreLoi(self::getArticleTitreLoi($loiobj, $levels)); 47 46 $art->save(); 48 47 } -
cpc/trunk/project/lib/model/doctrine/TitreLoi.class.php
r1442 r3065 23 23 } 24 24 25 public function getLargeTitre() { 26 $titre = ''; 27 if ($this->titre_loi_id != $this->id) { 28 if (isset($this->chapitre) && $this->chapitre != 0) { 29 $titre .= '<a href="@loi_chapitre">Chapitre '.$this->chapitre; 30 if (isset($this->section) && $this->section != 0) 31 $titre .= '</a> - <a href="@loi_section">section '.$this->section; 32 $titre .= ' : '.$this->titre.'</a>'; 33 } 25 public function setLevel($level, $value) { 26 $this->_set($levelstr, $value); 27 } 28 29 public static function findLevel($levels = array(0,0,0,0)) { 30 for ($i = 3; $i >= 0; $i--) 31 if ($levels[$i]) return $i+1; 32 return 0; 33 } 34 35 public function getLevel() { 36 $levels = array(); 37 for ($i = 1; $i < 5; $i++) 38 $levels[] = $this->_get('level'.$i, 0); 39 return self::findLevel($levels); 40 } 41 42 public function getLevelValue($level) { 43 if ($level != 1 && $level != 2 && $level != 3 && $level != 4) 44 return ''; 45 return $this->_get('level'.$level); 46 } 47 48 public function getUrl() { 49 $level = $this->getLevel(); 50 if (!$level) 51 return '@loi?loi='.$this->texteloi_id; 52 $args = "?loi=".$this->texteloi_id; 53 for ($i = 1; $i <= $level; $i++) 54 $args .= "&level".$i."=".$this->_get('level'.$i); 55 return '@loi_level'.$level.$args; 56 } 57 58 public function getShortLevelTitre() { 59 if ($this->getLevel()) 60 return ucfirst($this->leveltype).' '.$this->_get('level'.$this->getLevel()); 61 return ''; 62 } 63 64 public function getLevelTitre() { 65 $titre = ucfirst($this->titre); 66 if ($this->getShortLevelTitre()) 67 $titre = $this->getShortLevelTitre()." : ".$titre; 68 return $titre; 69 } 70 71 public function getHierarchie() { 72 if (!$this->getLevel()) 73 return ''; 74 sfProjectConfiguration::getActive()->loadHelpers(array('Url')); 75 $titreparent = '<a href="'.url_for($this->getUrl()).'">'.$this->getShortLevelTitre()."</a>"; 76 if ($this->getLevel() > 1) { 77 $parent = $this->TitreLoi; 78 $titreparent = $parent->getHierarchie()." - ".$titreparent; 34 79 } 35 return $titre ;80 return $titreparent; 36 81 } 37 82 … … 49 94 } 50 95 96 public function getVoisins() { 97 $result = array("",""); 98 $level = $this->getLevel(); 99 if (!$level) 100 return $result; 101 $levelstr = "level".$level; 102 $levelvalue = $this->_get($levelstr); 103 $levels = array(0,0,0,0); 104 for ($i = 1; $i < $level; $i++) 105 $levels[$i-1] = $this->_get('level'.$i); 106 if (preg_match('/^(\d+)\s+bis$/',$levelvalue, $match)) { 107 $result[0] = $match[1]; 108 $levels[$levelvalue] = $match[1] + 1; 109 if (Doctrine::getTable('TitreLoi')->findLevel($this->texteloi_id, $levels)) 110 $result[1] = $match[1] + 1; 111 } else { 112 $pre = $levelvalue - 1; 113 $qvoisins = Doctrine::getTable('TitreLoi')->createQuery('c') 114 ->select('c.'.$levelstr) 115 ->where('c.texteloi_id = ?', $this->texteloi_id); 116 for ($i = 1; $i < $level; $i++) 117 $qvoisins->andWhere('c.level'.$i.' = ?', $levels[$i-1]); 118 for ($i = $level + 1; $i < 5; $i++) 119 $qvoisins->andWhere('c.level'.$i.' IS NULL'); 120 $voisins = $qvoisins->andWhereIn('c.'.$levelstr, array($pre, $pre." bis", $levelvalue." bis", $levelvalue + 1)) 121 ->orderBy('c.'.$levelstr) 122 ->fetchArray(); 123 $ct = count($voisins); 124 if ($ct == 1) { 125 if ($levelvalue == 1) $result[1] = $voisins[0][$levelstr]; 126 else $result[0] = $voisins[0][$levelstr]; 127 } else if ($ct == 2) { 128 if ($levelvalue == 1) 129 $result[1] = $voisins[0][$levelstr]; 130 else if (preg_match('/^(\d+)\s+bis$/', $voisins[1][$levelstr], $match) && $match[1] < $levelvalue) 131 $result[0] = $voisins[1][$levelstr]; 132 else { 133 $result[0] = $voisins[0][$levelstr]; 134 $result[1] = $voisins[1][$levelstr]; 135 } 136 } else if ($ct > 2) { 137 if (preg_match('/bis/', $voisins[1][$levelstr]) && preg_match('/bis/', $voisins[2][$levelstr])) { 138 $result[0] = $voisins[1][$levelstr]; 139 $result[1] = $voisins[2][$levelstr]; 140 } else { 141 $result[0] = $voisins[0][$levelstr]; 142 if (preg_match('/'.$n_section.'/', $voisins[1][$levelstr])) { 143 $result[0] = $voisins[0][$levelstr]; 144 $result[1] = $voisins[1][$levelstr]; 145 } else { 146 $result[0] = $voisins[1][$levelstr]; 147 $result[1] = $voisins[2][$levelstr]; 148 } 149 } 150 } 151 } 152 return $result; 153 } 154 51 155 } -
cpc/trunk/project/lib/model/doctrine/TitreLoiTable.class.php
r1102 r3065 11 11 ->from('TitreLoi t') 12 12 ->where('t.texteloi_id = ?', $id) 13 ->andWhere('t.chapitre IS NULL') 14 ->andWhere('t.section IS NULL') 13 ->andWhere('t.leveltype = ?', 'loi') 15 14 ->fetchOne(); 16 15 if (!$loiarr) return null; … … 28 27 $query = $this->createQuery('t') 29 28 ->where('t.texteloi_id = ?', $numero) 30 ->andWhere('t.chapitre IS NULL') 31 ->andWhere('t.section IS NULL'); 29 ->andWhere('t.leveltype = ?', 'loi'); 32 30 return $query->fetchOne(); 33 31 } … … 39 37 $loi->texteloi_id = $numero; 40 38 $loi->nb_articles = 0; 39 $loi->leveltype = 'loi'; 41 40 $loi->save(); 42 41 } … … 46 45 } 47 46 48 public function findChapitre($loi, $numero) { 49 $query = $this->createQuery('t') 50 ->where('t.texteloi_id = ?', $loi) 51 ->andWhere('t.chapitre = ?', $numero) 52 ->andWhere('t.section IS NULL'); 53 return $query->fetchOne(); 54 } 55 56 public function findChapitreOrCreate($loi, $numero) { 57 $chap = $this->findChapitre($loi, $numero); 58 if (!$chap) { 59 $chap = new TitreLoi(); 60 $chap->texteloi_id = $loi; 61 $chap->chapitre = $numero; 62 $chap->nb_articles = 0; 63 } 64 $chap->titre_loi_id = $this->findLoiOrCreate($loi)->id; 65 $chap->save(); 66 return $chap; 47 public function identifyAndFindLevel($loi, $levels = array(0, 0, 0, 0)) { 48 return self::findLevel($loi, TitreLoi::findLevel($levels), $levels); 67 49 } 68 50 69 public function find Section($loi, $chapitre, $numero) {51 public function findLevel($loi, $level, $levels = array(0, 0, 0, 0)) { 70 52 $query = $this->createQuery('t') 71 ->where('t.texteloi_id = ?', $loi) 72 ->andWhere('t.chapitre = ?', $chapitre) 73 ->andWhere('t.section = ?', $numero); 53 ->where('t.texteloi_id = ?', $loi); 54 for ($i = 0; $i < 4; $i++) { 55 if ($i < $level) 56 $query->andWhere('t.level'.($i+1).' = ?', $levels[$i]); 57 else $query->andWhere('t.level'.($i+1).' IS NULL'); 58 } 74 59 return $query->fetchOne(); 75 60 } 76 61 77 public function findSectionOrCreate($loi, $chapitre, $numero) { 78 $sect = $this->findSection($loi, $chapitre, $numero); 62 public function findLevelOrCreate($loi, $level, $levels = array(0, 0, 0, 0), $leveltype = '') { 63 if ($level == 0) 64 return $this->findLoiOrCreate($loi); 65 $sect = $this->findLevel($loi, $level, $levels); 79 66 if (!$sect) { 80 67 $sect = new TitreLoi(); 81 68 $sect->texteloi_id = $loi; 82 $sect->chapitre = $chapitre;83 $sect->section = $numero;69 for ($i = 0; $i < $level; $i++) 70 $sect->setLevel($i+1, $levels[$i]); 84 71 $sect->nb_articles = 0; 85 72 } 86 $sect->titre_loi_id = $this->findChapitreOrCreate($loi, $chapitre)->id; 73 if (!$sect->leveltype && $leveltype != "") 74 $sect->leveltype = $leveltype; 75 $sect->titre_loi_id = $this->findLevelOrCreate($loi, $level-1, $levels)->id; 87 76 $sect->save(); 88 77 return $sect; -
cpc/trunk/project/lib/task/loadLoiTask.class.php
r1244 r3065 29 29 continue; 30 30 } 31 if ( $json->expose) $json->expose = preg_replace("/<a\shref='([^']+)'>/", '<a href="\1">', $json->expose);32 if ( $json->texte) $json->texte = preg_replace("/<a\shref='([^']+)'>/", '<a href="\1">', $json->texte);31 if (isset($json->expose)) $json->expose = preg_replace("/<a\shref='([^']+)'>/", '<a href="\1">', $json->expose); 32 if (isset($json->texte)) $json->texte = preg_replace("/<a\shref='([^']+)'>/", '<a href="\1">', $json->texte); 33 33 if ($json->type == 'loi') { 34 34 $loi = Doctrine::getTable('TitreLoi')->findLoiOrCreate($json->loi); … … 39 39 if ($json->auteur) $loi->setAuteur($json->auteur); 40 40 $loi->save(); 41 } else if ($json->type == 'chapitre') {42 $chap = Doctrine::getTable('TitreLoi')->findChapitreOrCreate($json->loi, $json->chapitre);43 if ($json->titre) $chap->titre = $json->titre;44 if ($json->expose) $chap->expose = $json->expose;45 $chap->save();46 41 } else if ($json->type == 'section') { 47 $sec = Doctrine::getTable('TitreLoi')->find SectionOrCreate($json->loi, $json->chapitre, $json->section);42 $sec = Doctrine::getTable('TitreLoi')->findLevelOrCreate($json->loi, $json->level, array($json->level1, $json->level2, $json->level3, $json->level4), $json->leveltype); 48 43 if ($json->titre) $sec->titre = $json->titre; 49 44 if ($json->expose) $sec->expose = $json->expose; 50 45 $sec->save(); 51 46 } else if ($json->type == 'article') { 52 $art = Doctrine::getTable('ArticleLoi')->findOrCreate($json->loi, $json->article, $json->chapitre, $json->section);47 $art = Doctrine::getTable('ArticleLoi')->findOrCreate($json->loi, $json->article, array($json->level1, $json->level2, $json->level3, $json->level4)); 53 48 if ($json->expose && $json->expose != '') $art->expose = $json->expose; 54 49 if ($json->ordre && $json->ordre != '') { … … 63 58 } else $art->save(); 64 59 } else if ($json->type == 'alinea') { 65 $ali = Doctrine::getTable('Alinea')->findOrCreate($json->loi, $json->article, $json->alinea, $json->chapitre, $json->section);60 $ali = Doctrine::getTable('Alinea')->findOrCreate($json->loi, $json->article, $json->alinea, array($json->level1, $json->level2, $json->level3, $json->level4)); 66 61 if ($json->alinea == 1) 67 62 $refcode = ''; -
cpc/trunk/project/web/css/xneth/style.css
r3048 r3065 1287 1287 border-bottom: 1px dashed #E8E7E4; 1288 1288 } 1289 .inscription input, .connexion input { width: 20em; }1289 .inscription input, .connexion input { max-width: 320px; } 1290 1290 /* commentaires */ 1291 1291 .link_comment { … … 1299 1299 clear:both; 1300 1300 margin-bottom: 15px; 1301 } 1302 1303 .commentaires .com_ajax textarea { 1304 max-width: 840px; 1301 1305 } 1302 1306 .commentaire_avatar { … … 1331 1335 text-decoration: underline; 1332 1336 } 1333 .commentaires com_link { 1334 float: right; 1337 .commentaires .com_link { 1338 float: right; 1339 } 1340 1341 .commentaires th { 1342 max-width: 400px; 1335 1343 } 1336 1344 .source { … … 1360 1368 padding-left: 20px; 1361 1369 } 1362 .loi li { 1363 margin-left: -15px; 1370 .sommaireloi ul { 1371 margin-bottom: 8px; 1372 } 1373 .sommaireloi li { 1374 margin-top: 5px; 1364 1375 } 1365 1376 .loi blockquote { … … 1413 1424 } 1414 1425 .alineatexte { 1415 width: 870px;1426 max-width: 870px; 1416 1427 } 1417 1428 .alineatexte p:first-letter { … … 1428 1439 display: none; 1429 1440 float: right; 1430 margin-top: 1 3px;1431 margin-bottom: 0px;1432 margin-right: 25px;1441 margin-top: 10px; 1442 margin-bottom: 3px; 1443 margin-right: 18px; 1433 1444 height: 11px; 1434 1445 } … … 1436 1447 margin-top: 22px; 1437 1448 margin-left: 10px; 1449 max-width: 850px; 1450 clear: both; 1451 margin: auto; 1438 1452 } 1439 1453 .com_ajax { 1440 1454 margin-top: 30px; 1441 1455 } 1442 .alineatexte .commentaires {1443 clear: both;1444 margin: auto;1445 }1446 1456 .alineatexte .commentaire_avatar img { 1447 1457 margin: 6px; … … 1449 1459 .loi, .sommaireloi { 1450 1460 font-size: 12px; 1461 } 1462 .sommaireloi .level1 { 1463 font-weight: bold; 1464 font-size: 14px; 1465 } 1466 .sommaireloi .level2 { 1467 font-weight: bold; 1468 opacity: 0.8; 1469 font-size: 13px; 1470 } 1471 .sommaireloi .level3 { 1472 font-weight: normal; 1473 opacity: 1; 1474 font-size: 13px; 1475 } 1476 .sommaireloi .articleloi { 1477 font-weight: normal; 1478 font-size: 12px; 1479 } 1480 .sommaireloi small { 1481 font-weight: normal; 1482 opacity: 1; 1483 font-size: 11px; 1451 1484 } 1452 1485 .loi .alineatexte .commentaire a { … … 1469 1502 text-align: right; 1470 1503 } 1471 .alineatexte .commentaires com_link { 1472 float: right; 1504 .alineatexte .commentaires .com_link { 1505 float: right; 1506 } 1507 .alineatexte .commentaires .com_link tr { 1508 max-width: 830px; 1473 1509 } 1474 1510 .perso {
Note: See TracChangeset
for help on using the changeset viewer.