source: branches/unified_backend/plugins/ImageManager/images.php @ 172

Last change on this file since 172 was 172, checked in by yermol, 14 years ago

htmlarea.js

. added workaround fix for NASTY FIREFOX BUG resulting in the infamous

uneditable area problem (exception on designMode="on" issue -
refer to bug:


https://bugzilla.mozilla.org/show_bug.cgi?id=207842


and this thread:


http://xinha.gogo.co.nz/punbb/viewtopic.php?id=229


. trailing <BR>'s are no longer stripped out of the document. This

was wreaking havoc on EnterParagraphs?. It's not clear whether or not
this is going to have unanticipated side-effects.

plugins/EnterParagraphs/enter-paragraphs.js

NOT FULLY FUNCTIONAL YET - DOESN'T HANDLE ALL CASES CORRECTLY,
but it's much better than it was I think.

. largely reworked.
. changed obfuscated variables names to make it more readable.
. expanded out nested (x ? y : z) constructs to make it more readable.
. added alot of comments.
. fixed a serious bug in findEachNodeUnder() that was not correctly

handling beginning and end node conditions.

. fixed design flaw that selected a non-existent insertion point for

placing the cursor.

. fixed several exceptions.
. now correctly handles lists by passing the back back to the Gecko

engine if we are in a list with the exception of being at the
first position in the first element in which case we insert
a paragraph before the list and move the cursor back to the first
item on the list.

File size: 7.9 KB
Line 
1<?php
2
3/**
4 * Show a list of images in a long horizontal table.
5 * @author $Author: Wei Zhuo $
6 * @version $Id: images.php 27 2004-04-01 08:31:57Z Wei Zhuo $
7 * @package ImageManager
8 */
9
10require_once('config.inc.php');
11
12// we may already have a definition of _ddt().
13
14if ( ! function_exists( "_ddt" ) )
15        {
16        require_once(XINHA_INSTALL_ROOT . '/ddt/ddt.php');
17        }
18
19require_once('Classes/ImageManager.php');
20
21// uncomment for debugging
22
23// _ddtOn();
24
25_ddt( __FILE__, __LINE__, "images.php - base_url is '" . $IMConfig['base_url'] . "'" );
26
27// default path is /
28
29$relative = '/';
30$manager = new ImageManager($IMConfig);
31
32// process any file uploads
33
34$manager->processUploads();
35
36$manager->deleteFiles();
37
38$refreshDir = false;
39
40// process any directory functions
41
42if($manager->deleteDirs() || $manager->processNewDir())
43        $refreshDir = true;
44
45// check for any sub-directory request
46// check that the requested sub-directory exists
47// and valid
48
49if (isset($_REQUEST['dir']))
50        {
51        $path = rawurldecode($_REQUEST['dir']);
52        if($manager->validRelativePath($path))
53                $relative = $path;
54        }
55
56
57$manager = new ImageManager($IMConfig);
58
59// get the list of files and directories
60
61$list = $manager->getFiles($relative);
62
63/* ================= OUTPUT/DRAW FUNCTIONS ======================= */
64
65/**
66 * Draw the files in an table.
67 */
68
69function drawFiles($list, &$manager)
70{
71        global $relative;
72
73        // we used to have the global $IMConfig here but for some reason the global
74        // reference was getting dropped. Pulling it from inside manager is probably
75        // cleaner.
76
77        _ddt( __FILE__, __LINE__, "drawFiles(): config['base_url'] is '" . $manager->config['base_url'] . "'" );
78
79        foreach($list as $entry => $file)
80        {
81                ?>
82                <td>
83
84                <?php _ddt( __FILE__, __LINE__, "drawFiles(): relative is '" . $file['relative'] . "' thumbnail '" . $manager->getThumbnail($file['relative']) . "'" ); ?>
85
86                <table width="100" cellpadding="0" cellspacing="0"><tr><td class="block">
87
88                <a href="javascript:;" onclick="selectImage('<?php echo $file['relative'];?>', '<?php echo $entry; ?>', <?php echo $file['image'][0];?>, <?php echo $file['image'][1]; ?>);"title="<?php echo $entry; ?> - <?php echo Files::formatSize($file['stat']['size']); ?>"><img src="<?php print $manager->getThumbnail($file['relative']); ?>" alt="<?php echo $entry; ?> - <?php echo Files::formatSize($file['stat']['size']); ?>"/></a>
89                </td></tr><tr><td class="edit">
90                        <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
91                       
92                        _ddt( __FILE__, __LINE__, "images.php - base_url is '" . $manager->config['base_url'] . "'" );
93                       
94                        echo $manager->config['base_url'];?>img/edit_trash.gif" height="15" width="15" alt="Trash"/></a><a href="javascript:;" title="Edit" onclick="editImage('<?php echo rawurlencode($file['relative']);?>');"><img src="<?php print $manager->config['base_url'];?>img/edit_pencil.gif" height="15" width="15" alt="Edit"/></a>
95                <?php if($file['image']){ echo $file['image'][0].'x'.$file['image'][1]; } else echo $entry;?>
96                </td></tr></table></td>
97          <?php
98        }//foreach
99}//function drawFiles
100
101
102/**
103* Draw the directory.
104*/
105
106function drawDirs($list, &$manager)
107{
108        global $relative;
109
110        foreach($list as $path => $dir)
111        { ?>
112                <td><table width="100" cellpadding="0" cellspacing="0"><tr><td class="block">
113                <a href="<?php print $manager->config['backend_url']; ?>__function=images&dir=<?php echo rawurlencode($path); ?>" onclick="updateDir('<?php echo $path; ?>')" title="<?php echo $dir['entry']; ?>"><img src="<?php print $manager->config['base_url'];?>img/folder.gif" height="80" width="80" alt="<?php echo $dir['entry']; ?>" /></a>
114                </td></tr><tr>
115                <td class="edit">
116                        <a href="<?php print $$manager->config['backend_url']; ?>__function=editor&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
117
118                        _ddt( __FILE__, __LINE__, "images.php - base_url is '" . $manager->config['base_url'] . "'" );
119                       
120                        print $manager->config['base_url'];?>img/edit_trash.gif" height="15" width="15" alt="Trash"/></a>
121                        <?php echo $dir['entry']; ?>
122                </td>
123                </tr></table></td>
124          <?php
125        } //foreach
126}//function drawDirs
127
128
129/**
130 * No directories and no files.
131 */
132function drawNoResults()
133{
134?>
135<table width="100%">
136  <tr>
137    <td class="noResult">No Images Found</td>
138  </tr>
139</table>
140<?     
141}
142
143/**
144 * No directories and no files.
145 */
146function drawErrorBase(&$manager)
147{
148?>
149<table width="100%">
150  <tr>
151    <td class="error">Invalid base directory: <?php echo $manager->config['images_dir']; ?></td>
152  </tr>
153</table>
154<?     
155}
156
157?>
158<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
159
160<html>
161<head>
162        <title>Image List</title>
163  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
164        <link href="<?php print $IMConfig['base_url'];?>assets/imagelist.css" rel="stylesheet" type="text/css" />
165<script type="text/javascript">
166_backend_url = "<?php print $IMConfig['backend_url']; ?>";
167
168// This page is a frame inside manager.php.
169//
170// our parent frame (manager.php) has an _imgManager reference that we need to
171// import here. _imgManager has an .editor member that allows us to get to the editor
172// instance we're working with if we need it.
173
174_imgManager = top._imgManager;
175
176_imgManager.ddt._ddt( "images.php", "38", "top of file after _imgManager from top frame." );
177
178</script>
179
180<script type="text/javascript" src="<?php print $IMConfig['base_url'];?>assets/dialog.js"></script>
181<script type="text/javascript">
182/*<![CDATA[*/
183
184        if(window.top)
185                HTMLArea = window.top.HTMLArea;
186
187        function hideMessage()
188                {
189
190                _imgManager.ddt._ddt( "images.php", "38", "hideMessage(): top" );
191
192                var topDoc = window.top.document;
193                var messages = topDoc.getElementById('messages');
194                if(messages)
195                        messages.style.display = "none";
196                }
197
198        init = function()
199                {
200
201                _imgManager.ddt._ddt( "images.php", "38", "init(): top" );
202
203                hideMessage();
204                var topDoc = window.top.document;
205
206<?php
207        //we need to refesh the drop directory list
208        //save the current dir, delete all select options
209        //add the new list, re-select the saved dir.
210        if($refreshDir)
211        {
212                $dirs = $manager->getDirs();
213?>
214
215                _imgManager.ddt._ddt( "images.php", "38", "init(): refreshDir section" );
216
217                var selection = topDoc.getElementById('dirPath');
218                var currentDir = selection.options[selection.selectedIndex].text;
219
220                while(selection.length > 0)
221                        {       
222                        selection.remove(0);
223                        }
224               
225                selection.options[selection.length] = new Option("/","<?php echo rawurlencode('/'); ?>");       
226
227                <?php foreach($dirs as $relative=>$fullpath) { ?>
228                        selection.options[selection.length] = new Option("<?php echo $relative; ?>","<?php echo rawurlencode($relative); ?>");         
229                <?php } ?>
230               
231                for(var i = 0; i < selection.length; i++)
232                {
233                        var thisDir = selection.options[i].text;
234                        if(thisDir == currentDir)
235                        {
236                                selection.selectedIndex = i;
237                                break;
238                        }
239                }               
240<?php } ?>
241        }       
242
243        function editImage(image)
244                {
245
246                _imgManager.ddt._ddt( "images.php", "38", "editImage(): top with image '" + image + "'" );
247
248                var url = "<?php echo $IMConfig['backend_url']; ?>__function=editor&img="+image;
249
250                // we have to propagate the editor object through.
251
252                Dialog(url,
253                        function(param)
254                                {
255                                if (!param) // user must have pressed Cancel
256                                        return false;
257                                else
258                                        {
259                                        return true;
260                                        }
261                                }, null, _imgManager.editor);           
262
263                } // end of editImage()
264
265/*]]>*/
266</script>
267<script type="text/javascript" src="<?php print $IMConfig['base_url'];?>assets/images.js"></script>
268</head>
269
270<body>
271<?php if ($manager->isValidBase() == false) { drawErrorBase($manager); }
272        elseif(count($list[0]) > 0 || count($list[1]) > 0) { ?>
273<table>
274        <tr>
275        <?php drawDirs($list[0], $manager); ?>
276        <?php drawFiles($list[1], $manager); ?>
277        </tr>
278</table>
279<?php } else { drawNoResults(); } ?>
280</body>
281</html>
Note: See TracBrowser for help on using the repository browser.