Version 71.1 by Super Admin on 2026/03/18 20:48

Show last authors
1 {{velocity}}
2 ## ===== 学校ページ テンプレート =====
3 ## ゲストが ?sheet= 付きURL(編集フォーム等)に直接アクセスした場合、ログインページへリダイレクト
4 #if($xcontext.user == 'XWiki.XWikiGuest' && $request.sheet && $request.sheet != '')
5 #set($currentUrl = $doc.getURL('view', "sheet=${request.sheet}"))
6 $response.sendRedirect("/bin/login/XWiki/XWikiLogin?srid=$escapetool.url($currentUrl)")
7 #stop
8 #end
9 {{html clean="false"}}
10 ## メンテナンスバナー({{include}}ではなくインラインで記述し、<p>タグ挿入を回避)
11 #set($bannerDoc = $xwiki.getDocument('SeitokaiAdmin.MaintenanceBanner'))
12 #set($bannerObj = $bannerDoc.getObject('SeitokaiCode.MaintenanceBannerClass'))
13 #if($bannerObj && $bannerObj.getValue('enabled') == 1)
14 #set($bannerMsg = $bannerObj.getValue('message'))
15 #set($bannerLevel = $bannerObj.getValue('level'))
16 #if(!$bannerLevel || $bannerLevel == '')#set($bannerLevel = 'warning')#end
17 <div class="maintenance-banner active maintenance-${bannerLevel}" id="maintenance-banner">
18 <div class="maintenance-banner-inner">
19 <span class="maintenance-icon">#if($bannerLevel == 'urgent')<svg class="ico-banner" viewBox="0 0 24 24"><path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>#elseif($bannerLevel == 'info')<svg class="ico-banner" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>#else<svg class="ico-banner" viewBox="0 0 24 24"><path d="M14.7 6.3a1 1 0 000 1.4l1.6 1.6a1 1 0 001.4 0l3.77-3.77a6 6 0 01-7.94 7.94l-6.91 6.91a2.12 2.12 0 01-3-3l6.91-6.91a6 6 0 017.94-7.94l-3.76 3.76z"/></svg>#end</span>
20 <span class="maintenance-text">$!escapetool.xml($bannerMsg)</span>
21 <button class="maintenance-close" onclick="document.getElementById('maintenance-banner').style.display='none'">&times;</button>
22 </div>
23 </div>
24 #end
25 ## --- 学校基本情報フィールド ---
26 #set($schoolCode = $doc.getValue('schoolCode'))
27 #set($schoolName = $doc.getValue('schoolName'))
28 #set($prefecture = $doc.getValue('prefecture'))
29 #set($city = $doc.getValue('city'))
30 #set($classCount = $doc.getValue('classCount'))
31 #set($studentCount = $doc.getValue('studentCount'))
32 #set($coeducation = $doc.getValue('coeducation'))
33 #set($establishment = $doc.getValue('establishment'))
34 #set($schoolLevel = $doc.getValue('schoolLevel'))
35 #set($schoolSystem = $doc.getValue('schoolSystem'))
36 #set($website = $doc.getValue('website'))
37
38 ## --- 組織図 ---
39 #set($orgChart = $doc.getValue('orgChart'))
40 #set($orgChartImage = $doc.getValue('orgChartImage'))
41
42 ## --- 日常の活動・選挙・定例活動 ---
43 #set($dailyActivities = $doc.getValue('dailyActivities'))
44 #set($dailyActivitiesNote = $doc.getValue('dailyActivitiesNote'))
45 #set($electionExists = $doc.getValue('electionExists'))
46 #set($electionType = $doc.getValue('electionType'))
47 #set($electionNote = $doc.getValue('electionNote'))
48 #set($meetingFrequency = $doc.getValue('meetingFrequency'))
49 #set($regularActivitiesNote = $doc.getValue('regularActivitiesNote'))
50
51 ## --- 予算 ---
52 #set($budgetProcess = $doc.getValue('budgetProcess'))
53 #set($studentFee = $doc.getValue('studentFee'))
54 #set($budgetScale = $doc.getValue('budgetScale'))
55 #set($budgetAllocation = $doc.getValue('budgetAllocation'))
56 #set($budgetNote = $doc.getValue('budgetNote'))
57
58 ## --- 校則の見直し ---
59 #set($ruleReviewStatus = $doc.getValue('ruleReviewStatus'))
60 #set($ruleReviewContent = $doc.getValue('ruleReviewContent'))
61 #set($ruleReviewProposer = $doc.getValue('ruleReviewProposer'))
62 #set($ruleReviewImplementer = $doc.getValue('ruleReviewImplementer'))
63 #set($ruleReviewSystem = $doc.getValue('ruleReviewSystem'))
64
65 ## --- 課題・連絡先 ---
66 #set($challenges = $doc.getValue('challenges'))
67 #set($contactInfo = $doc.getValue('contactInfo'))
68 #set($seitokaiWebsite = $doc.getValue('seitokaiWebsite'))
69 #set($seitokaiTwitter = $doc.getValue('seitokaiTwitter'))
70 #set($seitokaiInstagram = $doc.getValue('seitokaiInstagram'))
71 #set($seitokaiYoutube = $doc.getValue('seitokaiYoutube'))
72 #set($seitokaiOtherSns = $doc.getValue('seitokaiOtherSns'))
73
74 ## --- 現在の年度を計算(4月始まり) ---
75 #set($nowFY = $datetool.date)
76 #set($currentFYMonth = $mathtool.toInteger($datetool.format('MM', $nowFY)))
77 #set($currentFYYear = $mathtool.toInteger($datetool.format('yyyy', $nowFY)))
78 #if($currentFYMonth >= 4)
79 #set($currentFiscalYear = $currentFYYear)
80 #else
81 #set($currentFiscalYear = $mathtool.sub($currentFYYear, 1))
82 #end
83
84 ## --- 公開範囲フィールド ---
85 #set($visibilityOrgChart = $!doc.getValue('visibilityOrgChart'))
86 #set($visibilityBudget = $!doc.getValue('visibilityBudget'))
87 #set($visibilityRuleReview = $!doc.getValue('visibilityRuleReview'))
88 #set($visibilityChallenges = $!doc.getValue('visibilityChallenges'))
89 ## デフォルト値(未設定なら全体公開)
90 #if(!$visibilityOrgChart || $visibilityOrgChart == '') #set($visibilityOrgChart = 'public') #end
91 #if(!$visibilityBudget || $visibilityBudget == '') #set($visibilityBudget = 'public') #end
92 #if(!$visibilityRuleReview || $visibilityRuleReview == '') #set($visibilityRuleReview = 'public') #end
93 #if(!$visibilityChallenges || $visibilityChallenges == '') #set($visibilityChallenges = 'public') #end
94
95 ## --- 閲覧者情報(公開範囲チェック用) ---
96 #set($viewerUser = $xcontext.user)
97 #set($isGuest = $viewerUser == 'XWiki.XWikiGuest')
98 #set($isViewerAdmin = false)
99 #set($viewerSchoolCode = '')
100 #if(!$isGuest)
101 #set($viewerDoc = $xwiki.getDocument($viewerUser))
102 #set($viewerAccountType = $!viewerDoc.getValue('accountType'))
103 #set($viewerSchoolCode = $!viewerDoc.getValue('schoolCode'))
104 #if($viewerAccountType == 'admin')
105 #set($isViewerAdmin = true)
106 #end
107 #end
108
109 ## --- 関連校(中高一貫校)情報 ---
110 #set($affiliatedSchoolCode = $!doc.getValue('affiliatedSchoolCode'))
111 #set($affiliatedSchoolName = $!doc.getValue('affiliatedSchoolName'))
112 #set($isAffiliated = false)
113 #if($affiliatedSchoolCode && $affiliatedSchoolCode != '' && $viewerSchoolCode == $affiliatedSchoolCode)
114 #set($isAffiliated = true)
115 #end
116
117 ## --- 学校ページ非表示チェック ---
118 #set($schoolHidden = $doc.getValue('hidden'))
119 #if($schoolHidden == 1)
120 #if($isViewerAdmin)
121 ## 管理者: 黄色バナー + ページ内容は通常表示(プレビュー)
122 <div class="school-hidden-banner admin">
123 <svg class="ico" viewBox="0 0 24 24"><path d="M17.94 17.94A10.07 10.07 0 0112 20c-7 0-11-8-11-8a18.45 18.45 0 015.06-5.94M9.9 4.24A9.12 9.12 0 0112 4c7 0 11 8 11 8a18.5 18.5 0 01-2.16 3.19m-6.72-1.07a3 3 0 01-4.24-4.24"/><line x1="1" y1="1" x2="23" y2="23"/></svg>
124 <div>
125 <strong>このページは非表示になっています</strong>(管理者のみ閲覧可能)
126 #set($hBy = $!doc.getValue('hiddenBy'))
127 #set($hAt = $!doc.getValue('hiddenAt'))
128 #set($hReason = $!doc.getValue('hiddenReason'))
129 <div class="school-hidden-detail">
130 非表示: $!escapetool.xml($hAt) / $!escapetool.xml($hBy)
131 #if($hReason && $hReason != '') ・ 理由: $!escapetool.xml($hReason)#end
132 </div>
133 <a href="$xwiki.getURL('SeitokaiAdmin.SchoolManagement', 'view')" style="color:#92400e;text-decoration:underline">学校ページ管理へ</a>
134 </div>
135 </div>
136 #else
137 ## 一般ユーザー・ゲスト: 非公開メッセージを表示して停止
138 <div class="school-hidden-public">
139 <svg class="ico" viewBox="0 0 24 24" style="width:2.5em;height:2.5em"><path d="M17.94 17.94A10.07 10.07 0 0112 20c-7 0-11-8-11-8a18.45 18.45 0 015.06-5.94M9.9 4.24A9.12 9.12 0 0112 4c7 0 11 8 11 8a18.5 18.5 0 01-2.16 3.19m-6.72-1.07a3 3 0 01-4.24-4.24"/><line x1="1" y1="1" x2="23" y2="23"/></svg>
140 <h2>このページは現在公開されていません</h2>
141 <p>このページは管理者により非公開に設定されています。</p>
142 <a href="$xwiki.getURL('Schools.WebHome', 'view')" class="btn-back-list">学校一覧に戻る</a>
143 </div>
144 #stop
145 #end
146 #end
147
148 ## --- 投稿固定/解除処理 ---
149 #set($pinAction = $!request.action)
150 #if(($pinAction == 'pin' || $pinAction == 'unpin') && ($viewerAccountType == 'admin' || ($viewerAccountType == 'verified' && ($viewerSchoolCode == $schoolCode || $isAffiliated))) && $services.csrf.isTokenValid($request.form_token))
151 #set($pinPostObjStr = $!request.postObj)
152 #if(!$pinPostObjStr.matches('^\d+$'))
153 ## 不正な値 → 無視
154 #else
155 #set($postObjNum = $mathtool.toInteger($pinPostObjStr))
156 #set($postObj = $doc.getObject('SeitokaiCode.ActivityPostClass', $postObjNum))
157 #if($postObj)
158 #if($pinAction == 'pin')
159 $postObj.set('pinned', '1')
160 #set($pinnerDoc = $xwiki.getDocument($xcontext.user))
161 #set($pinnerName = $!pinnerDoc.getValue('displayName'))
162 #if(!$pinnerName || $pinnerName == '')#set($pinnerName = $xwiki.getUserName($xcontext.user))#end
163 $postObj.set('pinnedBy', $pinnerName)
164 $postObj.set('pinnedDate', $datetool.format('yyyy/MM/dd HH:mm', $datetool.date))
165 $doc.saveWithProgrammingRights('投稿を固定')
166 #else
167 $postObj.set('pinned', '')
168 $postObj.set('pinnedBy', '')
169 $postObj.set('pinnedDate', '')
170 $doc.saveWithProgrammingRights('投稿の固定を解除')
171 #end
172 $response.sendRedirect($doc.getURL('view'))
173 #stop
174 #end
175 #end## /matches
176 #end
177
178 ## --- 特色ある活動 選定/解除処理 ---
179 #set($featAction = $!request.action)
180 #if(($featAction == 'feature' || $featAction == 'unfeature') && ($viewerAccountType == 'admin' || (($viewerAccountType == 'verified' || $viewerAccountType == 'referred') && $viewerSchoolCode == $schoolCode)) && $services.csrf.isTokenValid($request.form_token))
181 #set($featActObjStr = $!request.actObj)
182 #if($featActObjStr.matches('^\d+$'))
183 #set($actObjNum = $mathtool.toInteger($featActObjStr))
184 #set($actObj = $doc.getObject('SeitokaiCode.ActivityClass', $actObjNum))
185 #if($actObj)
186 #if($featAction == 'feature')
187 ## 上限3件チェック
188 #set($allActs = $doc.getObjects('SeitokaiCode.ActivityClass'))
189 #set($featCount = 0)
190 #if($allActs)
191 #foreach($fa in $allActs)
192 #if($!fa.getValue('featured') == '1')
193 #set($featCount = $featCount + 1)
194 #end
195 #end
196 #end
197 #if($featCount < 3)
198 $actObj.set('featured', '1')
199 #set($featurerDoc = $xwiki.getDocument($xcontext.user))
200 #set($featurerName = $!featurerDoc.getValue('displayName'))
201 #if(!$featurerName || $featurerName == '')#set($featurerName = $xwiki.getUserName($xcontext.user))#end
202 $actObj.set('featuredBy', $featurerName)
203 $actObj.set('featuredDate', $datetool.format('yyyy/MM/dd HH:mm', $datetool.date))
204 $doc.saveWithProgrammingRights('特色ある活動に選定')
205 #end
206 #else
207 $actObj.set('featured', '')
208 $actObj.set('featuredBy', '')
209 $actObj.set('featuredDate', '')
210 $doc.saveWithProgrammingRights('特色ある活動の選定を解除')
211 #end
212 $response.sendRedirect($doc.getURL('view'))
213 #stop
214 #end
215 #end## /matches
216 #end
217
218 ## --- ユーザー情報取得 ---
219 ## displayName: Wiki上の表示名(ニックネーム)。本名(firstName/lastName)は管理者のみ閲覧可能。
220 #set($lastAuthor = $doc.author)
221 #set($lastAuthorDoc = $xwiki.getDocument($lastAuthor))
222 #set($authorAccountType = '')
223 #set($authorUserRole = '')
224 #set($authorUserStatus = '')
225 #set($authorEnrollmentYear = '')
226 #set($authorGrade = '')
227 #set($authorDisplayName = '')
228 #if($lastAuthorDoc)
229 #set($authorAccountType = $!lastAuthorDoc.getValue('accountType'))
230 #set($authorUserRole = $!lastAuthorDoc.getValue('userRole'))
231 #set($authorUserStatus = $!lastAuthorDoc.getValue('userStatus'))
232 #set($authorEnrollmentYear = $!lastAuthorDoc.getValue('enrollmentYear'))
233 #set($authorDisplayName = $!lastAuthorDoc.getValue('displayName'))
234 #if(!$authorDisplayName || $authorDisplayName == '')
235 ## false引数でプレーンテキスト(HTMLリンクなし)を取得
236 #set($authorDisplayName = $xwiki.getUserName($doc.author, false))
237 #end
238 ## --- 学年の動的計算(学校種別対応) ---
239 ## 日本の学校年度: 4月始まり。currentSchoolYear = (月>=4) ? 今年 : 去年
240 ## 学年 = currentSchoolYear - enrollmentYear + 1
241 ## 在学年数超過: 卒業生として表示
242 #set($authorSchoolCode = $!lastAuthorDoc.getValue('schoolCode'))
243 #if($authorEnrollmentYear && $authorEnrollmentYear != '' && $authorUserRole == 'student')
244 #set($now = $datetool.date)
245 #set($currentYear = $datetool.format('yyyy', $now))
246 #set($currentMonth = $datetool.format('MM', $now))
247 #set($currentYearInt = $mathtool.toInteger($currentYear))
248 #set($currentMonthInt = $mathtool.toInteger($currentMonth))
249 #set($enrollYearInt = $mathtool.toInteger($authorEnrollmentYear))
250 #if($currentMonthInt >= 4)
251 #set($schoolYear = $currentYearInt)
252 #else
253 #set($schoolYear = $mathtool.sub($currentYearInt, 1))
254 #end
255 ## 学校種別から在学年数を判定: C1=中学(3年), C2=義務教育(9年), D1=高校(3年), D2=中等教育(6年)
256 #set($authorMaxYears = 3)
257 #if($authorSchoolCode && $authorSchoolCode.length() >= 2)
258 #set($authorSchoolType = $authorSchoolCode.substring(0, 2))
259 #if($authorSchoolType == 'C2')
260 #set($authorMaxYears = 9)
261 #elseif($authorSchoolType == 'D2')
262 #set($authorMaxYears = 6)
263 #end
264 #end
265 #set($gradeNum = $mathtool.add($mathtool.sub($schoolYear, $enrollYearInt), 1))
266 #if($gradeNum >= 1 && $gradeNum <= $authorMaxYears)
267 #set($authorGrade = "${gradeNum}年生")
268 #elseif($gradeNum > $authorMaxYears)
269 #set($authorGrade = "卒業生")
270 #end
271 #end
272 #end
273
274 ## --- 学校名見出し(XWikiデフォルトタイトルを非表示にし、学校名を表示) ---
275 #if($schoolName && $schoolName != '')
276 <style>.document-header { display: none !important; }</style>
277 <h1 class="school-page-title">$!escapetool.xml($schoolName)</h1>
278 #end
279
280 ## --- 編集ボタン(権限があるユーザーのみ表示) ---
281 #set($canEditSchool = false)
282 #if(!$isGuest && ($isViewerAdmin || $viewerSchoolCode == $schoolCode || $isAffiliated))
283 #set($canEditSchool = true)
284 #end
285 #if($canEditSchool)
286 <div style="text-align:right; margin-bottom:12px;">
287 <a href="$doc.getURL('view', 'sheet=SeitokaiCode.SchoolEditForm')" class="btn-school-edit"><svg class="ico" viewBox="0 0 24 24"><path d="M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"/></svg> 基本情報を編集</a>
288 </div>
289 #end
290
291 ## --- 関連校(中高一貫校)バナー ---
292 #if($affiliatedSchoolCode && $affiliatedSchoolCode != '')
293 #set($affiliatedPageRef = "Schools.${affiliatedSchoolCode}.WebHome")
294 #set($affiliatedPageExists = $xwiki.exists($affiliatedPageRef))
295 <div class="affiliated-school-banner">
296 <svg class="ico" viewBox="0 0 24 24" stroke-width="1.5"><path d="M2 20h20"/><path d="M5 20V10l7-5 7 5v10"/><path d="M9 20v-5h6v5"/></svg>
297 <div>
298 <strong>中高一貫校</strong>:
299 #if($affiliatedPageExists)
300 <a href="$xwiki.getURL($affiliatedPageRef, 'view')">$!escapetool.xml($affiliatedSchoolName)</a>
301 #else
302 $!escapetool.xml($affiliatedSchoolName)
303 #end
304 と連携しています
305 </div>
306 </div>
307 #end
308
309 ## --- ① 学校基本情報 ---
310 <div class="school-info-card collapsed" id="card-basic-info">
311 <h2 role="button" tabindex="0" aria-expanded="false" onclick="toggleInfoCard('card-basic-info')" onkeydown="if(event.key==='Enter'||event.key===' '){event.preventDefault();toggleInfoCard('card-basic-info')}"><span><svg class="ico ico-md" viewBox="0 0 24 24"><path d="M4 19.5A2.5 2.5 0 016.5 17H20"/><path d="M6.5 2H20v20H6.5A2.5 2.5 0 014 19.5v-15A2.5 2.5 0 016.5 2z"/></svg> 学校基本情報</span><span class="collapse-toggle"><span class="collapse-label-open">たたむ</span><span class="collapse-label-closed">開く</span> <span class="collapse-arrow">▼</span></span></h2>
312 <table class="wiki-table school-info-table">
313 <tr><th>学校コード</th><td>$!escapetool.xml($!schoolCode)</td></tr>
314 <tr><th>学校名</th><td>$!escapetool.xml($!schoolName)</td></tr>
315 <tr><th>所在地</th><td>$!escapetool.xml($!prefecture) #if($city && $city != '')$!escapetool.xml($city)#end</td></tr>
316 <tr><th>学級数・生徒数</th><td>#if($classCount && $classCount != '')${classCount}学級#end #if($studentCount && $studentCount != '')/ 約${studentCount}名#end</td></tr>
317 <tr><th>共学・別学</th><td>$!escapetool.xml($!coeducation)</td></tr>
318 <tr><th>設置者</th><td>$!escapetool.xml($!establishment)</td></tr>
319 <tr><th>学校種</th><td>$!escapetool.xml($!schoolLevel)</td></tr>
320 <tr><th>課程</th><td>#if($schoolSystem && !$schoolSystem.isEmpty())#foreach($ss in $schoolSystem)#if($foreach.count > 1) / #end$!escapetool.xml($ss)#end#end</td></tr>
321 <tr><th>公式サイト</th><td>#if($website && $website != '')<a href="$!escapetool.xml($website)" target="_blank" rel="noopener">$!escapetool.xml($website)</a>#else<span class="text-placeholder">未登録</span>#end</td></tr>
322 </table>
323 #set($infoEditDate = $!doc.getValue('lastInfoEditedDate'))
324 #set($infoEditBy = $!doc.getValue('lastInfoEditedBy'))
325 #if($infoEditDate && $infoEditDate != '')
326 <div class="info-last-updated"><svg class="ico" viewBox="0 0 24 24"><path d="M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"/></svg> 基本情報の最終更新: $!escapetool.xml($infoEditBy) — $!escapetool.xml($infoEditDate)</div>
327 #end
328 </div>
329
330 ## --- ② 生徒会基本情報(折りたたみカード) ---
331 <div class="school-info-card" id="card-seitokai-info">
332 <h2 role="button" tabindex="0" aria-expanded="true" onclick="toggleInfoCard('card-seitokai-info')" onkeydown="if(event.key==='Enter'||event.key===' '){event.preventDefault();toggleInfoCard('card-seitokai-info')}"><span><svg class="ico ico-md" viewBox="0 0 24 24"><path d="M3 21h18"/><path d="M5 21V7l7-4 7 4v14"/><path d="M9 21v-4h6v4"/></svg> 生徒会基本情報</span><span class="collapse-toggle"><span class="collapse-label-open">たたむ</span><span class="collapse-label-closed">開く</span> <span class="collapse-arrow">▼</span></span></h2>
333 <div class="seitokai-info-body">
334
335 ## --- 組織図 ---
336 #set($hasOrgContent = ($orgChart && $orgChart != '') || ($orgChartImage && $orgChartImage != ''))
337 #if($hasOrgContent)
338 #set($canViewOrgChart = true)
339 #if($visibilityOrgChart == 'school' && ($isGuest || (!$isViewerAdmin && $viewerSchoolCode != $schoolCode && !$isAffiliated))) #set($canViewOrgChart = false)
340 #elseif($visibilityOrgChart == 'school_trusted' && ($isGuest || (!$isViewerAdmin && (($viewerSchoolCode != $schoolCode && !$isAffiliated) || ($viewerAccountType != 'verified' && $viewerAccountType != 'referred'))))) #set($canViewOrgChart = false)
341 #end
342 #if($canViewOrgChart)
343 <div class="seitokai-subsection">
344 <h3 class="seitokai-subsection-title"><svg class="ico" viewBox="0 0 24 24"><path d="M3 21h18"/><path d="M5 21V7l7-4 7 4v14"/><path d="M9 21v-4h6v4"/><line x1="9" y1="10" x2="9" y2="10.01"/><line x1="15" y1="10" x2="15" y2="10.01"/><line x1="9" y1="14" x2="9" y2="14.01"/><line x1="15" y1="14" x2="15" y2="14.01"/></svg> 組織図 #if($visibilityOrgChart != 'public')<span class="visibility-badge visibility-${visibilityOrgChart}">#if($visibilityOrgChart == 'school_trusted')<svg class="ico" viewBox="0 0 24 24"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg> 校内承認者限定#else<svg class="ico" viewBox="0 0 24 24"><path d="M2 20h20"/><path d="M5 20V10l7-5 7 5v10"/><path d="M9 20v-5h6v5"/></svg> 校内限定#end</span>#end</h3>
345 <div class="seitokai-subsection-content">
346 #if($orgChartImage && $orgChartImage != '')
347 <div class="school-org-img-wrap"><img src="$doc.getAttachmentURL($orgChartImage)" alt="組織図" class="org-chart-img" /></div>
348 #end
349 #if($orgChart && $orgChart != '')$!escapetool.xml($orgChart)#end
350 </div>
351 </div>
352 #else
353 <div class="visibility-restricted-notice"><svg class="ico" viewBox="0 0 24 24"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0110 0v4"/></svg> 組織図は #if($visibilityOrgChart == 'school_trusted')校内の承認済み・紹介メンバー#else校内メンバー#end のみ閲覧可能です</div>
354 #end
355 #end
356
357 ## --- 日常の活動 ---
358 #if($dailyActivities && !$dailyActivities.isEmpty())
359 <div class="seitokai-subsection">
360 <h3 class="seitokai-subsection-title"><svg class="ico" 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> 日常の活動</h3>
361 <div class="seitokai-subsection-content">
362 <p class="activity-hint">活動時間の多い順に上位3つ</p>
363 <div class="tag-container">
364 #set($daIdx = 1)
365 #foreach($da in $dailyActivities)
366 <span class="tag tag-accent">${daIdx}. $!escapetool.xml($da.trim())</span>
367 #set($daIdx = $daIdx + 1)
368 #end
369 </div>
370 #if($dailyActivitiesNote && $dailyActivitiesNote.trim() != '')
371 <div class="free-note">$!escapetool.xml($dailyActivitiesNote)</div>
372 #end
373 </div>
374 </div>
375 #end
376
377 ## --- 選挙 ---
378 #if($electionExists && $electionExists != '')
379 <div class="seitokai-subsection">
380 <h3 class="seitokai-subsection-title"><svg class="ico" viewBox="0 0 24 24"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M7 13l3 3 7-7"/></svg> 選挙</h3>
381 <div class="seitokai-subsection-content">
382 <div class="info-row">
383 <span class="info-label">役員選挙</span>
384 <span class="info-value">$!escapetool.xml($!electionExists)</span>
385 </div>
386 #if($electionType && $electionType != '')
387 <div class="info-row">
388 <span class="info-label">直近の選挙方式</span>
389 <span class="info-value">$!escapetool.xml($!electionType)</span>
390 </div>
391 #end
392 #if($electionNote && $electionNote.trim() != '')
393 <div class="free-note">$!escapetool.xml($electionNote)</div>
394 #end
395 </div>
396 </div>
397 #end
398
399 ## --- 定例活動 ---
400 #if($meetingFrequency && $meetingFrequency != '')
401 <div class="seitokai-subsection">
402 <h3 class="seitokai-subsection-title"><svg class="ico" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="18" rx="2"/><line x1="16" y1="2" x2="16" y2="6"/><line x1="8" y1="2" x2="8" y2="6"/><line x1="3" y1="10" x2="21" y2="10"/></svg> 定例活動</h3>
403 <div class="seitokai-subsection-content">
404 <div class="info-row">
405 <span class="info-label">役員定例会の頻度</span>
406 <span class="info-value">$!escapetool.xml($!meetingFrequency)</span>
407 </div>
408 #if($regularActivitiesNote && $regularActivitiesNote.trim() != '')
409 <div class="free-note">$!escapetool.xml($regularActivitiesNote)</div>
410 #end
411 </div>
412 </div>
413 #end
414
415 ## --- 予算 ---
416 #set($hasBudget = ($budgetProcess && !$budgetProcess.isEmpty()) || ($studentFee && $studentFee != '') || ($budgetScale && $budgetScale != ''))
417 #if($hasBudget)
418 #set($canViewBudget = true)
419 #if($visibilityBudget == 'school' && ($isGuest || (!$isViewerAdmin && $viewerSchoolCode != $schoolCode && !$isAffiliated))) #set($canViewBudget = false)
420 #elseif($visibilityBudget == 'school_trusted' && ($isGuest || (!$isViewerAdmin && (($viewerSchoolCode != $schoolCode && !$isAffiliated) || ($viewerAccountType != 'verified' && $viewerAccountType != 'referred'))))) #set($canViewBudget = false)
421 #end
422 #if($canViewBudget)
423 <div class="seitokai-subsection">
424 <h3 class="seitokai-subsection-title"><svg class="ico" viewBox="0 0 24 24"><line x1="12" y1="1" x2="12" y2="23"/><path d="M17 5H9.5a3.5 3.5 0 000 7h5a3.5 3.5 0 010 7H6"/></svg> 予算 #if($visibilityBudget != 'public')<span class="visibility-badge visibility-${visibilityBudget}">#if($visibilityBudget == 'school_trusted')<svg class="ico" viewBox="0 0 24 24"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg> 校内承認者限定#else<svg class="ico" viewBox="0 0 24 24"><path d="M2 20h20"/><path d="M5 20V10l7-5 7 5v10"/><path d="M9 20v-5h6v5"/></svg> 校内限定#end</span>#end</h3>
425 <div class="seitokai-subsection-content">
426 #if($budgetProcess && !$budgetProcess.isEmpty())
427 <div class="info-row">
428 <span class="info-label">作成過程の生徒関与</span>
429 <span class="info-value">
430 <div class="selection-display">
431 #foreach($bp in $budgetProcess)
432 <span class="selection-item">$!escapetool.xml($bp.trim())</span>
433 #end
434 </div>
435 </span>
436 </div>
437 #end
438 #if($studentFee && $studentFee != '')
439 <div class="info-row">
440 <span class="info-label">生徒会費(年額)</span>
441 <span class="info-value">$!escapetool.xml($!studentFee)</span>
442 </div>
443 #end
444 #if($budgetScale && $budgetScale != '')
445 <div class="info-row">
446 <span class="info-label">予算規模</span>
447 <span class="info-value">$!escapetool.xml($!budgetScale)</span>
448 </div>
449 #end
450 #if($budgetAllocation && !$budgetAllocation.isEmpty())
451 <div class="info-row">
452 <span class="info-label">主な予算配分</span>
453 <span class="info-value">
454 <div class="selection-display">
455 #foreach($ba in $budgetAllocation)
456 <span class="selection-item">$!escapetool.xml($ba.trim())</span>
457 #end
458 </div>
459 </span>
460 </div>
461 #end
462 #if($budgetNote && $budgetNote.trim() != '')
463 <div class="free-note">$!escapetool.xml($budgetNote)</div>
464 #end
465 </div>
466 </div>
467 #else
468 <div class="visibility-restricted-notice"><svg class="ico" viewBox="0 0 24 24"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0110 0v4"/></svg> 予算情報は #if($visibilityBudget == 'school_trusted')校内の承認済み・紹介メンバー#else校内メンバー#end のみ閲覧可能です</div>
469 #end
470 #end
471
472 ## --- 校則の見直し ---
473 #if($ruleReviewStatus && $ruleReviewStatus != '')
474 #set($canViewRuleReview = true)
475 #if($visibilityRuleReview == 'school' && ($isGuest || (!$isViewerAdmin && $viewerSchoolCode != $schoolCode && !$isAffiliated))) #set($canViewRuleReview = false)
476 #elseif($visibilityRuleReview == 'school_trusted' && ($isGuest || (!$isViewerAdmin && (($viewerSchoolCode != $schoolCode && !$isAffiliated) || ($viewerAccountType != 'verified' && $viewerAccountType != 'referred'))))) #set($canViewRuleReview = false)
477 #end
478 #if($canViewRuleReview)
479 <div class="seitokai-subsection">
480 <h3 class="seitokai-subsection-title"><svg class="ico" viewBox="0 0 24 24"><path d="M16 4h2a2 2 0 012 2v12a2 2 0 01-2 2h-2"/><path d="M8 4H6a2 2 0 00-2 2v12a2 2 0 002 2h2"/><line x1="12" y1="4" x2="12" y2="8"/><line x1="12" y1="16" x2="12" y2="20"/><line x1="8" y1="8" x2="16" y2="8"/><line x1="8" y1="16" x2="16" y2="16"/></svg> 校則の見直し #if($visibilityRuleReview != 'public')<span class="visibility-badge visibility-${visibilityRuleReview}">#if($visibilityRuleReview == 'school_trusted')<svg class="ico" viewBox="0 0 24 24"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg> 校内承認者限定#else<svg class="ico" viewBox="0 0 24 24"><path d="M2 20h20"/><path d="M5 20V10l7-5 7 5v10"/><path d="M9 20v-5h6v5"/></svg> 校内限定#end</span>#end</h3>
481 <div class="seitokai-subsection-content">
482 <div class="info-row">
483 <span class="info-label">見直しの有無(3年以内)</span>
484 <span class="info-value"><span class="tag tag-primary tag-sm">$!escapetool.xml($!ruleReviewStatus)</span></span>
485 </div>
486 #if($ruleReviewContent && !$ruleReviewContent.isEmpty())
487 <div class="info-row">
488 <span class="info-label">見直しの内容</span>
489 <span class="info-value">
490 <div class="selection-display">
491 #foreach($rc in $ruleReviewContent)
492 <span class="selection-item">$!escapetool.xml($rc.trim())</span>
493 #end
494 </div>
495 </span>
496 </div>
497 #end
498 #if($ruleReviewProposer && !$ruleReviewProposer.isEmpty())
499 <div class="info-row">
500 <span class="info-label">見直しの提案者</span>
501 <span class="info-value">
502 <div class="selection-display">
503 #foreach($rp in $ruleReviewProposer)
504 <span class="selection-item">$!escapetool.xml($rp.trim())</span>
505 #end
506 </div>
507 </span>
508 </div>
509 #end
510 #if($ruleReviewImplementer && !$ruleReviewImplementer.isEmpty())
511 <div class="info-row">
512 <span class="info-label">見直しの実施者</span>
513 <span class="info-value">
514 <div class="selection-display">
515 #foreach($ri in $ruleReviewImplementer)
516 <span class="selection-item">$!escapetool.xml($ri.trim())</span>
517 #end
518 </div>
519 </span>
520 </div>
521 #end
522 #if($ruleReviewSystem && $ruleReviewSystem != '')
523 <div class="info-row">
524 <span class="info-label">見直しの仕組み</span>
525 <span class="info-value">$!escapetool.xml($!ruleReviewSystem)</span>
526 </div>
527 #end
528 </div>
529 </div>
530 #else
531 <div class="visibility-restricted-notice"><svg class="ico" viewBox="0 0 24 24"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0110 0v4"/></svg> 校則の見直し情報は #if($visibilityRuleReview == 'school_trusted')校内の承認済み・紹介メンバー#else校内メンバー#end のみ閲覧可能です</div>
532 #end
533 #end
534
535 ## --- 生徒会の課題意識 ---
536 #if($challenges && $challenges != '')
537 #set($canViewChallenges = true)
538 #if($visibilityChallenges == 'school' && ($isGuest || (!$isViewerAdmin && $viewerSchoolCode != $schoolCode && !$isAffiliated))) #set($canViewChallenges = false)
539 #elseif($visibilityChallenges == 'school_trusted' && ($isGuest || (!$isViewerAdmin && (($viewerSchoolCode != $schoolCode && !$isAffiliated) || ($viewerAccountType != 'verified' && $viewerAccountType != 'referred'))))) #set($canViewChallenges = false)
540 #end
541 #if($canViewChallenges)
542 <div class="seitokai-subsection">
543 <h3 class="seitokai-subsection-title"><svg class="ico" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg> 生徒会の課題意識 #if($visibilityChallenges != 'public')<span class="visibility-badge visibility-${visibilityChallenges}">#if($visibilityChallenges == 'school_trusted')<svg class="ico" viewBox="0 0 24 24"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg> 校内承認者限定#else<svg class="ico" viewBox="0 0 24 24"><path d="M2 20h20"/><path d="M5 20V10l7-5 7 5v10"/><path d="M9 20v-5h6v5"/></svg> 校内限定#end</span>#end</h3>
544 <div class="seitokai-subsection-content">
545 <div class="challenge-text">$!escapetool.xml($challenges)</div>
546 </div>
547 </div>
548 #else
549 <div class="visibility-restricted-notice"><svg class="ico" viewBox="0 0 24 24"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0110 0v4"/></svg> 課題情報は #if($visibilityChallenges == 'school_trusted')校内の承認済み・紹介メンバー#else校内メンバー#end のみ閲覧可能です</div>
550 #end
551 #end
552
553 </div>## seitokai-info-body 終了
554 </div>## card-seitokai-info 終了
555
556 ## --- ③ SNS・連絡先 ---
557 <div class="school-info-card collapsed" id="card-contact">
558 <h2 role="button" tabindex="0" aria-expanded="false" onclick="toggleInfoCard('card-contact')" onkeydown="if(event.key==='Enter'||event.key===' '){event.preventDefault();toggleInfoCard('card-contact')}"><span><svg class="ico ico-md" viewBox="0 0 24 24"><path d="M22 16.92v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07 19.5 19.5 0 01-6-6 19.79 19.79 0 01-3.07-8.67A2 2 0 014.11 2h3a2 2 0 012 1.72c.127.96.361 1.903.7 2.81a2 2 0 01-.45 2.11L8.09 9.91a16 16 0 006 6l1.27-1.27a2 2 0 012.11-.45c.907.339 1.85.573 2.81.7A2 2 0 0122 16.92z"/></svg> SNS・連絡先</span><span class="collapse-toggle"><span class="collapse-label-open">たたむ</span><span class="collapse-label-closed">開く</span> <span class="collapse-arrow">▼</span></span></h2>
559 <table class="wiki-table school-info-table">
560 <tr><th>問い合わせ先</th><td>#if($contactInfo && $contactInfo != '')$!escapetool.xml($contactInfo)#else<span class="text-placeholder">未登録</span>#end</td></tr>
561 <tr><th>生徒会Web</th><td>#if($seitokaiWebsite && $seitokaiWebsite != '')<a href="$!escapetool.xml($seitokaiWebsite)" target="_blank" rel="noopener"><svg class="ico" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M2 12h20"/><path d="M12 2a15.3 15.3 0 014 10 15.3 15.3 0 01-4 10 15.3 15.3 0 01-4-10 15.3 15.3 0 014-10z"/></svg> $!escapetool.xml($seitokaiWebsite)</a>#else<span class="text-placeholder">未登録</span>#end</td></tr>
562 <tr><th>X (Twitter)</th><td>#if($seitokaiTwitter && $seitokaiTwitter != '')<a href="https://x.com/$!escapetool.url($seitokaiTwitter)" target="_blank" rel="noopener">𝕏 @$!escapetool.xml($seitokaiTwitter)</a>#else<span class="text-placeholder">未登録</span>#end</td></tr>
563 <tr><th>Instagram</th><td>#if($seitokaiInstagram && $seitokaiInstagram != '')<a href="https://instagram.com/$!escapetool.url($seitokaiInstagram)" target="_blank" rel="noopener"><svg class="ico" viewBox="0 0 24 24"><path d="M23 19a2 2 0 01-2 2H3a2 2 0 01-2-2V8a2 2 0 012-2h4l2-3h6l2 3h4a2 2 0 012 2z"/><circle cx="12" cy="13" r="4"/></svg> @$!escapetool.xml($seitokaiInstagram)</a>#else<span class="text-placeholder">未登録</span>#end</td></tr>
564 <tr><th>YouTube</th><td>#if($seitokaiYoutube && $seitokaiYoutube != '')<a href="$!escapetool.xml($seitokaiYoutube)" target="_blank" rel="noopener"><svg class="ico" viewBox="0 0 24 24"><polygon points="5 3 19 12 5 21 5 3"/></svg> YouTubeチャンネル</a>#else<span class="text-placeholder">未登録</span>#end</td></tr>
565 <tr><th>その他SNS</th><td>#if($seitokaiOtherSns && $seitokaiOtherSns != '')$!escapetool.xml($seitokaiOtherSns)#else<span class="text-placeholder">未登録</span>#end</td></tr>
566 </table>
567 </div>
568
569 {{/html}}
570
571 ----
572
573 ## --- ⑩ 活動報告一覧(スレッド型・年度タブ付き) ---
574 = 活動報告 =
575
576 ## --- 年度タブ + 投稿者ステータス凡例 ---
577 {{html clean="false"}}
578
579 ## --- 年度タブ ---
580 ## 全活動から年度一覧を収集
581 #set($activities = $doc.getObjects('SeitokaiCode.ActivityClass'))
582 #set($allPosts = $doc.getObjects('SeitokaiCode.ActivityPostClass'))
583 #set($fySet = [])
584 #if($activities && $activities.size() > 0)
585 #foreach($act in $activities)
586 #set($aFY = $!act.getValue('fiscalYear'))
587 #if($aFY && $aFY != '' && !$fySet.contains($aFY))
588 #set($discard = $fySet.add($aFY))
589 #end
590 #end
591 #end
592 ## 現在の年度が含まれていなければ追加
593 #set($currentFYStr = $currentFiscalYear.toString())
594 #if(!$fySet.contains($currentFYStr))
595 #set($discard = $fySet.add($currentFYStr))
596 #end
597 ## ソート(降順にしたいが Velocity にはないので JS で制御)
598
599 <div class="activity-toolbar">
600 <div class="activity-fy-tabs">
601 <button class="activity-fy-tab active" onclick="switchActivityFY('$currentFYStr', this)">$currentFYStr 年度</button>
602 #foreach($fy in $fySet)
603 #if($fy != $currentFYStr)
604 <button class="activity-fy-tab" onclick="switchActivityFY('$fy', this)">$fy 年度</button>
605 #end
606 #end
607 <button class="activity-fy-tab" onclick="switchActivityFY('all', this)">全期間</button>
608 </div>
609 <div class="activity-toolbar-right">
610 <button class="btn-view-toggle" id="btnViewToggle" onclick="toggleCompactView()" title="タイトルのみ表示">
611 <svg class="ico-list" viewBox="0 0 24 24" stroke="currentColor" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/></svg>
612 <svg class="ico-detail" viewBox="0 0 24 24" stroke="currentColor" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/><rect x="14" y="14" width="7" height="7"/></svg>
613 <span class="toggle-label">一覧表示</span>
614 </button>
615 </div>
616 <div class="author-legend-wrapper">
617 <button class="author-legend-toggle" onclick="this.classList.toggle('open');this.nextElementSibling.classList.toggle('open')"><svg class="ico" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg> バッジの見方 <span class="chevron">▼</span></button>
618 <div class="author-legend-body">
619 <div class="author-legend">
620 <span class="author-legend-title">投稿者の信頼度:</span>
621 <span class="author-legend-item"><span class="bar bar-admin"></span> 管理者 <span class="text-hint">— 運営スタッフ</span></span>
622 <span class="author-legend-item"><span class="bar bar-verified"></span> 承認済み <span class="text-hint">— 本人確認済みのユーザー</span></span>
623 <span class="author-legend-item"><span class="bar bar-referred"></span> 紹介 <span class="text-hint">— 承認済みユーザーからの紹介</span></span>
624 <span class="author-legend-item"><span class="bar bar-general"></span> 一般 <span class="text-hint">— 一般登録ユーザー</span></span>
625 </div>
626 <div class="author-legend">
627 <span class="author-legend-title">所属:</span>
628 <span class="author-legend-item"><span class="badge badge-school-internal-confirmed badge-sm"><svg class="ico" viewBox="0 0 24 24"><path d="M2 20h20"/><path d="M5 20V10l7-5 7 5v10"/><path d="M9 20v-5h6v5"/></svg> 校内(確認済)</span> <span class="text-hint">所属が確認されたこの学校のユーザー</span></span>
629 <span class="author-legend-item"><span class="badge badge-school-internal badge-sm"><svg class="ico" viewBox="0 0 24 24"><path d="M2 20h20"/><path d="M5 20V10l7-5 7 5v10"/><path d="M9 20v-5h6v5"/></svg> 校内</span> <span class="text-hint">この学校に所属登録しているユーザー</span></span>
630 <span class="author-legend-item"><span class="badge badge-school-external badge-sm"><svg class="ico" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M2 12h20"/><path d="M12 2a15.3 15.3 0 014 10 15.3 15.3 0 01-4 10 15.3 15.3 0 01-4-10 15.3 15.3 0 014-10z"/></svg> 他校</span> <span class="text-hint">別の学校に所属しているユーザー</span></span>
631 <span class="author-legend-item text-hint">※一般アカウントは所属バッジが表示されません</span>
632 </div>
633 <div class="author-legend">
634 <span class="author-legend-title">役割:</span>
635 <span class="author-legend-item"><span class="badge badge-role-student badge-sm"><svg class="ico" viewBox="0 0 24 24"><path d="M22 10v6M2 10l10-5 10 5-10 5z"/><path d="M6 12v5c0 2 4 3 6 3s6-1 6-3v-5"/></svg> 生徒</span></span>
636 <span class="author-legend-item"><span class="badge badge-role-officer badge-sm"><svg class="ico" viewBox="0 0 24 24"><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> 役員</span> <span class="text-hint">生徒会役員</span></span>
637 <span class="author-legend-item"><span class="badge badge-role-teacher badge-sm"><svg class="ico" viewBox="0 0 24 24"><path d="M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2"/><circle cx="12" cy="7" r="4"/></svg> 教員</span></span>
638 </div>
639 </div>
640 </div>
641 </div>
642
643 {{/html}}
644
645 ## 特色ある活動を先頭に表示するため、並び替え用リストを作成
646 #set($featuredActivities = [])
647 #set($normalActivities = [])
648 #if($activities && $activities.size() > 0)
649 #foreach($act in $activities)
650 #set($isFeatured = $!act.getValue('featured'))
651 #if($isFeatured == '1')
652 #set($discard = $featuredActivities.add($foreach.index))
653 #else
654 #set($discard = $normalActivities.add($foreach.index))
655 #end
656 #end
657 #end
658 #set($orderedActivityIndices = [])
659 #set($discard = $orderedActivityIndices.addAll($featuredActivities))
660 #set($discard = $orderedActivityIndices.addAll($normalActivities))
661
662 #if($activities && $activities.size() > 0)
663 #foreach($actIdx in $orderedActivityIndices)
664 #set($activity = $activities.get($actIdx))
665 #set($actTitle = $activity.getValue('title'))
666 #set($actCommittee = $activity.getValue('committee'))
667 #set($actPeriod = $activity.getValue('period'))
668 #set($actFY = $!activity.getValue('fiscalYear'))
669 #set($actFeatured = $!activity.getValue('featured'))
670 #if(!$actFY || $actFY == '') #set($actFY = 'unknown') #end
671 ## この活動に紐づく投稿を収集(固定投稿を先頭に)
672 #set($pinnedPosts = [])
673 #set($normalPosts = [])
674 #if($allPosts)
675 #foreach($post in $allPosts)
676 #if($post.getValue('activityIndex') == $actIdx)
677 #set($isPinned = $!post.getValue('pinned'))
678 #if($isPinned == '1')
679 #set($discard = $pinnedPosts.add($post))
680 #else
681 #set($discard = $normalPosts.add($post))
682 #end
683 #end
684 #end
685 #end
686 #set($threadPosts = [])
687 #set($discard = $threadPosts.addAll($pinnedPosts))
688 #set($discard = $threadPosts.addAll($normalPosts))
689 ## report/comment カウント
690 #set($reportCount = 0)
691 #set($commentCount = 0)
692 #foreach($tp in $threadPosts)
693 #set($tpType = $!tp.getValue('postType'))
694 #if($tpType == 'comment')
695 #set($commentCount = $commentCount + 1)
696 #else
697 #set($reportCount = $reportCount + 1)
698 #end
699 #end
700
701 {{html clean="false"}}
702 <div class="activity-thread" data-fiscal-year="$!escapetool.xml($actFY)">
703 <div class="activity-thread-header">
704 <div class="activity-thread-title">
705 <h3 #if($actFeatured == '1')class="featured-title"#end>$!escapetool.xml($!actTitle) #if($actFeatured == '1')<svg class="ico ico-fixed-14 ico-star-offset" 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>#end</h3>
706 <span class="activity-meta">$!escapetool.xml($!actCommittee) | $!escapetool.xml($!actPeriod) #if($actFY != 'unknown')| $!escapetool.xml($actFY)年度#end</span>
707 #set($actTagsList = $activity.getValue('tags'))
708 #if($actTagsList && !$actTagsList.isEmpty())
709 #foreach($tagItem in $actTagsList)
710 #if($tagItem && $tagItem.trim() != '')<span class="activity-tag-badge">$escapetool.xml($tagItem)</span>#end
711 #end
712 #end
713 </div>
714 <div class="thread-meta-row">
715 <span class="thread-post-count">${reportCount}件の報告 ・ ${commentCount}件のコメント</span>
716 #if($viewerAccountType == 'admin' || $viewerAccountType == 'verified' || $viewerAccountType == 'referred')
717 #if($actFeatured == '1')
718 <a href="$doc.getURL('view', "action=unfeature&actObj=${actIdx}&form_token=${services.csrf.getToken()}")" class="btn-featured-toggle btn-unfeature" title="特色ある活動の選定を解除"><svg class="ico ico-fixed-14" 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> 特色解除</a>
719 #else
720 <a href="$doc.getURL('view', "action=feature&actObj=${actIdx}&form_token=${services.csrf.getToken()}")" class="btn-featured-toggle btn-feature" title="特色ある活動に選定(最大3件)"><svg class="ico ico-fixed-14" viewBox="0 0 24 24"><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> 特色設定</a>
721 #end
722 #end
723 </div>
724 </div>
725
726 ## --- 活動報告セクション ---
727 #foreach($post in $threadPosts)
728 #set($thisPostType = $!post.getValue('postType'))
729 #if($thisPostType != 'comment')
730 #set($postContent = $post.getValue('content'))
731 #set($postAuthor = $post.getValue('author'))
732 #set($postAccountType = $!post.getValue('authorAccountType'))
733 #set($postUserRole = $!post.getValue('authorUserRole'))
734 #set($postGrade = $!post.getValue('authorGrade'))
735 #set($postSchoolCode = $!post.getValue('authorSchoolCode'))
736 #set($postDate = $post.getValue('createdDate'))
737 ## 論理削除チェック
738 #set($postDeleted = $!post.getValue('deleted'))
739 #if($postDeleted == 1 || $postDeleted == '1')
740 #if($viewerAccountType == 'admin')
741 <div class="thread-post thread-post-deleted thread-post-admin-deleted">
742 <div class="thread-post-admin-deleted-content">
743 <svg class="ico" viewBox="0 0 24 24"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"/></svg>
744 <strong>投稿者により削除済み</strong>($!post.getValue('deletedAt'))
745 <div class="thread-post-restored-content">$!escapetool.xml($!postContent)</div>
746 </div>
747 </div>
748 #else
749 <div class="thread-post thread-post-deleted thread-post-user-deleted">
750 <div class="thread-post-user-deleted-content">
751 <svg class="ico" viewBox="0 0 24 24"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"/></svg>
752 この投稿は削除されました
753 </div>
754 </div>
755 #end
756 #else
757 ## 通報による非表示チェック
758 #set($postHidden = $!post.getValue('hidden'))
759 #if($postHidden == 1 || $postHidden == '1')
760 #if($viewerAccountType == 'admin')
761 <div class="thread-post thread-post-admin-hidden">
762 <div class="thread-post-admin-hidden-content">
763 <svg class="ico" viewBox="0 0 24 24"><path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>
764 <strong>通報により非表示中</strong>(理由: $!escapetool.xml($!post.getValue('hiddenReason')))
765 <div class="thread-post-restored-content">$!escapetool.xml($!postContent)</div>
766 </div>
767 </div>
768 #end
769 #else
770 ## 投稿の公開範囲チェック
771 #set($postVis = $!post.getValue('visibility'))
772 #if(!$postVis || $postVis == '') #set($postVis = 'public') #end
773 #set($canViewPost = true)
774 #if($postVis == 'school' && ($isGuest || (!$isViewerAdmin && $viewerSchoolCode != $schoolCode && !$isAffiliated))) #set($canViewPost = false)
775 #elseif($postVis == 'school_trusted' && ($isGuest || (!$isViewerAdmin && (($viewerSchoolCode != $schoolCode && !$isAffiliated) || ($viewerAccountType != 'verified' && $viewerAccountType != 'referred'))))) #set($canViewPost = false)
776 #end
777 #if(!$canViewPost)
778 <div class="thread-post visibility-restricted-post">
779 <div class="visibility-restricted-notice"><svg class="ico" viewBox="0 0 24 24"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0110 0v4"/></svg> この投稿は #if($postVis == 'school_trusted')校内の承認済み・紹介メンバー#else校内メンバー#end のみ閲覧可能です</div>
780 </div>
781 #else
782 ## 投稿者のアカウント種別に基づいたCSSクラス
783 #set($postAuthorClass = 'author-general')
784 #if($postAccountType == 'admin')
785 #set($postAuthorClass = 'author-admin')
786 #elseif($postAccountType == 'verified')
787 #set($postAuthorClass = 'author-verified')
788 #elseif($postAccountType == 'referred')
789 #set($postAuthorClass = 'author-referred')
790 #end
791
792 #set($isPinned = $!post.getValue('pinned'))
793 <div class="thread-post $postAuthorClass #if($isPinned == '1')thread-post-pinned#end">
794 <div class="thread-post-sidebar"><div class="thread-post-bar"></div></div>
795 <div class="thread-post-content">
796 <div class="thread-post-header">
797 #if($isPinned == '1')
798 <span class="pin-badge"><svg class="ico ico-fixed-14" viewBox="0 0 24 24" fill="currentColor" stroke="none"><path d="M16 2l-4 4-2-1-5 5 3 3-6 6h4l4-4 3 3 5-5-1-2 4-4-5-5z"/></svg> 固定</span>
799 #end
800 #set($postAuthorRef = $!post.getValue('authorRef'))
801 <span class="thread-post-author">
802 #if($postAuthorRef && $postAuthorRef != '')
803 <a href="$xwiki.getURL('SeitokaiCode.UserProfile', 'view', "user=${escapetool.url($postAuthorRef)}")">$!escapetool.xml($!postAuthor)</a>
804 #else
805 $!escapetool.xml($!postAuthor)
806 #end
807 </span>
808 <span class="author-badge">
809 #if($postAccountType == 'admin')
810 <span class="badge badge-admin badge-sm"><svg class="ico" viewBox="0 0 24 24"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg> 管理者</span>
811 #elseif($postAccountType == 'verified')
812 <span class="badge badge-verified badge-sm"><svg class="ico" viewBox="0 0 24 24" stroke-width="2.5"><path d="M20 6L9 17l-5-5"/></svg> 承認済み</span>
813 #elseif($postAccountType == 'referred')
814 <span class="badge badge-referred badge-sm"><svg class="ico" viewBox="0 0 24 24"><path d="M10 13a5 5 0 007.54.54l3-3a5 5 0 00-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 00-7.54-.54l-3 3a5 5 0 007.07 7.07l1.71-1.71"/></svg> 紹介</span>
815 #else
816 <span class="badge badge-general badge-sm">一般</span>
817 #end
818 ## 所属バッジ(投稿者の学校コードとページの学校コードを比較)
819 #if($postSchoolCode && $postSchoolCode != '' && $postAccountType != 'general')
820 #if($postSchoolCode == $schoolCode || ($affiliatedSchoolCode != '' && $postSchoolCode == $affiliatedSchoolCode))
821 #if($postAccountType == 'verified' || $postAccountType == 'admin')
822 <span class="badge badge-school-internal-confirmed badge-sm"><svg class="ico" viewBox="0 0 24 24"><path d="M2 20h20"/><path d="M5 20V10l7-5 7 5v10"/><path d="M9 20v-5h6v5"/></svg> 校内(確認済)</span>
823 #else
824 <span class="badge badge-school-internal badge-sm"><svg class="ico" viewBox="0 0 24 24"><path d="M2 20h20"/><path d="M5 20V10l7-5 7 5v10"/><path d="M9 20v-5h6v5"/></svg> 校内</span>
825 #end
826 #else
827 <span class="badge badge-school-external badge-sm"><svg class="ico" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M2 12h20"/><path d="M12 2a15.3 15.3 0 014 10 15.3 15.3 0 01-4 10 15.3 15.3 0 01-4-10 15.3 15.3 0 014-10z"/></svg> 他校</span>
828 #end
829 #end
830 #if($postUserRole == 'student')
831 <span class="badge badge-role-student badge-sm"><svg class="ico" viewBox="0 0 24 24"><path d="M22 10l-10-5L2 10l10 5 10-5z"/><path d="M6 12v5c0 1.66 2.69 3 6 3s6-1.34 6-3v-5"/></svg> 生徒</span>
832 #set($postIsOfficer = $!post.getValue('authorIsOfficer'))
833 #if($postIsOfficer == 'true')
834 <span class="badge badge-role-officer badge-sm"><svg class="ico" viewBox="0 0 24 24"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg> 役員</span>
835 #end
836 #elseif($postUserRole == 'teacher')
837 <span class="badge badge-role-teacher badge-sm"><svg class="ico" viewBox="0 0 24 24"><path d="M4 19.5A2.5 2.5 0 016.5 17H20"/><path d="M6.5 2H20v20H6.5A2.5 2.5 0 014 19.5v-15A2.5 2.5 0 016.5 2z"/></svg> 教員</span>
838 #elseif($postUserRole == 'graduate')
839 <span class="badge badge-role-graduate badge-sm"><svg class="ico" viewBox="0 0 24 24"><path d="M22 10l-10-5L2 10l10 5 10-5z"/><path d="M6 12v5c0 1.66 2.69 3 6 3s6-1.34 6-3v-5"/></svg> 卒業生</span>
840 #end
841 </span>
842 <span class="thread-post-date">$!postDate</span>
843 #set($postEdited = $!post.getValue('edited'))
844 #if($postEdited == 1 || $postEdited == '1')
845 <span class="post-edited-label">(編集済み)</span>
846 #end
847 </div>
848 <div class="thread-post-body">
849 $!escapetool.xml($!postContent)
850 #set($postImages = $!post.getValue('images'))
851 #if($postImages && $postImages.trim() != '')
852 <div class="post-images">
853 #set($imageList = $postImages.trim().split("\n"))
854 #set($imageCount = $imageList.size())
855 #if($imageCount > 4)#set($imageCount = 4)#end
856 <div class="post-image-grid post-image-count-${imageCount}">
857 #foreach($imgFile in $imageList)
858 #if($foreach.count <= 4)
859 #set($imgName = $imgFile.trim())
860 #if($imgName != '')
861 <div class="post-image-item">
862 <a href="$doc.getAttachmentURL($imgName)" target="_blank">
863 <img src="$doc.getAttachmentURL($imgName)" alt="$!escapetool.xml($imgName)" loading="lazy"/>
864 </a>
865 </div>
866 #end
867 #end
868 #end
869 </div>
870 </div>
871 #end
872 ## ファイル添付の表示
873 #set($postFiles = $!post.getValue('files'))
874 #if($postFiles && $postFiles.trim() != '')
875 <div class="post-files">
876 #set($fileList = $postFiles.trim().split("\n"))
877 #foreach($attachFile in $fileList)
878 #if($foreach.count <= 2)
879 #set($fName = $attachFile.trim())
880 #if($fName != '')
881 #set($fLower = $fName.toLowerCase())
882 #set($fIcon = 'file')
883 #set($fColor = '#64748b')
884 #if($fLower.endsWith('.pdf'))#set($fIcon = 'pdf')#set($fColor = '#dc2626')#end
885 #if($fLower.endsWith('.docx'))#set($fIcon = 'word')#set($fColor = '#2563eb')#end
886 #if($fLower.endsWith('.xlsx'))#set($fIcon = 'excel')#set($fColor = '#16a34a')#end
887 #if($fLower.endsWith('.pptx'))#set($fIcon = 'ppt')#set($fColor = '#ea580c')#end
888 ## ファイル名からプレフィックス(file_YYYYMMDDHHMMSS_N_)を除去して表示
889 #set($displayName = $fName)
890 #if($fName.matches('file_\d{14}_\d+_.*'))
891 #set($displayName = $fName.replaceFirst('file_\d{14}_\d+_', ''))
892 #end
893 <div class="post-file-item">
894 <a href="$doc.getAttachmentURL($fName)" target="_blank" download="$!escapetool.xml($displayName)">
895 #if($fIcon == 'pdf')<svg class="ico ico-md" style="color:${fColor};" 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"/><path d="M9 15v-2h1.5a1.5 1.5 0 010 3H9"/></svg>
896 #elseif($fIcon == 'word')<svg class="ico ico-md" style="color:${fColor};" 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"/><path d="M8 15l1.5-5 1.5 5 1.5-5 1.5 5"/></svg>
897 #elseif($fIcon == 'excel')<svg class="ico ico-md" style="color:${fColor};" 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="8" y1="13" x2="16" y2="13"/><line x1="8" y1="17" x2="16" y2="17"/><line x1="12" y1="13" x2="12" y2="17"/></svg>
898 #elseif($fIcon == 'ppt')<svg class="ico ico-md" style="color:${fColor};" 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"/><rect x="8" y="12" width="8" height="6" rx="1"/></svg>
899 #else<svg class="ico ico-md" style="color:${fColor};" 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"/></svg>
900 #end
901 <span class="post-file-name">$!escapetool.xml($displayName)</span>
902 </a>
903 </div>
904 #end
905 #end
906 #end
907 </div>
908 #end
909 </div>
910 #if($postVis != 'public')
911 <div class="visibility-badge visibility-${postVis} post-action-mt">#if($postVis == 'school_trusted')<svg class="ico" viewBox="0 0 24 24"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg> 校内承認者限定#else<svg class="ico" viewBox="0 0 24 24"><path d="M2 20h20"/><path d="M5 20V10l7-5 7 5v10"/><path d="M9 20v-5h6v5"/></svg> 校内限定#end</div>
912 #end
913 ## 固定/解除ボタン(承認済み・管理者のみ)
914 #if($viewerAccountType == 'admin' || $viewerAccountType == 'verified')
915 #set($postObjNum = $post.number)
916 <div class="post-pin-action post-action-mt">
917 #if($isPinned == '1')
918 <a href="$doc.getURL('view', "action=unpin&postObj=${postObjNum}&form_token=${services.csrf.getToken()}")" class="btn-pin-toggle btn-unpin" title="固定を解除">
919 <svg class="ico ico-fixed-14" viewBox="0 0 24 24" fill="currentColor" stroke="none"><path d="M16 2l-4 4-2-1-5 5 3 3-6 6h4l4-4 3 3 5-5-1-2 4-4-5-5z"/></svg> 固定を解除
920 </a>
921 #else
922 <a href="$doc.getURL('view', "action=pin&postObj=${postObjNum}&form_token=${services.csrf.getToken()}")" class="btn-pin-toggle btn-pin" title="この投稿を固定">
923 <svg class="ico ico-fixed-14" viewBox="0 0 24 24"><path d="M16 2l-4 4-2-1-5 5 3 3-6 6h4l4-4 3 3 5-5-1-2 4-4-5-5z"/></svg> 固定する
924 </a>
925 #end
926 </div>
927 #end
928 ## 編集・削除ボタン(投稿者本人 or 管理者)
929 #set($postAuthorRef = $!post.getValue('authorRef'))
930 #set($postObjNumED = $post.number)
931 #if($xcontext.user == $postAuthorRef || $viewerAccountType == 'admin')
932 <div class="post-edit-actions post-action-mt">
933 #if($xcontext.user == $postAuthorRef)
934 <button type="button" class="btn-post-edit" onclick="openEditPost(this, '${doc.fullName}', $postObjNumED, '$!escapetool.javascript($!postContent)')" title="この投稿を編集">
935 <svg class="ico ico-fixed-14" viewBox="0 0 24 24"><path d="M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"/></svg> 編集
936 </button>
937 #end
938 <button type="button" class="btn-post-delete" onclick="confirmDeletePost('${doc.fullName}', $postObjNumED, '${services.csrf.getToken()}')" title="この投稿を削除">
939 <svg class="ico ico-fixed-14" viewBox="0 0 24 24"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"/></svg> 削除
940 </button>
941 </div>
942 #end
943 </div>
944 </div>
945 #end## /canViewPost
946 #end## /postHidden
947 #end## /postDeleted
948 #end## /postType != comment
949 #end## /foreach reports
950
951 ## --- コメントセクション(折りたたみ) ---
952 #if($commentCount > 0)
953 <details class="thread-comments-section">
954 <summary class="thread-comments-toggle">
955 <svg class="ico" 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> ${commentCount}件のコメント
956 </summary>
957 #foreach($post in $threadPosts)
958 #set($thisPostType = $!post.getValue('postType'))
959 #if($thisPostType == 'comment')
960 #set($postContent = $post.getValue('content'))
961 #set($postAuthor = $post.getValue('author'))
962 #set($postAccountType = $!post.getValue('authorAccountType'))
963 #set($postDate = $post.getValue('createdDate'))
964 #set($postDeleted = $!post.getValue('deleted'))
965 #if($postDeleted == 1 || $postDeleted == '1')
966 <div class="thread-comment thread-comment-deleted">
967 <span class="thread-comment-meta">このコメントは削除されました</span>
968 </div>
969 #else
970 #set($postHidden = $!post.getValue('hidden'))
971 #if($postHidden == 1 || $postHidden == '1')
972 <div class="thread-comment thread-comment-hidden">
973 <span class="thread-comment-meta">このコメントは非表示にされました</span>
974 </div>
975 #else
976 <div class="thread-comment">
977 <span class="thread-comment-author">$!escapetool.xml($postAuthor)</span>
978 <span class="thread-comment-date">$!postDate</span>
979 <div class="thread-comment-body">$!escapetool.xml($postContent)</div>
980 </div>
981 #end
982 #end
983 #end
984 #end
985 </details>
986 #end
987
988 #if($xcontext.user != "XWiki.XWikiGuest")
989 <div class="thread-add-post">
990 <a href="/bin/SeitokaiCode/ActivityPostForm?schoolPage=${doc.fullName}&activityIndex=${actIdx}&schoolCode=$!escapetool.url($schoolCode)&postType=report" class="btn-thread-add">
991 + 活動報告を追加
992 </a>
993 <a href="/bin/SeitokaiCode/ActivityPostForm?schoolPage=${doc.fullName}&activityIndex=${actIdx}&schoolCode=$!escapetool.url($schoolCode)&postType=comment" class="btn-thread-comment">
994 <svg class="ico" 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> コメントを書く
995 </a>
996 </div>
997 #end
998 </div>
999 {{/html}}
1000 #end
1001 #else
1002 {{html clean="false"}}
1003 <div class="empty-state">
1004 <div class="empty-state-icon"><svg class="ico" viewBox="0 0 24 24" stroke-width="1.5"><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></div>
1005 <div class="empty-state-title">活動報告はまだありません</div>
1006 <div class="empty-state-desc">この学校の活動を記録して、他校と共有しましょう。<br>「活動を追加」ボタンから最初の活動を作成できます。</div>
1007 </div>
1008 {{/html}}
1009 #end
1010
1011 ## --- 活動追加ボタン ---
1012 #if($xcontext.user != "XWiki.XWikiGuest")
1013 {{html clean="false"}}
1014 <div class="activity-add-section">
1015 <a href="/bin/SeitokaiCode/ActivityForm?schoolPage=${doc.fullName}&schoolCode=$!escapetool.url($schoolCode)" class="btn btn-primary btn-add-activity">
1016 <svg class="ico" viewBox="0 0 24 24" stroke-width="2.5"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg> 活動を追加
1017 </a>
1018 </div>
1019 {{/html}}
1020 #end
1021
1022 ## --- 年度タブ切り替え JavaScript ---
1023 {{html clean="false"}}
1024 <script>
1025 // コンパクト表示(タイトルのみ)トグル
1026 function toggleCompactView() {
1027 var container = document.querySelector('.xwiki-content') || document.body;
1028 var isCompact = container.classList.toggle('activity-compact-view');
1029 var btn = document.getElementById('btnViewToggle');
1030 if (btn) {
1031 btn.querySelector('.toggle-label').textContent = isCompact ? '詳細表示' : '一覧表示';
1032 btn.title = isCompact ? '詳細表示に戻す' : 'タイトルのみ表示';
1033 }
1034 // コンパクトモードでは各スレッドヘッダーをクリックで個別展開可能にする
1035 document.querySelectorAll('.activity-thread').forEach(function(thread) {
1036 if (isCompact) {
1037 thread.classList.remove('compact-expanded');
1038 }
1039 });
1040 }
1041
1042 // コンパクトモードで個別スレッドを展開/折りたたみ
1043 function toggleThreadExpand(e) {
1044 var container = document.querySelector('.xwiki-content') || document.body;
1045 if (!container.classList.contains('activity-compact-view')) return;
1046 // リンクやボタンのクリックはスルー
1047 if (e.target.closest('a, button, .btn-featured-toggle')) return;
1048 var thread = e.target.closest('.activity-thread');
1049 if (thread) {
1050 thread.classList.toggle('compact-expanded');
1051 }
1052 }
1053
1054 function switchActivityFY(fy, btn) {
1055 // タブのアクティブ状態を切り替え
1056 document.querySelectorAll('.activity-fy-tab').forEach(function(t) { t.classList.remove('active'); });
1057 btn.classList.add('active');
1058 // 活動スレッドの表示切り替え
1059 document.querySelectorAll('.activity-thread[data-fiscal-year]').forEach(function(thread) {
1060 if (fy === 'all' || thread.getAttribute('data-fiscal-year') === fy) {
1061 thread.classList.remove('fy-hidden');
1062 } else {
1063 thread.classList.add('fy-hidden');
1064 }
1065 });
1066 }
1067 // ページ読み込み時の初期化
1068 document.addEventListener('DOMContentLoaded', function() {
1069 // 年度タブを降順にソート(「全期間」タブは末尾に固定)
1070 var tabContainer = document.querySelector('.activity-fy-tabs');
1071 if (tabContainer) {
1072 var tabs = Array.from(tabContainer.querySelectorAll('.activity-fy-tab'));
1073 var allTab = null;
1074 var fyTabs = [];
1075 tabs.forEach(function(t) {
1076 var onclickStr = t.getAttribute('onclick') || '';
1077 if (onclickStr.indexOf("'all'") !== -1) { allTab = t; }
1078 else { fyTabs.push(t); }
1079 });
1080 // 年度タブを数値の降順でソート
1081 fyTabs.sort(function(a, b) {
1082 var aYear = parseInt(a.textContent) || 0;
1083 var bYear = parseInt(b.textContent) || 0;
1084 return bYear - aYear;
1085 });
1086 // DOM再配置
1087 fyTabs.forEach(function(t) { tabContainer.appendChild(t); });
1088 if (allTab) { tabContainer.appendChild(allTab); }
1089 }
1090 // デフォルトで現在の年度を表示
1091 var defaultTab = document.querySelector('.activity-fy-tab.active');
1092 if (defaultTab) { defaultTab.click(); }
1093 // 保存成功時のトースト通知
1094 if (window.location.search.indexOf('saved=1') !== -1) {
1095 showToast('学校情報を保存しました', 'success');
1096 // URLパラメータをクリーンアップ(リロード時に再表示されないよう)
1097 if (window.history.replaceState) {
1098 window.history.replaceState({}, document.title, window.location.pathname);
1099 }
1100 }
1101 // コンパクトモード: スレッドヘッダークリックで個別展開
1102 document.querySelectorAll('.activity-thread-header').forEach(function(header) {
1103 header.addEventListener('click', toggleThreadExpand);
1104 });
1105 // 長文投稿の折りたたみ初期化(max-height: 12em 超で省略)
1106 document.querySelectorAll('.thread-post-body').forEach(function(body) {
1107 // pre-wrapのまま高さを測定し、max-height(12em ≒ ~200px)を超える場合に折りたたむ
1108 var fullH = body.scrollHeight;
1109 // 12em を px に変換(font-size × line-height × 行数 の近似値ではなくCSSと同じ値を取得)
1110 body.classList.add('truncated');
1111 var maxH = body.clientHeight; // max-height: 12em 適用後の高さ
1112 body.classList.remove('truncated');
1113 if (fullH > maxH + 30) {
1114 body.classList.add('truncated');
1115 var btn = document.createElement('button');
1116 btn.className = 'btn-read-more';
1117 btn.textContent = '広げて読む ▼';
1118 btn.addEventListener('click', function() {
1119 var isExpanded = body.classList.toggle('expanded');
1120 btn.textContent = isExpanded ? '折りたたむ ▲' : '広げて読む ▼';
1121 });
1122 body.parentNode.insertBefore(btn, body.nextSibling);
1123 }
1124 });
1125 });
1126
1127 // トースト通知表示
1128 function showToast(message, type) {
1129 type = type || 'success';
1130 var container = document.getElementById('toast-container');
1131 if (!container) {
1132 container = document.createElement('div');
1133 container.id = 'toast-container';
1134 container.className = 'toast-container';
1135 document.body.appendChild(container);
1136 }
1137 var icons = {
1138 success: '<svg class="ico ico-md" viewBox="0 0 24 24" stroke-width="2.5"><path d="M20 6L9 17l-5-5"/></svg>',
1139 error: '<svg class="ico ico-md" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>'
1140 };
1141 var toast = document.createElement('div');
1142 toast.className = 'toast toast-' + type;
1143 toast.innerHTML = (icons[type] || '') + '<span>' + message + '</span>';
1144 container.appendChild(toast);
1145 setTimeout(function() { toast.remove(); }, 3200);
1146 }
1147
1148 // 学校基本情報・連絡先の折りたたみトグル
1149 function toggleInfoCard(cardId) {
1150 var card = document.getElementById(cardId);
1151 if (!card) return;
1152 card.classList.toggle('collapsed');
1153 var isCollapsed = card.classList.contains('collapsed');
1154 var h2 = card.querySelector('h2[role="button"]');
1155 if (h2) h2.setAttribute('aria-expanded', !isCollapsed);
1156 }
1157
1158 // 投稿の編集(インライン編集フォームを開く)
1159 function openEditPost(btn, schoolPage, postObjNum, currentContent) {
1160 var postEl = btn.closest('.thread-post');
1161 if (!postEl) return;
1162 // 既存の編集フォームがあれば閉じる
1163 var existing = postEl.querySelector('.post-edit-form');
1164 if (existing) { existing.remove(); return; }
1165 var bodyEl = postEl.querySelector('.thread-post-body');
1166 if (!bodyEl) return;
1167 var form = document.createElement('div');
1168 form.className = 'post-edit-form';
1169 form.innerHTML = '<textarea id="editContent_' + postObjNum + '">' + currentContent.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;') + '</textarea>' +
1170 '<div class="post-edit-form-actions">' +
1171 '<button type="button" class="btn-cancel-edit" onclick="this.closest(\'.post-edit-form\').remove()">キャンセル</button>' +
1172 '<button type="button" class="btn-save" onclick="saveEditPost(\'' + schoolPage + '\', ' + postObjNum + ')">保存</button>' +
1173 '</div>';
1174 bodyEl.parentNode.insertBefore(form, bodyEl.nextSibling);
1175 form.querySelector('textarea').focus();
1176 }
1177
1178 // 投稿の編集を保存
1179 function saveEditPost(schoolPage, postObjNum) {
1180 var textarea = document.getElementById('editContent_' + postObjNum);
1181 if (!textarea) return;
1182 var newContent = textarea.value.trim();
1183 if (!newContent) { alert('投稿内容を入力してください'); return; }
1184 var csrfEl = document.querySelector('input[name="form_token"]');
1185 var csrfToken = csrfEl ? csrfEl.value : '';
1186 var xhr = new XMLHttpRequest();
1187 xhr.open('POST', '/bin/get/SeitokaiCode/EditPost?outputSyntax=plain', true);
1188 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1189 var editPostData = 'schoolPage=' + encodeURIComponent(schoolPage) + '&postObj=' + postObjNum + '&newContent=' + encodeURIComponent(newContent) + '&form_token=' + encodeURIComponent(csrfToken);
1190 xhr.onload = function() {
1191 try {
1192 var res = JSON.parse(xhr.responseText);
1193 if (res.success) {
1194 showToast('投稿を更新しました', 'success');
1195 setTimeout(function() { location.reload(); }, 800);
1196 } else {
1197 alert('編集に失敗しました: ' + (res.error || ''));
1198 }
1199 } catch(e) { alert('編集に失敗しました'); }
1200 };
1201 xhr.onerror = function() { alert('通信エラーが発生しました'); };
1202 xhr.send(editPostData);
1203 }
1204
1205 // 投稿の削除(確認ダイアログ付き)
1206 function confirmDeletePost(schoolPage, postObjNum, token) {
1207 if (!confirm('この投稿を削除しますか?\\n削除後は「この投稿は削除されました」と表示されます。')) return;
1208 var xhr = new XMLHttpRequest();
1209 xhr.open('POST', '/bin/get/SeitokaiCode/DeletePost?outputSyntax=plain', true);
1210 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1211 var deletePostData = 'schoolPage=' + encodeURIComponent(schoolPage) + '&postObj=' + postObjNum + '&form_token=' + encodeURIComponent(token);
1212 xhr.onload = function() {
1213 try {
1214 var res = JSON.parse(xhr.responseText);
1215 if (res.success) {
1216 showToast('投稿を削除しました', 'success');
1217 setTimeout(function() { location.reload(); }, 800);
1218 } else {
1219 alert('削除に失敗しました: ' + (res.error || ''));
1220 }
1221 } catch(e) { alert('削除に失敗しました'); }
1222 };
1223 xhr.onerror = function() { alert('通信エラーが発生しました'); };
1224 xhr.send(deletePostData);
1225 }
1226 </script>
1227 {{/html}}
1228 {{/velocity}}