Dotclear

source: plugins/pacKman/_install.php @ 3246

Revision 3246, 2.2 KB checked in by JcDenis, 10 years ago (diff)

Fix notice (unremoved old var), Fix install version comparison

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ----------------------------------
3#
4# This file is part of pacKman, a plugin for Dotclear 2.
5#
6# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
7# contact@jcdenis.fr
8#
9# Licensed under the GPL version 2.0 license.
10# A copy of this license is available in LICENSE file or at
11# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
12#
13# -- END LICENSE BLOCK ------------------------------------
14
15if (!defined('DC_CONTEXT_ADMIN')) {
16
17     return null;
18}
19
20# -- Module specs --
21
22$dc_min = '2.6';
23$mod_id = 'pacKman';
24$mod_conf = array(
25     array(
26          'packman_menu_plugins',
27          'Add link to pacKman in plugins page',
28          false,
29          'boolean'
30     ),
31     array(
32          'packman_pack_nocomment',
33          'Remove comments from files',
34          false,
35          'boolean'
36     ),
37     array(
38          'packman_pack_overwrite',
39          'Overwrite existing package',
40          false,
41          'boolean'
42     ),
43     array(
44          'packman_pack_filename',
45          'Name of package',
46          '%type%-%id%',
47          'string'
48     ),
49     array(
50          'packman_secondpack_filename',
51          'Name of second package',
52          '%type%-%id%-%version%',
53          'string'
54     ),
55     array(
56          'packman_pack_repository',
57          'Path to package repository',
58          '',
59          'string'
60     ),
61     array(
62          'packman_pack_excludefiles',
63          'Extra files to exclude from package',
64          '*.zip,*.tar,*.tar.gz,.directory,.hg',
65          'string'
66     )
67);
68
69# -- Nothing to change below --
70
71try {
72
73     # Check module version
74     if (version_compare(
75          $core->getVersion($mod_id),
76          $core->plugins->moduleInfo($mod_id, 'version'),
77          '>='
78     )) {
79
80          return null;
81     }
82
83     # Check Dotclear version
84     if (!method_exists('dcUtils', 'versionsCompare') 
85      || dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) {
86          throw new Exception(sprintf(
87               '%s requires Dotclear %s', $mod_id, $dc_min
88          ));
89     }
90
91     # Set module settings
92     $core->blog->settings->addNamespace($mod_id);
93     foreach($mod_conf as $v) {
94          $core->blog->settings->{$mod_id}->put(
95               $v[0], $v[2], $v[3], $v[1], false, true
96          );
97     }
98
99     # Set module version
100     $core->setVersion(
101          $mod_id,
102          $core->plugins->moduleInfo($mod_id, 'version')
103     );
104
105     return true;
106}
107catch (Exception $e) {
108     $core->error->add($e->getMessage());
109
110     return false;
111}
112
113?>
Note: See TracBrowser for help on using the repository browser.

Sites map