Wiki source code of 学校一覧

Version 30.1 by Super Admin on 2026/03/21 17:40

Show last authors
1 {{velocity}}
2 ## ===== 学校一覧ページ =====
3 ## ソート: 更新順(デフォルト)/ 都道府県順
4 ## カード形式で表示し、活動数・投稿数・最終更新日を表示
5
6 ## --- 閲覧者情報(非表示校フィルタ用) ---
7 #set($listViewerUser = $xcontext.user)
8 #set($isListAdmin = false)
9 #if($listViewerUser != 'XWiki.XWikiGuest')
10 #set($listViewerDoc = $xwiki.getDocument($listViewerUser))
11 #set($listViewerAccountType = $!listViewerDoc.getValue('accountType'))
12 #if($listViewerAccountType == 'admin')
13 #set($isListAdmin = true)
14 #end
15 #end
16
17 #set($sortParam = $!request.sort)
18 #if(!$sortParam || $sortParam == '')
19 #set($sortParam = 'updated')
20 #end
21
22 ## ソート順に応じたXWQLクエリ(非表示校フィルタ付き)
23 #if($isListAdmin)
24 ## 管理者: 全校表示
25 #if($sortParam == 'pref')
26 #set($query = $services.query.xwql("from doc.object(SeitokaiCode.SchoolClass) as school order by school.prefecture, school.schoolName"))
27 #else
28 #set($query = $services.query.xwql("from doc.object(SeitokaiCode.SchoolClass) as school order by doc.date desc"))
29 #end
30 #else
31 ## 一般: 非表示校を除外
32 #if($sortParam == 'pref')
33 #set($query = $services.query.xwql("from doc.object(SeitokaiCode.SchoolClass) as school where (school.hidden <> 1 or school.hidden is null) order by school.prefecture, school.schoolName"))
34 #else
35 #set($query = $services.query.xwql("from doc.object(SeitokaiCode.SchoolClass) as school where (school.hidden <> 1 or school.hidden is null) order by doc.date desc"))
36 #end
37 #end
38 #set($results = $query.execute())
39
40 {{html clean="false"}}
41 <div style="display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:var(--sp-3); margin-bottom:var(--sp-2);">
42 <h1 class="home-section-title" style="margin-bottom:0;">登録されている学校</h1>
43 #if($listViewerUser != 'XWiki.XWikiGuest')
44 <a href="/bin/view/SeitokaiCode/CreateSchool" class="btn-primary" style="white-space:nowrap; text-decoration:none;">
45 <svg class="ico" viewBox="0 0 24 24" style="vertical-align:middle; margin-right:4px;"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>新しく学校を追加する
46 </a>
47 #end
48 </div>
49 <div class="sort-header">
50 <div class="school-count">
51 $results.size() 校が登録されています
52 </div>
53 <div class="sort-toggle-group">
54 <a href="$doc.getURL('view', 'sort=updated')"
55 class="sort-toggle #if($sortParam == 'updated')active#end">
56 <svg class="ico ico-fixed-14" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg> 更新順
57 </a>
58 <a href="$doc.getURL('view', 'sort=pref')"
59 class="sort-toggle #if($sortParam == 'pref')active#end">
60 <svg class="ico ico-fixed-14" viewBox="0 0 24 24"><path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0118 0z"/><circle cx="12" cy="10" r="3"/></svg> 都道府県順
61 </a>
62 </div>
63 </div>
64 {{/html}}
65
66 #if($results.size() > 0)
67
68 ## 都道府県順の場合、都道府県グループヘッダーを表示
69 #set($currentPref = '')
70
71 {{html clean="false"}}
72 <div class="school-card-grid">
73 #foreach($docName in $results)
74 #set($schoolDoc = $xwiki.getDocument($docName))
75 #set($schoolObj = $schoolDoc.getObject('SeitokaiCode.SchoolClass'))
76 #if($schoolObj)
77 #set($sName = $!schoolObj.getValue('schoolName'))
78 #set($sPref = $!schoolObj.getValue('prefecture'))
79 #set($sCity = $!schoolObj.getValue('city'))
80 #set($sType = $!schoolObj.getValue('schoolType'))
81 #set($sEst = $!schoolObj.getValue('establishment'))
82 #set($sCoed = $!schoolObj.getValue('coeducation'))
83 #set($sSystem = $!schoolObj.getValue('schoolSystem'))
84 #set($lastUpdate = $datetool.format('yyyy/MM/dd', $schoolDoc.date))
85 ## 活動数をカウント
86 #set($actCount = $schoolDoc.getObjects('SeitokaiCode.ActivityClass').size())
87 ## 投稿数をカウント(全活動の投稿合計)
88 #set($postCount = $schoolDoc.getObjects('SeitokaiCode.ActivityPostClass').size())
89 ## 特色ある活動の数とタイトルを収集
90 #set($schoolActivities = $schoolDoc.getObjects('SeitokaiCode.ActivityClass'))
91 #set($featuredCount = 0)
92 #set($featuredTitles = [])
93 #if($schoolActivities)
94 #foreach($sa in $schoolActivities)
95 #if($!sa.getValue('featured') == '1')
96 #set($featuredCount = $featuredCount + 1)
97 #set($discard = $featuredTitles.add($!sa.getValue('title')))
98 #end
99 #end
100 #end
101
102 ## 都道府県グループヘッダー(都道府県順の場合)
103 #if($sortParam == 'pref' && $sPref != $currentPref)
104 #set($currentPref = $sPref)
105 <div class="pref-group-header">
106 <span class="pref-group-label"><svg class="ico ico-fixed-16" viewBox="0 0 24 24"><path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0118 0z"/><circle cx="12" cy="10" r="3"/></svg> $!escapetool.xml($currentPref)</span>
107 </div>
108 #end
109
110 #set($sHidden = $!schoolObj.getValue('hidden'))
111 <a href="$schoolDoc.getURL('view')" class="school-card #if($sHidden == 1)school-card-hidden#end">
112 <div class="school-card-body">
113 <div class="school-card-header-row">
114 <div class="school-card-name">$!escapetool.xml($sName)</div>
115 #if($sHidden == 1)
116 <span class="badge-hidden">非表示</span>
117 #end
118 #if($sEst)
119 <span class="school-card-badge #if($sEst == '公立')public#elseif($sEst == '私立')private#else national#end">$!escapetool.xml($sEst)</span>
120 #end
121 </div>
122 <div class="school-card-meta">
123 $!escapetool.xml($sPref) $!escapetool.xml($sCity)
124 #if($sCoed) ・ $!escapetool.xml($sCoed)#end
125 #if($sSystem && !$sSystem.isEmpty()) ・ #foreach($__sys in $sSystem)#if($foreach.count > 1)・#end$!escapetool.xml($__sys)#end#end
126 </div>
127 ## 特色ある活動タイトル
128 #if($featuredCount > 0)
129 <div class="school-card-featured-titles">
130 #foreach($ft in $featuredTitles)
131 <span class="featured-title-item"><svg class="ico ico-fixed-12" viewBox="0 0 24 24" fill="currentColor" stroke="none"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg> $!escapetool.xml($ft)</span>
132 #end
133 </div>
134 #end
135 <div class="school-card-stats">
136 <span><svg class="ico ico-fixed-14" viewBox="0 0 24 24"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/></svg> 活動 <span class="num">$actCount</span>件</span>
137 <span><svg class="ico ico-fixed-14" viewBox="0 0 24 24"><path d="M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"/></svg> 投稿 <span class="num">$postCount</span>件</span>
138 <span><svg class="ico ico-fixed-14" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg> 更新 $lastUpdate</span>
139 </div>
140 </div>
141 </a>
142 #end
143 #end
144 </div>
145 {{/html}}
146
147 #else
148 //まだ学校ページが登録されていません。//
149
150 [[学校ページを作成する>>SeitokaiCode.CreateSchool]]
151 #end
152 {{/velocity}}