Browse Source

Lista istanze a tabella

pezcurrel 4 years ago
parent
commit
5f5187bbd0
2 changed files with 130 additions and 6 deletions
  1. 82 4
      web/admin/instances.php
  2. 48 2
      web/admin/theme.css

+ 82 - 4
web/admin/instances.php

@@ -7,16 +7,94 @@ require('include/menu.php');
 buildmenu($menu);
 
 require('include/myconn.php');
-$res=mysqli_query($link,'SELECT * FROM Instances ORDER BY URI ASC')
-	or muoribene(mysqli_error($link).'<br>'.$btl,false);
+
+function nully($val,$filter='') {
+	if (!is_null($val)) {
+		if ($filter=='strip') {
+			return(strip_tags($val,'<a><br><ol><ul><li>'));
+		} elseif ($filter=='htmlent') {
+			return(htmlentities($val));
+		} else {
+			return($val);
+		}
+	} else {
+		return('<span class="nully">Non definito</span>');
+	}
+}
+
+function booly($pre,$val,$nottoobad=false,$invcol=false) {
+	if ($val) {
+		if (!$invcol) {
+			$p='<p class="good">';
+		} else {
+			if (!$nottoobad) {
+				$p='<p class="bad">';
+			} else {
+				$p='<p class="neut">';
+			}
+		}
+		return($p.$pre.'SI</p>');
+	} else {
+		if (!$invcol) {
+			if (!$nottoobad) {
+				$p='<p class="bad">';
+			} else {
+				$p='<p class="neut">';
+			}
+		} else {
+			$p='<p class="good">';
+		}
+		return($p.$pre.'NO</p>');
+	}
+}
+
+$cols=array(
+	'New'=>array('name'=>'Nuova','type'=>'bool'),
+	'Good'=>array('name'=>'Papabile','type'=>'bool'),
+	'Chosen'=>array('name'=>'Scelta','type'=>'bool'),
+	'Visible'=>array('name'=>'Visibile','type'=>'bool'),
+	'Blacklisted'=>array('name'=>'Blacklistata','type'=>'bool'),
+	'URI'=>array('name'=>'URI','type'=>'text'),
+	'Title'=>array('name'=>'Titolo','type'=>'text'),
+	'ShortDesc'=>array('name'=>'Descrizione breve','type'=>'text'),
+	'LongDesc'=>array('name'=>'Descrizione lunga','type'=>'text'),
+	'OurDesc'=>array('name'=>'Descrizione nostra','type'=>'text'),
+	'PlaceID'=>array('name'=>'Località','type'=>'select'),
+	'Email'=>array('name'=>'Email di contatto','type'=>'text'),
+	'Software'=>array('name'=>'Software','type'=>'text'),
+	'Version'=>array('name'=>'Versione','type'=>'text'),
+	'UserCount'=>array('name'=>'Utenti','type'=>'number'),
+	'StatusCount'=>array('name'=>'Stati','type'=>'number'),
+	'DomainCount'=>array('name'=>'Istanze note','type'=>'number'),
+	'ActiveUsersMonth'=>array('name'=>'Utenti attivi (mese)','type'=>'number'),
+	'ActiveUsersHalfYear'=>array('name'=>'Utenti attivi (6 mesi)','type'=>'number'),
+	'Thumb'=>array('name'=>'Logo','type'=>'image'),
+	'RegOpen'=>array('name'=>'Registrazioni aperte','type'=>'bool'),
+	'RegReqApproval'=>array('name'=>'Approvazione registrazioni','type'=>'bool'),
+	'MaxTootChars'=>array('Name'=>'Limite caratteri','type'=>'number'),
+
+);
+
+$res=mysqli_query($link,'SELECT * FROM Instances LEFT JOIN Places ON Places.ID=PlaceID ORDER BY URI ASC')
+	or muoribene(mysqli_error($link),false);
 mysqli_close($link);
 if (mysqli_num_rows($res)<1) {
 	$out='<p>Nessuna istanza da mostrare.</p>'.N;
 } else {
-	$out='<table>'.N;
+	$out='<table id="bigtab">'.N;
+	$out.='<thead><tr><th class="tdattr">Attributi</th><th>'.$cols['URI']['name'].'</th><th>'.$cols['Title']['name'].'</th><th>'.$cols['OurDesc']['name'].'</th><th>'.$cols['ShortDesc']['name'].'</th><th>'.$cols['LongDesc']['name'].'</th></tr></thead>'.N;
+	$out.='<tbody>'.N;
 	while ($row=mysqli_fetch_assoc($res)) {
-		$out.='<tr><td>'.$row['URI'].'</td></tr>'.N;
+		$attr=booly($cols['Blacklisted']['name'].': ',$row['Blacklisted'],false,true).N;
+		$attr.=booly($cols['New']['name'].': ',$row['New'],true).N;
+		$attr.=booly($cols['Good']['name'].': ',$row['Good']).N;
+		$attr.=booly($cols['Chosen']['name'].': ',$row['Chosen']).N;
+		$attr.=booly($cols['Visible']['name'].': ',$row['Visible']).N;
+		$attr.=booly($cols['RegOpen']['name'].': ',$row['RegOpen']).N;
+		$attr.=booly($cols['RegReqApproval']['name'].': ',$row['RegReqApproval'],true,true).N;
+		$out.='<tr><td class="tdattr">'.$attr.'</td><td><a href="https://'.$row['URI'].'" target="_blank">'.$row['URI'].'</a></td><td>'.nully($row['Title'],'strip').'</td><td>'.nully($row['OurDesc'],'htmlent').'</td><td>'.nully($row['ShortDesc'],'strip').'</td><td>'.nully($row['LongDesc'],'strip').'</td></tr>'.N;
 	}
+	$out.='</tbody>'.N;
 	$out.='</table>'.N;
 }
 

+ 48 - 2
web/admin/theme.css

@@ -11,7 +11,7 @@ body {
   	background-color: white;
 	color: black;
 	font-family: Arial, Helvetica, Sans-Serif, sans;
-	font-size: 14pt;
+	font-size: 12pt;
 	margin: 0;
 	padding: 5px;
 	height: 100%
@@ -31,6 +31,49 @@ ul {
 	padding-left: 0;
 	margin-left: 14pt;
 }
+#bigtab {
+	background-color: white;
+	font-size: 10pt;
+}
+#bigtab thead {
+	padding: 3px;
+	position: sticky;
+	top: 40px;
+	color: white;
+	height: 30px;
+}
+#bigtab th {
+	background-color: #916f6f;
+	border-radius: 5px;
+}
+#bigtab td {
+	padding: 3px;
+	text-align: left;
+	vertical-align: top;
+	word-wrap: break-word;
+	max-width: 300px;
+	min-width: 200px;
+	background-color: lightgrey;
+	border-radius: 5px;
+}
+#bigtab .tdattr {
+	min-width: 130px;
+	max-width: 130px;
+}
+.good, .bad, .neut {
+	padding: 3px;
+	margin-bottom: 3px;
+	border-radius: 5px;
+}
+.good {
+	background-color: #87DE87;
+}
+.bad {
+	background-color: #DE8787;
+}
+.neut {
+	background-color: #FFCCAA;
+}
 #fullscreen, #fullscreenm {
 	width: 100%;
 	height: 100%;
@@ -132,7 +175,10 @@ input {
 	line-height: 40px;
 	vertical-align: middle;
 }
-
+.nully {
+	font-style: italic;
+	color: #333333;
+}
 
 #hmenu {
 	font-size: 14pt;