[3329] | 1 | <?php |
---|
| 2 | |
---|
| 3 | function plugin_install() |
---|
| 4 | { |
---|
| 5 | global $prefixeTable; |
---|
| 6 | |
---|
| 7 | |
---|
| 8 | $q = 'CREATE TABLE ' . $prefixeTable . 'mp_playlist ( |
---|
[6877] | 9 | id SMALLINT NOT NULL AUTO_INCREMENT , |
---|
[3329] | 10 | type VARCHAR( 50 ) NOT NULL , |
---|
| 11 | url VARCHAR( 255 ) NOT NULL , |
---|
| 12 | texte TINYTEXT NOT NULL , |
---|
| 13 | PRIMARY KEY ( id ) |
---|
| 14 | ); |
---|
| 15 | '; |
---|
| 16 | pwg_query($q); |
---|
| 17 | $q = 'CREATE TABLE ' . $prefixeTable . 'mp_music ( |
---|
| 18 | id TINYINT NOT NULL AUTO_INCREMENT , |
---|
| 19 | pl_id TINYINT NOT NULL , |
---|
| 20 | rang TINYINT NOT NULL , |
---|
| 21 | url VARCHAR( 255 ) NOT NULL , |
---|
| 22 | nom VARCHAR( 255 ) NOT NULL , |
---|
| 23 | PRIMARY KEY ( id ) |
---|
| 24 | ); |
---|
| 25 | '; |
---|
| 26 | pwg_query($q); |
---|
| 27 | |
---|
| 28 | /* $q = 'CREATE TABLE ' . $prefixeTable . 'mp_playlist ( |
---|
| 29 | id TINYINT NOT NULL AUTO_INCREMENT , |
---|
| 30 | url VARCHAR( 255 ) NOT NULL , |
---|
| 31 | texte TINYTEXT NOT NULL , |
---|
| 32 | music MEDIUMTEXT NOT NULL , |
---|
| 33 | PRIMARY KEY ( id ) |
---|
| 34 | ); |
---|
| 35 | '; |
---|
| 36 | $q = 'CREATE TABLE ' . $prefixeTable . 'mp_config_save ( |
---|
| 37 | id TINYINT NOT NULL AUTO_INCREMENT , |
---|
| 38 | type VARCHAR( 255 ) NOT NULL , |
---|
| 39 | config TINYTEXT NOT NULL , |
---|
| 40 | PRIMARY KEY ( id ) |
---|
| 41 | ); |
---|
| 42 | ';*/ |
---|
| 43 | |
---|
| 44 | $q = ' |
---|
| 45 | INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) |
---|
| 46 | VALUES |
---|
[3559] | 47 | ("mp_lecteur" , "148,300,128,true,128,false,list,0,true,./template/style/default.conf.php,true" , "Lecteur config : haut tt, larg tt, haut pl, miniature, larg min, shuffle, repeat, autostart, autoscroll, style, style pour chaque thème");'; |
---|
[3329] | 48 | pwg_query($q); |
---|
| 49 | |
---|
| 50 | $q = ' |
---|
| 51 | INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) |
---|
| 52 | VALUES |
---|
[3542] | 53 | ("mp_plugin" , "true,false,false,260,400" , "Plugin music_player : evidence, header, footer, hauteur, largeur");'; |
---|
[3329] | 54 | pwg_query($q); |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | |
---|
| 59 | function plugin_activate() |
---|
| 60 | { |
---|
| 61 | global $prefixeTable; |
---|
| 62 | |
---|
| 63 | ///[ update from 1.2 ] |
---|
| 64 | $q = pwg_query('SHOW COLUMNS FROM '.$prefixeTable.'mp_playlist'); |
---|
| 65 | $champ = array(); |
---|
| 66 | while ($rep = mysql_fetch_row($q)) |
---|
| 67 | { |
---|
| 68 | array_push($champ, $rep[0]); |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | if (!in_array('type', $champ)) { |
---|
| 72 | pwg_query('ALTER TABLE '.$prefixeTable.'mp_playlist ADD type VARCHAR( 50 ) NOT NULL AFTER id '); |
---|
| 73 | } |
---|
| 74 | //ALTER TABLE `phpwebgallery_mp_playlist` ADD `type` VARCHAR( 50 ) NOT NULL AFTER `id` ; |
---|
| 75 | $query = ' |
---|
| 76 | SELECT COUNT(*) AS result FROM '.$prefixeTable.'mp_playlist |
---|
| 77 | WHERE type="" |
---|
| 78 | ;'; |
---|
| 79 | $data_table = mysql_fetch_array(pwg_query($query)); |
---|
| 80 | $exist = $data_table['result']; |
---|
| 81 | if ( $exist != 0 ) |
---|
| 82 | { |
---|
| 83 | $query = ' |
---|
| 84 | SELECT id FROM '.$prefixeTable.'mp_playlist |
---|
| 85 | WHERE type="" |
---|
| 86 | ;'; |
---|
| 87 | $result = pwg_query($query); |
---|
| 88 | while ($data = mysql_fetch_assoc($result)) |
---|
| 89 | { |
---|
| 90 | $query = ' |
---|
| 91 | UPDATE '.$prefixeTable.'mp_playlist |
---|
| 92 | SET type="local" |
---|
| 93 | WHERE id="'.$data['id'].'" |
---|
| 94 | LIMIT 1'; |
---|
| 95 | pwg_query($query); |
---|
| 96 | } |
---|
| 97 | } |
---|
| 98 | ///[\] |
---|
| 99 | |
---|
| 100 | $query = ' |
---|
| 101 | SELECT COUNT(*) AS result FROM '.CONFIG_TABLE.' |
---|
| 102 | WHERE param IN (\'mp_lecteur\') |
---|
| 103 | ;'; |
---|
| 104 | $data_table = mysql_fetch_array(pwg_query($query)); |
---|
| 105 | $exist = $data_table['result']; |
---|
| 106 | if ( $exist == 0 ) |
---|
| 107 | { |
---|
| 108 | $q = ' |
---|
| 109 | INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) |
---|
| 110 | VALUES |
---|
[3559] | 111 | ("mp_lecteur" , "148,300,128,true,128,false,list,0,true,./template/style/default.conf.php,true" , "Lecteur config : haut tt, larg tt, haut pl, miniature, larg min, shuffle, repeat, autostart, autoscroll, style, style pour chaque thème");'; |
---|
[3329] | 112 | pwg_query($q); |
---|
| 113 | } |
---|
| 114 | else { |
---|
| 115 | $query = ' |
---|
| 116 | SELECT value FROM '.CONFIG_TABLE.' |
---|
| 117 | WHERE param IN (\'mp_lecteur\') |
---|
| 118 | ;'; |
---|
| 119 | $data_conf = mysql_fetch_array(pwg_query($query)); |
---|
| 120 | $conf=explode(',', $data_conf['value']); |
---|
| 121 | $nbr=count($conf); |
---|
| 122 | |
---|
[3561] | 123 | if ($nbr!=11 or $conf[9]=='lecteur.css')// pour update depuis 2.1.0 |
---|
[3329] | 124 | { |
---|
| 125 | pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param IN (\'mp_lecteur\')'); |
---|
| 126 | pwg_query($q); |
---|
| 127 | $q = ' |
---|
| 128 | INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) |
---|
| 129 | VALUES |
---|
[3559] | 130 | ("mp_lecteur" , "148,300,128,true,128,false,list,0,true,./template/style/default.conf.php,true" , "Lecteur config : haut tt, larg tt, haut pl, miniature, larg min, shuffle, repeat, autostart, autoscroll, style, style pour chaque thème");'; |
---|
[3329] | 131 | pwg_query($q); |
---|
| 132 | } |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | |
---|
| 136 | $query = ' |
---|
| 137 | SELECT COUNT(*) AS result FROM '.CONFIG_TABLE.' |
---|
| 138 | WHERE param IN (\'mp_plugin\') |
---|
| 139 | ;'; |
---|
| 140 | $data_table = mysql_fetch_array(pwg_query($query)); |
---|
| 141 | $exist = $data_table['result']; |
---|
| 142 | if ( $exist == 0 ) |
---|
| 143 | { |
---|
| 144 | $q = ' |
---|
| 145 | INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) |
---|
| 146 | VALUES |
---|
[3542] | 147 | ("mp_plugin" , "true,false,false,260,400" , "Plugin music_player : evidence, header, footer, hauteur, largeur");'; |
---|
[3329] | 148 | pwg_query($q); |
---|
| 149 | } |
---|
| 150 | else { |
---|
| 151 | $query = ' |
---|
| 152 | SELECT value FROM '.CONFIG_TABLE.' |
---|
| 153 | WHERE param IN (\'mp_plugin\') |
---|
| 154 | ;'; |
---|
| 155 | $data_conf = mysql_fetch_array(pwg_query($query)); |
---|
| 156 | $conf=explode(',', $data_conf['value']); |
---|
| 157 | $nbr=count($conf); |
---|
| 158 | |
---|
| 159 | if ($nbr!=5) |
---|
| 160 | { |
---|
| 161 | pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param IN (\'mp_plugin\')'); |
---|
| 162 | pwg_query($q); |
---|
| 163 | $q = ' |
---|
| 164 | INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) |
---|
| 165 | VALUES |
---|
[3542] | 166 | ("mp_plugin" , "true,false,false,260,400" , "Plugin music_player : evidence, header, footer, hauteur, largeur");'; |
---|
[3329] | 167 | pwg_query($q); |
---|
| 168 | } |
---|
| 169 | } |
---|
| 170 | |
---|
| 171 | }//fin active |
---|
| 172 | |
---|
| 173 | |
---|
| 174 | |
---|
| 175 | |
---|
| 176 | function plugin_uninstall() |
---|
| 177 | { |
---|
| 178 | global $prefixeTable; |
---|
| 179 | |
---|
| 180 | $q = 'DROP TABLE ' . $prefixeTable . 'mp_playlist;'; |
---|
| 181 | pwg_query($q); |
---|
| 182 | $q = 'DROP TABLE ' . $prefixeTable . 'mp_music;'; |
---|
| 183 | pwg_query($q); |
---|
| 184 | |
---|
| 185 | pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param IN (\'mp_plugin\')'); |
---|
| 186 | pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param IN (\'mp_lecteur\')'); |
---|
| 187 | }//fin uninstall |
---|
| 188 | |
---|
| 189 | |
---|
| 190 | ?> |
---|