Changeset 3473


Ignore:
Timestamp:
Jun 29, 2009, 1:55:17 PM (15 years ago)
Author:
Criss
Message:

Add obsolete files management

Location:
extensions/CommentEditor
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • extensions/CommentEditor/administration.php

    r3465 r3473  
    11<?php
    2 /* $Id: administration.php,v 1.2 2009/06/26 14:40:27 Criss Exp $ */
     2/* $Id: administration.php,v 1.3 2009/06/29 11:43:18 Criss Exp $ */
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    44include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
     
    4949// Define common values
    5050$ce_common = array(
    51     'version' => CE_VERSION,
     51    'version' => $ce_plugin->getVersion(),
    5252    'title'   => $ce_plugin->plugin_id,
    5353);
  • extensions/CommentEditor/classes/ce_config.class.php

    r3462 r3473  
    8989        REPLACE INTO '.CONFIG_TABLE.'
    9090        VALUES(
    91           \''.$plugin_id.'\',
    92           \''.serialize($default_config).'\',
     91          \'' . $plugin_id . '\',
     92          \'' . serialize($default_config) . '\',
    9393          \'Factory settings for '. $plugin_id . '\')
    9494        ;';
     
    104104    $query = '
    105105        DELETE FROM '.CONFIG_TABLE.'
    106         WHERE param = \''.$plugin_id.'\'
     106        WHERE param = \'' . $plugin_id . '\'
    107107        ;';
    108108    $result = pwg_query($query);
  • extensions/CommentEditor/classes/ce_plugin.class.php

    r3462 r3473  
    11<?php
    2 /* $Id: ce_plugin.class.php,v 1.11 2009/06/26 09:17:01 Criss Exp $ */
     2/* $Id: ce_plugin.class.php,v 1.12 2009/06/29 11:43:18 Criss Exp $ */
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    44
     
    110110  function loc_begin_picture() {
    111111    $this->doAction();
     112  }
     113
     114  /* ************************ */
     115  /* ** Accessors          ** */
     116  /* ************************ */
     117
     118  function getVersion() {
     119    if (isset($this->config->config_values[CE_CFG_VERSION])) {
     120      return $this->config->config_values[CE_CFG_VERSION];
     121    }
     122    return CE_VERSION;
    112123  }
    113124
  • extensions/CommentEditor/include/ce_common.inc.php

    r3462 r3473  
    11<?php
    2 /* $Id: ce_common.inc.php,v 1.11 2009/06/26 09:49:27 Criss Exp $ */
     2/* $Id: ce_common.inc.php,v 1.12 2009/06/29 11:43:18 Criss Exp $ */
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
     4
     5/* ************************** */
     6/* ** Constants            ** */
     7/* ************************** */
     8
     9// Version update
     10define('CE_VERSION',  '1.0.j');
    411
    512// Define constants
     
    1623define('CE_AMDIN_TPL',     CE_ROOT.CE_ADMIN_DIR.CE_TEMPLATE_DIR);
    1724
     25define('CE_OBSOLETE',      'obsolete.list');
    1826define('CE_ERRORS',        CE_INCLUDE.'errors.png');
    1927define('CE_INFOS',         CE_INCLUDE.'infos.png');
     
    2937define('CE_ACTION_ERROR',  'error_comment');
    3038
     39// Config keys
     40if (isset($plugin)) {
     41  define('CE_CFG_DB_KEY',     $plugin['id']);
     42  define('CE_CFG_DB_COMMENT', 'Configuration of plugin ' . $plugin['id']);
     43}
     44define('CE_CFG_DISPLAY_ERROR',  'display_error');
     45define('CE_CFG_DISPLAY_INFO',   'display_info');
     46define('CE_CFG_VERSION',        'version');
     47
     48// Templates usage
     49define('CE_CHECKED',  'checked="checked"');
     50
     51/* ************************** */
     52/* ** Includes             ** */
     53/* ************************** */
     54
    3155// Include plugin functions
    3256@include_once(CE_INCLUDE.'ce_functions.inc.php');
     
    3761ce_require_class("CE_Plugin");
    3862
    39 // Config keys
    40 if (isset($plugin)) {
    41   define('CE_CFG_DB_KEY',     $plugin['id']);
    42   define('CE_CFG_DB_COMMENT', 'Configuration of plugin ' . $plugin['id']);
    43 }
    44 define('CE_CFG_DISPLAY_ERROR',  'display_error');
    45 define('CE_CFG_DISPLAY_INFO',   'display_info');
     63/* ************************** */
     64/* ** Variable definitions ** */
     65/* ************************** */
    4666
    4767// Config default values
     
    4969$ce_config_default[CE_CFG_DISPLAY_INFO]   = true;
    5070
    51 // Templates usage
    52 define('CE_CHECKED',  'checked="checked"')
    5371?>
  • extensions/CommentEditor/include/ce_functions.inc.php

    r3462 r3473  
    11<?php
    2 /* $Id: ce_functions.inc.php,v 1.6 2009/06/26 08:56:32 Criss Exp $ */
     2/* $Id: ce_functions.inc.php,v 1.7 2009/06/29 11:43:18 Criss Exp $ */
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    44
     
    1010function ce_require_class($aClassName) {
    1111  require_once CE_CLASSES .strtolower($aClassName) . '.class.php';
     12}
     13
     14function ce_clean_obsolete_files($obsolete_file_list) {
     15  if (!file_exists(CE_PATH.$obsolete_file_list)) {
     16    return TRUE;
     17  }
     18  $obsolete = file(CE_PATH.$obsolete_file_list);
     19  array_push($obsolete, $obsolete_file_list);
     20  return ce_clean_obsolete_list($obsolete);
     21}
     22
     23function ce_clean_obsolete_list($file_list = array(), &$errors = array()) {
     24  if (!function_exists('unlink')) {
     25      // No unlink available...
     26      array_push($errors, l10n('ce_no_unlink'));
     27      return FALSE;
     28  }
     29  $success = TRUE;
     30  foreach ($file_list as $file) {
     31    $file = CE_PATH . $file;
     32    if (file_exists($file)) {
     33      // Remove obsolete file
     34      $success &= unlink($file);
     35    }
     36  }
     37  if (!$success) {
     38      array_push($errors, l10n('ce_unlink_errors'));
     39  }
     40  return $success;
    1241}
    1342
  • extensions/CommentEditor/language/en_UK/plugin.lang.php

    r3465 r3473  
    11<?php
    2 /* $Id: plugin.lang.php,v 1.5 2009/06/26 14:40:27 Criss Exp $ */
     2/* $Id: plugin.lang.php,v 1.6 2009/06/29 11:43:18 Criss Exp $ */
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    44global $lang;
     
    2222// ==================================================================
    2323// Config
     24$lang['ce_inconsistent_version'] = '%s: inconsistent version numbers';
     25$lang['ce_no_unlink'] = 'Function \'unlink\' not available...';
     26$lang['ce_unlink_errors'] = 'Error occured during file deletion';
    2427$lang['ce_config_saved'] = 'Configuration successfully saved';
    2528$lang['ce_config_saved_with_errors'] = 'Configuration saved with errors';
  • extensions/CommentEditor/language/fr_FR/plugin.lang.php

    r3465 r3473  
    11<?php
    2 /* $Id: plugin.lang.php,v 1.6 2009/06/26 14:40:27 Criss Exp $ */
     2/* $Id: plugin.lang.php,v 1.7 2009/06/29 11:43:18 Criss Exp $ */
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    44global $lang;
     
    2121// ==================================================================
    2222// Config
     23$lang['ce_inconsistent_version'] = '%s : numéros de version incohérentes';
     24$lang['ce_no_unlink'] = 'La fonction \'unlink\' n\'est pas disponible';
     25$lang['ce_unlink_errors'] = 'Des erreurs ont eu lieu lors de la suppression de fichiers';
    2326$lang['ce_config_saved'] = 'Configuration sauvée avec succès';
    2427$lang['ce_config_saved_with_errors'] = 'Configuration sauvée mais avec des erreurs';
  • extensions/CommentEditor/language/it_IT/index.php

    r3471 r3473  
    55// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
    66// +-----------------------------------------------------------------------+
    7 // | file          : $Id: index.php,v 1.1 2009/06/15 21:42:12 cmarchad Exp $
    8 // | last update   : $Date: 2009/06/15 21:42:12 $
    9 // | last modifier : $Author: cmarchad $
     7// | file          : $Id: index.php,v 1.1 2009/06/29 11:51:59 Criss Exp $
     8// | last update   : $Date: 2009/06/29 11:51:59 $
     9// | last modifier : $Author: Criss $
    1010// | revision      : $Revision: 1.1 $
    1111// +-----------------------------------------------------------------------+
  • extensions/CommentEditor/language/it_IT/plugin.lang.php

    r3471 r3473  
    11<?php
    2 /* $Id: plugin.lang.php,v 1.4 2009/06/22 22:18:12 Criss Exp $ */
     2/* $Id: plugin.lang.php,v 1.1 2009/06/29 11:51:59 Criss Exp $ */
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    44global $lang;
    55
    6 
     6// ==================================================================
     7// Edit block
    78$lang['comment_edit'] = 'Edizione dei commenti';
    89$lang['comment_author'] = 'Autore';
    910$lang['comment_author_free'] = 'Scelta libera del\'autore';
    1011$lang['comment_content'] = 'Commento';
     12//$lang['comment_edit_tool'] = ''; // TODO
    1113
     14
     15// ==================================================================
     16// Message block
    1217$lang[CE_TYPE_INFO] = 'Informazione';
    1318$lang[CE_TYPE_ERROR] = 'Errore';
    1419$lang['comment_edit_forbidden'] = 'Non siete autorizati ad editare questo commento';
    1520$lang['comment_access_invalid'] = 'Accesso invalido';
     21
     22// ==================================================================
     23// Config
     24//$lang['ce_inconsistent_version'] = '%s : '; // TODO
     25//$lang['ce_no_unlink'] = ''; // TODO
     26//$lang['ce_unlink_errors'] = ''; // TODO
     27//$lang['ce_config_saved'] = ''; // TODO
     28//$lang['ce_config_saved_with_errors'] = ''; // TODO
     29//$lang['ce_button_submit'] = ''; // TODO
     30
     31// ==================================================================
     32// Config tab
     33//$lang['ce_tab_config'] = ''; // TODO
     34//$lang['ce_config_desc'] = ''; // TODO
     35//$lang['ce_label_config'] = ''; // TODO
     36//$lang['ce_label_display_info'] = ''; // TODO
     37//$lang['ce_label_display_error'] = ''; // TODO
    1638?>
  • extensions/CommentEditor/main.inc.php

    r3465 r3473  
    11<?php
    2 /* $Id: main.inc.php,v 1.15 2009/06/26 14:42:03 Criss Exp $ */
     2/* $Id: main.inc.php,v 1.17 2009/06/29 11:51:59 Criss Exp $ */
    33/*
    44 Plugin Name: Comment Editor
    5  Version: 1.0.i
     5 Version: 1.0.j
    66 Description: Allow to edit comment
    77 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=296
     
    1111
    1212/** History **
     13  2009-06-29 1.0.j
     14                    Add obsolete files management
     15                    Add italian language (thanks to Rio)
    1316
    1417  2009-06-26 1.0.i
     
    5053if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    5154
    52 define('CE_VERSION',  '1.0.i');
    5355define('CE_PATH',     PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
    5456define('CE_ROOT',     dirname(__FILE__).'/');
  • extensions/CommentEditor/maintain.inc.php

    r3462 r3473  
    1010}
    1111
    12 function plugin_install($plugin_id) {
     12function plugin_install($plugin_id, $version, &$errors) {
    1313  include_once(CE_PATH . 'include/ce_common.inc.php');
     14  // Include language advices
     15  load_language('plugin.lang', CE_PATH);
     16  if ($version != CE_VERSION) {
     17      array_push($errors, sprintf(l10n('ce_inconsistent_version'), $plugin_id));
     18      return;
     19  }
     20  $clean = ce_clean_obsolete_files(CE_OBSOLETE);
     21  $ce_config_default[CE_CFG_VERSION] = $version;
    1422  $install = CE_Config::install($plugin_id, $ce_config_default);
    1523}
    1624
    17 function plugin_activate($plugin_id) {
     25function plugin_activate($plugin_id, $version, &$errors) {
     26  // Nothing special
     27}
     28
     29function plugin_deactivate($plugin_id) {
    1830  // Nothing special
    1931}
     
    2335  $uninstall = CE_Config::uninstall($plugin_id);
    2436}
     37
    2538?>
Note: See TracChangeset for help on using the changeset viewer.