PDA

View Full Version : Mys 1.3.4 Paging in admin panel für images


anno1986
01-28-2014, 01:31 PM
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

--- 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


--- 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);
}

AndromedaKerova
11-09-2014, 12:36 PM
This doesn't really explain how to add the fix. It might be ok for coders but some of us are beginners or even non coders.

kristhasirah
05-05-2015, 12:26 PM
after trying and testing I manage to make the code work, because copy and paste just gives a blank page, and so i will post the code thats working for me for those that don't have idea what to do... like me XD



in admincp/image.php find:

public function manage(){
$mysidia = Registry::get("mysidia");
$stmt = $mysidia->db->select("filesmap", array("id", "wwwpath"));
$filesMap = new LinkedHashMap;
while($file = $stmt->fetchObject()){
$filesMap->put(new Integer($file->id), new Image($file->wwwpath));
}
$this->setField("filesMap", $filesMap);
}

and replace with:

public function manage(){
$mysidia = Registry::get("mysidia");
$stmt = $mysidia->db->select("filesmap", array("id", "wwwpath"));
$total = $mysidia->db->select("filesmap", array("id"))->rowCount();
$pagination = new Pagination($total, 20, "admincp/image/delete");
$pagination->setPage($mysidia->input->get("page"));
$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));

}
$this->setField("pagination", $pagination);
$this->setField("filesMap", $filesMap);
}


in admincp/view/imageview.php find:
public function manage(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle($this->lang->manage_title);
$document->addLangvar($this->lang->manage);

$imageForm = new Form("manageform", "delete", "post");
$filesMap = $this->getField("filesMap");
$iterator = $filesMap->iterator();
while ($iterator->hasNext()){
$file = $iterator->next();
$fileID = $file->getKey();
$fileImage = $file->getValue();
$fileImage->setLineBreak(TRUE);

$action = new RadioButton("Delete this Image", "iid", $fileID->getValue());
$action->setLineBreak(TRUE);
$imageForm->add($fileImage);
$imageForm->add($action);
}
$imageForm->add(new Button("Submit", "submit", "submit"));
$document->add($imageForm);
}


and replace with this:

public function manage(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle($this->lang->manage_title);
$document->addLangvar($this->lang->manage);
$pagination = $this->getField("pagination");

$imageForm = new Form("manageform", "delete", "post");
$imageForm->add(new Comment($pagination->showPage()));
$filesMap = $this->getField("filesMap");
$iterator = $filesMap->iterator();
while ($iterator->hasNext()){
$file = $iterator->next();
$fileID = $file->getKey();
$fileImage = $file->getValue();
$fileImage->setLineBreak(TRUE);

$action = new RadioButton("Delete this Image", "iid", $fileID->getValue());
$action->setLineBreak(TRUE);
$imageForm->add(new Comment("<div style='display:inline-block;width:100px;margin-top:20px;'>",FALSE));
$imageForm->add($fileImage);
$imageForm->add($action);
$imageForm->add(new Comment("</div>", FALSE));

}
$imageForm->add(new Comment($pagination->showPage()));

$imageForm->add(new Button("Submit", "submit", "submit"));
$document->add($imageForm);
}


those are the codes that are working for me, hope it works for everyone else =)
and thanks anno1986 for posting the code ^^ because if i tried to do it myself i probably wont be able to do it.

also replace the "20" with the number of images you want to see in each page and replace "100" with the max width of your adoptbles.