Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#37 2008-08-04 16:34:17

jameslomax
Member
From: UK
Registered: 2005-05-09
Posts: 448
Website

Re: [plugin] [ORPHAN] fpx_image_import

Aha! I worked it out by intuitive trial and error. Yay me. Yes, that’s the code that works, thanks.

Offline

#38 2008-11-15 11:47:15

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 619
Website

Re: [plugin] [ORPHAN] fpx_image_import

qlontz wrote:

Still no word on the option to delete imported files? If anyone has a workaround for this, I would REALLY appreciate the help.

+1

I will love if it will delete the gallery folder and the files from the import folder after the files have been imported

;)

Offline

#39 2008-11-15 18:02:47

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: [plugin] [ORPHAN] fpx_image_import

I think the only way to make this happen is a bounty… I’m all bountied out tho…

Offline

#40 2009-04-18 00:54:00

grundgesetz
Plugin Author
From: Germany
Registered: 2009-04-17
Posts: 24

Re: [plugin] [ORPHAN] fpx_image_import

THE BLUE DRAGON wrote:

I will love if it will delete the gallery folder and the files from the import folder after the files have been imported
;)

Quick-and-Dirty solution:

Step 1

Around Line 234:

change

         } //while
        @closedir($handlesub)

to

         } //while
        @closedir($handlesub)
        rmdirr(IMIMPORTPATH.$file);

Step 2

At the very end of the plugin change

       return !$hasError;
} //function fpx_import

to

       return !$hasError;
} //function fpx_import.
/**
 * Delete a file, or a folder and its contents (recursive algorithm)
 *
 * @author      Aidan Lister <aidan@php.net>
 * @version     1.0.3
 * @link        http://aidanlister.com/repos/v/function.rmdirr.php
 * @param       string   $dirname    Directory to delete
 * @return      bool     Returns TRUE on success, FALSE on failure
 */
function rmdirr($dirname)
{
    // Sanity check
    if (!file_exists($dirname)) {
        return false;
    }
    // Simple delete for a file
    if (is_file($dirname) || is_link($dirname)) {
        return unlink($dirname);
    }
    // Loop through the folder
    $dir = dir($dirname);
    while (false !== $entry = $dir->read()) {
        // Skip pointers
        if ($entry == '.' || $entry == '..') {
            continue;
        }
        // Recurse
        rmdirr($dirname . DIRECTORY_SEPARATOR . $entry);
    }
    // Clean up
    $dir->close();
    return rmdir($dirname);
}

Beware: The folders will be deleted in either case (i.e. if import failed)!

Greetings,
Jonas

Last edited by grundgesetz (2009-04-18 00:55:24)

Offline

#41 2009-04-18 09:06:14

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 619
Website

Re: [plugin] [ORPHAN] fpx_image_import

perfect!
working good!
thanks ;)

Offline

#42 2009-11-04 18:23:33

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: [plugin] [ORPHAN] fpx_image_import

Can anyone confirm if this still works with TXP 4.2? I just tried to import a ton of images and they were added to the database but the images weren’t there.


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#43 2009-11-04 19:27:57

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,303

Re: [plugin] [ORPHAN] fpx_image_import

Hi Matt,

just a quick test, so I can’t say everything’s fine, but I have new db entries and new files.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#44 2009-11-04 22:09:12

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: [plugin] [ORPHAN] fpx_image_import

Thanks Uli.


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#45 2009-11-29 12:23:30

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 619
Website

Re: [plugin] [ORPHAN] fpx_image_import

grundgesetz wrote:

       return !$hasError;
} //function fpx_import.
/**
 * Delete a file, or a folder and its contents (recursive algorithm)
 *
 * @author      Aidan Lister <aidan@php.net>
 * @version     1.0.3
 * @link        http://aidanlister.com/repos/v/function.rmdirr.php
 * @param       string   $dirname    Directory to delete
 * @return      bool     Returns TRUE on success, FALSE on failure
 */
function rmdirr($dirname)
{
    // Sanity check
    if (!file_exists($dirname)) {
        return false;
    }
    // Simple delete for a file
    if (is_file($dirname) || is_link($dirname)) {
        return unlink($dirname);
    }
    // Loop through the folder
    $dir = dir($dirname);
    while (false !== $entry = $dir->read()) {
        // Skip pointers
        if ($entry == '.' || $entry == '..') {
            continue;
        }
        // Recurse
        rmdirr($dirname . DIRECTORY_SEPARATOR . $entry);
    }
    // Clean up
    $dir->close();
    return rmdir($dirname);
}

Can this be change to delete only the files without the folder please?

I’m using the uploadify script to upload the images to a folder name “new_gallery” into the “import” folder
and I want that after I upload the images with the “uploadify” script, I will just import the folder and then select the images and change the category.
so the “new_gallery” folder will always be there
(for quick import and not need to mark all the images one by one)
but the files inside will be deleted after importing.

Offline

#46 2009-12-02 06:35:12

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: [plugin] [ORPHAN] fpx_image_import

Might be easier to just recreate the directory after it’s deleted.


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#47 2009-12-02 14:30:14

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 619
Website

Re: [plugin] [ORPHAN] fpx_image_import

MattD wrote:

Might be easier to just recreate the directory after it’s deleted.

cool but where do I add this code?: mkdir("/images/import/new_gallery", 0755);

for now (thanks for your link) I just changed the return rmdir($dirname); to return ; and it works ;)

Offline

#48 2010-07-28 12:37:26

gfdesign
Member
From: Argentina
Registered: 2009-04-20
Posts: 401

Re: [plugin] [ORPHAN] fpx_image_import

Hi. one question
What field does this plugin use for to order the images ?
(size, file name, date ?)
Thanks

Offline

Board footer

Powered by FluxBB