unzip function in the media manager component of joomla 1.5

Forum closed, please submit your tips and tricks to: http://docs.joomla.org/Category:Tips_and_tricks
Forum rules
Please submit all new Tips and Tricks to: http://docs.joomla.org/Category:Tips_and_tricks

This forum section will be closed and removed eventually.
Post Reply
User avatar
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Mon Jun 30, 2008 12:54 pm

unzip function in the media manager component of joomla 1.5

Post by Marko34 » Tue Jul 15, 2008 3:20 pm

Hello everyone,

I have developed a hack to had the capacity to unzip and untar files in the media manager component of joomla 1.5. It work like the delete function, you check the file and you click on the icon to unzip the selected file. It generate a folder with the same name of the selected file.

This hack is avaible here http://www.marc-dugas.fr/Blog/Blog/37-b ... -joomla-15 at the end of the post.

Just copy it at the root of your site.

By hand it work like this.

Open the file administrator/component/com_media/views/media/view.html.php and after the line 106

Code: Select all

/* (...) */
// Add a delete button
$title = JText::_('Delete');
$dhtml = "<a href=\"#\" onclick=\"MediaManager.submit('folder.delete')\" 
            <span class=\"icon-32-delete\" title=\"$title\" 
$bar->appendButton( 'Custom', $dhtml, 'delete' );
/* (...) */  

Code: Select all

/* (...) */
// Add a Unzip button
$title = JText::_('Unzip');
$dhtml = "<a href=\"#\" onclick=\"MediaManager.submit('folder.unzip')\" 
            <span class=\"icon-32-unarchive\" title=\"$title\" 
$bar->appendButton( 'Custom', $dhtml, 'unzip' );
/* (...) */  
This add the icon button on the top of the media manager near the delete button.
Then open the file administrator/component/com_media/controllers/folder.php and add after the delete function

Code: Select all

/* (...) */
function unzip() {
    global $mainframe;

    // Set FTP credentials, if given

    // Get some data from the request
    $tmpl    = JRequest::getCmd( 'tmpl' );
    $paths    = JRequest::getVar( 'rm', array(), '', 'array' );
    $folder = JRequest::getVar( 'folder', '', '', 'path');
    // Initialize variables
    $msg = array();
    $ret = true;

    if (count($paths)) {
        foreach ($paths as $path)
            if ($path !== JFilterInput::clean($path, 'path')) {
                JError::raiseWarning(100, JText::_('Impossible de 
                  decompresser:').htmlspecialchars($path, ENT_COMPAT, 
                  'UTF-8').' '.JText::_('WARNDIRNAME'));

            $fullPath = JPath::clean(COM_MEDIA_BASE.DS.$folder.DS.$path);
            if (is_file($fullPath)) {
                $ext = JFile::getExt(strtolower($fullPath));
                    $pathdir = $fullPath;
                    if($ext != 'gz') {
                        $pathdir = str_replace( ".".$ext, "",$pathdir);
                else {
                    $pathdir = str_replace( ".".$ext, "",$pathdir);
                    $pathdir = str_replace( ".tar", "",$pathdir);
                JFile::write($pathdir.DS."index.html", "<html>\n<body 
                JArchive::extract($fullPath, $pathdir);

            } else if (is_dir($fullPath)) {
                JError::raiseWarning(100, JText::_('Imossible de 
                  decompresser:').$fullPath.' '.JText::_('Pas un fichier 
    if ($tmpl == 'component') {
        // We are inside the iframe
    } else {
/* (...) */  
That's all. My hack use the joomla.filesystem.archive librairy of joomla 1.5 and work with zip, tar and gz extension.

I hope that you will like my hack which is usefull for me.

PS: Sorry if my english is not very well, i'm a poor french computer scientist :-[

Gergo Erdosi
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4031
Joined: Sat Nov 11, 2006 9:34 pm
Location: Hungary

Re: unzip function in the media manager component of joomla 1.5

Post by Gergo Erdosi » Thu Jul 17, 2008 3:50 pm

I added this post to the Docs site:
http://docs.joomla.org/Unzip_function_i ... ia_Manager

Post Reply

Return to “Submit Your Suggested Tips & Tricks to Docs.joomla.org now please.”