Changeset 724

Show
Ignore:
Timestamp:
12/09/07 17:11:01 (12 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
Files:
2 added
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/admin/index.php

    r646 r724  
    5656                                $_REQUEST["action"] = ""; 
    5757                        switch ($_REQUEST["action"]) { 
    58                                 case "check_login"           : $admin->check_login((array_key_exists("login", $_POST))?$_POST["login"]:"");                        break; 
    59                                 case "logout"                : $admin->logout();                                            break; 
    60                                 case "show_cats"             : $admin->show_cats();                                         break; 
    61                                 case "edit_cat"              : $admin->edit_cat((array_key_exists("id", $_REQUEST))?$_REQUEST["id"]:0);                           break; 
    62                                 case "save_cat"              : $admin->save_cat($_POST["cat"]);                             break; 
    63                                 case "delete_cat"            : $admin->delete_cat($_REQUEST["cat"]["id"]);                  break; 
    64                                 case "show_dossiers"         : $admin->show_dossiers();                                     break; 
    65                                 case "edit_dossier"          : $admin->edit_dossier((array_key_exists("id", $_REQUEST))?$_REQUEST["id"]:0);                           break; 
    66                                 case "save_dossier"          : $admin->save_dossier($_POST["dossier"]);                             break; 
    67                                 case "delete_dossier"        : $admin->delete_dossier($_REQUEST["dossier"]["id"]);                  break; 
    68                                 case "show_posts"            : $admin->show_posts((array_key_exists("options", $_REQUEST))?$_REQUEST["options"]:"");                    break; 
    69                                 case "edit_post"             : $admin->edit_post((array_key_exists("id", $_REQUEST))?$_REQUEST["id"]:0);                          break; 
    70                                 case "save_post"             : $admin->save_post($_POST["post"]);                           break; 
    71                                 case "delete_post"           : $admin->delete_post($_REQUEST["post"]["id"]);                break; 
    72                                 case "show_authors"          : $admin->show_authors();                                      break; 
    73                                 case "edit_author"           : $admin->edit_author((array_key_exists("id", $_REQUEST))?$_REQUEST["id"]:0);                        break; 
    74                                 case "save_author"           : $admin->save_author($_POST["author"]);                       break; 
    75                                 case "show_users"            : $admin->show_users();                                        break; 
    76                                 case "edit_user"             : $admin->edit_user((array_key_exists("id", $_REQUEST))?$_REQUEST["id"]:0);                          break; 
    77                                 case "save_user"             : $admin->save_user($_POST["user"]);                           break; 
    78                                 case "delete_inactive_users" : $admin->delete_inactive_users($_POST["select_inactive"]);    break; 
    79                                 case "delete_user"           : $admin->delete_user($_REQUEST["user"]["id"]);                break; 
    80                                 case "show_settings"         : $admin->show_settings();                                     break; 
    81                                 case "save_settings"         : $admin->save_settings($_POST["settings"]); 
    82                                                                $admin->show_settings();                                     break; 
    83                                 case "show_menuitems"        : $admin->show_menuitems();                                    break; 
    84                                 case "save_menuitems"        : $admin->save_menuitems($_POST["link"]);                      break; 
    85                                 case "show_comments"         : $admin->show_comments((array_key_exists("options", $_REQUEST))?$_REQUEST["options"]:"");                 break; 
    86                                 case "delete_comment"        : $admin->delete_comment($_REQUEST["id"]);                     break; 
    87                                 case "recover_comment"       : $admin->recover_comment($_REQUEST["id"]);                    break; 
    88                                 case "show_plugins"          : $admin->show_plugins();                                      break; 
    89                                 case "activate_plugin"       : $admin->_activate_plugin($_REQUEST["plugin"]); 
    90                                                                $admin->show_plugins();                                      break; 
    91                                 case "deactivate_plugin"     : $admin->_deactivate_plugin($_REQUEST["plugin"]); 
    92                                                                $admin->show_plugins();                                      break; 
    93                                 case "config_plugin"         : $admin->configure_plugin($_REQUEST["plugin"]);               break; 
    94                                 case "edit_plugin_setting"   : $admin->edit_plugin_setting($_REQUEST["plugin"], $_REQUEST); break; 
    95                                 case "save_plugin_setting"   : $admin->save_plugin_setting($_REQUEST["plugin"], $_REQUEST); break; 
    96                                 case "show_about"            : $admin->show_about();                                        break; 
    97                                 default                      : $admin->show_index();                                        break; 
     58                                case "check_login" :  
     59                                        $admin->check_login((array_key_exists("login", $_POST))?$_POST["login"]:""); 
     60                                        break; 
     61                                case "logout" :  
     62                                        $admin->logout(); 
     63                                        break; 
     64                                case "show_cats" : 
     65                                        $admin->show_cats(); 
     66                                        break; 
     67                                case "edit_cat" : 
     68                                        $admin->edit_cat((array_key_exists("id", $_REQUEST))?$_REQUEST["id"]:0); 
     69                                        break; 
     70                                case "save_cat" : 
     71                                        $admin->save_cat($_POST["cat"]); 
     72                                        break; 
     73                                case "delete_cat" : 
     74                                        $admin->delete_cat($_REQUEST["cat"]["id"]); 
     75                                        break; 
     76                                case "show_dossiers" : 
     77                                        $admin->show_dossiers(); 
     78                                        break; 
     79                                case "edit_dossier" : 
     80                                        $admin->edit_dossier((array_key_exists("id", $_REQUEST))?$_REQUEST["id"]:0); 
     81                                        break; 
     82                                case "save_dossier" : 
     83                                        $admin->save_dossier($_POST["dossier"]); 
     84                                        break; 
     85                                case "delete_dossier" : 
     86                                        $admin->delete_dossier($_REQUEST["dossier"]["id"]); 
     87                                        break; 
     88                                case "show_posts" : 
     89                                        $admin->show_posts((array_key_exists("options", $_REQUEST))?$_REQUEST["options"]:""); 
     90                                        break; 
     91                                case "edit_post" : 
     92                                        $admin->edit_post((array_key_exists("id", $_REQUEST))?$_REQUEST["id"]:0); 
     93                                        break; 
     94                                case "save_post" : 
     95                                        $admin->save_post($_POST["post"]); 
     96                                        break; 
     97                                case "delete_post" : 
     98                                        $admin->delete_post($_REQUEST["post"]["id"]); 
     99                                        break; 
     100                                case "show_authors" : 
     101                                        $admin->show_authors(); 
     102                                        break; 
     103                                case "edit_author" : 
     104                                        $admin->edit_author((array_key_exists("id", $_REQUEST))?$_REQUEST["id"]:0); 
     105                                        break; 
     106                                case "save_author" : 
     107                                        $admin->save_author($_POST["author"]); 
     108                                        break; 
     109                                case "show_users" : 
     110                                        $admin->show_users(); 
     111                                        break; 
     112                                case "edit_user" : 
     113                                        $admin->edit_user((array_key_exists("id", $_REQUEST))?$_REQUEST["id"]:0); 
     114                                        break; 
     115                                case "save_user" : 
     116                                        $admin->save_user($_POST["user"]); 
     117                                        break; 
     118                                case "delete_inactive_users" : 
     119                                        $admin->delete_inactive_users($_POST["select_inactive"]); 
     120                                        break; 
     121                                case "delete_user" : 
     122                                        $admin->delete_user($_REQUEST["user"]["id"]); 
     123                                        break; 
     124                                case "show_settings" : 
     125                                        $admin->show_settings(); 
     126                                        break; 
     127                                case "save_settings" : 
     128                                        $admin->save_settings($_POST["settings"]); 
     129                                        $admin->show_settings(); 
     130                                        break; 
     131                                case "show_menuitems" : 
     132                                        $admin->show_menuitems(); 
     133                                        break; 
     134                                case "save_menuitems" : 
     135                                        $admin->save_menuitems($_POST["link"]); 
     136                                        break; 
     137                                case "show_comments" : 
     138                                        $admin->show_comments((array_key_exists("options", $_REQUEST))?$_REQUEST["options"]:""); 
     139                                        break; 
     140                                case "delete_comment" : 
     141                                        $admin->delete_comment($_REQUEST["id"]); 
     142                                        break; 
     143                                case "recover_comment" : 
     144                                        $admin->recover_comment($_REQUEST["id"]); 
     145                                        break; 
     146                                case "show_plugins" : 
     147                                        $admin->show_plugins(); 
     148                                        break; 
     149                                case "activate_plugin" : 
     150                                        $admin->_activate_plugin($_REQUEST["plugin"]); 
     151                                        $admin->show_plugins(); 
     152                                        break; 
     153                                case "deactivate_plugin" : 
     154                                        $admin->_deactivate_plugin($_REQUEST["plugin"]); 
     155                                        $admin->show_plugins(); 
     156                                        break; 
     157                                case "config_plugin" : 
     158                                        $admin->configure_plugin($_REQUEST["plugin"]); 
     159                                        break; 
     160                                case "edit_plugin_setting" : 
     161                                        $admin->edit_plugin_setting($_REQUEST["plugin"], $_REQUEST); 
     162                                        break; 
     163                                case "save_plugin_setting" : 
     164                                        $admin->save_plugin_setting($_REQUEST["plugin"], $_REQUEST); 
     165                                        break; 
     166                                case "show_import" : 
     167                                        $admin->show_import(); 
     168                                        break; 
     169                                case "import" : 
     170                                        $admin->import((array_key_exists("type", $_REQUEST))?$_REQUEST["type"]:"", $_REQUEST); 
     171                                        break; 
     172                                case "show_about" : 
     173                                        $admin->show_about(); 
     174                                        break; 
     175                                default :  
     176                                        $admin->show_index(); 
     177                                        break; 
    98178                        } 
    99179$admin->html_footer(); 
  • 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: {{{ */