Wiki source code of 学校一覧

Version 28.1 by Super Admin on 2026/03/18 12:01

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 <h1 class="home-section-title">登録されている学校</h1>
42 <div class="sort-header">
43 <div class="school-count">
44 $results.size() 校が登録されています
45 </div>
46 <div class="sort-toggle-group">
47 <a href="$doc.getURL('view', 'sort=updated')"
48 class="sort-toggle #if($sortParam == 'updated')active#end">
49 <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> 更新順
50 </a>
51 <a href="$doc.getURL('view', 'sort=pref')"
52 class="sort-toggle #if($sortParam == 'pref')active#end">
53 <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> 都道府県順
54 </a>
55 </div>
56 </div>
57 {{/html}}
58
59 #if($results.size() > 0)
60
61 ## 都道府県順の場合、都道府県グループヘッダーを表示
62 #set($currentPref = '')
63
64 {{html clean="false"}}
65 <div class="school-card-grid">
66 #foreach($docName in $results)
67 #set($schoolDoc = $xwiki.getDocument($docName))
68 #set($schoolObj = $schoolDoc.getObject('SeitokaiCode.SchoolClass'))
69 #if($schoolObj)
70 #set($sName = $!schoolObj.getValue('schoolName'))
71 #set($sPref = $!schoolObj.getValue('prefecture'))
72 #set($sCity = $!schoolObj.getValue('city'))
73 #set($sType = $!schoolObj.getValue('schoolType'))
74 #set($sEst = $!schoolObj.getValue('establishment'))
75 #set($sCoed = $!schoolObj.getValue('coeducation'))
76 #set($sSystem = $!schoolObj.getValue('schoolSystem'))
77 #set($lastUpdate = $datetool.format('yyyy/MM/dd', $schoolDoc.date))
78 ## 活動数をカウント
79 #set($actCount = $schoolDoc.getObjects('SeitokaiCode.ActivityClass').size())
80 ## 投稿数をカウント(全活動の投稿合計)
81 #set($postCount = $schoolDoc.getObjects('SeitokaiCode.ActivityPostClass').size())
82 ## 特色ある活動の数とタイトルを収集
83 #set($schoolActivities = $schoolDoc.getObjects('SeitokaiCode.ActivityClass'))
84 #set($featuredCount = 0)
85 #set($featuredTitles = [])
86 #if($schoolActivities)
87 #foreach($sa in $schoolActivities)
88 #if($!sa.getValue('featured') == '1')
89 #set($featuredCount = $featuredCount + 1)
90 #set($discard = $featuredTitles.add($!sa.getValue('title')))
91 #end
92 #end
93 #end
94
95 ## 都道府県グループヘッダー(都道府県順の場合)
96 #if($sortParam == 'pref' && $sPref != $currentPref)
97 #set($currentPref = $sPref)
98 <div class="pref-group-header">
99 <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>
100 </div>
101 #end
102
103 #set($sHidden = $!schoolObj.getValue('hidden'))
104 <a href="$schoolDoc.getURL('view')" class="school-card #if($sHidden == 1)school-card-hidden#end">
105 <div class="school-card-body">
106 <div class="school-card-header-row">
107 <div class="school-card-name">$!escapetool.xml($sName)</div>
108 #if($sHidden == 1)
109 <span class="badge-hidden">非表示</span>
110 #end
111 #if($sEst)
112 <span class="school-card-badge #if($sEst == '公立')public#elseif($sEst == '私立')private#else national#end">$!escapetool.xml($sEst)</span>
113 #end
114 </div>
115 <div class="school-card-meta">
116 $!escapetool.xml($sPref) $!escapetool.xml($sCity)
117 #if($sCoed) ・ $!escapetool.xml($sCoed)#end
118 #if($sSystem && !$sSystem.isEmpty()) ・ #foreach($__sys in $sSystem)#if($foreach.count > 1)・#end$!escapetool.xml($__sys)#end#end
119 </div>
120 ## 特色ある活動タイトル
121 #if($featuredCount > 0)
122 <div class="school-card-featured-titles">
123 #foreach($ft in $featuredTitles)
124 <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>
125 #end
126 </div>
127 #end
128 <div class="school-card-stats">
129 <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>
130 <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>
131 <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>
132 </div>
133 </div>
134 </a>
135 #end
136 #end
137 </div>
138 {{/html}}
139
140 #else
141 //まだ学校ページが登録されていません。//
142
143 [[学校ページを作成する>>SeitokaiCode.CreateSchool]]
144 #end
145 {{/velocity}}