summaryrefslogtreecommitdiffstats
path: root/modules/imgmanagement
diff options
context:
space:
mode:
Diffstat (limited to 'modules/imgmanagement')
-rw-r--r--modules/imgmanagement/page.inc.php75
-rw-r--r--modules/imgmanagement/templates/page-imgmanagement.html20
2 files changed, 49 insertions, 46 deletions
diff --git a/modules/imgmanagement/page.inc.php b/modules/imgmanagement/page.inc.php
index 27844e23..dc19cb2a 100644
--- a/modules/imgmanagement/page.inc.php
+++ b/modules/imgmanagement/page.inc.php
@@ -16,11 +16,6 @@ class Page_Imgmanagement extends Page
Util::redirect('?do=Main');
}
-
- //Depends on the server location;
- $this->baselocation = '/var/images/';
- $this->images = array();
-
error_reporting(E_ALL);
ini_set('display_errors','on');
@@ -29,46 +24,38 @@ class Page_Imgmanagement extends Page
}
protected function doRender()
- {
- /*get city of user !!!!NOT TESTED!!!!
-
- $data=array( 'id'= User.getId());
- $res = Database::exec("SELECT cityid FROM user WHERE userid=:id",$data);
- $cityid = $res->fetch(PDO::FETCH_ASSOC);
- $res = Database::exec("SELECT name FROM cities WHERE cityid=:cityid",$cityid);
- $city = $res->fetch(PDO::FETCH_ASSOC);
- $location = $baselocation . $city;
-
-
- verify type of vars (string concatenation and more)
- !!!!NOT TESTED!!!!
- */
-
- error_reporting(E_ALL);
+ {
+ error_reporting(E_ALL);
ini_set('display_errors','on');
- //Search images on location specified
- $location = $this->baselocation . 'curitiba/*';
- //Gets the configuration of each image
- $config = substr($location,0,-1).'config.json';
- $imgsactive = json_decode(file_get_contents($config),true);
- $images = glob($location, GLOB_ONLYDIR);
- $actives = array();
- $deactives= array();
- foreach($images as &$imgname){
- $imgname= substr($imgname, strlen($location)-1);
- //fill associative array (img->active[true/false])
- $this->images[$imgname] = isset($imgsactive[$imgname])?$imgsactive[$imgname] : false;
- if($this->images[$imgname]){
- array_push($actives, array('name' => $imgname));
- }else{
- array_push($deactives, array('name'=>$imgname));
- }
- }
-
- //Save eventually new images to config.json
- $fp = fopen($config,'w');
- fwrite($fp,json_encode($this->images));
- fclose($fp);
+
+ $actives = array();
+ $deactives = array();
+
+ $res = Database::simpleQuery("SELECT id, name, path, userid, is_template, is_active, description FROM images ORDER BY id DESC");
+ while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ if($row['is_active'])
+ $actives[] = array(
+ 'id' => $row['id'],
+ 'name' => $row['name'],
+ 'path' => $row['path'],
+ 'userid' => $row['userid'],
+ 'is_template' => $row['is_template'],
+ 'is_active' => $row['is_active'],
+ 'description' => $row['description']
+ );
+ else
+ $deactives[] = array(
+ 'id' => $row['id'],
+ 'name' => $row['name'],
+ 'path' => $row['path'],
+ 'userid' => $row['userid'],
+ 'is_template' => $row['is_template'],
+ 'is_active' => $row['is_active'],
+ 'description' => $row['description']
+ );
+
+ }
+
Render::addTemplate('page-imgmanagement', array(
'deactives' => $deactives,
'actives' => $actives));
diff --git a/modules/imgmanagement/templates/page-imgmanagement.html b/modules/imgmanagement/templates/page-imgmanagement.html
index 795ae39f..cdae627b 100644
--- a/modules/imgmanagement/templates/page-imgmanagement.html
+++ b/modules/imgmanagement/templates/page-imgmanagement.html
@@ -29,8 +29,13 @@
</div>
</div>
- <a class="btn btn-default" href="#" role="button">Upload de Nova Imagem<a>
- <a class="btn btn-info" href="#" role="button">Gerar IPXE<a>
+ <div class="panel-body text-center">
+ <input type='button' value='<<' id='move_left' />
+ <input type='button' value='>>' id='move_right' />
+ <a class="btn btn-default" href="#" role="button">Upload de Nova Imagem<a>
+ <a class="btn btn-info" href="#" role="button">Gerar IPXE<a>
+ <a class="btn btn-info" href="#" role="button">Salvar<a>
+ </div>
</div>
</div>
@@ -43,4 +48,15 @@
});
});
+ $('body').on('click', 'li', function() {
+ $(this).toggleClass('selected');
+ });
+
+ $('#move_left').click(function() {
+ $('.source').append($('.target .selected').removeClass('selected'));
+ });
+
+ $('#move_right').click(function() {
+ $('.target').append($('.source .selected').removeClass('selected'));
+ });
</script>