XPressME Integration Kit

Trac

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

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

WPなしでのインストールに対応 Fixed#405

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        $db =& Database::getInstance() ;
41        $mid = $module->getVar('mid') ;
42
43        if( defined( 'XOOPS_CUBE_LEGACY' ) ) {
44                $ret[] = "********************************* Template Install Log ********************************<br />";
45        } else {
46                $ret[] = '<h4 style="border-bottom: 1px dashed rgb(0, 0, 0); text-align: left; margin-bottom: 0px;">Template Install Log</h4>';
47    }
48    // permission and wordpress files check
49/*
50        if(! xp_permission_check($mydirname, $mydirpath)){
51                if( ! defined( 'XOOPS_CUBE_LEGACY' ) ) {
52                        $ret = $GLOBALS["err_log"];
53                        $ret[] = "<br /><span style=\"color:#ff0000;\">The uninstallation of the module is executed now. </span><br />";
54                        $ret[] = xoops_module_uninstall($mydirname);
55                }
56                return false;
57        }
58*/
59        // make templates
60        $t_mess = xpress_templates_make($mid,$mydirname);
61        $ret = array_merge($ret,$t_mess);
62       
63        if( defined( 'XOOPS_CUBE_LEGACY' ) ) {
64                $ret[] = "********************************* WordPress Install Log ********************************<br />";
65        } else {
66                $ret[] = '<h4 style="border-bottom: 1px dashed rgb(0, 0, 0); text-align: left; margin-bottom: 0px;">WordPress Install Log</h4>';
67    }
68        // wp install
69//      $i_mess = wp_installer($mydirname);
70//      $ret = array_merge($ret,$i_mess);
71
72        return true ;
73}
74endif;
75
76if( ! function_exists( 'xpress_message_append_oninstall' ) ) :
77function xpress_message_append_oninstall( &$module_obj , &$log )
78{
79        if( is_array( @$GLOBALS['ret'] ) ) {
80                foreach( $GLOBALS['ret'] as $message ) {
81                        $log->add( strip_tags( $message ) ) ;
82                }
83        }
84
85        // use mLog->addWarning() or mLog->addError() if necessary
86}
87endif;
88
89if( ! function_exists( 'xpress_message_append_oninstall_err' ) ) :
90function xpress_message_append_oninstall_err( &$module_obj , &$log )
91{
92        if( is_array( @$GLOBALS["err_log"] ) ) {
93                foreach( $GLOBALS["err_log"] as $message ) {
94                        $log->add( strip_tags( $message ) ) ;
95                }
96        }
97
98        // use mLog->addWarning() or mLog->addError() if necessary
99}
100endif;
101
102
103if( ! function_exists( 'wp_install_old_defaults' ) ) :
104function wp_install_old_defaults($user_id) {
105        global $wpdb;
106
107        // Now drop in some default links
108        $wpdb->query("INSERT INTO $wpdb->linkcategories (cat_id, cat_name) VALUES (1, '".$wpdb->escape(__('Blogroll'))."')");
109        $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/', '');");
110        $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/', '');");
111        $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/', '');");
112        $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/', '');");
113        $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/', '');");
114        $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', '');");
115        $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/', '');");
116
117        // Default category
118        $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', '')");
119
120        // First post
121        $now = date('Y-m-d H:i:s');
122        $now_gmt = gmdate('Y-m-d H:i:s');
123        $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', '', '', '')");
124
125        $wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (1, 1, 1)" );
126
127        // Default comment
128        $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.'))."')");
129
130        // First Page
131
132        $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', '', '', '')");
133}
134endif;
135?>
Note: See TracBrowser for help on using the repository browser.