Subversion Repositories ggsysinfo

[/] [classes/] [sysinfomodule.php] - Blame information for rev 123

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 76 gg
<?php
2
/**
3
 * Class used to help managing in a single place all module/view info
4
 *
5
 * @author G. Giunta
6
 * @version $Id: contentstats.php 2570 2008-11-25 11:35:44Z ezsystems $
7
 * @copyright (C) G. Giunta 2010
8
 * @license Licensed under GNU General Public License v2.0. See file license.txt
9
 */
10
 
11
class sysinfoModule{
12
 
13 89 gg
    static $initialized = false;
14
 
15
    /**
16
    * Structure used by eZP module view definitions, augmented somewhat by:
17
    * - title / name ???
18
    * - description
19
    * - disabled (this one is calculated by the initialize() function
20 91 gg
    * - hidden (for left menu)
21 89 gg
    */
22 76 gg
    static $view_groups = array(
23
 
24
        'Index' => array(
25
            'index' => array(
26
                "script" => "genericview.php",
27
                "default_navigation_part" => 'ezsysinfonavigationpart',
28
                'name' => '',
29
                'title' => 'System Information' ),
30
        ),
31
 
32
        'PHP' => array(
33
            'php' => array(
34
                //'functions' => array( 'system_info' ), - we check in the module itself
35
                "script" => "genericview.php",
36
                "default_navigation_part" => 'ezsysinfonavigationpart',
37
                'name' => 'phpinfo()',
38
                'description' => 'The standard phpinfo() information page detailing php settings' ),
39
 
40
            'apc' => array(
41
                //'functions' => array( 'system_info' ), - we check in the module itself
42
                "script" => "genericview.php",
43
                "default_navigation_part" => 'ezsysinfonavigationpart',
44
                'name' => 'APC',
45 89 gg
                'description' => 'The control panel for the APC opcode cache',
46
                'disabled' => true ),
47 76 gg
 
48
            'eaccelerator' => array(
49
                //'functions' => array( 'system_info' ), - we check in the module itself
50
                "script" => "genericview.php",
51
                "default_navigation_part" => 'ezsysinfonavigationpart',
52
                'name' => 'eAccelerator',
53 89 gg
                'description' => 'The control panel for the eAccelerator opcode cache',
54
                'disabled' => true ),
55 76 gg
 
56
            'xcache' => array(
57
                //'functions' => array( 'system_info' ), - we check in the module itself
58
                "script" => "genericview.php",
59
                "default_navigation_part" => 'ezsysinfonavigationpart',
60
                'name' => 'XCache',
61 89 gg
                'description' => 'The control panel for the XCache opcode cache',
62
                'disabled' => true ),
63 76 gg
 
64
            'wincache' => array(
65
                //'functions' => array( 'system_info' ), - we check in the module itself
66
                "script" => "genericview.php",
67
                "default_navigation_part" => 'ezsysinfonavigationpart',
68
                'name' => 'WinCache',
69 89 gg
                'description' => 'The control panel for the WinCache opcode cache',
70
                'disabled' => true ),
71 76 gg
        ),
72
        'eZPublish' => array(
73
 
74
            'systemstatus' => array(
75
                //'functions' => array( 'system_info' ), - we check in the module itself
76 91 gg
                "script" => "genericview.php",
77 76 gg
                "default_navigation_part" => 'ezsysinfonavigationpart',
78
                "params" => array( 'output_format' ),
79 100 gg
                'name' => 'System status',
80
                'description' => 'Executes tests to verify the functioning of various parts of the system (e.g. connection to the database or to the eZFind indexing server)' ),
81 76 gg
 
82
            'cachestats' => array(
83
                //'functions' => array( 'system_info' ), - we check in the module itself
84
                "script" => "genericview.php",
85
                "default_navigation_part" => 'ezsysinfonavigationpart',
86 89 gg
                'name' => 'Cache stats',
87 100 gg
                'description' => 'Number of files and total size per every cache type',
88 89 gg
                'disabled' => true ),
89 76 gg
 
90
            'cachesearch' => array(
91
                //'functions' => array( 'system_info' ), - we check in the module itself
92 91 gg
                "script" => "genericview.php",
93 76 gg
                "default_navigation_part" => 'ezsysinfonavigationpart',
94 89 gg
                'name' => 'Cache search',
95 100 gg
                'description' => 'Allows to search for a given string or regexp in the different cache files',
96 89 gg
                'disabled' => true ),
97 76 gg
 
98
 
99
            'storagestats' => array(
100
                //'functions' => array( 'system_info' ), - we check in the module itself
101
                "script" => "genericview.php",
102
                "default_navigation_part" => 'ezsysinfonavigationpart',
103 89 gg
                'name' => 'Storage stats',
104 100 gg
                'description' => 'Number of files and total size for binary contents',
105 89 gg
                'disabled' => true ),
106 76 gg
 
107
            'storagechurn' => array(
108
                //'functions' => array( 'system_info' ), - we check in the module itself
109
                "script" => "genericview.php",
110
                "default_navigation_part" => 'ezsysinfonavigationpart',
111 100 gg
                'name' => 'Storage churn',
112
                'description' => 'Graph of number of files per minutes written to disk (including caches and binary contents)' ),
113 76 gg
 
114
            'contentstats' => array(
115
                //'functions' => array( 'system_info' ), - we check in the module itself
116
                "script" => "genericview.php",
117
                "default_navigation_part" => 'ezsysinfonavigationpart',
118 100 gg
                'name' => 'Content stats',
119
                'description' => 'Number of content objects present, information collections, pending notification events, pending indexation events etc...' ),
120 76 gg
 
121
            'logstats' => array(
122
                //'functions' => array( 'system_info' ), - we check in the module itself
123
                "script" => "genericview.php",
124
                "default_navigation_part" => 'ezsysinfonavigationpart',
125 100 gg
                'name' => 'Log Stats',
126
                'description' => 'Total size and last modification date of log files' ),
127 76 gg
 
128 91 gg
            /*'logsearch' => array(
129 76 gg
                //'functions' => array( 'system_info' ), - we check in the module itself
130
                "script" => "logsearch.php",
131
                "default_navigation_part" => 'ezsysinfonavigationpart',
132 91 gg
                'name' => 'Log search' ),*/
133 76 gg
 
134
            'logchurn' => array(
135
                //'functions' => array( 'system_info' ), - we check in the module itself
136
                "script" => "genericview.php",
137
                "default_navigation_part" => 'ezsysinfonavigationpart',
138
                "unordered_params" => array(),
139 100 gg
                'name' => 'Log churn',
140
                'description' => 'Graph of events written per minute in the log files' ),
141 76 gg
 
142
            'logview' => array(
143
                //'functions' => array( 'system_info' ), - we check in the module itself
144 91 gg
                "script" => "genericview.php",
145 76 gg
                "default_navigation_part" => 'ezsysinfonavigationpart',
146
                "params" => array( 'logfile' ),
147 91 gg
                'name' => 'Log view',
148
                'hidden' => true ),
149 76 gg
 
150
        ),
151
        'Development' => array(
152
 
153
/*'extensiondetails'] = array(
154
   "script" => "extensiondetails.php",
155
   "default_navigation_part" => 'ezsysinfonavigationpart',
156
   "params" => array( 'extensionname' ) );*/
157
 
158
        'modulelist' => array(
159
            //'functions' => array( 'system_info' ), - we check in the module itself
160 91 gg
            "script" => "genericview.php",
161 76 gg
            "default_navigation_part" => 'ezsysinfonavigationpart',
162
            "params" => array( 'extensionname' ),
163 100 gg
            'name' => 'Module list',
164
            'description' => 'List of all active modules' ),
165 76 gg
 
166
/*'moduledetails'] = array(
167
   "script" => "moduledetails.php",
168
   "default_navigation_part" => 'ezsysinfonavigationpart',
169
   "params" => array( 'modulename' ) );*/
170
 
171
        'viewlist' => array(
172
            //'functions' => array( 'system_info' ), - we check in the module itself
173 91 gg
            "script" => "genericview.php",
174 76 gg
            "default_navigation_part" => 'ezsysinfonavigationpart',
175
            "params" => array( 'modulename' ),
176 100 gg
            'name' => 'View list',
177
            'description' => 'List of all module views' ),
178 76 gg
 
179
/*'viewdetails'] = array(
180
   "script" => "viewdetails.php",
181
   "default_navigation_part" => 'ezsysinfonavigationpart',
182
   "params" => array( 'modulename', 'viewname' ) );*/
183
 
184
        'policylist' => array(
185
            //'functions' => array( 'system_info' ), - we check in the module itself
186 91 gg
            "script" => "genericview.php",
187 76 gg
            "default_navigation_part" => 'ezsysinfonavigationpart',
188
            "params" => array( 'modulename' ),
189 100 gg
            'name' => 'Policy functions list',
190
            'description' => 'List of all module access policies' ),
191 76 gg
 
192 88 gg
        'operationlist' => array(
193
            //'functions' => array( 'system_info' ), - we check in the module itself
194 91 gg
            "script" => "genericview.php",
195 88 gg
            "default_navigation_part" => 'ezsysinfonavigationpart',
196
            "params" => array( 'modulename' ),
197 100 gg
            'name' => 'Operations list',
198
            'description' => 'List of all module operations' ),
199 88 gg
 
200 76 gg
        'fetchlist' => array(
201
            //'functions' => array( 'system_info' ), - we check in the module itself
202 91 gg
            "script" => "genericview.php",
203 76 gg
            "default_navigation_part" => 'ezsysinfonavigationpart',
204
            "params" => array( 'modulename' ),
205 100 gg
            'name' => 'Fetch functions list',
206
            'description' => 'List of all module fetch functions' ),
207 76 gg
 
208
/*'operatorlist'] = array(
209
   //'functions' => array( 'system_info' ), - we check in the module itself
210
   "script" => "operatorlist.php",
211
   "default_navigation_part" => 'ezsysinfonavigationpart',
212
   "params" => array( ) );*/
213
 
214
        ),
215
        'QA' => array(
216
 
217 123 gg
            'secinfo' => array(
218
                //'functions' => array( 'system_info' ), - we check in the module itself
219
                "script" => "genericview.php",
220
                "default_navigation_part" => 'ezsysinfonavigationpart',
221
                'name' => 'Security checks',
222
                'description' => 'Executes tests to verify the proper configuration of the system for security-related aspects' ),
223
 
224 76 gg
            'inifilesqa' => array(
225
                //'functions' => array( 'system_info' ), - we check in the module itself
226
                "script" => "genericview.php",
227
                "default_navigation_part" => 'ezsysinfonavigationpart',
228 100 gg
                'name' => 'Ini files problems',
229
                'description' => 'Checks for all ini files found the correct naming conventions' ),
230 76 gg
 
231 81 gg
            'inisettingsqa' => array(
232 76 gg
                //'functions' => array( 'system_info' ), - we check in the module itself
233 81 gg
                "script" => "genericview.php",
234 76 gg
                "default_navigation_part" => 'ezsysinfonavigationpart',
235 100 gg
                'name' => 'Ini values problems',
236
                'description' => 'Checks for all ini files found the correctness of syntax, presence of php opening comment tag and charset declaration' ),
237 76 gg
 
238 82 gg
            'phpfilesqa' => array(
239
                //'functions' => array( 'system_info' ), - we check in the module itself
240
                "script" => "genericview.php",
241
                "default_navigation_part" => 'ezsysinfonavigationpart',
242 100 gg
                'name' => 'Php files problems',
243
                'description' => 'Checks for all php files found the presence of opening and closing php tags' ),
244 82 gg
 
245 76 gg
        ),
246
        'Reports' => array(
247
 
248
            'classesreport' => array(
249
                //'functions' => array( 'system_info' ), - we check in the module itself
250
                "script" => "genericview.php",
251
                "default_navigation_part" => 'ezsysinfonavigationpart',
252
                "params" => array( ),
253
                'name' => 'Content classes',
254 100 gg
                'title' => 'Content classes report',
255 112 gg
                'description' => 'Definition of all content classes in a format friendly to backups' ),
256 76 gg
 
257 112 gg
            'policiesreport' => array(
258
                //'functions' => array( 'system_info' ), - we check in the module itself
259
                "script" => "genericview.php",
260
                "default_navigation_part" => 'ezsysinfonavigationpart',
261
                "params" => array( ),
262
                'name' => 'Roles & Policies',
263
                'title' => 'Roles & Policies report',
264
                'description' => 'Definition of all Roles & Policies in a format friendly to backups' ),
265
 
266 76 gg
        )
267
    );
268
 
269 89 gg
    protected static function initialize( $force=false )
270
    {
271
        if ( self::$initialized && !$force )
272
        {
273
            return;
274
        }
275
 
276 100 gg
        // starting with version 4.1, this is available in the Setup|System Info page
277
        if ( version_compare( '4.1', eZPublishSDK::version() ) <= 0 )
278
        {
279
             self::$view_groups['PHP']['php']['hidden'] = true;
280
        }
281
 
282 89 gg
        $ini = eZINI::instance( 'file.ini' );
283
        $h = $ini->variable( 'ClusteringSettings', 'FileHandler' );
284
        if ( in_array( $h, array( 'ezfs', 'eZFSFileHandler', 'eZFS2FileHandler' ) ) )
285
        {
286
            self::$view_groups['eZPublish']['cachestats']['disabled'] = false;
287
            self::$view_groups['eZPublish']['cachesearch']['disabled'] = false;
288
            self::$view_groups['eZPublish']['storagestats']['disabled'] = false;
289
        }
290 100 gg
 
291 89 gg
        /*if ( isset( $GLOBALS['_PHPA'] ) )
292
        {
293
           self::$view_groups['PHP']['phpaccelerator'];
294
        }
295
        else if ( extension_loaded( "Turck MMCache" ) )
296
        {
297
            $operatorValue = 'mmcache';
298
        }*/
299 119 gg
        if ( extension_loaded( "eAccelerator" ) )
300 89 gg
        {
301
            self::$view_groups['PHP']['eaccelerator']['disabled'] = false;
302
        }
303 119 gg
        if ( extension_loaded( "apc" ) )
304 89 gg
        {
305
             self::$view_groups['PHP']['apc']['disabled'] = false;
306
        }
307
        /*else if ( extension_loaded( "Zend Performance Suite" ) )
308
        {
309
            $operatorValue = 'performancesuite';
310
        }*/
311 119 gg
        if ( extension_loaded( "xcache" ) )
312 89 gg
        {
313
            self::$view_groups['PHP']['xcache']['disabled'] = false;
314
        }
315 119 gg
        if ( extension_loaded( "wincache" ) )
316 89 gg
        {
317
             self::$view_groups['PHP']['wincache']['disabled'] = false;
318
        }
319 100 gg
 
320 89 gg
        self::$initialized = true;
321
    }
322
 
323 76 gg
    static function groupList()
324
    {
325 89 gg
        self::initialize();
326
        return self::$view_groups;
327 76 gg
    }
328
 
329
    static function viewList( $group='' )
330
    {
331 89 gg
        self::initialize();
332 76 gg
        $viewlist = array();
333
        if ( $group == '' )
334
        {
335
            foreach( self::$view_groups as $views )
336
            {
337
                $viewlist = array_merge( $viewlist, $views );
338
            }
339
        }
340
        else if ( isset( self::$view_groups[$group] ) )
341
        {
342
            $viewlist = self::$view_groups[$group];
343
        }
344
        return $viewlist;
345
    }
346
 
347
    /// @todo use name if title is missing
348
    static function viewTitle( $viewname )
349
    {
350
        foreach( self::$view_groups as $views )
351
        {
352
            if ( array_key_exists( $viewname, $views ) )
353
            {
354
                return isset( $views[$viewname]['title'] ) ? $views[$viewname]['title'] : $views[$viewname]['name'];
355
            }
356
        }
357
        return 'title';
358
    }
359
 
360
    static function viewName( $viewname )
361
    {
362
        foreach( self::$view_groups as $views )
363
        {
364
            if ( array_key_exists( $viewname, $views ) )
365
            {
366
                return $views[$viewname]['name'];
367
            }
368
        }
369
        return 'title-for-path';
370
    }
371 91 gg
 
372
    /// true if view is neither hidden nor disabled
373
    static function viewActive( $viewname )
374
    {
375
        foreach( self::$view_groups as $views )
376
        {
377
            if ( array_key_exists( $viewname, $views ) )
378
            {
379
                return !@$views[$viewname]['disabled'] && !@$views[$viewname]['hidden'];
380
            }
381
        }
382
        return false;
383
    }
384 76 gg
}
385
?>