source: trunk/plugins/ImageManager/images.php @ 293

Last change on this file since 293 was 293, checked in by niko, 9 years ago

#451
remove notice

File size: 6.5 KB
Line 
1<?php
2/**
3 * Show a list of images in a long horizontal table.
4 * @author $Author: Wei Zhuo $
5 * @version $Id: images.php 27 2004-04-01 08:31:57Z Wei Zhuo $
6 * @package ImageManager
7 */
8
9require_once('config.inc.php');
10require_once('ddt.php');
11require_once('Classes/ImageManager.php');
12
13// uncomment for debugging
14
15// _ddtOn();
16
17//default path is /
18$relative = '/';
19$manager = new ImageManager($IMConfig);
20
21//process any file uploads
22$manager->processUploads();
23
24$manager->deleteFiles();
25
26$refreshDir = false;
27//process any directory functions
28if($manager->deleteDirs() || $manager->processNewDir())
29        $refreshDir = true;
30
31//check for any sub-directory request
32//check that the requested sub-directory exists
33//and valid
34if(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//get the list of files and directories
46$list = $manager->getFiles($relative);
47
48
49/* ================= OUTPUT/DRAW FUNCTIONS ======================= */
50
51/**
52 * Draw the files in an table.
53 */
54function 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; ?>&amp;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        }//foreach
76}//function drawFiles
77
78
79/**
80 * Draw the directory.
81 */
82function 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; ?>&amp;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        } //foreach
99}//function drawDirs
100
101
102/**
103 * No directories and no files.
104 */
105function drawNoResults()
106{
107?>
108<div class="noResult">No Images Found</div>
109<?php
110}
111
112/**
113 * No directories and no files.
114 */
115function 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 * Utility to convert ascii string to hex
124 */
125function 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        //we need to refesh the drop directory list
168        //save the current dir, delete all select options
169        //add the new list, re-select the saved dir.
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>
Note: See TracBrowser for help on using the repository browser.