Version 114.1 by Super Admin on 2026/03/27 03:45

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 ## --- OGP メタタグ(SNSシェア対応) ---
11 #set($ogTitle = "$!{schoolName} — 生徒会Wiki")
12 #set($ogDesc = "$!{schoolName}の生徒会活動情報。全国の高校の生徒会活動事例を集積・共有するプラットフォーム。")
13 #set($ogUrl = "https://${request.serverName}${doc.getURL('view')}")
14 <meta property="og:type" content="article" />
15 <meta property="og:title" content="$escapetool.xml($ogTitle)" />
16 <meta property="og:description" content="$escapetool.xml($ogDesc)" />
17 <meta property="og:url" content="$escapetool.xml($ogUrl)" />
18 <meta property="og:site_name" content="生徒会Wiki" />
19 <meta property="og:locale" content="ja_JP" />
20 <meta name="twitter:card" content="summary" />
21 <meta name="twitter:title" content="$escapetool.xml($ogTitle)" />
22 <meta name="twitter:description" content="$escapetool.xml($ogDesc)" />
23 ## メンテナンスバナー({{include}}ではなくインラインで記述し、<p>タグ挿入を回避)
24 #set($bannerDoc = $xwiki.getDocument('SeitokaiAdmin.MaintenanceBanner'))
25 #set($bannerObj = $bannerDoc.getObject('SeitokaiCode.MaintenanceBannerClass'))
26 #if($bannerObj && $bannerObj.getValue('enabled') == 1)
27 #set($bannerMsg = $bannerObj.getValue('message'))
28 #set($bannerLevel = $bannerObj.getValue('level'))
29 #if(!$bannerLevel || $bannerLevel == '')#set($bannerLevel = 'warning')#end
30 <div class="maintenance-banner active maintenance-${bannerLevel}" id="maintenance-banner">
31 <div class="maintenance-banner-inner">
32 <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>
33 <span class="maintenance-text">$!escapetool.xml($bannerMsg)</span>
34 <button class="maintenance-close" onclick="document.getElementById('maintenance-banner').style.display='none'">&times;</button>
35 </div>
36 </div>
37 #end
38 ## --- 学校基本情報フィールド ---
39 #set($schoolCode = $doc.getValue('schoolCode'))
40 #set($schoolName = $doc.getValue('schoolName'))
41 #set($prefecture = $doc.getValue('prefecture'))
42 #set($city = $doc.getValue('city'))
43 #set($classCount = $doc.getValue('classCount'))
44 #set($studentCount = $doc.getValue('studentCount'))
45 #set($coeducation = $doc.getValue('coeducation'))
46 #set($establishment = $doc.getValue('establishment'))
47 #set($schoolLevel = $doc.getValue('schoolLevel'))
48 #set($schoolSystem = $doc.getValue('schoolSystem'))
49 #set($website = $doc.getValue('website'))
50 #set($schoolPhoto = $doc.getValue('schoolPhoto'))
51 #set($schoolDescription = $doc.getValue('schoolDescription'))
52
53 ## --- 生徒会組織 ---
54 #set($orgChart = $doc.getValue('orgChart'))
55 #set($orgChartImage = $doc.getValue('orgChartImage'))
56
57 ## --- 日常の活動・選挙・定例活動 ---
58 #set($dailyActivities = $doc.getValue('dailyActivities'))
59 #set($dailyActivitiesNote = $doc.getValue('dailyActivitiesNote'))
60 #set($electionExists = $doc.getValue('electionExists'))
61 #set($electionType = $doc.getValue('electionType'))
62 #set($electionNote = $doc.getValue('electionNote'))
63 #set($meetingFrequency = $doc.getValue('meetingFrequency'))
64 #set($regularActivitiesNote = $doc.getValue('regularActivitiesNote'))
65
66 ## --- 予算 ---
67 #set($budgetProcess = $doc.getValue('budgetProcess'))
68 #set($studentFee = $doc.getValue('studentFee'))
69 #set($budgetScale = $doc.getValue('budgetScale'))
70 #set($budgetAllocation = $doc.getValue('budgetAllocation'))
71 #set($budgetNote = $doc.getValue('budgetNote'))
72
73 ## --- 校則・生徒会会則の見直し ---
74 #set($ruleReviewStatus = $doc.getValue('ruleReviewStatus'))
75 #set($ruleReviewContent = $doc.getValue('ruleReviewContent'))
76 #set($ruleReviewProposer = $doc.getValue('ruleReviewProposer'))
77 #set($ruleReviewImplementer = $doc.getValue('ruleReviewImplementer'))
78 #set($ruleReviewSystem = $doc.getValue('ruleReviewSystem'))
79
80 ## --- 活動環境 ---
81 #set($activityPlace = $doc.getValue('activityPlace'))
82 #set($activityRoomEquipment = $doc.getValue('activityRoomEquipment'))
83 #set($activityRoomImage = $doc.getValue('activityRoomImage'))
84 #set($ictTools = $doc.getValue('ictTools'))
85 #set($ictUsage = $doc.getValue('ictUsage'))
86
87 ## --- 生徒総会 ---
88 #set($assemblyFormat = $doc.getValue('assemblyFormat'))
89 #set($assemblyCount = $doc.getValue('assemblyCount'))
90 #set($assemblyAgenda = $doc.getValue('assemblyAgenda'))
91 #set($assemblyTopics = $doc.getValue('assemblyTopics'))
92 #set($assemblyNote = $doc.getValue('assemblyNote'))
93
94 ## --- 広報 ---
95 #set($publicityMethod = $doc.getValue('publicityMethod'))
96 #set($publicityFrequency = $doc.getValue('publicityFrequency'))
97 #set($publicityNote = $doc.getValue('publicityNote'))
98
99 ## --- 外部連携 ---
100 #set($externalCooperation = $doc.getValue('externalCooperation'))
101 #set($externalOrgName = $doc.getValue('externalOrgName'))
102 #set($socialParticipation = $doc.getValue('socialParticipation'))
103
104 ## --- 年間主要行事 ---
105 #set($eventApril = $doc.getValue('eventApril'))
106 #set($eventMay = $doc.getValue('eventMay'))
107 #set($eventJune = $doc.getValue('eventJune'))
108 #set($eventJuly = $doc.getValue('eventJuly'))
109 #set($eventAugust = $doc.getValue('eventAugust'))
110 #set($eventSeptember = $doc.getValue('eventSeptember'))
111 #set($eventOctober = $doc.getValue('eventOctober'))
112 #set($eventNovember = $doc.getValue('eventNovember'))
113 #set($eventDecember = $doc.getValue('eventDecember'))
114 #set($eventJanuary = $doc.getValue('eventJanuary'))
115 #set($eventFebruary = $doc.getValue('eventFebruary'))
116 #set($eventMarch = $doc.getValue('eventMarch'))
117
118 ## --- 課題・連絡先 ---
119 #set($challenges = $doc.getValue('challenges'))
120 #set($contactInfo = $doc.getValue('contactInfo'))
121 #set($seitokaiWebsite = $doc.getValue('seitokaiWebsite'))
122 #set($seitokaiTwitter = $doc.getValue('seitokaiTwitter'))
123 #set($seitokaiInstagram = $doc.getValue('seitokaiInstagram'))
124 #set($seitokaiYoutube = $doc.getValue('seitokaiYoutube'))
125 #set($seitokaiOtherSns = $doc.getValue('seitokaiOtherSns'))
126
127 ## --- 現在の年度を計算(4月始まり) ---
128 #set($nowFY = $datetool.date)
129 #set($currentFYMonth = $mathtool.toInteger($datetool.format('MM', $nowFY)))
130 #set($currentFYYear = $mathtool.toInteger($datetool.format('yyyy', $nowFY)))
131 #if($currentFYMonth >= 4)
132 #set($currentFiscalYear = $currentFYYear)
133 #else
134 #set($currentFiscalYear = $mathtool.sub($currentFYYear, 1))
135 #end
136
137 ## --- 公開範囲フィールド ---
138 #set($visibilityOrgChart = $!doc.getValue('visibilityOrgChart'))
139 #set($visibilityBudget = $!doc.getValue('visibilityBudget'))
140 #set($visibilityRuleReview = $!doc.getValue('visibilityRuleReview'))
141 #set($visibilityChallenges = $!doc.getValue('visibilityChallenges'))
142 #set($visibilityDailyActivities = $!doc.getValue('visibilityDailyActivities'))
143 #set($visibilityElection = $!doc.getValue('visibilityElection'))
144 #set($visibilityMeeting = $!doc.getValue('visibilityMeeting'))
145 #set($visibilityActivityEnv = $!doc.getValue('visibilityActivityEnv'))
146 #set($visibilityAssembly = $!doc.getValue('visibilityAssembly'))
147 #set($visibilityPublicity = $!doc.getValue('visibilityPublicity'))
148 #set($visibilityExternal = $!doc.getValue('visibilityExternal'))
149 #set($visibilityAnnualEvents = $!doc.getValue('visibilityAnnualEvents'))
150 ## デフォルト値(未設定なら全体公開)
151 #if(!$visibilityOrgChart || $visibilityOrgChart == '') #set($visibilityOrgChart = 'public') #end
152 #if(!$visibilityBudget || $visibilityBudget == '') #set($visibilityBudget = 'public') #end
153 #if(!$visibilityRuleReview || $visibilityRuleReview == '') #set($visibilityRuleReview = 'public') #end
154 #if(!$visibilityChallenges || $visibilityChallenges == '') #set($visibilityChallenges = 'public') #end
155
156 ## --- 閲覧者情報(公開範囲チェック用) ---
157 #set($viewerUser = $xcontext.user)
158 #set($isGuest = $viewerUser == 'XWiki.XWikiGuest')
159 #set($isViewerAdmin = false)
160 #set($viewerSchoolCode = '')
161 #set($viewerSecondaryGraduated = false)
162 #if(!$isGuest)
163 #set($viewerDoc = $xwiki.getDocument($viewerUser))
164 #set($viewerAccountType = $!viewerDoc.getValue('accountType'))
165 #set($viewerSchoolCode = $!viewerDoc.getValue('schoolCode'))
166 #set($viewerSecondarySchoolCode = $!viewerDoc.getValue('secondarySchoolCode'))
167 #set($viewerUserRole = $!viewerDoc.getValue('userRole'))
168 #if($viewerAccountType == 'admin')
169 #set($isViewerAdmin = true)
170 #end
171 ## 第2所属校の在学年数超過チェック
172 #set($viewerSecEnrollYear = $!viewerDoc.getValue('secondaryEnrollmentYear'))
173 #if($viewerSecondarySchoolCode && $viewerSecondarySchoolCode != '' && $viewerSecEnrollYear && $viewerSecEnrollYear != '')
174 #set($vNow = $datetool.date)
175 #set($vCurYear = $mathtool.toInteger($datetool.format('yyyy', $vNow)))
176 #set($vCurMonth = $mathtool.toInteger($datetool.format('MM', $vNow)))
177 #if($vCurMonth >= 4)#set($vSchoolYear = $vCurYear)#else#set($vSchoolYear = $mathtool.sub($vCurYear, 1))#end
178 #set($vSecEnroll = $mathtool.toInteger($viewerSecEnrollYear))
179 #set($vSecMax = 3)
180 #if($viewerSecondarySchoolCode.length() >= 2)
181 #set($vSecType = $viewerSecondarySchoolCode.substring(0, 2))
182 #if($vSecType == 'C2')#set($vSecMax = 9)#elseif($vSecType == 'D2')#set($vSecMax = 6)#end
183 #end
184 #set($vSecGrade = $mathtool.add($mathtool.sub($vSchoolYear, $vSecEnroll), 1))
185 #if($vSecGrade > $vSecMax)
186 #set($viewerSecondaryGraduated = true)
187 #end
188 #end
189 #end
190
191 ## --- 関連校(中高一貫校)情報 ---
192 #set($affiliatedSchoolCode = $!doc.getValue('affiliatedSchoolCode'))
193 #set($affiliatedSchoolName = $!doc.getValue('affiliatedSchoolName'))
194 #set($isAffiliated = false)
195 #if($affiliatedSchoolCode && $affiliatedSchoolCode != '')
196 #if($viewerSchoolCode == $affiliatedSchoolCode)
197 #set($isAffiliated = true)
198 #elseif($viewerSecondarySchoolCode && $viewerSecondarySchoolCode != '' && $viewerSecondarySchoolCode == $affiliatedSchoolCode && !$viewerSecondaryGraduated)
199 #set($isAffiliated = true)
200 #end
201 #end
202
203 ## --- 校内判定(卒業生を除外、secondarySchoolCodeも含む) ---
204 #set($isSchoolMember = false)
205 #if(!$isGuest && $viewerUserRole != 'graduate')
206 #if($viewerSchoolCode == $schoolCode || $isAffiliated)
207 #set($isSchoolMember = true)
208 #elseif($viewerSecondarySchoolCode && $viewerSecondarySchoolCode != '' && $viewerSecondarySchoolCode == $schoolCode && !$viewerSecondaryGraduated)
209 #set($isSchoolMember = true)
210 #end
211 #end
212 ## 卒業生の母校判定(投稿バッジ用)
213 #set($isAlumniOfSchool = false)
214 #if(!$isGuest && $viewerUserRole == 'graduate')
215 #if($viewerSchoolCode == $schoolCode || ($affiliatedSchoolCode != '' && $viewerSchoolCode == $affiliatedSchoolCode))
216 #set($isAlumniOfSchool = true)
217 #end
218 #end
219
220 ## --- 学校ページ非表示チェック ---
221 #set($schoolHidden = $doc.getValue('hidden'))
222 #if($schoolHidden == 1)
223 #if($isViewerAdmin)
224 ## 管理者: 黄色バナー + ページ内容は通常表示(プレビュー)
225 <div class="school-hidden-banner admin">
226 <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>
227 <div>
228 <strong>このページは非表示になっています</strong>(管理者のみ閲覧可能)
229 #set($hBy = $!doc.getValue('hiddenBy'))
230 #set($hAt = $!doc.getValue('hiddenAt'))
231 #set($hReason = $!doc.getValue('hiddenReason'))
232 <div class="school-hidden-detail">
233 非表示: $!escapetool.xml($hAt) / $!escapetool.xml($hBy)
234 #if($hReason && $hReason != '') ・ 理由: $!escapetool.xml($hReason)#end
235 </div>
236 <a href="$xwiki.getURL('SeitokaiAdmin.SchoolManagement', 'view')" style="color:#92400e;text-decoration:underline">学校ページ管理へ</a>
237 </div>
238 </div>
239 #else
240 ## 一般ユーザー・ゲスト: 非公開メッセージを表示して停止
241 <div class="school-hidden-public">
242 <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>
243 <h2>このページは現在公開されていません</h2>
244 <p>このページは管理者により非公開に設定されています。</p>
245 <a href="$xwiki.getURL('Schools.WebHome', 'view')" class="btn-back-list">学校一覧に戻る</a>
246 </div>
247 #stop
248 #end
249 #end
250
251 ## --- 投稿固定/解除処理 ---
252 #set($pinAction = $!request.action)
253 #if(($pinAction == 'pin' || $pinAction == 'unpin') && ($viewerAccountType == 'admin' || ($viewerAccountType == 'verified' && $isSchoolMember)) && $services.csrf.isTokenValid($request.form_token))
254 #set($pinPostObjStr = $!request.postObj)
255 #if(!$pinPostObjStr.matches('^\d+$'))
256 ## 不正な値 → 無視
257 #else
258 #set($postObjNum = $mathtool.toInteger($pinPostObjStr))
259 #set($postObj = $doc.getObject('SeitokaiCode.ActivityPostClass', $postObjNum))
260 #if($postObj)
261 #if($pinAction == 'pin')
262 $postObj.set('pinned', '1')
263 #set($pinnerDoc = $xwiki.getDocument($xcontext.user))
264 #set($pinnerName = $!pinnerDoc.getValue('displayName'))
265 #if(!$pinnerName || $pinnerName == '')#set($pinnerName = $xwiki.getUserName($xcontext.user))#end
266 $postObj.set('pinnedBy', $pinnerName)
267 $postObj.set('pinnedDate', $datetool.format('yyyy/MM/dd HH:mm', $datetool.date))
268 $doc.saveWithProgrammingRights('投稿を固定')
269 #else
270 $postObj.set('pinned', '')
271 $postObj.set('pinnedBy', '')
272 $postObj.set('pinnedDate', '')
273 $doc.saveWithProgrammingRights('投稿の固定を解除')
274 #end
275 $response.sendRedirect($doc.getURL('view'))
276 #stop
277 #end
278 #end## /matches
279 #end
280
281 ## --- 特色ある活動 選定/解除処理 ---
282 #set($featAction = $!request.action)
283 #if(($featAction == 'feature' || $featAction == 'unfeature') && ($viewerAccountType == 'admin' || (($viewerAccountType == 'verified' || $viewerAccountType == 'referred') && $isSchoolMember)) && $services.csrf.isTokenValid($request.form_token))
284 #set($featActObjStr = $!request.actObj)
285 #if($featActObjStr.matches('^\d+$'))
286 #set($actObjNum = $mathtool.toInteger($featActObjStr))
287 #set($actObj = $doc.getObject('SeitokaiCode.ActivityClass', $actObjNum))
288 #if($actObj)
289 #if($featAction == 'feature')
290 ## 上限3件チェック
291 #set($allActs = $doc.getObjects('SeitokaiCode.ActivityClass'))
292 #set($featCount = 0)
293 #if($allActs)
294 #foreach($fa in $allActs)
295 #if($!fa.getValue('featured') == '1')
296 #set($featCount = $featCount + 1)
297 #end
298 #end
299 #end
300 #if($featCount < 3)
301 $actObj.set('featured', '1')
302 #set($featurerDoc = $xwiki.getDocument($xcontext.user))
303 #set($featurerName = $!featurerDoc.getValue('displayName'))
304 #if(!$featurerName || $featurerName == '')#set($featurerName = $xwiki.getUserName($xcontext.user))#end
305 $actObj.set('featuredBy', $featurerName)
306 $actObj.set('featuredDate', $datetool.format('yyyy/MM/dd HH:mm', $datetool.date))
307 $doc.saveWithProgrammingRights('特色ある活動に選定')
308 #end
309 #else
310 $actObj.set('featured', '')
311 $actObj.set('featuredBy', '')
312 $actObj.set('featuredDate', '')
313 $doc.saveWithProgrammingRights('特色ある活動の選定を解除')
314 #end
315 $response.sendRedirect($doc.getURL('view'))
316 #stop
317 #end
318 #end## /matches
319 #end
320
321 ## --- ユーザー情報取得 ---
322 ## displayName: Wiki上の表示名(ニックネーム)。本名(firstName/lastName)は管理者のみ閲覧可能。
323 #set($lastAuthor = $doc.author)
324 #set($lastAuthorDoc = $xwiki.getDocument($lastAuthor))
325 #set($authorAccountType = '')
326 #set($authorUserRole = '')
327 #set($authorUserStatus = '')
328 #set($authorEnrollmentYear = '')
329 #set($authorGrade = '')
330 #set($authorDisplayName = '')
331 #if($lastAuthorDoc)
332 #set($authorAccountType = $!lastAuthorDoc.getValue('accountType'))
333 #set($authorUserRole = $!lastAuthorDoc.getValue('userRole'))
334 #set($authorUserStatus = $!lastAuthorDoc.getValue('userStatus'))
335 #set($authorEnrollmentYear = $!lastAuthorDoc.getValue('enrollmentYear'))
336 #set($authorDisplayName = $!lastAuthorDoc.getValue('displayName'))
337 #if(!$authorDisplayName || $authorDisplayName == '')
338 ## false引数でプレーンテキスト(HTMLリンクなし)を取得
339 #set($authorDisplayName = $xwiki.getUserName($doc.author, false))
340 #end
341 ## --- 学年の動的計算(学校種別対応) ---
342 ## 日本の学校年度: 4月始まり。currentSchoolYear = (月>=4) ? 今年 : 去年
343 ## 学年 = currentSchoolYear - enrollmentYear + 1
344 ## 在学年数超過: 卒業生として表示
345 #set($authorSchoolCode = $!lastAuthorDoc.getValue('schoolCode'))
346 #if($authorEnrollmentYear && $authorEnrollmentYear != '' && $authorUserRole == 'student')
347 #set($now = $datetool.date)
348 #set($currentYear = $datetool.format('yyyy', $now))
349 #set($currentMonth = $datetool.format('MM', $now))
350 #set($currentYearInt = $mathtool.toInteger($currentYear))
351 #set($currentMonthInt = $mathtool.toInteger($currentMonth))
352 #set($enrollYearInt = $mathtool.toInteger($authorEnrollmentYear))
353 #if($currentMonthInt >= 4)
354 #set($schoolYear = $currentYearInt)
355 #else
356 #set($schoolYear = $mathtool.sub($currentYearInt, 1))
357 #end
358 ## 学校種別から在学年数を判定: C1=中学(3年), C2=義務教育(9年), D1=高校(3年), D2=中等教育(6年)
359 #set($authorMaxYears = 3)
360 #if($authorSchoolCode && $authorSchoolCode.length() >= 2)
361 #set($authorSchoolType = $authorSchoolCode.substring(0, 2))
362 #if($authorSchoolType == 'C2')
363 #set($authorMaxYears = 9)
364 #elseif($authorSchoolType == 'D2')
365 #set($authorMaxYears = 6)
366 #end
367 #end
368 #set($gradeNum = $mathtool.add($mathtool.sub($schoolYear, $enrollYearInt), 1))
369 #if($gradeNum >= 1 && $gradeNum <= $authorMaxYears)
370 #set($authorGrade = "${gradeNum}年生")
371 #elseif($gradeNum > $authorMaxYears)
372 #set($authorGrade = "卒業生")
373 #end
374 #end
375 #end
376
377 ## --- 学校名見出し(XWikiデフォルトタイトルを非表示にし、学校名を表示) ---
378 #if($schoolName && $schoolName != '')
379 <style>.document-header { display: none !important; }</style>
380 <h1 class="school-page-title">$!escapetool.xml($schoolName)</h1>
381 #end
382
383 ## --- 編集ボタン(権限があるユーザーのみ表示) ---
384 #set($canEditSchool = false)
385 #if(!$isGuest && ($isViewerAdmin || $isSchoolMember || $isAlumniOfSchool))
386 #set($canEditSchool = true)
387 #end
388 #if($canEditSchool)
389 <div style="text-align:right; margin-bottom:12px;">
390 <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>
391 </div>
392 #end
393
394 ## --- 関連校(中高一貫校)バナー ---
395 #if($affiliatedSchoolCode && $affiliatedSchoolCode != '')
396 #set($affiliatedPageRef = "Schools.${affiliatedSchoolCode}.WebHome")
397 #set($affiliatedPageExists = $xwiki.exists($affiliatedPageRef))
398 <div class="affiliated-school-banner">
399 <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>
400 <div>
401 <strong>中高一貫校</strong>:
402 #if($affiliatedPageExists)
403 <a href="$xwiki.getURL($affiliatedPageRef, 'view')">$!escapetool.xml($affiliatedSchoolName)</a>
404 #else
405 $!escapetool.xml($affiliatedSchoolName)
406 #end
407 と連携しています
408 </div>
409 </div>
410 #end
411
412 ## --- ① 学校基本情報 ---
413 <div class="school-info-card collapsed" id="card-basic-info">
414 <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>
415 <div class="school-basic-info-layout">
416 <div class="school-basic-info-table">
417 <table class="wiki-table school-info-table">
418 <tr><th>学校コード</th><td>$!escapetool.xml($!schoolCode)</td></tr>
419 <tr><th>学校名</th><td>$!escapetool.xml($!schoolName)</td></tr>
420 <tr><th>所在地</th><td>$!escapetool.xml($!prefecture) #if($city && $city != '')$!escapetool.xml($city)#end</td></tr>
421 <tr><th>学級数・生徒数</th><td>#if($classCount && $classCount != '')${classCount}学級#end #if($studentCount && $studentCount != '')/ 約${studentCount}名#end</td></tr>
422 <tr><th>共学・別学</th><td>$!escapetool.xml($!coeducation)</td></tr>
423 <tr><th>設置者</th><td>$!escapetool.xml($!establishment)</td></tr>
424 <tr><th>学校種</th><td>$!escapetool.xml($!schoolLevel)</td></tr>
425 <tr><th>課程</th><td>#if($schoolSystem && !$schoolSystem.isEmpty())#foreach($ss in $schoolSystem)#if($foreach.count > 1) / #end$!escapetool.xml($ss)#end#end</td></tr>
426 <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>
427 </table>
428 </div>
429 #if($schoolPhoto && $schoolPhoto != '')
430 <div class="school-photo-area">
431 <img src="$doc.getAttachmentURL($schoolPhoto)" alt="$!escapetool.xml($schoolName)" class="school-photo" />
432 </div>
433 #end
434 </div>
435 #if($schoolDescription && $schoolDescription.trim() != '')
436 <div class="free-note" style="margin-top:var(--sp-4);">$!escapetool.xml($schoolDescription)</div>
437 #end
438
439 </div>
440
441 ## --- ② 生徒会情報(折りたたみカード) ---
442 <div class="school-info-card" id="card-seitokai-info">
443 <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>
444 <div class="seitokai-info-body">
445
446 ## --- 生徒会組織 ---
447 #set($hasOrgContent = ($orgChart && $orgChart != '') || ($orgChartImage && $orgChartImage != ''))
448 #if($hasOrgContent)
449 #set($canViewOrgChart = true)
450 #if($visibilityOrgChart == 'school' && ($isGuest || (!$isViewerAdmin && !$isSchoolMember))) #set($canViewOrgChart = false)
451 #elseif($visibilityOrgChart == 'school_trusted' && ($isGuest || (!$isViewerAdmin && ((!$isSchoolMember) || ($viewerAccountType != 'verified' && $viewerAccountType != 'referred'))))) #set($canViewOrgChart = false)
452 #end
453 #if($canViewOrgChart)
454 <div class="seitokai-subsection">
455 <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>
456 <div class="seitokai-subsection-content">
457 #if($orgChartImage && $orgChartImage != '')
458 <div class="school-org-img-wrap"><img src="$doc.getAttachmentURL($orgChartImage)" alt="組織図" class="org-chart-img" /></div>
459 #end
460 #if($orgChart && $orgChart != '')<div class="free-note">$!escapetool.xml($orgChart)</div>#end
461 </div>
462 </div>
463 #else
464 <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>
465 #end
466 #end
467
468 ## --- 活動環境 ---
469 #set($hasActivityEnv = ($activityPlace && !$activityPlace.isEmpty()) || ($activityRoomEquipment && $activityRoomEquipment != '') || ($activityRoomImage && $activityRoomImage != '') || ($ictTools && !$ictTools.isEmpty()) || ($ictUsage && !$ictUsage.isEmpty()))
470 #if($hasActivityEnv)
471 #set($canViewAE = true)
472 #if($visibilityActivityEnv == 'school' && ($isGuest || (!$isViewerAdmin && !$isSchoolMember))) #set($canViewAE = false)
473 #elseif($visibilityActivityEnv == 'school_trusted' && ($isGuest || (!$isViewerAdmin && ((!$isSchoolMember) || ($viewerAccountType != 'verified' && $viewerAccountType != 'referred'))))) #set($canViewAE = false)
474 #end
475 #if($canViewAE)
476 <div class="seitokai-subsection">
477 <h3 class="seitokai-subsection-title"><svg class="ico" viewBox="0 0 24 24"><path d="M3 9l9-7 9 7v11a2 2 0 01-2 2H5a2 2 0 01-2-2z"/><polyline points="9 22 9 12 15 12 15 22"/></svg> 生徒会の活動環境 #if($visibilityActivityEnv != '' && $visibilityActivityEnv != 'public')<span class="visibility-badge visibility-${visibilityActivityEnv}">#if($visibilityActivityEnv == '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>
478 <div class="seitokai-subsection-content">
479 #if($activityPlace && !$activityPlace.isEmpty())
480 <div class="info-row">
481 <span class="info-label">普段の活動場所</span>
482 <span class="info-value">
483 <div class="selection-display">
484 #foreach($ap in $activityPlace)
485 <span class="selection-item">$!escapetool.xml($ap.trim())</span>
486 #end
487 </div>
488 </span>
489 </div>
490 #end
491 #if($activityRoomEquipment && $activityRoomEquipment != '')
492 <div class="info-row">
493 <span class="info-label">生徒会室の設備</span>
494 <span class="info-value free-text-value">$!escapetool.xml($activityRoomEquipment)</span>
495 </div>
496 #end
497 #if($activityRoomImage && $activityRoomImage != '')
498 <div class="info-row">
499 <span class="info-label">活動場所の写真</span>
500 <span class="info-value"><div class="school-org-img-wrap"><img src="$doc.getAttachmentURL($activityRoomImage)" alt="活動場所の写真" class="org-chart-img" /></div></span>
501 </div>
502 #end
503 #if($ictTools && !$ictTools.isEmpty())
504 <div class="info-row">
505 <span class="info-label">利用しているICTツール</span>
506 <span class="info-value">
507 #set($ictCatDisplay = [
508 ["連絡ツール", ["メール","LINE","LINE WORKS","Discord","Slack","Microsoft Teams","Google Chat","InstagramのDM","XのDM","その他(連絡)"]],
509 ["ドキュメント作成・共有", ["Googleドキュメント","Googleスプレッドシート","Googleスライド","Googleドライブ","Word","Excel","PowerPoint","OneDrive","SharePoint","Notion","Pages","Numbers","Keynote","Dropbox","Box","その他(ドキュメント)"]],
510 ["タスク管理", ["Googleカレンダー","Google ToDoリスト","Trello","Asana","Excel等スプレッドシート","その他(タスク管理)"]],
511 ["ビデオ会議ツール", ["Zoom","Google Meet","その他(ビデオ会議)"]],
512 ["アンケート", ["Googleフォーム","Microsoft Forms","その他(アンケート)"]],
513 ["デザイン・クリエイティブ", ["Canva","各種Adobe","CapCut","LumaFusion","AviUtl","ibisPaint","その他(デザイン)"]],
514 ["その他", ["独自のWebシステム・自作アプリ"]]
515 ])
516 #foreach($catD in $ictCatDisplay)
517 #set($catHasItems = false)
518 #foreach($t in $catD.get(1))
519 #if($ictTools.contains($t)) #set($catHasItems = true) #end
520 #end
521 #if($catHasItems)
522 <div style="margin-bottom:6px">
523 <span style="font-size:0.8em;font-weight:600;color:var(--text-mid)">$catD.get(0):</span>
524 <div class="selection-display" style="margin-top:2px">
525 #foreach($t in $catD.get(1))
526 #if($ictTools.contains($t))
527 <span class="selection-item">$!escapetool.xml($t)</span>
528 #end
529 #end
530 </div>
531 </div>
532 #end
533 #end
534 </span>
535 </div>
536 #end
537 #if($ictUsage && !$ictUsage.isEmpty())
538 <div class="info-row">
539 <span class="info-label">ICT活用している場面</span>
540 <span class="info-value">
541 <div class="selection-display">
542 #foreach($iu in $ictUsage)
543 <span class="selection-item">$!escapetool.xml($iu.trim())</span>
544 #end
545 </div>
546 </span>
547 </div>
548 #end
549 </div>
550 </div>
551 #else
552 <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($visibilityActivityEnv == 'school_trusted')校内の承認済み・紹介メンバー#else校内メンバー#end のみ閲覧可能です</div>
553 #end
554 #end
555
556 ## --- 年間主要行事 ---
557 #set($months = [["4月", $eventApril], ["5月", $eventMay], ["6月", $eventJune], ["7月", $eventJuly], ["8月", $eventAugust], ["9月", $eventSeptember], ["10月", $eventOctober], ["11月", $eventNovember], ["12月", $eventDecember], ["1月", $eventJanuary], ["2月", $eventFebruary], ["3月", $eventMarch]])
558 #set($hasAnyEvent = false)
559 #foreach($m in $months)
560 #if($m.get(1) && $m.get(1) != '') #set($hasAnyEvent = true) #end
561 #end
562 #if($hasAnyEvent)
563 #set($canViewAN = true)
564 #if($visibilityAnnualEvents == 'school' && ($isGuest || (!$isViewerAdmin && !$isSchoolMember))) #set($canViewAN = false)
565 #elseif($visibilityAnnualEvents == 'school_trusted' && ($isGuest || (!$isViewerAdmin && ((!$isSchoolMember) || ($viewerAccountType != 'verified' && $viewerAccountType != 'referred'))))) #set($canViewAN = false)
566 #end
567 #if($canViewAN)
568 <div class="seitokai-subsection">
569 <h3 class="seitokai-subsection-title"><svg class="ico" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="18" rx="2" ry="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> 年間主要行事 #if($visibilityAnnualEvents != '' && $visibilityAnnualEvents != 'public')<span class="visibility-badge visibility-${visibilityAnnualEvents}">#if($visibilityAnnualEvents == '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>
570 <div class="seitokai-subsection-content">
571 <table class="wiki-table school-info-table" style="margin:0">
572 #foreach($m in $months)
573 #if($m.get(1) && $m.get(1) != '')
574 <tr><td style="width:60px;font-weight:600;white-space:nowrap">$m.get(0)</td><td>$!escapetool.xml($m.get(1))</td></tr>
575 #end
576 #end
577 </table>
578 </div>
579 </div>
580 #else
581 <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($visibilityAnnualEvents == 'school_trusted')校内の承認済み・紹介メンバー#else校内メンバー#end のみ閲覧可能です</div>
582 #end
583 #end
584
585 ## --- 日常の活動 ---
586 #if($dailyActivities && !$dailyActivities.isEmpty())
587 #set($canViewDA = true)
588 #if($visibilityDailyActivities == 'school' && ($isGuest || (!$isViewerAdmin && !$isSchoolMember))) #set($canViewDA = false)
589 #elseif($visibilityDailyActivities == 'school_trusted' && ($isGuest || (!$isViewerAdmin && ((!$isSchoolMember) || ($viewerAccountType != 'verified' && $viewerAccountType != 'referred'))))) #set($canViewDA = false)
590 #end
591 #if($canViewDA)
592 <div class="seitokai-subsection">
593 <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> 日常の活動 #if($visibilityDailyActivities != '' && $visibilityDailyActivities != 'public')<span class="visibility-badge visibility-${visibilityDailyActivities}">#if($visibilityDailyActivities == '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>
594 <div class="seitokai-subsection-content">
595 <p class="activity-hint">活動時間が多い3つ</p>
596 <div class="tag-container">
597 #foreach($da in $dailyActivities)
598 <span class="tag tag-accent">$!escapetool.xml($da.trim())</span>
599 #end
600 </div>
601 #if($dailyActivitiesNote && $dailyActivitiesNote.trim() != '')
602 <div class="free-note">$!escapetool.xml($dailyActivitiesNote)</div>
603 #end
604 </div>
605 </div>
606 #else
607 <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($visibilityDailyActivities == 'school_trusted')校内の承認済み・紹介メンバー#else校内メンバー#end のみ閲覧可能です</div>
608 #end
609 #end
610
611 ## --- 定例活動 ---
612 #if($meetingFrequency && $meetingFrequency != '')
613 #set($canViewMT = true)
614 #if($visibilityMeeting == 'school' && ($isGuest || (!$isViewerAdmin && !$isSchoolMember))) #set($canViewMT = false)
615 #elseif($visibilityMeeting == 'school_trusted' && ($isGuest || (!$isViewerAdmin && ((!$isSchoolMember) || ($viewerAccountType != 'verified' && $viewerAccountType != 'referred'))))) #set($canViewMT = false)
616 #end
617 #if($canViewMT)
618 <div class="seitokai-subsection">
619 <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> 定例活動 #if($visibilityMeeting != '' && $visibilityMeeting != 'public')<span class="visibility-badge visibility-${visibilityMeeting}">#if($visibilityMeeting == '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>
620 <div class="seitokai-subsection-content">
621 <div class="info-row">
622 <span class="info-label">役員定例会の頻度</span>
623 <span class="info-value">$!escapetool.xml($!meetingFrequency)</span>
624 </div>
625 #if($regularActivitiesNote && $regularActivitiesNote.trim() != '')
626 <div class="free-note">$!escapetool.xml($regularActivitiesNote)</div>
627 #end
628 </div>
629 </div>
630 #else
631 <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($visibilityMeeting == 'school_trusted')校内の承認済み・紹介メンバー#else校内メンバー#end のみ閲覧可能です</div>
632 #end
633 #end
634
635 ## --- 生徒総会 ---
636 #set($hasAssembly = ($assemblyFormat && $assemblyFormat != '') || ($assemblyCount && $assemblyCount > 0) || ($assemblyAgenda && !$assemblyAgenda.isEmpty()) || ($assemblyTopics && !$assemblyTopics.isEmpty()) || ($assemblyNote && $assemblyNote != ''))
637 #if($hasAssembly)
638 #set($canViewAS = true)
639 #if($visibilityAssembly == 'school' && ($isGuest || (!$isViewerAdmin && !$isSchoolMember))) #set($canViewAS = false)
640 #elseif($visibilityAssembly == 'school_trusted' && ($isGuest || (!$isViewerAdmin && ((!$isSchoolMember) || ($viewerAccountType != 'verified' && $viewerAccountType != 'referred'))))) #set($canViewAS = false)
641 #end
642 #if($canViewAS)
643 <div class="seitokai-subsection">
644 <h3 class="seitokai-subsection-title"><svg class="ico" viewBox="0 0 24 24"><path d="M17 21v-2a4 4 0 00-4-4H5a4 4 0 00-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 00-3-3.87"/><path d="M16 3.13a4 4 0 010 7.75"/></svg> 生徒総会 #if($visibilityAssembly != '' && $visibilityAssembly != 'public')<span class="visibility-badge visibility-${visibilityAssembly}">#if($visibilityAssembly == '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>
645 <div class="seitokai-subsection-content">
646 #if($assemblyFormat && $assemblyFormat != '')
647 <div class="info-row">
648 <span class="info-label">開催方式</span>
649 <span class="info-value"><span class="tag tag-primary tag-sm">$!escapetool.xml($assemblyFormat)</span></span>
650 </div>
651 #end
652 #if($assemblyCount && $assemblyCount > 0)
653 <div class="info-row">
654 <span class="info-label">開催回数(年)</span>
655 <span class="info-value">$!escapetool.xml($assemblyCount)回</span>
656 </div>
657 #end
658 #if($assemblyAgenda && !$assemblyAgenda.isEmpty())
659 <div class="info-row">
660 <span class="info-label">議案の集め方</span>
661 <span class="info-value">
662 <div class="selection-display">
663 #foreach($aa in $assemblyAgenda)
664 <span class="selection-item">$!escapetool.xml($aa.trim())</span>
665 #end
666 </div>
667 </span>
668 </div>
669 #end
670 #if($assemblyTopics && !$assemblyTopics.isEmpty())
671 <div class="info-row">
672 <span class="info-label">扱う内容</span>
673 <span class="info-value">
674 <div class="selection-display">
675 #foreach($at in $assemblyTopics)
676 <span class="selection-item">$!escapetool.xml($at.trim())</span>
677 #end
678 </div>
679 </span>
680 </div>
681 #end
682 #if($assemblyNote && $assemblyNote != '')
683 <div class="info-row">
684 <span class="info-label">自由記述</span>
685 <span class="info-value free-text-value">$!escapetool.xml($assemblyNote)</span>
686 </div>
687 #end
688 </div>
689 </div>
690 #else
691 <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($visibilityAssembly == 'school_trusted')校内の承認済み・紹介メンバー#else校内メンバー#end のみ閲覧可能です</div>
692 #end
693 #end
694
695 ## --- 選挙 ---
696 #if($electionExists && $electionExists != '')
697 #set($canViewEL = true)
698 #if($visibilityElection == 'school' && ($isGuest || (!$isViewerAdmin && !$isSchoolMember))) #set($canViewEL = false)
699 #elseif($visibilityElection == 'school_trusted' && ($isGuest || (!$isViewerAdmin && ((!$isSchoolMember) || ($viewerAccountType != 'verified' && $viewerAccountType != 'referred'))))) #set($canViewEL = false)
700 #end
701 #if($canViewEL)
702 <div class="seitokai-subsection">
703 <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> 選挙 #if($visibilityElection != '' && $visibilityElection != 'public')<span class="visibility-badge visibility-${visibilityElection}">#if($visibilityElection == '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>
704 <div class="seitokai-subsection-content">
705 <div class="info-row">
706 <span class="info-label">役員選挙</span>
707 <span class="info-value">$!escapetool.xml($!electionExists)</span>
708 </div>
709 #if($electionType && $electionType != '')
710 <div class="info-row">
711 <span class="info-label">直近の選挙方式</span>
712 <span class="info-value">$!escapetool.xml($!electionType)</span>
713 </div>
714 #end
715 #if($electionNote && $electionNote.trim() != '')
716 <div class="free-note">$!escapetool.xml($electionNote)</div>
717 #end
718 </div>
719 </div>
720 #else
721 <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($visibilityElection == 'school_trusted')校内の承認済み・紹介メンバー#else校内メンバー#end のみ閲覧可能です</div>
722 #end
723 #end
724
725 ## --- 校則・生徒会会則の見直し ---
726 #if($ruleReviewStatus && $ruleReviewStatus != '')
727 #set($canViewRuleReview = true)
728 #if($visibilityRuleReview == 'school' && ($isGuest || (!$isViewerAdmin && !$isSchoolMember))) #set($canViewRuleReview = false)
729 #elseif($visibilityRuleReview == 'school_trusted' && ($isGuest || (!$isViewerAdmin && ((!$isSchoolMember) || ($viewerAccountType != 'verified' && $viewerAccountType != 'referred'))))) #set($canViewRuleReview = false)
730 #end
731 #if($canViewRuleReview)
732 <div class="seitokai-subsection">
733 <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>
734 <div class="seitokai-subsection-content">
735 <div class="info-row">
736 <span class="info-label">見直しの有無(3年以内)</span>
737 <span class="info-value"><span class="tag tag-primary tag-sm">$!escapetool.xml($!ruleReviewStatus)</span></span>
738 </div>
739 #if($ruleReviewStatus != '実施なし')
740 #if($ruleReviewContent && !$ruleReviewContent.isEmpty())
741 <div class="info-row">
742 <span class="info-label">見直しの内容</span>
743 <span class="info-value">
744 <div class="selection-display">
745 #foreach($rc in $ruleReviewContent)
746 <span class="selection-item">$!escapetool.xml($rc.trim())</span>
747 #end
748 </div>
749 </span>
750 </div>
751 #end
752 #if($ruleReviewProposer && !$ruleReviewProposer.isEmpty())
753 <div class="info-row">
754 <span class="info-label">見直しの提案者</span>
755 <span class="info-value">
756 <div class="selection-display">
757 #foreach($rp in $ruleReviewProposer)
758 <span class="selection-item">$!escapetool.xml($rp.trim())</span>
759 #end
760 </div>
761 </span>
762 </div>
763 #end
764 #if($ruleReviewImplementer && !$ruleReviewImplementer.isEmpty())
765 <div class="info-row">
766 <span class="info-label">見直しの実施者</span>
767 <span class="info-value">
768 <div class="selection-display">
769 #foreach($ri in $ruleReviewImplementer)
770 <span class="selection-item">$!escapetool.xml($ri.trim())</span>
771 #end
772 </div>
773 </span>
774 </div>
775 #end
776 #end
777 #if($ruleReviewSystem && $ruleReviewSystem != '')
778 <div class="info-row">
779 <span class="info-label">見直しの仕組み</span>
780 <span class="info-value">$!escapetool.xml($!ruleReviewSystem)</span>
781 </div>
782 #end
783 </div>
784 </div>
785 #else
786 <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>
787 #end
788 #end
789
790 ## --- 予算 ---
791 #set($hasBudget = ($budgetProcess && !$budgetProcess.isEmpty()) || ($studentFee && $studentFee != '') || ($budgetScale && $budgetScale != ''))
792 #if($hasBudget)
793 #set($canViewBudget = true)
794 #if($visibilityBudget == 'school' && ($isGuest || (!$isViewerAdmin && !$isSchoolMember))) #set($canViewBudget = false)
795 #elseif($visibilityBudget == 'school_trusted' && ($isGuest || (!$isViewerAdmin && ((!$isSchoolMember) || ($viewerAccountType != 'verified' && $viewerAccountType != 'referred'))))) #set($canViewBudget = false)
796 #end
797 #if($canViewBudget)
798 <div class="seitokai-subsection">
799 <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>
800 <div class="seitokai-subsection-content">
801 #if($budgetProcess && !$budgetProcess.isEmpty())
802 <div class="info-row">
803 <span class="info-label">作成過程の生徒関与</span>
804 <span class="info-value">
805 <div class="selection-display">
806 #set($allBpOpts = ["各部・委員会等への予算希望額調査","予算額調整(折衝等)","生徒会予算案の作成","生徒総会での議決","生徒関与なし","その他"])
807 #foreach($bpOpt in $allBpOpts)
808 #if($budgetProcess.contains($bpOpt))
809 <span class="selection-item">$!escapetool.xml($bpOpt)</span>
810 #else
811 <span class="selection-item selection-item-off">$!escapetool.xml($bpOpt)</span>
812 #end
813 #end
814 </div>
815 </span>
816 </div>
817 #end
818 #if($studentFee && $studentFee != '')
819 <div class="info-row">
820 <span class="info-label">生徒会費(年額)</span>
821 <span class="info-value">$!escapetool.xml($!studentFee)</span>
822 </div>
823 #end
824 #if($budgetScale && $budgetScale != '')
825 <div class="info-row">
826 <span class="info-label">予算規模</span>
827 <span class="info-value">$!escapetool.xml($!budgetScale)</span>
828 </div>
829 #end
830 #if($budgetAllocation && !$budgetAllocation.isEmpty())
831 <div class="info-row">
832 <span class="info-label">主な予算配分</span>
833 <span class="info-value">
834 <div class="selection-display">
835 #foreach($ba in $budgetAllocation)
836 <span class="selection-item">$!escapetool.xml($ba.trim())</span>
837 #end
838 </div>
839 </span>
840 </div>
841 #end
842 #if($budgetNote && $budgetNote.trim() != '')
843 <div class="free-note">$!escapetool.xml($budgetNote)</div>
844 #end
845 </div>
846 </div>
847 #else
848 <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>
849 #end
850 #end
851
852 ## --- 広報 ---
853 #set($hasPublicity = ($publicityMethod && !$publicityMethod.isEmpty()) || ($publicityFrequency && $publicityFrequency != '') || ($publicityNote && $publicityNote != ''))
854 #if($hasPublicity)
855 #set($canViewPB = true)
856 #if($visibilityPublicity == 'school' && ($isGuest || (!$isViewerAdmin && !$isSchoolMember))) #set($canViewPB = false)
857 #elseif($visibilityPublicity == 'school_trusted' && ($isGuest || (!$isViewerAdmin && ((!$isSchoolMember) || ($viewerAccountType != 'verified' && $viewerAccountType != 'referred'))))) #set($canViewPB = false)
858 #end
859 #if($canViewPB)
860 <div class="seitokai-subsection">
861 <h3 class="seitokai-subsection-title"><svg class="ico" viewBox="0 0 24 24"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg> 広報 #if($visibilityPublicity != '' && $visibilityPublicity != 'public')<span class="visibility-badge visibility-${visibilityPublicity}">#if($visibilityPublicity == '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>
862 <div class="seitokai-subsection-content">
863 #if($publicityMethod && !$publicityMethod.isEmpty())
864 <div class="info-row">
865 <span class="info-label">方法</span>
866 <span class="info-value">
867 <div class="selection-display">
868 #foreach($pm in $publicityMethod)
869 <span class="selection-item">$!escapetool.xml($pm.trim())</span>
870 #end
871 </div>
872 </span>
873 </div>
874 #end
875 #if($publicityFrequency && $publicityFrequency != '')
876 <div class="info-row">
877 <span class="info-label">頻度</span>
878 <span class="info-value"><span class="tag tag-primary tag-sm">$!escapetool.xml($publicityFrequency)</span></span>
879 </div>
880 #end
881 #if($publicityNote && $publicityNote != '')
882 <div class="info-row">
883 <span class="info-label">自由記述</span>
884 <span class="info-value free-text-value">$!escapetool.xml($publicityNote)</span>
885 </div>
886 #end
887 </div>
888 </div>
889 #else
890 <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($visibilityPublicity == 'school_trusted')校内の承認済み・紹介メンバー#else校内メンバー#end のみ閲覧可能です</div>
891 #end
892 #end
893
894 ## --- 外部連携 ---
895 #set($hasExternal = ($externalCooperation && $externalCooperation != '') || ($externalOrgName && $externalOrgName != '') || ($socialParticipation && !$socialParticipation.isEmpty()))
896 #if($hasExternal)
897 #set($canViewEX = true)
898 #if($visibilityExternal == 'school' && ($isGuest || (!$isViewerAdmin && !$isSchoolMember))) #set($canViewEX = false)
899 #elseif($visibilityExternal == 'school_trusted' && ($isGuest || (!$isViewerAdmin && ((!$isSchoolMember) || ($viewerAccountType != 'verified' && $viewerAccountType != 'referred'))))) #set($canViewEX = false)
900 #end
901 #if($canViewEX)
902 <div class="seitokai-subsection">
903 <h3 class="seitokai-subsection-title"><svg class="ico" viewBox="0 0 24 24"><circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><line x1="8.59" y1="13.51" x2="15.42" y2="17.49"/><line x1="15.41" y1="6.51" x2="8.59" y2="10.49"/></svg> 外部連携 #if($visibilityExternal != '' && $visibilityExternal != 'public')<span class="visibility-badge visibility-${visibilityExternal}">#if($visibilityExternal == '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>
904 <div class="seitokai-subsection-content">
905 #if($externalCooperation && $externalCooperation != '')
906 <div class="info-row">
907 <span class="info-label">他校の生徒会との連携</span>
908 <span class="info-value"><span class="tag tag-primary tag-sm">$!escapetool.xml($externalCooperation)</span></span>
909 </div>
910 #end
911 #if($externalOrgName && $externalOrgName != '')
912 <div class="info-row">
913 <span class="info-label">参加している生徒会団体の名前</span>
914 <span class="info-value">$!escapetool.xml($externalOrgName)</span>
915 </div>
916 #end
917 #if($socialParticipation && !$socialParticipation.isEmpty())
918 <div class="info-row">
919 <span class="info-label">社会参加・地域連携・ボランティア</span>
920 <span class="info-value">
921 <div class="selection-display">
922 #foreach($sp2 in $socialParticipation)
923 <span class="selection-item">$!escapetool.xml($sp2.trim())</span>
924 #end
925 </div>
926 </span>
927 </div>
928 #end
929 </div>
930 </div>
931 #else
932 <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($visibilityExternal == 'school_trusted')校内の承認済み・紹介メンバー#else校内メンバー#end のみ閲覧可能です</div>
933 #end
934 #end
935
936 ## --- 生徒会の課題意識 ---
937 #if($challenges && $challenges != '')
938 #set($canViewChallenges = true)
939 #if($visibilityChallenges == 'school' && ($isGuest || (!$isViewerAdmin && !$isSchoolMember))) #set($canViewChallenges = false)
940 #elseif($visibilityChallenges == 'school_trusted' && ($isGuest || (!$isViewerAdmin && ((!$isSchoolMember) || ($viewerAccountType != 'verified' && $viewerAccountType != 'referred'))))) #set($canViewChallenges = false)
941 #end
942 #if($canViewChallenges)
943 <div class="seitokai-subsection">
944 <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>
945 <div class="seitokai-subsection-content">
946 <div class="challenge-text">$!escapetool.xml($challenges)</div>
947 </div>
948 </div>
949 #else
950 <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>
951 #end
952 #end
953
954 </div>## seitokai-info-body 終了
955 </div>## card-seitokai-info 終了
956
957 ## --- ③ SNS・連絡先 ---
958 <div class="school-info-card collapsed" id="card-contact">
959 <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>
960 <table class="wiki-table school-info-table">
961 <tr><th>問い合わせ先</th><td>#if($contactInfo && $contactInfo != '')$!escapetool.xml($contactInfo)#else<span class="text-placeholder">未登録</span>#end</td></tr>
962 <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>
963 <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>
964 <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>
965 <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>
966 <tr><th>その他SNS</th><td>#if($seitokaiOtherSns && $seitokaiOtherSns != '')$!escapetool.xml($seitokaiOtherSns)#else<span class="text-placeholder">未登録</span>#end</td></tr>
967 </table>
968 #set($infoEditDate = $!doc.getValue('lastInfoEditedDate'))
969 #set($infoEditBy = $!doc.getValue('lastInfoEditedBy'))
970 #if($infoEditDate && $infoEditDate != '')
971 <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>
972 #end
973 </div>
974
975 {{/html}}
976
977 ----
978
979 ## --- ⑩ 活動報告一覧(スレッド型・年度タブ付き) ---
980 = 活動報告 =
981
982 ## --- 年度タブ + 投稿者ステータス凡例 ---
983 {{html clean="false"}}
984
985 ## --- 年度タブ ---
986 ## 全活動から年度一覧を収集
987 #set($activities = $doc.getObjects('SeitokaiCode.ActivityClass'))
988 #set($allPosts = $doc.getObjects('SeitokaiCode.ActivityPostClass'))
989 #set($fySet = [])
990 #if($activities && $activities.size() > 0)
991 #foreach($act in $activities)
992 #set($aFY = $!act.getValue('fiscalYear'))
993 #if($aFY && $aFY != '' && !$fySet.contains($aFY))
994 #set($discard = $fySet.add($aFY))
995 #end
996 #end
997 #end
998 ## 現在の年度が含まれていなければ追加
999 #set($currentFYStr = $currentFiscalYear.toString())
1000 #if(!$fySet.contains($currentFYStr))
1001 #set($discard = $fySet.add($currentFYStr))
1002 #end
1003 ## ソート(降順にしたいが Velocity にはないので JS で制御)
1004
1005 <div class="activity-toolbar">
1006 <div class="activity-fy-tabs">
1007 <button class="activity-fy-tab" onclick="switchActivityFY('$currentFYStr', this)">$currentFYStr 年度</button>
1008 #foreach($fy in $fySet)
1009 #if($fy != $currentFYStr)
1010 <button class="activity-fy-tab" onclick="switchActivityFY('$fy', this)">$fy 年度</button>
1011 #end
1012 #end
1013 <button class="activity-fy-tab active" onclick="switchActivityFY('all', this)">全期間</button>
1014 </div>
1015 <div class="activity-toolbar-right">
1016 <button class="btn-view-toggle" id="btnViewToggle" onclick="toggleCompactView()" title="タイトルのみ表示">
1017 <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>
1018 <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>
1019 <span class="toggle-label">一覧表示</span>
1020 </button>
1021 </div>
1022 <div class="author-legend-wrapper">
1023 <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>
1024 <div class="author-legend-body">
1025 <div class="author-legend">
1026 <span class="author-legend-title">投稿者の信頼度:</span>
1027 <span class="author-legend-item"><span class="bar bar-admin"></span> 管理者 <span class="text-hint">— 運営スタッフ</span></span>
1028 <span class="author-legend-item"><span class="bar bar-verified"></span> 承認済み <span class="text-hint">— 本人確認済みのユーザー</span></span>
1029 <span class="author-legend-item"><span class="bar bar-referred"></span> 紹介 <span class="text-hint">— 承認済みユーザーからの紹介</span></span>
1030 <span class="author-legend-item"><span class="bar bar-general"></span> 一般 <span class="text-hint">— 一般登録ユーザー</span></span>
1031 </div>
1032 <div class="author-legend">
1033 <span class="author-legend-title">所属:</span>
1034 <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>
1035 <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>
1036 <span class="author-legend-item"><span class="badge badge-alumni 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> <span class="text-hint">この学校の卒業生</span></span>
1037 <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>
1038 <span class="author-legend-item text-hint">※一般アカウントは所属バッジが表示されません</span>
1039 </div>
1040 <div class="author-legend">
1041 <span class="author-legend-title">役割:</span>
1042 <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>
1043 <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>
1044 <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>
1045 </div>
1046 </div>
1047 </div>
1048 </div>
1049
1050 {{/html}}
1051
1052 ## 活動を「年度降順 + 特色あり先頭」で並び替え
1053 ## Step1: fySet から年度を降順ソート($sorttool を使用)
1054 #set($fyNums = [])
1055 #foreach($fy in $fySet)
1056 #if($fy && $fy != '' && $fy != 'unknown')
1057 #set($discard = $fyNums.add($fy))
1058 #end
1059 #end
1060 #set($fySorted = $sorttool.sort($fyNums))
1061 #if(!$fySorted)#set($fySorted = $fyNums)#end
1062 #set($fyDesc = [])
1063 #foreach($fy in $fySorted)
1064 #set($discard = $fyDesc.add(0, $fy))
1065 #end
1066 #if($fySet.contains('unknown'))
1067 #set($discard = $fyDesc.add('unknown'))
1068 #end
1069 ## Step2: 年度降順で featured → normal の順にインデックスを収集
1070 #set($orderedActivityIndices = [])
1071 #foreach($curFY in $fyDesc)
1072 ## 同年度の特色あり活動を先頭に
1073 #set($actIdx2 = 0)
1074 #foreach($act in $activities)
1075 #set($aFY2 = $!act.getValue('fiscalYear'))
1076 #if(!$aFY2 || $aFY2 == '') #set($aFY2 = 'unknown') #end
1077 #if($aFY2 == $curFY && $act.getValue('featured') == '1')
1078 #set($discard = $orderedActivityIndices.add($actIdx2))
1079 #end
1080 #set($actIdx2 = $actIdx2 + 1)
1081 #end
1082 ## 同年度の通常活動
1083 #set($actIdx2 = 0)
1084 #foreach($act in $activities)
1085 #set($aFY2 = $!act.getValue('fiscalYear'))
1086 #if(!$aFY2 || $aFY2 == '') #set($aFY2 = 'unknown') #end
1087 #if($aFY2 == $curFY && $act.getValue('featured') != '1')
1088 #set($discard = $orderedActivityIndices.add($actIdx2))
1089 #end
1090 #set($actIdx2 = $actIdx2 + 1)
1091 #end
1092 #end
1093
1094 #if($activities && $activities.size() > 0)
1095 #foreach($actIdx in $orderedActivityIndices)
1096 #set($activity = $activities.get($actIdx))
1097 #set($actTitle = $activity.getValue('title'))
1098 #set($actCommittee = $activity.getValue('committee'))
1099 #set($actPeriod = $activity.getValue('period'))
1100 #set($actFY = $!activity.getValue('fiscalYear'))
1101 #set($actFeatured = $!activity.getValue('featured'))
1102 #if(!$actFY || $actFY == '') #set($actFY = 'unknown') #end
1103 ## この活動に紐づく投稿を収集(固定投稿を先頭に)
1104 #set($pinnedPosts = [])
1105 #set($normalPosts = [])
1106 #if($allPosts)
1107 #foreach($post in $allPosts)
1108 #if($post.getValue('activityIndex') == $actIdx)
1109 #set($isPinned = $!post.getValue('pinned'))
1110 #if($isPinned == '1')
1111 #set($discard = $pinnedPosts.add($post))
1112 #else
1113 #set($discard = $normalPosts.add($post))
1114 #end
1115 #end
1116 #end
1117 #end
1118 #set($threadPosts = [])
1119 #set($discard = $threadPosts.addAll($pinnedPosts))
1120 #set($discard = $threadPosts.addAll($normalPosts))
1121 ## report/comment カウント
1122 #set($reportCount = 0)
1123 #set($commentCount = 0)
1124 #foreach($tp in $threadPosts)
1125 #set($tpType = $!tp.getValue('postType'))
1126 #if($tpType == 'comment')
1127 #set($commentCount = $commentCount + 1)
1128 #else
1129 #set($reportCount = $reportCount + 1)
1130 #end
1131 #end
1132
1133 {{html clean="false"}}
1134 <div class="activity-thread" data-fiscal-year="$!escapetool.xml($actFY)">
1135 <div class="activity-thread-header">
1136 <div class="activity-thread-title">
1137 <h3 #if($actFeatured == '1')class="featured-title"#end>#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$!escapetool.xml($!actTitle)</h3>
1138 <div class="activity-meta-line">
1139 <span class="activity-meta">$!escapetool.xml($!actCommittee) | $!escapetool.xml($!actPeriod) #if($actFY != 'unknown')| $!escapetool.xml($actFY)年度#end</span>
1140 #set($actTagsList = $activity.getValue('tags'))
1141 #if($actTagsList && !$actTagsList.isEmpty())
1142 #foreach($tagItem in $actTagsList)
1143 #if($tagItem && $tagItem.trim() != '')<span class="activity-tag-badge">$escapetool.xml($tagItem)</span>#end
1144 #end
1145 #end
1146 </div>
1147 </div>
1148 <div class="thread-meta-right">
1149 <span class="thread-post-count">${reportCount}件の報告 ・ ${commentCount}件のコメント</span>
1150 #if($viewerAccountType == 'admin' || $viewerAccountType == 'verified' || $viewerAccountType == 'referred')
1151 #if($actFeatured == '1')
1152 <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>
1153 #else
1154 <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>
1155 #end
1156 #end
1157 </div>
1158 </div>
1159
1160 ## --- 活動報告セクション ---
1161 #foreach($post in $threadPosts)
1162 #set($thisPostType = $!post.getValue('postType'))
1163 #if($thisPostType != 'comment')
1164 #set($postContent = $post.getValue('content'))
1165 #set($postAuthor = $post.getValue('author'))
1166 #set($postAccountType = $!post.getValue('authorAccountType'))
1167 #set($postUserRole = $!post.getValue('authorUserRole'))
1168 #set($postGrade = $!post.getValue('authorGrade'))
1169 #set($postSchoolCode = $!post.getValue('authorSchoolCode'))
1170 #set($postDate = $post.getValue('createdDate'))
1171 ## 論理削除チェック
1172 #set($postDeleted = $!post.getValue('deleted'))
1173 #if($postDeleted == 1 || $postDeleted == '1')
1174 #if($viewerAccountType == 'admin')
1175 <div class="thread-post thread-post-deleted thread-post-admin-deleted">
1176 <div class="thread-post-admin-deleted-content">
1177 <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>
1178 <strong>投稿者により削除済み</strong>($!post.getValue('deletedAt'))
1179 <div class="thread-post-restored-content">$!escapetool.xml($!postContent)</div>
1180 </div>
1181 </div>
1182 #else
1183 <div class="thread-post thread-post-deleted thread-post-user-deleted">
1184 <div class="thread-post-user-deleted-content">
1185 <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>
1186 この投稿は削除されました
1187 </div>
1188 </div>
1189 #end
1190 #else
1191 ## 通報による非表示チェック
1192 #set($postHidden = $!post.getValue('hidden'))
1193 #if($postHidden == 1 || $postHidden == '1')
1194 #if($viewerAccountType == 'admin')
1195 <div class="thread-post thread-post-admin-hidden">
1196 <div class="thread-post-admin-hidden-content">
1197 <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>
1198 <strong>通報により非表示中</strong>(理由: $!escapetool.xml($!post.getValue('hiddenReason')))
1199 <div class="thread-post-restored-content">$!escapetool.xml($!postContent)</div>
1200 </div>
1201 </div>
1202 #end
1203 #else
1204 ## 投稿の公開範囲チェック
1205 #set($postVis = $!post.getValue('visibility'))
1206 #if(!$postVis || $postVis == '') #set($postVis = 'public') #end
1207 #set($canViewPost = true)
1208 #if($postVis == 'school' && ($isGuest || (!$isViewerAdmin && !$isSchoolMember))) #set($canViewPost = false)
1209 #elseif($postVis == 'school_trusted' && ($isGuest || (!$isViewerAdmin && ((!$isSchoolMember) || ($viewerAccountType != 'verified' && $viewerAccountType != 'referred'))))) #set($canViewPost = false)
1210 #end
1211 #if(!$canViewPost)
1212 <div class="thread-post visibility-restricted-post">
1213 <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>
1214 </div>
1215 #else
1216 ## 投稿者のアカウント種別に基づいたCSSクラス
1217 #set($postAuthorClass = 'author-general')
1218 #if($postAccountType == 'admin')
1219 #set($postAuthorClass = 'author-admin')
1220 #elseif($postAccountType == 'verified')
1221 #set($postAuthorClass = 'author-verified')
1222 #elseif($postAccountType == 'referred')
1223 #set($postAuthorClass = 'author-referred')
1224 #end
1225
1226 #set($isPinned = $!post.getValue('pinned'))
1227 <div class="thread-post $postAuthorClass #if($isPinned == '1')thread-post-pinned#end">
1228 <div class="thread-post-sidebar"><div class="thread-post-bar"></div></div>
1229 <div class="thread-post-content">
1230 <div class="thread-post-header">
1231 #if($isPinned == '1')
1232 <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>
1233 #end
1234 #set($postAuthorRef = $!post.getValue('authorRef'))
1235 <span class="thread-post-author">
1236 #if($postAuthorRef && $postAuthorRef != '')
1237 <a href="$xwiki.getURL('SeitokaiCode.UserProfile', 'view', "user=${escapetool.url($postAuthorRef)}")">$!escapetool.xml($!postAuthor)</a>
1238 #else
1239 $!escapetool.xml($!postAuthor)
1240 #end
1241 </span>
1242 <span class="author-badge">
1243 #if($postAccountType == 'admin')
1244 <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>
1245 #elseif($postAccountType == 'verified')
1246 <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>
1247 #elseif($postAccountType == 'referred')
1248 <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>
1249 #else
1250 <span class="badge badge-general badge-sm">一般</span>
1251 #end
1252 ## 所属バッジ(投稿者の学校コードとページの学校コードを比較)
1253 #set($postIsSchoolMatch = ($postSchoolCode == $schoolCode || ($affiliatedSchoolCode != '' && $postSchoolCode == $affiliatedSchoolCode)))
1254 #if($postSchoolCode && $postSchoolCode != '' && $postAccountType != 'general')
1255 #if($postUserRole == 'graduate' && $postIsSchoolMatch)
1256 <span class="badge badge-alumni 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>
1257 #elseif($postIsSchoolMatch && $postUserRole != 'graduate')
1258 #if($postAccountType == 'verified' || $postAccountType == 'admin')
1259 <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>
1260 #else
1261 <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>
1262 #end
1263 #else
1264 <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>
1265 #end
1266 #end
1267 #if($postUserRole == 'student')
1268 <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>
1269 #set($postIsOfficer = $!post.getValue('authorIsOfficer'))
1270 #if($postIsOfficer == 'true')
1271 <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>
1272 #end
1273 #elseif($postUserRole == 'teacher')
1274 <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>
1275 #elseif($postUserRole == 'graduate')
1276 <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>
1277 #end
1278 </span>
1279 <span class="thread-post-date">$!postDate</span>
1280 #set($postEdited = $!post.getValue('edited'))
1281 #if($postEdited == 1 || $postEdited == '1')
1282 <span class="post-edited-label">(編集済み)</span>
1283 #end
1284 #set($postAuthorRefH = $!post.getValue('authorRef'))
1285 #set($postObjNumH = $post.number)
1286 #if(!$isGuest && $xcontext.user != $postAuthorRefH)
1287 <button type="button" class="btn-post-report btn-post-report-header" onclick="openReportDialog(this, '${doc.fullName}', $postObjNumH, '${services.csrf.getToken()}')" title="この投稿を通報">
1288 <svg class="ico ico-fixed-14" viewBox="0 0 24 24"><path d="M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z"/><line x1="4" y1="22" x2="4" y2="15"/></svg> 通報
1289 </button>
1290 #end
1291 </div>
1292 <div class="thread-post-body">
1293 $!escapetool.xml($!postContent)
1294 #set($postImages = $!post.getValue('images'))
1295 #if($postImages && $postImages.trim() != '')
1296 <div class="post-images">
1297 #set($imageList = $postImages.trim().split("\n"))
1298 #set($imageCount = $imageList.size())
1299 #if($imageCount > 4)#set($imageCount = 4)#end
1300 <div class="post-image-grid post-image-count-${imageCount}">
1301 #foreach($imgFile in $imageList)
1302 #if($foreach.count <= 4)
1303 #set($imgName = $imgFile.trim())
1304 #if($imgName != '')
1305 <div class="post-image-item">
1306 <a href="$doc.getAttachmentURL($imgName)" target="_blank">
1307 <img src="$doc.getAttachmentURL($imgName)" alt="$!escapetool.xml($imgName)" loading="lazy"/>
1308 </a>
1309 </div>
1310 #end
1311 #end
1312 #end
1313 </div>
1314 </div>
1315 #end
1316 ## ファイル添付の表示
1317 #set($postFiles = $!post.getValue('files'))
1318 #if($postFiles && $postFiles.trim() != '')
1319 <div class="post-files">
1320 #set($fileList = $postFiles.trim().split("\n"))
1321 #foreach($attachFile in $fileList)
1322 #if($foreach.count <= 2)
1323 #set($fName = $attachFile.trim())
1324 #if($fName != '')
1325 #set($fLower = $fName.toLowerCase())
1326 #set($fIcon = 'file')
1327 #set($fColor = '#64748b')
1328 #if($fLower.endsWith('.pdf'))#set($fIcon = 'pdf')#set($fColor = '#dc2626')#end
1329 #if($fLower.endsWith('.docx'))#set($fIcon = 'word')#set($fColor = '#2563eb')#end
1330 #if($fLower.endsWith('.xlsx'))#set($fIcon = 'excel')#set($fColor = '#16a34a')#end
1331 #if($fLower.endsWith('.pptx'))#set($fIcon = 'ppt')#set($fColor = '#ea580c')#end
1332 ## ファイル名からプレフィックス(file_YYYYMMDDHHMMSS_N_)を除去して表示
1333 #set($displayName = $fName)
1334 #if($fName.matches('file_\d{14}_\d+_.*'))
1335 #set($displayName = $fName.replaceFirst('file_\d{14}_\d+_', ''))
1336 #end
1337 <div class="post-file-item">
1338 <a href="$doc.getAttachmentURL($fName)" target="_blank" download="$!escapetool.xml($displayName)">
1339 #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>
1340 #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>
1341 #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>
1342 #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>
1343 #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>
1344 #end
1345 <span class="post-file-name">$!escapetool.xml($displayName)</span>
1346 </a>
1347 </div>
1348 #end
1349 #end
1350 #end
1351 </div>
1352 #end
1353 </div>
1354 #if($postVis != 'public')
1355 <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>
1356 #end
1357 ## いいねボタン
1358 #set($postLikeCount = $!post.getValue('likeCount'))
1359 #if(!$postLikeCount || $postLikeCount == '') #set($postLikeCount = 0) #end
1360 #set($postLikedBy = $!post.getValue('likedBy'))
1361 #set($isLikedByMe = false)
1362 #if($postLikedBy && $postLikedBy.contains($xcontext.user)) #set($isLikedByMe = true) #end
1363 <div class="post-like-row post-action-mt">
1364 #if($xcontext.user != 'XWiki.XWikiGuest')
1365 <button type="button" class="btn-like #if($isLikedByMe)liked#end" data-page="$escapetool.xml($doc.fullName)" data-obj="$post.number" data-csrf="$services.csrf.getToken()" onclick="toggleLike(this)">
1366 <svg class="ico ico-fixed-14" viewBox="0 0 24 24" #if($isLikedByMe)fill="currentColor" stroke="none"#end><path d="M20.84 4.61a5.5 5.5 0 00-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 00-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 000-7.78z"/></svg>
1367 <span class="like-count">$postLikeCount</span>
1368 </button>
1369 #else
1370 <span class="btn-like disabled">
1371 <svg class="ico ico-fixed-14" viewBox="0 0 24 24"><path d="M20.84 4.61a5.5 5.5 0 00-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 00-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 000-7.78z"/></svg>
1372 <span class="like-count">$postLikeCount</span>
1373 </span>
1374 #end
1375 </div>
1376 ## 固定/編集/削除/通報/非表示ボタン(横並び)
1377 #set($postAuthorRef = $!post.getValue('authorRef'))
1378 #set($postObjNumED = $post.number)
1379 #set($showPinBtn = ($viewerAccountType == 'admin' || $viewerAccountType == 'verified'))
1380 #set($showEditDeleteBtn = ($xcontext.user == $postAuthorRef || $viewerAccountType == 'admin'))
1381 #set($showHideBtn = ($viewerAccountType == 'admin'))
1382 #if($showPinBtn || $showEditDeleteBtn || $showHideBtn)
1383 <div class="post-edit-actions post-action-mt">
1384 #if($showPinBtn)
1385 #set($postObjNum = $post.number)
1386 #if($isPinned == '1')
1387 <a href="$doc.getURL('view', "action=unpin&postObj=${postObjNum}&form_token=${services.csrf.getToken()}")" class="btn-pin-toggle btn-unpin" title="固定を解除">
1388 <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> 固定を解除
1389 </a>
1390 #else
1391 <a href="$doc.getURL('view', "action=pin&postObj=${postObjNum}&form_token=${services.csrf.getToken()}")" class="btn-pin-toggle btn-pin" title="この投稿を固定">
1392 <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> 固定する
1393 </a>
1394 #end
1395 #end
1396 #if($showEditDeleteBtn)
1397 #if($xcontext.user == $postAuthorRef)
1398 #set($editImages = $!post.getValue('images'))
1399 #set($editFiles = $!post.getValue('files'))
1400 <button type="button" class="btn-post-edit" data-school="${doc.fullName}" data-obj="$postObjNumED" data-content="$!escapetool.xml($!postContent)" data-images="$!escapetool.xml($!editImages)" data-files="$!escapetool.xml($!editFiles)" data-post-type="$!post.getValue('postType')" onclick="openEditPost(this)" title="この投稿を編集">
1401 <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> 編集
1402 </button>
1403 #end
1404 <button type="button" class="btn-post-delete" onclick="confirmDeletePost('${doc.fullName}', $postObjNumED, '${services.csrf.getToken()}')" title="この投稿を削除">
1405 <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> 削除
1406 </button>
1407 #end
1408 #if($showHideBtn)
1409 <button type="button" class="btn-post-hide" onclick="openHideDialog(this, '${doc.fullName}', $postObjNumED, '${services.csrf.getToken()}')" title="この投稿を非表示にする">
1410 <svg class="ico ico-fixed-14" 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 11-4.24-4.24"/><line x1="1" y1="1" x2="23" y2="23"/></svg> 非表示
1411 </button>
1412 #end
1413 </div>
1414 #end
1415 </div>
1416 </div>
1417 #end## /canViewPost
1418 #end## /postHidden
1419 #end## /postDeleted
1420 #end## /postType != comment
1421 #end## /foreach reports
1422
1423 ## --- コメントセクション(折りたたみ) ---
1424 #if($commentCount > 0)
1425 <details class="thread-comments-section">
1426 <summary class="thread-comments-toggle">
1427 <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}件のコメント
1428 </summary>
1429 #foreach($post in $threadPosts)
1430 #set($thisPostType = $!post.getValue('postType'))
1431 #if($thisPostType == 'comment')
1432 #set($postContent = $post.getValue('content'))
1433 #set($postAuthor = $post.getValue('author'))
1434 #set($postAccountType = $!post.getValue('authorAccountType'))
1435 #set($postDate = $post.getValue('createdDate'))
1436 #set($postDeleted = $!post.getValue('deleted'))
1437 #if($postDeleted == 1 || $postDeleted == '1')
1438 <div class="thread-comment thread-comment-deleted">
1439 <span class="thread-comment-meta">このコメントは削除されました</span>
1440 </div>
1441 #else
1442 #set($postHidden = $!post.getValue('hidden'))
1443 #if($postHidden == 1 || $postHidden == '1')
1444 <div class="thread-comment thread-comment-hidden">
1445 <span class="thread-comment-meta">このコメントは非表示にされました</span>
1446 </div>
1447 #else
1448 <div class="thread-comment">
1449 <span class="thread-comment-author">$!escapetool.xml($postAuthor)</span>
1450 <span class="thread-comment-date">$!postDate</span>
1451 <div class="thread-comment-body">$!escapetool.xml($postContent)</div>
1452 </div>
1453 #end
1454 #end
1455 #end
1456 #end
1457 </details>
1458 #end
1459
1460 #if($xcontext.user != "XWiki.XWikiGuest")
1461 <div class="thread-add-post">
1462 #if($isSchoolMember || $isAlumniOfSchool || $isViewerAdmin)
1463 <a href="/bin/SeitokaiCode/ActivityPostForm?schoolPage=${doc.fullName}&activityIndex=${actIdx}&schoolCode=$!escapetool.url($schoolCode)&postType=report" class="btn-thread-add">
1464 + 活動報告を追加
1465 </a>
1466 #end
1467 <a href="/bin/SeitokaiCode/ActivityPostForm?schoolPage=${doc.fullName}&activityIndex=${actIdx}&schoolCode=$!escapetool.url($schoolCode)&postType=comment" class="btn-thread-comment">
1468 <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> コメントを書く
1469 </a>
1470 </div>
1471 #end
1472 </div>
1473 {{/html}}
1474 #end
1475 #else
1476 {{html clean="false"}}
1477 <div class="empty-state">
1478 <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>
1479 <div class="empty-state-title">活動報告はまだありません</div>
1480 <div class="empty-state-desc">この学校の活動を記録して、他校と共有しましょう。<br>「活動を追加」ボタンから最初の活動を作成できます。</div>
1481 </div>
1482 {{/html}}
1483 #end
1484
1485 ## --- 活動追加ボタン ---
1486 #if($xcontext.user != "XWiki.XWikiGuest")
1487 {{html clean="false"}}
1488 <div class="activity-add-section">
1489 <a href="/bin/SeitokaiCode/ActivityForm?schoolPage=${doc.fullName}&schoolCode=$!escapetool.url($schoolCode)" class="btn btn-primary btn-add-activity">
1490 <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> 活動を追加
1491 </a>
1492 </div>
1493 {{/html}}
1494 #end
1495
1496 ## --- OGP / SNSシェア対応 ---
1497 #set($ogpTitle = "${schoolName} — 生徒会Wiki")
1498 #set($ogpDesc = "${schoolName}の生徒会活動情報。")
1499 #if($prefecture && $prefecture != '') #set($ogpDesc = "${ogpDesc}${prefecture}") #end
1500 #if($city && $city != '') #set($ogpDesc = "${ogpDesc}${city}。") #end
1501 #if($dailyActivities && $dailyActivities != '') #set($ogpDesc = "${ogpDesc} 主な活動: ${dailyActivities}") #end
1502 #set($ogpUrl = "https://${request.serverName}${doc.getURL()}")
1503
1504 ## --- 年度タブ切り替え JavaScript ---
1505 {{html clean="false"}}
1506 <script>
1507 // OGPメタタグ挿入
1508 (function() {
1509 var ogp = {
1510 'og:title': '$escapetool.javascript($ogpTitle)',
1511 'og:description': '$escapetool.javascript($ogpDesc)',
1512 'og:type': 'article',
1513 'og:url': '$escapetool.javascript($ogpUrl)',
1514 'og:site_name': '生徒会Wiki',
1515 'twitter:card': 'summary'
1516 };
1517 for (var p in ogp) {
1518 var meta = document.createElement('meta');
1519 meta.setAttribute('property', p);
1520 meta.setAttribute('content', ogp[p]);
1521 document.head.appendChild(meta);
1522 }
1523 // twitter用
1524 var tw = document.createElement('meta');
1525 tw.setAttribute('name', 'twitter:card');
1526 tw.setAttribute('content', 'summary');
1527 document.head.appendChild(tw);
1528 })();
1529 // コンパクト表示(タイトルのみ)トグル
1530 // いいねトグル
1531 function toggleLike(btn) {
1532 var page = btn.getAttribute('data-page');
1533 var obj = btn.getAttribute('data-obj');
1534 var csrf = btn.getAttribute('data-csrf');
1535 btn.disabled = true;
1536 var fd = new FormData();
1537 fd.append('page', page);
1538 fd.append('obj', obj);
1539 fd.append('form_token', csrf);
1540 fetch('/bin/SeitokaiCode/LikePost', { method: 'POST', body: fd })
1541 .then(function(r) { return r.json(); })
1542 .then(function(data) {
1543 btn.querySelector('.like-count').textContent = data.count;
1544 if (data.action === 'liked') {
1545 btn.classList.add('liked');
1546 btn.querySelector('svg').setAttribute('fill', 'currentColor');
1547 btn.querySelector('svg').setAttribute('stroke', 'none');
1548 } else {
1549 btn.classList.remove('liked');
1550 btn.querySelector('svg').removeAttribute('fill');
1551 btn.querySelector('svg').setAttribute('stroke', 'currentColor');
1552 }
1553 })
1554 .catch(function() { alert('エラーが発生しました'); })
1555 .finally(function() { btn.disabled = false; });
1556 }
1557
1558 function toggleCompactView() {
1559 var container = document.querySelector('.xwiki-content') || document.body;
1560 var isCompact = container.classList.toggle('activity-compact-view');
1561 var btn = document.getElementById('btnViewToggle');
1562 if (btn) {
1563 btn.querySelector('.toggle-label').textContent = isCompact ? '詳細表示' : '一覧表示';
1564 btn.title = isCompact ? '詳細表示に戻す' : 'タイトルのみ表示';
1565 }
1566 // コンパクトモードでは各スレッドヘッダーをクリックで個別展開可能にする
1567 document.querySelectorAll('.activity-thread').forEach(function(thread) {
1568 if (isCompact) {
1569 thread.classList.remove('compact-expanded');
1570 }
1571 });
1572 }
1573
1574 // コンパクトモードで個別スレッドを展開/折りたたみ
1575 function toggleThreadExpand(e) {
1576 var container = document.querySelector('.xwiki-content') || document.body;
1577 if (!container.classList.contains('activity-compact-view')) return;
1578 // リンクやボタンのクリックはスルー
1579 if (e.target.closest('a, button, .btn-featured-toggle')) return;
1580 var thread = e.target.closest('.activity-thread');
1581 if (thread) {
1582 thread.classList.toggle('compact-expanded');
1583 }
1584 }
1585
1586 function switchActivityFY(fy, btn) {
1587 // タブのアクティブ状態を切り替え
1588 document.querySelectorAll('.activity-fy-tab').forEach(function(t) { t.classList.remove('active'); });
1589 btn.classList.add('active');
1590 // 活動スレッドの表示切り替え
1591 document.querySelectorAll('.activity-thread[data-fiscal-year]').forEach(function(thread) {
1592 if (fy === 'all' || thread.getAttribute('data-fiscal-year') === fy) {
1593 thread.classList.remove('fy-hidden');
1594 } else {
1595 thread.classList.add('fy-hidden');
1596 }
1597 });
1598 }
1599 // ページ読み込み時の初期化
1600 document.addEventListener('DOMContentLoaded', function() {
1601 // 年度タブを降順にソート(「全期間」タブは末尾に固定)
1602 var tabContainer = document.querySelector('.activity-fy-tabs');
1603 if (tabContainer) {
1604 var tabs = Array.from(tabContainer.querySelectorAll('.activity-fy-tab'));
1605 var allTab = null;
1606 var fyTabs = [];
1607 tabs.forEach(function(t) {
1608 var onclickStr = t.getAttribute('onclick') || '';
1609 if (onclickStr.indexOf("'all'") !== -1) { allTab = t; }
1610 else { fyTabs.push(t); }
1611 });
1612 // 年度タブを数値の降順でソート
1613 fyTabs.sort(function(a, b) {
1614 var aYear = parseInt(a.textContent) || 0;
1615 var bYear = parseInt(b.textContent) || 0;
1616 return bYear - aYear;
1617 });
1618 // DOM再配置
1619 fyTabs.forEach(function(t) { tabContainer.appendChild(t); });
1620 if (allTab) { tabContainer.appendChild(allTab); }
1621 }
1622 // デフォルトで全期間を表示
1623 var defaultTab = document.querySelector('.activity-fy-tab.active');
1624 if (defaultTab) { defaultTab.click(); }
1625 // 保存成功時のトースト通知
1626 if (window.location.search.indexOf('saved=1') !== -1) {
1627 showToast('学校情報を保存しました', 'success');
1628 // URLパラメータをクリーンアップ(リロード時に再表示されないよう)
1629 if (window.history.replaceState) {
1630 window.history.replaceState({}, document.title, window.location.pathname);
1631 }
1632 }
1633 // コンパクトモード: スレッドヘッダークリックで個別展開
1634 document.querySelectorAll('.activity-thread-header').forEach(function(header) {
1635 header.addEventListener('click', toggleThreadExpand);
1636 });
1637 // 長文投稿の折りたたみ初期化(max-height: 12em 超で省略)
1638 document.querySelectorAll('.thread-post-body').forEach(function(body) {
1639 // pre-wrapのまま高さを測定し、max-height(12em ≒ ~200px)を超える場合に折りたたむ
1640 var fullH = body.scrollHeight;
1641 // 12em を px に変換(font-size × line-height × 行数 の近似値ではなくCSSと同じ値を取得)
1642 body.classList.add('truncated');
1643 var maxH = body.clientHeight; // max-height: 12em 適用後の高さ
1644 body.classList.remove('truncated');
1645 if (fullH > maxH + 30) {
1646 body.classList.add('truncated');
1647 var btn = document.createElement('button');
1648 btn.className = 'btn-read-more';
1649 btn.textContent = '広げて読む ▼';
1650 btn.addEventListener('click', function() {
1651 var isExpanded = body.classList.toggle('expanded');
1652 btn.textContent = isExpanded ? '折りたたむ ▲' : '広げて読む ▼';
1653 });
1654 body.parentNode.insertBefore(btn, body.nextSibling);
1655 }
1656 });
1657 });
1658
1659 // トースト通知表示
1660 function showToast(message, type) {
1661 type = type || 'success';
1662 var container = document.getElementById('toast-container');
1663 if (!container) {
1664 container = document.createElement('div');
1665 container.id = 'toast-container';
1666 container.className = 'toast-container';
1667 document.body.appendChild(container);
1668 }
1669 var icons = {
1670 success: '<svg class="ico ico-md" viewBox="0 0 24 24" stroke-width="2.5"><path d="M20 6L9 17l-5-5"/></svg>',
1671 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>'
1672 };
1673 var toast = document.createElement('div');
1674 toast.className = 'toast toast-' + type;
1675 var iconSvg = icons[type] || '';
1676 if (iconSvg) {
1677 var iconSpan = document.createElement('span');
1678 iconSpan.innerHTML = iconSvg;
1679 toast.appendChild(iconSpan);
1680 }
1681 var msgSpan = document.createElement('span');
1682 msgSpan.textContent = message;
1683 toast.appendChild(msgSpan);
1684 container.appendChild(toast);
1685 setTimeout(function() { toast.remove(); }, 3200);
1686 }
1687
1688 // 学校基本情報・連絡先の折りたたみトグル
1689 function toggleInfoCard(cardId) {
1690 var card = document.getElementById(cardId);
1691 if (!card) return;
1692 card.classList.toggle('collapsed');
1693 var isCollapsed = card.classList.contains('collapsed');
1694 var h2 = card.querySelector('h2[role="button"]');
1695 if (h2) h2.setAttribute('aria-expanded', !isCollapsed);
1696 }
1697
1698 // 投稿の編集(インライン編集フォームを開く)
1699 function openEditPost(btn) {
1700 var postEl = btn.closest('.thread-post');
1701 if (!postEl) return;
1702 var existing = postEl.querySelector('.post-edit-form');
1703 if (existing) { existing.remove(); return; }
1704 var bodyEl = postEl.querySelector('.thread-post-body');
1705 if (!bodyEl) return;
1706
1707 var schoolPage = btn.getAttribute('data-school');
1708 var postObjNum = btn.getAttribute('data-obj');
1709 var currentContent = btn.getAttribute('data-content') || '';
1710 var currentImages = btn.getAttribute('data-images') || '';
1711 var currentFiles = btn.getAttribute('data-files') || '';
1712 var postType = btn.getAttribute('data-post-type') || 'report';
1713
1714 var form = document.createElement('div');
1715 form.className = 'post-edit-form';
1716 form.setAttribute('data-school', schoolPage);
1717 form.setAttribute('data-obj', postObjNum);
1718
1719 var html = '<textarea id="editContent_' + postObjNum + '">' + currentContent.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;') + '</textarea>';
1720
1721 // コメント以外は添付ファイル編集を表示
1722 function escAttr(s) { return s.replace(/&/g,'&amp;').replace(/"/g,'&quot;').replace(/'/g,'&#39;').replace(/</g,'&lt;').replace(/>/g,'&gt;'); }
1723 if (postType !== 'comment') {
1724 // 既存画像
1725 html += '<div class="edit-attachments">';
1726 if (currentImages.trim()) {
1727 html += '<div class="edit-attach-section"><span class="edit-attach-label">画像</span>';
1728 var imgs = currentImages.trim().split('\n');
1729 for (var i = 0; i < imgs.length; i++) {
1730 var img = imgs[i].trim();
1731 if (!img) continue;
1732 html += '<div class="edit-attach-item" data-name="' + escAttr(img) + '">' +
1733 '<img src="/xwiki/bin/download/' + schoolPage.replace(/\./g,'/') + '/' + encodeURIComponent(img) + '" class="edit-attach-thumb" />' +
1734 '<button type="button" class="edit-attach-remove" onclick="removeEditAttach(this)" title="削除">✕</button>' +
1735 '<input type="hidden" name="keepImages" value="' + escAttr(img) + '" />' +
1736 '</div>';
1737 }
1738 html += '</div>';
1739 }
1740 // 既存ファイル
1741 if (currentFiles.trim()) {
1742 html += '<div class="edit-attach-section"><span class="edit-attach-label">ファイル</span>';
1743 var files = currentFiles.trim().split('\n');
1744 for (var j = 0; j < files.length; j++) {
1745 var f = files[j].trim();
1746 if (!f) continue;
1747 var displayName = f;
1748 if (/^file_\d{14}_\d+_/.test(f)) displayName = f.replace(/^file_\d{14}_\d+_/, '');
1749 html += '<div class="edit-attach-item" data-name="' + escAttr(f) + '">' +
1750 '<span class="edit-attach-fname">' + escAttr(displayName) + '</span>' +
1751 '<button type="button" class="edit-attach-remove" onclick="removeEditAttach(this)" title="削除">✕</button>' +
1752 '<input type="hidden" name="keepFiles" value="' + escAttr(f) + '" />' +
1753 '</div>';
1754 }
1755 html += '</div>';
1756 }
1757 // 新規追加
1758 html += '<div class="edit-attach-add">' +
1759 '<label class="form-label-sm">画像を追加(最大4枚まで)</label>' +
1760 '<input type="file" name="editNewImages" accept="image/*" multiple class="form-file-input-sm" />' +
1761 '<div class="form-hint">JPEG / PNG / GIF / WebP、各5MBまで</div>' +
1762 '<label class="form-label-sm" style="margin-top:8px;">ファイルを追加(最大2つまで)</label>' +
1763 '<input type="file" name="editNewFiles" accept=".pdf,.docx,.xlsx,.pptx" multiple class="form-file-input-sm" />' +
1764 '<div class="form-hint">PDF / Word / Excel / PowerPoint、各10MBまで</div>' +
1765 '</div>';
1766 html += '</div>';
1767 }
1768
1769 html += '<div class="post-edit-form-actions">' +
1770 '<button type="button" class="btn-cancel-edit" onclick="this.closest(\'.post-edit-form\').remove()">キャンセル</button>' +
1771 '<button type="button" class="btn-save" onclick="saveEditPost(this)">保存</button>' +
1772 '</div>';
1773
1774 form.innerHTML = html;
1775 bodyEl.parentNode.insertBefore(form, bodyEl.nextSibling);
1776 form.querySelector('textarea').focus();
1777 }
1778
1779 function removeEditAttach(btn) {
1780 var item = btn.closest('.edit-attach-item');
1781 if (item) item.remove();
1782 }
1783
1784 // 投稿の編集を保存
1785 function saveEditPost(btn) {
1786 var formEl = btn.closest('.post-edit-form');
1787 if (!formEl) return;
1788 var schoolPage = formEl.getAttribute('data-school');
1789 var postObjNum = formEl.getAttribute('data-obj');
1790 var textarea = formEl.querySelector('textarea');
1791 if (!textarea) return;
1792 var newContent = textarea.value.trim();
1793 if (!newContent) { alert('投稿内容を入力してください'); return; }
1794
1795 var csrfEl = document.querySelector('input[name="form_token"]');
1796 var csrfToken = csrfEl ? csrfEl.value : '';
1797
1798 var fd = new FormData();
1799 fd.append('schoolPage', schoolPage);
1800 fd.append('postObj', postObjNum);
1801 fd.append('newContent', newContent);
1802 fd.append('form_token', csrfToken);
1803
1804 // 残す画像・ファイル
1805 formEl.querySelectorAll('input[name="keepImages"]').forEach(function(el) { fd.append('keepImages', el.value); });
1806 formEl.querySelectorAll('input[name="keepFiles"]').forEach(function(el) { fd.append('keepFiles', el.value); });
1807
1808 // 新規画像
1809 var newImgInput = formEl.querySelector('input[name="editNewImages"]');
1810 if (newImgInput && newImgInput.files) {
1811 for (var i = 0; i < newImgInput.files.length; i++) { fd.append('editNewImages', newImgInput.files[i]); }
1812 }
1813 // 新規ファイル
1814 var newFileInput = formEl.querySelector('input[name="editNewFiles"]');
1815 if (newFileInput && newFileInput.files) {
1816 for (var j = 0; j < newFileInput.files.length; j++) { fd.append('editNewFiles', newFileInput.files[j]); }
1817 }
1818
1819 btn.disabled = true;
1820 btn.textContent = '保存中...';
1821
1822 var xhr = new XMLHttpRequest();
1823 xhr.open('POST', '/bin/get/SeitokaiCode/EditPost?outputSyntax=plain', true);
1824 xhr.onload = function() {
1825 try {
1826 var res = JSON.parse(xhr.responseText);
1827 if (res.success) {
1828 showToast('投稿を更新しました', 'success');
1829 setTimeout(function() { location.reload(); }, 800);
1830 } else {
1831 btn.disabled = false; btn.textContent = '保存';
1832 alert('編集に失敗しました: ' + (res.error || ''));
1833 }
1834 } catch(e) { btn.disabled = false; btn.textContent = '保存'; alert('編集に失敗しました'); }
1835 };
1836 xhr.onerror = function() { btn.disabled = false; btn.textContent = '保存'; alert('通信エラーが発生しました'); };
1837 xhr.send(fd);
1838 }
1839
1840 // 投稿の削除(確認ダイアログ付き)
1841 function confirmDeletePost(schoolPage, postObjNum, token) {
1842 if (!confirm('この投稿を削除しますか?\\n削除後は「この投稿は削除されました」と表示されます。')) return;
1843 var xhr = new XMLHttpRequest();
1844 xhr.open('POST', '/bin/get/SeitokaiCode/DeletePost?outputSyntax=plain', true);
1845 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1846 var deletePostData = 'schoolPage=' + encodeURIComponent(schoolPage) + '&postObj=' + postObjNum + '&form_token=' + encodeURIComponent(token);
1847 xhr.onload = function() {
1848 try {
1849 var res = JSON.parse(xhr.responseText);
1850 if (res.success) {
1851 showToast('投稿を削除しました', 'success');
1852 setTimeout(function() { location.reload(); }, 800);
1853 } else {
1854 alert('削除に失敗しました: ' + (res.error || ''));
1855 }
1856 } catch(e) { alert('削除に失敗しました'); }
1857 };
1858 xhr.onerror = function() { alert('通信エラーが発生しました'); };
1859 xhr.send(deletePostData);
1860 }
1861
1862 /* --- 通報ダイアログ --- */
1863 function openReportDialog(btn, targetPage, postObjNum, token) {
1864 if (document.getElementById('report-dialog-overlay')) return;
1865 var reasons = ['宣伝・スパム','不適切な内容','個人情報の露出','誹謗中傷','誤情報','その他'];
1866 var overlay = document.createElement('div');
1867 overlay.id = 'report-dialog-overlay';
1868 overlay.style.cssText = 'position:fixed;inset:0;background:rgba(0,0,0,0.5);z-index:9999;display:flex;align-items:center;justify-content:center;';
1869 var dialog = document.createElement('div');
1870 dialog.style.cssText = 'background:#fff;border-radius:12px;padding:24px;max-width:400px;width:90%;max-height:80vh;overflow-y:auto;';
1871 var html = '<h3 style="margin:0 0 16px;font-size:1.1em;">投稿を通報</h3>';
1872 html += '<p style="margin:0 0 12px;font-size:0.9em;color:#4b5563;">通報された投稿は管理者が確認するまで一時的に非表示になります。</p>';
1873 html += '<label style="display:block;margin-bottom:8px;font-weight:600;font-size:0.9em;">通報理由</label>';
1874 html += '<select id="report-reason" style="width:100%;padding:8px;border:1px solid #d1d5db;border-radius:8px;margin-bottom:12px;font-size:0.9em;">';
1875 for (var i=0; i<reasons.length; i++) html += '<option value="'+reasons[i]+'">'+reasons[i]+'</option>';
1876 html += '</select>';
1877 html += '<label style="display:block;margin-bottom:8px;font-weight:600;font-size:0.9em;">補足コメント(任意)</label>';
1878 html += '<textarea id="report-detail" rows="3" maxlength="500" style="width:100%;padding:8px;border:1px solid #d1d5db;border-radius:8px;resize:vertical;font-size:0.9em;box-sizing:border-box;" placeholder="具体的な内容があればご記入ください"></textarea>';
1879 html += '<div style="display:flex;gap:8px;margin-top:16px;justify-content:flex-end;">';
1880 html += '<button type="button" id="report-cancel-btn" style="padding:8px 16px;border:1px solid #d1d5db;border-radius:8px;background:#fff;cursor:pointer;">キャンセル</button>';
1881 html += '<button type="button" id="report-submit-btn" style="padding:8px 16px;border:none;border-radius:8px;background:#dc2626;color:#fff;cursor:pointer;font-weight:600;">通報する</button>';
1882 html += '</div>';
1883 dialog.innerHTML = html;
1884 overlay.appendChild(dialog);
1885 document.body.appendChild(overlay);
1886 overlay.addEventListener('click', function(e) { if (e.target === overlay) overlay.remove(); });
1887 document.getElementById('report-cancel-btn').addEventListener('click', function() { overlay.remove(); });
1888 document.getElementById('report-submit-btn').addEventListener('click', function() {
1889 var reason = document.getElementById('report-reason').value;
1890 var detail = document.getElementById('report-detail').value;
1891 var submitBtn = document.getElementById('report-submit-btn');
1892 submitBtn.disabled = true; submitBtn.textContent = '送信中...';
1893 var xhr = new XMLHttpRequest();
1894 xhr.open('POST', '/bin/get/SeitokaiCode/ReportAction?outputSyntax=plain', true);
1895 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1896 var data = 'targetPage=' + encodeURIComponent(targetPage) + '&targetPost=' + postObjNum + '&reason=' + encodeURIComponent(reason) + '&detail=' + encodeURIComponent(detail) + '&form_token=' + encodeURIComponent(token);
1897 xhr.onload = function() {
1898 overlay.remove();
1899 showToast('通報を受け付けました', 'success');
1900 setTimeout(function() { location.reload(); }, 1000);
1901 };
1902 xhr.onerror = function() { overlay.remove(); alert('通信エラーが発生しました'); };
1903 xhr.send(data);
1904 });
1905 }
1906
1907 /* --- 非表示ダイアログ(管理者用) --- */
1908 function openHideDialog(btn, targetPage, postObjNum, token) {
1909 if (document.getElementById('hide-dialog-overlay')) return;
1910 var overlay = document.createElement('div');
1911 overlay.id = 'hide-dialog-overlay';
1912 overlay.style.cssText = 'position:fixed;inset:0;background:rgba(0,0,0,0.5);z-index:9999;display:flex;align-items:center;justify-content:center;';
1913 var dialog = document.createElement('div');
1914 dialog.style.cssText = 'background:#fff;border-radius:12px;padding:24px;max-width:400px;width:90%;';
1915 var html = '<h3 style="margin:0 0 16px;font-size:1.1em;">投稿を非表示にする</h3>';
1916 html += '<label style="display:block;margin-bottom:8px;font-weight:600;font-size:0.9em;">非表示の理由</label>';
1917 html += '<input type="text" id="hide-reason" style="width:100%;padding:8px;border:1px solid #d1d5db;border-radius:8px;margin-bottom:12px;font-size:0.9em;box-sizing:border-box;" placeholder="理由を入力" />';
1918 html += '<div style="display:flex;gap:8px;margin-top:16px;justify-content:flex-end;">';
1919 html += '<button type="button" id="hide-cancel-btn" style="padding:8px 16px;border:1px solid #d1d5db;border-radius:8px;background:#fff;cursor:pointer;">キャンセル</button>';
1920 html += '<button type="button" id="hide-submit-btn" style="padding:8px 16px;border:none;border-radius:8px;background:#d97706;color:#fff;cursor:pointer;font-weight:600;">非表示にする</button>';
1921 html += '<button type="button" id="hide-warn-btn" style="padding:8px 16px;border:none;border-radius:8px;background:#dc2626;color:#fff;cursor:pointer;font-weight:600;">非表示+警告</button>';
1922 html += '</div>';
1923 dialog.innerHTML = html;
1924 overlay.appendChild(dialog);
1925 document.body.appendChild(overlay);
1926 overlay.addEventListener('click', function(e) { if (e.target === overlay) overlay.remove(); });
1927 document.getElementById('hide-cancel-btn').addEventListener('click', function() { overlay.remove(); });
1928 function doHide(action) {
1929 var reason = document.getElementById('hide-reason').value || '管理者判断';
1930 window.location.href = '/bin/view/SeitokaiCode/ModerationAction?action=' + action + '&targetPage=' + encodeURIComponent(targetPage) + '&targetPost=' + postObjNum + '&reason=' + encodeURIComponent(reason) + '&form_token=' + encodeURIComponent(token);
1931 }
1932 document.getElementById('hide-submit-btn').addEventListener('click', function() { doHide('hide'); });
1933 document.getElementById('hide-warn-btn').addEventListener('click', function() { doHide('hide-warn'); });
1934 }
1935 </script>
1936 {{/html}}
1937 {{/velocity}}