OSDN Git Service

git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@1059 1ca29b6e-896d...
[nucleus-jp/nucleus-plugins.git] / trunk / NP_Mediatocu / NP_Mediatocu.php
1 <?php\r
2 class NP_Mediatocu extends NucleusPlugin\r
3 {\r
4 \r
5         function NP_Mediatocu()\r
6         {\r
7 //              $this->baseUrl = $this->getAdminURL();\r
8                 global $CONF;\r
9                 $this->baseUrl = str_replace ($CONF['AdminURL'], '', $this->getAdminURL()); \r
10         }\r
11 \r
12         function getName()\r
13         {\r
14                 return 'mediatocu';\r
15         }\r
16 \r
17         function getAuthor()\r
18         {\r
19                 return 'yamamoto,shizuki, Nucleus JP team, and Cacher';\r
20         }\r
21 \r
22         function getURL()\r
23         {\r
24 //              return '';\r
25                 return 'http://japan.nucleuscms.org/wiki/plugins:np_mediatocu';//2008-11-10 cacher\r
26         }\r
27 \r
28         function getVersion()\r
29         {\r
30                 return '1.0.8.1 SP1 RC6';\r
31         }\r
32 \r
33         function getDescription()\r
34         {\r
35                 return _MEDIA_PHP_37;\r
36         }\r
37 \r
38         function supportsFeature($w)\r
39         {\r
40                 return ($w == 'SqlTablePrefix') ? 1 : 0;\r
41         }\r
42 \r
43 \r
44 \r
45 /**2005.3--2005.09.26 00:50 keiei edit\r
46         * media-tocu3.01.zip  for register_globals=off\r
47         *\r
48         */\r
49 /**\r
50         *       media-tocu3.02.zip\r
51         * T.Kosugi edit 2006.8.22 for security reason\r
52         */\r
53 /**\r
54         *       media-tocu-dirs1.0.zip\r
55         *               extends media-tocu3.02.zip\r
56         * 1.0.7 m17n and making to plugin. by yamamoto\r
57         * 1.0.6 to put it even by the thumbnail image click, small bug.  by yamamoto\r
58         * 1.0.5 to put it even by the thumbnail image click, it remodels it.  by yamamoto\r
59         * 1.0.4 bug fix mkdir if memberdir is missing incase mkdir\r
60         * 1.0.3 bug fix missing memberdir in uploading file.\r
61         * 1.0.2 add checking filname with null\r
62         * 1.0.1 add first dir check\r
63         *\r
64         */\r
65 // add language definition by yamamoto\r
66 \r
67 \r
68 \r
69         function install()\r
70         {\r
71                 $this->createOption(\r
72                         'thumb_width',\r
73                         _MEDIA_PHP_17,\r
74                         'text',\r
75                         '60',\r
76                         'datatype=numerical'\r
77                 );\r
78                 $this->createOption(\r
79                         'thumb_height',\r
80                         _MEDIA_PHP_18,\r
81                         'text',\r
82                         '45',\r
83                         'datatype=numerical'\r
84                 );\r
85                 $this->createOption(\r
86                         'thumb_quality',\r
87                         _MEDIA_PHP_19,\r
88                         'text',\r
89                         '70',\r
90                         'datatype=numerical'\r
91                 );\r
92                 $this->createOption(\r
93                         'media_per_page',\r
94                         _MEDIA_PHP_22,\r
95                         'text',\r
96                         '9',\r
97                         'datatype=numerical'\r
98                 );\r
99                 $this->createOption(\r
100                         'popup_width',\r
101                         _MEDIA_PHP_23,\r
102                         'text',\r
103                         '600',\r
104                         'datatype=numerical'\r
105                 );//restore 2008-05-14 Cacher\r
106                 $this->createOption(\r
107                         'popup_height',\r
108                         _MEDIA_PHP_24,\r
109                         'text',\r
110                         '600',\r
111                         'datatype=numerical'\r
112                 );//restore 2008-05-14 Cacher\r
113                 $this->createOption(\r
114                         'paste_mode_checked',\r
115                         _MEDIA_PHP_27,\r
116                         'yesno',\r
117                         'no'\r
118                 );\r
119                 $this->createOption(\r
120                         'hidden_dir',\r
121                         _MEDIA_PHP_43,\r
122                         'text',\r
123                         'thumb,thumbnail,phpthumb'\r
124                 );\r
125                 $this->createOption(\r
126                         'filename_rule',\r
127                         _MEDIA_PHP_33,\r
128                         'select',\r
129                         'default',\r
130                         _MEDIA_PHP_34 . '|default|' . _MEDIA_PHP_35 . '|ascii'\r
131                 );\r
132                 $this->createOption(\r
133                         'use_gray_box',\r
134                         _MEDIA_PHP_36,\r
135                         'yesno',\r
136                         'yes'\r
137                 );\r
138         }\r
139 \r
140         /**\r
141           * Add extra header\r
142           */\r
143         function _addExtraHead(&$data)\r
144         {\r
145                 global $member;\r
146                 $this->memberid = $member->id;\r
147                 $this->memberadmin = $member->admin;\r
148                 $this->_getExtraHead($data);\r
149         }\r
150 \r
151 //      function unInstall() {}\r
152 //2008-11-10 cacher\r
153 \r
154         function init()\r
155         {\r
156                 // include language file for this plugin\r
157                 $language = ereg_replace( '[\\|/]', '', getLanguageName());\r
158                 if (file_exists($this->getDirectory() . 'lang/' . $language . '.php')) {\r
159                         include_once($this->getDirectory() . 'lang/' . $language . '.php');\r
160                 } else {\r
161                         include_once($this->getDirectory() . 'lang/english.php');\r
162                 }\r
163         }\r
164 \r
165         function getEventList()\r
166         {\r
167                 return array(\r
168                         'AdminPrePageHead',\r
169                         'BookmarkletExtraHead',\r
170                         'PreSendContentType'\r
171                 );\r
172         }\r
173 \r
174         function event_BookmarkletExtraHead(&$data)\r
175         {\r
176                 $this->_addExtraHead($data['extrahead']);\r
177         }\r
178 \r
179         function event_AdminPrePageHead(&$data)\r
180         {\r
181                 global $member;\r
182                 $action = $data['action'];\r
183                 if (($action != 'createitem') && ($action != 'itemedit')) {\r
184                         return;\r
185                 }\r
186                 $this->_addExtraHead($data['extrahead']);\r
187         }\r
188 \r
189         function event_PreSendContentType(&$data)\r
190         {\r
191                 $pageType = $data['pageType'];\r
192                 if (    ($pageType == 'bookmarklet-add')\r
193                         ||      ($pageType == 'bookmarklet-edit')\r
194                         ||      ($pageType == 'admin-createitem')\r
195                         ||      ($pageType == 'admin-itemedit')\r
196                    ) {\r
197                         if ($data['contentType'] == 'application/xhtml+xml') {\r
198                                 $data['contentType'] = 'text/html';\r
199                         }\r
200                 }\r
201         }\r
202 \r
203         function _getExtraHead(&$extrahead)\r
204         {\r
205                 global $CONF, $manager, $itemid, $blogid ;\r
206                 if ($manager->pluginInstalled('NP_TinyMCE')) return;\r
207                 $mediatocu    = $manager->getPlugin('NP_Mediatocu');\r
208                 $popup_width  = $mediatocu->getOption('popup_width');//restore 2008-05-14 Cacher\r
209                 $popup_height = $mediatocu->getOption('popup_height');//restore 2008-05-14 Cacher\r
210                 $mediaPhpURL  = $CONF['AdminURL'] . $this->baseUrl . 'media.php';\r
211 //              $GreyBox      = $mediatocu->getOption('use_gray_box');\r
212                 if ($mediatocu->getOption('use_gray_box') == 'yes') {\r
213                 $extrahead .= <<<_EXTRAHEAD_\r
214 \r
215         <script type="text/javascript" src="plugins/mediatocu/greybox/AJS.js"></script>\r
216         <script type="text/javascript" src="plugins/mediatocu/greybox/AJS_fx.js"></script>\r
217         <script type="text/javascript">\r
218                 var GB_ROOT_DIR = "./plugins/mediatocu/greybox/";\r
219         </script>\r
220         <script type="text/javascript" src="plugins/mediatocu/greybox/gb_scripts.js"></script>\r
221         <link href="plugins/mediatocu/greybox/gb_styles.css" rel="stylesheet" type="text/css" media="all" />\r
222         <style TYPE="text/css">\r
223                 #GB_window td {\r
224                         border : none;\r
225                         background : url(plugins/mediatocu/greybox/header_bg.gif);\r
226                 }\r
227         </style>\r
228         <script type="text/javascript">\r
229                 function addMedia() {\r
230                         GB_showFullScreen('Mediatocu', '{$mediaPhpURL}');\r
231                 }\r
232         </script>\r
233 \r
234 _EXTRAHEAD_;\r
235                 } else {\r
236                 $extrahead .= <<<_EXTRAHEAD_\r
237 \r
238         <script type="text/javascript">\r
239                 function addMedia() {\r
240                         window.open('{$mediaPhpURL}', "name" , "width=$popup_width , height=$popup_height , scrollbars=yes , resizable=yes" );\r
241                 }\r
242         </script>\r
243 \r
244 _EXTRAHEAD_;\r
245                 }\r
246         }\r
247 }\r
248 ?>\r