3232$ rankingSettings = new RankingSettings ();
3333$ message = '' ;
3434$ error = '' ;
35+ $ selectedView = selectedRankingView ();
3536$ selectedType = selectedRankingType ($ rankingSettings );
3637
3738if ($ _SERVER ['REQUEST_METHOD ' ] === 'POST ' ) {
39+ $ selectedView = 'controls ' ;
3840 $ postedType = isset ($ _POST ['type ' ]) ? (string ) $ _POST ['type ' ] : 'sites ' ;
3941 $ selectedType = supportedRankingType ($ rankingSettings , $ postedType );
4042 $ token = isset ($ _POST ['csrf_token ' ]) ? (string ) $ _POST ['csrf_token ' ] : null ;
@@ -103,6 +105,13 @@ function requestIp(): string
103105 return (string ) ($ _SERVER ['REMOTE_ADDR ' ] ?? 'unknown ' );
104106}
105107
108+ function selectedRankingView (): string
109+ {
110+ $ view = isset ($ _GET ['view ' ]) ? (string ) $ _GET ['view ' ] : 'controls ' ;
111+
112+ return in_array ($ view , ['controls ' , 'analytics ' ], true ) ? $ view : 'controls ' ;
113+ }
114+
106115function selectedRankingType (RankingSettings $ settings ): string
107116{
108117 $ type = isset ($ _GET ['type ' ]) ? (string ) $ _GET ['type ' ] : 'sites ' ;
@@ -273,6 +282,17 @@ function renderWeightInputs(array $weights): string
273282 </div>
274283 </section>
275284
285+ <nav class="adminPageTabs" aria-label="Ranking sections">
286+ <a class="<?php echo $ selectedView === 'controls ' ? 'active ' : '' ; ?> "
287+ href="ranking.php?view=controls&type=<?php echo h ($ selectedType ); ?> ">
288+ Controls
289+ </a>
290+ <a class="<?php echo $ selectedView === 'analytics ' ? 'active ' : '' ; ?> "
291+ href="ranking.php?view=analytics&type=<?php echo h ($ selectedType ); ?> ">
292+ Analytics
293+ </a>
294+ </nav>
295+
276296 <?php if ($ message !== '' ): ?>
277297 <p class="adminAlert adminAlertSuccess"><?php echo h ($ message ); ?> </p>
278298 <?php endif ; ?>
@@ -281,10 +301,11 @@ function renderWeightInputs(array $weights): string
281301 <p class="adminAlert adminAlertDanger"><?php echo h ($ error ); ?> </p>
282302 <?php endif ; ?>
283303
284- <?php if ($ analyticsError !== '' ): ?>
304+ <?php if ($ selectedView === ' analytics ' && $ analyticsError !== '' ): ?>
285305 <p class="adminAlert adminAlertWarning"><?php echo h ($ analyticsError ); ?> </p>
286306 <?php endif ; ?>
287307
308+ <?php if ($ selectedView === 'controls ' ): ?>
288309 <section class="adminPanel">
289310 <div class="adminPanelHeader">
290311 <div>
@@ -293,15 +314,20 @@ function renderWeightInputs(array $weights): string
293314 </div>
294315 </div>
295316
296- <div class="rankingTabs" role="list">
297- <?php foreach ($ rankingSettings ->supportedTypes () as $ type ): ?>
298- <a class="<?php echo $ type === $ selectedType ? 'active ' : '' ; ?> "
299- href="ranking.php?type=<?php echo h ($ type ); ?> "
300- role="listitem">
301- <?php echo h (ucfirst ($ type )); ?>
302- </a>
303- <?php endforeach ; ?>
304- </div>
317+ <form class="adminForm adminSelectForm" action="ranking.php" method="get">
318+ <input type="hidden" name="view" value="controls">
319+ <label for="ranking-type">Vertical</label>
320+ <select id="ranking-type" class="adminSelect" name="type" onchange="this.form.submit()">
321+ <?php foreach ($ rankingSettings ->supportedTypes () as $ type ): ?>
322+ <option value="<?php echo h ($ type ); ?> " <?php echo $ type === $ selectedType ? 'selected ' : '' ; ?> >
323+ <?php echo h (ucfirst ($ type )); ?>
324+ </option>
325+ <?php endforeach ; ?>
326+ </select>
327+ <noscript>
328+ <button class="adminSecondaryButton" type="submit">Load</button>
329+ </noscript>
330+ </form>
305331
306332 <form action="ranking.php" method="post" class="adminForm rankingForm">
307333 <input type="hidden" name="csrf_token" value="<?php echo h ($ csrfToken ); ?> ">
@@ -329,7 +355,9 @@ function renderWeightInputs(array $weights): string
329355 </div>
330356 </div>
331357 </section>
358+ <?php endif ; ?>
332359
360+ <?php if ($ selectedView === 'analytics ' ): ?>
333361 <section class="adminPanel">
334362 <div class="adminPanelHeader">
335363 <div>
@@ -360,6 +388,7 @@ function renderWeightInputs(array $weights): string
360388 </section>
361389 </div>
362390 </section>
391+ <?php endif ; ?>
363392 </main>
364393 </div>
365394</body>
0 commit comments