View Single Post
  #1  
Old 01-28-2014, 01:31 PM
anno1986 anno1986 is offline
Member
 
Join Date: Jan 2014
Posts: 3
Gender: Male
Credits: 658
anno1986 is on a distinguished road
Smile Paging in admin panel für images

The following patch provides paging for the image menu in admin panel.
Useful for slow connections and/or many pictures stored in filemap database table

diff -ruw v1.3.4/admincp/image.php src/admincp/image.php
Code:
--- v1.3.4/admincp/image.php	2013-08-24 23:29:48.000000000 +0200
+++ src/admincp/image.php	2014-01-26 18:18:36.000000000 +0100
@@ -103,11 +103,20 @@
 
 	public function manage(){
 	    $mysidia = Registry::get("mysidia");
-		$stmt = $mysidia->db->select("filesmap", array("id", "wwwpath"));
+	    // anno1986 added paging for images
+	    $total = $mysidia->db->select("filesmap", array("id"))->rowCount();
+	    $pagination = new Pagination($total, 9, "admincp/image/delete");
+        $pagination->setPage($mysidia->input->get("page"));
+        // anno1986 added paging for images
+		$stmt = $mysidia->db->select("filesmap", array("id", "wwwpath"), "1 LIMIT {$pagination->getLimit()},{$pagination->getRowsperPage()}");
 		$filesMap = new LinkedHashMap;
 		while($file = $stmt->fetchObject()){
-		    $filesMap->put(new Integer($file->id), new Image($file->wwwpath));
+		    $img = new Image($file->wwwpath);
+            //$img->resample(100,null);
+		    $filesMap->put(new Integer($file->id), $img);
 		}
+        // anno1986 added paging for images
+        $this->setField("pagination", $pagination);
 		$this->setField("filesMap", $filesMap);
 	}

diff -ruw v1.3.4/admincp/view/imageview.php src/admincp/view/imageview.php
Code:
--- v1.3.4/admincp/view/imageview.php	2013-04-26 21:04:22.000000000 +0200
+++ src/admincp/view/imageview.php	2014-01-26 18:15:00.000000000 +0100
@@ -36,7 +36,12 @@
 		$document->setTitle($this->lang->manage_title);
 		$document->addLangvar($this->lang->manage);
 		
+        $pagination = $this->getField("pagination");
+		
 		$imageForm = new Form("manageform", "delete", "post");		
+        // anno1986 added paging to image view
+        $imageForm->add(new Comment($pagination->showPage()));
+        
 		$filesMap = $this->getField("filesMap");
 		$iterator = $filesMap->iterator();
         while ($iterator->hasNext()){
@@ -46,10 +51,17 @@
 			$fileImage->setLineBreak(TRUE);
 			
 		    $action = new RadioButton("Delete this Image", "iid", $fileID->getValue());
-			$action->setLineBreak(TRUE);
+			//$action->setLineBreak(TRUE);
+			$imageForm->add(new Comment("<div style='display:inline-block;width:270px;margin-top:20px;'>",FALSE));
 			$imageForm->add($fileImage);
 			$imageForm->add($action);
+            
+            $imageForm->add(new Comment("</div>", FALSE));
+            
 		}
+        // anno1986 added paging to image view
+        $imageForm->add(new Comment($pagination->showPage()));
+        
         $imageForm->add(new Button("Submit", "submit", "submit"));
 		$document->add($imageForm);
 	}
Reply With Quote