| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | require_once('config.inc.php'); |
|---|
| 10 | require_once('ddt.php'); |
|---|
| 11 | require_once('Classes/ImageManager.php'); |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | $relative = '/'; |
|---|
| 19 | $manager = new ImageManager($IMConfig); |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | $manager->processUploads(); |
|---|
| 23 | |
|---|
| 24 | $manager->deleteFiles(); |
|---|
| 25 | |
|---|
| 26 | $refreshDir = false; |
|---|
| 27 | |
|---|
| 28 | if($manager->deleteDirs() || $manager->processNewDir()) |
|---|
| 29 | $refreshDir = true; |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | if(isset($_REQUEST['dir'])) |
|---|
| 35 | { |
|---|
| 36 | $path = rawurldecode($_REQUEST['dir']); |
|---|
| 37 | if($manager->validRelativePath($path)) |
|---|
| 38 | $relative = $path; |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | $manager = new ImageManager($IMConfig); |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | |
|---|
| 46 | $list = $manager->getFiles($relative); |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | function drawFiles($list, &$manager) |
|---|
| 55 | { |
|---|
| 56 | global $relative; |
|---|
| 57 | global $IMConfig; |
|---|
| 58 | |
|---|
| 59 | foreach($list as $entry => $file) |
|---|
| 60 | { |
|---|
| 61 | ?> |
|---|
| 62 | <div class="thumb_holder" id="holder_<?php echo asc2hex($entry) ?>"> |
|---|
| 63 | <a href="#" class="thumb" style="cursor: pointer;" onclick="selectImage('<?php echo $file['relative'];?>', '<?php echo $entry; ?>', <?php echo $file['image'][0];?>, <?php echo $file['image'][1]; ?>);return false;" title="<?php echo $entry; ?> - <?php echo Files::formatSize($file['stat']['size']); ?>"> |
|---|
| 64 | <img src="<?php print $manager->getThumbnail($file['relative']); ?>" alt="<?php echo $entry; ?> - <?php echo Files::formatSize($file['stat']['size']); ?>"/> |
|---|
| 65 | </a> |
|---|
| 66 | <div class="edit"> |
|---|
| 67 | <a href="<?php print $IMConfig['backend_url']; ?>__function=images&dir=<?php echo $relative; ?>&delf=<?php echo rawurlencode($file['relative']);?>" title="Trash" onclick="return confirmDeleteFile('<?php echo $entry; ?>');"><img src="<?php print $IMConfig['base_url'];?>img/edit_trash.gif" height="15" width="15" alt="Trash" /></a> |
|---|
| 68 | |
|---|
| 69 | <a href="javascript:;" title="Edit" onclick="editImage('<?php echo rawurlencode($file['relative']);?>');"><img src="<?php print $IMConfig['base_url'];?>img/edit_pencil.gif" height="15" width="15" alt="Edit" /></a> |
|---|
| 70 | |
|---|
| 71 | <?php if($file['image']){ echo $file['image'][0].'x'.$file['image'][1]; } else echo $entry;?> |
|---|
| 72 | </div> |
|---|
| 73 | </div> |
|---|
| 74 | <?php |
|---|
| 75 | } |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | |
|---|
| 81 | |
|---|
| 82 | function drawDirs($list, &$manager) |
|---|
| 83 | { |
|---|
| 84 | global $relative; |
|---|
| 85 | global $IMConfig; |
|---|
| 86 | |
|---|
| 87 | foreach($list as $path => $dir) |
|---|
| 88 | { ?> |
|---|
| 89 | <div class="dir_holder"> |
|---|
| 90 | <a class="dir" href="<?php print $IMConfig['backend_url'];?>__function=images&dir=<?php echo rawurlencode($path); ?>" onclick="updateDir('<?php echo $path; ?>')" title="<?php echo $dir['entry']; ?>"><img src="<?php print $IMConfig['base_url'];?>img/folder.gif" height="80" width="80" alt="<?php echo $dir['entry']; ?>" /></a> |
|---|
| 91 | |
|---|
| 92 | <div class="edit"> |
|---|
| 93 | <a href="<?php print $IMConfig['backend_url'];?>__function=images&dir=<?php echo $relative; ?>&deld=<?php echo rawurlencode($path); ?>" title="Trash" onclick="return confirmDeleteDir('<?php echo $dir['entry']; ?>', <?php echo $dir['count']; ?>);"><img src="<?php print $IMConfig['base_url'];?>img/edit_trash.gif" height="15" width="15" alt="Trash"/></a> |
|---|
| 94 | <?php echo $dir['entry']; ?> |
|---|
| 95 | </div> |
|---|
| 96 | </div> |
|---|
| 97 | <?php |
|---|
| 98 | } |
|---|
| 99 | } |
|---|
| 100 | |
|---|
| 101 | |
|---|
| 102 | |
|---|
| 103 | |
|---|
| 104 | |
|---|
| 105 | function drawNoResults() |
|---|
| 106 | { |
|---|
| 107 | ?> |
|---|
| 108 | <div class="noResult">No Images Found</div> |
|---|
| 109 | <?php |
|---|
| 110 | } |
|---|
| 111 | |
|---|
| 112 | |
|---|
| 113 | |
|---|
| 114 | |
|---|
| 115 | function drawErrorBase(&$manager) |
|---|
| 116 | { |
|---|
| 117 | ?> |
|---|
| 118 | <div class="error"><span>Invalid base directory:</span> <?php echo $manager->config['images_dir']; ?></div> |
|---|
| 119 | <?php |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | |
|---|
| 123 | |
|---|
| 124 | |
|---|
| 125 | function asc2hex ($temp) |
|---|
| 126 | { |
|---|
| 127 | $len = strlen($temp); |
|---|
| 128 | $data = ""; |
|---|
| 129 | for ($i=0; $i<$len; $i++) $data.=sprintf("%02x",ord(substr($temp,$i,1))); |
|---|
| 130 | return $data; |
|---|
| 131 | } |
|---|
| 132 | |
|---|
| 133 | ?> |
|---|
| 134 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|---|
| 135 | |
|---|
| 136 | <html> |
|---|
| 137 | <head> |
|---|
| 138 | <title>Image List</title> |
|---|
| 139 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
|---|
| 140 | <link href="<?php print $IMConfig['base_url'];?>assets/imagelist.css" rel="stylesheet" type="text/css" /> |
|---|
| 141 | <script type="text/javascript"> |
|---|
| 142 | _backend_url = "<?php print $IMConfig['backend_url']; ?>"; |
|---|
| 143 | </script> |
|---|
| 144 | |
|---|
| 145 | <script type="text/javascript" src="<?php print $IMConfig['base_url'];?>assets/dialog.js"></script> |
|---|
| 146 | <script type="text/javascript"> |
|---|
| 147 | /*<![CDATA[*/ |
|---|
| 148 | |
|---|
| 149 | if(window.top) |
|---|
| 150 | HTMLArea = window.top.HTMLArea; |
|---|
| 151 | |
|---|
| 152 | function hideMessage() |
|---|
| 153 | { |
|---|
| 154 | var topDoc = window.top.document; |
|---|
| 155 | var messages = topDoc.getElementById('messages'); |
|---|
| 156 | if(messages) |
|---|
| 157 | messages.style.display = "none"; |
|---|
| 158 | } |
|---|
| 159 | |
|---|
| 160 | init = function() |
|---|
| 161 | { |
|---|
| 162 | __dlg_translate('ImageManager'); |
|---|
| 163 | hideMessage(); |
|---|
| 164 | var topDoc = window.top.document; |
|---|
| 165 | |
|---|
| 166 | <?php |
|---|
| 167 | |
|---|
| 168 | |
|---|
| 169 | |
|---|
| 170 | if($refreshDir) |
|---|
| 171 | { |
|---|
| 172 | $dirs = $manager->getDirs(); |
|---|
| 173 | ?> |
|---|
| 174 | var selection = topDoc.getElementById('dirPath'); |
|---|
| 175 | var currentDir = selection.options[selection.selectedIndex].text; |
|---|
| 176 | |
|---|
| 177 | while(selection.length > 0) |
|---|
| 178 | { selection.remove(0); } |
|---|
| 179 | |
|---|
| 180 | selection.options[selection.length] = new Option("/","<?php echo rawurlencode('/'); ?>"); |
|---|
| 181 | <?php foreach($dirs as $relative=>$fullpath) { ?> |
|---|
| 182 | selection.options[selection.length] = new Option("<?php echo $relative; ?>","<?php echo rawurlencode($relative); ?>"); |
|---|
| 183 | <?php } ?> |
|---|
| 184 | |
|---|
| 185 | for(var i = 0; i < selection.length; i++) |
|---|
| 186 | { |
|---|
| 187 | var thisDir = selection.options[i].text; |
|---|
| 188 | if(thisDir == currentDir) |
|---|
| 189 | { |
|---|
| 190 | selection.selectedIndex = i; |
|---|
| 191 | break; |
|---|
| 192 | } |
|---|
| 193 | } |
|---|
| 194 | <?php } ?> |
|---|
| 195 | update_selected(); |
|---|
| 196 | } |
|---|
| 197 | |
|---|
| 198 | function editImage(image) |
|---|
| 199 | { |
|---|
| 200 | var url = "<?php print $IMConfig['backend_url']; ?>__function=editor&img="+image; |
|---|
| 201 | Dialog(url, function(param) |
|---|
| 202 | { |
|---|
| 203 | if (!param) // user must have pressed Cancel |
|---|
| 204 | return false; |
|---|
| 205 | else |
|---|
| 206 | { |
|---|
| 207 | return true; |
|---|
| 208 | } |
|---|
| 209 | }, null); |
|---|
| 210 | } |
|---|
| 211 | |
|---|
| 212 | /*]]>*/ |
|---|
| 213 | </script> |
|---|
| 214 | <script type="text/javascript" src="<?php print $IMConfig['base_url'];?>assets/images.js"></script> |
|---|
| 215 | <script type="text/javascript" src="assets/popup.js"></script> |
|---|
| 216 | </head> |
|---|
| 217 | |
|---|
| 218 | <body> |
|---|
| 219 | <?php if ($manager->isValidBase() == false) { drawErrorBase($manager); } |
|---|
| 220 | elseif(count($list[0]) > 0 || count($list[1]) > 0) { ?> |
|---|
| 221 | |
|---|
| 222 | <?php drawDirs($list[0], $manager); ?> |
|---|
| 223 | <?php drawFiles($list[1], $manager); ?> |
|---|
| 224 | |
|---|
| 225 | <?php } else { drawNoResults(); } ?> |
|---|
| 226 | </body> |
|---|
| 227 | </html> |
|---|