3 class mw_thumbs extends mw_plugin{
9 function description(){
10 return "Un générateur de miniatures";
13 function install($env){
15 $env->bdd("sgbd") == "mysql"
16 || $env->bdd("sgbd") == "pdo_mysql"
18 return $this->install_mysql($env);
21 $env->bdd("sgbd") == "pdo_sqlite"
23 return $this->install_sqlite($env);
26 $env->bdd("sgbd") == "xml"
28 return $this->install_xml($env);
31 return "Mode de stockage pour Mtweb (".$env->bdd("sgbd").") non supporté par mw_thumbs";
36 function install_mysql($env){
38 $sgbd = $data->sgbd();
40 $EXISTS = $sgbd->table_exists("#--thumbs");
43 return "impossible de savoir si la table #--thumbs existe";
46 return "la table #--thumbs existe deja";
50 "CREATE TABLE #--thumbs("
\r
51 ." `id` int(11) NOT NULL AUTO_INCREMENT,"
\r
52 ." `src` varchar(255) NOT NULL DEFAULT '',"
\r
53 ." `src_width` int(11) NOT NULL DEFAULT '0',"
\r
54 ." `src_height` int(11) NOT NULL DEFAULT '0',"
\r
55 ." `max_width` int(11) NOT NULL DEFAULT '0',"
\r
56 ." `max_height` int(11) NOT NULL DEFAULT '0',"
\r
57 ." `thumb_file` varchar(255) NOT NULL,"
\r
58 ." `thumb_width` int(11) NOT NULL DEFAULT '0',"
\r
59 ." `thumb_height` int(11) NOT NULL DEFAULT '0',"
\r
60 ." `creation_date` datetime NOT NULL,"
\r
61 ." PRIMARY KEY (`id`)"
\r
66 return "imposible de creer la table #--thumbs";
71 function install_sqlite($env){
73 $sgbd = $data->sgbd();
75 $EXISTS = $sgbd->table_exists("#--thumbs");
78 return "impossible de savoir si la table #--thumbs existe";
81 return "la table #--thumbs existe deja";
85 "CREATE TABLE #--thumbs("
\r
86 ." `id` INTEGER PRIMARY KEY AUTOINCREMENT"
\r
87 ." `src` TEXT NOT NULL DEFAULT '',"
\r
88 ." `src_width` INTEGER NOT NULL DEFAULT '0',"
\r
89 ." `src_height` INTEGER NOT NULL DEFAULT '0',"
\r
90 ." `max_width` INTEGER NOT NULL DEFAULT '0',"
\r
91 ." `max_height` INTEGER NOT NULL DEFAULT '0',"
\r
92 ." `thumb_file` TEXT NOT NULL,"
\r
93 ." `thumb_width` INTEGER NOT NULL DEFAULT '0',"
\r
94 ." `thumb_height` INTEGER NOT NULL DEFAULT '0',"
\r
95 ." `creation_date` TEXT NOT NULL"
\r
100 return "imposible de creer la table #--thumbs";
105 function install_xml($env){
106 $data = $env->data();
107 $sgbd = $data->sgbd();
108 $EXISTS = $sgbd->data_exists("thumbs");
110 return "impossible de savoir si la table #--thumbs existe";
113 return "la table #--thumbs existe deja";
115 if(!$sgbd->create_data("thumbs")){
116 return "imposible de creer la table #--thumbs";
121 function uninstall($env){
122 if($env->bdd("sgbd") == "xml") return $this->uninstall_xml($env);
123 else return $this->uninstall_sql($env);
126 function uninstall_xml($env){
127 $data = $env->data();
128 $sgbd = $data->sgbd();
129 if(!$this->disable($env)) return "impossible de desactiver le plugin";
130 $EXISTS = $sgbd->data_exists("thumbs");
132 return "impossible de savoir si la table #--thumbs existe";
135 // return "la table #--thumbs n'existe pas";
137 elseif(!$sgbd->remove_data("thumbs")){
138 return "imposible de supprimer la table #--thumbs";
143 function uninstall_sql($env){
144 $data = $env->data();
145 $sgbd = $data->sgbd();
146 if(!$this->disable($env)) return "impossible de desactiver le plugin";
148 $EXISTS = $sgbd->table_exists("#--thumbs");
151 return "impossible de savoir si la table #--thumbs existe";
154 // return "la table #--thumbs n'existe pas";
158 $sgbd->query("DROP TABLE #--thumbs");
161 return "imposible de supprimer la table #--thumbs";