-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmacros_entrees.html
164 lines (147 loc) · 4.97 KB
/
macros_entrees.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<CONTENT VERSION="1.0" LANG="fr" CHARSET="utf-8"/>
/**
* Initialisation de la page.
*/
<DEFMACRO NAME="ENTREES_INIT">
<LET VAR="CURRENT_TYPE" GLOBAL="1">[#TYPE.TYPE]</LET>
<LET VAR="titre_page" GLOBAL="1">
<IF COND="[#TYPE.TITLE]"><IF COND="[#TYPE.ALTERTITLE:#SITELANG]">[#TYPE.ALTERTITLE:#SITELANG]<ELSE/>[#TYPE.TITLE]</IF></IF> – [#OPTIONS.METADONNEESSITE.TITRESITE]
</LET>
</DEFMACRO>
/**
* Macro principale appelée par le template.
*/
<DEFMACRO NAME="ENTREES_MAIN">
<MACRO NAME="ENTREES_TITLE" />
<IF COND="[#TYPE.FLAT] AND [#TYPE.SORT] EQ 'sortkey'">
<MACRO NAME="ENTREES_INDEX_PLAT" />
<ELSE />
<MACRO NAME="ENTREES_INDEX_HIERARCHIQUE" />
</IF>
</DEFMACRO>
/**
* Titre h1 du type d'index.
*/
<DEFMACRO NAME="ENTREES_TITLE">
<h1 id="indexes-alphabet" class="main-title entrees__title">
[@INDEX] | <span class="entrees__type"><IF COND="[#TYPE.ALTERTITLE:#SITELANG]">[#TYPE.ALTERTITLE:#SITELANG]<ELSE/>[#TYPE.TITLE]</IF></span>
</h1>
</DEFMACRO>
/**
* Raccourcis vers les mots-clés dans d'autres langues.
*/
<DEFMACRO NAME="ENTREES_RACCOURCIS">
<IF COND="[%CURRENT_TYPE] LIKE /^mots?cle/">
<LOOP NAME="entrees_raccourcis"
TABLE="entrytypes, entries"
SELECT="DISTINCT(idtype), type, title, altertitle, lang"
WHERE="type LIKE 'mot%cle%' AND entries.idtype = entrytypes.id"
ORDER="entrytypes.rank">
<BEFORE>
<IF COND="[#NBLIGNES] GT 1">
<section id="page-shortcuts" class="page-shortcuts">
<ul class="nav nav-pills">
</IF>
</BEFORE>
<DO>
<IF COND="[#NBLIGNES] GT 1">
<LET VAR="active_class"><IF COND="[#TYPE] EQ [%CURRENT_TYPE]">active</IF></LET>
<li class="page-shortcuts__item [#ACTIVE_CLASS]"><a href="[#IDTYPE|makeurlwithid]"><FUNC NAME="BASE_ML_TITRE" INDEX="1" /></a></li>
</IF>
</DO>
<AFTER>
<IF COND="[#NBLIGNES] GT 1">
</ul>
</section>
</IF>
</AFTER>
</LOOP>
</IF>
</DEFMACRO>
/**
* Afficher un index plat.
*/
<DEFMACRO NAME="ENTREES_INDEX_PLAT">
<MACRO NAME="ENTREES_RACCOURCIS" />
<LET VAR="table">#_TP_entries</LET>
<LET VAR="field">[#TYPE.SORT]</LET>
<LET VAR="idtype">[#TYPE.ID]</LET>
<MACRO NAME="NAV_ALPHABET" />
<section id="index-list" class="index-list index-list--plat index-list--type-[%CURRENT_TYPE]">
<LOOP NAME="alphabetSpec">
<LET VAR="lettresql">[#LETTRE|replace("'", "\'")]</LET>
<LOOP NAME="entrees_index_plat_alpha"
TABLE="entries"
SELECT="id, g_name"
WHERE="type = '[#TYPE.TYPE]' AND UPPER(SUBSTRING([#FIELD],1,1)) = '[#LETTRESQL]'"
ORDER="[#FIELD]">
<BEFORE>
<section id="alpha[#LETTRE|ord]" class="index-list__section">
<div class="row">
<div class="index-list__letter-col col-sm-2 col-sm-offset-1">
<h2 class="index-list__letter">
<a href="#indexes-alphabet">[#LETTRE]</a>
</h2>
</div>
<div class="index-list__contents-col col-sm-8">
<ul class="index-list__list index-list__list--plat" xml:lang="[#TYPE.LANG]" lang="[#TYPE.LANG]">
</BEFORE>
<DO>
<li class="index-list__item index-list__item--plat"><MACRO NAME="ENTREES_ENTREE"/></li>
</DO>
<AFTER>
</ul>
</div>
</div>
</section>
</AFTER>
</LOOP>
</LOOP>
</section>
</DEFMACRO>
/**
* Afficher un index hiérarchique.
*/
<DEFMACRO NAME="ENTREES_INDEX_HIERARCHIQUE">
<LET VAR="idrec">0</LET>
<section id="index-list" class="index-list index-list--hierarchique index-list--type-[%CURRENT_TYPE]">
<LOOP NAME="entrees_index_hierarchique" SELECT="id, g_name" TABLE="entries" WHERE="type = '[#TYPE.TYPE]' AND idparent = '[#IDREC]'" ORDER="entries.[#TYPE.SORT]">
<BEFORE>
<ul class="index-list__list index-list__list--hierarchique">
</BEFORE>
<DO>
<li class="index-list__item index-list__item--hierarchique">
<MACRO NAME="ENTREES_ENTREE"/>
<LET VAR="idrec">[#ID]</LET>
<LOOP NAME="entrees_index_hierarchique"></LOOP>
</li>
</DO>
<AFTER>
</ul>
</AFTER>
</LOOP>
</section>
</DEFMACRO>
/**
* Afficher une entrée d'index avec le nombre d'entités liées
* (si pas d'entitiés alors ne pas afficher le nombre et ne pas créer de lien)
*/
<DEFMACRO NAME="ENTREES_ENTREE">
<LOOP NAME="entrees_entree_count"
TABLE="relations, entities"
SELECT="count(id) AS n"
WHERE="id2 = '[#ID]' AND type NOT IN ('informations', 'actualite') AND id1 = entities.id AND entities.id [#NOT_IN_TRADUCTIONS]">
<!--[ Si pas de résultat alors chercher dans les traductions ]-->
<IF COND="[#N] EQ '0'">
<LOOP NAME="entrees_entree_count_traductions" TABLE="relations, entities" SELECT="count(id) AS n" WHERE="id2 = '[#ID]' AND type NOT IN ('informations', 'actualite') AND id1 = entities.id AND entities.id">
<IF COND="[#N] EQ '0'">
[#G_NAME]
<ELSE/>
<a class="index-list__entree" href="[#ID|makeurlwithid]">[#G_NAME]</a> <span class="index-list__count">([#N])</span>
</IF>
</LOOP>
<ELSE/>
<a class="index-list__entree" href="[#ID|makeurlwithid]">[#G_NAME]</a> <span class="index-list__count">([#N])</span>
</IF>
</LOOP>
</DEFMACRO>