• R/O
  • HTTP
  • SSH
  • HTTPS

nucleus-plugins: Commit

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


Commit MetaInfo

Revisión45288b0453aba294593b8e97fafca495dbb2b2fe (tree)
Tiempo2012-10-20 15:11:45
Autorsakamocchi <o-takashi@saka...>
Commitersakamocchi

Log Message

FIX: NP_ImageLimitSizeをNucleus 3.65/PHP5.4/MySQL5.5で動作するよう修正

Cambiar Resumen

  • modified: NP_ImageLimitSize/NP_ImageLimitSize.php (diff)
  • delete: NP_ImageLimitSize/imagelimitsize/{english.php => en_Latn_US.ISO-8859-1.php}
  • delete: NP_ImageLimitSize/imagelimitsize/{japanese-euc.php => ja_Jpan_JP.EUC-JP.php}
  • delete: NP_ImageLimitSize/imagelimitsize/{japanese-utf8.php => ja_Jpan_JP.UTF-8.php}

Diferencia incremental

--- a/NP_ImageLimitSize/NP_ImageLimitSize.php
+++ b/NP_ImageLimitSize/NP_ImageLimitSize.php
@@ -1,8 +1,8 @@
11 <?php
22 /**
33 * ImageLimitSize 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 Kai Greve and maintained by shizuki and yamamoto
77 * This plugin depends on NP_MediaUtils
88 *
@@ -12,18 +12,20 @@
1212 * of the License, or (at your option) any later version.
1313 */
1414
15-class NP_ImageLimitSize extends NucleusPlugin {
15+class NP_ImageLimitSize extends NucleusPlugin
16+{
1617 public function getName() {return 'ImageLimitSize';}
1718 public function getAuthor() {return 'Mocchi, shizuki, yamamoto, Kai Greve';}
1819 public function getURL() {return 'http://japan.nucleuscms.org/wiki/plugins:imagelimitsize';}
19- public function getVersion() {return '0.9.6 (1.0 RC2)';}
20+ public function getVersion() {return '1.0.0';}
2021 public function getDescription() {return _NP_IMAGELIMITSIZE_01;}
2122 public function getPluginDep() {return array('NP_MediaUtils');}
2223 public function getMinNucleusVersion() {return 360;}
2324 public function supportsFeature($feature) { return in_array ($feature, array ('SqlTablePrefix', 'SqlApi'));}
2425 public function getEventList() {return array('PrePluginOptionsEdit', 'PreMediaUpload', 'MediaUploadFormExtras');}
2526
26- public function install() {
27+ public function install()
28+ {
2729 $this->createOption('maxwidth', '_NP_IMAGELIMITSIZE_02', 'text', '550', 'datatype=numerical');
2830 $this->createOption('maxheight', '_NP_IMAGELIMITSIZE_03', 'text', '0', 'datatype=numerical');
2931 $this->createBlogOption('status', '_NP_IMAGELIMITSIZE_04', 'yesno', 'yes');
@@ -32,132 +34,160 @@ class NP_ImageLimitSize extends NucleusPlugin {
3234 return;
3335 }
3436
35- public function uninstall() {
37+ public function uninstall()
38+ {
3639 // plugin options are purged automatically when uninstalled.
3740 return;
3841 }
3942
40- public function init() {
41- if((string)$_REQUEST['action'] == 'pluginlist' && !defined('_NP_IMAGELIMITSIZE_01')) {
43+ public function init()
44+ {
45+ $locale = '';
46+
47+ /* new API */
48+ if ( class_exists('i18n', FALSE) )
49+ {
50+ $locale = i18n::get_current_locale() . '.' . i18n::get_current_charset() . '.php';
51+ }
52+ /* old API */
53+ else
54+ {
4255 $language = preg_replace('#[/|\\\\]#', '', getLanguageName());
43- if (file_exists($this->getDirectory() . $language.'.php')) {
44- include($this->getDirectory() . $language.'.php');
45- } else {
46- include($this->getDirectory() . 'english.php');
56+ if ( $language == 'japanese-euc' )
57+ {
58+ $locale = 'ja_Jpan_JP.EUC-JP.php';
59+ }
60+ else if ( $language = 'japanese-utf8' )
61+ {
62+ $locale = 'ja_Jpan_JP.UTF-8.php';
4763 }
4864 }
65+
66+ if ( !$locale || !file_exists($this->getDirectory() . $locale) )
67+ {
68+ include($this->getDirectory() . 'en_Latn_US.ISO-8859-1.php');
69+ }
70+ else
71+ {
72+ include($this->getDirectory() . $locale);
73+ }
74+
4975 return;
5076 }
5177
52-/*
53- * for translation
54- */
55- public function event_PrePluginOptionsEdit ($data) {
56- if(!defined('_NP_IMAGELIMITSIZE_01')) {
57- $language = preg_replace('#[/|\\\\]#', '', getLanguageName());
58- if (file_exists($this->getDirectory() . $language.'.php')) {
59- include($this->getDirectory() . $language.'.php');
60- } else {
61- include($this->getDirectory() . 'english.php');
62- }
63- }
64- if ($data['context'] != 'global') {
65- foreach($data['options'] as $key => $option) {
66- if ($option['pid'] == $this->getID()) {
67- if (defined($option['description'])) {
68- $data['options'][$key]['description'] = constant($option['description']);
69- }
70- if ($option['type'] == 'select') {
71- foreach (explode('|', $option['typeinfo']) as $option) {
72- if (defined($option)) {
73- $data['options'][$key]['typeinfo'] = str_replace($option, constant($option), $data['options'][$key]['typeinfo']);
78+ /*
79+ * for translation
80+ */
81+ public function event_PrePluginOptionsEdit(&$data)
82+ {
83+ /* Old version do not support natively */
84+ if ( getNucleusVersion() < 400 )
85+ {
86+ if ( $data['context'] != 'global' )
87+ {
88+ foreach ( $data['options'] as $key => $option )
89+ {
90+ if ( $option['pid'] == $this->getID() )
91+ {
92+ if ( defined($option['description']) )
93+ {
94+ $data['options'][$key]['description'] = constant($option['description']);
95+ }
96+ if ( $option['type'] == 'select' )
97+ {
98+ foreach ( explode('|', $option['typeinfo']) as $option )
99+ {
100+ if ( defined($option) )
101+ {
102+ $data['options'][$key]['typeinfo'] = str_replace($option, constant($option), $data['options'][$key]['typeinfo']);
103+ }
74104 }
75105 }
76106 }
77107 }
78108 }
79- } else if ($data['plugid'] == $this->getID()) {
80- foreach($data['options'] as $key => $option){
81- if (defined($option['description'])) {
82- $data['options'][$key]['description'] = constant($option['description']);
83- }
84- if ($option['type'] == 'select') {
85- foreach (explode('|', $option['typeinfo']) as $option) {
86- if (defined($option)) {
87- $data['options'][$key]['typeinfo'] = str_replace($option, constant($option), $data['options'][$key]['typeinfo']);
109+ else if ($data['plugid'] == $this->getID() )
110+ {
111+ foreach ( $data['options'] as $key => $option )
112+ {
113+ if ( defined($option['description']) )
114+ {
115+ $data['options'][$key]['description'] = constant($option['description']);
116+ }
117+ if ( $option['type'] == 'select' )
118+ {
119+ foreach ( explode('|', $option['typeinfo']) as $option )
120+ {
121+ if ( defined($option) )
122+ {
123+ $data['options'][$key]['typeinfo'] = str_replace($option, constant($option), $data['options'][$key]['typeinfo']);
124+ }
88125 }
89- }
126+ }
90127 }
91128 }
92129 }
130+
93131 return;
94132 }
95133
96-/*
97- * for translation
98- */
99- static private function t($text,$array=array()) {
100- if (is_array($array)) {
101- $search = array();
102- $replace = array();
103-
104- foreach ($array as $key => $value){
105- if (is_array($value)) {
106- continue;
107- }
108- $search[] = '<%'.preg_replace('/[^a-zA-Z0-9_]+/','',$key).'%>';
109- $replace[] = $value;
110- }
111- }
112- return htmlspecialchars (str_replace($search, $replace, $text), ENT_QUOTES, _CHARSET);
113- }
114-
115- public function event_PreMediaUpload($data) {
134+ public function event_PreMediaUpload(&$data)
135+ {
116136 global $CONF, $manager;
117137
118- if (!class_exists('MediaUtils', FALSE)) {
138+ if ( !class_exists('MediaUtils', FALSE) )
139+ {
119140 return;
120141 }
121142
122- if (MediaUtils::$blogid == 0) {
143+ if ( MediaUtils::$blogid == 0 )
144+ {
123145 return;
124146 }
125147
126- if ($this->getBlogOption(MediaUtils::$blogid, 'status') == 'no') {
148+ if ( $this->getBlogOption(MediaUtils::$blogid, 'status') == 'no' )
149+ {
127150 return;
128151 }
129152
130- if (0 == ($maxwidth = $this->getBlogOption(MediaUtils::$blogid, 'blog_maxwidth'))) {
153+ if ( 0 == ($maxwidth = $this->getBlogOption(MediaUtils::$blogid, 'blog_maxwidth')) )
154+ {
131155 $maxwidth = $this->getOption('maxwidth');
132156 }
133157
134- if (0 == ($maxheight = $this->getBlogOption(MediaUtils::$blogid, 'blog_maxheight'))) {
158+ if ( 0 == ($maxheight = $this->getBlogOption(MediaUtils::$blogid, 'blog_maxheight')) )
159+ {
135160 $maxheight = $this->getOption('maxheight');
136161 }
137162
138163 $path = basename($data['uploadfile']);
139164 $root = str_replace('/' . $path, '', $data['uploadfile']);
140165
141- if (FALSE === ($medium = new MEDIUM($root, $path, MediaUtils::$prefix))) {
166+ if ( FALSE === ($medium = new MEDIUM($root, $path, MediaUtils::$prefix)) )
167+ {
142168 return;
143169 }
144170
145- if (!array_key_exists($medium->mime, MediaUtils::$image_mime)
146- || ($maxwidth >= $medium->width && $maxheight >= $medium->height)) {
171+ if ( !array_key_exists($medium->mime, MediaUtils::$image_mime)
172+ || ($maxwidth >= $medium->width && $maxheight >= $medium->height) )
173+ {
147174 return;
148175 }
149176
150- if (FALSE === $medium->setResampledSize($maxwidth, $maxheight)) {
177+ if ( FALSE === $medium->setResampledSize($maxwidth, $maxheight) )
178+ {
151179 return;
152180 }
153181
154- if (!MediaUtils::storeResampledImage($root, $path, $medium)) {
182+ if ( !MediaUtils::storeResampledImage($root, $path, $medium) )
183+ {
155184 return;
156185 }
157186 return;
158187 }
159188
160- public function event_MediaUploadFormExtras() {
189+ public function event_MediaUploadFormExtras()
190+ {
161191 echo '<input type="hidden" name="blogid" value="' . MediaUtils::$blogid . '" />' . "\n";
162192 return;
163193 }
--- a/NP_ImageLimitSize/imagelimitsize/english.php
+++ b/NP_ImageLimitSize/imagelimitsize/en_Latn_US.ISO-8859-1.php
@@ -1,8 +1,8 @@
11 <?php
22 /**
33 * ImageLimitSize 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 Kai Greve and maintained by shizuki and yamamoto
77 * This plugin depends on NP_MediaUtils
88 *
--- a/NP_ImageLimitSize/imagelimitsize/japanese-euc.php
+++ b/NP_ImageLimitSize/imagelimitsize/ja_Jpan_JP.EUC-JP.php
@@ -1,8 +1,8 @@
11 <?php
22 /**
33 * ImageLimitSize 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 Kai Greve and maintained by shizuki and yamamoto
77 * This plugin depends on NP_MediaUtils
88 *
--- a/NP_ImageLimitSize/imagelimitsize/japanese-utf8.php
+++ b/NP_ImageLimitSize/imagelimitsize/ja_Jpan_JP.UTF-8.php
@@ -1,8 +1,8 @@
11 <?php
22 /**
33 * ImageLimitSize 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 Kai Greve and maintained by shizuki and yamamoto
77 * This plugin depends on NP_MediaUtils
88 *
Show on old repository browser