Sfoglia il codice sorgente

* Improved album list.
* New album form.

seavenois 9 anni fa
parent
commit
bb125ac152
3 ha cambiato i file con 215 aggiunte e 66 eliminazioni
  1. 50 61
      www-admin/css/galeria.css
  2. 95 1
      www-admin/galeria/add/add.php
  3. 70 4
      www-admin/galeria/index.php

+ 50 - 61
www-admin/css/galeria.css

@@ -1,96 +1,85 @@
-div.album_list{
-	display:inline-block;
-	vertical-align:	bottom;
-}
-
-/* Translate page */
+/* Album list */
 
-div#translation_instructions{
-	text-align:	center;
+table#album_list{
+        border-collapse:        collapse;
+        margin:                         0.5em;
 }
 
-div#translation_instructions ul{
-	display:	inline-block;
-	text-align:	left;
+table#album_list td, th{
+        border:         1px solid black;
+        padding:        0.5em;
 }
 
-div#translation_instructions ul li{
-	margin-top: 0.5em;
+table#album_list th{
+        background-color:       #66aaff;
 }
 
-table#table_translate_languages td.translate_language{
-	min-width:			30%;
-	border-collapse:	collapse;
-	border:				none;
-	vertical-align:		top;
+table#album_list td.album_column_title{
+        width:  10%;
 }
 
-table#table_translate_photos{
-	border-collapse:	collapse;
+table#album_list td.album_column_text{
+        width:  25%;
 }
 
-table#table_translate_photos td.details{
-	width:	24%;
-	border:	1px solid #000000;
-	vertical-align:	top;
+table#album_list td.album_column_text ul{
+        margin:         0;
 }
 
-table#table_translate_photos td.image{
-	max-width:		8.5em;
-	border:			1px solid #000000;
-	vertical-align:	top;
+table#album_list td.album_column_text li{
+        margin:         0.5em 0.1em 0 0.2em;
+        font-size:      80%;
+        font-style:     italic;
 }
 
-table#table_translate_photos textarea{
-	width:		100%;
-	height:		100%;
-	min-height:	6em;
-	resize:		none;
+table#album_list td.album_column_text img{
+        max-width:      5em;
+        max-height:     2em;
+        border:         0.1em solid black;
+        margin:         0.05em;
 }
 
-table#table_translate_photos img{
-	min-width:	8em;
-	min-height:	6em;
-	float:		right;
-	border:		1px solid black;
-	resize:		none;
+table#album_list td.album_column_details{
+        font-size:      80%;
+        width:          10%;
+        text-align:     center;
 }
 
-div.translate_row_title{
-	height:	3em;
+table#album_list td.album_column_translations{
+        width:          10%;
+        text-align:     center;
 }
 
-div.translate_row_description{
-	height:		12em;
-	overflow: 	auto;
+table#album_list td.album_column_action{
+        width:          10%;
+        text-align:     center;
 }
 
-div.translate_row_description p{
-	font-size:	80%;
+table#album_list td.album_column_action input{
+        margin:         0.05em;
+        padding:        0.06em;
+        font-size:      70%
 }
 
-div.translate_row_description textarea{
-	width:	100%;
-	height:	80%;
-    resize:	none;
+table#album_list form{
+        margin: 0;
 }
 
-
-div.translate_row_itinerary table td textarea{
-	width:	100%;
-	height:	100%;
-	resize:	none;
+table#album_list td.album_column_action input[type="button"], input[type="submit"]{
+        width:                  90%;
+        margin-top:             0.2em;
+        margin-bottom:  0.2em;
 }
 
-
 div#translate_controls{
-	margin-top:		20px;
-	margin-bottom:	20px;
-	text-align:		center;
+        width:                  50%;
+        margin-left:    auto;
+        margin-right:   auto;
+        text-align:             center;
 }
 
 div#translate_controls input{
-	margin:	20px;
+        width:          100%;
+        margin-top:     1em;
 }
 
-xmp{ white-space:pre-wrap; word-wrap:break-word; }

+ 95 - 1
www-admin/galeria/add/add.php

@@ -1 +1,95 @@
- 
+<?php
+	$http_host = $_SERVER['HTTP_HOST'];
+	include("../../functions.php");
+	$con = startdb('rw');
+	if (!checkSession($con)){
+		header("Location: /index.php");
+		exit (-1);
+	}
+	else{
+		
+		//Get POST data
+		$title_es = mysqli_real_escape_string($con, $_POST['title_es']);
+		$title_eu = mysqli_real_escape_string($con, $_POST['title_eu']);
+		$title_en = mysqli_real_escape_string($con, $_POST['title_en']);
+		$text_es = mysqli_real_escape_string($con, $_POST['text_es']);
+		$text_eu = mysqli_real_escape_string($con, $_POST['text_eu']);
+		$text_en = mysqli_real_escape_string($con, $_POST['text_en']);
+		$comments = mysqli_real_escape_string($con, $_POST['comments']);
+		$visible = mysqli_real_escape_string($con, $_POST['visible']);
+		$public = mysqli_real_escape_string($con, $_POST['public']);
+		$populate = mysqli_real_escape_string($con, $_POST['populate'])
+		
+		//Check spanish title and generate permalink
+		if ($title_es == null)
+			exit();
+		else{
+			$permalink = permalink($title_es);
+			$i = 2;
+			$ok = false;
+			$tmppermalink = $permalink;
+			while ($ok == false){
+				$query = mysqli_query($con, "SELECT id FROM post WHERE permalink = '$tmppermalink';");
+				if (mysqli_num_rows($query) > 0){
+					$tmppermalink = $permalink . "-" . $i;
+					$i ++;
+				}
+				else{
+					$permalink = $tmppermalink;
+					$ok = true;
+				}
+			}
+		}
+		
+		//Check titles with no text
+		if (strlen($title_eu) > 0 && strlen($text_eu) < 1)
+			exit();
+		if (strlen($title_en) > 0 && strlen($text_en) < 1)
+			exit();
+		
+		//Check text with no titles
+		if (strlen($text_eu) > 0 && strlen($title_eu) < 1)
+			exit();
+		if (strlen($text_en) > 0 && strlen($title_en) < 1)
+			exit();
+		
+		//Check booleans and assign default values if not
+		if ($comments == 'off')
+			$comments = 0;
+		else
+			$comments = 1;
+		if ($visible == 'off')
+			$visible = 0;
+		else
+			$visible = 1;
+		if ($public == 'on')
+			$public = 1;
+		else
+			$public = 0;
+		if ($populate == 'on')
+                        $populate = 1;
+                else
+                        $populate = 0;
+	
+		// If no translations, same text in all languages
+		if (strlen($text_eu) == 0){
+			$text_eu = $text_es;
+			$title_eu = $title_es; 
+		}
+		
+		if (strlen($text_en) == 0){
+			$text_en = $text_es;
+			$title_en = $title_es; 
+		}
+		
+		//Insert into database and get id
+		mysqli_query($con, "INSERT INTO album (permalink, title_es, title_eu, title_en, text_es, text_eu, text_en, open, visible, comments) VALUES ('$permalink', '$title_es', '$title_eu', '$title_en', '$text_es', '$text_eu', '$text_en', $public, $visible, $comments);");
+		$res_album = mysqli_query($con, "SELECT id FROM album WHERE permalink = '$permalink' ORDER BY dtime DESC LIMIT 1;");
+		$row_album = mysqli_fetch_array($res_album);
+		$album_id = $row_album['id'];
+		
+		version();
+		
+		header("Location: /galeria/");
+	}
+?>

+ 70 - 4
www-admin/galeria/index.php

@@ -1,15 +1,81 @@
+<?php
+	$http_host = $_SERVER['HTTP_HOST'];
+	$default_host = substr($http_host, 0, strpos($http_host, ':'));
+	include("../functions.php");
+	$con = startdb();
+	if (!checkSession($con)){
+		header("Location: /index.php");
+		exit (-1);
+	}
+	else{
+?>
 <html>
 	<head>
 		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
 		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Nuevo post - Administracion</title>
+		<title>Galeria - Administracion</title>
 		<!-- CSS files -->
 		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/blog.css"/>
+		<link rel="stylesheet" type="text/css" href="/css/galeria.css"/>
 		<!-- CSS for mobile version -->
 		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
+		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/galeria.css"/>
+		<!-- Script files -->
+		<script type="text/javascript" src="/script/ui.js"></script>
 	</head>
 	<body>
+		<?php include('../toolbar.php'); ?>
+		<div id='content'>
+			<div class="section">
+				<h3 class="section_title">Galer&iacute;a - <a href="/actividades/add/">A&ntilde;adir &aacute;lbum</a></h3>
+				<div class="entry">
+					<table id='album_list'>
+						<tr>
+							<th>Titulo / Texto</th>
+							<th>Detalles</th>
+							<th>Traducciones</th>
+							<th>Accion</th>
+						</tr>
+						<?php
+							$q = mysqli_query($con, "SELECT id, title_es, title_eu, title_en, description_es, description_eu, description_en, user, DATE_FORMAT(dtime, '%b %d, %Y %H:%i:%s') AS ptime, open FROM album ORDER BY dtime DESC;");
+							while ($r = mysqli_fetch_array($q)){
+								echo("<tr>\n<td class='album_column_title'>" . cutText($r['title_es'], 35, '', '') . "<br/>$r[dat]");
+								echo("<br/>" . str_replace('<br/>', ' ', cutText($r['text_es'], 60, '', '')) . "\n</td>\n");
+								$q_user = mysqli_query($con, "SELECT username FROM user WHERE id = $r[user];");
+								$r_user = mysqli_fetch_array($q_user);
+								echo("<td class='activity_column_details'>$r[ptime]<br/>\n");
+								//Count
+								$q_photos = mysqli_query($con, "SELECT count(id) AS cnt FROM photo, photo_album where album = $r[id] and photo = id;");
+								$r_photos = mysqli_fetch_array($q_photos);
+								echo("$r_photos[cnt] fotos.<br/>");
+								echo("Por $r_user[username]<br/>");
+								echo("<br/>P&uacute;blico: ");
+                                                                if ($r['open'] == 1)
+                                                                        echo("S&iacute;");
+                                                                else
+                                                                        echo("No");
+
+								echo("</td>\n<td class='gallery_column_translations'>\nEuskera: ");
+								if (strlen($r['description_eu']) == 0 || $r['description_eu'] == $r['description_es'])
+									echo("No");
+								else
+									echo("S&iacute;");
+								echo("<br/>Ingl&eacute;s: ");
+									if (strlen($r['description_en']) == 0 || $r['description_en'] == $r['description_es'])
+									echo("No");
+								else
+									echo("S&iacute;");
+								echo("\n</td>\n<td class='album_column_action'>\n<form action='/album/edit/edit.php?p=$r[id]'>\n<input type='submit' value='Editar / Traducir'/>\n</form>\n");
+								echo("<input type='button' onClick='delete_album($r[id], \"$r[title_es]\");' value='Borrar'/>");
+								echo("<form action='/album/moderate/moderate.php?p=$r[id]'>\n<input type='submit' value='Moderar comentarios'/>\n</form>");
+								echo("</td>\n</tr>");
+							}
+							
+						?>
+					</table>
+				</div>
+			</div>
+		</div>
 	</body>
-</html>
+</html>
+<?php } ?>