Changeset 17644


Ignore:
Timestamp:
Aug 25, 2012, 3:22:45 PM (8 years ago)
Author:
mistic100
Message:

improve upgrade process (for manual upgrades and piwigo.com upgrades)
improve delete button visibility

Location:
extensions/header_manager
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • extensions/header_manager/admin.php

    r16937 r17644  
    55load_language('plugin.lang', HEADER_MANAGER_PATH);
    66
    7 if (!file_exists(HEADER_MANAGER_DIR))
    8 {
    9   mkdir(HEADER_MANAGER_DIR, 0755);
    10 }
    11 
    127$page['tab'] = (isset($_GET['tab'])) ? $_GET['tab'] : 'config';
    138
    14 if ($page['tab'] == 'album')
    15 {
    16   include(HEADER_MANAGER_PATH . 'admin/album.php');
    17 }
    18 else
     9if ($page['tab'] != 'album')
    1910{
    2011  // tabsheet
    2112  include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');   
    2213  $tabsheet = new tabsheet();
     14  $tabsheet->set_id('header_manager');
    2315  $tabsheet->add('config', l10n('Configuration'), HEADER_MANAGER_ADMIN . '-config');
    2416  $tabsheet->add('add', l10n('Add a banner'), HEADER_MANAGER_ADMIN . '-add');
    2517  $tabsheet->select($page['tab']);
    2618  $tabsheet->assign();
    27 
    28   // include page
    29   include(HEADER_MANAGER_PATH . 'admin/' . $page['tab'] . '.php');
    3019
    3120  // template
     
    3625}
    3726
     27// include page
     28include(HEADER_MANAGER_PATH . 'admin/' . $page['tab'] . '.php');
     29
    3830$template->assign('HEADER_MANAGER_PATH', HEADER_MANAGER_PATH);
    3931
  • extensions/header_manager/admin/template/config.tpl

    r15958 r17644  
    3636  {if $banners}
    3737    <div class="banner-radio" style="display:block;">
    38       <input type="radio" name="image" value="random" id="banner-random"{if $BANNER_IMAGE=='random'}checked="checked"{/if}>
     38      <input type="radio" name="image" value="random" id="banner-random" {if $BANNER_IMAGE=='random'}checked="checked"{/if}>
    3939      <label for="banner-random"><b>{'Random'|@translate}</b></label>
    4040    </div>
     
    4343      <span class="actions">
    4444        <input type="radio" name="image" value="{$image.NAME}" id="banner-{$image.NAME}" {if $BANNER_IMAGE==$image.NAME}checked="checked"{/if}><br>
    45         <a href="{$CONFIG_URL}&amp;delete_banner={$image.NAME}" class="removeFilter" title="{'Delete'|@translate}" onclick="return confirm('{'Are you sure?'|@translate|@escape:javascript}');"><span>[x]</span></a>
    4645      </span>
    47       <label for="banner-{$image.NAME}"><img src="{$image.THUMB}" alt="{$image.NAME}"></label>
     46      <span class="banner-wrapper">
     47        <a href="{$CONFIG_URL}&amp;delete_banner={$image.NAME}" title="{'Delete'|@translate}" onclick="return confirm('{'Are you sure?'|@translate|@escape:javascript}');" class="delete-banner">&times;</a>
     48        <label for="banner-{$image.NAME}"><img src="{$image.THUMB}" alt="{$image.NAME}"></label>
     49      </span>
    4850    </div>
    4951    {/foreach}
  • extensions/header_manager/admin/template/style.css

    r15854 r17644  
    33  margin:5px 0 0 20px;
    44}
    5 .banner-radio .actions {
    6   display:inline-block;
    7   vertical-align:80%;
    8   text-align:center;
    9 }
     5  .banner-radio .actions {
     6    display:inline-block;
     7    padding-top:30px;
     8    vertical-align:top;
     9  }
     10  .banner-wrapper {
     11    display:inline-block;
     12    position:relative;
     13    width:230px;
     14    height:70px;
     15  }
     16    .delete-banner {
     17      position:absolute;
     18      display:block;
     19      top:0;
     20      right:0;
     21      margin:0;
     22      width:16px;
     23      height:16px;
     24      background:rgba(20,20,20,0.5);
     25      color:#eee;
     26      border:1px solid #999;
     27      border-top:none;
     28      border-right:none;
     29      border-radius:0 0 0 4px;
     30      font-weight:bold;
     31      text-align:center;
     32    }
     33      .delete-banner:hover {
     34        color:#e00 !important;
     35        border-color:#e00;
     36        background:rgba(20,20,20,1);
     37      }
     38
    1039.showInfo {
    1140  position:static;
  • extensions/header_manager/include/header_manager.inc.php

    r17012 r17644  
    88{
    99  global $conf, $user, $template, $page;
    10  
    11   if (defined('IN_ADMIN')) return $page_banner;
    1210 
    1311  // search banner for a specific category
     
    2826    if (count($cat_banners))
    2927    {
    30       function uppercats_sort($a, $b)
    31       {
    32         global $page;
    33         $ids = explode(',', $page['category']['uppercats']);
    34         return array_search($a['category_id'], $ids) < array_search($b['category_id'], $ids);
    35       }
    36       usort($cat_banners, 'uppercats_sort');
     28      usort($cat_banners, 'hm_uppercats_sort');
    3729     
    3830      foreach ($cat_banners as $cat_banner)
     
    10698}
    10799
    108 /**
    109  * Header Manager admin link
    110  */
    111 function header_manager_admin_menu($menu)
     100function hm_uppercats_sort($a, $b)
    112101{
    113   array_push($menu, array(
    114     'NAME' => 'Header Manager',
    115     'URL' => HEADER_MANAGER_ADMIN,
    116   ));
    117   return $menu;
    118 }
    119 
    120 /**
    121  * tab on album edition page
    122  */
    123 function header_manager_tab($sheets, $id)
    124 {
    125   if ($id == 'album')
    126   {
    127     load_language('plugin.lang', HEADER_MANAGER_PATH);
    128    
    129     $sheets['headermanager'] = array(
    130       'caption' => l10n('Banner'),
    131       'url' => HEADER_MANAGER_ADMIN.'-album&amp;cat_id='.$_GET['cat_id'],
    132       );
    133   }
    134  
    135   return $sheets;
     102  global $page;
     103  $ids = explode(',', $page['category']['uppercats']);
     104  return array_search($a['category_id'], $ids) < array_search($b['category_id'], $ids);
    136105}
    137106
  • extensions/header_manager/main.inc.php

    r17012 r17644  
    1212
    1313global $prefixeTable;
    14 define('HEADER_MANAGER_PATH', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
    15 define('HEADER_MANAGER_ADMIN', get_root_url() . 'admin.php?page=plugin-' . basename(dirname(__FILE__)));
    16 define('HEADER_MANAGER_DIR', PWG_LOCAL_DIR . 'banners/');
    17 define('HEADER_MANAGER_TABLE', $prefixeTable . 'category_banner');
     14define('HEADER_MANAGER_PATH',    PHPWG_PLUGINS_PATH . 'header_manager/');
     15define('HEADER_MANAGER_ADMIN',   get_root_url() . 'admin.php?page=plugin-header_manager');
     16define('HEADER_MANAGER_DIR',     PWG_LOCAL_DIR . 'banners/');
     17define('HEADER_MANAGER_TABLE',   $prefixeTable . 'category_banner');
     18define('HEADER_MANAGER_VERSION', '1.0.3');
    1819
    1920add_event_handler('init', 'header_manager_init');
     
    2627  $conf['header_manager'] = unserialize($conf['header_manager']);
    2728   
    28   include(HEADER_MANAGER_PATH . 'include/functions.inc.php');
    29   include(HEADER_MANAGER_PATH . 'include/header_manager.inc.php');
     29  include_once(HEADER_MANAGER_PATH . 'include/functions.inc.php');
     30  include_once(HEADER_MANAGER_PATH . 'include/header_manager.inc.php');
    3031 
    31   add_event_handler('render_page_banner', 'header_manager_render');
    32 
    33   if (defined('IN_ADMIN'))
     32  if (!defined('IN_ADMIN'))
    3433  {
     34    add_event_handler('render_page_banner', 'header_manager_render');
     35  }
     36  else
     37  {
     38    add_event_handler('loc_begin_admin_page', 'header_manager_check_version');
     39    add_event_handler('get_admin_plugin_menu_links', 'header_manager_admin_menu');
    3540    add_event_handler('tabsheet_before_select', 'header_manager_tab', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
    36     add_event_handler('get_admin_plugin_menu_links', 'header_manager_admin_menu');
    3741    add_event_handler('delete_categories', 'header_manager_delete_categories');
    3842  }
    3943}
    4044
     45/**
     46 * Header Manager admin link
     47 */
     48function header_manager_admin_menu($menu)
     49{
     50  array_push($menu, array(
     51    'NAME' => 'Header Manager',
     52    'URL' => HEADER_MANAGER_ADMIN,
     53  ));
     54  return $menu;
     55}
     56
     57/**
     58 * tab on album edition page
     59 */
     60function header_manager_tab($sheets, $id)
     61{
     62  if ($id == 'album')
     63  {
     64    load_language('plugin.lang', HEADER_MANAGER_PATH);
     65   
     66    $sheets['headermanager'] = array(
     67      'caption' => l10n('Banner'),
     68      'url' => HEADER_MANAGER_ADMIN.'-album&amp;cat_id='.$_GET['cat_id'],
     69      );
     70  }
     71 
     72  return $sheets;
     73}
     74
     75/**
     76 * updating the plugin
     77 */
     78function header_manager_check_version()
     79{
     80  global $pwg_loaded_plugins, $page;
     81 
     82  if (
     83    (
     84      @$page['page'] == 'intro' or
     85      @$_GET['section'] == 'header_manager/admin.php'
     86    )
     87    and
     88    (
     89      $pwg_loaded_plugins['header_manager']['version'] == 'auto' or
     90      version_compare($pwg_loaded_plugins['header_manager']['version'], HEADER_MANAGER_VERSION, '<')
     91    )
     92  )
     93  {
     94    include_once(HEADER_MANAGER_PATH . 'include/install.inc.php');
     95    header_manager_install();
     96   
     97    if ($pwg_loaded_plugins['header_manager']['version'] != 'auto')
     98    {
     99      $query = '
     100UPDATE '. PLUGINS_TABLE .'
     101SET version = "'. HEADER_MANAGER_VERSION .'"
     102WHERE id = "header_manager"';
     103      pwg_query($query);
     104    }
     105  }
     106}
     107
    41108?>
  • extensions/header_manager/maintain.inc.php

    r16937 r17644  
    11<?php
    22if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    3 
    4 define('header_dir', PWG_LOCAL_DIR . 'banners/');
    5 
    6 define(
    7   'header_manager_default_config',
    8   serialize(array(
    9     'width' => 1000,
    10     'height' => 150,
    11     'image' => 'random',
    12     'display' => 'image_only'
    13     ))
    14   );
    153 
     4include_once(PHPWG_PLUGINS_PATH . 'header_manager/include/install.inc.php');
    165
    176function plugin_install()
    187{
    19   global $prefixeTable;
    20  
    21         pwg_query(
    22 'CREATE TABLE IF NOT EXISTS `' .$prefixeTable . 'category_banner` (
    23   `category_id` smallint(5) unsigned NOT NULL,
    24   `image` varchar(255) NOT NULL,
    25   `deep` tinyint(1) DEFAULT 1,
    26   PRIMARY KEY (`category_id`)
    27 ) ENGINE=MyISAM DEFAULT CHARSET=utf8
    28 ;');
    29 
    30   conf_update_param('header_manager', header_manager_default_config);
    31   mkdir(header_dir, 0755);
     8  header_manager_install();
     9  define('header_manager_installed', true);
    3210}
    3311
    3412function plugin_activate()
    3513{
    36   global $conf, $prefixeTable;
    37 
    38   if (empty($conf['header_manager']))
     14  if (!defined('header_manager_installed'))
    3915  {
    40     conf_update_param('header_manager', header_manager_default_config);
     16    header_manager_install()
    4117  }
    42   if (!file_exists(header_dir))
    43   {
    44     mkdir(header_dir, 0755);
    45   }
    46  
    47   pwg_query(
    48 'CREATE TABLE IF NOT EXISTS `' .$prefixeTable . 'category_banner` (
    49   `category_id` smallint(5) unsigned NOT NULL,
    50   `image` varchar(255) NOT NULL,
    51   `deep` tinyint(1) DEFAULT 1,
    52   PRIMARY KEY (`category_id`)
    53 ) ENGINE=MyISAM DEFAULT CHARSET=utf8
    54 ;');
    5518}
    5619
Note: See TracChangeset for help on using the changeset viewer.