summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorBjörn Geiger2011-07-05 13:46:50 +0200
committerBjörn Geiger2011-07-05 13:46:50 +0200
commit8a66fc8e7bca6c8973353e557d4e65c31efa2d14 (patch)
tree5d93d2bc4ef899ea5dbfb6b3cf10d9693e646e6c /library
parentApikey im Eventcontroller wird nun aus der Session genommen (diff)
downloadpoolctrl-8a66fc8e7bca6c8973353e557d4e65c31efa2d14.tar.gz
poolctrl-8a66fc8e7bca6c8973353e557d4e65c31efa2d14.tar.xz
poolctrl-8a66fc8e7bca6c8973353e557d4e65c31efa2d14.zip
Notifier und Pagination hinzugefügt
Diffstat (limited to 'library')
-rw-r--r--library/Poolctrl/Notifier.php178
-rw-r--r--library/Poolctrl/Pagination.php98
2 files changed, 276 insertions, 0 deletions
diff --git a/library/Poolctrl/Notifier.php b/library/Poolctrl/Notifier.php
new file mode 100644
index 0000000..77de708
--- /dev/null
+++ b/library/Poolctrl/Notifier.php
@@ -0,0 +1,178 @@
+<?php
+/*
+ * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
+ * This program is free software distributed under the GPL version 2.
+ * See http://gpl.openslx.org/
+ *
+ * If you have any feedback please consult http://feedback.openslx.org/ and
+ * send your suggestions, praise, or complaints to feedback@openslx.org
+ *
+ * General information about OpenSLX can be found at http://openslx.org/
+ */
+
+class Pool_Notifier{
+
+
+ public function notify($action,$result){
+
+ switch($action){
+ default:
+ switch($result){
+ case "forbidden":
+ $result = "errorbox";
+ break;
+ case "ok":
+ $result = "okbox";
+ break;
+ case "error":
+ $result = "warningbox";
+ break;
+ case "info":
+ $result = "infobox";
+ break;
+ }
+ $result = "<div class='$result'>$action</div>";
+ break;
+ case "delete":
+ switch($result){
+ case "forbidden":
+ $result = "<div class='errorbox'>Not allowed to delete this</div>";
+ break;
+ case "ok":
+ $result = "<div class='okbox'>Delete sucessful</div>";
+ break;
+ case "error":
+ $result = "<div class='warningbox'>Delete failed</div>";
+ break;
+ }
+ break;
+ case "view":
+ switch($result){
+ case "forbidden":
+ $result = "<div class='errorbox'>Not allowed to see this</div>";
+ break;
+ }
+ break;
+ case "download":
+ switch($result){
+ case "forbidden":
+ $result = "<div class='errorbox'>Not allowed to download this</div>";
+ break;
+ case "404":
+ $result = "<div class='errorbox'>The Resource was not found on the Server</div>";
+ break;
+ case "error":
+ $result = "<div class='errorbox'>Download failed</div>";
+ break;
+ }
+ break;
+ case "modify":
+ switch($result){
+ case "forbidden":
+ $result = "<div class='errorbox'>Not allowed to modify this</div>";
+ break;
+ case "ok":
+ $result = "<div class='okbox'>Modify sucessful</div>";
+ break;
+ case "error":
+ $result = "<div class='warningbox'>Modify failed</div>";
+ break;
+ }
+ break;
+ case "create":
+ switch($result){
+ case "forbidden":
+ $result = "<div class='errorbox'>Not allowed to create this</div>";
+ break;
+ case "ok":
+ $result = "<div class='okbox'>Creation sucessful</div>";
+ break;
+ case "error":
+ $result = "<div class='warningbox'>Creation failed</div>";
+ break;
+ case "file":
+ $result = "<div class='errorbox'>The File must be greater than 0 bytes</div>";
+ break;
+ }
+ break;
+ case "update":
+ switch($result){
+ case "forbidden":
+ $result = "<div class='errorbox'>Not allowed to update this</div>";
+ break;
+ case "404":
+ $result = "<div class='errorbox'>The Resource was not found on the specified path</div>";
+ break;
+ case "ok":
+ $result = "<div class='okbox'>Update sucessful</div>";
+ break;
+ case "error":
+ $result = "<div class='warningbox'>Update failed</div>";
+ break;
+ }
+ break;
+ case "serial":
+ switch($result){
+ case "noserial":
+ $result = "<div class='errorbox'>Your PreBoot is broken, please download a new Version or contact a PBS Administrator</div>";
+ break;
+ }
+ break;
+ case "link":
+ switch($result){
+ case "forbidden":
+ $result = "<div class='errorbox'>Not allowed to link this</div>";
+ break;
+ case "ok":
+ $result = "<div class='okbox'>Link sucessful</div>";
+ break;
+ case "error":
+ $result = "<div class='warningbox'>Link failed</div>";
+ break;
+ }
+ break;
+ case "unlink":
+ switch($result){
+ case "forbidden":
+ $result = "<div class='errorbox'>Not allowed to unlink this</div>";
+ break;
+ case "ok":
+ $result = "<div class='okbox'>Unlink sucessful</div>";
+ break;
+ case "error":
+ $result = "<div class='warningbox'>Unlink failed</div>";
+ break;
+ }
+ break;
+ case "json":
+ switch($result){
+ default:{
+ $result = unserialize($result);
+
+ $result2 = "<div class='infobox'>";
+ $result2 .= "<table class='json'>";
+ $result2 .= "<tr><td><b>info</b>: </td><td>".$result['info']."</td></tr>";
+ $result2 .= "<tr><td><b>kernel</b>: </td><td><a href=".$result['kernel'].">".$result['kernel']."<a></td></tr>";
+ $result2 .= "<tr><td><b>initramfs</b>: </td><td><a href=".$result['initramfs'].">".$result['initramfs']."<a></td></tr>";
+ $result2 .= "<tr><td><b>kcl</b>: </td><td><a href=".$result['kcl'].">".$result['kcl']."<a></td></tr>";
+ $result2 .= "<tr><td><b>config</b>: </td><td>".$result['config']."</td></tr>";
+ $result2 .= "</table>";
+ $result2 .= "</div>";
+ $result = $result2;
+ }
+ break;
+ case "forbidden":
+ $result = "<div class='errorbox'>Not allowed to display ressources</div>";
+ break;
+ case "error":
+ $result = "<div class='warningbox'>Displaying ressources failed</div>";
+ break;
+ }
+ break;
+ }
+ return $result;
+
+ }
+}
+
+?>
diff --git a/library/Poolctrl/Pagination.php b/library/Poolctrl/Pagination.php
new file mode 100644
index 0000000..7f1a596
--- /dev/null
+++ b/library/Poolctrl/Pagination.php
@@ -0,0 +1,98 @@
+<?php
+/*
+ * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
+ * This program is free software distributed under the GPL version 2.
+ * See http://gpl.openslx.org/
+ *
+ * If you have any feedback please consult http://feedback.openslx.org/ and
+ * send your suggestions, praise, or complaints to feedback@openslx.org
+ *
+ * General information about OpenSLX can be found at http://openslx.org/
+ */
+
+class Pool_Pagination{
+
+ private $element;
+ private $perpage;
+ private $requestpage;
+ private $maxNumber;
+ private $numpages;
+ private $pageUrl;
+
+ public function pagination($url=null,$selected=null,$max=null){
+ if($selected == null)
+ $selected = $this->requestpage;
+ if($max == null)
+ $max = $this->numpages;
+ if($url == null)
+ $url = $this->pageUrl;
+
+ #print_a($url,$selected,$max);
+
+ $str = "<div class='pbs_pagination'>";
+ if ( 1 <= $selected){
+ $str .= "<a href='$url/page/0' >&lt;&lt;</a>";
+ $str .= "<a href='$url/page/".(($selected)-1)."' rel='next'>&lt;</a>";
+ }else{
+ $str .= "<span class='disabled'>&lt;&lt;</span>";
+ $str .= "<span class='disabled'>&lt;</span>";
+ }
+
+ #
+ $rightleft = 2;
+ for($i=0;$i<($max);$i++){
+ if($selected == $i)
+ $str .= "<a class='active'>".($i+1) ."</a> ";
+ else if($i >= $selected -$rightleft && $i <= $selected+$rightleft)
+ $str .= "<a href='$url/page/".($i)."'>".($i+1) ."</a> ";
+ }
+
+ #
+ if ( $max-2 >= $selected){
+ $str .= "<a href='$url/page/".(($selected)+1)."'>&gt;</a> ";
+ $str .= "<a href='$url/page/".($max-1)."'>&gt;&gt;</a> ";
+ }else{
+ $str .= "<span class='disabled'>&gt;</span> ";
+ $str .= "<span class='disabled'>&gt;&gt;</span> ";
+ }
+
+ $str .= "</div>";
+ return $str;
+ }
+ public function setPerPage($perpage){
+ $this->perpage = $perpage;
+ return $this;
+ }
+ public function getPerPage(){
+ return $this->perpage;
+ }
+ public function setRequestPage($requestpage){
+ if($requestpage < 0 || !is_numeric($requestpage) )
+ $requestpage = 0;
+ if($requestpage >= $this->numpages)
+ $requestpage = $this->numpages-1;
+ $this->requestpage = $requestpage;
+ return $this;
+ }
+ public function getRequestPage(){
+ return $this->requestpage;
+ }
+ public function setElement($element){
+ $this->element = $element;
+ $this->maxNumber = count($element);
+ $this->numpages = ceil(count($element)/$this->perpage);
+ return $this;
+ }
+ public function getStartItem(){
+ return $this->requestpage * $this->perpage;
+ }
+ public function getElements(){
+ return array_slice($this->element,$this->getStartItem(),$this->getPerPage(),true);
+ }
+ public function setPageUrl($url){
+ $this->pageUrl = $url;
+ return $this;
+ }
+
+}
+