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

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

hide NESW handles when forcing ratio

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