source: extensions/header_manager/maintain.inc.php @ 26298

Last change on this file since 26298 was 26298, checked in by mistic100, 10 years ago

update for 2.6 + better calculation + option to force ratio
TODO: issue with PNG (unable to generate thumbnail with IM)

File size: 1.8 KB
Line 
1<?php
2defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
3
4class header_manager_maintain extends PluginMaintain
5{
6  private $installed = false;
7 
8  private $default_conf = array(
9      'width' => 1000,
10      'height' => 150,
11      'image' => 'random',
12      'display' => 'image_only',
13      'banner_on_picture' => true,
14    );
15
16  function install($plugin_version, &$errors=array())
17  {
18    global $conf, $prefixeTable;
19
20    // configuration
21    if (empty($conf['header_manager']))
22    {
23      $conf['header_manager'] = serialize($this->default_conf);
24      conf_update_param('header_manager', $conf['header_manager']);
25    }
26    else
27    {
28      $new_conf = is_string($conf['header_manager']) ? unserialize($conf['header_manager']) : $conf['header_manager'];
29      if (!isset($new_conf['banner_on_picture']))
30      {
31        $new_conf['banner_on_picture'] = true;
32        $conf['header_manager'] = serialize($new_conf);
33        conf_update_param('header_manager', $conf['header_manager']);
34      }
35    }
36
37    // banners directory
38    if (!file_exists(PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'banners')) 
39    {
40      mkdir(PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'banners', 0755);
41    }
42
43    // banners table
44    $query = '
45CREATE TABLE IF NOT EXISTS `' .$prefixeTable . 'category_banner` (
46  `category_id` smallint(5) unsigned NOT NULL,
47  `image` varchar(255) NOT NULL,
48  `deep` tinyint(1) DEFAULT 1,
49  PRIMARY KEY (`category_id`)
50) ENGINE=MyISAM DEFAULT CHARSET=utf8
51;';
52    pwg_query($query);
53
54    $this->installed = true;
55  }
56
57  function activate($plugin_version, &$errors=array())
58  {
59    if (!$this->installed)
60    {
61      $this->install($plugin_version, $errors);
62    }
63  }
64
65  function deactivate()
66  {
67  }
68
69  function uninstall()
70  {
71    global $prefixeTable;
72
73    conf_delete_param('header_manager');
74
75    pwg_query('DROP TABLE `' .$prefixeTable . 'category_banner`;');
76  }
77}
Note: See TracBrowser for help on using the repository browser.