source: branches/MootoolsFileManager-Update/plugins/MootoolsFileManager/XinhaFileManager.php @ 1302

Last change on this file since 1302 was 1302, checked in by gogo, 8 years ago

Updates to http://www.github.com/sleemanj/mootools-filemanager from GerHoblett?

http://www.github.com/GerHoblett/

Changes to said updates by gogo (sleemanj @ github)

Modifications to MootoolsFileManager? to work with those updates, some courtesy of GerHoblett?, some sleemanj

GerHoblett? provided a large diff which accomplished the goal in a quite different way. It has merit, however I have opted for a less-affecting path in so far as Xinha's "way" is concerned, namely, not splitting the config for a single plugin into several calls to backend config passing functions which seemed a little cumbersome.

Instead I take the option of using POST to send backend data around, at the minor expense of an extra round trip when displaying thumbnails (for each one). This could be reduced by checking for thumbnail existence and returning the thumbnail name directly in "onView" rather than the backend request to generate said thumbnail.

Still to do, is to make the preview pane thumbnail also work.


File size: 2.0 KB
Line 
1<?php
2/*
3 * Script: XinhaFileManager.php
4 *   MooTools FileManager - Backend for the Xinha editor
5 *
6 *   Derived class which includes special tweaks to make MFM work with Xinha.
7 *
8 * Note: derive from FileManagerWithAlias instead when you need aliasing support; this is left as an exercise
9 *       for the reader. (A non-trivial exercise. You'll need to alias images_dir to images_url
10 *           and files_dir to files_url, at least.
11 *
12 * Authors:
13 *  - Ger Hobbelt (http://hebbut.net)
14 *
15 * License:
16 *   MIT-style license.
17 *
18 * Copyright:
19 *   Copyright (c) 2011 [Ger Hobbelt](http://hobbelt.com)
20 *
21 * Dependencies:
22 *   - FileManager.php
23 */
24
25require_once(str_replace('\\', '/', dirname(__FILE__)) . '/mootools-filemanager/Assets/Connector/FMgr4Alias.php');
26
27
28class XinhaFileManager extends FileManagerWithAliasSupport
29{
30        public function __construct($options)
31        {
32    if(isset($options['images_dir']) && isset($options['images_url']))
33    {
34      $options['Aliases'][$options['images_url']] = $options['images_dir'];
35      $options['directory'] = $options['images_url'];
36    }
37   
38    if(isset($options['files_dir']) && isset($options['files_url']))
39    {
40      $options['Aliases'][$options['files_url']] = $options['files_dir'];
41      $options['directory'] = $options['files_url'];
42    }
43   
44    if(isset($options['thumbs_dir']) && isset($options['thumbs_url']))
45    {
46      $options['Aliases'][$options['thumbs_url']] = $options['thumbs_dir'];
47      $options['thumbnailPath'] = $options['thumbs_url'];
48    }
49   
50    if(isset($options['suggestedMaxImageDimension']))
51    {
52      $options['maxImageDimension'] = $options['suggestedMaxImageDimension'];
53    }
54       
55                parent::__construct($options);
56        }
57
58        // when you want img.preview style max-width = 164px (was before: max-width: 140px)
59        //
60        // Note that this will force all 250px thumbnails to a maximum width of 140px
61        public function getThumb($legal_url, $path, $width, $height)
62        {
63                return parent::getThumb($legal_url, $path, min(164, $width), $height);
64        }
65}
66
67
Note: See TracBrowser for help on using the repository browser.