XPressME Integration Kit

Trac

source: branches/Ver3.0/xpressme_integration_kit/include/oninstall.php @ 749

Last change on this file since 749 was 749, checked in by toemon, 14 years ago

Database::getInstance()を使わずに、global $xoopsDB を使用する。(xoops3対策)

File size: 7.0 KB
Line 
1<?php
2$mydirpath = dirname(dirname(__FILE__));
3$mydirname = basename($mydirpath);
4$lang = @$GLOBALS["xoopsConfig"]['language'];
5global $wp_db_version,$wp_rewrite;
6include_once $mydirpath .'/wp-includes/version.php' ;
7
8// language file (modinfo.php)
9
10if( file_exists( $mydirpath .'/language/'.$lang.'/modinfo.php' ) ) {
11        include_once $mydirpath .'/language/'.$lang.'/modinfo.php' ;
12} else if( file_exists(  $mydirpath .'/language/english/modinfo.php' ) ) {
13        include_once $mydirpath .'/language/english/modinfo.php' ;
14}
15
16
17eval( ' function xoops_module_install_'.$mydirname.'( $module ) { return xpress_oninstall_base( $module , "'.$mydirname.'" ) ; } ' ) ;
18
19
20if( ! function_exists( 'xpress_oninstall_base' ) ) :
21function xpress_oninstall_base( $module , $mydirname )
22{
23        // transations on module install
24        $mydirpath = dirname(dirname(__FILE__));
25
26        global $ret ; // TODO :-D
27        include_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/include/wp_installer.php' ;
28        include_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/include/xpress_templates_make.php' ;
29
30        // for Cube 2.1
31        if( defined( 'XOOPS_CUBE_LEGACY' ) ) {
32                $root =& XCube_Root::getSingleton();
33                $root->mDelegateManager->add( 'Legacy.Admin.Event.ModuleInstall.' . ucfirst($mydirname) . '.Success' , 'xpress_message_append_oninstall' ) ;
34                $root->mDelegateManager->add( 'Legacy.Admin.Event.ModuleInstall.' . ucfirst($mydirname) . '.Fail' , 'xpress_message_append_oninstall_err' ) ;
35                $ret = array() ;
36        } else {
37                if( ! is_array( $ret ) ) $ret = array() ;
38        }
39
40        $mid = $module->getVar('mid') ;
41
42        if( defined( 'XOOPS_CUBE_LEGACY' ) ) {
43                $ret[] = "********************************* Template Install Log ********************************<br />";
44        } else {
45                $ret[] = '<h4 style="border-bottom: 1px dashed rgb(0, 0, 0); text-align: left; margin-bottom: 0px;">Template Install Log</h4>';
46    }
47    // permission and wordpress files check
48/*
49        if(! xp_permission_check($mydirname, $mydirpath)){
50                if( ! defined( 'XOOPS_CUBE_LEGACY' ) ) {
51                        $ret = $GLOBALS["err_log"];
52                        $ret[] = "<br /><span style=\"color:#ff0000;\">The uninstallation of the module is executed now. </span><br />";
53                        $ret[] = xoops_module_uninstall($mydirname);
54                }
55                return false;
56        }
57*/
58        // make templates
59        $t_mess = xpress_templates_make($mid,$mydirname);
60        $ret = array_merge($ret,$t_mess);
61       
62        if( defined( 'XOOPS_CUBE_LEGACY' ) ) {
63                $ret[] = "********************************* WordPress Install Log ********************************<br />";
64        } else {
65                $ret[] = '<h4 style="border-bottom: 1px dashed rgb(0, 0, 0); text-align: left; margin-bottom: 0px;">WordPress Install Log</h4>';
66    }
67        // wp install
68//      $i_mess = wp_installer($mydirname);
69//      $ret = array_merge($ret,$i_mess);
70
71        return true ;
72}
73endif;
74
75if( ! function_exists( 'xpress_message_append_oninstall' ) ) :
76function xpress_message_append_oninstall( &$module_obj , &$log )
77{
78        if( is_array( @$GLOBALS['ret'] ) ) {
79                foreach( $GLOBALS['ret'] as $message ) {
80                        $log->add( strip_tags( $message ) ) ;
81                }
82        }
83
84        // use mLog->addWarning() or mLog->addError() if necessary
85}
86endif;
87
88if( ! function_exists( 'xpress_message_append_oninstall_err' ) ) :
89function xpress_message_append_oninstall_err( &$module_obj , &$log )
90{
91        if( is_array( @$GLOBALS["err_log"] ) ) {
92                foreach( $GLOBALS["err_log"] as $message ) {
93                        $log->add( strip_tags( $message ) ) ;
94                }
95        }
96
97        // use mLog->addWarning() or mLog->addError() if necessary
98}
99endif;
100
101
102if( ! function_exists( 'wp_install_old_defaults' ) ) :
103function wp_install_old_defaults($user_id) {
104        global $wpdb;
105
106        // Now drop in some default links
107        $wpdb->query("INSERT INTO $wpdb->linkcategories (cat_id, cat_name) VALUES (1, '".$wpdb->escape(__('Blogroll'))."')");
108        $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://blogs.linux.ie/xeer/', 'Donncha', 1, 'http://blogs.linux.ie/xeer/feed/', '');");
109        $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zengun.org/weblog/', 'Michel', 1, 'http://zengun.org/weblog/feed/', '');");
110        $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://boren.nu/', 'Ryan', 1, 'http://boren.nu/feed/', '');");
111        $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://photomatt.net/', 'Matt', 1, 'http://xml.photomatt.net/feed/', '');");
112        $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zed1.com/journalized/', 'Mike', 1, 'http://zed1.com/journalized/feed/', '');");
113        $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://www.alexking.org/', 'Alex', 1, 'http://www.alexking.org/blog/wp-rss2.php', '');");
114        $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://dougal.gunters.org/', 'Dougal', 1, 'http://dougal.gunters.org/feed/', '');");
115
116        // Default category
117        $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_count, category_description) VALUES ('0', '".$wpdb->escape(__('Uncategorized'))."', '".sanitize_title(__('Uncategorized'))."', '1', '')");
118
119        // First post
120        $now = date('Y-m-d H:i:s');
121        $now_gmt = gmdate('Y-m-d H:i:s');
122        $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, comment_count, to_ping, pinged, post_content_filtered) VALUES ('1', '$now', '$now_gmt', '".$wpdb->escape(__('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!'))."', '', '".$wpdb->escape(__('Hello world!'))."', '0', '".$wpdb->escape(__('hello-world'))."', '$now', '$now_gmt', '1', '', '', '')");
123
124        $wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (1, 1, 1)" );
125
126        // Default comment
127        $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_date, comment_date_gmt, comment_content) VALUES ('1', '".$wpdb->escape(__('Mr WordPress'))."', '', 'http://wordpress.org/', '$now', '$now_gmt', '".$wpdb->escape(__('Hi, this is a comment.<br />To delete a comment, just log in and view the post&#039;s comments. There you will have the option to edit or delete them.'))."')");
128
129        // First Page
130
131        $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, post_status, to_ping, pinged, post_content_filtered) VALUES ('1', '$now', '$now_gmt', '".$wpdb->escape(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '', '".$wpdb->escape(__('About'))."', '0', '".$wpdb->escape(__('about'))."', '$now', '$now_gmt', 'static', '', '', '')");
132}
133endif;
134?>
Note: See TracBrowser for help on using the repository browser.