Ignore:
Timestamp:
Dec 21, 2013, 11:02:24 PM (10 years ago)
Author:
mistic100
Message:

update for Piwigo 2.6 + many code and logical cleaning

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/bbcode_bar/maintain.inc.php

    r14525 r26076  
    11<?php
    2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
     2defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
    33
    4 function plugin_install()
    5 { 
    6   global $conf;
     4class bbcode_bar_maintain extends PluginMaintain
     5{
     6  private $installed = false;
    77 
    8   $BBcode_default = array(
     8  private $default_conf = array(
    99    'b' => true,
    1010    'i' => true,
     
    2222    'size' => true,
    2323    'color' => true,
    24   );
     24    );
    2525
    26   if (!isset($conf['bbcode_bar']))
     26  function install($plugin_version, &$errors=array())
    2727  {
    28     conf_update_param('bbcode_bar',serialize($BBcode_default));
     28    global $conf;
     29   
     30    if (isset($conf['bbcode_bar']))
     31    {
     32      $conf['bbcode_bar'] = serialize($this->default_conf);
     33
     34      conf_update_param('bbcode_bar', $conf['bbcode_bar']);
     35    }
     36   
     37    $this->installed = true;
     38  }
     39
     40  function activate($plugin_version, &$errors=array())
     41  {
     42    if (!$this->installed)
     43    {
     44      $this->install($plugin_version, $errors);
     45    }
     46  }
     47
     48  function deactivate()
     49  {
     50  }
     51
     52  function uninstall()
     53  {
     54    conf_delete_param('bbcode_bar');
    2955  }
    3056}
    31 
    32 function plugin_activate()
    33 {
    34   global $conf;
    35  
    36   if (strpos($conf['bbcode_bar'],',') !== false)
    37   {
    38     $conf_bbcode_bar = explode(',', $conf['bbcode_bar']);
    39    
    40     $new_bbcode_bar =  array(
    41       'b' => $conf_bbcode_bar[1] == '1' ? true : false,
    42       'i' => $conf_bbcode_bar[2] == '1' ? true : false,
    43       'u' => $conf_bbcode_bar[3] == '1' ? true : false,
    44       's' => $conf_bbcode_bar[4] == '1' ? true : false,
    45       'p' => $conf_bbcode_bar[0] == '1' ? true : false,
    46       'center' => $conf_bbcode_bar[5] == '1' ? true : false,
    47       'right' => $conf_bbcode_bar[6] == '1' ? true : false,
    48       'quote' => $conf_bbcode_bar[9] == '1' ? true : false,
    49       'ul' => $conf_bbcode_bar[7] == '1' ? true : false,
    50       'ol' => $conf_bbcode_bar[8] == '1' ? true : false,
    51       'img' => $conf_bbcode_bar[10] == '1' ? true : false,
    52       'url' => $conf_bbcode_bar[11] == '1' ? true : false,
    53       'email' => $conf_bbcode_bar[12] == '1' ? true : false,
    54       'size' => $conf_bbcode_bar[13] == '1' ? true : false,
    55       'color' => $conf_bbcode_bar[14] == '1' ? true : false,
    56     );
    57    
    58     conf_update_param('bbcode_bar', serialize($new_bbcode_bar));
    59   }
    60 }
    61 
    62 function plugin_uninstall()
    63 {
    64   pwg_query('DELETE FROM ' . CONFIG_TABLE . ' WHERE param="bbcode_bar";');
    65 }
    66 
    67 ?>
Note: See TracChangeset for help on using the changeset viewer.