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

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

htmlarea.js

. more debugging messages added.
. added HTMLArea.Config.linkReplacementMode which can be either

fullyqualified (the old default behavior) or absolute.


When set to fullyqualified all absolute links (e.g. /somepath) will be changed to fullyqualified URLS (e.g. http://yoursite/somepth).


When set to absolute, all fullyqualified urls back to the current site
will be changed to absolute (e.g. httpyoursite/somepath to /somepath)
making the Xinha generated content portable between sites.


( see HTMLArea.prototype.outwardHtml() )


. bugfix - if plugin .js file has a parse error htmlarea will only try to load

it a configurable number of times before popping up an error message.


backends/backend.php

. initial unified backend created. Requests to this backend are routed

to the corresponding plugin specific backend.php file.


backends/backend_conf.php

. a central server side configuration file has been created for the use

of plugin serverside code.

. all backends hooked into this scheme must include the central config file.

ImageManager?

. modified the config to allow overriding default values.
. default image directory is now xinha/examples/images
. added debugging trace messages which are tagged with the ImageManager? name.
. now uses unified backend.

Linker

. includes central config.
. default directory is now the xinha/examples directory (to avoid scan.php security

problem)

. added debugging trace messages which are tagged with the Linker name.
. links selected from the tree are now displayed in absolute instead of fully qualified

fashion.

. on edit the link that was previously selected is highlighted.
. on edit the selected link is scrolled to if it's outside the viewable area.
. if scan.php returns some kind of error or invalid javascript Linker now pops up

a nice descriptive error message.


. bugfix - same pattern as in loading plugins. If there is some error in loading the directory listing Linker will only attempt it a few times before giving up and

displaying a nice error.


dTree.js

. added clear_s() method to clear the selection
. added getNodeElement() method to return the <a ..> element for a given node.

File size: 7.2 KB
RevLine 
[43]1<?
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');
[121]10require_once(XINHA_INSTALL_ROOT . '/ddt/ddt.php');
[43]11require_once('Classes/ImageManager.php');
12
13// uncomment for debugging
14
[46]15// _ddtOn();
[43]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//get the list of files and directories
45$list = $manager->getFiles($relative);
46
47/* ================= OUTPUT/DRAW FUNCTIONS ======================= */
48
49/**
50 * Draw the files in an table.
51 */
52function drawFiles($list, &$manager)
53{
54        global $relative;
55        global $IMConfig;
56
57        foreach($list as $entry => $file)
58        {
59                ?>
60                <td>
61
[121]62                <?php _ddt( __FILE__, __LINE__, "drawFiles(): relative is '" . $file['relative'] . "' thumbnail '" . $manager->getThumbnail($file['relative']) . "'" ); ?>
[43]63
64                <table width="100" cellpadding="0" cellspacing="0"><tr><td class="block">
65
[121]66                <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>
[43]67                </td></tr><tr><td class="edit">
[121]68                        <a href="<?php echo $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><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>
69                <?php if($file['image']){ echo $file['image'][0].'x'.$file['image'][1]; } else echo $entry;?>
[43]70                </td></tr></table></td>
[121]71          <?php
[43]72        }//foreach
73}//function drawFiles
74
75
76/**
[121]77* Draw the directory.
78*/
79
[43]80function drawDirs($list, &$manager)
81{
82        global $relative;
83   global $IMConfig;
84
85        foreach($list as $path => $dir)
86        { ?>
87                <td><table width="100" cellpadding="0" cellspacing="0"><tr><td class="block">
[121]88                <a 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>
[43]89                </td></tr><tr>
90                <td class="edit">
[121]91                        <a href="<?php print $IMConfig['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 print $IMConfig['base_url'];?>img/edit_trash.gif" height="15" width="15" alt="Trash"/></a>
92                        <?php echo $dir['entry']; ?>
[43]93                </td>
94                </tr></table></td>
[121]95          <?php
[43]96        } //foreach
97}//function drawDirs
98
99
100/**
101 * No directories and no files.
102 */
103function drawNoResults()
104{
105?>
106<table width="100%">
107  <tr>
108    <td class="noResult">No Images Found</td>
109  </tr>
110</table>
111<?     
112}
113
114/**
115 * No directories and no files.
116 */
117function drawErrorBase(&$manager)
118{
119?>
120<table width="100%">
121  <tr>
[121]122    <td class="error">Invalid base directory: <?php echo $manager->config['images_dir']; ?></td>
[43]123  </tr>
124</table>
125<?     
126}
127
128?>
129<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
130
131<html>
132<head>
133        <title>Image List</title>
134  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
[121]135        <link href="<?php print $IMConfig['base_url'];?>assets/imagelist.css" rel="stylesheet" type="text/css" />
[43]136<script type="text/javascript">
[121]137_backend_url = "<?php print $IMConfig['backend_url']; ?>";
138
139// This page is a frame inside manager.php.
140//
141// our parent frame (manager.php) has an _imgManager reference that we need to
142// import here. _imgManager has an .editor member that allows us to get to the editor
143// instance we're working with if we need it.
144
145_imgManager = top._imgManager;
146
147_imgManager.ddt._ddt( "images.php", "38", "top of file after _imgManager from top frame." );
148
[43]149</script>
150
[121]151<script type="text/javascript" src="<?php print $IMConfig['base_url'];?>assets/dialog.js"></script>
[43]152<script type="text/javascript">
153/*<![CDATA[*/
154
155        if(window.top)
[60]156                HTMLArea = window.top.HTMLArea;
[43]157
158        function hideMessage()
[121]159                {
160
161                _imgManager.ddt._ddt( "images.php", "38", "hideMessage(): top" );
162
[43]163                var topDoc = window.top.document;
164                var messages = topDoc.getElementById('messages');
165                if(messages)
166                        messages.style.display = "none";
[121]167                }
[43]168
169        init = function()
[121]170                {
171
172                _imgManager.ddt._ddt( "images.php", "38", "init(): top" );
173
[43]174                hideMessage();
175                var topDoc = window.top.document;
176
[121]177<?php
[43]178        //we need to refesh the drop directory list
179        //save the current dir, delete all select options
180        //add the new list, re-select the saved dir.
181        if($refreshDir)
182        {
183                $dirs = $manager->getDirs();
184?>
[121]185
186                _imgManager.ddt._ddt( "images.php", "38", "init(): refreshDir section" );
187
[43]188                var selection = topDoc.getElementById('dirPath');
189                var currentDir = selection.options[selection.selectedIndex].text;
190
191                while(selection.length > 0)
[121]192                        {       
193                        selection.remove(0);
194                        }
[43]195               
[121]196                selection.options[selection.length] = new Option("/","<?php echo rawurlencode('/'); ?>");       
197
198                <?php foreach($dirs as $relative=>$fullpath) { ?>
199                        selection.options[selection.length] = new Option("<?php echo $relative; ?>","<?php echo rawurlencode($relative); ?>");         
200                <?php } ?>
[43]201               
202                for(var i = 0; i < selection.length; i++)
203                {
204                        var thisDir = selection.options[i].text;
205                        if(thisDir == currentDir)
206                        {
207                                selection.selectedIndex = i;
208                                break;
209                        }
210                }               
[121]211<?php } ?>
[43]212        }       
213
214        function editImage(image)
215                {
216
[121]217                _imgManager.ddt._ddt( "images.php", "38", "editImage(): top with image '" + image + "'" );
218
219                var url = "<?php echo $IMConfig['backend_url']; ?>__function=editor&img="+image;
220
221                // we have to propagate the editor object through.
222
223                Dialog(url,
224                        function(param)
225                                {
226                                if (!param) // user must have pressed Cancel
227                                        return false;
228                                else
229                                        {
230                                        return true;
231                                        }
232                                }, null, _imgManager.editor);           
233
234                } // end of editImage()
235
[43]236/*]]>*/
237</script>
[121]238<script type="text/javascript" src="<?php print $IMConfig['base_url'];?>assets/images.js"></script>
[43]239</head>
240
241<body>
[121]242<?php if ($manager->isValidBase() == false) { drawErrorBase($manager); }
[43]243        elseif(count($list[0]) > 0 || count($list[1]) > 0) { ?>
244<table>
245        <tr>
[121]246        <?php drawDirs($list[0], $manager); ?>
247        <?php drawFiles($list[1], $manager); ?>
[43]248        </tr>
249</table>
[121]250<?php } else { drawNoResults(); } ?>
[43]251</body>
252</html>
Note: See TracBrowser for help on using the repository browser.