Changeset 524 for trunk


Ignore:
Timestamp:
07/04/06 14:20:38 (13 years ago)
Author:
koto
Message:
Location:
trunk/plugins
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugins/ExtendedFileManager/Classes/ExtendedFileManager.php

    r521 r524  
    44 * Authors: Wei Zhuo, Afru, Krzysztof Kotowicz 
    55 * Version: Updated on 08-01-2005 by Afru 
    6  * Version: Updated on 20-06-2006 by Krzysztof Kotowicz 
    7  * Package: ExtendedFileManager (EFM 1.1.1) 
     6 * Version: Updated on 04-07-2006 by Krzysztof Kotowicz 
     7 * Package: ExtendedFileManager (EFM 1.1.2) 
    88 * http://www.afrusoft.com/htmlarea 
    99 */ 
     
    747747                } 
    748748        } 
     749 
     750        /** 
     751         * Renames files if certain GET variables are set 
     752         * @return bool 
     753         */ 
     754        function processRenames() 
     755        { 
     756                if(!empty($_GET['rename']) && !empty($_GET['renameTo'])) 
     757                { 
     758                        // new file name (without path and extension) 
     759                        $newName = Files::escape(rawurldecode($_GET['renameTo'])); 
     760                        $newName = str_replace('.', '', $newName); 
     761 
     762                        // path to file (from base images directory) 
     763                        $oldName = rawurldecode($_GET['rename']); 
     764 
     765                        // strip parent dir ("..") to avoid escaping from base directiory 
     766                        $oldName = preg_replace('#\.\.#', '', $oldName); 
     767 
     768                        // path to old file 
     769                        $oldPath = Files::makeFile($this->getImagesDir(), $oldName); 
     770 
     771                        $ret = Files::renameFile($oldPath, $newName); 
     772                        if ($ret === true) { 
     773                                // delete old thumbnail 
     774                                Files::delFile($this->getThumbname($oldPath)); 
     775                        } 
     776                        return $ret; 
     777                } 
     778                 
     779                return null; 
     780        } 
     781 
    749782} 
    750783 
  • trunk/plugins/ExtendedFileManager/assets/imagelist.css

    r521 r524  
    11body { margin: 0; padding: 0;} 
    22.edit   { font-size: 8pt; font-family: small-caption, sans-serif; padding-top: 3px;} 
    3 .edit a { border: none; padding: 3px; text-decoration:none; } 
     3.edit a { border: none; padding: 0; text-decoration:none; } 
    44.edit a:hover { background-color: ButtonHighlight; } 
    55.edit a img { border: none; vertical-align: bottom; } 
  • trunk/plugins/ExtendedFileManager/assets/images.js

    r521 r524  
    33 * Authors: Wei Zhuo, Afru, Krzysztof Kotowicz 
    44 * Version: Updated on 08-01-2005 by Afru 
    5  * Version: Updated on 20-06-2006 by Krzysztof Kotowicz 
    6  * Package: ExtendedFileManager (EFM 1.1.1) 
     5 * Version: Updated on 04-07-2006 by Krzysztof Kotowicz 
     6 * Package: ExtendedFileManager (EFM 1.1.2) 
    77 * http://www.afrusoft.com/htmlarea 
    88 */ 
    99 
    1010function i18n(str) { 
    11     return HTMLArea._lc(str, 'ImageManager'); 
     11    return HTMLArea._lc(str, 'ExtendedFileManager'); 
    1212} 
    1313 
     
    2727    var viewtype = selection.options[selection.selectedIndex].value; 
    2828    location.href = _backend_url + "__function=images&mode="+mode+"&dir="+dir+"&newDir="+newDir+"&viewtype="+viewtype; 
     29} 
     30 
     31function renameFile(oldPath) { 
     32    // strip directory and extension 
     33    var oldName=oldPath.replace(/.*%2F/,'').replace(/\..*$/,''); 
     34    var newName = prompt(i18n('Please enter new name for this file...'), oldName); 
     35 
     36    if(newName == '' || newName == null || newName == oldName) 
     37    { 
     38        alert(i18n('Cancelled rename.')); 
     39        return false; 
     40    } 
     41    var mode=window.top.document.getElementById('manager_mode').value; 
     42    var selection = window.top.document.getElementById('dirPath'); 
     43    var dir = selection.options[selection.selectedIndex].value; 
     44    selection = window.top.document.getElementById('viewtype'); 
     45    var viewtype = selection.options[selection.selectedIndex].value; 
     46    location.href = _backend_url + "__function=images&mode="+mode+"&dir="+dir+"&rename="+oldPath+"&renameTo="+newName+"&viewtype="+viewtype; 
    2947} 
    3048 
  • trunk/plugins/ExtendedFileManager/config.inc.php

    r521 r524  
    44 * Authors: Wei Zhuo, Afru 
    55 * Version: Updated on 08-01-2005 by Afru 
    6  * Version 1.1.1: Updated on 21-06-2006 by Krzysztof Kotowicz <koto@webworkers.pl> 
     6 * Version 1.1.2: Updated on 04-07-2006 by Krzysztof Kotowicz <koto@webworkers.pl> 
    77 * Package: ExtendedFileManager 
    88 * http://www.afrusoft.com/htmlarea 
     
    184184$IMConfig['allow_edit_image'] = true; 
    185185 
     186/* 
     187  Possible values: true, false 
     188 
     189 TRUE -  Allow the user to rename files. 
     190 
     191 FALSE - No rename icon will be displayed. 
     192 
     193*/ 
     194$IMConfig['allow_rename'] = true; 
    186195 
    187196/* 
  • trunk/plugins/ExtendedFileManager/images.php

    r521 r524  
    44 * Authors: Wei Zhuo, Afru, Krzysztof Kotowicz 
    55 * Version: Updated on 08-01-2005 by Afru 
    6  * Version: Updated on 21-06-2006 by Krzysztof Kotowicz 
    7  * Package: ExtendedFileManager (EFM 1.1.1) 
     6 * Version: Updated on 04-07-2006 by Krzysztof Kotowicz 
     7 * Package: ExtendedFileManager (EFM 1.1.2) 
    88 * http://www.afrusoft.com/htmlarea 
    99 */ 
     
    2121//process any file uploads 
    2222$uploadStatus=$manager->processUploads(); 
     23 
     24//process any file renames 
     25$renameStatus=$manager->processRenames(); 
    2326 
    2427if ($manager->deleteFiles()) 
     
    105108                <tr> 
    106109                          <td><img src="<?php print $IMConfig['base_url']; if(is_file('icons/'.$file['ext'].'_small.gif')) echo "icons/".$file['ext']."_small.gif"; else echo $IMConfig['default_listicon']; ?>" alt="" /></td> 
    107                   <th><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']); ?>" <?php if ($insertMode == 'image') { ?> onmouseover="showPreview('<?php echo $file['relative'];?>')" onmouseout="showPreview(window.parent.document.getElementById('f_url').value)" <?php } ?> > 
     110                  <th><a href="#" class="thumb" style="cursor: pointer;" onclick="selectImage('<?php echo $file['relative'];?>', '<?php echo preg_replace('#\..{3,4}$#', '', $entry); ?>', <?php echo $file['image'][0];?>, <?php echo $file['image'][1]; ?>);return false;" title="<?php echo $entry; ?> - <?php echo Files::formatSize($file['stat']['size']); ?>" <?php if ($insertMode == 'image') { ?> onmouseover="showPreview('<?php echo $file['relative'];?>')" onmouseout="showPreview(window.parent.document.getElementById('f_url').value)" <?php } ?> > 
    108111                                <?php 
    109112                                if(strlen($entry)>$maxNameLength) echo substr($entry,0,$maxNameLength)."..."; else echo $entry; 
     
    115118                  <td class="actions"> 
    116119                    <a href="<?php print $IMConfig['backend_url']; ?>__function=images&dir=<?php echo $relative; ?>&amp;delf=<?php echo rawurlencode($file['relative']);?>&amp;mode=<?php echo $insertMode;?>&amp;viewtype=<?php echo $afruViewType; ?>" 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" border="0" /></a> 
     120                                <?php if ($IMConfig['allow_rename']) { ?> 
     121                    <a href="#" title="Rename" onclick="renameFile('<?php echo rawurlencode($file['relative']);?>'); return false;"><img src="<?php print $IMConfig['base_url'];?>img/edit_rename.gif" height="15" width="15" alt="Rename" border="0" /></a> 
     122                    <?php }  ?> 
    117123                                <?php if($IMConfig['img_library'] && $IMConfig['allow_edit_image'] && $file['image'][0] > 0) { ?> 
    118124                    <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" border="0" /></a> 
     
    129135        case 'thumbview': // thumbview is default 
    130136        default: 
    131                 $maxFileNameLength=10; 
     137                $maxFileNameLength=11; 
    132138                $maxFolderNameLength=13; 
    133139                // start of foreach for draw thumbview folders. 
     
    153159                { 
    154160                        $afruimgdimensions=$manager->checkImageSize($file['relative']); 
     161                        $thisFileNameLength = $maxFileNameLength; 
    155162                        ?> 
    156163                <div class="thumb_holder" id="holder_<?php echo asc2hex($entry) ?>"> 
    157                   <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']); ?>"> 
     164                  <a href="#" class="thumb" style="cursor: pointer;" onclick="selectImage('<?php echo $file['relative'];?>', '<?php echo preg_replace('#\..{3,4}$#', '', $entry); ?>', <?php echo $file['image'][0];?>, <?php echo $file['image'][1]; ?>);return false;" title="<?php echo $entry; ?> - <?php echo Files::formatSize($file['stat']['size']); ?>"> 
    158165                    <img src="<?php print $manager->getThumbnail($file['relative']); ?>" alt="<?php echo $entry; ?> - <?php echo Files::formatSize($file['stat']['size']); ?>" /> 
    159166                  </a> 
    160167                  <div class="edit"> 
    161168                    <a href="<?php print $IMConfig['backend_url']; ?>__function=images&amp;mode=<?php echo $insertMode;?>&amp;dir=<?php echo $relative; ?>&amp;delf=<?php echo rawurlencode($file['relative']);?>&amp;viewtype=<?php echo $afruViewType; ?>" 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> 
    162  
     169                                <?php if ($IMConfig['allow_rename']) { ?> 
     170                    <a href="#" title="Rename" onclick="renameFile('<?php echo rawurlencode($file['relative']);?>'); return false;"><img src="<?php print $IMConfig['base_url'];?>img/edit_rename.gif" height="15" width="15" alt="Rename" /></a> 
     171                    <?php $thisFileNameLength -= 3; }  ?> 
    163172                        <?php if($IMConfig['img_library'] && $IMConfig['allow_edit_image'] && $file['image'][0] > 0 ) 
    164173                    { ?> 
    165174                    <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> 
    166                         <?php $maxFileName2=$maxFileNameLength-3;} 
    167                         else $maxFileName2=$maxFileNameLength; ?> 
     175                        <?php $thisFileNameLength -= 3; } ?> 
    168176 
    169177                        <?php 
    170                                 if(strlen($entry)>$maxFileName2) echo strtolower(substr($entry,0,$maxFileName2))."..."; else echo $entry; 
     178                                if(strlen($entry) > $thisFileNameLength + 3) echo strtolower(substr($entry,0,$thisFileNameLength))."..."; else echo $entry; 
    171179                        ?> 
    172180                  </div> 
     
    241249                <?php 
    242250                if(isset($uploadStatus) && !is_numeric($uploadStatus) && !is_bool($uploadStatus)) 
    243                 echo 'alert("'.$uploadStatus.'");'; 
     251                echo 'alert(i18n("'.$uploadStatus.'"));'; 
    244252                else if(isset($uploadStatus) && $uploadStatus==false) 
    245253                echo 'alert("Unable to upload File. \nEither Maximum file size ['.($insertMode == 'image' ? $IMConfig['max_filesize_kb_image'] : $IMConfig['max_filesize_kb_link'] ).'Kb] exceeded or\nFolder doesn\'t have write permission.");'; 
    246254                ?> 
    247                  
     255 
     256                <?php 
     257                if(isset($renameStatus) && !is_numeric($renameStatus) && !is_bool($renameStatus)) 
     258                echo 'alert(i18n("'.$renameStatus.'"));'; 
     259                else if(isset($renameStatus) && $renameStatus===false) 
     260                echo 'alert(i18n("Unable to rename file. File of the same name already exists or\nfolder doesn\'t have write permission."));'; 
     261                ?> 
    248262 
    249263                var topDoc = window.top.document; 
  • trunk/plugins/ExtendedFileManager/lang/pl.js

    r521 r524  
    9595  "Folder is not empty. Please delete all Files and Subfolders inside.": "Folder nie jest pusty. Najpierw usuń wszystkie pliki i podfoldery tego folderu.", 
    9696  "Image Size": "Wymiary", 
    97   "Other" : "Inne..." 
     97  "Other" : "Inne...", 
     98  "Rename": "Zmień nazwę", 
     99  "Please enter new name for this file...": "Podaj nowÄ 
     100 nazwę dla tego pliku...", 
     101  "Unable to rename file. File of the same name already exists or\nfolder doesn't have write permission.": "Nie mogłem zmienić nazwy pliku. Plik o nowej nazwie juÅŒ istnieje\nlub prak praw zapisu do katalogu.", 
     102  "Cancelled rename.": "Anulowano zmianę nazwy pliku." 
    98103}; 
  • trunk/plugins/ImageManager/Classes/Files.php

    r521 r524  
    9090         * @return string the escaped safe filename 
    9191         */ 
    92         function escape($filename)  
     92        function escape($filename) 
    9393        { 
    9494                Return preg_replace('/[^\w\._]/', '_', $filename); 
     
    239239                return $size; 
    240240        } 
     241         
     242        /** 
     243         * Renames file, preserving its directory and extension 
     244         * @param string $oldPath path to the old existing file 
     245         * @param string new filename (just the name, without path or extension) 
     246         * @author Krzysztof Kotowicz <koto@webworkers.pl> 
     247         */ 
     248        function renameFile($oldPath, $newName) { 
     249 
     250                if(!(file_exists($oldPath) && is_file($oldPath))) 
     251                        return FILE_ERROR_NO_SOURCE; 
     252 
     253                $oldFileParts = pathinfo($oldPath); 
     254 
     255                $newPath = $oldFileParts['dirname'] . '/' 
     256                                   . $newName 
     257                                   . (!empty($oldFileParts['extension']) ? '.' . $oldFileParts['extension'] : ''); 
     258 
     259                if (file_exists($newPath)) 
     260                        return false; 
     261 
     262                if (!rename($oldPath, $newPath)) 
     263                        return FILE_ERROR_COPY_FAILED; 
     264 
     265        } 
    241266 
    242267} 
  • trunk/plugins/ImageManager/manager.php

    r493 r524  
    151151 
    152152  <tr> 
    153     <th align="left">Align:</th> 
     153    <th align="left">Alignment:</th> 
    154154    <td colspan="2"> 
    155155      <select size="1" id="f_align"  title="Positioning of this image"> 
Note: See TracChangeset for help on using the changeset viewer.