OSDN Git Service

Subversion由来のタグを削除
[nucleus-jp/nucleus-jp-ancient.git] / nucleus / plugins / NP_SkinFiles.php
1 <?php
2 /* ==========================================================================================
3  * Nucleus SkinFiles Plugin
4  *
5  * Copyright 2005-2009 by Jeff MacMichael and Niels Leenheer
6  *
7  * ==========================================================================================
8  * This program is free software and open source software; you can redistribute
9  * it and/or modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of the License,
11  * or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
16  * more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  or visit
21  * http://www.gnu.org/licenses/gpl.html
22  * ==========================================================================================
23  *
24  * Changes:
25  * v0.91        ged                     - added ICO, PHPx files, fixed/added some icons
26  *                                              - changed perms on file or folder creation or upload to 0755 from 0640
27  *                                              - changed 'cancel' links for delete actions to $parent dir from http_referer
28  *                                              - changed order of links next to files... moved 'del' over a bit.  ;)
29  * v0.92        ged                     - changed order of links next to dirs
30  *                                              - $privateskins = FALSE by default
31  * v1.0 ged                     - fixed security catch so it actually quits the script
32  *                                              - "columnated" the files & dirs display for easier viewing
33  *                                              - Made the edit cancel link more intuitive
34  * v1.01        ged                     - fixed event_QuickMenu to properly skip for non-admins
35  *                                              - lined up columns for directories & added <tr> highlights
36  * v2.00        rakaz           - Almost complete rewrite
37  * v2.01        yama            - modified form button for IE
38  * v2.02        kimitake        - multilingual support, modified form button for IE
39  * v2.03        yama            - CSS out source. and textarea width bug fix for IE. And some lang add.And add routine empty file delete.
40  *                      cacher          - replace function 'basename' (PHP BUG)
41  *                                              - add help
42  *                      Mocchi          - arrange codes for PHP5
43  */
44
45 class NP_SkinFiles extends NucleusPlugin {
46         public function getName() { return 'SkinFiles'; }
47         public function getAuthor() { return 'Misc authors'; }
48         public function getURL() { return 'http://wakka.xiffy.nl/skinfiles'; }
49         public function getVersion() { return '2.032'; }
50         public function getDescription() { return _SKINFILES_01; }
51         public function supportsFeature($feature)       { return in_array ($feature, array ('SqlTablePrefix', 'SqlApi', 'HelpPage'));}
52         public function hasAdminArea() { return 1; }
53         
54         public function install() {
55                 $this->createOption(
56                         'generate_backup',
57                         '_SKINFILES_OPT_GENBACKUP',
58                         'yesno',
59                         'no'
60                 );
61                 $this->createOption(
62                         'backup_prefix',
63                         '_SKINFILES_OPT_BACKUPPREFIX',
64                         'text',
65                         'bkup_'
66                 );
67                 return;
68         }
69         
70         public function unInstall() {
71                 return;
72         }
73         
74         public function getEventList() {
75                 return array(
76                         'QuickMenu',
77                         'AdminPrePageHead',
78                         'PrePluginOptionsEdit'
79                 );
80         }
81         
82         public function init() {
83                 $language = preg_replace( '#\\\\|/#', '', getLanguageName());
84                 if (file_exists($this->getDirectory().$language.'.php')) {
85                         include_once($this->getDirectory().$language.'.php');
86                 } else {
87                         include_once($this->getDirectory().'english.php');
88                 }
89                 return;
90         }
91         
92         public function event_QuickMenu(&$data) {
93                 global $member;
94                 
95                 if (!($member->isLoggedIn() && $member->isAdmin())) {
96                         return;
97                 }
98                 
99                 array_push(
100                         $data['options'], 
101                         array(
102                                  'title'        => _SKINFILES_TITLE,
103                                  'url'    => $this->getAdminURL(),
104                                  'tooltip' => _SKINFILES_TOOLTIP
105                         )
106                 );
107                 return;
108         }
109         
110         public function event_AdminPrePageHead(&$data) {
111                 global $CONF;
112                 $path = $CONF['PluginURL'];
113                 if ($data['action'] != 'plugin_SkinFiles') {
114                         return;
115                 }
116                 
117                 $data['extrahead'] .= '<link rel="stylesheet" type="text/css" href="{$path}skinfiles/style.css" />';
118         }
119         
120         public function event_PrePluginOptionsEdit($data) {
121                 if ($data['context'] !== 'global' || $data['plugid'] !== $this->getID()) {
122                         return;
123                 }
124                 foreach($data['options'] as $key => $value){
125                         if (defined($value['description'])) {
126                                 $data['options'][$key]['description'] = constant($value['description']);
127                         }
128                 }
129                 return;
130         }
131 }