Dotclear


Ignore:
Timestamp:
11/14/13 08:32:17 (10 years ago)
Author:
JcDenis
Message:

switch to DC 2.6, clean up code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/dcFilterDuplicate/_install.php

    r2902 r3262  
    11<?php 
    22# -- BEGIN LICENSE BLOCK ---------------------------------- 
     3# 
    34# This file is part of dcFilterDuplicate, a plugin for Dotclear 2. 
    45#  
    5 # Copyright (c) 2009-2011 JC Denis and contributors 
    6 # jcdenis@gdwd.com 
     6# Copyright (c) 2009-2013 Jean-Christian Denis and contributors 
     7# contact@jcdenis.fr http://jcd.lv 
    78#  
    89# Licensed under the GPL version 2.0 license. 
    910# A copy of this license is available in LICENSE file or at 
    1011# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 
     12# 
    1113# -- END LICENSE BLOCK ------------------------------------ 
    1214 
    13 if (!defined('DC_CONTEXT_ADMIN')){return;} 
     15if (!defined('DC_CONTEXT_ADMIN')) { 
    1416 
    15 # Get new version 
    16 $new_version = $core->plugins->moduleInfo('dcFilterDuplicate','version'); 
    17 $old_version = $core->getVersion('dcFilterDuplicate'); 
     17     return null; 
     18} 
    1819 
    19 # Compare versions 
    20 if (version_compare($old_version,$new_version,'>=')) {return;} 
     20# -- Module specs -- 
    2121 
    22 # Install or update 
    23 try 
    24 { 
    25      # Check version 
    26      if (version_compare(str_replace("-r","-p",DC_VERSION),'2.2-alpha','<')) 
    27      { 
    28           throw new Exception('dcFilterDuplicate requires Dotclear 2.2'); 
     22$dc_min = '2.6'; 
     23$mod_id = 'dcFilterDuplicate'; 
     24$mod_conf = array( 
     25     array( 
     26          'dcfilterduplicate_minlen', 
     27          'Minimum lenght of comment to filter', 
     28          30, 
     29          'integer' 
     30     ) 
     31); 
     32 
     33# -- Nothing to change below -- 
     34 
     35try { 
     36 
     37     # Check module version 
     38     if (version_compare( 
     39          $core->getVersion($mod_id), 
     40          $core->plugins->moduleInfo($mod_id, 'version'), 
     41          '>=' 
     42     )) { 
     43 
     44          return null; 
    2945     } 
    30       
    31      # Settings 
    32      $core->blog->settings->addNamespace('dcFilterDuplicate'); 
    33      $core->blog->settings->dcFilterDuplicate->put('dcfilterduplicate_minlen',30,'integer','Minimum lenght of comment to filter',false,true); 
    3446 
    35      # Version 
    36      $core->setVersion('dcFilterDuplicate',$new_version); 
     47     # Check Dotclear version 
     48     if (!method_exists('dcUtils', 'versionsCompare')  
     49      || dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) { 
     50          throw new Exception(sprintf( 
     51               '%s requires Dotclear %s', $mod_id, $dc_min 
     52          )); 
     53     } 
     54 
     55     # Set module settings 
     56     $core->blog->settings->addNamespace($mod_id); 
     57     foreach($mod_conf as $v) { 
     58          $core->blog->settings->{$mod_id}->put( 
     59               $v[0], $v[2], $v[3], $v[1], false, true 
     60          ); 
     61     } 
     62 
     63     # Set module version 
     64     $core->setVersion( 
     65          $mod_id, 
     66          $core->plugins->moduleInfo($mod_id, 'version') 
     67     ); 
    3768 
    3869     return true; 
    3970} 
    40 catch (Exception $e) 
    41 { 
     71catch (Exception $e) { 
    4272     $core->error->add($e->getMessage()); 
     73 
    4374     return false; 
    4475} 
    45 ?> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map