Changeset 724 for trunk/common

Show
Ignore:
Timestamp:
12/09/07 17:11:01 (13 months ago)
Author:
michiel
Message:

merge import from wordpress and global import structure from team/michiel/import_blogs
Thanks to fboender for providing me his database and files so I could test it.

Closes #37

Location:
trunk/common
Files:
2 added
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/common/mvblog_admin.php

    r695 r724  
    361361                                <a class="if_menu_item<?php if ($this->_selected_menuitem == "settings")   { echo "_act"; } ?>" href="./index.php?action=show_settings"><?php echo gettext("Settings"); ?></a>&nbsp; 
    362362                                <a class="if_menu_item<?php if ($this->_selected_menuitem == "plugins")    { echo "_act"; } ?>" href="./index.php?action=show_plugins"><?php echo gettext("Plugins"); ?></a>&nbsp; 
     363                                <a class="if_menu_item<?php if ($this->_selected_menuitem == "import")     { echo "_act"; } ?>" href="./index.php?action=show_import"><?php echo gettext("Import"); ?></a>&nbsp; 
    363364                                <a class="if_menu_item" href="./index.php?action=logout"><?php echo gettext("Logout"); ?></a>&nbsp; 
    364365                        </div> 
     
    19591960        } 
    19601961        /* }}} */ 
     1962        /* show_import {{{ */ 
     1963        /** 
     1964         * Show the import module screen with links to all the supported blogtools 
     1965         */ 
     1966        public function show_import() { 
     1967                $import = new MvBlog_import(); 
     1968                $import->show_options(); 
     1969        } 
     1970        /* }}} */ 
     1971        /* import {{{ */ 
     1972        /** 
     1973         * Run the blogtool import routine. 
     1974         * 
     1975         * @param string $type The blogtool to import from. Can only be 'wordpress' right now 
     1976         * @param array $options The additional parameters to pass to the specific import plugin called by run_module() 
     1977         */ 
     1978        public function import($type, $options = array()) { 
     1979                $import = new MvBlog_import(); 
     1980                $import->run_module($type, $options); 
     1981        } 
     1982        /* }}} */ 
    19611983} 
    19621984?> 
  • trunk/common/mvblog_common.php

    r682 r724  
    806806        } 
    807807        /* }}} */ 
    808  
     808        /* filesystem methods */ 
     809        /* copy_files {{{ */ 
     810        /** 
     811         * Copies files and directories recursive to dirs under site_images 
     812         * 
     813         * @param string $src The sourcefile or dir 
     814         * @param string $dst The dir inside site_images where the files/folders should be copied to 
     815         * @param int $overwrite_dest if set will overwrite the destination if it already exists 
     816         */ 
     817        public function copy_files($srcbase, $src, $dest, $overwrite_dest = 0) { 
     818                // calculate where the site_images dir is 
     819                $basepath = realpath(dirname(__FILE__)."/../site_images/"); 
     820                $dst = sprintf("%s/%s", $basepath, $dest); 
     821                //check if the dst dir is there 
     822                if (!is_dir($dst)) 
     823                        if (!mkdir($dst)) 
     824                                die("could not create directory $dst"); 
     825                if ($handle = opendir(sprintf("%s/%s", $srcbase, $src))) { //open source directory 
     826                        while (false !== ($file = readdir($handle))) { //loop through all items in the opened source dir 
     827                                if ($file != "." && $file != "..") { //we wont copy the special 'current dir' and 'one dir up' items 
     828                                        if ($src) 
     829                                                $path = sprintf("%s/%s", $src, $file); 
     830                                        else 
     831                                                $path = $file; 
     832                                                $s = sprintf("%s/%s", $srcbase, $path); 
     833                                                $d = sprintf("%s/%s", $dst, $path); 
     834                                        if (is_file($s)) { 
     835                                                if (is_file($d) || $overwrite_dest) { 
     836                                                        if (!copy($s, $d)) 
     837                                                                echo "Something went wrong while trying to copy $s to $d<br>"; 
     838                                                } 
     839                                        } elseif (is_dir($s)) { 
     840                                                if (!is_dir($d)) 
     841                                                        if (!mkdir($d)) 
     842                                                                echo "Something went wrong while trying to create dir $d<br>\n"; 
     843                                                $this->copy_files($srcbase, $path, $dest, 1); 
     844                                        } 
     845                                } 
     846                        } 
     847                        closedir($handle); 
     848                } 
     849        } 
     850        /* }}} */ 
    809851        /* output methods */ 
    810852        /* html_header: {{{ */