Robert Marshall vor 10 Jahren
Ursprung
Commit
476f7f0692

+ 39 - 0
Controller/SettingsEditor.php

@@ -0,0 +1,39 @@
+<?php
+class SettingsEditor {
+	const KEY_SPLITTER='|';
+
+	public function Index($params) {
+		$data=parse_ini_file(ApplicationSettings::SETTINGS_PATH,true);
+		return new View("SettingsEditor/index.view",array("data"=>$data));
+	}
+	
+	public function Save($params) {
+		$newSettings=array();
+		foreach ($params as $param=>$value){
+			if (strpos($param, self::KEY_SPLITTER)===false)
+				continue;
+			$setting=explode(self::KEY_SPLITTER, $param);
+			$section=$setting[0];
+			$key=$setting[1];
+			if (!isset($newSettings[$section]))
+				$newSettings[$section]=array();
+			$newSettings[$section][$key]=$value;
+		}
+		
+		$currentSettings=parse_ini_file(ApplicationSettings::SETTINGS_PATH,true);
+		foreach ($currentSettings as $section=>$setting){
+			if (!isset($newSettings[$section])){
+				$newSettings[$section]=$setting;
+				continue;
+			}
+			foreach ($setting as $key=>$value)
+				if (!isset($newSettings[$section][$key]))
+					$newSettings[$section][$key]=$value;
+		}
+		
+		rename(ApplicationSettings::SETTINGS_PATH, ApplicationSettings::SETTINGS_PATH.(int)microtime(true));
+		Helper::WriteINIFile($newSettings, ApplicationSettings::SETTINGS_PATH, true);
+		
+		header("location:/settingseditor");
+	}
+}

+ 2 - 2
View/Blog/create.view

@@ -15,8 +15,8 @@
 	});
 	});
 }@
 }@
 @ButtonsRight{
 @ButtonsRight{
-	<button type="submit" form="blogForm">
-		+
+	<button type="submit" form="blogForm" title="Save">
+		<img src="/images/save.svg" alt="Save" />
 	</button>
 	</button>
 }@
 }@
 @Body{
 @Body{

+ 6 - 9
View/Blog/index.view

@@ -1,21 +1,18 @@
 @Title{Blog}@
 @Title{Blog}@
 @ButtonsLeft{
 @ButtonsLeft{
 	<?php if ($page>1){?>
 	<?php if ($page>1){?>
-		<button onclick="window.location.href='/blog/page/<?=$page-1?>'">
-			P
+		<button onclick="window.location.href='/blog/page/<?=$page-1?>'" title="Previous Page">
+			<img src="/images/previous.svg" alt="Previous" />
 		</button>
 		</button>
 	<?php }?>
 	<?php }?>
 }@
 }@
 @ButtonsRight{
 @ButtonsRight{
-	<button onclick="window.location.href='/blog/create'">
-		+
-	</button><br/>
-	<button onclick="window.location.href='/blog/manage'">
-		M
+	<button onclick="window.location.href='/blog/manage'" title="Manage">
+		<img src="/images/library.svg" alt="Library" />
 	</button><br/>
 	</button><br/>
 	<?php if ($page<$maxPages) { ?>
 	<?php if ($page<$maxPages) { ?>
-		<button onclick="window.location.href='/blog/page/<?=$page+1?>'">
-			N
+		<button onclick="window.location.href='/blog/page/<?=$page+1?>'" title="Next Page">
+			<img src="/images/next.svg" alt="Next" />
 		</button>
 		</button>
 	<?php } ?>
 	<?php } ?>
 }@
 }@

+ 6 - 1
View/Blog/manage.view

@@ -1,4 +1,9 @@
 @Title{Blog}@
 @Title{Blog}@
+@ButtonsRight{
+	<button onclick="window.location.href='/blog/create'" title="Create">
+		<img src="/images/add.svg" alt="Add" />
+	</button>
+}@
 @Body{
 @Body{
 <form action="" method="post">
 <form action="" method="post">
 	<input type="hidden" name="formSubmitted" value="yes" />
 	<input type="hidden" name="formSubmitted" value="yes" />
@@ -14,7 +19,7 @@
 			<td><?=$post->PostId?></td>
 			<td><?=$post->PostId?></td>
 			<td><?=$post->PostTitle?></td>
 			<td><?=$post->PostTitle?></td>
 			<td><?=$post->PostTimestamp?></td>
 			<td><?=$post->PostTimestamp?></td>
-			<td><button value="<?=$post->PostId?>" name="delete">Delete</button></td>
+			<td><button value="<?=$post->PostId?>" name="delete" title="Delete"><img src="/images/delete.svg" alt="Delete" /></button></td>
 		</tr>
 		</tr>
 		<?php } ?>
 		<?php } ?>
 	</table>
 	</table>

+ 24 - 0
View/SettingsEditor/index.view

@@ -0,0 +1,24 @@
+@Title{Settings Editor}@
+@CSS{
+	td:first-child{
+		text-align:right;
+	}
+}@
+@ButtonsRight{
+	<button type="submit" form="settingsForm">
+		<img src="/images/save.svg" alt="Save" />
+	</button>
+}@
+@Body{
+<form action="/settingseditor/save" method="post" id="settingsForm">
+	<input type="hidden" value="asdasd" name="werwert" />
+	<?php foreach ($data as $sectionName=>$section){
+		echo '<h3>',$sectionName,'</h3><table>';
+		foreach ($section as $key=>$value){
+			$id=$sectionName.SettingsEditor::KEY_SPLITTER.$key;
+			echo '<tr><td><label for="',$id,'">',$key,':</label></td><td><input type="text" id="',$id,'" name="',$id,'" value="',$value,'" /></td></tr>';
+		}
+		echo '</table>';
+	}?>
+</form>
+}@

+ 41 - 0
base/Helper.php

@@ -76,4 +76,45 @@ class Helper{
 		$string=preg_replace('/[^a-zA-Z0-9]+/', '-', $string);
 		$string=preg_replace('/[^a-zA-Z0-9]+/', '-', $string);
 		return $string;
 		return $string;
 	}
 	}
+	
+	//stolen (with a few edits) from http://stackoverflow.com/questions/5695145/how-to-read-and-write-to-an-ini-file-with-php
+	public static function WriteINIFile($array,$path,$hasSections){
+		$content="";
+		if ($hasSections) {
+			foreach ($array as $key=>$elem) {
+				$content.="\n[".$key."]\n";
+				foreach ($elem as $key2=>$elem2) {
+					if (is_array($elem2)) {
+						for ($i=0; $i<count($elem2); $i++) {
+							$content.=$key2."[]=".$elem2[$i]."\n";
+						}
+					} else if ($elem2=="")
+						$content.=$key2."=\"\"\n";
+					else
+						$content.=$key2."=".$elem2."\n";
+				}
+			}
+		} else {
+			foreach ($array as $key=>$elem) {
+				if (is_array($elem)) {
+					for ($i=0; $i<count($elem); $i++) {
+						$content.=$key."[]=".$elem[$i]."\n";
+					}
+				} else if ($elem=="")
+					$content.=$key."=\"\"\n";
+				else
+					$content.=$key."=".$elem."\n";
+			}
+		}
+
+		if (!$handle=fopen($path, 'w')) {
+			return false;
+		}
+
+		$content=trim($content);
+		$success=fwrite($handle, $content);
+		fclose($handle);
+
+		return $success;
+	}
 }
 }

+ 10 - 0
images/add.svg

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+	 width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
+<path fill="#1E88E5" d="M4,6H2v14c0,1.1,0.9,2,2,2h14v-2H4V6z"/>
+<path fill="#42A5F5" d="M22,4v12c0,1.1-0.9,2-2,2H8c-1.1,0-2-0.9-2-2V4c0-1.1,0.9-2,2-2h12C21.1,2,22,2.9,22,4z"/>
+<path fill="#1E88E5" d="M22,4v12c0,1.1-0.9,2-2,2h-6V2h6C21.1,2,22,2.9,22,4z"/>
+<polygon fill="#FFFFFF" points="19,11 15,11 15,15 13,15 13,11 9,11 9,9 13,9 13,5 15,5 15,9 19,9 "/>
+</svg>

+ 12 - 0
images/delete.svg

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+	 width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
+<path fill="#9E9E9E" d="M6,19c0,1.1,0.9,2,2,2h8c1.1,0,2-0.9,2-2V6H6V19z"/>
+<polygon fill="#616161" points="19,4 15.5,4 14.5,3 9.5,3 8.5,4 5,4 5,6 19,6 "/>
+<path fill="none" d="M0,0h24v24H0V0z"/>
+<rect x="8" y="8" fill="#757575" width="2" height="11"/>
+<rect x="12" y="8" fill="#757575" width="2" height="11"/>
+<rect x="16" y="8" fill="#757575" width="2" height="11"/>
+</svg>

+ 12 - 0
images/edit.svg

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+	 width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
+<polygon fill="#CFD8DC" points="17.266,10.453 19.094,8.656 15.344,4.891 13.703,6.547 "/>
+<polygon fill="#78909C" points="17.811,9.94 6.75,21 3,21 3,17.25 14.061,6.19 "/>
+<path fill="#B0BEC5" d="M20.71,7.04c0.39-0.39,0.39-1.02,0-1.41l-2.34-2.34c-0.39-0.39-1.021-0.39-1.41,0l-1.83,1.83l3.75,3.75
+	L20.71,7.04z"/>
+<path fill="none" d="M0,0h24v24H0V0z"/>
+<polygon fill="#B0BEC5" points="6.75,21 3,21 3,17.25 "/>
+</svg>

+ 13 - 0
images/library.svg

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+	 width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
+<path fill="none" d="M0,0h24v24H0V0z"/>
+<path fill="#6D4C41" d="M4,6H2v14c0,1.1,0.9,2,2,2h14v-2H4V6z"/>
+<path fill="#8D6E63" d="M22,4v12c0,1.1-0.9,2-2,2H8c-1.1,0-2-0.9-2-2V4c0-1.1,0.9-2,2-2h12C21.1,2,22,2.9,22,4z"/>
+<path fill="#6D4C41" d="M22,4v12c0,1.1-0.9,2-2,2h-6.04V2H20C21.1,2,22,2.9,22,4z"/>
+<rect x="9" y="9" fill="#FFFFFF" width="10" height="2"/>
+<rect x="9" y="13" fill="#FFFFFF" width="6" height="2"/>
+<rect x="9" y="5" fill="#FFFFFF" width="10" height="2"/>
+</svg>

+ 8 - 0
images/next.svg

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+	 width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
+<path fill="#FFFFFF" d="M10,6L8.59,7.41L13.17,12l-4.58,4.59L10,18l6-6L10,6z"/>
+<path fill="none" d="M0,0h24v24H0V0z"/>
+</svg>

+ 8 - 0
images/previous.svg

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+	 width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
+<path fill="#FFFFFF" d="M15.41,7.41L14,6l-6,6l6,6l1.41-1.41L10.83,12L15.41,7.41z"/>
+<path fill="none" d="M0,0h24v24H0V0z"/>
+</svg>

+ 15 - 0
images/save.svg

@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+	 width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
+<g id="Capa_1_1_">
+	<path fill="none" d="M0,0h24v24H0V0z"/>
+	<path fill="#37474F" d="M21,7v12c0,1.1-0.9,2-2,2H5c-1.11,0-2-0.9-2-2V5c0-1.1,0.89-2,2-2h12L21,7z"/>
+	<path opacity="0.5" fill="#455A64" d="M11.96,3v18H5c-1.11,0-2-0.9-2-2V5c0-1.1,0.89-2,2-2H11.96z"/>
+	<path fill="#B0BEC5" d="M15,16c0,1.66-1.34,3-3,3h-0.05C10.31,18.97,9,17.641,9,16s1.31-2.97,2.95-3H12C13.66,13,15,14.34,15,16z"
+		/>
+	<rect x="5" y="5" fill="#B0BEC5" width="10" height="4"/>
+	<path fill="#90A4AE" d="M15,16c0,1.66-1.34,3-3,3h-0.05v-6H12C13.66,13,15,14.34,15,16z"/>
+</g>
+</svg>

+ 15 - 14
style.css

@@ -57,20 +57,6 @@ button:hover{
 	cursor: hand;
 	cursor: hand;
 }
 }
 
 
-#buttons button{
-	border-radius: 50%;
-	display: inline-block;
-	text-align: center;
-	box-shadow: 0px 2px 3px 0px rgba(0,0,0,0.25);
-	vertical-align: middle;
-	border:none;
-	background:#F44336;
-	width:40px;
-	height:40px;
-	color: white;
-	font-size: 24px
-}
-
 #menu{
 #menu{
 	background:#fafafa;
 	background:#fafafa;
 	width:240px;
 	width:240px;
@@ -147,6 +133,21 @@ button:hover{
 	margin-top:20px;
 	margin-top:20px;
 }
 }
 
 
+#buttons button{
+	border-radius: 50%;
+	display: inline-block;
+	text-align: center;
+	box-shadow: 0px 2px 3px 0px rgba(0,0,0,0.25);
+	vertical-align: middle;
+	border:none;
+	background:#F44336;
+	width:40px;
+	height:40px;
+	color: white;
+	font-size: 24px;
+	line-height: 24px;
+}
+
 .header {
 .header {
 	height:64px;
 	height:64px;
 	background:#F44336;
 	background:#F44336;