• R/O
  • HTTP
  • SSH
  • HTTPS

nucleus-plugins: Commit

Nucleus CMS日本語版用プラグインのうち、日本語版開発者がサポートしているもの


Commit MetaInfo

Revision7af2f9c09cf52bdc2d36873b63f342ee38187fdf (tree)
Zeit2012-10-20 11:19:48
Autorsakamocchi <o-takashi@saka...>
Commitersakamocchi

Log Message

CHANGE: NP_AttachをNucleus CMS 4.0でも動作するよう変更

翻訳ファイルのinclude処理を修正。翻訳ファイル名も変更。

Ändern Zusammenfassung

Diff

--- a/NP_Attach/NP_Attach.php
+++ b/NP_Attach/NP_Attach.php
@@ -1,8 +1,8 @@
11 <?php
22 /**
33 * Attach plugin for Nucleus CMS
4- * Version 0.9.6 (1.0 RC2) for PHP5
5- * Written By Mocchi, Apr. 04, 2011
4+ * Version 1.0.0 for PHP5
5+ * Written By Mocchi, Oct. 20, 2012
66 * Original code was written by NKJG and yamamoto, May 02, 2009
77 * This plugin depends on NP_Thumbnail and NP_MediaUtils
88 *
@@ -16,23 +16,25 @@
1616 // TODO (hard) There are no ways to show the error message even if upload processing is failed.
1717 // TODO (medium) all of the plugin options are purged when uninstalling plugins.
1818
19-class NP_Attach extends NucleusPlugin {
20- static private $buffer = false;
21- static private $blogid = 0;
22- static private $itemid = 0;
23- static private $amount = 0;
24- static private $data = array();
19+class NP_Attach extends NucleusPlugin
20+{
21+ static private $buffer = false;
22+ static private $blogid = 0;
23+ static private $itemid = 0;
24+ static private $amount = 0;
25+ static private $data = array();
2526
2627 public function getName() { return 'Attach'; }
2728 public function getAuthor() { return 'Mocchi, yamamoto, NKJG'; }
2829 public function getURL() { return 'http://japan.nucleuscms.org/wiki/plugins:attach'; }
29- public function getVersion() { return '0.9.6 (1.0 RC2)'; }
30+ public function getVersion() { return '1.0.0'; }
3031 public function getDescription() { return _NP_ATTACH_01; }
3132 public function getPluginDep() { return array('NP_MediaUtils', 'NP_Thumbnail');}
32- public function getMinNucleusVersion() {return 340;}
33- public function supportsFeature($feature) { return in_array ($feature, array ('SqlTablePrefix', 'SqlApi'));}
34- public function getEventList() {
35- return array (
33+ public function getMinNucleusVersion() {return 340;}
34+ public function supportsFeature($feature) { return in_array($feature, array('SqlTablePrefix', 'SqlApi'));}
35+ public function getEventList()
36+ {
37+ return array(
3638 'PrePluginOptionsEdit',
3739 'AdminPrePageHead',
3840 'BookmarkletExtraHead',
@@ -46,7 +48,8 @@ class NP_Attach extends NucleusPlugin {
4648 'EditItemFormExtras');
4749 }
4850
49- public function install () {
51+ public function install()
52+ {
5053 $this->createOption('maxwidth', '_NP_ATTACH_02', 'text', '90', 'datatype=numerical');
5154 $this->createOption('maxheight', '_NP_ATTACH_03', 'text', '90', 'datatype=numerical');
5255 $this->createOption('admin_popup_template', '_NP_ATTACH_04', 'textarea', '<a href="<%rawpopuplink%>" title="<%popuptext%>" onclick="<%popupcode%>"><img src="<%thumb_url%>" width="<%thumb_width%>" height="<%thumb_height%>" alt="<%popuptext%>" /></a>');
@@ -58,150 +61,189 @@ class NP_Attach extends NucleusPlugin {
5861 return;
5962 }
6063
61- public function uninstall () {
64+ public function uninstall()
65+ {
6266 return;
6367 }
6468
65- public function init() {
66- if(!defined('_NP_ATTACH_01')) {
69+ public function init()
70+ {
71+ $locale = '';
72+
73+ /* new API */
74+ if ( class_exists('i18n', FALSE) )
75+ {
76+ $locale = i18n::get_current_locale() . '.' . i18n::get_current_charset() . '.php';
77+ }
78+ /* old API */
79+ else
80+ {
6781 $language = preg_replace('#[/|\\\\]#', '', getLanguageName());
68- if (file_exists($this->getDirectory() . $language.'.php')) {
69- include($this->getDirectory() . $language.'.php');
70- } else {
71- include($this->getDirectory() . 'english.php');
82+ if ( $language == 'japanese-euc' )
83+ {
84+ $locale = 'ja_Jpan_JP.EUC-JP.php';
85+ }
86+ else if ( $language = 'japanese-utf8' )
87+ {
88+ $locale = 'ja_Jpan_JP.UTF-8.php';
7289 }
7390 }
91+
92+ if ( !$locale || !file_exists($this->getDirectory() . $locale) )
93+ {
94+ include($this->getDirectory() . 'en_Latn_US.ISO-8859-1.php');
95+ }
96+ else
97+ {
98+ include($this->getDirectory() . $locale);
99+ }
100+
74101 return;
75102 }
76103
77-/*
78- * for translation
79- */
80- public function event_PrePluginOptionsEdit ($data)
104+ /*
105+ * for translation
106+ */
107+ public function event_PrePluginOptionsEdit(&$data)
81108 {
82- if ($data['context'] != 'global') {
83- foreach($data['options'] as $key => $option) {
84- if ($option['pid'] == $this->getID()) {
85- if (defined($option['description'])) {
86- $data['options'][$key]['description'] = constant($option['description']);
87- }
88- if ($option['type'] == 'select') {
89- foreach (explode('|', $option['typeinfo']) as $option) {
90- if (defined($option)) {
91- $data['options'][$key]['typeinfo'] = str_replace($option, constant($option), $data['options'][$key]['typeinfo']);
109+ /* Old version do not support natively */
110+ if ( getNucleusVersion() < 400 )
111+ {
112+ if ( $data['context'] != 'global' )
113+ {
114+ foreach ( $data['options'] as $key => $option )
115+ {
116+ if ( $option['pid'] == $this->getID() )
117+ {
118+ if ( defined($option['description']) )
119+ {
120+ $data['options'][$key]['description'] = constant($option['description']);
121+ }
122+ if ( $option['type'] == 'select' )
123+ {
124+ foreach ( explode('|', $option['typeinfo']) as $option )
125+ {
126+ if ( defined($option) )
127+ {
128+ $data['options'][$key]['typeinfo'] = str_replace($option, constant($option), $data['options'][$key]['typeinfo']);
129+ }
92130 }
93131 }
94132 }
95133 }
96134 }
97- } else if ($data['plugid'] == $this->getID()) {
98- foreach($data['options'] as $key => $option){
99- if (defined($option['description'])) {
100- $data['options'][$key]['description'] = constant($option['description']);
101- }
102- if ($option['type'] == 'select') {
103- foreach (explode('|', $option['typeinfo']) as $option) {
104- if (defined($option)) {
105- $data['options'][$key]['typeinfo'] = str_replace($option, constant($option), $data['options'][$key]['typeinfo']);
135+ else if ($data['plugid'] == $this->getID() )
136+ {
137+ foreach ( $data['options'] as $key => $option )
138+ {
139+ if ( defined($option['description']) )
140+ {
141+ $data['options'][$key]['description'] = constant($option['description']);
142+ }
143+ if ( $option['type'] == 'select' )
144+ {
145+ foreach ( explode('|', $option['typeinfo']) as $option )
146+ {
147+ if ( defined($option) )
148+ {
149+ $data['options'][$key]['typeinfo'] = str_replace($option, constant($option), $data['options'][$key]['typeinfo']);
150+ }
106151 }
107- }
152+ }
108153 }
109154 }
110155 }
156+
111157 return;
112158 }
113159
114-/*
115- * for translation
116- */
117- static private function t ($text,$array=array()){
118- if (is_array($array)) {
119- $search = array();
120- $replace = array();
121-
122- foreach ($array as $key => $value){
123- if (is_array($value)) {
124- continue;
125- }
126- $search[] = '<%'.preg_replace('/[^a-zA-Z0-9_]+/','',$key).'%>';
127- $replace[] = $value;
128- }
129- }
130- return htmlspecialchars (str_replace($search, $replace, $text), ENT_QUOTES, _CHARSET);
131- }
132-
133-/*
134- * Change enctype attribute of form element as 'multipart/form-data'
135- * Insert interface
136- */
137- public function event_AdminPrePageHead ($data) {
138- if (!in_array ($data['action'], array ('createitem', 'itemedit'))) {
139- return;
160+ /*
161+ * Change enctype attribute of form element as 'multipart/form-data'
162+ * Insert interface
163+ */
164+ public function event_AdminPrePageHead(&$data)
165+ {
166+ if ( !in_array ($data['action'], array('createitem', 'itemedit')) )
167+ {
168+ self::prepareEnctype();
140169 }
141-
142- self::prepareEnctype ();
143170 return;
144171 }
145172
146- public function event_BookmarkletExtraHead ($data) {
147- self::prepareEnctype ();
173+ public function event_BookmarkletExtraHead(&$data)
174+ {
175+ self::prepareEnctype();
148176 return;
149177 }
150178
151- public function event_AddItemFormExtras ($data) {
179+ public function event_AddItemFormExtras(&$data)
180+ {
152181 global $DIR_MEDIA;
153182 $blog = $data['blog'];
154183 self::$blogid = $blog->blogid;
155184 self::$itemid = 0;
156- self::setEnctype ();
185+ self::setEnctype();
157186 $this->setData($DIR_MEDIA);
158- $this->showInterface ();
187+ $this->showInterface();
159188 return;
160189 }
161190
162- public function event_EditItemFormExtras ($data) {
191+ public function event_EditItemFormExtras(&$data)
192+ {
163193 global $DIR_MEDIA;
164194 $blog = $data['blog'];
165195 self::$blogid = $blog->blogid;
166196 self::$itemid = $data['itemid'];
167- self::setEnctype ();
197+ self::setEnctype();
168198 $this->setData($DIR_MEDIA);
169- $this->showInterface ();
199+ $this->showInterface();
170200 return;
171201 }
172202
173-/*
174- * Process upload and update plugin item option
175- */
176- public function event_PreAddItem ($data) {
203+ /*
204+ * Process upload and update plugin item option
205+ */
206+ public function event_PreAddItem(&$data)
207+ {
177208 self::$blogid = $data['blog']->blogid;
178209 return;
179210 }
180- public function event_PreUpdateItem ($data) {
211+
212+ public function event_PreUpdateItem(&$data)
213+ {
181214 self::$blogid = $data['blog']->blogid;
182215 return;
183216 }
184- public function event_PostAddItem ($data) {
217+
218+ public function event_PostAddItem(&$data)
219+ {
185220 self::$itemid = $data['itemid'];
186221 return;
187222 }
188- public function event_PostUpdateItem ($data) {
223+
224+ public function event_PostUpdateItem(&$data)
225+ {
189226 self::$itemid = $data['itemid'];
190227 return;
191228 }
192- public function event_PrePluginOptionsUpdate ($data) {
229+
230+ public function event_PrePluginOptionsUpdate(&$data)
231+ {
193232 global $DIR_MEDIA, $member;
194233
195- if ($data['plugid'] != $this->getID () || $data['optionname'] != 'media') {
234+ if ( $data['plugid'] != $this->getID() || $data['optionname'] != 'media' )
235+ {
196236 return;
197237 }
198238
199239 $this->setData($DIR_MEDIA);
200- self::batchRequest ($DIR_MEDIA, $member->getID());
240+ self::batchRequest($DIR_MEDIA, $member->getID());
201241
202242 $value = '';
203- foreach (self::$data as $datum) {
204- if (!$datum['path']) {
243+ foreach ( self::$data as $datum )
244+ {
245+ if ( !$datum['path'] )
246+ {
205247 continue;
206248 }
207249 $value .= "{$datum['path']}:{$datum['alt']}:{$datum['way']};";
@@ -211,100 +253,144 @@ class NP_Attach extends NucleusPlugin {
211253 return;
212254 }
213255
214-/*
215- * Show media in item
216- */
217- public function event_PreItem($data) {
256+ /*
257+ * Show media in item
258+ */
259+ public function event_PreItem(&$data)
260+ {
218261 global $DIR_MEDIA;
262+
219263 self::$blogid =& $data['blog']->blogid;
220264 self::$itemid =& $data["item"]->itemid;
221265 $this->setData($DIR_MEDIA);
222266
223- $data["item"]->body = preg_replace_callback("#<\%Attach\((.+?)(,.+?)?(,.+?)?\)%\>#", array(&$this, 'getParsedTag'), $data["item"]->body);
224- $data["item"]->more = preg_replace_callback("#<\%Attach\((.+?)(,.+?)?(,.+?)?\)%\>#", array(&$this, 'getParsedTag'), $data["item"]->more);
267+ $data["item"]->body = preg_replace_callback("#<\%Attach\((.+?)(,.+?)?(,.+?)?\)%\>#", array($this, 'getParsedTag'), $data["item"]->body);
268+ $data["item"]->more = preg_replace_callback("#<\%Attach\((.+?)(,.+?)?(,.+?)?\)%\>#", array($this, 'getParsedTag'), $data["item"]->more);
225269 return;
226270 }
227- public function doTemplateVar($item, $mediumid) {
271+
272+ public function doTemplateVar($item, $mediumid)
273+ {
228274 global $DIR_MEDIA, $blogid;
229275
230- if (!self::$itemid || !self::$blogid) {
276+ if ( !self::$itemid || !self::$blogid )
277+ {
231278 self::$blogid = $blogid;
232279 self::$itemid = $item->itemid;
233280 $this->setData($DIR_MEDIA);
234281 }
235- $this->getParsedTag(array('item', $mediumid));
282+
283+ $params = array('item', $mediumid);
284+ $this->getParsedTag($params);
236285 return;
237286 }
238287
239- private function getParsedTag($match) {
288+ private function getParsedTag($match)
289+ {
240290 global $DIR_MEDIA, $manager;
241291
292+ /* receice maximum dimension */
242293 $maxwidth = 0;
243294 $maxheight = 0;
244- if (array_key_exists(3, $match)) {
295+ if ( array_key_exists(3, $match) )
296+ {
245297 $maxheight = (integer) trim($match[3], ',');
246298 }
247- if (array_key_exists(2, $match)) {
299+ if ( array_key_exists(2, $match) )
300+ {
248301 $maxwidth = (integer) trim($match[2], ',');
249302 }
250303
251- $data = &self::$data;
304+ /* ID in tag starts 1 but ID in program starts 0 */
252305 $mediumid = $match[1];
253306 $mediumid--;
254307
255- if (!array_key_exists ($mediumid, $data) || !$data[$mediumid]['path']) {
308+ /* filled tag or blank if failed */
309+ $tag = $this->generateParsedTag($maxwidth, $maxheight);
310+
311+ return $tag;
312+ }
313+
314+ private function generateParsedTag($maxwidth, $maxheight)
315+ {
316+ global $manager;
317+
318+ /* check medium has path */
319+ $data = &self::$data;
320+ if ( !array_key_exists($mediumid, $data) || !$data[$mediumid]['path'] )
321+ {
256322 return;
257323 }
258324
325+ /* receive an instance of NP_Thumbnail class */
259326 $NP_Thumbnail =& $manager->getPlugin('NP_Thumbnail');
260327
261- if ($maxwidth==0 && $maxheight==0) {
328+ /* confirm to have maximum dimension */
329+ if ( $maxwidth == 0 && $maxheight == 0 )
330+ {
262331 $maxwidth = $NP_Thumbnail->getOption('maxwidth');
263332 $maxheight = $NP_Thumbnail->getOption('maxheight');
264333 }
265334
266- if (FALSE === ($medium = new MEDIUM($DIR_MEDIA, $data[$mediumid]['path'], MediaUtils::$prefix))) {
335+ /* receive an instance of MEDIUM class */
336+ if ( FALSE === ($medium = new MEDIUM($DIR_MEDIA, $data[$mediumid]['path'], MediaUtils::$prefix)) )
337+ {
267338 return;
268339 }
269340
270- if (array_key_exists($medium->mime, MediaUtils::$image_mime)
271- && !$medium->setResampledSize($maxwidth, $maxheight)) {
341+ /* take the instance having correct resampled dimension */
342+ if ( array_key_exists($medium->mime, MediaUtils::$image_mime)
343+ && !$medium->setResampledSize($maxwidth, $maxheight) )
344+ {
272345 return;
273346 }
274347
275- if (!array_key_exists($medium->mime, MediaUtils::$image_mime)
276- || $data[$mediumid]['way'] == 'anchor') {
348+ /* receive template */
349+ if ( !array_key_exists($medium->mime, MediaUtils::$image_mime)
350+ || $data[$mediumid]['way'] == 'anchor' )
351+ {
277352 $template = $this->getBlogOption(self::$blogid, 'blog_media_template');
278- } else if ($data[$mediumid]['way'] == 'original') {
353+ }
354+ else if ( $data[$mediumid]['way'] == 'original' )
355+ {
279356 $template = $this->getBlogOption(self::$blogid, 'blog_image_template');
280- } else {
357+ }
358+ else
359+ {
281360 $template = $NP_Thumbnail->getBlogOption(self::$blogid, 'thumb_template');
282361 }
362+
363+ /* return filled template */
283364 return $NP_Thumbnail->generateTag($template, $medium, $data[$mediumid]['alt']);
284365 }
285366
286- private function showInterface () {
367+ private function showInterface()
368+ {
287369 global $CONF, $DIR_LIBS, $DIR_MEDIA, $manager;
288370
289- if (!class_exists('BODYACTIONS', FALSE)) {
290- include ($DIR_LIBS . 'BODYACTIONS.php');
371+ if ( !class_exists('BODYACTIONS', FALSE) )
372+ {
373+ include($DIR_LIBS . 'BODYACTIONS.php');
291374 }
292375 $action = new BODYACTIONS;
293376
294- if (!$manager->pluginInstalled('NP_Thumbnail')) {
377+ if ( !$manager->pluginInstalled('NP_Thumbnail') )
378+ {
295379 return;
296380 }
297381 $NP_Thumbnail = &$manager->getPlugin('NP_Thumbnail');
298382 $maxwidth = $NP_Thumbnail->getOption('maxwidth');
299383 $maxheight = $NP_Thumbnail->getOption('maxheight');
300384
301- if (!self::$amount) {
385+ if ( !self::$amount )
386+ {
302387 return;
303388 }
304389
305390 $data = self::$data;
306391
307- if (empty($data)) {
392+ if ( empty($data) )
393+ {
308394 return;
309395 }
310396
@@ -318,14 +404,16 @@ class NP_Attach extends NucleusPlugin {
318404 echo "</thead>\n";
319405 echo "<tbody>\n";
320406
321- for ($count = 0; $count < self::$amount; $count++) {
407+ for ( $count = 0; $count < self::$amount; $count++ )
408+ {
322409 $id = $count + 1;
323410
324411 echo "<tr>\n";
325412 echo "<td>\n";
326413 echo "<label for=\"alt{$count}\"><%Attach({$id})%></label>\n";
327414
328- if ($data[$count]['path']) {
415+ if ( $data[$count]['path'] )
416+ {
329417 echo "<br />\n";
330418 echo "<input type=\"checkbox\" id=\"delete{$count}\" name=\"delete[{$count}]\" value=\"1\" />\n";
331419 echo "<label for=\"delete{$count}\">" . _NP_ATTACH_13 . "</label>\n";
@@ -334,21 +422,29 @@ class NP_Attach extends NucleusPlugin {
334422 echo "</td>\n";
335423 echo "<td>\n";
336424
337- if (!$data[$count]['path']) {
425+ if ( !$data[$count]['path'] )
426+ {
338427 echo "<input type=\"file\" id=\"medium{$count}\" name=\"medium[{$count}]\" size=\"1\" /><br />\n";
339- } else {
340- if (FALSE === ($medium = new MEDIUM($DIR_MEDIA, $data[$count]['path'], MediaUtils::$prefix))) {
428+ }
429+ else
430+ {
431+ if ( FALSE === ($medium = new MEDIUM($DIR_MEDIA, $data[$count]['path'], MediaUtils::$prefix)) )
432+ {
341433 return;
342434 }
343435
344- if (array_key_exists($medium->mime, MediaUtils::$image_mime)
345- && !$medium->setResampledSize($maxwidth, $maxheight)) {
436+ if ( array_key_exists($medium->mime, MediaUtils::$image_mime)
437+ && !$medium->setResampledSize($maxwidth, $maxheight) )
438+ {
346439 return;
347440 }
348441
349- if (array_key_exists($medium->mime, MediaUtils::$image_mime)) {
442+ if ( array_key_exists($medium->mime, MediaUtils::$image_mime) )
443+ {
350444 $template = $this->getOption('admin_popup_template');
351- } else {
445+ }
446+ else
447+ {
352448 $template = $this->getOption('admin_media_template');
353449 }
354450
@@ -359,19 +455,27 @@ class NP_Attach extends NucleusPlugin {
359455 echo "</td>\n";
360456 echo "<td>\n";
361457
362- if ($data[$count]['path'] && !array_key_exists($data[$count]['mime'], MediaUtils::$image_mime)) {
458+ if ( $data[$count]['path'] && !array_key_exists($data[$count]['mime'], MediaUtils::$image_mime) )
459+ {
363460 echo "<input type=\"hidden\" name=\"way[{$count}]\" value=\"anchor\" />\n";
364461 echo _NP_ATTACH_14 . "\n";
365- } else {
462+ }
463+ else
464+ {
366465 $thumbnail_checked = "";
367466 $original_checked = "";
368467 $anchor_checked = "";
369468
370- if ($data[$count]['way'] == 'original') {
469+ if ( $data[$count]['way'] == 'original' )
470+ {
371471 $original_checked = 'checked="checked"';
372- } else if ($data[$count]['way'] == 'anchor') {
472+ }
473+ else if ($data[$count]['way'] == 'anchor' )
474+ {
373475 $anchor_checked = 'checked="checked"';
374- } else {
476+ }
477+ else
478+ {
375479 $thumbnail_checked = 'checked="checked"';
376480 }
377481
@@ -391,31 +495,38 @@ class NP_Attach extends NucleusPlugin {
391495 return;
392496 }
393497
394- private function setData($root) {
395- if(self::$blogid === 0 || !self::$itemid === 0) {
498+ private function setData($root)
499+ {
500+ if ( self::$blogid === 0 || !self::$itemid === 0 )
501+ {
396502 return;
397503 }
398504
399505 self::$amount = $this->getBlogOption(self::$blogid, 'amount');
400- $media = explode(';', $this->getitemOption (self::$itemid, 'media'));
506+ $media = explode(';', $this->getitemOption(self::$itemid, 'media'));
401507 $data = array();
402508
403- for ($count = 0; $count < self::$amount; $count++) {
404- if((self::$itemid != 0) && array_key_exists ($count, $media) && !empty ($media[$count])) {
405- $medium = explode (':', $media[$count]);
509+ for ( $count = 0; $count < self::$amount; $count++ )
510+ {
511+ if ( (self::$itemid != 0) && array_key_exists($count, $media) && !empty($media[$count]) )
512+ {
513+ $medium = explode(':', $media[$count]);
406514 $data[$count]['path'] = $medium[0];
407515 $data[$count]['alt'] = $medium[1];
408516 $data[$count]['way'] = $medium[2];
409517
410- if (FALSE === ($file = new Medium($root, $data[$count]['path'], MediaUtils::$prefix))) {
411- $data[$count] = array ('path' => "", 'alt' => "", 'way' => "");
518+ if ( FALSE === ($file = new Medium($root, $data[$count]['path'], MediaUtils::$prefix)) )
519+ {
520+ $data[$count] = array('path' => "", 'alt' => "", 'way' => "");
412521 }
413522
414523 $data[$count]['mime'] = $file->mime;
415524 $data[$count]['width'] = $file->width;
416525 $data[$count]['height'] = $file->height;
417- } else {
418- $data[$count] = array ('path' => "", 'alt' => "", 'way' => "");
526+ }
527+ else
528+ {
529+ $data[$count] = array('path' => "", 'alt' => "", 'way' => "");
419530 }
420531 }
421532
@@ -423,46 +534,55 @@ class NP_Attach extends NucleusPlugin {
423534 return;
424535 }
425536
426- static private function batchRequest($root, $collection) {
537+ static private function batchRequest($root, $collection)
538+ {
427539 global $CONF, $manager;
428- $media = array ();
429- $paths = array ();
430- $alts = array ();
431- $ways = array ();
432- $deletes = array ();
433-
434- if (array_key_exists ('medium', $_FILES)) {
540+ $media = array();
541+ $paths = array();
542+ $alts = array();
543+ $ways = array();
544+ $deletes = array();
545+
546+ if ( array_key_exists('medium', $_FILES) )
547+ {
435548 $media = $_FILES['medium'];
436549 }
437550
438- if (array_key_exists ('path', $_POST)) {
551+ if ( array_key_exists('path', $_POST) )
552+ {
439553 $paths = $_POST['path'];
440554 }
441555
442- if (array_key_exists ('alt', $_POST)) {
556+ if ( array_key_exists('alt', $_POST) )
557+ {
443558 $alts = $_POST['alt'];
444559 }
445560
446- if (array_key_exists ('way', $_POST)) {
561+ if ( array_key_exists('way', $_POST) )
562+ {
447563 $ways = $_POST['way'];
448564 }
449565
450- if (array_key_exists ('delete', $_POST)) {
566+ if ( array_key_exists('delete', $_POST) )
567+ {
451568 $deletes = $_POST['delete'];
452569 }
453570
454571 $data = &self::$data;
455572
456- if (!$manager->pluginInstalled('NP_Thumbnail')) {
573+ if ( !$manager->pluginInstalled('NP_Thumbnail') )
574+ {
457575 return;
458576 }
459- $NP_Thumbnail = &$manager->getPlugin('NP_Thumbnail');
460577
461- foreach ($data as $key => $value) {
462- if ($media && array_key_exists ($key, $media['name']) && !empty ($media['name'][$key])) {
463- $medium = array ();
464- if (preg_match ("#(\\\\|/|\\n)#", $media['name'][$key])) {
465- $data[$key] = array ('path' => "", 'alt' => "", 'way' => "");
578+ foreach ( $data as $key => $value )
579+ {
580+ if ( $media && array_key_exists($key, $media['name']) && !empty($media['name'][$key]) )
581+ {
582+ $medium = array();
583+ if ( preg_match ("#(\\\\|/|\\n)#", $media['name'][$key]) )
584+ {
585+ $data[$key] = array('path' => "", 'alt' => "", 'way' => "");
466586 continue;
467587 }
468588
@@ -471,40 +591,54 @@ class NP_Attach extends NucleusPlugin {
471591 $medium['tmp_name'] = $media['tmp_name'][$key];
472592 $medium['error'] = $media['error'][$key];
473593
474- $result = MediaUtils::uploadMedium ($root, $collection, $medium, $medium['name'], $manager);
594+ $result = MediaUtils::uploadMedium($root, $collection, $medium, '', $manager);
475595
476- if ($result) {
596+ if ( $result )
597+ {
477598 $data[$key]['path'] = "";
478- $data[$key]['alt'] = $result . ' (' . $medium['name'] . ')';
599+ $data[$key]['alt'] = "{$result} ({$medium['name']})";
479600 $data[$key]['way'] = "";
480601 continue;
481- } else {
482- $data[$key]['path'] = $collection . '/' . $medium['name'];
483602 }
484- } else if (array_key_exists($key, $paths) && !empty ($paths[$key])) {
485- if (FALSE === ($medium = new MEDIUM($root, $paths[$key], MediaUtils::$prefix))) {
486- $data[$key] = array ('path' => "", 'alt' => "", 'way' => "");
603+ else
604+ {
605+ $data[$key]['path'] = "{$collection}/{$medium['name']}";
606+ }
607+ }
608+ else if ( array_key_exists($key, $paths) && !empty($paths[$key]) )
609+ {
610+ if ( FALSE === ($medium = new MEDIUM($root, $paths[$key], MediaUtils::$prefix)) )
611+ {
612+ $data[$key] = array('path' => "", 'alt' => "", 'way' => "");
487613 continue;
488614 }
489- if ($deletes && array_key_exists ($key, $deletes) && $deletes[$key] == 1) {
490- if (@ unlink ($root . $paths[$key])) {
491- if (array_key_exists($medium->mime, MediaUtils::$image_mime)) {
492- @ unlink ($root . $NP_Thumbnail->getThumbPath($medium));
615+ if ( $deletes && array_key_exists($key, $deletes) && $deletes[$key] == 1 )
616+ {
617+ if ( @unlink($root . $paths[$key]) )
618+ {
619+ if ( array_key_exists($medium->mime, MediaUtils::$image_mime) )
620+ {
621+ @ unlink($root . NP_Thumbnail::getThumbPath($medium));
493622 }
494- $data[$key] = array ('path' => "", 'alt' => "", 'way' => "");
623+ $data[$key] = array('path' => "", 'alt' => "", 'way' => "");
495624 continue;
496625 }
497626 }
498627 }
499628
500- if (array_key_exists ($key, $alts) && $alts[$key] != $value['alt']) {
501- $data[$key]['alt'] = htmlspecialchars ($alts[$key], ENT_QUOTES, _CHARSET);
629+ if ( array_key_exists($key, $alts) && $alts[$key] != $value['alt'] )
630+ {
631+ $data[$key]['alt'] = htmlspecialchars($alts[$key], ENT_QUOTES, _CHARSET);
502632 }
503633
504- if (array_key_exists ($key, $ways) && $ways[$key] != $value['way']) {
505- if (!in_array ($ways[$key], array ('thumbnail', 'original', 'anchor'))) {
634+ if ( array_key_exists($key, $ways) && $ways[$key] != $value['way'] )
635+ {
636+ if ( !in_array($ways[$key], array('thumbnail', 'original', 'anchor')) )
637+ {
506638 $data[$key]['way'] = 'thumbnail';
507- } else {
639+ }
640+ else
641+ {
508642 $data[$key]['way'] = $ways[$key];
509643 }
510644 }
@@ -512,18 +646,22 @@ class NP_Attach extends NucleusPlugin {
512646 return;
513647 }
514648
515- static private function prepareEnctype () {
516- self::$buffer = ob_start ();
649+ static private function prepareEnctype()
650+ {
651+ self::$buffer = ob_start();
517652 return;
518653 }
519654
520- static private function setEnctype () {
521- if (!self::$buffer) {
655+ static private function setEnctype()
656+ {
657+ if ( !self::$buffer )
658+ {
522659 return;
523660 }
524- $strings = ob_get_contents ();
525- ob_end_clean ();
526- $strings = preg_replace ('#action="(index.php|bookmarklet.php)"#', '$0 enctype="multipart/form-data"', $strings);
661+
662+ $strings = ob_get_contents();
663+ ob_end_clean();
664+ $strings = preg_replace('#action="(index.php|bookmarklet.php)"#', '$0 enctype="multipart/form-data"', $strings);
527665 echo $strings;
528666 return;
529667 }
--- a/NP_Attach/attach/english.php
+++ b/NP_Attach/attach/en_Latn_US.ISO-8859-1.php
@@ -1,8 +1,8 @@
11 <?php
22 /**
33 * Attach plugin for Nucleus CMS
4- * Version 0.9.6 (1.0 RC2) for PHP5
5- * Written By Mocchi, Apr. 04, 2011
4+ * Version 1.0.0 for PHP5
5+ * Written By Mocchi, Oct. 20, 2012
66 * Original code was written by NKJG and yamamoto, May 02, 2009
77 * This plugin depends on NP_Thumbnail and NP_MediaUtils
88 *
--- a/NP_Attach/attach/japanese-utf8.php
+++ b/NP_Attach/attach/ja_Jpan_JP.EUC-JP.php
@@ -1,8 +1,8 @@
11 <?php
22 /**
33 * Attach plugin for Nucleus CMS
4- * Version 0.9.6 (1.0 RC2) for PHP5
5- * Written By Mocchi, Apr. 04, 2011
4+ * Version 1.0.0 for PHP5
5+ * Written By Mocchi, Oct. 20, 2012
66 * Original code was written by NKJG and yamamoto, May 02, 2009
77 * This plugin depends on NP_Thumbnail and NP_MediaUtils
88 *
--- /dev/null
+++ b/NP_Attach/attach/ja_Jpan_JP.UTF-8.php
@@ -0,0 +1,31 @@
1+<?php
2+/**
3+ * Attach plugin for Nucleus CMS
4+ * Version 1.0.0 for PHP5
5+ * Written By Mocchi, Oct. 20, 2012
6+ * Original code was written by NKJG and yamamoto, May 02, 2009
7+ * This plugin depends on NP_Thumbnail and NP_MediaUtils
8+ *
9+ * This program is free software; you can redistribute it and/or
10+ * modify it under the terms of the GNU General Public License
11+ * as published by the Free Software Foundation; either version 3
12+ * of the License, or (at your option) any later version.
13+ */
14+
15+define('_NP_ATTACH_01', 'アイテムに直接、ファイルを添付します。添付したファイルはタグ<%Attach%>でアイテム中に表示できます');
16+define('_NP_ATTACH_02', '管理画面に表示するサムネイルの横幅の最大値');
17+define('_NP_ATTACH_03', '管理画面に表示するサムネイルの縦幅の最大値');
18+define('_NP_ATTACH_04', '管理画面に表示する縮小画像のテンプレート');
19+define('_NP_ATTACH_05', '管理画面に表示する画像以外のテンプレート');
20+define('_NP_ATTACH_06', 'アイテムに添付できるファイルの数');
21+define('_NP_ATTACH_07', 'ウェブログに表示する原寸画像のテンプレート。縮小画像のテンプレートはNP_Thumbnailのテンプレートに準じてます。');
22+define('_NP_ATTACH_08', 'ウェブログに表示する画像以外のテンプレート');
23+define('_NP_ATTACH_09', 'ファイルの情報');
24+define('_NP_ATTACH_10', 'タグ');
25+define('_NP_ATTACH_11', 'ファイルと説明文');
26+define('_NP_ATTACH_12', '埋め込み方法');
27+define('_NP_ATTACH_13', '削除');
28+define('_NP_ATTACH_14', 'リンク');
29+define('_NP_ATTACH_15', 'リンク');
30+define('_NP_ATTACH_16', '縮小');
31+define('_NP_ATTACH_17', '実寸');
--- a/NP_Attach/attach/japanese-euc.php
+++ /dev/null
@@ -1,31 +0,0 @@
1-<?php
2-/**
3- * Attach plugin for Nucleus CMS
4- * Version 0.9.6 (1.0 RC2) for PHP5
5- * Written By Mocchi, Apr. 04, 2011
6- * Original code was written by NKJG and yamamoto, May 02, 2009
7- * This plugin depends on NP_Thumbnail and NP_MediaUtils
8- *
9- * This program is free software; you can redistribute it and/or
10- * modify it under the terms of the GNU General Public License
11- * as published by the Free Software Foundation; either version 3
12- * of the License, or (at your option) any later version.
13- */
14-
15-define('_NP_ATTACH_01', 'アイテムに直接、ファイルを添付します。添付したファイルはタグ<%Attach%>でアイテム中に表示できます');
16-define('_NP_ATTACH_02', '管理画面に表示するサムネイルの横幅の最大値');
17-define('_NP_ATTACH_03', '管理画面に表示するサムネイルの縦幅の最大値');
18-define('_NP_ATTACH_04', '管理画面に表示する縮小画像のテンプレート');
19-define('_NP_ATTACH_05', '管理画面に表示する画像以外のテンプレート');
20-define('_NP_ATTACH_06', 'アイテムに添付できるファイルの数');
21-define('_NP_ATTACH_07', 'ウェブログに表示する原寸画像のテンプレート。縮小画像のテンプレートはNP_Thumbnailのテンプレートに準じてます。');
22-define('_NP_ATTACH_08', 'ウェブログに表示する画像以外のテンプレート');
23-define('_NP_ATTACH_09', 'ファイルの情報');
24-define('_NP_ATTACH_10', 'タグ');
25-define('_NP_ATTACH_11', 'ファイルと説明文');
26-define('_NP_ATTACH_12', '埋め込み方法');
27-define('_NP_ATTACH_13', '削除');
28-define('_NP_ATTACH_14', 'リンク');
29-define('_NP_ATTACH_15', 'リンク');
30-define('_NP_ATTACH_16', '縮小');
31-define('_NP_ATTACH_17', '実寸');
Show on old repository browser