-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.php
210 lines (167 loc) · 5.08 KB
/
install.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
/**
* Script file of HelloWorld component
*/
class plgSystemAsikart_easysetInstallerScript
{
/**
* method to install the component
*
* @return void
*/
function install($parent)
{
$msg = '';
$db = JFactory::getDbo();
$sql = "UPDATE #__extensions
SET enabled='1'
WHERE element='asikart_easyset' ;" ;
$db->setQuery( $sql );
$db->query();
$this->_createTable();
//JFolder::copy( JPATH_PLUGINS.DS.'system'.DS.'asikart_easyset' , JPATH_ROOT.DS.'easyset' , '' , true );
JFolder::create( JPATH_ROOT.'/easyset' );
JFolder::create( JPATH_ROOT.'/easyset/cmd' );
/*
$array = array();
$array[] = 'onAfterInitialise';
$array[] = 'onAfterRoute';
$array[] = 'onAfterDispatch';
$array[] = 'onAfterRender';
$array[] = 'onContentPrepare';
$array[] = 'onContentBeforeDisplay';
$array[] = 'onContentAfterDisplay';
$array[] = 'onContentBeforeTitle';
$array[] = 'onContentBeforeSave';
$array[] = 'onContentAfterSave';
$array[] = 'onContentBeforeDelete';
$array[] = 'onContentAfterDelete';
$array[] = 'onContentChangeState';
$content = "<"."?php \n\n\n?".">" ;
$libpath = JPATH_ROOT.DS.'easyset'.DS.'lib'.DS.'events' ;
JPath::setPermissions( $libpath , 755 );
foreach( $array as $file ) {
if( JFile::exists( $libpath.DS.$file.'.php' ) )
JFile::write( $libpath.DS.$file.'.php' , $content );
}*/
$file_list = $this->_copyIncludeFiles();
if( $file_list ) $msg .= "<h3>成功複製檔案</h3><ul>{$file_list}</ul><br /><br />" ;
// direct link
$sql = "SELECT * FROM #__extensions WHERE element='asikart_easyset' ;" ;
$db->setQuery( $sql );
$plugin = $db->loadObject() ;
$link = 'index.php?option=com_plugins&task=plugin.edit&extension_id='.$plugin->extension_id ;
$msg = "<p>Easy set 安裝成功。</p><br />
<h3><a href=\"{$link}\">[進入外掛管理]</a></h3><br /><br />".$msg;
echo $msg ;
}
/**
* method to uninstall the component
*
* @return void
*/
function uninstall($parent)
{
// $parent is the class calling this method
//echo '<p>' . JText::_('COM_HELLOWORLD_UNINSTALL_TEXT') . '</p>';
}
/**
* method to update the component
*
* @return void
*/
function update($parent)
{
// $parent is the class calling this method
$this->_createTable();
$file_list = $this->_copyIncludeFiles();
$msg = '';
if( $file_list ) $msg .= "<h3>成功複製更新檔案</h3><ul>{$file_list}</ul><br /><br />" ;
echo '<p>' . '更新成功'. '</p>'.$msg;
//JFolder::copy( JPATH_PLUGINS.DS.'system'.DS.'asikart_easyset' , JPATH_ROOT.DS.'easyset' , '' , true );
}
/**
* method to run before an install/update/uninstall method
*
* @return void
*/
function preflight($type, $parent)
{
// $parent is the class calling this method
// $type is the type of change (install, update or discover_install)
//echo '<p>' . JText::_('COM_HELLOWORLD_PREFLIGHT_' . $type . '_TEXT') . '</p>';
}
/**
* method to run after an install/update/uninstall method
*
* @return void
*/
function postflight($type, $parent)
{
$db = JFactory::getDbo();
// Get install manifest
// ========================================================================
$p_installer = $parent->getParent() ;
$installer = new JInstaller();
$manifest = $p_installer->manifest ;
$path = $p_installer->getPath('source');
$result = array() ;
$css =
<<<CSS
<style type="text/css">
#ak-install-img {
}
#ak-install-msg {
}
</style>
CSS;
echo $css ;
include_once $path.'/windwalker/admin/installscript.php' ;
}
function _copyIncludeFiles(){
$file_list = '' ;
// css
$types['css']['from'] = 'lib/events' ;
$types['css']['to'] = 'easyset/events' ;
// js
$types['js']['from'] = 'css' ;
$types['js']['to'] = 'easyset/css' ;
// events
$types['events']['from'] = 'js' ;
$types['events']['to'] = 'easyset/js' ;
foreach( $types as $type ):
$include_path = JPath::clean(JPATH_ROOT.'/plugins/system/asikart_easyset/'.$type['from']) ;
$include_path_to= JPath::clean(JPATH_ROOT.'/'.$type['to']) ;
$include_files = JFolder::files( $include_path , '.' , true , true ) ;
if( !JFolder::exists($include_path_to) ) JFolder::create( $include_path_to ) ;
foreach( $include_files as $include ){
$include = JPath::clean($include) ;
$file = str_replace( $include_path , $include_path_to , $include ) ;
if( !JFile::exists( $file ) ){
JFile::copy( $include , $file );
$file_list .= '<li>'.$file.'</li>' ;
}
}
endforeach;
return $file_list ;
}
function _createTable() {
$db = JFactory::getDbo();
//if($db->getTableCreate( '#__content_images' ))
//return ;
$sql = <<<SQL
CREATE TABLE IF NOT EXISTS `#__content_images` (
`contentid` INT( 11 ) NOT NULL ,
`catid` INT( 11 ) NOT NULL ,
`url` VARCHAR( 255 ) NOT NULL ,
`link` VARCHAR( 255 ) NOT NULL ,
`main` INT( 3 ) NOT NULL ,
`ordering` INT( 11 ) NOT NULL
) ENGINE = MYISAM ;
SQL;
$db->setQuery( $sql );
$db->query() ;
}
}