source: extensions/AdditionalPages/maintain.inc.php @ 3836

Last change on this file since 3836 was 3609, checked in by patdenice, 15 years ago

Convert all php and tpl files in Unix format for my plugins.

File size: 2.1 KB
Line 
1<?php
2
3function plugin_install()
4{
5  global $prefixeTable, $conf;
6
7  $query = 'SHOW TABLES LIKE "' . $prefixeTable . 'additionalpages"';
8  $result = pwg_query($query);
9  if (!mysql_fetch_row($result))
10  {
11    $query = 'CREATE TABLE ' . $prefixeTable . 'additionalpages (
12id SMALLINT( 5 ) UNSIGNED NOT NULL ,
13pos SMALLINT( 5 ) UNSIGNED default NULL ,
14lang VARCHAR( 255 ) NOT NULL ,
15title VARCHAR( 255 ) NOT NULL ,
16text LONGTEXT NOT NULL ,
17PRIMARY KEY (id) ,
18INDEX (pos) ,
19INDEX (lang))
20DEFAULT CHARACTER SET utf8;';
21    pwg_query($query);
22  }
23
24  if (!isset($conf['additional_pages']))
25  {
26    $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
27VALUES ("additional_pages" , "Additional Pages,on,on,off,off,,off,off" , "Parametres du plugin Additional Pages");';
28    pwg_query($query);
29  }
30}
31
32function plugin_activate()
33{
34  global $prefixeTable;
35
36  $q = pwg_query('SHOW COLUMNS FROM ' . HISTORY_TABLE . ' LIKE "section"');
37  $section = mysql_fetch_array($q);
38  $type = $section['Type'];
39
40  // Add additional page section into history table
41  if (strpos($type, 'additional_page') === false)
42  {
43    $type = strtr($type , array(')' => ',\'additional_page\')'));
44    pwg_query('ALTER TABLE ' . HISTORY_TABLE . ' CHANGE section section ' . $type . ' DEFAULT NULL');
45  }
46 
47  // Check if upgrade is needed
48  $query = 'SHOW FULL COLUMNS FROM ' . $prefixeTable . 'additionalpages;';
49  $result = array_from_query($query, 'Collation');
50  if (strpos($result[4], 'utf8') === false)
51  {
52    upgrade_ap_from_17();
53  }
54}
55
56function plugin_uninstall()
57{
58  global $prefixeTable;
59
60        $q = 'DROP TABLE ' . $prefixeTable . 'additionalpages;';
61  pwg_query($q);
62
63        $q = 'DELETE FROM ' . CONFIG_TABLE . ' WHERE param="additional_pages" LIMIT 1;';
64  pwg_query($q);
65}
66
67function upgrade_ap_from_17()
68{
69  global $prefixeTable;
70
71  $query = 'ALTER TABLE ' . $prefixeTable . 'additionalpages
72MODIFY COLUMN lang varchar(255) CHARACTER SET utf8 NOT NULL,
73MODIFY COLUMN title varchar(255) CHARACTER SET utf8 NOT NULL,
74MODIFY COLUMN text longtext CHARACTER SET utf8 NOT NULL,
75DEFAULT CHARACTER SET utf8;';
76
77  pwg_query($query);
78}
79
80?>
Note: See TracBrowser for help on using the repository browser.