• R/O
  • HTTP
  • SSH
  • HTTPS

nucleus-plugins: Commit

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


Commit MetaInfo

Revision352fb8238c9004b36f81760777b7965178869b19 (tree)
Time2012-10-20 09:44:04
Authorsakamocchi <o-takashi@saka...>
Commitersakamocchi

Log Message

ADD: Mocchiが手がけたファイル管理プラグイン一式をコミット

NP_Attach 0.9.6:

NP_ImageLimitSize 0.9.6:

NP_ImprovedMedia 3.0.1:

NP_MediaUtils 0.9.6:

NP_Thumbnail 3.9.6:

Change Summary

Incremental Difference

--- /dev/null
+++ b/NP_Attach/NP_Attach.php
@@ -0,0 +1,530 @@
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+// TODO (hard) If itemOption is set as "hidden", PrePluginOptionsUpdate event is not generated, related Nucleus CMS library problem.
16+// TODO (hard) There are no ways to show the error message even if upload processing is failed.
17+// TODO (medium) all of the plugin options are purged when uninstalling plugins.
18+
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();
25+
26+ public function getName() { return 'Attach'; }
27+ public function getAuthor() { return 'Mocchi, yamamoto, NKJG'; }
28+ 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 getDescription() { return _NP_ATTACH_01; }
31+ 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 (
36+ 'PrePluginOptionsEdit',
37+ 'AdminPrePageHead',
38+ 'BookmarkletExtraHead',
39+ 'PreItem',
40+ 'PreAddItem',
41+ 'PreUpdateItem',
42+ 'PostAddItem',
43+ 'PostUpdateItem',
44+ 'PrePluginOptionsUpdate',
45+ 'AddItemFormExtras',
46+ 'EditItemFormExtras');
47+ }
48+
49+ public function install () {
50+ $this->createOption('maxwidth', '_NP_ATTACH_02', 'text', '90', 'datatype=numerical');
51+ $this->createOption('maxheight', '_NP_ATTACH_03', 'text', '90', 'datatype=numerical');
52+ $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>');
53+ $this->createOption('admin_media_template', '_NP_ATTACH_05', 'textarea', '<a href="<%link%>" title="<%text%>"><%text%></a>');
54+ $this->createBlogOption('amount', '_NP_ATTACH_06', 'text', '3');
55+ $this->createBlogOption('blog_image_template', '_NP_ATTACH_07', 'textarea', '<img src="<%link%>" width="<%width%>" height="<%height%>" alt="<%text%>" />');
56+ $this->createBlogOption('blog_media_template', '_NP_ATTACH_08', 'textarea', '<a href="<%link%>" title="<%text%>"><%text%></a>');
57+ $this->createItemOption('media', '_NP_ATTACH_09', 'text', '');
58+ return;
59+ }
60+
61+ public function uninstall () {
62+ return;
63+ }
64+
65+ public function init() {
66+ if(!defined('_NP_ATTACH_01')) {
67+ $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');
72+ }
73+ }
74+ return;
75+ }
76+
77+/*
78+ * for translation
79+ */
80+ public function event_PrePluginOptionsEdit ($data)
81+ {
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']);
92+ }
93+ }
94+ }
95+ }
96+ }
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']);
106+ }
107+ }
108+ }
109+ }
110+ }
111+ return;
112+ }
113+
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;
140+ }
141+
142+ self::prepareEnctype ();
143+ return;
144+ }
145+
146+ public function event_BookmarkletExtraHead ($data) {
147+ self::prepareEnctype ();
148+ return;
149+ }
150+
151+ public function event_AddItemFormExtras ($data) {
152+ global $DIR_MEDIA;
153+ $blog = $data['blog'];
154+ self::$blogid = $blog->blogid;
155+ self::$itemid = 0;
156+ self::setEnctype ();
157+ $this->setData($DIR_MEDIA);
158+ $this->showInterface ();
159+ return;
160+ }
161+
162+ public function event_EditItemFormExtras ($data) {
163+ global $DIR_MEDIA;
164+ $blog = $data['blog'];
165+ self::$blogid = $blog->blogid;
166+ self::$itemid = $data['itemid'];
167+ self::setEnctype ();
168+ $this->setData($DIR_MEDIA);
169+ $this->showInterface ();
170+ return;
171+ }
172+
173+/*
174+ * Process upload and update plugin item option
175+ */
176+ public function event_PreAddItem ($data) {
177+ self::$blogid = $data['blog']->blogid;
178+ return;
179+ }
180+ public function event_PreUpdateItem ($data) {
181+ self::$blogid = $data['blog']->blogid;
182+ return;
183+ }
184+ public function event_PostAddItem ($data) {
185+ self::$itemid = $data['itemid'];
186+ return;
187+ }
188+ public function event_PostUpdateItem ($data) {
189+ self::$itemid = $data['itemid'];
190+ return;
191+ }
192+ public function event_PrePluginOptionsUpdate ($data) {
193+ global $DIR_MEDIA, $member;
194+
195+ if ($data['plugid'] != $this->getID () || $data['optionname'] != 'media') {
196+ return;
197+ }
198+
199+ $this->setData($DIR_MEDIA);
200+ self::batchRequest ($DIR_MEDIA, $member->getID());
201+
202+ $value = '';
203+ foreach (self::$data as $datum) {
204+ if (!$datum['path']) {
205+ continue;
206+ }
207+ $value .= "{$datum['path']}:{$datum['alt']}:{$datum['way']};";
208+ }
209+
210+ $data['value'] = $value;
211+ return;
212+ }
213+
214+/*
215+ * Show media in item
216+ */
217+ public function event_PreItem($data) {
218+ global $DIR_MEDIA;
219+ self::$blogid =& $data['blog']->blogid;
220+ self::$itemid =& $data["item"]->itemid;
221+ $this->setData($DIR_MEDIA);
222+
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);
225+ return;
226+ }
227+ public function doTemplateVar($item, $mediumid) {
228+ global $DIR_MEDIA, $blogid;
229+
230+ if (!self::$itemid || !self::$blogid) {
231+ self::$blogid = $blogid;
232+ self::$itemid = $item->itemid;
233+ $this->setData($DIR_MEDIA);
234+ }
235+ $this->getParsedTag(array('item', $mediumid));
236+ return;
237+ }
238+
239+ private function getParsedTag($match) {
240+ global $DIR_MEDIA, $manager;
241+
242+ $maxwidth = 0;
243+ $maxheight = 0;
244+ if (array_key_exists(3, $match)) {
245+ $maxheight = (integer) trim($match[3], ',');
246+ }
247+ if (array_key_exists(2, $match)) {
248+ $maxwidth = (integer) trim($match[2], ',');
249+ }
250+
251+ $data = &self::$data;
252+ $mediumid = $match[1];
253+ $mediumid--;
254+
255+ if (!array_key_exists ($mediumid, $data) || !$data[$mediumid]['path']) {
256+ return;
257+ }
258+
259+ $NP_Thumbnail =& $manager->getPlugin('NP_Thumbnail');
260+
261+ if ($maxwidth==0 && $maxheight==0) {
262+ $maxwidth = $NP_Thumbnail->getOption('maxwidth');
263+ $maxheight = $NP_Thumbnail->getOption('maxheight');
264+ }
265+
266+ if (FALSE === ($medium = new MEDIUM($DIR_MEDIA, $data[$mediumid]['path'], MediaUtils::$prefix))) {
267+ return;
268+ }
269+
270+ if (array_key_exists($medium->mime, MediaUtils::$image_mime)
271+ && !$medium->setResampledSize($maxwidth, $maxheight)) {
272+ return;
273+ }
274+
275+ if (!array_key_exists($medium->mime, MediaUtils::$image_mime)
276+ || $data[$mediumid]['way'] == 'anchor') {
277+ $template = $this->getBlogOption(self::$blogid, 'blog_media_template');
278+ } else if ($data[$mediumid]['way'] == 'original') {
279+ $template = $this->getBlogOption(self::$blogid, 'blog_image_template');
280+ } else {
281+ $template = $NP_Thumbnail->getBlogOption(self::$blogid, 'thumb_template');
282+ }
283+ return $NP_Thumbnail->generateTag($template, $medium, $data[$mediumid]['alt']);
284+ }
285+
286+ private function showInterface () {
287+ global $CONF, $DIR_LIBS, $DIR_MEDIA, $manager;
288+
289+ if (!class_exists('BODYACTIONS', FALSE)) {
290+ include ($DIR_LIBS . 'BODYACTIONS.php');
291+ }
292+ $action = new BODYACTIONS;
293+
294+ if (!$manager->pluginInstalled('NP_Thumbnail')) {
295+ return;
296+ }
297+ $NP_Thumbnail = &$manager->getPlugin('NP_Thumbnail');
298+ $maxwidth = $NP_Thumbnail->getOption('maxwidth');
299+ $maxheight = $NP_Thumbnail->getOption('maxheight');
300+
301+ if (!self::$amount) {
302+ return;
303+ }
304+
305+ $data = self::$data;
306+
307+ if (empty($data)) {
308+ return;
309+ }
310+
311+ echo "<table frame=\"box\" rules=\"all\" summary=\"Attached Media\">\n";
312+ echo "<thead>\n";
313+ echo "<tr>\n";
314+ echo "<th>" . _NP_ATTACH_10 . "</th>\n";
315+ echo "<th>" . _NP_ATTACH_11 . "</th>\n";
316+ echo "<th>" . _NP_ATTACH_12 . "</th>\n";
317+ echo "</tr>\n";
318+ echo "</thead>\n";
319+ echo "<tbody>\n";
320+
321+ for ($count = 0; $count < self::$amount; $count++) {
322+ $id = $count + 1;
323+
324+ echo "<tr>\n";
325+ echo "<td>\n";
326+ echo "<label for=\"alt{$count}\"><%Attach({$id})%></label>\n";
327+
328+ if ($data[$count]['path']) {
329+ echo "<br />\n";
330+ echo "<input type=\"checkbox\" id=\"delete{$count}\" name=\"delete[{$count}]\" value=\"1\" />\n";
331+ echo "<label for=\"delete{$count}\">" . _NP_ATTACH_13 . "</label>\n";
332+ }
333+
334+ echo "</td>\n";
335+ echo "<td>\n";
336+
337+ if (!$data[$count]['path']) {
338+ 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))) {
341+ return;
342+ }
343+
344+ if (array_key_exists($medium->mime, MediaUtils::$image_mime)
345+ && !$medium->setResampledSize($maxwidth, $maxheight)) {
346+ return;
347+ }
348+
349+ if (array_key_exists($medium->mime, MediaUtils::$image_mime)) {
350+ $template = $this->getOption('admin_popup_template');
351+ } else {
352+ $template = $this->getOption('admin_media_template');
353+ }
354+
355+ echo $NP_Thumbnail->generateTag($template, $medium, $data[$count]['alt']) . "<br />\n";
356+ echo "<input type=\"hidden\" id=\"path{$count}\" name=\"path[{$count}]\" value=\"{$data[$count]['path']}\" /><br />\n";
357+ }
358+ echo "<input type=\"text\" id=\"alt{$count}\" name=\"alt[{$count}]\" value=\"{$data[$count]['alt']}\" size=\"12\" />\n";
359+ echo "</td>\n";
360+ echo "<td>\n";
361+
362+ if ($data[$count]['path'] && !array_key_exists($data[$count]['mime'], MediaUtils::$image_mime)) {
363+ echo "<input type=\"hidden\" name=\"way[{$count}]\" value=\"anchor\" />\n";
364+ echo _NP_ATTACH_14 . "\n";
365+ } else {
366+ $thumbnail_checked = "";
367+ $original_checked = "";
368+ $anchor_checked = "";
369+
370+ if ($data[$count]['way'] == 'original') {
371+ $original_checked = 'checked="checked"';
372+ } else if ($data[$count]['way'] == 'anchor') {
373+ $anchor_checked = 'checked="checked"';
374+ } else {
375+ $thumbnail_checked = 'checked="checked"';
376+ }
377+
378+ echo "<input type=\"radio\" id=\"way{$count}-anchor\" name=\"way[{$count}]\" value=\"anchor\" {$anchor_checked} />\n";
379+ echo "<label for=\"way{$count}-anchor\">" . _NP_ATTACH_15 . "<label><br />\n";
380+ echo "<input type=\"radio\" id=\"way{$count}-small\" name=\"way[{$count}]\" value=\"thumbnail\" {$thumbnail_checked} />\n";
381+ echo "<label for=\"way{$count}-small\">" . _NP_ATTACH_16 . "<label><br />\n";
382+ echo "<input type=\"radio\" id=\"way{$count}-original\" name=\"way[{$count}]\" value=\"original\" {$original_checked} />\n";
383+ echo "<label for=\"way{$count}-original\">" . _NP_ATTACH_17 . "<label>\n";
384+ }
385+ echo "</td>\n";
386+ echo "</tr>\n";
387+ }
388+
389+ echo "</tbody>\n";
390+ echo "</table>\n";
391+ return;
392+ }
393+
394+ private function setData($root) {
395+ if(self::$blogid === 0 || !self::$itemid === 0) {
396+ return;
397+ }
398+
399+ self::$amount = $this->getBlogOption(self::$blogid, 'amount');
400+ $media = explode(';', $this->getitemOption (self::$itemid, 'media'));
401+ $data = array();
402+
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]);
406+ $data[$count]['path'] = $medium[0];
407+ $data[$count]['alt'] = $medium[1];
408+ $data[$count]['way'] = $medium[2];
409+
410+ if (FALSE === ($file = new Medium($root, $data[$count]['path'], MediaUtils::$prefix))) {
411+ $data[$count] = array ('path' => "", 'alt' => "", 'way' => "");
412+ }
413+
414+ $data[$count]['mime'] = $file->mime;
415+ $data[$count]['width'] = $file->width;
416+ $data[$count]['height'] = $file->height;
417+ } else {
418+ $data[$count] = array ('path' => "", 'alt' => "", 'way' => "");
419+ }
420+ }
421+
422+ self::$data = $data;
423+ return;
424+ }
425+
426+ static private function batchRequest($root, $collection) {
427+ 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)) {
435+ $media = $_FILES['medium'];
436+ }
437+
438+ if (array_key_exists ('path', $_POST)) {
439+ $paths = $_POST['path'];
440+ }
441+
442+ if (array_key_exists ('alt', $_POST)) {
443+ $alts = $_POST['alt'];
444+ }
445+
446+ if (array_key_exists ('way', $_POST)) {
447+ $ways = $_POST['way'];
448+ }
449+
450+ if (array_key_exists ('delete', $_POST)) {
451+ $deletes = $_POST['delete'];
452+ }
453+
454+ $data = &self::$data;
455+
456+ if (!$manager->pluginInstalled('NP_Thumbnail')) {
457+ return;
458+ }
459+ $NP_Thumbnail = &$manager->getPlugin('NP_Thumbnail');
460+
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' => "");
466+ continue;
467+ }
468+
469+ $medium['name'] = &$media['name'][$key];
470+ $medium['size'] = $media['size'][$key];
471+ $medium['tmp_name'] = $media['tmp_name'][$key];
472+ $medium['error'] = $media['error'][$key];
473+
474+ $result = MediaUtils::uploadMedium ($root, $collection, $medium, $medium['name'], $manager);
475+
476+ if ($result) {
477+ $data[$key]['path'] = "";
478+ $data[$key]['alt'] = $result . ' (' . $medium['name'] . ')';
479+ $data[$key]['way'] = "";
480+ continue;
481+ } else {
482+ $data[$key]['path'] = $collection . '/' . $medium['name'];
483+ }
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' => "");
487+ continue;
488+ }
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));
493+ }
494+ $data[$key] = array ('path' => "", 'alt' => "", 'way' => "");
495+ continue;
496+ }
497+ }
498+ }
499+
500+ if (array_key_exists ($key, $alts) && $alts[$key] != $value['alt']) {
501+ $data[$key]['alt'] = htmlspecialchars ($alts[$key], ENT_QUOTES, _CHARSET);
502+ }
503+
504+ if (array_key_exists ($key, $ways) && $ways[$key] != $value['way']) {
505+ if (!in_array ($ways[$key], array ('thumbnail', 'original', 'anchor'))) {
506+ $data[$key]['way'] = 'thumbnail';
507+ } else {
508+ $data[$key]['way'] = $ways[$key];
509+ }
510+ }
511+ }
512+ return;
513+ }
514+
515+ static private function prepareEnctype () {
516+ self::$buffer = ob_start ();
517+ return;
518+ }
519+
520+ static private function setEnctype () {
521+ if (!self::$buffer) {
522+ return;
523+ }
524+ $strings = ob_get_contents ();
525+ ob_end_clean ();
526+ $strings = preg_replace ('#action="(index.php|bookmarklet.php)"#', '$0 enctype="multipart/form-data"', $strings);
527+ echo $strings;
528+ return;
529+ }
530+}
--- /dev/null
+++ b/NP_Attach/attach/english.php
@@ -0,0 +1,31 @@
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 files directly on item. <%Attach%> can show these files on item.');
16+define('_NP_ATTACH_02', 'Maximum width for thumbnail on item edit page');
17+define('_NP_ATTACH_03', 'Maximum height for thumbnail on item edit page');
18+define('_NP_ATTACH_04', 'Template for thumbnail on item edit page');
19+define('_NP_ATTACH_05', 'Template for normal file on item edit page');
20+define('_NP_ATTACH_06', 'Maximum number of files on an item');
21+define('_NP_ATTACH_07', 'Template for original image on weblog. Template for thumbnail is based on NP_Thumbnail.');
22+define('_NP_ATTACH_08', 'Template for normal file on weblog.');
23+define('_NP_ATTACH_09', 'Media Information');
24+define('_NP_ATTACH_10', 'Tag');
25+define('_NP_ATTACH_11', 'Media file and alternative text');
26+define('_NP_ATTACH_12', 'Way to embed');
27+define('_NP_ATTACH_13', 'Erase');
28+define('_NP_ATTACH_14', 'Anchor');
29+define('_NP_ATTACH_15', 'Anchor');
30+define('_NP_ATTACH_16', 'Thumbnail');
31+define('_NP_ATTACH_17', 'Original');
--- /dev/null
+++ b/NP_Attach/attach/index.html
@@ -0,0 +1,11 @@
1+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2+<html xmlns="http://www.w3.org/1999/xhtml">
3+<head>
4+<title>Nothing Here</title>
5+</head>
6+<body>
7+
8+<h1>Nothing to see here</h1>
9+
10+</body>
11+</html>
\ No newline at end of file
--- /dev/null
+++ b/NP_Attach/attach/japanese-euc.php
@@ -0,0 +1,31 @@
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', '実寸');
--- /dev/null
+++ b/NP_Attach/attach/japanese-utf8.php
@@ -0,0 +1,31 @@
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', '実寸');
--- /dev/null
+++ b/NP_ImageLimitSize/NP_ImageLimitSize.php
@@ -0,0 +1,164 @@
1+<?php
2+/**
3+ * ImageLimitSize 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 Kai Greve and maintained by shizuki and yamamoto
7+ * This plugin depends on 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+class NP_ImageLimitSize extends NucleusPlugin {
16+ public function getName() {return 'ImageLimitSize';}
17+ public function getAuthor() {return 'Mocchi, shizuki, yamamoto, Kai Greve';}
18+ 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 getDescription() {return _NP_IMAGELIMITSIZE_01;}
21+ public function getPluginDep() {return array('NP_MediaUtils');}
22+ public function getMinNucleusVersion() {return 360;}
23+ public function supportsFeature($feature) { return in_array ($feature, array ('SqlTablePrefix', 'SqlApi'));}
24+ public function getEventList() {return array('PrePluginOptionsEdit', 'PreMediaUpload', 'MediaUploadFormExtras');}
25+
26+ public function install() {
27+ $this->createOption('maxwidth', '_NP_IMAGELIMITSIZE_02', 'text', '550', 'datatype=numerical');
28+ $this->createOption('maxheight', '_NP_IMAGELIMITSIZE_03', 'text', '0', 'datatype=numerical');
29+ $this->createBlogOption('status', '_NP_IMAGELIMITSIZE_04', 'yesno', 'yes');
30+ $this->createBlogOption('blog_maxwidth', '_NP_IMAGELIMITSIZE_05', 'text', '0', 'datatype=numerical');
31+ $this->createBlogOption('blog_maxheight', '_NP_IMAGELIMITSIZE_06', 'text', '0', 'datatype=numerical');
32+ return;
33+ }
34+
35+ public function uninstall() {
36+ // plugin options are purged automatically when uninstalled.
37+ return;
38+ }
39+
40+ public function init() {
41+ if((string)$_REQUEST['action'] == 'pluginlist' && !defined('_NP_IMAGELIMITSIZE_01')) {
42+ $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');
47+ }
48+ }
49+ return;
50+ }
51+
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']);
74+ }
75+ }
76+ }
77+ }
78+ }
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']);
88+ }
89+ }
90+ }
91+ }
92+ }
93+ return;
94+ }
95+
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) {
116+ global $CONF, $manager;
117+
118+ if (!class_exists('MediaUtils', FALSE)) {
119+ return;
120+ }
121+
122+ if (MediaUtils::$blogid == 0) {
123+ return;
124+ }
125+
126+ if ($this->getBlogOption(MediaUtils::$blogid, 'status') == 'no') {
127+ return;
128+ }
129+
130+ if (0 == ($maxwidth = $this->getBlogOption(MediaUtils::$blogid, 'blog_maxwidth'))) {
131+ $maxwidth = $this->getOption('maxwidth');
132+ }
133+
134+ if (0 == ($maxheight = $this->getBlogOption(MediaUtils::$blogid, 'blog_maxheight'))) {
135+ $maxheight = $this->getOption('maxheight');
136+ }
137+
138+ $path = basename($data['uploadfile']);
139+ $root = str_replace('/' . $path, '', $data['uploadfile']);
140+
141+ if (FALSE === ($medium = new MEDIUM($root, $path, MediaUtils::$prefix))) {
142+ return;
143+ }
144+
145+ if (!array_key_exists($medium->mime, MediaUtils::$image_mime)
146+ || ($maxwidth >= $medium->width && $maxheight >= $medium->height)) {
147+ return;
148+ }
149+
150+ if (FALSE === $medium->setResampledSize($maxwidth, $maxheight)) {
151+ return;
152+ }
153+
154+ if (!MediaUtils::storeResampledImage($root, $path, $medium)) {
155+ return;
156+ }
157+ return;
158+ }
159+
160+ public function event_MediaUploadFormExtras() {
161+ echo '<input type="hidden" name="blogid" value="' . MediaUtils::$blogid . '" />' . "\n";
162+ return;
163+ }
164+}
--- /dev/null
+++ b/NP_ImageLimitSize/imagelimitsize/english.php
@@ -0,0 +1,20 @@
1+<?php
2+/**
3+ * ImageLimitSize 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 Kai Greve and maintained by shizuki and yamamoto
7+ * This plugin depends on 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_IMAGELIMITSIZE_01', 'Resample uploaded image just after uploading if bigger than defined size');
16+define('_NP_IMAGELIMITSIZE_02', 'Maximam height for image');
17+define('_NP_IMAGELIMITSIZE_03', 'Maximum width for image');
18+define('_NP_IMAGELIMITSIZE_04', 'Enable Resampling');
19+define('_NP_IMAGELIMITSIZE_05', 'Maximum height for image. Plugin\'s global option is applied if blank');
20+define('_NP_IMAGELIMITSIZE_06', 'Maximal height for image. Plugin\'s global option is applied if blank');
--- /dev/null
+++ b/NP_ImageLimitSize/imagelimitsize/index.html
@@ -0,0 +1,10 @@
1+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2+<html xmlns="http://www.w3.org/1999/xhtml">
3+<head>
4+<title>Notice</title>
5+</head>
6+<body>
7+<h1>Notice</h1>
8+<p>Nothing to see here</p>
9+</body>
10+</html>
\ No newline at end of file
--- /dev/null
+++ b/NP_ImageLimitSize/imagelimitsize/japanese-euc.php
@@ -0,0 +1,20 @@
1+<?php
2+/**
3+ * ImageLimitSize 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 Kai Greve and maintained by shizuki and yamamoto
7+ * This plugin depends on 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_IMAGELIMITSIZE_01', 'ファイルをアップロードした直後に、画像ファイルでありかつ縦横サイズが設定値より大きかった場合、縮小した画像ファイルを代わりに保存します');
16+define('_NP_IMAGELIMITSIZE_02', '最大の横幅');
17+define('_NP_IMAGELIMITSIZE_03', '最大の高さ');
18+define('_NP_IMAGELIMITSIZE_04', '機能を有効にします');
19+define('_NP_IMAGELIMITSIZE_05', '最大の横幅。0の場合はプラグインオプションの値を適用します');
20+define('_NP_IMAGELIMITSIZE_06', '最大の高さ。0の場合はプラグインオプションの値を適用します');
--- /dev/null
+++ b/NP_ImageLimitSize/imagelimitsize/japanese-utf8.php
@@ -0,0 +1,20 @@
1+<?php
2+/**
3+ * ImageLimitSize 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 Kai Greve and maintained by shizuki and yamamoto
7+ * This plugin depends on 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_IMAGELIMITSIZE_01', 'ファイルをアップロードした直後に、画像ファイルでありかつ縦横サイズが設定値より大きかった場合、縮小した画像ファイルを代わりに保存します');
16+define('_NP_IMAGELIMITSIZE_02', '最大の横幅');
17+define('_NP_IMAGELIMITSIZE_03', '最大の高さ');
18+define('_NP_IMAGELIMITSIZE_04', '機能を有効にします');
19+define('_NP_IMAGELIMITSIZE_05', '最大の横幅。0の場合はプラグインオプションの値を適用します');
20+define('_NP_IMAGELIMITSIZE_06', '最大の高さ。0の場合はプラグインオプションの値を適用します');
--- /dev/null
+++ b/NP_ImprovedMedia/NP_ImprovedMedia.php
@@ -0,0 +1,278 @@
1+<?php
2+/**
3+ * ImprovedMedia plugin for Nucleus CMS
4+ * Version 3.0.1 for PHP5
5+ * Written By Mocchi, Feb.28, 2010
6+ *
7+ * This program is free software; you can redistribute it and/or
8+ * modify it under the terms of the GNU General Public License
9+ * as published by the Free Software Foundation; either version 3
10+ * of the License, or (at your option) any later version.
11+ */
12+
13+class NP_ImprovedMedia extends NucleusPlugin {
14+ // private
15+ private $baseUrl = ''; //string
16+ // private
17+ private $blog = FALSE; //object
18+ // private
19+ private $blogid = 1; //integer
20+
21+ // public
22+ public function __construct() {
23+ global $CONF;
24+ $this->baseUrl = str_replace($CONF['AdminURL'], '', $this->getAdminURL());
25+ self::setBlogObject();
26+ return;
27+ }
28+
29+ // public
30+ public function getName() { return 'ImprovedMedia'; }
31+ // public
32+ public function getAuthor() { return 'Mocchi'; }
33+ // public
34+ public function getURL() { return 'http://japan.nucleuscms.org/wiki/plugins:improvedmedia'; }
35+ // public
36+ public function getVersion() { return '3.0.1 for PHP5'; }
37+ // public
38+ public function getMinNucleusVersion() { return 223; }
39+ // public
40+ public function getDescription() { return _IM_DESCRIPTION; }
41+
42+ // public
43+ public function supportsFeature($what) {
44+ global $CONF;
45+ switch($what) {
46+ case 'HelpPage':
47+ case 'SqlTablePrefix':
48+ return 1;
49+ default:
50+ return 0;
51+ }
52+ }
53+
54+ // public
55+ public function init() {
56+ $language = preg_replace( '#[/|\\\\]#', '', getLanguageName());
57+ if(file_exists($this->getDirectory() .'lang/' . $language.'.php'))
58+ include_once($this->getDirectory() . 'lang/' . $language.'.php');
59+ else
60+ include_once($this->getDirectory() . 'lang/english.php');
61+
62+ if($this->getOption('IM_EACHBLOGDIR') == 'yes')
63+ self::setDirectories();
64+
65+ return;
66+ }
67+
68+ // public
69+ public function install() {
70+ $this->createOption('IM_PRIVATE', _IM_OPTION_PRIVATE , 'yesno', 'yes');
71+ $this->createOption('IM_ITEMDISPLAY', _IM_OPTION_ITEMDISPLAY , 'text', '10', 'datatype=numerical' );
72+ $this->createOption('IM_GREYBOX', _IM_OPTION_GREYBOX , 'yesno', 'no');
73+ $this->createOption('IM_EACHBLOGDIR', _IM_OPTION_EACHBLOGDIR , 'yesno', 'no');
74+ return;
75+ }
76+
77+ // public
78+ public function unInstall() {
79+ $this->deleteOption('IM_PRIVATE');
80+ $this->deleteOption('IM_ITEMDISPLAY');
81+ $this->deleteOption('IM_GREYBOX');
82+ $this->deleteOption('IM_EACHBLOGDIR');
83+ return;
84+ }
85+
86+ // public
87+ public function getEventList() {
88+ return array('InitSkinParse', 'AdminPrePageHead', 'BookmarkletExtraHead');
89+ }
90+
91+ // public
92+ public function doAction($type) {
93+ global $DIR_LIBS;
94+ if(!class_exists('MEDIA', FALSE))
95+ include($DIR_LIBS . 'MEDIA.php');
96+ if(!class_exists('MEDIA_VARIABLES', FALSE))
97+ include($this->getDirectory() . 'MEDIA_VARIABLES.php');
98+ if(!class_exists('MEDIA_CONTROL', FALSE))
99+ include($this->getDirectory() . 'MEDIA_CONTROL.php');
100+
101+ new MEDIA_CONTROL($this);
102+ exit;
103+ }
104+
105+ // public
106+ public function doSkinVar($data, $place) {
107+ global $CONF, $member;
108+ if($member->isLoggedIn()) {
109+ if($this->getOption('IM_GREYBOX') == 'yes') {
110+ switch($place) {
111+ case 'head':
112+ echo '<script type="text/javascript">' . "\n" .
113+ '<!--' . "\n" .
114+ ' var GB_ROOT_DIR = "' . $CONF['AdminURL'] . $this->baseUrl . 'greybox/";' . "\n" .
115+ '// -->' . "\n" .
116+ '</script>' . "\n" .
117+ '<script type="text/javascript" src="' . $CONF['AdminURL'] . $this->baseUrl . 'greybox/AJS.js"></script>' . "\n" .
118+ '<script type="text/javascript" src="' . $CONF['AdminURL'] . $this->baseUrl . 'greybox/AJS_fx.js"></script>' . "\n" .
119+ '<script type="text/javascript" src="' . $CONF['AdminURL'] . $this->baseUrl . 'greybox/gb_scripts.js"></script>' . "\n".
120+ '<link href="' . $CONF['AdminURL'] . $this->baseUrl . 'greybox/gb_styles.css" rel="stylesheet" type="text/css" />' . "\n";
121+ break;
122+ case 'anchor':
123+ echo '<a href="' . $CONF['ActionURL'] . '?action=plugin&amp;name=ImprovedMedia&amp;astool=1&amp;blogid=' . $this->blogid . '" onclick="GB_showCenter(\'Media Control' . _IM_HEADER_TEXT . '\',this.href,540,600); return false;">' . _IM_ANCHOR_TEXT . '</a>';
124+ break;
125+ default:
126+ break;
127+ }
128+ } else {
129+ if($place == 'anchor') {
130+ echo '<a href="' . $CONF['ActionURL'] . '?action=plugin&amp;name=ImprovedMedia&amp;astool=1&amp;blogid=' . $this->blogid . '" onclick="window.open(this.href , \'MediaControl\' , \'width=600 , height=600, scrollbars=1\'); return false;">' . _IM_ANCHOR_TEXT . '</a>';
131+ }
132+ }
133+ }
134+ return;
135+ }
136+
137+ // public
138+ public function event_InitSkinParse(&$data) {
139+ return;
140+ }
141+
142+ // public
143+ public function event_BookmarkletExtraHead(&$data) {
144+ self::addHeader($data['extrahead']);
145+ return;
146+ }
147+
148+ // public
149+ public function event_AdminPrePageHead(&$data) {
150+ if(($data['action'] == 'createitem') || ($data['action'] == 'itemedit'))
151+ self::addHeader($data['extrahead']);
152+ return;
153+ }
154+
155+ // private
156+ private function addHeader(&$extrahead) {
157+ global $CONF;
158+
159+ if($this->getOption('IM_GREYBOX') == 'yes') {
160+ $extrahead .= '<script type="text/javascript">' ."\n" .
161+ '<!--' ."\n".
162+ 'function addMedia() {' ."\n".
163+ ' GB_showCenter(\'Media Control' . _IM_HEADER_TEXT . '\',\'' . $CONF['ActionURL'] . '?action=plugin&name=ImprovedMedia&mode=upload_select&astool=0&blogid=' . $this->blogid . '\',540,600);' . "\n" .
164+ '}' . "\n";
165+ } else {
166+ $extrahead .= '<script type="text/javascript">' ."\n" .
167+ '<!--' ."\n".
168+ 'function addMedia() {' ."\n".
169+ ' window.open(\'' . $CONF['ActionURL'] . '?action=plugin&name=ImprovedMedia&mode=upload_select&astool=0&blogid=' . $this->blogid . '\' , \'MediaControl\' , \'width=600 , height=600, scrollbars=1\');' . "\n" .
170+ '}' . "\n";
171+ }
172+ $extrahead .= 'function includeImage(collection, filename, type, width, height, text) {' . "\n" .
173+ ' var fullName;' . "\n" .
174+ ' if(isNaN(collection) || (nucleusAuthorId != collection)) {' . "\n" .
175+ ' fullName = collection + \'/\' + filename;' . "\n" .
176+ ' } else {' . "\n" .
177+ ' fullName = filename;' . "\n" .
178+ ' }' . "\n" .
179+ ' var replaceBy;' . "\n" .
180+ ' switch(type) {' . "\n" .
181+ ' case \'popup\':' . "\n" .
182+ ' replaceBy = \'<%popup(\' + fullName + \'|\'+width+\'|\'+height+\'|\' + text +\')%>\';' . "\n" .
183+ ' break;' . "\n" .
184+ ' case \'inline\':' . "\n" .
185+ ' default:' . "\n" .
186+ ' replaceBy = \'<%image(\' + fullName + \'|\'+width+\'|\'+height+\'|\' + text +\')%>\';' . "\n" .
187+ ' }' . "\n" .
188+ ' insertAtCaret(replaceBy);' . "\n" .
189+ ' updAllPreviews();' . "\n" .
190+ '}' . "\n" .
191+ '' . "\n" .
192+ 'function includeOtherMedia(collection, filename, text) {' . "\n" .
193+ ' var fullName;' . "\n" .
194+ ' if(isNaN(collection) || (nucleusAuthorId != collection)) {' . "\n" .
195+ ' fullName = collection + \'/\' + filename;' . "\n" .
196+ ' } else {' . "\n" .
197+ ' fullName = filename;' . "\n" .
198+ ' }' . "\n" .
199+ ' var replaceBy = \'<%media(\' + fullName + \'|\' + text +\')%>\';' . "\n" .
200+ ' insertAtCaret(replaceBy);' . "\n" .
201+ ' updAllPreviews();' . "\n" .
202+ '}' .
203+ '// -->' ."\n".
204+ '</script>'."\n";
205+
206+ if($this->getOption('IM_GREYBOX') == 'yes') {
207+ $extrahead .= '<script type="text/javascript">' . "\n" .
208+ '<!--' . "\n" .
209+ ' var GB_ROOT_DIR = "' . $CONF['AdminURL'] . $this->baseUrl . 'greybox/";' . "\n" .
210+ '// -->' . "\n" .
211+ '</script>' . "\n" .
212+ '<script type="text/javascript" src="' . $CONF['AdminURL'] . $this->baseUrl . 'greybox/AJS.js"></script>' . "\n" .
213+ '<script type="text/javascript" src="' . $CONF['AdminURL'] . $this->baseUrl . 'greybox/AJS_fx.js"></script>' . "\n" .
214+ '<script type="text/javascript" src="' . $CONF['AdminURL'] . $this->baseUrl . 'greybox/gb_scripts.js"></script>' . "\n" .
215+ '<link href="' . $CONF['AdminURL'] . $this->baseUrl . 'greybox/gb_styles.css" rel="stylesheet" type="text/css" />' . "\n";
216+ }
217+ return;
218+ }
219+
220+ // private
221+ private function setBlogObject() {
222+ global $manager, $blog;
223+
224+ $blogid = intRequestVar('blogid');
225+ $itemid = intRequestVar('itemid');
226+
227+ if($blog) {
228+ $this->blog =& $blog;
229+ $this->blogid =& $blog->getID();
230+ return;
231+ }
232+
233+ if($blogid && $manager->existsBlogID($blogid)) {
234+ $this->blog =& $manager->getBlog($blogid);
235+ $this->blogid =& $this->blog->getID();
236+ return;
237+ }
238+
239+ if($itemid && $manager->existsItem($itemid, 1, 1)) {
240+ $this->blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
241+ $this->blogid =& $this->blog->getID();
242+ return;
243+ }
244+ }
245+
246+ // private
247+ private function setDirectories() {
248+ global $DIR_MEDIA, $CONF;
249+
250+ if(!$this->blog)
251+ return;
252+
253+ $blog =& $this->blog;
254+ $bshortname =& $blog->getShortName();
255+
256+ if($this->blogid !== 1) {
257+ $DIR_MEDIA = preg_replace('#(.+)/(.+)?/$#',"$1/$bshortname/$2/",$DIR_MEDIA);
258+ $CONF['MediaURL'] = preg_replace( '#(.+)/(.+)?/$#' , "$1/$bshortname/$2/" , $CONF['MediaURL'] );
259+ }
260+ return;
261+ }
262+
263+ // public
264+ public function & getBlog() {
265+ return $this->blog;
266+ }
267+
268+ // public
269+ public function & getBlogid() {
270+ return $this->blogid;
271+ }
272+
273+ // public
274+ public function getBaseURL() {
275+ return $this->baseUrl;
276+ }
277+}
278+?>
\ No newline at end of file
--- /dev/null
+++ b/NP_ImprovedMedia/improvedmedia/MEDIA_CONTROL.php
@@ -0,0 +1,1733 @@
1+<?php
2+/**
3+ * ImprovedMedia plugin for Nucleus CMS
4+ * Version 3.0.1 for PHP5
5+ * Written By Mocchi, Feb.28, 2010
6+ *
7+ * This program is free software; you can redistribute it and/or
8+ * modify it under the terms of the GNU General Public License
9+ * as published by the Free Software Foundation; either version 3
10+ * of the License, or (at your option) any later version.
11+ */
12+
13+class MEDIA_CONTROL extends MEDIA_VARIABLES {
14+ public function __construct(&$PluginObject) {
15+ global $CONF, $manager, $member;
16+
17+ parent::__construct(&$PluginObject);
18+ self::setMode();
19+
20+ // login routine from globalfunctions.php
21+ // this should be checked and changes as soon as the core program is updated
22+ if(self::getMode() == 'login') {
23+ if (!isset($CONF['secureCookieKey']))
24+ $CONF['secureCookieKey'] = 24;
25+ switch($CONF['secureCookieKey']){
26+ case 8:
27+ $CONF['secureCookieKeyIP'] = preg_replace('#\.[0-9]+\.[0-9]+\.[0-9]+$#', '', serverVar('REMOTE_ADDR'));
28+ break;
29+ case 16:
30+ $CONF['secureCookieKeyIP'] = preg_replace('#\.[0-9]+\.[0-9]+$#', '', serverVar('REMOTE_ADDR'));
31+ break;
32+ case 24:
33+ $CONF['secureCookieKeyIP'] = preg_replace('#\.[0-9]+$#', '', serverVar('REMOTE_ADDR'));
34+ break;
35+ case 32:
36+ $CONF['secureCookieKeyIP'] = serverVar('REMOTE_ADDR');
37+ break;
38+ default:
39+ $CONF['secureCookieKeyIP'] = '';
40+ }
41+
42+ $login = postVar('login');
43+ $pw = substr(postVar('password'),0,40);
44+ $shared = intPostVar('shared');
45+
46+ if($member->login($login, $pw)) {
47+ $member->newCookieKey();
48+ $member->setCookies($shared);
49+
50+ if ($CONF['secureCookieKey'] !=='none') {
51+ $member->setCookieKey(md5($member->getCookieKey() . $CONF['secureCookieKeyIP']));
52+ $member->write();
53+ }
54+
55+ $manager->notify('LoginSuccess', array('member' => &$member));
56+ ACTIONLOG::add(INFO, "Login successful for $login (sharedpc=$shared)");
57+ } else {
58+ $manager->notify('LoginFailed', array('username' => $login));
59+ ACTIONLOG::add(INFO, "Login failed for $login");
60+ }
61+ }
62+
63+ self::setAlttext();
64+ self::setAstool();
65+ self::setCollection();
66+ self::setSubDir();
67+ self::setFilename();
68+ self::setNewFilename();
69+ self::setOffset();
70+ self::setWay();
71+ self::setFilter();
72+
73+ if(!$member->isLoggedIn()) {
74+ self::media_loginAndPassThrough();
75+ return;
76+ }
77+
78+ if(!$PluginObject->getBlogid()) {
79+ self::media_doError(_IM_FORBIDDEN_ACCESS);
80+ return;
81+ }
82+
83+ if(!$member->isAdmin() && !$member->isTeamMember(self::getBlogid())) {
84+ self::media_doError(_ERROR_NOTONTEAM);
85+ return;
86+ }
87+
88+ if(!in_array(self::getMode(), parent::$modesNotToCheck) && !$manager->checkTicket()) {
89+ self::media_doError(_ERROR_BADTICKET);
90+ return;
91+ }
92+
93+ if(!is_dir(self::getDirMedia()) || !is_writable(self::getDirMedia())) {
94+ self::media_doError(_IM_REMIND_MEDIADIR);
95+ return;
96+ }
97+
98+ if(self::getCollections() === 'error') {
99+ self::media_doError(_IM_REMIND_DIRECTORY);
100+ return;
101+ }
102+
103+ if(self::getCollection() === 'error') {
104+ self::media_doError(_IM_MISSING_DIRECTORY);
105+ return;
106+ }
107+
108+ if(self::getSubdirs() === 'error') {
109+ self::media_doError(_IM_COLLECTION_FAILED_READ);
110+ return;
111+ }
112+
113+ if(self::getFilename() === 'error') {
114+ self::media_doError(_IM_MISSING_FILE);
115+ return;
116+ }
117+
118+ switch(self::getMode()) {
119+ case 'rename_confirm';
120+ self::media_rename_confirm();
121+ return;
122+ case 'rename';
123+ self::media_rename();
124+ return;
125+ case 'erase_confirm':
126+ self::media_erase_confirm();
127+ return;
128+ case 'erase';
129+ self::media_erase();
130+ return;
131+ case 'upload_select':
132+ case _IM_UPLOAD_NEW:
133+ self::media_upload_select();
134+ return;
135+ case 'upload':
136+ self::media_upload();
137+ return;
138+ case 'embed_confirm':
139+ self::media_embed_confirm();
140+ return;
141+ case 'embed':
142+ self::media_embed();
143+ return;
144+ case 'directory_remove_confirm':
145+ self::media_directory_remove_confirm();
146+ return;
147+ case 'directory_remove':
148+ self::media_directory_remove();
149+ return;
150+ case _IM_CREATE_SUBDIR_CONFIRM:
151+ self::media_directory_create_confirm();
152+ return;
153+ case 'directory_create':
154+ self::media_directory_create();
155+ return;
156+ case 'directory_rename_confirm':
157+ self::media_directory_rename_confirm();
158+ return;
159+ case 'directory_rename':
160+ self::media_directory_rename();
161+ return;
162+ case _IM_DISPLAY_SUBDIR:
163+ case _IM_DISPLAY_SUBDIR_SELECT:
164+ case 'directory_display':
165+ self::media_directory_display();
166+ return;
167+ case _IM_COLLECTION_SELECT:
168+ case _IM_FILTER_APPLY:
169+ case 'display':
170+ default:
171+ self::media_display();
172+ return;
173+ }
174+ return;
175+ }
176+
177+ private function showMediaList() {
178+ global $manager, $member;
179+
180+ $collections = self::getCollections();
181+
182+ if(!self::getSubdir()) $combinedcollection = self::getCollection();
183+ else $combinedcollection = self::getCollection() . '/' . self::getSubdir();
184+
185+ $arr = MEDIA::getMediaListByCollection($combinedcollection, self::getFilter());
186+ $list = array();
187+
188+ foreach($arr as $obj) {
189+ if(!is_dir(self::getDirMedia() . $obj->collection . '/' . $obj->filename)
190+ && preg_match('#^(.+)\.([a-zA-Z0-9]{2,})$#', $obj->filename))
191+ array_push($list, $obj);
192+ }
193+
194+ if(self::getMediaprefix())
195+ usort($list, array("MEDIA_CONTROL", "sort_media_by_filename"));
196+
197+ $fileamount = count($list);
198+
199+ if($fileamount > 0) {
200+ $idxStart = ceil(self::getOffset() / self::getItemdisplay()) * self::getItemdisplay();
201+ $idxEnd = $idxStart + self::getItemdisplay();
202+ if($idxEnd > $fileamount)
203+ $idxEnd = $fileamount;
204+ $idxPrev = $idxStart - self::getItemdisplay();
205+ if($idxPrev < 0)
206+ $idxPrev = 0;
207+ $idxNext = $idxStart + self::getItemdisplay();
208+
209+ echo '<table frame="void" rules="none" summary="FILE LIST" width="100%">' . "\n";
210+ echo '<caption>' . _IM_COLLECTION_AMOUNT . $fileamount . ' (';
211+ if(!self::getFilter())
212+ echo _IM_FILTER_NONE;
213+ else
214+ echo _IM_FILTER . self::getFilter();
215+ echo ') &gt;&gt; ';
216+ if(self::getSubdir())
217+ echo self::getSubdir() . ' &gt;&gt; ';
218+ echo $collections[self::getCollection()];
219+ if(self::getBlogShortName() && self::getEachblogdir())
220+ echo ' &gt;&gt; ' . self::getBlogShortName();
221+ echo "</caption>\n";
222+ echo "<thead>\n";
223+ echo "<tr>\n";
224+
225+ if(self::getMediaprefix())
226+ echo '<th>' . _IM_UPDATE . "</th>\n";
227+ else
228+ echo '<th>' . _MEDIA_MODIFIED . "</th>\n";
229+
230+ echo '<th>' . _IM_FILENAME_CLICK . "</th>\n";
231+ echo '<th>' . _IM_TYPE . "</th>\n";
232+
233+ if(!self::getAstool())
234+ echo '<th>' . _IM_ACTION . "</th>\n";
235+
236+ echo '<th>' . _IM_DIMENSIONS . "</th>\n";
237+ echo '<th colspan="2">' . _IM_FUNCTION . "</th>\n";
238+ echo "</tr>\n";
239+ echo "</thead>\n";
240+ echo "<tfoot>";
241+ echo "<tr>\n";
242+ echo '<td colspan="2">'. "\n";
243+ if($idxStart > 0)
244+ echo '<a href="' . self::getAccessURL() . '&amp;collection=' . urlencode(self::getCollection()) . '&amp;subdir=' . urlencode(self::getSubdir()) . '&amp;filter=' . urlencode(self::getFilter()) . '&amp;astool=' . urlencode(self::getAstool()) . '&amp;offset=' . urlencode($idxPrev) . '&amp;blogid=' . urlencode(self::getBlogid()) . '">' . _LISTS_PREV . ' &lt;</a> ';
245+ if(($idxStart + 1) != $idxEnd)
246+ echo ($idxStart + 1) . ' to ' . $idxEnd . ' / ' . $fileamount . ' ';
247+ if($idxEnd < $fileamount)
248+ echo '<a href="' . self::getAccessURL() . '&amp;collection=' . urlencode(self::getCollection()) . '&amp;subdir=' . urlencode(self::getSubdir()) . '&amp;filter=' . urlencode(self::getFilter()) . '&amp;astool=' . urlencode(self::getAstool()) . '&amp;offset=' . urlencode($idxNext) . '&amp;blogid=' . urlencode(self::getBlogid()) . '">&lt; ' . _LISTS_NEXT . '</a> ';
249+ echo "</td>\n";
250+ if(!self::getAstool())
251+ echo '<td colspan="5" class="right">'. "\n";
252+ else
253+ echo '<td colspan="4" class="right">'. "\n";
254+ if(self::getBlogName() && self::getEachblogdir())
255+ echo _IM_WEBLOG_LABEL . ': ' . self::getBlogName();
256+ echo "</td>\n";
257+ echo "</tr>\n";
258+ echo "</tfoot>\n";
259+ echo "<tbody>\n";
260+
261+ for($i = $idxStart; $i < $idxEnd; $i++) {
262+ $obj = $list[$i];
263+
264+ list($width, $height, $filetype, $filesize) = self::getFileData($combinedcollection, $obj->filename);
265+ list($update, $onlyfilename, $onlyprefix) = self::getSplitFilename($combinedcollection, $obj->filename);
266+
267+ echo "<tr>\n";
268+ echo "<td>" . $update . "</td>\n";
269+ echo "<td>\n";
270+ if($filetype != 0 && !self::getSubdir())
271+ echo '<a href="'. self::getMediaURL() . urlencode(self::getCollection()) . '/' . urlencode($obj->filename) . '" onclick="window.open(this.href,\'PopupWindow\',\'width=400, height=400,location=yes,status=yes,scrollbars=yes,resizable=yes\'); return false;" title="' . $obj->filename . _IM_VIEW_TT . '">' . "\n";
272+ elseif($filetype == 0 && !self::getSubdir())
273+ echo '<a href="'. self::getMediaURL() . urlencode(self::getCollection()) . '/' . urlencode($obj->filename) . '" onclick="window.open(this.href,\'PopupWindow\',\'width=' . $width . ', height=' . $height . ',location=yes,status=yes,scrollbars=yes,resizable=yes\'); return false;" title="' . $obj->filename . _IM_VIEW_TT .'">'."\n";
274+ elseif($filetype != 0 && self::getSubdir())
275+ echo '<a href="'. self::getMediaURL() . urlencode(self::getCollection()) . '/' . urlencode(self::getSubdir()) . '/' . urlencode($obj->filename) . '" onclick="window.open(this.href,\'PopupWindow\',\'width=400, height=400,location=yes,status=yes,scrollbars=yes,resizable=yes\'); return false;" title="' . $obj->filename . _IM_VIEW_TT . '">' . "\n";
276+ else
277+ echo '<a href="'. self::getMediaURL() . urlencode(self::getCollection()) . '/' . urlencode(self::getSubdir()) . '/' . urlencode($obj->filename) . '" onclick="window.open(this.href,\'PopupWindow\',\'width=' . $width . ', height=' . $height . ',location=yes,status=yes,scrollbars=yes,resizable=yes\'); return false;" title="' . $obj->filename . _IM_VIEW_TT .'">'."\n";
278+
279+ if(!self::getAstool())
280+ echo shorten($onlyfilename . '.' . $onlyprefix, 15, '...') . "\n";
281+ else
282+ echo shorten($onlyfilename . '.' . $onlyprefix, 30, '...') . "\n";
283+
284+ echo "</a>\n";
285+ echo "</td>\n";
286+ echo '<td>' . $onlyprefix . "</td>\n";
287+ if(!self::getAstool()) {
288+ echo "<td>\n";
289+ echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
290+ echo "<p>\n";
291+ echo '<input type="hidden" name="mode" value="embed_confirm" />' . "\n";
292+ echo $manager->addTicketHidden() . "\n";
293+ echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
294+ echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
295+ echo '<input type="hidden" name="filename" value="' . $obj->filename . '" />' . "\n";
296+ echo '<input type="hidden" name="filter" value="'. self::getFilter() . '" />' . "\n";
297+ echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
298+ echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
299+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
300+ if($filetype != 0)
301+ echo '<input type="hidden" name="type" value="image" />' . "\n";
302+ else
303+ echo '<input type="hidden" name="type" value="other" />' . "\n";
304+ echo '<input type="submit" name="button" value="' . _IM_INCLUDE .'" class="formbutton" />' . "\n";
305+ echo "</p>\n";
306+ echo '</form>' . "\n";
307+ echo '</td>' . "\n";
308+ }
309+ if($filetype != 0)
310+ echo '<td>' . $width . '&nbsp;x&nbsp;' . $height . "</td>\n";
311+ else
312+ echo '<td>' . $filesize . "&nbsp;KB</td>\n";
313+ echo '<td>' . "\n";
314+ echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
315+ echo "<p>\n";
316+ echo '<input type="hidden" name="mode" value="erase_confirm" />' . "\n";
317+ echo $manager->addTicketHidden() . "\n";
318+ echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
319+ echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
320+ echo '<input type="hidden" name="filename" value="' . $obj->filename . '" />' . "\n";
321+ echo '<input type="hidden" name="filter" value="'. self::getFilter() . '" />' . "\n";
322+ echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
323+ echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
324+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
325+ echo '<input type="submit" name="button" value="' . _IM_ERASE . '" class="formbutton" />' . "\n";
326+ echo "</p>\n";
327+ echo '</form>' . "\n";
328+ echo '</td>' . "\n";
329+ echo '<td>' . "\n";
330+ echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
331+ echo "<p>\n";
332+ echo '<input type="hidden" name="mode" value="rename_confirm" />' . "\n";
333+ echo $manager->addTicketHidden() . "\n";
334+ echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
335+ echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
336+ echo '<input type="hidden" name="filename" value="' . $obj->filename . '" />' . "\n";
337+ echo '<input type="hidden" name="filter" value="'. self::getFilter() . '" />' . "\n";
338+ echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
339+ echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
340+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
341+ echo '<input type="submit" name="button" value="' . _IM_RENAME . '" class="formbutton" />' . "\n";
342+ echo "</p>\n";
343+ echo '</form>' . "\n";
344+ echo '</td>' . "\n";
345+ echo '</tr>' . "\n";
346+ }
347+ echo "</tbody>\n";
348+ echo "</table>\n";
349+ } else {
350+ echo '<p>' . _IM_COLLECTION_BRANK . ' (';
351+ if(!self::getFilter())
352+ echo _IM_FILTER_NONE;
353+ else
354+ echo _IM_FILTER . self::getFilter();
355+ echo ') ' . ' &gt;&gt; ';
356+ if(self::getSubdir())
357+ echo self::getSubdir() . ' &gt;&gt; ';
358+ echo $collections[self::getCollection()];
359+ if(self::getBlogShortName() && self::getEachblogdir())
360+ echo ' &gt;&gt; ' . self::getBlogShortName();
361+ echo "</p>\n";
362+ }
363+ return;
364+ }
365+
366+ private function media_display() {
367+ global $manager, $member;
368+
369+ $collections = self::getCollections();
370+ $subdirs = self::getSubdirs();
371+
372+ array_shift($subdirs);
373+
374+ if(self::getItemdisplay() != strval(intval(self::getItemdisplay())) || (self::getItemdisplay() < 5) || (self::getItemdisplay() > 50 )) {
375+ self::media_doError(_IM_ITEMDISPLAY_WRONG);
376+ return;
377+ }
378+
379+ self::media_head();
380+
381+ echo '<form method="post" action="' . self::getAccessURL() . '" enctype="application/x-www-form-urlencoded">' . "\n";
382+ echo '<p>' . "\n";
383+
384+ if(count($collections) > 1) {
385+ echo '<label for="media_collection">' . _IM_COLLECTION_LABEL . '</label>' . "\n";
386+ echo '<select name="collection" id="media_collection">' . "\n";
387+ foreach($collections as $dirname => $description) {
388+ if((string)$dirname == (string)self::getCollection())
389+ echo '<option value="' . $dirname . '" selected="selected">' . $description . "</option>\n";
390+ else
391+ echo '<option value="' . $dirname . '">' . $description . "</option>\n";
392+ }
393+ echo '</select>' . "\n";
394+ echo '<input type="submit" name="mode" value="' . _IM_COLLECTION_SELECT . '" title="' . _IM_COLLECTION_TT . '" class="formbutton" />' . "\n";
395+ } else {
396+ echo _IM_COLLECTION . ': ' . $collections[self::getCollection()] . '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
397+ }
398+ echo '<input type="submit" name="mode" value="' . _IM_UPLOAD_NEW . '" title="' . _IM_UPLOADLINK . '" class="formbutton" />' . "\n";
399+ echo $manager->addTicketHidden() . "\n";
400+ echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
401+ echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
402+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
403+ echo '</p>' . "\n";
404+ echo '</form>' . "\n";
405+
406+ echo '<form method="post" action="' . self::getAccessURL() . '" enctype="application/x-www-form-urlencoded">' . "\n";
407+ echo '<p>' . "\n";
408+ if(count($subdirs) > 0) {
409+ echo '<label for="media_subdir">' . _IM_SUBDIR_LABEL . '</label>' . "\n";
410+ echo '<select name="subdir" id="media_subdir">' . "\n";
411+ if(self::getSubdir() == '')
412+ echo '<option value="" selected="selected">' . _IM_SUBDIR_NONE . "</option>\n";
413+ else
414+ echo '<option value="">' . _IM_SUBDIR_NONE . "</option>\n";
415+ foreach($subdirs as $key => $options) {
416+ if($options['subdirname'] == self::getSubdir())
417+ echo '<option value="' . $options['subdirname'] . '" selected="selected">' . $options['subdirname'] . "</option>\n";
418+ else
419+ echo '<option value="' . $options['subdirname'] . '">' . $options['subdirname'] . "</option>\n";
420+ }
421+ echo '</select>' . "\n";
422+ echo '<input type="submit" name="mode" value="' . _IM_SUBDIR_SELECT . '" title="' . _IM_SUBDIR_TT . '" class="formbutton" />' . "\n";
423+ } elseif(self::getSubdir() == '') {
424+ echo _IM_SUBDIR_LABEL . _IM_SUBDIR_NONE . '<input type="hidden" name="subdir" value="" />' . "\n";
425+ }
426+ echo '<input type="submit" name="mode" value="' . _IM_DISPLAY_SUBDIR . '" title="' . _IM_DISPLAY_SUBDIR_TT. '" class="formbutton" />' . "\n";
427+ echo $manager->addTicketHidden() . "\n";
428+ echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
429+ echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
430+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
431+ echo '</p>' . "\n";
432+ echo '</form>' . "\n";
433+
434+ echo '<form method="post" action="' . self::getAccessURL() . '" enctype="application/x-www-form-urlencoded">' . "\n";
435+ echo '<p>' . "\n";
436+ echo '<label for="media_filter">' . _IM_FILTER_LABEL . '</label>' . "\n";
437+ echo '<select name="filter" id="media_filter">' . "\n";
438+ if(self::getFilter() == '')
439+ echo '<option value="" selected="selected">' . _IM_FILTER_NONE . "</option>\n";
440+ else
441+ echo '<option value="">' . _IM_FILTER_NONE . "</option>\n";
442+ if(is_array(self::getAllowedtypes())) {
443+ foreach(self::getAllowedtypes() as $allowedtype) {
444+ if($allowedtype == self::getFilter())
445+ echo '<option value="' . $allowedtype . '" selected="selected">' . $allowedtype . "</option>\n";
446+ else
447+ echo '<option value="' . $allowedtype . '">' . $allowedtype . "</option>\n";
448+ }
449+ }
450+ echo '</select>' . "\n";
451+ echo '<input type="submit" name="mode" value="' . _IM_FILTER_APPLY . '" class="formbutton" />' . "\n";
452+ echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
453+ echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
454+ echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
455+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
456+ echo '</p>' . "\n";
457+ echo '</form>' . "\n";
458+ echo '<hr />' . "\n";
459+
460+ self::showMediaList();
461+ self::media_foot();
462+ return;
463+ }
464+
465+ private function media_erase() {
466+ global $manager;
467+
468+ if(!self::getSubdir()) $combinedfilename = self::getFilename();
469+ else $combinedfilename = self::getSubdir() . '/' . self::getFilename();
470+
471+ $manager->notify('PreMediaErase',array('collection' => self::getCollection(), 'filename' => $combinedfilename));
472+
473+ if(!@unlink(self::getDirMedia() . self::getCollection() . '/' . $combinedfilename)) {
474+ self::media_doError(_IM_ERASE_FAILED . ': ' . self::getCollection() . '/' . $combinedfilename);
475+ return;
476+ }
477+ $manager->notify('PostMediaErase',array('collection' => self::getCollection(), 'filename' => $combinedfilename));
478+
479+ self::resetFilter();
480+ self::resetOffset();
481+ self::media_display();
482+ return;
483+ }
484+
485+ private function media_rename() {
486+ global $manager;
487+
488+ $newfilename = self::getNewfilename();
489+
490+ if($newfilename == '') {
491+ self::media_rename_confirm(_IM_RENAME_BLANK);
492+ return;
493+ } elseif(mb_strlen($newfilename, _CHARSET) > 30) {
494+ self::media_rename_confirm(_IM_RENAME_TOOLONG);
495+ return;
496+ } elseif(!preg_match('#^[a-zA-Z0-9 \_\-\+]+$#', $newfilename)) {
497+ self::media_rename_confirm(_IM_RENAME_WRONG);
498+ return;
499+ } elseif(stristr($newfilename, '%00')) {
500+ self::media_doError(_IM_RENAME_FORBIDDEN);
501+ return;
502+ }
503+
504+ if(!self::getSubdir()) $combinedfilename = self::getFilename();
505+ else $combinedfilename = self::getSubdir() . '/' . self::getFilename();
506+
507+ list($update, $onlyfilename, $onlyprefix) = self::getSplitFilename(self::getCollection(), $combinedfilename);
508+ $update = preg_replace('#/|\\\\#', '', $update);
509+
510+ if(self::getMediaprefix())
511+ $newfilename = $update . '-' . $newfilename . '.' . $onlyprefix;
512+ else
513+ $newfilename = $newfilename . '.' . $onlyprefix;
514+
515+ if(!self::getSubdir()) $combinednewfilename = $newfilename;
516+ else $combinednewfilename = self::getSubdir() . '/' . $newfilename;
517+
518+ $manager->notify('PreMediaRename',array('collection' => self::getCollection(), 'oldfilename' => $combinedfilename, 'newfilename' => $combinednewfilename));
519+
520+ if(!@rename(self::getDirMedia() . self::getCollection() . '/' . $combinedfilename, self::getDirMedia() . self::getCollection() . '/' . $combinednewfilename)) {
521+ self::media_doError(_IM_RENAME_FAILED . ': ' . self::getCollection() . '/' . $combinedfilename);
522+ return;
523+ }
524+
525+ $manager->notify('PostMediaRename',array('collection' => self::getCollection(), 'oldfilename' => $combinedfilename, 'newfilename' => $combinednewfilename));
526+
527+ self::resetFilter();
528+ self::resetOffset();
529+ self::media_display();
530+ return;
531+ }
532+
533+ private function media_upload() {
534+ global $CONF;
535+ if(!$CONF['AllowUpload']) {
536+ self::media_doError(_ERROR_DISALLOWED);
537+ return;
538+ }
539+
540+ $uploadInfo = postFileInfo('uploadfile');
541+ $filename = $uploadInfo['name'];
542+ $filetype = $uploadInfo['type'];
543+ $filesize = $uploadInfo['size'];
544+ $filetempname = $uploadInfo['tmp_name'];
545+ $fileerror = intval($uploadInfo['error']);
546+
547+ // include error code for debugging
548+ // (see http://www.php.net/manual/en/features.file-upload.errors.php)
549+ switch($fileerror) {
550+ case 0: // = UPLOAD_ERR_OK
551+ break;
552+ case 1: // = UPLOAD_ERR_INI_SIZE
553+ case 2: // = UPLOAD_ERR_FORM_SIZE
554+ self::media_doError(_ERROR_FILE_TOO_BIG);
555+ return;
556+ case 3: // = UPLOAD_ERR_PARTIAL
557+ case 4: // = UPLOAD_ERR_NO_FILE
558+ case 6: // = UPLOAD_ERR_NO_TMP_DIR
559+ case 7: // = UPLOAD_ERR_CANT_WRITE
560+ default:
561+ self::media_doError(_ERROR_BADREQUEST . ' (' . $fileerror . ')');
562+ return;
563+ }
564+
565+ if($filesize > self::getMaxuploadsize()) {
566+ self::media_doError(_ERROR_FILE_TOO_BIG);
567+ return;
568+ }
569+
570+ $ok = 0;
571+ foreach(self::getAllowedtypes() as $allowedtype) {
572+ if(eregi("\." . $allowedtype . "$",$filename))
573+ $ok = 1;
574+ }
575+
576+ if(!$ok) {
577+ self::media_doError(_ERROR_BADFILETYPE);
578+ return;
579+ }
580+
581+ if(!is_uploaded_file($filetempname)) {
582+ self::media_doError(_ERROR_BADREQUEST);
583+ return;
584+ }
585+
586+ // prefix filename with current date (YYYY-MM-DD-) to avoid nameclashes
587+ if(self::getMediaprefix())
588+ $filename = strftime("%Y%m%d-", time()) . $filename;
589+
590+ if(!self::getSubdir()) $combinedfilename = $filename;
591+ else $combinedfilename = self::getSubdir() . '/' . $filename;
592+
593+ $message = MEDIA::addMediaObject(self::getCollection(), $filetempname, $combinedfilename);
594+
595+ if($message != '') {
596+ self::media_doError($message);
597+ return;
598+ }
599+
600+ self::resetFilter();
601+ self::resetOffset();
602+
603+ if(!self::getAstool()) {
604+ $tempfilename =& self::getFilename();
605+ $tempfilename = $filename;
606+ self::media_embed_confirm(_IM_UPLOAD_CONPLETE);
607+ return;
608+ } else {
609+ self::media_display();
610+ }
611+ }
612+
613+ private function media_embed() {
614+ global $manager, $member;
615+
616+ $collections = self::getCollections();
617+
618+ if(!self::getSubdir()) $combinedfilename = self::getFilename();
619+ else $combinedfilename = self::getSubdir() . '/' . self::getFilename();
620+
621+ $jsCollection = str_replace("'","\\'", self::getCollection());
622+ $jsFileName = str_replace("'","\\'", $combinedfilename);
623+
624+ list($width, $height, $filetype, $filesize) = self::getFileData(self::getCollection(), $combinedfilename);
625+
626+ if(self::getAlttext() == '') {
627+ self::media_embed_confirm(_IM_REQUIREMENT);
628+ return;
629+ } elseif(mb_strlen(self::getAlttext(), _CHARSET) > 40 ) {
630+ self::media_embed_confirm(_IM_ALT_TOOLONG);
631+ return;
632+ }
633+
634+ self::media_head();
635+ echo '<h2>' . _IM_HEADER_EMBED . "</h2>\n";
636+ echo '<h3>' . _IM_INCLUDE_DESC . '</h3>' . "\n";
637+ echo '<div class="filedetail">' . "\n";
638+ echo '<dl>' . "\n";
639+ echo '<dt>' . _IM_FILENAME . '</dt>' . "\n";
640+ echo '<dd>' . self::getFilename() . '</dd>' . "\n";
641+ echo '<dt>' . _IM_INCLUDE_ALT . '</dt>' . "\n";
642+ echo '<dd>' . self::getAlttext() . '</dd>' . "\n";
643+
644+ if(self::getSubdir()) {
645+ echo '<dt>' . _IM_SUBDIR . "</dt>\n";
646+ echo '<dd>' . self::getSubdir() . "</dd>\n";
647+ }
648+
649+ echo '<dt>' . _IM_COLLECTION . '</dt>' . "\n";
650+ echo '<dd>' . $collections[self::getCollection()] . '</dd>' . "\n";
651+
652+ if(self::getBlogName() && self::getEachblogdir()) {
653+ echo '<dt>' . _IM_WEBLOG_LABEL . "</dt>\n";
654+ echo '<dd>' . self::getBlogName() . "</dd>\n";
655+ }
656+
657+ if(self::getWay() == 'popup') {
658+ echo '<dt>' . _IM_DIMENSIONS . '</dt>' . "\n";
659+ echo '<dd>' . $width . ' x ' . $height . ' (' . $filesize . 'KB)</dd>' . "\n";
660+ echo '<dt>' . _IM_INCLUDE_WAY . '</dt>' . "\n";
661+ echo '<dd>' . _IM_INCLUDE_WAY_POPUP . '</dd>' . "\n";
662+ } elseif(self::getWay() == 'inline') {
663+ echo '<dt>' . _IM_DIMENSIONS . '</dt>' . "\n";
664+ echo '<dd>' . $width . ' x ' . $height . ' (' . $filesize . 'KB)</dd>' . "\n";
665+ echo '<dt>' . _IM_INCLUDE_WAY . '</dt>' . "\n";
666+ echo '<dd>' . _IM_INCLUDE_WAY_INLINE . '</dd>';
667+ } elseif(self::getWay() == 'other') {
668+ echo '<dt>' . _IM_DIMENSIONS . '</dt>' . "\n";
669+ echo '<dd>' . $filesize . 'KB' . '</dd>' . "\n";
670+ echo '<dt>' . _IM_INCLUDE_WAY . '</dt>' . "\n";
671+ echo '<dd>' . _IM_INCLUDE_WAY_OTHER . '</dd>';
672+ }
673+
674+ echo '</dl>' . "\n";
675+ echo '</div>' . "\n";
676+
677+ echo '<h3>' . _IM_INCLUDE_CODE . '</h3>' . "\n";
678+ echo '<p>' . _IM_INCLUDE_CODE_DESC . '</p>' . "\n";
679+
680+ if(self::getWay() == 'popup') {
681+ echo '<p>&lt;%popup(' . self::getCollection() . '/' . $combinedfilename . '|' . $width . '|' . $height . '|' . self::getAlttext() . ')%&gt;</p>' . "\n";
682+ echo '<form method="post" action="' . self::getAccessURL() . '" enctype="application/x-www-form-urlencoded" onclick="chooseImage(\'' . $jsCollection . '\',\'' . $jsFileName . '\',\'popup\',\'' . $width . '\',\'' . $height . '\',\'' . self::getAlttext() . '\'' . ')" >' . "\n";
683+ } elseif(self::getWay() == 'inline') {
684+ echo '<p>&lt;%image(' . self::getCollection() . '/' . $combinedfilename . '|' . $width . '|' . $height . '|' . self::getAlttext() . ')%&gt;</p>' . "\n";
685+ echo '<form method="post" action="' . self::getAccessURL() . '" enctype="application/x-www-form-urlencoded" onclick="chooseImage(\'' . $jsCollection . '\',\'' . $jsFileName . '\',\'inline\',\'' . $width . '\',\'' . $height . '\',\'' . self::getAlttext() . '\'' . ')" >' . "\n";
686+ } else {
687+ echo '<p>&lt;%media(' . self::getCollection() . '/' . $combinedfilename . '|' . self::getAlttext() . ')%&gt;</p>' . "\n";
688+ echo '<form method="post" action="' . self::getAccessURL() . '" enctype="application/x-www-form-urlencoded" onclick="chooseOther(\'' . $jsCollection . '\',\'' . $jsFileName . '\',\'' . self::getAlttext() . '\'' . ')" >' . "\n";
689+ }
690+
691+ echo '<p class="left">' . "\n";
692+ echo '<input type="submit" value="' . _IM_INCLUDE . '" />' . "\n";
693+ echo '</p>' . "\n";
694+ echo '</form>' . "\n";
695+
696+ echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
697+ echo '<p class="right">' . "\n";
698+ echo '<input type="hidden" name="mode" value="embed_confirm" />' . "\n";
699+ echo $manager->addTicketHidden() . "\n";
700+ echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
701+ echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
702+ echo '<input type="hidden" name="filename" value="' . self::getFilename() . '" />' . "\n";
703+ echo '<input type="hidden" name="alttext" value="' . self::getAlttext() . '" />' . "\n";
704+ echo '<input type="hidden" name="way" value="' . self::getWay() . '" />' . "\n";
705+ echo '<input type="hidden" name="filter" value="'. self::getFilter() . '" />' . "\n";
706+ echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
707+ echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
708+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
709+ echo '<input type="submit" value="' . _IM_INCLUDE_MODIFIED . '" />' . "\n";
710+ echo '</p>' . "\n";
711+ echo '</form>' . "\n";
712+
713+ self::media_foot();
714+ return;
715+ }
716+
717+ private function media_erase_confirm() {
718+ global $manager, $member;
719+
720+ $collections = self::getCollections();
721+
722+ if(!self::getSubdir()) $combinedcollection = self::getCollection();
723+ else $combinedcollection = self::getCollection() . '/' . self::getSubdir();
724+
725+ list($width, $height, $filetype, $filesize) = self::getFileData($combinedcollection, self::getFilename());
726+
727+ self::media_head();
728+ echo '<h2>' . _IM_HEADER_ERASE_CONFIRM . "</h2>\n";
729+ echo '<h3>' . _IM_ERASE_CONFIRM . '</h3>' . "\n";
730+ echo '<div class="filedetail">' . "\n";
731+ echo '<dl>' . "\n";
732+ echo '<dt>' . _IM_FILENAME . '</dt>' . "\n";
733+ echo '<dd>' . self::getFilename() . '</dd>' . "\n";
734+
735+ if(self::getSubdir()) {
736+ echo '<dt>' . _IM_SUBDIR . "</dt>\n";
737+ echo '<dd>' . self::getSubdir() . "</dd>\n";
738+ }
739+
740+ echo '<dt>' . _IM_COLLECTION . '</dt>' . "\n";
741+ echo '<dd>' . $collections[self::getCollection()] . '</dd>' . "\n";
742+
743+ if(self::getBlogName() && self::getEachblogdir()) {
744+ echo '<dt>' . _IM_WEBLOG_LABEL . "</dt>\n";
745+ echo '<dd>' . self::getBlogName() . "</dd>\n";
746+ }
747+
748+ echo '<dt>' . _IM_DIMENSIONS . '</dt>' . "\n";
749+ echo '<dd>' . $filesize . 'KB' . '</dd>' . "\n";
750+ echo '</dl>' . "\n";
751+ echo '</div>' . "\n";
752+ echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
753+ echo '<p class="left">' . "\n";
754+ echo '<input type="hidden" name="mode" value="erase" />' . "\n";
755+ echo $manager->addTicketHidden() . "\n";
756+ echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
757+ echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
758+ echo '<input type="hidden" name="filename" value="' . self::getFilename() . '" />' . "\n";
759+ echo '<input type="hidden" name="filter" value="'. self::getFilter() . '" />' . "\n";
760+ echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
761+ echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
762+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
763+ echo '<input type="submit" value="' . _IM_ERASE_DONE . '" />' . "\n";
764+ echo '</p>' . "\n";
765+ echo '</form>' . "\n";
766+ echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
767+ echo '<p class="right">' . "\n";
768+ echo $manager->addTicketHidden() . "\n";
769+ echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
770+ echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
771+ echo '<input type="hidden" name="filter" value="'. self::getFilter() . '" />' . "\n";
772+ echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
773+ echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
774+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
775+ echo '<input type="submit" name="button" value="' . _IM_RETURN . '" />' . "\n";
776+ echo '</p>' . "\n";
777+ echo '</form>' . "\n";
778+
779+ self::media_foot();
780+ return;
781+ }
782+
783+ private function media_rename_confirm($notice = '') {
784+ global $manager, $member;
785+
786+ $collections = self::getCollections();
787+
788+ self::media_head();
789+ echo '<h2>' . _IM_HEADER_ERASE_CONFIRM . "</h2>\n";
790+
791+ if($notice) {
792+ echo '<h3>' . _IM_NOTICE . "</h3>\n";
793+ echo '<p class="notice">' . $notice . "</p>\n";
794+ }
795+
796+ if(!self::getSubdir()) $combinedcollection = self::getCollection();
797+ else $combinedcollection = self::getCollection() . '/' . self::getSubdir();
798+
799+ list($update, $onlyfilename, $onlyprefix) = self::getSplitFilename($combinedcollection, self::getFilename());
800+
801+ echo '<h3>' . _IM_RENAME_FILENAME . '</h3>' . "\n";
802+ echo '<div class="filedetail">'."\n";
803+ echo "<dl>\n";
804+ echo '<dt>' . _IM_FILENAME . '</dt>' . "\n";
805+ echo '<dd>' . $onlyfilename . '</dd>' . "\n";
806+ echo '<dt>' . _IM_TYPE . '</dt>' . "\n";
807+ echo '<dd>' . $onlyprefix . '</dd>' . "\n";
808+
809+ if(self::getSubdir()) {
810+ echo '<dt>' . _IM_SUBDIR . "</dt>\n";
811+ echo '<dd>' . self::getSubdir() . "</dd>\n";
812+ }
813+
814+ echo '<dt>' . _IM_COLLECTION . '</dt>' . "\n";
815+ echo '<dd>' . $collections[self::getCollection()] . '</dd>' . "\n";
816+
817+ if(self::getBlogName() && self::getEachblogdir()) {
818+ echo '<dt>' . _IM_WEBLOG_LABEL . "</dt>\n";
819+ echo '<dd>' . self::getBlogName() . "</dd>\n";
820+ }
821+
822+ if(self::getMediaprefix())
823+ echo '<dt>'. _IM_UPDATE . "</dt>\n";
824+ else
825+ echo '<dt>'. _MEDIA_MODIFIED . "</dt>\n";
826+
827+ echo '<dd>' . $update . '</dd>' . "\n";
828+ echo '</dl>' . "\n";
829+ echo '</div>' . "\n";
830+ echo '<h3>' ._IM_RENAME_AFTER . '</h3>' . "\n";
831+ echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
832+ echo '<p>' ._IM_RENAME_DESCRIPTION . '</p>' . "\n";
833+ echo '<p>' . "\n";
834+
835+ if(self::getNewfilename())
836+ echo '<input type="text" name="newfilename" value="' . self::getNewfilename() . '" size="40" />' . "\n";
837+ else
838+ echo '<input type="text" name="newfilename" value="' . $onlyfilename . '" size="40" />' . "\n";
839+
840+ echo '</p>' . "\n";
841+ echo '<p class="left">' . "\n";
842+ echo '<input type="hidden" name="mode" value="rename" />' . "\n";
843+ echo $manager->addTicketHidden() . "\n";
844+ echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
845+ echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
846+ echo '<input type="hidden" name="filename" value="' . self::getFilename() . '" />' . "\n";
847+ echo '<input type="hidden" name="filter" value="' . self::getFilter() . '" />' . "\n";
848+ echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
849+ echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
850+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
851+ echo '<input type="submit" value="' . _IM_RENAME . '" />' . "\n";
852+ echo '</p>' . "\n";
853+ echo '</form>' . "\n";
854+
855+ echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
856+ echo '<p class="right">' . "\n";
857+ echo $manager->addTicketHidden() . "\n";
858+ echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
859+ echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
860+ echo '<input type="hidden" name="filter" value="' . self::getFilter() . '" />' . "\n";
861+ echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
862+ echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
863+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
864+ echo '<input type="submit" name="button" value="' . _IM_RETURN . '" />' . "\n";
865+ echo '</p>' . "\n";
866+ echo '</form>' . "\n";
867+
868+ self::media_foot();
869+ return;
870+ }
871+
872+ private function media_upload_select() {
873+ global $CONF, $manager, $member;
874+
875+ if(!$CONF['AllowUpload']) {
876+ self::media_doError(_ERROR_DISALLOWED);
877+ return;
878+ }
879+
880+ $collections = self::getCollections();
881+ $subdirs = self::getSubdirs();
882+
883+ if($subdirs)
884+ array_shift($subdirs);
885+
886+ self::media_head();
887+ echo '<h2>' . _IM_HEADER_UPLOAD_SELECT . "</h2>\n";
888+ echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
889+
890+ if(self::getBlogName() && self::getEachblogdir()) {
891+ echo '<h3>' . _IM_WEBLOG_LABEL . "</h3>\n";
892+ echo '<p>' . self::getBlogName() . "</p>\n";
893+ }
894+
895+ echo '<h3><label for="upload_collection">' . _IM_COLLECTION . "</label></h3>\n";
896+ echo "<p>\n";
897+
898+ if(count($collections) > 1) {
899+ echo _IM_COLLECTION_DESC . "<br />\n";
900+ echo '<select name="collection" id="upload_collection">' . "\n";
901+ foreach($collections as $dirname => $description) {
902+ if((string)$dirname == (string)self::getCollection())
903+ echo '<option value="' . $dirname . '" selected="selected">' . $description . "</option>\n";
904+ else
905+ echo '<option value="' . $dirname . '">' . $description . "</option>\n";
906+ }
907+ echo '</select>' . "\n";
908+ echo '<input type="submit" name="button" value="' . _IM_COLLECTION_SELECT . '" title="' . _IM_COLLECTION_TT . '" class="formbutton" />' . "\n";
909+ } else {
910+ echo _IM_COLLECTION . ': ' . $collections[self::getCollection()] . '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
911+ }
912+ echo '<input type="hidden" name="mode" value="upload_select" />' . "\n";
913+ echo $manager->addTicketHidden() . "\n";
914+ echo '<input type="hidden" name="subdir" value="" />' . "\n";
915+ echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
916+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
917+ echo '</p>' . "\n";
918+ echo '</form>' . "\n";
919+
920+ echo '<form mode="' . self::getAccessURL() . '" method="post" enctype="multipart/form-data">' . "\n";
921+ echo '<h3><label for="media_subdir">' . _IM_SUBDIR . "</label></h3>\n";
922+ echo "<p>\n";
923+
924+ if(count($subdirs) > 0) {
925+ echo _IM_SUBDIR_DESC . '<br />';
926+ echo '<select name="subdir" id="media_subdir">' . "\n";
927+ if(self::getSubdir() == '')
928+ echo '<option value="" selected="selected">' . _IM_SUBDIR_NONE . "</option>\n";
929+ else
930+ echo '<option value="">' . _IM_SUBDIR_NONE . "</option>\n";
931+ foreach($subdirs as $key => $options) {
932+ if($options['subdirname'] == self::getSubdir())
933+ echo '<option value="' . $options['subdirname'] . '" selected="selected">' . $options['subdirname'] . "</option>\n";
934+ else
935+ echo '<option value="' . $options['subdirname'] . '">' . $options['subdirname'] . "</option>\n";
936+ }
937+ echo '</select>' . "\n";
938+ } elseif(self::getSubdir() == '') {
939+ echo _IM_SUBDIR_LABEL . _IM_SUBDIR_NONE . '<input type="hidden" name="subdir" value="" />' . "\n";
940+ }
941+ echo "</p>\n";
942+
943+ echo '<h3>' . _IM_UPLOAD_USED_FILETYPE . "</h3>\n";
944+ echo '<p>' . implode(', ', self::getAllowedtypes() ) . "</p>\n";
945+ echo '<h3><label for="uploadfile">' . _UPLOAD_TITLE . "</label></h3>\n";
946+ echo '<p><input type="file" name="uploadfile" id="uploadfile" size="30" />' . "</p>\n";
947+ echo '<h3>' . _IM_UPLOAD_USED_ASCII . "</h3>\n";
948+ echo '<p>' . _IM_UPLOAD_USED_ASCII_DESC1 . "</p>\n";
949+ echo '<p>' . _IM_UPLOAD_USED_ASCII_DESC2 . "</p>\n";
950+ echo '<p class="left">' . "\n";
951+ echo '<input type="hidden" name="mode" value="upload" />' . "\n";
952+ echo $manager->addTicketHidden() . "\n";
953+ echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
954+ echo '<input type="hidden" name="MAX_FILE_SIZE" value="' . self::getMaxuploadsize() . ' " />' . "\n";
955+ echo '<input type="hidden" name="filter" value="' . self::getFilter() . '" />' . "\n";
956+ echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
957+ echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
958+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
959+ echo '<input type="submit" value="' . _UPLOAD_BUTTON . '" />' . "\n";
960+ echo '</p>' . "\n";
961+ echo '</form>' . "\n";
962+ echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
963+ echo '<p class="right">' . "\n";
964+ echo $manager->addTicketHidden . "\n";
965+ echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
966+ echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
967+ echo '<input type="hidden" name="filter" value="' . self::getFilter() . '" />' . "\n";
968+ echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
969+ echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
970+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
971+ echo '<input type="submit" name="button" value="' . _IM_RETURN . '" />' . "\n";
972+ echo '</p>' . "\n";
973+ echo '</form>' . "\n";
974+
975+ self::media_foot();
976+ return;
977+ }
978+
979+ private function media_embed_confirm($notice = '') {
980+ global $manager, $member;
981+
982+ $collections = self::getCollections();
983+
984+ if(!self::getSubdir()) $combinedcollection = self::getCollection();
985+ else $combinedcollection = self::getCollection() . '/' . self::getSubdir();
986+
987+ list($width, $height, $filetype, $filesize) = self::getFileData($combinedcollection, self::getFilename());
988+
989+ self::media_head();
990+ echo '<h2>' . _IM_HEADER_EMBED_CONFIRM . "</h2>\n";
991+
992+ if($notice) {
993+ echo '<h3>' . _IM_NOTICE . "</h3>\n";
994+ echo '<p class="notice">' . $notice . "</p>\n";
995+ }
996+
997+ echo '<h3>'. _IM_INCLUDE_FILE_SELECTED . '</h3>' . "\n";
998+ echo '<div class="filedetail">' . "\n";
999+ echo '<dl>' . "\n";
1000+ echo '<dt>' . _IM_FILENAME . '</dt>' . "\n";
1001+ echo '<dd>' . self::getFilename() . '</dd>' . "\n";
1002+
1003+ if(self::getSubdir()) {
1004+ echo '<dt>' . _IM_SUBDIR . "</dt>\n";
1005+ echo '<dd>' . self::getSubdir() . "</dd>\n";
1006+ }
1007+
1008+ echo '<dt>' . _IM_COLLECTION . '</dt>' . "\n";
1009+ echo '<dd>' . $collections[self::getCollection()] . '</dd>' . "\n";
1010+
1011+ if(self::getBlogName() && self::getEachblogdir()) {
1012+ echo '<dt>' . _IM_WEBLOG_LABEL . "</dt>\n";
1013+ echo '<dd>' . self::getBlogName() . "</dd>\n";
1014+ }
1015+
1016+ echo '<dt>' . _IM_DIMENSIONS . '</dt>' . "\n";
1017+
1018+ if($filetype !== 0)
1019+ echo '<dd>' . $width . ' x ' . $height . ' (' . $filesize . 'KB)</dd>' . "\n";
1020+ else
1021+ echo '<dd>' . $filesize . 'KB' . '</dd>' . "\n";
1022+
1023+ echo '</dl>' . "\n";
1024+ echo '</div>' . "\n";
1025+ echo '<h3>'. _IM_INCLUDE_ALT . '</h3>' . "\n";
1026+ echo '<p><label for="alt">'. _IM_INCLUDE_ALT_DESC . "</label></p>\n";
1027+ echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
1028+ echo '<p>' . "\n";
1029+ echo '<input type="text" name="alttext" value="'. self::getAlttext() . '" size="40" id="alt" />' . "\n";
1030+ echo '</p>'. "\n";
1031+ echo '<h3>'. _IM_INCLUDE_WAY . "</h3>\n";
1032+
1033+ if($filetype !== 0) {
1034+ echo '<p>'. "\n";
1035+ if(self::getWay() == 'inline') {
1036+ echo '<input type="radio" name="way" value="popup" id="popup" />'. "\n";
1037+ echo '<label for="popup">'. _IM_INCLUDE_WAY_POPUP . '</label><br />'. "\n";
1038+ echo '<input type="radio" name="way" value="inline" id="inline" checked="checked" />'. "\n";
1039+ echo '<label for="inline">'. _IM_INCLUDE_WAY_INLINE . '</label>'. "\n";
1040+ } else {
1041+ echo '<input type="radio" name="way" value="popup" id="popup" checked="checked" />'. "\n";
1042+ echo '<label for="popup">'. _IM_INCLUDE_WAY_POPUP . '</label><br />'. "\n";
1043+ echo '<input type="radio" name="way" value="inline" id="inline" />'. "\n";
1044+ echo '<label for="inline">'. _IM_INCLUDE_WAY_INLINE . '</label>'. "\n";
1045+ }
1046+ echo '</p>'. "\n";
1047+ } else {
1048+ echo '<p>'. _IM_INCLUDE_WAY_OTHER . "\n";
1049+ echo '<input type="hidden" name="way" value="other" /></p>'. "\n";
1050+ }
1051+
1052+ echo '<p class="left">'. "\n";
1053+ echo '<input type="hidden" name="mode" value="embed" />' . "\n";
1054+ echo $manager->addTicketHidden() . "\n";
1055+ echo '<input type="hidden" name="collection" value="'. self::getCollection() . '" />' . "\n";
1056+ echo '<input type="hidden" name="subdir" value="'. self::getSubdir() . '" />' . "\n";
1057+ echo '<input type="hidden" name="filename" value="'. self::getFilename() . '" />' . "\n";
1058+ echo '<input type="hidden" name="filter" value="' . self::getFilter() . '" />' . "\n";
1059+ echo '<input type="hidden" name="offset" value="'. self::getOffset() . '" />' . "\n";
1060+ echo '<input type="hidden" name="astool" value="'. self::getAstool() . '" />'. "\n";
1061+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
1062+ echo '<input type="submit" value="'. _IM_INCLUDE_WAY_DECIDE . '" />'. "\n";
1063+ echo '</p>'. "\n";
1064+ echo '</form>'. "\n";
1065+ echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">'. "\n";
1066+ echo '<p class="right">'. "\n";
1067+ echo $manager->addTicketHidden() . "\n";
1068+ echo '<input type="hidden" name="collection" value="'. self::getCollection() . '" />'. "\n";
1069+ echo '<input type="hidden" name="subdir" value="'. self::getSubdir() . '" />' . "\n";
1070+ echo '<input type="hidden" name="filter" value="' . self::getFilter() . '" />' . "\n";
1071+ echo '<input type="hidden" name="offset" value="'. self::getOffset() . '" />'. "\n";
1072+ echo '<input type="hidden" name="astool" value="'. self::getAstool() . '" />'. "\n";
1073+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
1074+ echo '<input type="submit" name="button" value="'. _IM_RETURN . '" />'. "\n";
1075+ echo '</p>'. "\n";
1076+ echo '</form>'. "\n";
1077+
1078+ self::media_foot();
1079+ return;
1080+ }
1081+
1082+ private function media_directory_remove_confirm($notice = '') {
1083+ global $manager, $member;
1084+
1085+ $collections = self::getCollections();
1086+ $subdirs = self::getSubdirs();
1087+
1088+ self::media_head();
1089+ echo '<h2>' . _IM_HEADER_SUBDIR_REMOVE_CONFIRM . "</h2>\n";
1090+
1091+ if($notice) {
1092+ echo '<h3>' . _IM_NOTICE . "</h3>\n";
1093+ echo '<p class="notice">' . $notice . "</p>\n";
1094+ }
1095+
1096+ echo '<h3>' . _IM_REMOVE_SUBIDR . "</h3>\n";
1097+ echo '<div class="filedetail">'."\n";
1098+ echo "<dl>\n";
1099+ echo '<dt>' . _IM_SUBDIR . "</dt>\n";
1100+ echo '<dd>' . self::getSubdir() . '</dd>' . "\n";
1101+ echo '<dt>' . _IM_SUBDIR_NUM_FILES . "</dt>\n";
1102+
1103+ foreach($subdirs as $key => $options) {
1104+ if($options['subdirname'] == self::getSubdir())
1105+ echo '<dd>' . $options['number'] . "</dd>\n";
1106+ }
1107+
1108+ echo '<dt>' . _IM_COLLECTION . "</dt>\n";
1109+ echo '<dd>' . $collections[self::getCollection()] . '</dd>' . "\n";
1110+
1111+ if(self::getBlogName() && self::getEachblogdir()) {
1112+ echo '<dt>' . _IM_WEBLOG_LABEL . "</dt>\n";
1113+ echo '<dd>' . self::getBlogName() . "</dd>\n";
1114+ }
1115+
1116+ echo "</dl>\n";
1117+ echo "</div>\n";
1118+
1119+ echo '<h3>' . _IM_REMOVE_SUBIDR_CONFIRM . "</h3>\n";
1120+ echo '<p>' . _IM_REMOVE_SUBIDR_REMIND . "</p>\n";
1121+
1122+ echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
1123+ echo '<p class="left">' . "\n";
1124+ echo '<input type="hidden" name="mode" value="directory_remove" />' . "\n";
1125+ echo $manager->addTicketHidden() . "\n";
1126+ echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
1127+ echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
1128+ echo '<input type="hidden" name="filename" value="' . self::getFilename() . '" />' . "\n";
1129+ echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
1130+ echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
1131+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
1132+ echo '<input type="submit" value="' . _IM_ERASE_DONE . '" />' . "\n";
1133+ echo '</p>' . "\n";
1134+ echo '</form>' . "\n";
1135+ echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
1136+ echo '<p class="right">' . "\n";
1137+ echo $manager->addTicketHidden() . "\n";
1138+ echo '<input type="hidden" name="mode" value="directory_display" />' . "\n";
1139+ echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
1140+ echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
1141+ echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
1142+ echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
1143+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
1144+ echo '<input type="submit" name="button" value="' . _IM_RETURN . '" />' . "\n";
1145+ echo '</p>' . "\n";
1146+ echo '</form>' . "\n";
1147+
1148+ self::media_foot();
1149+ return;
1150+ }
1151+
1152+ private function media_directory_remove() {
1153+ global $manager;
1154+
1155+ if(self::getSubdir() == '') {
1156+ self::media_doError(_IM_SUBDIR_FAILED_READ . ' (' . self::getCollection() . '/' . self::getSubdir() . ')');
1157+ return;
1158+ }
1159+
1160+ $manager->notify('PreSubdirRemove', array('collection' => self::getCollection(), 'subdir' => self::getSubdir()));
1161+
1162+ $log = self::removeSubdir(self::getCollection(), self::getSubdir());
1163+
1164+ if($log) {
1165+ self::media_doError($log);
1166+ return;
1167+ }
1168+
1169+ $manager->notify('PostSubdirRemove',array('collection' => self::getCollection(), 'subdir' => self::getSubdir()));
1170+
1171+ self::resetOffset();
1172+ self::media_directory_display();
1173+ return;
1174+ }
1175+
1176+ private function media_directory_create_confirm($notice = '') {
1177+ global $manager;
1178+
1179+ $collections = self::getCollections();
1180+
1181+ self::media_head();
1182+ echo '<h2>' . _IM_HEADER_SUBDIR_CREATE_CONFIRM . "</h2>\n";
1183+
1184+ if($notice) {
1185+ echo '<h3>' . _IM_NOTICE . "</h3>\n";
1186+ echo '<p class="notice">' . $notice . "</p>\n";
1187+ }
1188+
1189+ if(self::getBlogName() && self::getEachblogdir()) {
1190+ echo '<h3>' . _IM_WEBLOG_LABEL . "</h3>\n";
1191+ echo '<p>' . self::getBlogName() . "</p>\n";
1192+ }
1193+
1194+ echo "<h3>" . _IM_CREATE_SUBDIR_COLLECTION_LABEL . "</h3>\n";
1195+
1196+ echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
1197+ echo "<p>\n";
1198+ echo '<label for="media_collection">' . _IM_CREATE_SUBDIR_COLLECTION . "</label><br />\n";
1199+ echo '<select name="collection" id="media_collection">' . "\n";
1200+ foreach ($collections as $dirname => $description){
1201+ if((string)$dirname == (string)self::getCollection())
1202+ echo '<option value="' . $dirname . '" selected="selected">' . $description . "</option>\n";
1203+ else
1204+ echo '<option value="' . $dirname . '">' . $description . "</option>\n";
1205+ }
1206+ echo '</select>' . "\n";
1207+ echo "</p>\n";
1208+
1209+ echo '<h3>' . _IM_CREATE_SUBDIR_INPUT_NAME . "</h3>\n";
1210+ echo "<p>" . _IM_CREATE_SUBDIR_CHARS_DESC . "</p>\n";
1211+ echo '<p>' . "\n";
1212+ echo $manager->addTicketHidden() . "\n";
1213+ if(self::getNewfilename() != '')
1214+ echo '<input type="text" name="newfilename" value="' . self::getNewfilename() . '" size="20" />' . "\n";
1215+ else
1216+ echo '<input type="text" name="newfilename" value="" size="20" />' . "\n";
1217+ echo '</p>' . "\n";
1218+ echo '<p class="left">' . "\n";
1219+ echo '<input type="hidden" name="mode" value="directory_create" />' . "\n";
1220+ echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
1221+ echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
1222+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
1223+ echo '<input type="submit" value="' . _IM_CREATE_SUBDIR_CONFIRM . '" />' . "\n";
1224+ echo '</p>' . "\n";
1225+ echo '</form>' . "\n";
1226+
1227+ echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
1228+ echo '<p class="right">' . "\n";
1229+ echo '<input type="hidden" name="mode" value="directory_display" />' . "\n";
1230+ echo $manager->addTicketHidden() . "\n";
1231+ echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
1232+ echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
1233+ echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
1234+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
1235+ echo '<input type="submit" name="button" value="' . _IM_RETURN . '" />' . "\n";
1236+ echo '</p>' . "\n";
1237+ echo '</form>' . "\n";
1238+
1239+ self::media_foot();
1240+ return;
1241+ }
1242+
1243+ private function media_directory_create() {
1244+ global $manager;
1245+ $newdirname = self::getNewfilename();
1246+
1247+ if($newdirname == '') {
1248+ self::media_directory_create_confirm(_IM_RENAME_SUBDIR_BLANK);
1249+ return;
1250+ } elseif(mb_strlen($newdirname,_CHARSET) > 20) {
1251+ self::media_directory_create_confirm(_IM_RENAME_SUBDIR_TOOLONG);
1252+ return;
1253+ } elseif(!preg_match('#^[a-zA-Z0-9 \_\-\+]+$#', $newdirname)) {
1254+ self::media_directory_create_confirm(_IM_RENAME_SUBDIR_WRONG);
1255+ return;
1256+ } elseif(stristr($newdirname, '%00')) {
1257+ self::media_doError(_IM_RENAME_FORBIDDEN);
1258+ return;
1259+ } elseif(is_dir(self::getDirMedia() . self::getCollection() . '/' . $newdirname)) {
1260+ self::media_directory_create_confirm(_IM_RENAME_SUBDIR_DUPLICATE);
1261+ return;
1262+ } elseif(!@is_dir(self::getDirMedia() . self::getCollection()) && is_numeric(self::getCollection())) {
1263+ $oldumask = umask(0000);
1264+ if(!@mkdir(self::getDirMedia() . self::getCollection(), 0777)) {
1265+ self::media_doError(_ERROR_BADPERMISSIONS);
1266+ return;
1267+ }
1268+ umask($oldumask);
1269+ }
1270+
1271+ $manager->notify('PreSubdirCreate',array('collection' => self::getCollection(), 'subdir' => $newdirname));
1272+
1273+ $oldumask = umask(0000);
1274+ if(!@mkdir(self::getDirMedia() . self::getCollection() . '/' . $newdirname))
1275+ self::media_directory_create_confirm(_IM_CREATE_SUBDIR_WRONG . '(' . $collection . '/' . $newdirname . ')');
1276+ umask($oldumask);
1277+ @chmod(self::getDirMedia() . self::getCollection() . '/' . $newdirname, 0777);
1278+
1279+ $manager->notify('PostSubdirCreate',array('collection' => self::getCollection(), 'subdir' => $newdirname));
1280+
1281+ self::resetOffset();
1282+ self::media_directory_display();
1283+ return;
1284+ }
1285+
1286+ private function media_directory_rename_confirm($notice = '') {
1287+ global $manager, $member;
1288+
1289+ $collections = self::getCollections();
1290+ $newdirname = self::getNewfilename();
1291+ $subdirs = self::getSubdirs();
1292+
1293+ self::media_head();
1294+ echo '<h2>' . _IM_HEADER_SUBDIR_RENAME_CONFIRM . "</h2>\n";
1295+
1296+ if($notice) {
1297+ echo '<h3>' . _IM_NOTICE . "</h3>\n";
1298+ echo '<p class="notice">' . $notice . "</p>\n";
1299+ }
1300+
1301+ echo '<h3>' . _IM_RENAME_SUBDIR_COLLECTION . "</h3>\n";
1302+ echo '<div class="filedetail">'."\n";
1303+ echo "<dl>\n";
1304+ echo '<dt>' . _IM_SUBDIR . "</dt>\n";
1305+ echo '<dd>' . self::getSubdir() . '</dd>' . "\n";
1306+ echo '<dt>' . _IM_SUBDIR_NUM_FILES . "</dt>\n";
1307+
1308+ foreach($subdirs as $key => $options) {
1309+ if($options['subdirname'] == self::getSubdir())
1310+ echo '<dd>' . $options['number'] . "</dd>\n";
1311+ }
1312+
1313+ echo '<dt>' . _IM_COLLECTION . "</dt>\n";
1314+ echo '<dd>' . $collections[self::getCollection()] . '</dd>' . "\n";
1315+
1316+ if(self::getBlogName() && self::getEachblogdir()) {
1317+ echo '<dt>' . _IM_WEBLOG_LABEL . "</dt>\n";
1318+ echo '<dd>' . self::getBlogName() . "</dd>\n";
1319+ }
1320+
1321+ echo '</dl>' . "\n";
1322+ echo '</div>' . "\n";
1323+ echo '<h3>' ._IM_RENAME_AFTER . '</h3>' . "\n";
1324+ echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
1325+ echo '<p>' ._IM_RENAME_DESCRIPTION . '</p>' . "\n";
1326+ echo '<p>' . "\n";
1327+ if($newdirname != '')
1328+ echo '<input type="text" name="newfilename" value="' . $newdirname . '" size="40" />' . "\n";
1329+ else
1330+ echo '<input type="text" name="newfilename" value="' . self::getSubdir() . '" size="40" />' . "\n";
1331+ echo '</p>' . "\n";
1332+
1333+ echo '<p class="left">' . "\n";
1334+ echo '<input type="hidden" name="mode" value="directory_rename" />' . "\n";
1335+ echo $manager->addTicketHidden() . "\n";
1336+ echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
1337+ echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
1338+ echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
1339+ echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
1340+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
1341+ echo '<input type="submit" value="' . _IM_RENAME . '" class="formbutton" />' . "\n";
1342+ echo '</p>' . "\n";
1343+ echo '</form>' . "\n";
1344+
1345+ echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
1346+ echo '<p class="right">' . "\n";
1347+ echo $manager->addTicketHidden() . "\n";
1348+ echo '<input type="hidden" name="mode" value="directory_display" />' . "\n";
1349+ echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
1350+ echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
1351+ echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
1352+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
1353+ echo '<input type="submit" name="button" value="' . _IM_RETURN . '" />' . "\n";
1354+ echo '</p>' . "\n";
1355+ echo '</form>' . "\n";
1356+
1357+ self::media_foot();
1358+ return;
1359+ }
1360+
1361+ private function media_directory_rename() {
1362+ global $manager;
1363+
1364+ $newdirname = self::getNewfilename();
1365+
1366+ if(self::getSubdir() == '') {
1367+ self::media_doError(_IM_SUBDIR_FAILED_READ);
1368+ }
1369+
1370+ if($newdirname == '') {
1371+ self::media_directory_rename_confirm(_IM_RENAME_SUBDIR_BLANK);
1372+ return;
1373+ } elseif(mb_strlen($newdirname,_CHARSET) > 20) {
1374+ self::media_directory_rename_confirm(_IM_RENAME_SUBDIR_TOOLONG);
1375+ return;
1376+ } elseif(!preg_match('#^[a-zA-Z0-9 \_\-\+]+$#',$newdirname)) {
1377+ self::media_directory_rename_confirm(_IM_RENAME_SUBDIR_WRONG);
1378+ return;
1379+ } elseif(stristr($newdirname, '%00')) {
1380+ self::media_doError(_IM_RENAME_FORBIDDEN);
1381+ return;
1382+ } elseif(!is_dir(self::getDirMedia() . self::getCollection() . '/' . self::getSubdir())) {
1383+ self::media_doError(_IM_MISSING_DIRECTORY);
1384+ return;
1385+ } elseif(is_dir(self::getDirMedia() . self::getCollection() . '/' . $newdirname)) {
1386+ self::media_directory_rename_confirm(_IM_RENAME_SUBDIR_DUPLICATE);
1387+ return;
1388+ }
1389+
1390+ $manager->notify('PreSubdirRename',array('collection' => self::getCollection(), 'olddirname' => self::getSubdir(), 'newdirname' => $newdirname));
1391+
1392+ if(!@rename(self::getDirMedia() . self::getCollection() . '/' . self::getSubdir(), self::getDirMedia() . self::getCollection() . '/' . $newdirname)) {
1393+ self::media_doError(_IM_RENAME_FAILED . ': ' . $collection . '/' . self::getSubdir() . '/' . $filename);
1394+ return;
1395+ }
1396+
1397+ $manager->notify('PostSubdirRename',array('collection' => self::getCollection(), 'olddirname' => self::getSubdir(), 'newdirname' => $newdirname));
1398+
1399+ self::resetOffset();
1400+ self::media_directory_display();
1401+ return;
1402+ }
1403+
1404+ private function media_directory_display() {
1405+ global $manager, $member;
1406+
1407+ $collections = self::getCollections();
1408+ $subdirs = self::getSubdirs();
1409+ $fileamount = count($subdirs) -1;
1410+
1411+ self::media_head();
1412+
1413+ echo '<form method="post" action="' . self::getAccessURL() . '" enctype="application/x-www-form-urlencoded">' . "\n";
1414+ echo '<p>' . "\n";
1415+
1416+ echo '<label for="media_collection">' . _IM_COLLECTION_LABEL . '</label>' . "\n";
1417+ echo '<select name="collection" id="media_collection">' . "\n";
1418+ foreach ($collections as $dirname => $description){
1419+ if ((string)$dirname == (string)self::getCollection())
1420+ echo '<option value="' . $dirname . '" selected="selected">' . $description . "</option>\n";
1421+ else
1422+ echo '<option value="' . $dirname . '">' . $description . "</option>\n";
1423+ }
1424+ echo '</select>' . "\n";
1425+ echo '<input type="submit" name="mode" value="' . _IM_DISPLAY_SUBDIR_SELECT . '" class="formbutton" />' . "\n";
1426+ echo '<input type="submit" name="mode" value="' . _IM_CREATE_SUBDIR_CONFIRM . '" class="formbutton" />' . "\n";
1427+ echo $manager->addTicketHidden() . "\n";
1428+ echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
1429+ echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
1430+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
1431+ echo '</p>' . "\n";
1432+ echo '</form>' . "\n";
1433+
1434+ echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
1435+ echo '<p>' . _IM_DISPLAY_SUBDIR_LABEL1 . $fileamount . _IM_DISPLAY_SUBDIR_LABEL2 . $subdirs[0]['number'] . "\n";
1436+ echo $manager->addTicketHidden() . "\n";
1437+ echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
1438+ echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
1439+ echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
1440+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
1441+ echo '<input type="submit" name="button" value="' . _IM_DISPLAY_SUBDIR_RETURN . '" class="formbutton" />' . "\n";
1442+ echo '</p>' . "\n";
1443+ echo '</form>' . "\n";
1444+
1445+ echo "<hr />\n";
1446+
1447+
1448+ if($fileamount > 0) {
1449+ $idxStart = ceil(self::getOffset() / self::getItemdisplay()) * self::getItemdisplay();
1450+ $idxEnd = $idxStart + self::getItemdisplay();
1451+ if($idxEnd > $fileamount)
1452+ $idxEnd = $fileamount;
1453+ $idxPrev = $idxStart - self::getItemdisplay();
1454+ if($idxPrev < 0)
1455+ $idxPrev =0;
1456+ $idxNext = $idxStart + self::getItemdisplay();
1457+
1458+ array_shift($subdirs);
1459+
1460+ echo '<table frame="void" rules="none" summary="Directory List" width="100%">' . "\n";
1461+ echo '<caption>' . _IM_DISPLAY_SUBDIR_CAPTION . ' &gt;&gt; ' . $collections[self::getCollection()];
1462+ if(self::getBlogShortName() && self::getEachblogdir())
1463+ echo ' &gt;&gt; ' . self::getBlogShortName();
1464+ echo "</caption>\n";
1465+ echo '<thead>' . "\n";
1466+ echo '<tr>' . "\n";
1467+ echo '<th>' . _IM_SUBDIR . "</th>\n";
1468+ echo '<th>' . _IM_SUBDIR_NUM_FILES . "</th>\n";
1469+ echo '<th colspan="3">' . _IM_ACTION . "</th>\n";
1470+ echo '</tr>' . "\n";
1471+ echo '</thead>' . "\n";
1472+ echo '<tfoot>' . "\n";
1473+ echo '<tr>' . "\n";
1474+ echo '<td colspan="2">' . "\n";
1475+ if ($idxStart > 0)
1476+ echo '<a href="' . self::getAccessURL() . '&amp;mode=directory_display&amp;collection=' . urlencode(self::getCollection()) . '&amp;offset=' . urlencode($idxPrev) . '&amp;astool=' . urlencode(self::getAstool()) . '&amp;blogid=' . urlencode(self::getBlogid()) . '">' . _LISTS_PREV . ' &lt;</a> ';
1477+ if(($idxStart + 1) != $idxEnd)
1478+ echo ($idxStart + 1) . ' to ' . $idxEnd . '&nbsp;';
1479+ if ($idxEnd < $fileamount )
1480+ echo '<a href="' . self::getAccessURL() . '&amp;mode=directory_display&amp;collection=' . urlencode(self::getCollection()) . '&amp;offset=' . urlencode($idxNext) . '&amp;astool=' . urlencode(self::getAstool()) . '&amp;blogid=' . urlencode(self::getBlogid()) . '">' . '&gt; ' . _LISTS_NEXT . '</a>';
1481+ echo "</td>\n";
1482+ echo '<td colspan="3" class="right">'. "\n";
1483+ if(self::getBlogName() && self::getEachblogdir())
1484+ echo _IM_WEBLOG_LABEL . ': ' . self::getBlogName();
1485+ echo "</td>\n";
1486+ echo "</tr>\n";
1487+ echo '</tfoot>' . "\n";
1488+ echo '<tbody>' . "\n";
1489+
1490+ for($i = $idxStart; $i < $idxEnd; $i++) {
1491+ $options = $subdirs[$i];
1492+ echo '<tr>' . "\n";
1493+ if($options['subdirname'] == ".")
1494+ echo '<td>' . _IM_SUBDIR_NONE . '</td>' . "\n";
1495+ else
1496+ echo '<td>' . $options['subdirname'] . '</td>' . "\n";
1497+ echo '<td>' . $options['number'] . '</td>' . "\n";
1498+ echo '<td>' . "\n";
1499+ echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
1500+ echo "<p>\n";
1501+ echo '<input type="hidden" name="mode" value="display" />' . "\n";
1502+ echo $manager->addTicketHidden() . "\n";
1503+ echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
1504+ echo '<input type="hidden" name="subdir" value="' . $options['subdirname'] . '" />' . "\n";
1505+ echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
1506+ echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
1507+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
1508+ echo '<input type="submit" name="button" value="' . _IM_DISPLAY_FILES . '" class="formbutton" />' . "\n";
1509+ echo "</p>\n";
1510+ echo '</form>' . "\n";
1511+ echo '</td>' . "\n";
1512+
1513+ if($options['subdirname'] == ".") {
1514+ echo "<td></td>\n";
1515+ echo "<td></td>\n";
1516+ echo "</tr>\n";
1517+ } else {
1518+ echo '<td>' . "\n";
1519+ echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
1520+ echo "<p>\n";
1521+ echo '<input type="hidden" name="mode" value="directory_remove_confirm" />' . "\n";
1522+ echo $manager->addTicketHidden() . "\n";
1523+ echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
1524+ echo '<input type="hidden" name="subdir" value="' . $options['subdirname'] . '" />' . "\n";
1525+ echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
1526+ echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
1527+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
1528+ echo '<input type="submit" name="button" value="' . _IM_SUBDIR_REMOVE . '" class="formbutton" />' . "\n";
1529+ echo "</p>\n";
1530+ echo '</form>' . "\n";
1531+ echo '</td>' . "\n";
1532+ echo '<td>' . "\n";
1533+ echo '<form action="' . self::getAccessURL() . '" method="post">' . "\n";
1534+ echo "<p>\n";
1535+ echo '<input type="hidden" name="mode" value="directory_rename_confirm" />' . "\n";
1536+ echo $manager->addTicketHidden() . "\n";
1537+ echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
1538+ echo '<input type="hidden" name="subdir" value="' . $options['subdirname'] . '" />' . "\n";
1539+ echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
1540+ echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
1541+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
1542+ echo '<input type="submit" name="button" value="' . _IM_RENAME . '" class="formbutton" />' . "\n";
1543+ echo "</p>\n";
1544+ echo '</form>' . "\n";
1545+ echo '</td>' . "\n";
1546+ echo '</tr>' . "\n";
1547+ }
1548+ }
1549+ echo '</tbody>' . "\n";
1550+ echo '</table>' . "\n";
1551+ } else {
1552+ if(self::getBlogShortName() && self::getEachblogdir())
1553+ echo "<p>" . _IM_DISPLAY_SUBDIR_NOTHING . ' &gt;&gt; ' . $collections[self::getCollection()] . ' &gt;&gt; ' . self::getBlogShortName() . "</p>\n";
1554+ else
1555+ echo "<p>" . _IM_DISPLAY_SUBDIR_NOTHING . ' &gt;&gt; ' . $collections[self::getCollection()] . "</p>\n";
1556+ }
1557+
1558+ self::media_foot();
1559+ return;
1560+ }
1561+
1562+ private function media_loginAndPassThrough() {
1563+ self::media_head();
1564+
1565+ echo '<h2>' . _LOGIN_PLEASE . "</h2>\n";
1566+ echo '<form method="post" action="' . self::getAccessURL() . '" enctype="application/x-www-form-urlencoded">' . "\n";
1567+ echo '<p>' . "\n";
1568+ echo _LOGINFORM_NAME . '<br />' . "\n";
1569+ echo '<input name="login" size="20" maxlength="40" value="" /><br />' . "\n";
1570+ echo _LOGINFORM_PWD . '<br />' . "\n";
1571+ echo '<input name="password" type="password" size="20" maxlength="40" /><br />' . "\n";
1572+ echo '<input type="checkbox" value="1" name="shared" id="nucleus_lf_shared" checked="checked" />' . "\n";
1573+ echo '<label for="nucleus_lf_shared">' . _LOGINFORM_SHARED . "</label>\n";
1574+ echo "</p>\n";
1575+ echo "<p>\n";
1576+ echo '<input name="mode" value="login" type="hidden" />' . "\n";
1577+ echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
1578+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
1579+ echo '<input type="submit" value="' . _LOGIN . '" />' . "\n";
1580+ echo "</p>\n";
1581+ echo "</form>\n";
1582+
1583+ self::media_foot();
1584+ return;
1585+ }
1586+
1587+ private function media_doError($message) {
1588+ global $manager;
1589+
1590+ self::media_head();
1591+
1592+ echo '<h2>' . _ERROR . "</h2>\n";
1593+ echo '<p>' . $message . "</p>\n";
1594+ echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
1595+ echo '<p class="right">' . "\n";
1596+ echo '<input type="hidden" name="mode" value="display" />' . "\n";
1597+ echo $manager->addTicketHidden() . "\n";
1598+ echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
1599+ echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
1600+ echo '<input type="submit" name="button" value="' . _IM_RETURN . '" />' . "\n";
1601+ echo '</p>' . "\n";
1602+ echo '</form>' . "\n";
1603+
1604+ self::media_foot();
1605+ return;
1606+ }
1607+
1608+ private function media_head() {
1609+ sendContentType('application/xhtml+xml', 'media');
1610+ echo '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . "\n";
1611+ echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n";
1612+ echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">' . "\n";
1613+ echo '<head>' . "\n";
1614+ echo '<title>Media Control' . _IM_HEADER_TEXT . '</title>' . "\n";
1615+ echo '<meta http-equiv="content-style-type" content="text/css" />' . "\n";
1616+ echo '<link rel="stylesheet" type="text/css" href="' . self::getPluginDir() . 'popups.css" />' . "\n";
1617+ echo '<meta http-equiv="content-script-type" content="text/javascript" />' . "\n";
1618+ echo '<script type="text/javascript">' . "\n";
1619+
1620+ if(self::getGreybox()) {
1621+ echo 'function chooseImage(collection, filename, type, width, height, text) {' . "\n";
1622+ echo ' top.window.focus();' . "\n";
1623+ echo ' top.window.includeImage(collection, filename, type, width, height, text);' . "\n";
1624+ echo ' top.window.GB_hide();' . "\n";
1625+ echo '}' . "\n";
1626+ echo 'function chooseOther(collection, filename, text) {' . "\n";
1627+ echo ' top.window.focus();' . "\n";
1628+ echo ' top.window.includeOtherMedia(collection, filename, text);' . "\n";
1629+ echo ' top.window.GB_hide();' . "\n";
1630+ echo '}' . "\n";
1631+ } else {
1632+ echo 'function chooseImage(collection, filename, type, width, height, text) {' . "\n";
1633+ echo ' top.opener.focus();' . "\n";
1634+ echo ' top.opener.includeImage(collection, filename, type, width, height, text);' . "\n";
1635+ echo ' window.close();' . "\n";
1636+ echo '}' . "\n";
1637+ echo 'function chooseOther(collection, filename, text) {' . "\n";
1638+ echo ' top.opener.focus();' . "\n";
1639+ echo ' top.opener.includeOtherMedia(collection, filename, text);' . "\n";
1640+ echo ' window.close();' . "\n";
1641+ echo '}' . "\n";
1642+ }
1643+
1644+ echo '</script>' . "\n";
1645+ echo '</head>' . "\n";
1646+ echo '<body>' . "\n";
1647+
1648+ if(!self::getGreybox()) {
1649+ echo '<h1>Media Control<span class="header">' . _IM_HEADER_TEXT . '</span></h1>' . "\n";
1650+ echo '<hr />' . "\n";
1651+ }
1652+ return;
1653+ }
1654+
1655+ private function media_foot() {
1656+ echo "</body>\n";
1657+ echo "</html>";
1658+ exit;
1659+ }
1660+
1661+ private function getSplitFilename(&$collection, &$filename) {
1662+ if(self::getMediaprefix()) {
1663+ if(preg_match('#^([0-9]{8})\-(.*)\.([a-zA-Z0-9]{2,})$#', $filename, $filealt) == 1 ) {
1664+ $update = preg_replace('#^([0-9]{4})([0-9]{2})([0-9]{2})$#', '$1/$2/$3', $filealt[1]);
1665+ $onlyfilename = $filealt[2];
1666+ $onlyprefix = $filealt[3];
1667+ } else {
1668+ preg_match('#^(.*)\.([a-zA-Z0-9]{2,})$#', $filename, $filealt);
1669+ $update = date("Y/m/d", @filemtime( self::getDirMedia() . $collection . '/' . $filename));
1670+ $onlyfilename = $filealt[1];
1671+ $onlyprefix = $filealt[2];
1672+ }
1673+ } else {
1674+ preg_match('#^(.*)\.([a-zA-Z0-9]{2,})$#', $filename, $filealt);
1675+ $update = date("Y/m/d", @filemtime( self::getDirMedia() . $collection . '/' . $filename));
1676+ $onlyfilename = $filealt[1];
1677+ $onlyprefix = $filealt[2];
1678+ }
1679+ return array((string)$update, (string)$onlyfilename, (string)$onlyprefix);
1680+ }
1681+
1682+ private function getFileData(&$collection, &$filename) {
1683+ $old_level = error_reporting(0);
1684+ $size = @GetImageSize(self::getDirMedia() . $collection . '/' .$filename);
1685+ error_reporting($old_level);
1686+ $width = $size[0];
1687+ $height = $size[1];
1688+ $filetype = $size[2];
1689+ $filesize = number_format(ceil((@filesize(self::getDirMedia() . $collection . '/' . $filename) / 1000)));
1690+
1691+ return array((int)$width, (int)$height, (int)$filetype, (int)$filesize);
1692+ }
1693+
1694+ private function sort_media_by_filename($a, $b) {
1695+ if($a->filename == $b->filename) return 0;
1696+ elseif($a->filename > $b->filename) return -1;
1697+ else return 1;
1698+ }
1699+
1700+ private function removeSubdir($collection, $subdir, $log = '') {
1701+ $dirname = self::getDirMedia() . $collection . '/' . $subdir;
1702+
1703+ if(!is_dir($dirname)) {
1704+ $log .= _IM_SUBDIR_FAILED_READ . ' (' . $collection . '/' . $subdir . ')<br />';
1705+ return $log;
1706+ }
1707+
1708+ if(($dir = @opendir($dirname)) == FALSE) {
1709+ $log .= _IM_SUBDIR_FAILED_READ . ' (' . $collection . '/' . $subdir . ')<br />';
1710+ return $log;
1711+ } else {
1712+ while(($file = readdir($dir)) !== false) {
1713+ if($file != "." && $file != "..") {
1714+ if(filetype($dirname . "/" . $file) == "dir")
1715+ $log .= self::removeSubdir($collection, $subdir . "/" . $file, $log);
1716+ else
1717+ if(@unlink($dirname . "/" . $file) == false)
1718+ $log .= _IM_SUBDIR_REMOVE_FAILED . ' (' . $collection . '/' . $subdir . '/' . $file . ")<br />";
1719+ }
1720+ }
1721+ }
1722+ closedir($dir);
1723+
1724+ if($log)
1725+ return $log;
1726+
1727+ if(@rmdir($dirname) == false) {
1728+ $log .= _IM_SUBDIR_REMOVE_FAILED . ' (' . $collection . '/' . $subdir . ')<br />';
1729+ return $log;
1730+ }
1731+ }
1732+}
1733+?>
--- /dev/null
+++ b/NP_ImprovedMedia/improvedmedia/MEDIA_VARIABLES.php
@@ -0,0 +1,447 @@
1+<?php
2+/**
3+ * ImprovedMedia plugin for Nucleus CMS
4+ * Version 3.0.1 for PHP5
5+ * Written By Mocchi, Feb.28, 2010
6+ *
7+ * This program is free software; you can redistribute it and/or
8+ * modify it under the terms of the GNU General Public License
9+ * as published by the Free Software Foundation; either version 3
10+ * of the License, or (at your option) any later version.
11+ */
12+
13+class MEDIA_VARIABLES {
14+ private $accessurl = 'media.php'; //string
15+ // privete
16+ private $plugindir = ''; //string
17+ private $private = 1; //boolean
18+ private $greybox = 0; //boolean
19+ private $itemdisplay = 10; //integer
20+ private $eachblogdir = 0; //boolean
21+
22+ private $allowedtypes = array(); //array
23+ private $mediaprefix = 0; //boolean
24+ private $maxuploadsize = 0; //integer
25+
26+ private $mediaurl = ''; //string
27+ private $dirmedia = ''; //string
28+
29+ private $blog = FALSE; //object
30+ private $blogid = 1; //object
31+
32+ private $mode = 'display'; //string
33+ private $alttext = ''; //string
34+ private $astool = 0; //boolean
35+ private $collection = ''; //string
36+ private $subdir = ''; //string
37+ private $filename= ''; //string
38+ private $newfilename = ''; //string
39+ private $offset = 0; //integer
40+ private $way = 'popup'; //string
41+ private $filter = ''; //string
42+
43+ private static $modes = array('rename_confirm', 'rename', 'erase_confirm', 'erase',
44+ 'upload_select', _IM_UPLOAD_NEW, 'upload', 'embed_confirm', 'embed',
45+ _IM_COLLECTION_SELECT, _IM_FILTER_APPLY, 'display', 'login',
46+ 'directory_remove_confirm', 'directory_remove', _IM_CREATE_SUBDIR_CONFIRM, 'directory_create',
47+ 'directory_rename_confirm', 'directory_rename',
48+ _IM_DISPLAY_SUBDIR, _IM_DISPLAY_SUBDIR_SELECT, 'directory_display');
49+ // protected
50+ protected static $modesNotToCheck
51+ = array('display', _IM_FILTER_APPLY, _IM_COLLECTION_SELECT, 'login', 'upload_select',
52+ _IM_DISPLAY_SUBDIR, _IM_DISPLAY_SUBDIR_SELECT, 'directory_display');
53+
54+ public function __construct(&$PluginObject) {
55+ global $CONF;
56+ $this->blog =& $PluginObject->getBlog();
57+ $this->blogid =& $PluginObject->getBlogid();
58+ $this->accessurl = $CONF['ActionURL'] . '?action=plugin&amp;name=ImprovedMedia';
59+ $this->plugindir = $CONF['AdminURL'] . $PluginObject->getBaseURL();
60+ self::setOptions($PluginObject);
61+
62+ self::setAllowedTypes();
63+ self::setMediaPrefix();
64+ self::setMaxUploadSize();
65+
66+ self::setMediaURL();
67+ self::setDIR_MEDIA();
68+
69+ return;
70+ }
71+
72+ public function __destruct() {return;}
73+
74+ protected function setMode() {
75+ $mode = htmlspecialchars(requestVar('mode'), ENT_QUOTES, _CHARSET);
76+ if(in_array($mode, self::$modes))
77+ $this->mode = (string)$mode;
78+ return;
79+ }
80+
81+ protected function setAlttext() {
82+ $alttext = htmlspecialchars(requestVar('alttext'), ENT_QUOTES, _CHARSET);
83+ trim($alttext);
84+ $this->alttext = (string)$alttext;
85+ return;
86+ }
87+
88+ protected function setAstool() {
89+ $astool = intRequestVar('astool');
90+ if($astool)
91+ $this->astool = (int)1;
92+ return;
93+ }
94+
95+ public function getCollections() {
96+ $collections = array();
97+ $collections = MEDIA::getCollectionList();
98+
99+ if(!$this->private) {
100+ if(count($collections) < 2)
101+ return (string)'error';
102+ else
103+ array_shift($collections);
104+ }
105+ ksort($collections, SORT_STRING);
106+ return (array)$collections;
107+ }
108+
109+ protected function setCollection() {
110+ global $member;
111+ $collection = htmlspecialchars(requestVar('collection'), ENT_QUOTES, _CHARSET);
112+ $collections = $this->getCollections();
113+
114+ if($collections == 'error') {
115+ $this->collection = (string)'error';
116+ return;
117+ }
118+
119+ if(!$this->private) {
120+ if($collection == '') {
121+ $keys = array_keys($collections);
122+ $this->collection = (string)$collections[$keys[0]];
123+ return;
124+ }
125+ if(!array_key_exists($collection, $collections)) {
126+ $this->collection = (string)'error';
127+ return;
128+ }
129+ $this->collection = (string)$collection;
130+ return;
131+ } else {
132+ if($collection == '') {
133+ $this->collection = (string)$member->getID();
134+ return;
135+ }
136+ if(!array_key_exists($collection, $collections)) {
137+ $this->collection = (string)'error';
138+ return;
139+ }
140+ $this->collection = (string)$collection;
141+ return;
142+ }
143+ }
144+
145+ public function getSubdirs() {
146+ $subdirs = array();
147+ $temp = array();
148+ $number = 0;
149+
150+ if($this->collection == 'error') {
151+ return (string)'error';
152+ }
153+
154+ if(!is_dir($this->dirmedia . $this->collection)) {
155+ $subdirs[] = array('subdirname' => '.', 'number' => 0, 'collection' => $this->collection);
156+ return $subdirs;
157+ }
158+
159+ $dirhandle = @opendir($this->dirmedia . $this->collection);
160+
161+ if(!$dirhandle) return (string)'error';
162+
163+ while(($subdirname = readdir($dirhandle)) !== FALSE) {
164+ if(is_dir($this->dirmedia . $this->collection . '/' . $subdirname) && $subdirname != "..") {
165+ $number = 0;
166+ if($subdirhandle = @opendir($this->dirmedia . $this->collection . '/' . $subdirname)) {
167+ if(!$subdirhandle) {
168+ return (string)'error';
169+ }
170+ while(($file = readdir($subdirhandle)) !== FALSE)
171+ if($file != '..' && $file != '.' && !is_dir($this->dirmedia . $this->collection . '/' . $subdirname . '/' . $file))
172+ ++$number;
173+ closedir($subdirhandle);
174+ }
175+ $temp[$subdirname] = array('number' => $number, 'collection' => $this->collection);
176+ }
177+ }
178+ closedir($dirhandle);
179+ ksort($temp);
180+ foreach($temp as $subdirname => $options) {
181+ $subdirs[] = array('subdirname' => $subdirname, 'number' => $options['number'], 'collection' => $options['collection']);
182+ }
183+ return (array)$subdirs;
184+ }
185+
186+ protected function setSubDir() {
187+ $subdir = htmlspecialchars(requestVar('subdir'), ENT_QUOTES, _CHARSET);
188+ $subdirs = self::getSubdirs();
189+ $list = array();
190+
191+ if($subdir == '') {
192+ $this->subdir = (string)'';
193+ }
194+
195+ if($subdirs == 'error') {
196+ $this->subdir = (string)'error';
197+ return;
198+ }
199+
200+ if(count($subdirs) < 2) {
201+ $this->subdir = (string)'';
202+ return;
203+ }
204+
205+ array_shift($subdirs);
206+
207+ foreach($subdirs as $key => $options) {
208+ if((string)$options['subdirname'] == (string)$subdir) {
209+ $this->subdir = (string)$subdir;
210+ break;
211+ }
212+ }
213+ }
214+
215+ protected function setFilename() {
216+ $filename = htmlspecialchars(requestVar('filename'), ENT_QUOTES, _CHARSET);
217+
218+ if($filename == '') {
219+ $this->filename = (string)'';
220+ return;
221+ }
222+
223+ if($this->collection === 'error') {
224+ $this->filename = (string)'error';
225+ return;
226+ }
227+
228+ if($this->subdir === 'error') {
229+ $this->filename = (string)'error';
230+ return;
231+ }
232+
233+ if(!$this->subdir)
234+ $fileobjectlist = MEDIA::getMediaListByCollection($this->collection);
235+ else
236+ $fileobjectlist = MEDIA::getMediaListByCollection($this->collection . '/' . $this->subdir);
237+
238+ foreach($fileobjectlist as $fileobject) {
239+ if((string)$fileobject->filename == (string)$filename) {
240+ $this->filename = $fileobject->filename;
241+ break;
242+ }
243+ }
244+ return;
245+ }
246+
247+ protected function setNewFilename() {
248+ $newfilename = htmlspecialchars(requestVar('newfilename'), ENT_QUOTES, _CHARSET);
249+ trim($newfilename);
250+ $this->newfilename = (string)$newfilename;
251+ return;
252+ }
253+
254+ protected function setOffset() {
255+ $offset = intRequestVar('offset');
256+ if($offset >= 0)
257+ $this->offset = (int)$offset;
258+ return;
259+ }
260+
261+ protected function setWay() {
262+ $way = htmlspecialchars(requestVar('way'), ENT_QUOTES, _CHARSET);
263+ $ways = array('popup','inline','other');
264+ if(in_array($way, $ways))
265+ $this->way = (string)$way;
266+ return;
267+ }
268+
269+ protected function setFilter() {
270+ $filter = htmlspecialchars(requestVar('filter'), ENT_QUOTES, _CHARSET);
271+ if($this->allowedtypes === array()) {
272+ $this->filter = (string)'';
273+ return;
274+ }
275+ if(in_array($filter, $this->allowedtypes))
276+ $this->filter = (string)$filter;
277+ return;
278+ }
279+
280+ private function setAllowedTypes() {
281+ global $CONF;
282+ if($CONF['AllowedTypes'] == '')
283+ return array();
284+ $allowedtypes = explode(',', $CONF['AllowedTypes']);
285+ if(is_array($allowedtypes)) {
286+ sort($allowedtypes);
287+ $this->allowedtypes = (array)$allowedtypes;
288+ }
289+ return;
290+ }
291+
292+ private function setMediaPrefix() {
293+ global $CONF;
294+ $this->mediaprefix = (string)$CONF['MediaPrefix'];
295+ return;
296+ }
297+
298+ private function setMediaURL() {
299+ global $CONF;
300+ $this->mediaurl = (string)$CONF['MediaURL'];
301+ return;
302+ }
303+
304+ private function setMaxUploadSize() {
305+ global $CONF;
306+ $this->maxuploadsize = (int)$CONF['MaxUploadSize'];
307+ return;
308+ }
309+
310+ private function setDIR_MEDIA() {
311+ global $DIR_MEDIA;
312+ $this->dirmedia = (string)$DIR_MEDIA;
313+ return;
314+ }
315+
316+ private function setOptions(&$PluginObject) {
317+ if($PluginObject->getOption('IM_PRIVATE') == 'no')
318+ $this->private = (int)0;
319+
320+ if($PluginObject->getOption('IM_GREYBOX') == 'yes')
321+ $this->greybox = (int)1;
322+
323+ $this->itemdisplay =& $PluginObject->getOption('IM_ITEMDISPLAY');
324+
325+ if($PluginObject->getOption('IM_EACHBLOGDIR') == 'yes')
326+ $this->eachblogdir = (int)1;
327+
328+ return;
329+ }
330+
331+ public function getAccessURL() {
332+ return $this->accessurl;
333+ }
334+
335+ public function getPluginDir() {
336+ return $this->plugindir;
337+ }
338+
339+ public function & getBlog() {
340+ return $this->blog;
341+ }
342+
343+ public function & getBlogid() {
344+ return $this->blogid;
345+ }
346+
347+ public function & getBlogName() {
348+ $blog =& $this->blog;
349+ if(!$blog)
350+ return '';
351+ else
352+ return $blog->getName();
353+ }
354+
355+ public function & getBlogShortName() {
356+ $blog =& $this->blog;
357+ if(!$blog)
358+ return '';
359+ else
360+ return $blog->getShortName();
361+ }
362+
363+ public function getPrivate() {
364+ return $this->private;
365+ }
366+
367+ public function getGreybox() {
368+ return $this->greybox;
369+ }
370+
371+ public function getEachblogdir() {
372+ return $this->eachblogdir;
373+ }
374+
375+ public function getItemdisplay() {
376+ return $this->itemdisplay;
377+ }
378+
379+ public function getAllowedtypes() {
380+ return $this->allowedtypes;
381+ }
382+
383+ public function getMediaprefix() {
384+ return $this->mediaprefix;
385+ }
386+
387+ public function getMaxuploadsize() {
388+ return $this->maxuploadsize;
389+ }
390+
391+ public function getMediaURL() {
392+ return $this->mediaurl;
393+ }
394+
395+ public function getDirMedia() {
396+ return $this->dirmedia;
397+ }
398+
399+ public function getMode() {
400+ return $this->mode;
401+ }
402+
403+ public function getAlttext() {
404+ return $this->alttext;
405+ }
406+
407+ public function getAstool() {
408+ return $this->astool;
409+ }
410+
411+ public function getCollection() {
412+ return $this->collection;
413+ }
414+
415+ public function getSubdir() {
416+ return $this->subdir;
417+ }
418+
419+ public function & getFilename() {
420+ return $this->filename;
421+ }
422+
423+ public function getNewfilename() {
424+ return $this->newfilename;
425+ }
426+
427+ public function & getOffset() {
428+ return $this->offset;
429+ }
430+
431+ public function getWay() {
432+ return $this->way;
433+ }
434+
435+ public function getFilter() {
436+ return $this->filter;
437+ }
438+
439+ public function resetOffset() {
440+ $this->offset = 0;
441+ }
442+
443+ public function resetFilter() {
444+ $this->filter = '';
445+ }
446+}
447+?>
\ No newline at end of file
--- /dev/null
+++ b/NP_ImprovedMedia/improvedmedia/greybox/AJS.js
@@ -0,0 +1,514 @@
1+AJS={BASE_URL:"",drag_obj:null,drag_elm:null,_drop_zones:[],_cur_pos:null,getScrollTop:function(){
2+var t;
3+if(document.documentElement&&document.documentElement.scrollTop){
4+t=document.documentElement.scrollTop;
5+}else{
6+if(document.body){
7+t=document.body.scrollTop;
8+}
9+}
10+return t;
11+},addClass:function(){
12+var _2=AJS.forceArray(arguments);
13+var _3=_2.pop();
14+var _4=function(o){
15+if(!new RegExp("(^|\\s)"+_3+"(\\s|$)").test(o.className)){
16+o.className+=(o.className?" ":"")+_3;
17+}
18+};
19+AJS.map(_2,function(_6){
20+_4(_6);
21+});
22+},setStyle:function(){
23+var _7=AJS.forceArray(arguments);
24+var _8=_7.pop();
25+var _9=_7.pop();
26+AJS.map(_7,function(_a){
27+_a.style[_9]=AJS.getCssDim(_8);
28+});
29+},extend:function(_b){
30+var _c=new this("no_init");
31+for(k in _b){
32+var _d=_c[k];
33+var _e=_b[k];
34+if(_d&&_d!=_e&&typeof _e=="function"){
35+_e=this._parentize(_e,_d);
36+}
37+_c[k]=_e;
38+}
39+return new AJS.Class(_c);
40+},log:function(o){
41+if(window.console){
42+console.log(o);
43+}else{
44+var div=AJS.$("ajs_logger");
45+if(!div){
46+div=AJS.DIV({id:"ajs_logger","style":"color: green; position: absolute; left: 0"});
47+div.style.top=AJS.getScrollTop()+"px";
48+AJS.ACN(AJS.getBody(),div);
49+}
50+AJS.setHTML(div,""+o);
51+}
52+},setHeight:function(){
53+var _11=AJS.forceArray(arguments);
54+_11.splice(_11.length-1,0,"height");
55+AJS.setStyle.apply(null,_11);
56+},_getRealScope:function(fn,_13){
57+_13=AJS.$A(_13);
58+var _14=fn._cscope||window;
59+return function(){
60+var _15=AJS.$FA(arguments).concat(_13);
61+return fn.apply(_14,_15);
62+};
63+},documentInsert:function(elm){
64+if(typeof (elm)=="string"){
65+elm=AJS.HTML2DOM(elm);
66+}
67+document.write("<span id=\"dummy_holder\"></span>");
68+AJS.swapDOM(AJS.$("dummy_holder"),elm);
69+},getWindowSize:function(doc){
70+doc=doc||document;
71+var _18,_19;
72+if(self.innerHeight){
73+_18=self.innerWidth;
74+_19=self.innerHeight;
75+}else{
76+if(doc.documentElement&&doc.documentElement.clientHeight){
77+_18=doc.documentElement.clientWidth;
78+_19=doc.documentElement.clientHeight;
79+}else{
80+if(doc.body){
81+_18=doc.body.clientWidth;
82+_19=doc.body.clientHeight;
83+}
84+}
85+}
86+return {"w":_18,"h":_19};
87+},flattenList:function(_1a){
88+var r=[];
89+var _1c=function(r,l){
90+AJS.map(l,function(o){
91+if(o==null){
92+}else{
93+if(AJS.isArray(o)){
94+_1c(r,o);
95+}else{
96+r.push(o);
97+}
98+}
99+});
100+};
101+_1c(r,_1a);
102+return r;
103+},isFunction:function(obj){
104+return (typeof obj=="function");
105+},setEventKey:function(e){
106+e.key=e.keyCode?e.keyCode:e.charCode;
107+if(window.event){
108+e.ctrl=window.event.ctrlKey;
109+e.shift=window.event.shiftKey;
110+}else{
111+e.ctrl=e.ctrlKey;
112+e.shift=e.shiftKey;
113+}
114+switch(e.key){
115+case 63232:
116+e.key=38;
117+break;
118+case 63233:
119+e.key=40;
120+break;
121+case 63235:
122+e.key=39;
123+break;
124+case 63234:
125+e.key=37;
126+break;
127+}
128+},removeElement:function(){
129+var _22=AJS.forceArray(arguments);
130+AJS.map(_22,function(elm){
131+AJS.swapDOM(elm,null);
132+});
133+},_unloadListeners:function(){
134+if(AJS.listeners){
135+AJS.map(AJS.listeners,function(elm,_25,fn){
136+AJS.REV(elm,_25,fn);
137+});
138+}
139+AJS.listeners=[];
140+},join:function(_27,_28){
141+try{
142+return _28.join(_27);
143+}
144+catch(e){
145+var r=_28[0]||"";
146+AJS.map(_28,function(elm){
147+r+=_27+elm;
148+},1);
149+return r+"";
150+}
151+},getIndex:function(elm,_2c,_2d){
152+for(var i=0;i<_2c.length;i++){
153+if(_2d&&_2d(_2c[i])||elm==_2c[i]){
154+return i;
155+}
156+}
157+return -1;
158+},isIn:function(elm,_30){
159+var i=AJS.getIndex(elm,_30);
160+if(i!=-1){
161+return true;
162+}else{
163+return false;
164+}
165+},isArray:function(obj){
166+return obj instanceof Array;
167+},setLeft:function(){
168+var _33=AJS.forceArray(arguments);
169+_33.splice(_33.length-1,0,"left");
170+AJS.setStyle.apply(null,_33);
171+},appendChildNodes:function(elm){
172+if(arguments.length>=2){
173+AJS.map(arguments,function(n){
174+if(AJS.isString(n)){
175+n=AJS.TN(n);
176+}
177+if(AJS.isDefined(n)){
178+elm.appendChild(n);
179+}
180+},1);
181+}
182+return elm;
183+},getElementsByTagAndClassName:function(_36,_37,_38,_39){
184+var _3a=[];
185+if(!AJS.isDefined(_38)){
186+_38=document;
187+}
188+if(!AJS.isDefined(_36)){
189+_36="*";
190+}
191+var els=_38.getElementsByTagName(_36);
192+var _3c=els.length;
193+var _3d=new RegExp("(^|\\s)"+_37+"(\\s|$)");
194+for(i=0,j=0;i<_3c;i++){
195+if(_3d.test(els[i].className)||_37==null){
196+_3a[j]=els[i];
197+j++;
198+}
199+}
200+if(_39){
201+return _3a[0];
202+}else{
203+return _3a;
204+}
205+},isOpera:function(){
206+return (navigator.userAgent.toLowerCase().indexOf("opera")!=-1);
207+},isString:function(obj){
208+return (typeof obj=="string");
209+},hideElement:function(elm){
210+var _40=AJS.forceArray(arguments);
211+AJS.map(_40,function(elm){
212+elm.style.display="none";
213+});
214+},setOpacity:function(elm,p){
215+elm.style.opacity=p;
216+elm.style.filter="alpha(opacity="+p*100+")";
217+},insertBefore:function(elm,_45){
218+_45.parentNode.insertBefore(elm,_45);
219+return elm;
220+},setWidth:function(){
221+var _46=AJS.forceArray(arguments);
222+_46.splice(_46.length-1,0,"width");
223+AJS.setStyle.apply(null,_46);
224+},createArray:function(v){
225+if(AJS.isArray(v)&&!AJS.isString(v)){
226+return v;
227+}else{
228+if(!v){
229+return [];
230+}else{
231+return [v];
232+}
233+}
234+},isDict:function(o){
235+var _49=String(o);
236+return _49.indexOf(" Object")!=-1;
237+},isMozilla:function(){
238+return (navigator.userAgent.toLowerCase().indexOf("gecko")!=-1&&navigator.productSub>=20030210);
239+},removeEventListener:function(elm,_4b,fn,_4d){
240+var _4e="ajsl_"+_4b+fn;
241+if(!_4d){
242+_4d=false;
243+}
244+fn=elm[_4e]||fn;
245+if(elm["on"+_4b]==fn){
246+elm["on"+_4b]=elm[_4e+"old"];
247+}
248+if(elm.removeEventListener){
249+elm.removeEventListener(_4b,fn,_4d);
250+if(AJS.isOpera()){
251+elm.removeEventListener(_4b,fn,!_4d);
252+}
253+}else{
254+if(elm.detachEvent){
255+elm.detachEvent("on"+_4b,fn);
256+}
257+}
258+},callLater:function(fn,_50){
259+var _51=function(){
260+fn();
261+};
262+window.setTimeout(_51,_50);
263+},setTop:function(){
264+var _52=AJS.forceArray(arguments);
265+_52.splice(_52.length-1,0,"top");
266+AJS.setStyle.apply(null,_52);
267+},_createDomShortcuts:function(){
268+var _53=["ul","li","td","tr","th","tbody","table","input","span","b","a","div","img","button","h1","h2","h3","h4","h5","h6","br","textarea","form","p","select","option","optgroup","iframe","script","center","dl","dt","dd","small","pre","i"];
269+var _54=function(elm){
270+AJS[elm.toUpperCase()]=function(){
271+return AJS.createDOM.apply(null,[elm,arguments]);
272+};
273+};
274+AJS.map(_53,_54);
275+AJS.TN=function(_56){
276+return document.createTextNode(_56);
277+};
278+},addCallback:function(fn){
279+this.callbacks.unshift(fn);
280+},bindMethods:function(_58){
281+for(var k in _58){
282+var _5a=_58[k];
283+if(typeof (_5a)=="function"){
284+_58[k]=AJS.$b(_5a,_58);
285+}
286+}
287+},partial:function(fn){
288+var _5c=AJS.$FA(arguments);
289+_5c.shift();
290+return function(){
291+_5c=_5c.concat(AJS.$FA(arguments));
292+return fn.apply(window,_5c);
293+};
294+},isNumber:function(obj){
295+return (typeof obj=="number");
296+},getCssDim:function(dim){
297+if(AJS.isString(dim)){
298+return dim;
299+}else{
300+return dim+"px";
301+}
302+},isIe:function(){
303+return (navigator.userAgent.toLowerCase().indexOf("msie")!=-1&&navigator.userAgent.toLowerCase().indexOf("opera")==-1);
304+},removeClass:function(){
305+var _5f=AJS.forceArray(arguments);
306+var cls=_5f.pop();
307+var _61=function(o){
308+o.className=o.className.replace(new RegExp("\\s?"+cls,"g"),"");
309+};
310+AJS.map(_5f,function(elm){
311+_61(elm);
312+});
313+},setHTML:function(elm,_65){
314+elm.innerHTML=_65;
315+return elm;
316+},map:function(_66,fn,_68,_69){
317+var i=0,l=_66.length;
318+if(_68){
319+i=_68;
320+}
321+if(_69){
322+l=_69;
323+}
324+for(i;i<l;i++){
325+var val=fn(_66[i],i);
326+if(val!=undefined){
327+return val;
328+}
329+}
330+},addEventListener:function(elm,_6e,fn,_70,_71){
331+var _72="ajsl_"+_6e+fn;
332+if(!_71){
333+_71=false;
334+}
335+AJS.listeners=AJS.$A(AJS.listeners);
336+if(AJS.isIn(_6e,["keypress","keydown","keyup","click"])){
337+var _73=fn;
338+fn=function(e){
339+AJS.setEventKey(e);
340+return _73.apply(window,arguments);
341+};
342+}
343+var _75=AJS.isIn(_6e,["submit","load","scroll","resize"]);
344+var _76=AJS.$A(elm);
345+AJS.map(_76,function(_77){
346+if(_70){
347+var _78=fn;
348+fn=function(e){
349+AJS.REV(_77,_6e,fn);
350+return _78.apply(window,arguments);
351+};
352+}
353+if(_75){
354+var _7a=_77["on"+_6e];
355+var _7b=function(){
356+if(_7a){
357+fn(arguments);
358+return _7a(arguments);
359+}else{
360+return fn(arguments);
361+}
362+};
363+_77[_72]=_7b;
364+_77[_72+"old"]=_7a;
365+elm["on"+_6e]=_7b;
366+}else{
367+_77[_72]=fn;
368+if(_77.attachEvent){
369+_77.attachEvent("on"+_6e,fn);
370+}else{
371+if(_77.addEventListener){
372+_77.addEventListener(_6e,fn,_71);
373+}
374+}
375+AJS.listeners.push([_77,_6e,fn]);
376+}
377+});
378+},preloadImages:function(){
379+AJS.AEV(window,"load",AJS.$p(function(_7c){
380+AJS.map(_7c,function(src){
381+var pic=new Image();
382+pic.src=src;
383+});
384+},arguments));
385+},forceArray:function(_7f){
386+var r=[];
387+AJS.map(_7f,function(elm){
388+r.push(elm);
389+});
390+return r;
391+},update:function(l1,l2){
392+for(var i in l2){
393+l1[i]=l2[i];
394+}
395+return l1;
396+},getBody:function(){
397+return AJS.$bytc("body")[0];
398+},HTML2DOM:function(_85,_86){
399+var d=AJS.DIV();
400+d.innerHTML=_85;
401+if(_86){
402+return d.childNodes[0];
403+}else{
404+return d;
405+}
406+},getElement:function(id){
407+if(AJS.isString(id)||AJS.isNumber(id)){
408+return document.getElementById(id);
409+}else{
410+return id;
411+}
412+},showElement:function(){
413+var _89=AJS.forceArray(arguments);
414+AJS.map(_89,function(elm){
415+elm.style.display="";
416+});
417+},bind:function(fn,_8c,_8d){
418+fn._cscope=_8c;
419+return AJS._getRealScope(fn,_8d);
420+},createDOM:function(_8e,_8f){
421+var i=0,_91;
422+var elm=document.createElement(_8e);
423+var _93=_8f[0];
424+if(AJS.isDict(_8f[i])){
425+for(k in _93){
426+_91=_93[k];
427+if(k=="style"||k=="s"){
428+elm.style.cssText=_91;
429+}else{
430+if(k=="c"||k=="class"||k=="className"){
431+elm.className=_91;
432+}else{
433+elm.setAttribute(k,_91);
434+}
435+}
436+}
437+i++;
438+}
439+if(_93==null){
440+i=1;
441+}
442+for(var j=i;j<_8f.length;j++){
443+var _91=_8f[j];
444+if(_91){
445+var _95=typeof (_91);
446+if(_95=="string"||_95=="number"){
447+_91=AJS.TN(_91);
448+}
449+elm.appendChild(_91);
450+}
451+}
452+return elm;
453+},swapDOM:function(_96,src){
454+_96=AJS.getElement(_96);
455+var _98=_96.parentNode;
456+if(src){
457+src=AJS.getElement(src);
458+_98.replaceChild(src,_96);
459+}else{
460+_98.removeChild(_96);
461+}
462+return src;
463+},isDefined:function(o){
464+return (o!="undefined"&&o!=null);
465+}};
466+AJS.$=AJS.getElement;
467+AJS.$$=AJS.getElements;
468+AJS.$f=AJS.getFormElement;
469+AJS.$p=AJS.partial;
470+AJS.$b=AJS.bind;
471+AJS.$A=AJS.createArray;
472+AJS.DI=AJS.documentInsert;
473+AJS.ACN=AJS.appendChildNodes;
474+AJS.RCN=AJS.replaceChildNodes;
475+AJS.AEV=AJS.addEventListener;
476+AJS.REV=AJS.removeEventListener;
477+AJS.$bytc=AJS.getElementsByTagAndClassName;
478+AJS.$AP=AJS.absolutePosition;
479+AJS.$FA=AJS.forceArray;
480+AJS.addEventListener(window,"unload",AJS._unloadListeners);
481+AJS._createDomShortcuts();
482+AJS.Class=function(_9a){
483+var fn=function(){
484+if(arguments[0]!="no_init"){
485+return this.init.apply(this,arguments);
486+}
487+};
488+fn.prototype=_9a;
489+AJS.update(fn,AJS.Class.prototype);
490+return fn;
491+};
492+AJS.Class.prototype={extend:function(_9c){
493+var _9d=new this("no_init");
494+for(k in _9c){
495+var _9e=_9d[k];
496+var cur=_9c[k];
497+if(_9e&&_9e!=cur&&typeof cur=="function"){
498+cur=this._parentize(cur,_9e);
499+}
500+_9d[k]=cur;
501+}
502+return new AJS.Class(_9d);
503+},implement:function(_a0){
504+AJS.update(this.prototype,_a0);
505+},_parentize:function(cur,_a2){
506+return function(){
507+this.parent=_a2;
508+return cur.apply(this,arguments);
509+};
510+}};
511+script_loaded=true;
512+
513+
514+script_loaded=true;
\ No newline at end of file
--- /dev/null
+++ b/NP_ImprovedMedia/improvedmedia/greybox/AJS_fx.js
@@ -0,0 +1,138 @@
1+AJS.fx={_shades:{0:"ffffff",1:"ffffee",2:"ffffdd",3:"ffffcc",4:"ffffbb",5:"ffffaa",6:"ffff99"},highlight:function(_1,_2){
2+var _3=new AJS.fx.Base();
3+_3.elm=AJS.$(_1);
4+_3.options.duration=600;
5+_3.setOptions(_2);
6+AJS.update(_3,{increase:function(){
7+if(this.now==7){
8+_1.style.backgroundColor="#fff";
9+}else{
10+_1.style.backgroundColor="#"+AJS.fx._shades[Math.floor(this.now)];
11+}
12+}});
13+return _3.custom(6,0);
14+},fadeIn:function(_4,_5){
15+_5=_5||{};
16+if(!_5.from){
17+_5.from=0;
18+AJS.setOpacity(_4,0);
19+}
20+if(!_5.to){
21+_5.to=1;
22+}
23+var s=new AJS.fx.Style(_4,"opacity",_5);
24+return s.custom(_5.from,_5.to);
25+},fadeOut:function(_7,_8){
26+_8=_8||{};
27+if(!_8.from){
28+_8.from=1;
29+}
30+if(!_8.to){
31+_8.to=0;
32+}
33+_8.duration=300;
34+var s=new AJS.fx.Style(_7,"opacity",_8);
35+return s.custom(_8.from,_8.to);
36+},setWidth:function(_a,_b){
37+var s=new AJS.fx.Style(_a,"width",_b);
38+return s.custom(_b.from,_b.to);
39+},setHeight:function(_d,_e){
40+var s=new AJS.fx.Style(_d,"height",_e);
41+return s.custom(_e.from,_e.to);
42+}};
43+AJS.fx.Base=new AJS.Class({init:function(_10){
44+this.options={onStart:function(){
45+},onComplete:function(){
46+},transition:AJS.fx.Transitions.sineInOut,duration:500,wait:true,fps:50};
47+AJS.update(this.options,_10);
48+AJS.bindMethods(this);
49+},setOptions:function(_11){
50+AJS.update(this.options,_11);
51+},step:function(){
52+var _12=new Date().getTime();
53+if(_12<this.time+this.options.duration){
54+this.cTime=_12-this.time;
55+this.setNow();
56+}else{
57+setTimeout(AJS.$b(this.options.onComplete,this,[this.elm]),10);
58+this.clearTimer();
59+this.now=this.to;
60+}
61+this.increase();
62+},setNow:function(){
63+this.now=this.compute(this.from,this.to);
64+},compute:function(_13,to){
65+var _15=to-_13;
66+return this.options.transition(this.cTime,_13,_15,this.options.duration);
67+},clearTimer:function(){
68+clearInterval(this.timer);
69+this.timer=null;
70+return this;
71+},_start:function(_16,to){
72+if(!this.options.wait){
73+this.clearTimer();
74+}
75+if(this.timer){
76+return;
77+}
78+setTimeout(AJS.$p(this.options.onStart,this.elm),10);
79+this.from=_16;
80+this.to=to;
81+this.time=new Date().getTime();
82+this.timer=setInterval(this.step,Math.round(1000/this.options.fps));
83+return this;
84+},custom:function(_18,to){
85+return this._start(_18,to);
86+},set:function(to){
87+this.now=to;
88+this.increase();
89+return this;
90+},setStyle:function(elm,_1c,val){
91+if(this.property=="opacity"){
92+AJS.setOpacity(elm,val);
93+}else{
94+AJS.setStyle(elm,_1c,val);
95+}
96+}});
97+AJS.fx.Style=AJS.fx.Base.extend({init:function(elm,_1f,_20){
98+this.parent();
99+this.elm=elm;
100+this.setOptions(_20);
101+this.property=_1f;
102+},increase:function(){
103+this.setStyle(this.elm,this.property,this.now);
104+}});
105+AJS.fx.Styles=AJS.fx.Base.extend({init:function(elm,_22){
106+this.parent();
107+this.elm=AJS.$(elm);
108+this.setOptions(_22);
109+this.now={};
110+},setNow:function(){
111+for(p in this.from){
112+this.now[p]=this.compute(this.from[p],this.to[p]);
113+}
114+},custom:function(obj){
115+if(this.timer&&this.options.wait){
116+return;
117+}
118+var _24={};
119+var to={};
120+for(p in obj){
121+_24[p]=obj[p][0];
122+to[p]=obj[p][1];
123+}
124+return this._start(_24,to);
125+},increase:function(){
126+for(var p in this.now){
127+this.setStyle(this.elm,p,this.now[p]);
128+}
129+}});
130+AJS.fx.Transitions={linear:function(t,b,c,d){
131+return c*t/d+b;
132+},sineInOut:function(t,b,c,d){
133+return -c/2*(Math.cos(Math.PI*t/d)-1)+b;
134+}};
135+script_loaded=true;
136+
137+
138+script_loaded=true;
\ No newline at end of file
--- /dev/null
+++ b/NP_ImprovedMedia/improvedmedia/greybox/LGPL.txt
@@ -0,0 +1,504 @@
1+ GNU LESSER GENERAL PUBLIC LICENSE
2+ Version 2.1, February 1999
3+
4+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
5+ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
6+ Everyone is permitted to copy and distribute verbatim copies
7+ of this license document, but changing it is not allowed.
8+
9+[This is the first released version of the Lesser GPL. It also counts
10+ as the successor of the GNU Library Public License, version 2, hence
11+ the version number 2.1.]
12+
13+ Preamble
14+
15+ The licenses for most software are designed to take away your
16+freedom to share and change it. By contrast, the GNU General Public
17+Licenses are intended to guarantee your freedom to share and change
18+free software--to make sure the software is free for all its users.
19+
20+ This license, the Lesser General Public License, applies to some
21+specially designated software packages--typically libraries--of the
22+Free Software Foundation and other authors who decide to use it. You
23+can use it too, but we suggest you first think carefully about whether
24+this license or the ordinary General Public License is the better
25+strategy to use in any particular case, based on the explanations below.
26+
27+ When we speak of free software, we are referring to freedom of use,
28+not price. Our General Public Licenses are designed to make sure that
29+you have the freedom to distribute copies of free software (and charge
30+for this service if you wish); that you receive source code or can get
31+it if you want it; that you can change the software and use pieces of
32+it in new free programs; and that you are informed that you can do
33+these things.
34+
35+ To protect your rights, we need to make restrictions that forbid
36+distributors to deny you these rights or to ask you to surrender these
37+rights. These restrictions translate to certain responsibilities for
38+you if you distribute copies of the library or if you modify it.
39+
40+ For example, if you distribute copies of the library, whether gratis
41+or for a fee, you must give the recipients all the rights that we gave
42+you. You must make sure that they, too, receive or can get the source
43+code. If you link other code with the library, you must provide
44+complete object files to the recipients, so that they can relink them
45+with the library after making changes to the library and recompiling
46+it. And you must show them these terms so they know their rights.
47+
48+ We protect your rights with a two-step method: (1) we copyright the
49+library, and (2) we offer you this license, which gives you legal
50+permission to copy, distribute and/or modify the library.
51+
52+ To protect each distributor, we want to make it very clear that
53+there is no warranty for the free library. Also, if the library is
54+modified by someone else and passed on, the recipients should know
55+that what they have is not the original version, so that the original
56+author's reputation will not be affected by problems that might be
57+introduced by others.
58+
59+ Finally, software patents pose a constant threat to the existence of
60+any free program. We wish to make sure that a company cannot
61+effectively restrict the users of a free program by obtaining a
62+restrictive license from a patent holder. Therefore, we insist that
63+any patent license obtained for a version of the library must be
64+consistent with the full freedom of use specified in this license.
65+
66+ Most GNU software, including some libraries, is covered by the
67+ordinary GNU General Public License. This license, the GNU Lesser
68+General Public License, applies to certain designated libraries, and
69+is quite different from the ordinary General Public License. We use
70+this license for certain libraries in order to permit linking those
71+libraries into non-free programs.
72+
73+ When a program is linked with a library, whether statically or using
74+a shared library, the combination of the two is legally speaking a
75+combined work, a derivative of the original library. The ordinary
76+General Public License therefore permits such linking only if the
77+entire combination fits its criteria of freedom. The Lesser General
78+Public License permits more lax criteria for linking other code with
79+the library.
80+
81+ We call this license the "Lesser" General Public License because it
82+does Less to protect the user's freedom than the ordinary General
83+Public License. It also provides other free software developers Less
84+of an advantage over competing non-free programs. These disadvantages
85+are the reason we use the ordinary General Public License for many
86+libraries. However, the Lesser license provides advantages in certain
87+special circumstances.
88+
89+ For example, on rare occasions, there may be a special need to
90+encourage the widest possible use of a certain library, so that it becomes
91+a de-facto standard. To achieve this, non-free programs must be
92+allowed to use the library. A more frequent case is that a free
93+library does the same job as widely used non-free libraries. In this
94+case, there is little to gain by limiting the free library to free
95+software only, so we use the Lesser General Public License.
96+
97+ In other cases, permission to use a particular library in non-free
98+programs enables a greater number of people to use a large body of
99+free software. For example, permission to use the GNU C Library in
100+non-free programs enables many more people to use the whole GNU
101+operating system, as well as its variant, the GNU/Linux operating
102+system.
103+
104+ Although the Lesser General Public License is Less protective of the
105+users' freedom, it does ensure that the user of a program that is
106+linked with the Library has the freedom and the wherewithal to run
107+that program using a modified version of the Library.
108+
109+ The precise terms and conditions for copying, distribution and
110+modification follow. Pay close attention to the difference between a
111+"work based on the library" and a "work that uses the library". The
112+former contains code derived from the library, whereas the latter must
113+be combined with the library in order to run.
114+
115+ GNU LESSER GENERAL PUBLIC LICENSE
116+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
117+
118+ 0. This License Agreement applies to any software library or other
119+program which contains a notice placed by the copyright holder or
120+other authorized party saying it may be distributed under the terms of
121+this Lesser General Public License (also called "this License").
122+Each licensee is addressed as "you".
123+
124+ A "library" means a collection of software functions and/or data
125+prepared so as to be conveniently linked with application programs
126+(which use some of those functions and data) to form executables.
127+
128+ The "Library", below, refers to any such software library or work
129+which has been distributed under these terms. A "work based on the
130+Library" means either the Library or any derivative work under
131+copyright law: that is to say, a work containing the Library or a
132+portion of it, either verbatim or with modifications and/or translated
133+straightforwardly into another language. (Hereinafter, translation is
134+included without limitation in the term "modification".)
135+
136+ "Source code" for a work means the preferred form of the work for
137+making modifications to it. For a library, complete source code means
138+all the source code for all modules it contains, plus any associated
139+interface definition files, plus the scripts used to control compilation
140+and installation of the library.
141+
142+ Activities other than copying, distribution and modification are not
143+covered by this License; they are outside its scope. The act of
144+running a program using the Library is not restricted, and output from
145+such a program is covered only if its contents constitute a work based
146+on the Library (independent of the use of the Library in a tool for
147+writing it). Whether that is true depends on what the Library does
148+and what the program that uses the Library does.
149+
150+ 1. You may copy and distribute verbatim copies of the Library's
151+complete source code as you receive it, in any medium, provided that
152+you conspicuously and appropriately publish on each copy an
153+appropriate copyright notice and disclaimer of warranty; keep intact
154+all the notices that refer to this License and to the absence of any
155+warranty; and distribute a copy of this License along with the
156+Library.
157+
158+ You may charge a fee for the physical act of transferring a copy,
159+and you may at your option offer warranty protection in exchange for a
160+fee.
161+
162+ 2. You may modify your copy or copies of the Library or any portion
163+of it, thus forming a work based on the Library, and copy and
164+distribute such modifications or work under the terms of Section 1
165+above, provided that you also meet all of these conditions:
166+
167+ a) The modified work must itself be a software library.
168+
169+ b) You must cause the files modified to carry prominent notices
170+ stating that you changed the files and the date of any change.
171+
172+ c) You must cause the whole of the work to be licensed at no
173+ charge to all third parties under the terms of this License.
174+
175+ d) If a facility in the modified Library refers to a function or a
176+ table of data to be supplied by an application program that uses
177+ the facility, other than as an argument passed when the facility
178+ is invoked, then you must make a good faith effort to ensure that,
179+ in the event an application does not supply such function or
180+ table, the facility still operates, and performs whatever part of
181+ its purpose remains meaningful.
182+
183+ (For example, a function in a library to compute square roots has
184+ a purpose that is entirely well-defined independent of the
185+ application. Therefore, Subsection 2d requires that any
186+ application-supplied function or table used by this function must
187+ be optional: if the application does not supply it, the square
188+ root function must still compute square roots.)
189+
190+These requirements apply to the modified work as a whole. If
191+identifiable sections of that work are not derived from the Library,
192+and can be reasonably considered independent and separate works in
193+themselves, then this License, and its terms, do not apply to those
194+sections when you distribute them as separate works. But when you
195+distribute the same sections as part of a whole which is a work based
196+on the Library, the distribution of the whole must be on the terms of
197+this License, whose permissions for other licensees extend to the
198+entire whole, and thus to each and every part regardless of who wrote
199+it.
200+
201+Thus, it is not the intent of this section to claim rights or contest
202+your rights to work written entirely by you; rather, the intent is to
203+exercise the right to control the distribution of derivative or
204+collective works based on the Library.
205+
206+In addition, mere aggregation of another work not based on the Library
207+with the Library (or with a work based on the Library) on a volume of
208+a storage or distribution medium does not bring the other work under
209+the scope of this License.
210+
211+ 3. You may opt to apply the terms of the ordinary GNU General Public
212+License instead of this License to a given copy of the Library. To do
213+this, you must alter all the notices that refer to this License, so
214+that they refer to the ordinary GNU General Public License, version 2,
215+instead of to this License. (If a newer version than version 2 of the
216+ordinary GNU General Public License has appeared, then you can specify
217+that version instead if you wish.) Do not make any other change in
218+these notices.
219+
220+ Once this change is made in a given copy, it is irreversible for
221+that copy, so the ordinary GNU General Public License applies to all
222+subsequent copies and derivative works made from that copy.
223+
224+ This option is useful when you wish to copy part of the code of
225+the Library into a program that is not a library.
226+
227+ 4. You may copy and distribute the Library (or a portion or
228+derivative of it, under Section 2) in object code or executable form
229+under the terms of Sections 1 and 2 above provided that you accompany
230+it with the complete corresponding machine-readable source code, which
231+must be distributed under the terms of Sections 1 and 2 above on a
232+medium customarily used for software interchange.
233+
234+ If distribution of object code is made by offering access to copy
235+from a designated place, then offering equivalent access to copy the
236+source code from the same place satisfies the requirement to
237+distribute the source code, even though third parties are not
238+compelled to copy the source along with the object code.
239+
240+ 5. A program that contains no derivative of any portion of the
241+Library, but is designed to work with the Library by being compiled or
242+linked with it, is called a "work that uses the Library". Such a
243+work, in isolation, is not a derivative work of the Library, and
244+therefore falls outside the scope of this License.
245+
246+ However, linking a "work that uses the Library" with the Library
247+creates an executable that is a derivative of the Library (because it
248+contains portions of the Library), rather than a "work that uses the
249+library". The executable is therefore covered by this License.
250+Section 6 states terms for distribution of such executables.
251+
252+ When a "work that uses the Library" uses material from a header file
253+that is part of the Library, the object code for the work may be a
254+derivative work of the Library even though the source code is not.
255+Whether this is true is especially significant if the work can be
256+linked without the Library, or if the work is itself a library. The
257+threshold for this to be true is not precisely defined by law.
258+
259+ If such an object file uses only numerical parameters, data
260+structure layouts and accessors, and small macros and small inline
261+functions (ten lines or less in length), then the use of the object
262+file is unrestricted, regardless of whether it is legally a derivative
263+work. (Executables containing this object code plus portions of the
264+Library will still fall under Section 6.)
265+
266+ Otherwise, if the work is a derivative of the Library, you may
267+distribute the object code for the work under the terms of Section 6.
268+Any executables containing that work also fall under Section 6,
269+whether or not they are linked directly with the Library itself.
270+
271+ 6. As an exception to the Sections above, you may also combine or
272+link a "work that uses the Library" with the Library to produce a
273+work containing portions of the Library, and distribute that work
274+under terms of your choice, provided that the terms permit
275+modification of the work for the customer's own use and reverse
276+engineering for debugging such modifications.
277+
278+ You must give prominent notice with each copy of the work that the
279+Library is used in it and that the Library and its use are covered by
280+this License. You must supply a copy of this License. If the work
281+during execution displays copyright notices, you must include the
282+copyright notice for the Library among them, as well as a reference
283+directing the user to the copy of this License. Also, you must do one
284+of these things:
285+
286+ a) Accompany the work with the complete corresponding
287+ machine-readable source code for the Library including whatever
288+ changes were used in the work (which must be distributed under
289+ Sections 1 and 2 above); and, if the work is an executable linked
290+ with the Library, with the complete machine-readable "work that
291+ uses the Library", as object code and/or source code, so that the
292+ user can modify the Library and then relink to produce a modified
293+ executable containing the modified Library. (It is understood
294+ that the user who changes the contents of definitions files in the
295+ Library will not necessarily be able to recompile the application
296+ to use the modified definitions.)
297+
298+ b) Use a suitable shared library mechanism for linking with the
299+ Library. A suitable mechanism is one that (1) uses at run time a
300+ copy of the library already present on the user's computer system,
301+ rather than copying library functions into the executable, and (2)
302+ will operate properly with a modified version of the library, if
303+ the user installs one, as long as the modified version is
304+ interface-compatible with the version that the work was made with.
305+
306+ c) Accompany the work with a written offer, valid for at
307+ least three years, to give the same user the materials
308+ specified in Subsection 6a, above, for a charge no more
309+ than the cost of performing this distribution.
310+
311+ d) If distribution of the work is made by offering access to copy
312+ from a designated place, offer equivalent access to copy the above
313+ specified materials from the same place.
314+
315+ e) Verify that the user has already received a copy of these
316+ materials or that you have already sent this user a copy.
317+
318+ For an executable, the required form of the "work that uses the
319+Library" must include any data and utility programs needed for
320+reproducing the executable from it. However, as a special exception,
321+the materials to be distributed need not include anything that is
322+normally distributed (in either source or binary form) with the major
323+components (compiler, kernel, and so on) of the operating system on
324+which the executable runs, unless that component itself accompanies
325+the executable.
326+
327+ It may happen that this requirement contradicts the license
328+restrictions of other proprietary libraries that do not normally
329+accompany the operating system. Such a contradiction means you cannot
330+use both them and the Library together in an executable that you
331+distribute.
332+
333+ 7. You may place library facilities that are a work based on the
334+Library side-by-side in a single library together with other library
335+facilities not covered by this License, and distribute such a combined
336+library, provided that the separate distribution of the work based on
337+the Library and of the other library facilities is otherwise
338+permitted, and provided that you do these two things:
339+
340+ a) Accompany the combined library with a copy of the same work
341+ based on the Library, uncombined with any other library
342+ facilities. This must be distributed under the terms of the
343+ Sections above.
344+
345+ b) Give prominent notice with the combined library of the fact
346+ that part of it is a work based on the Library, and explaining
347+ where to find the accompanying uncombined form of the same work.
348+
349+ 8. You may not copy, modify, sublicense, link with, or distribute
350+the Library except as expressly provided under this License. Any
351+attempt otherwise to copy, modify, sublicense, link with, or
352+distribute the Library is void, and will automatically terminate your
353+rights under this License. However, parties who have received copies,
354+or rights, from you under this License will not have their licenses
355+terminated so long as such parties remain in full compliance.
356+
357+ 9. You are not required to accept this License, since you have not
358+signed it. However, nothing else grants you permission to modify or
359+distribute the Library or its derivative works. These actions are
360+prohibited by law if you do not accept this License. Therefore, by
361+modifying or distributing the Library (or any work based on the
362+Library), you indicate your acceptance of this License to do so, and
363+all its terms and conditions for copying, distributing or modifying
364+the Library or works based on it.
365+
366+ 10. Each time you redistribute the Library (or any work based on the
367+Library), the recipient automatically receives a license from the
368+original licensor to copy, distribute, link with or modify the Library
369+subject to these terms and conditions. You may not impose any further
370+restrictions on the recipients' exercise of the rights granted herein.
371+You are not responsible for enforcing compliance by third parties with
372+this License.
373+
374+ 11. If, as a consequence of a court judgment or allegation of patent
375+infringement or for any other reason (not limited to patent issues),
376+conditions are imposed on you (whether by court order, agreement or
377+otherwise) that contradict the conditions of this License, they do not
378+excuse you from the conditions of this License. If you cannot
379+distribute so as to satisfy simultaneously your obligations under this
380+License and any other pertinent obligations, then as a consequence you
381+may not distribute the Library at all. For example, if a patent
382+license would not permit royalty-free redistribution of the Library by
383+all those who receive copies directly or indirectly through you, then
384+the only way you could satisfy both it and this License would be to
385+refrain entirely from distribution of the Library.
386+
387+If any portion of this section is held invalid or unenforceable under any
388+particular circumstance, the balance of the section is intended to apply,
389+and the section as a whole is intended to apply in other circumstances.
390+
391+It is not the purpose of this section to induce you to infringe any
392+patents or other property right claims or to contest validity of any
393+such claims; this section has the sole purpose of protecting the
394+integrity of the free software distribution system which is
395+implemented by public license practices. Many people have made
396+generous contributions to the wide range of software distributed
397+through that system in reliance on consistent application of that
398+system; it is up to the author/donor to decide if he or she is willing
399+to distribute software through any other system and a licensee cannot
400+impose that choice.
401+
402+This section is intended to make thoroughly clear what is believed to
403+be a consequence of the rest of this License.
404+
405+ 12. If the distribution and/or use of the Library is restricted in
406+certain countries either by patents or by copyrighted interfaces, the
407+original copyright holder who places the Library under this License may add
408+an explicit geographical distribution limitation excluding those countries,
409+so that distribution is permitted only in or among countries not thus
410+excluded. In such case, this License incorporates the limitation as if
411+written in the body of this License.
412+
413+ 13. The Free Software Foundation may publish revised and/or new
414+versions of the Lesser General Public License from time to time.
415+Such new versions will be similar in spirit to the present version,
416+but may differ in detail to address new problems or concerns.
417+
418+Each version is given a distinguishing version number. If the Library
419+specifies a version number of this License which applies to it and
420+"any later version", you have the option of following the terms and
421+conditions either of that version or of any later version published by
422+the Free Software Foundation. If the Library does not specify a
423+license version number, you may choose any version ever published by
424+the Free Software Foundation.
425+
426+ 14. If you wish to incorporate parts of the Library into other free
427+programs whose distribution conditions are incompatible with these,
428+write to the author to ask for permission. For software which is
429+copyrighted by the Free Software Foundation, write to the Free
430+Software Foundation; we sometimes make exceptions for this. Our
431+decision will be guided by the two goals of preserving the free status
432+of all derivatives of our free software and of promoting the sharing
433+and reuse of software generally.
434+
435+ NO WARRANTY
436+
437+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
438+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
439+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
440+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
441+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
442+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
443+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
444+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
445+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
446+
447+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
448+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
449+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
450+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
451+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
452+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
453+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
454+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
455+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
456+DAMAGES.
457+
458+ END OF TERMS AND CONDITIONS
459+
460+ How to Apply These Terms to Your New Libraries
461+
462+ If you develop a new library, and you want it to be of the greatest
463+possible use to the public, we recommend making it free software that
464+everyone can redistribute and change. You can do so by permitting
465+redistribution under these terms (or, alternatively, under the terms of the
466+ordinary General Public License).
467+
468+ To apply these terms, attach the following notices to the library. It is
469+safest to attach them to the start of each source file to most effectively
470+convey the exclusion of warranty; and each file should have at least the
471+"copyright" line and a pointer to where the full notice is found.
472+
473+ <one line to give the library's name and a brief idea of what it does.>
474+ Copyright (C) <year> <name of author>
475+
476+ This library is free software; you can redistribute it and/or
477+ modify it under the terms of the GNU Lesser General Public
478+ License as published by the Free Software Foundation; either
479+ version 2.1 of the License, or (at your option) any later version.
480+
481+ This library is distributed in the hope that it will be useful,
482+ but WITHOUT ANY WARRANTY; without even the implied warranty of
483+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
484+ Lesser General Public License for more details.
485+
486+ You should have received a copy of the GNU Lesser General Public
487+ License along with this library; if not, write to the Free Software
488+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
489+
490+Also add information on how to contact you by electronic and paper mail.
491+
492+You should also get your employer (if you work as a programmer) or your
493+school, if any, to sign a "copyright disclaimer" for the library, if
494+necessary. Here is a sample; alter the names:
495+
496+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
497+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
498+
499+ <signature of Ty Coon>, 1 April 1990
500+ Ty Coon, President of Vice
501+
502+That's all there is to it!
503+
504+
Binary files /dev/null and b/NP_ImprovedMedia/improvedmedia/greybox/g_close.gif differ
--- /dev/null
+++ b/NP_ImprovedMedia/improvedmedia/greybox/gb_scripts.js
@@ -0,0 +1,445 @@
1+var GB_CURRENT=null;
2+GB_hide=function(cb){
3+GB_CURRENT.hide(cb);
4+};
5+GreyBox=new AJS.Class({init:function(_2){
6+this.use_fx=AJS.fx;
7+this.type="page";
8+this.overlay_click_close=false;
9+this.salt=0;
10+this.root_dir=GB_ROOT_DIR;
11+this.callback_fns=[];
12+this.reload_on_close=false;
13+this.src_loader=this.root_dir+"loader_frame.html";
14+var _3=window.location.hostname.indexOf("www");
15+var _4=this.src_loader.indexOf("www");
16+if(_3!=-1&&_4==-1){
17+this.src_loader=this.src_loader.replace("://","://www.");
18+}
19+if(_3==-1&&_4!=-1){
20+this.src_loader=this.src_loader.replace("://www.","://");
21+}
22+this.show_loading=true;
23+AJS.update(this,_2);
24+},addCallback:function(fn){
25+if(fn){
26+this.callback_fns.push(fn);
27+}
28+},show:function(_6){
29+GB_CURRENT=this;
30+this.url=_6;
31+var _7=[AJS.$bytc("object"),AJS.$bytc("select")];
32+AJS.map(AJS.flattenList(_7),function(_8){
33+_8.style.visibility="hidden";
34+});
35+this.createElements();
36+return false;
37+},hide:function(cb){
38+var me=this;
39+AJS.callLater(function(){
40+var _b=me.callback_fns;
41+if(_b!=[]){
42+AJS.map(_b,function(fn){
43+fn();
44+});
45+}
46+me.onHide();
47+if(me.use_fx){
48+var _d=me.overlay;
49+AJS.fx.fadeOut(me.overlay,{onComplete:function(){
50+AJS.removeElement(_d);
51+_d=null;
52+},duration:300});
53+AJS.removeElement(me.g_window);
54+}else{
55+AJS.removeElement(me.g_window,me.overlay);
56+}
57+me.removeFrame();
58+AJS.REV(window,"scroll",_GB_setOverlayDimension);
59+AJS.REV(window,"resize",_GB_update);
60+var _e=[AJS.$bytc("object"),AJS.$bytc("select")];
61+AJS.map(AJS.flattenList(_e),function(_f){
62+_f.style.visibility="visible";
63+});
64+GB_CURRENT=null;
65+if(me.reload_on_close){
66+window.location.reload();
67+}
68+if(AJS.isFunction(cb)){
69+cb();
70+}
71+},10);
72+},update:function(){
73+this.setOverlayDimension();
74+this.setFrameSize();
75+this.setWindowPosition();
76+},createElements:function(){
77+this.initOverlay();
78+this.g_window=AJS.DIV({"id":"GB_window"});
79+AJS.hideElement(this.g_window);
80+AJS.getBody().insertBefore(this.g_window,this.overlay.nextSibling);
81+this.initFrame();
82+this.initHook();
83+this.update();
84+var me=this;
85+if(this.use_fx){
86+AJS.fx.fadeIn(this.overlay,{duration:300,to:0.7,onComplete:function(){
87+me.onShow();
88+AJS.showElement(me.g_window);
89+me.startLoading();
90+}});
91+}else{
92+AJS.setOpacity(this.overlay,0.7);
93+AJS.showElement(this.g_window);
94+this.onShow();
95+this.startLoading();
96+}
97+AJS.AEV(window,"scroll",_GB_setOverlayDimension);
98+AJS.AEV(window,"resize",_GB_update);
99+},removeFrame:function(){
100+try{
101+AJS.removeElement(this.iframe);
102+}
103+catch(e){
104+}
105+this.iframe=null;
106+},startLoading:function(){
107+this.iframe.src=this.src_loader+"?s="+this.salt++;
108+AJS.showElement(this.iframe);
109+},setOverlayDimension:function(){
110+var _11=AJS.getWindowSize();
111+if(AJS.isMozilla()||AJS.isOpera()){
112+AJS.setWidth(this.overlay,"100%");
113+}else{
114+AJS.setWidth(this.overlay,_11.w);
115+}
116+var _12=Math.max(AJS.getScrollTop()+_11.h,AJS.getScrollTop()+this.height);
117+if(_12<AJS.getScrollTop()){
118+AJS.setHeight(this.overlay,_12);
119+}else{
120+AJS.setHeight(this.overlay,AJS.getScrollTop()+_11.h);
121+}
122+},initOverlay:function(){
123+this.overlay=AJS.DIV({"id":"GB_overlay"});
124+if(this.overlay_click_close){
125+AJS.AEV(this.overlay,"click",GB_hide);
126+}
127+AJS.setOpacity(this.overlay,0);
128+AJS.getBody().insertBefore(this.overlay,AJS.getBody().firstChild);
129+},initFrame:function(){
130+if(!this.iframe){
131+var d={"name":"GB_frame","class":"GB_frame","frameBorder":0};
132+if(AJS.isIe()){
133+d.src="javascript:false;document.write(\"\");";
134+}
135+this.iframe=AJS.IFRAME(d);
136+this.middle_cnt=AJS.DIV({"class":"content"},this.iframe);
137+this.top_cnt=AJS.DIV();
138+this.bottom_cnt=AJS.DIV();
139+AJS.ACN(this.g_window,this.top_cnt,this.middle_cnt,this.bottom_cnt);
140+}
141+},onHide:function(){
142+},onShow:function(){
143+},setFrameSize:function(){
144+},setWindowPosition:function(){
145+},initHook:function(){
146+}});
147+_GB_update=function(){
148+if(GB_CURRENT){
149+GB_CURRENT.update();
150+}
151+};
152+_GB_setOverlayDimension=function(){
153+if(GB_CURRENT){
154+GB_CURRENT.setOverlayDimension();
155+}
156+};
157+AJS.preloadImages(GB_ROOT_DIR+"indicator.gif");
158+script_loaded=true;
159+var GB_SETS={};
160+function decoGreyboxLinks(){
161+var as=AJS.$bytc("a");
162+AJS.map(as,function(a){
163+if(a.getAttribute("href")&&a.getAttribute("rel")){
164+var rel=a.getAttribute("rel");
165+if(rel.indexOf("gb_")==0){
166+var _17=rel.match(/\w+/)[0];
167+var _18=rel.match(/\[(.*)\]/)[1];
168+var _19=0;
169+var _1a={"caption":a.title||"","url":a.href};
170+if(_17=="gb_pageset"||_17=="gb_imageset"){
171+if(!GB_SETS[_18]){
172+GB_SETS[_18]=[];
173+}
174+GB_SETS[_18].push(_1a);
175+_19=GB_SETS[_18].length;
176+}
177+if(_17=="gb_pageset"){
178+a.onclick=function(){
179+GB_showFullScreenSet(GB_SETS[_18],_19);
180+return false;
181+};
182+}
183+if(_17=="gb_imageset"){
184+a.onclick=function(){
185+GB_showImageSet(GB_SETS[_18],_19);
186+return false;
187+};
188+}
189+if(_17=="gb_image"){
190+a.onclick=function(){
191+GB_showImage(_1a.caption,_1a.url);
192+return false;
193+};
194+}
195+if(_17=="gb_page"){
196+a.onclick=function(){
197+var sp=_18.split(/, ?/);
198+GB_show(_1a.caption,_1a.url,parseInt(sp[1]),parseInt(sp[0]));
199+return false;
200+};
201+}
202+if(_17=="gb_page_fs"){
203+a.onclick=function(){
204+GB_showFullScreen(_1a.caption,_1a.url);
205+return false;
206+};
207+}
208+if(_17=="gb_page_center"){
209+a.onclick=function(){
210+var sp=_18.split(/, ?/);
211+GB_showCenter(_1a.caption,_1a.url,parseInt(sp[1]),parseInt(sp[0]));
212+return false;
213+};
214+}
215+}
216+}
217+});
218+}
219+AJS.AEV(window,"load",decoGreyboxLinks);
220+GB_showImage=function(_1d,url,_1f){
221+var _20={width:300,height:300,type:"image",fullscreen:false,center_win:true,caption:_1d,callback_fn:_1f};
222+var win=new GB_Gallery(_20);
223+return win.show(url);
224+};
225+GB_showPage=function(_22,url,_24){
226+var _25={type:"page",caption:_22,callback_fn:_24,fullscreen:true,center_win:false};
227+var win=new GB_Gallery(_25);
228+return win.show(url);
229+};
230+GB_Gallery=GreyBox.extend({init:function(_27){
231+this.parent({});
232+this.img_close=this.root_dir+"g_close.gif";
233+AJS.update(this,_27);
234+this.addCallback(this.callback_fn);
235+},initHook:function(){
236+AJS.addClass(this.g_window,"GB_Gallery");
237+var _28=AJS.DIV({"class":"inner"});
238+this.header=AJS.DIV({"class":"GB_header"},_28);
239+AJS.setOpacity(this.header,0);
240+AJS.getBody().insertBefore(this.header,this.overlay.nextSibling);
241+var _29=AJS.TD({"id":"GB_caption","class":"caption","width":"40%"},this.caption);
242+var _2a=AJS.TD({"id":"GB_middle","class":"middle","width":"20%"});
243+var _2b=AJS.IMG({"src":this.img_close});
244+AJS.AEV(_2b,"click",GB_hide);
245+var _2c=AJS.TD({"class":"close","width":"40%"},_2b);
246+var _2d=AJS.TBODY(AJS.TR(_29,_2a,_2c));
247+var _2e=AJS.TABLE({"cellspacing":"0","cellpadding":0,"border":0},_2d);
248+AJS.ACN(_28,_2e);
249+if(this.fullscreen){
250+AJS.AEV(window,"scroll",AJS.$b(this.setWindowPosition,this));
251+}else{
252+AJS.AEV(window,"scroll",AJS.$b(this._setHeaderPos,this));
253+}
254+},setFrameSize:function(){
255+var _2f=this.overlay.offsetWidth;
256+var _30=AJS.getWindowSize();
257+if(this.fullscreen){
258+this.width=_2f-40;
259+this.height=_30.h-80;
260+}
261+AJS.setWidth(this.iframe,this.width);
262+AJS.setHeight(this.iframe,this.height);
263+AJS.setWidth(this.header,_2f);
264+},_setHeaderPos:function(){
265+AJS.setTop(this.header,AJS.getScrollTop()+10);
266+},setWindowPosition:function(){
267+var _31=this.overlay.offsetWidth;
268+var _32=AJS.getWindowSize();
269+AJS.setLeft(this.g_window,((_31-50-this.width)/2));
270+var _33=AJS.getScrollTop()+55;
271+if(!this.center_win){
272+AJS.setTop(this.g_window,_33);
273+}else{
274+var fl=((_32.h-this.height)/2)+20+AJS.getScrollTop();
275+if(fl<0){
276+fl=0;
277+}
278+if(_33>fl){
279+fl=_33;
280+}
281+AJS.setTop(this.g_window,fl);
282+}
283+this._setHeaderPos();
284+},onHide:function(){
285+AJS.removeElement(this.header);
286+AJS.removeClass(this.g_window,"GB_Gallery");
287+},onShow:function(){
288+if(this.use_fx){
289+AJS.fx.fadeIn(this.header,{to:1});
290+}else{
291+AJS.setOpacity(this.header,1);
292+}
293+}});
294+AJS.preloadImages(GB_ROOT_DIR+"g_close.gif");
295+GB_showFullScreenSet=function(set,_36,_37){
296+var _38={type:"page",fullscreen:true,center_win:false};
297+var _39=new GB_Sets(_38,set);
298+_39.addCallback(_37);
299+_39.showSet(_36-1);
300+return false;
301+};
302+GB_showImageSet=function(set,_3b,_3c){
303+var _3d={type:"image",fullscreen:false,center_win:true,width:300,height:300};
304+var _3e=new GB_Sets(_3d,set);
305+_3e.addCallback(_3c);
306+_3e.showSet(_3b-1);
307+return false;
308+};
309+GB_Sets=GB_Gallery.extend({init:function(_3f,set){
310+this.parent(_3f);
311+if(!this.img_next){
312+this.img_next=this.root_dir+"next.gif";
313+}
314+if(!this.img_prev){
315+this.img_prev=this.root_dir+"prev.gif";
316+}
317+this.current_set=set;
318+},showSet:function(_41){
319+this.current_index=_41;
320+var _42=this.current_set[this.current_index];
321+this.show(_42.url);
322+this._setCaption(_42.caption);
323+this.btn_prev=AJS.IMG({"class":"left",src:this.img_prev});
324+this.btn_next=AJS.IMG({"class":"right",src:this.img_next});
325+AJS.AEV(this.btn_prev,"click",AJS.$b(this.switchPrev,this));
326+AJS.AEV(this.btn_next,"click",AJS.$b(this.switchNext,this));
327+GB_STATUS=AJS.SPAN({"class":"GB_navStatus"});
328+AJS.ACN(AJS.$("GB_middle"),this.btn_prev,GB_STATUS,this.btn_next);
329+this.updateStatus();
330+},updateStatus:function(){
331+AJS.setHTML(GB_STATUS,(this.current_index+1)+" / "+this.current_set.length);
332+if(this.current_index==0){
333+AJS.addClass(this.btn_prev,"disabled");
334+}else{
335+AJS.removeClass(this.btn_prev,"disabled");
336+}
337+if(this.current_index==this.current_set.length-1){
338+AJS.addClass(this.btn_next,"disabled");
339+}else{
340+AJS.removeClass(this.btn_next,"disabled");
341+}
342+},_setCaption:function(_43){
343+AJS.setHTML(AJS.$("GB_caption"),_43);
344+},updateFrame:function(){
345+var _44=this.current_set[this.current_index];
346+this._setCaption(_44.caption);
347+this.url=_44.url;
348+this.startLoading();
349+},switchPrev:function(){
350+if(this.current_index!=0){
351+this.current_index--;
352+this.updateFrame();
353+this.updateStatus();
354+}
355+},switchNext:function(){
356+if(this.current_index!=this.current_set.length-1){
357+this.current_index++;
358+this.updateFrame();
359+this.updateStatus();
360+}
361+}});
362+AJS.AEV(window,"load",function(){
363+AJS.preloadImages(GB_ROOT_DIR+"next.gif",GB_ROOT_DIR+"prev.gif");
364+});
365+GB_show=function(_45,url,_47,_48,_49){
366+var _4a={caption:_45,height:_47||500,width:_48||500,fullscreen:false,callback_fn:_49};
367+var win=new GB_Window(_4a);
368+return win.show(url);
369+};
370+GB_showCenter=function(_4c,url,_4e,_4f,_50){
371+var _51={caption:_4c,center_win:true,height:_4e||500,width:_4f||500,fullscreen:false,callback_fn:_50};
372+var win=new GB_Window(_51);
373+return win.show(url);
374+};
375+GB_showFullScreen=function(_53,url,_55){
376+var _56={caption:_53,fullscreen:true,callback_fn:_55};
377+var win=new GB_Window(_56);
378+return win.show(url);
379+};
380+GB_Window=GreyBox.extend({init:function(_58){
381+this.parent({});
382+this.img_header=this.root_dir+"header_bg.gif";
383+this.img_close=this.root_dir+"w_close.gif";
384+this.show_close_img=true;
385+AJS.update(this,_58);
386+this.addCallback(this.callback_fn);
387+},initHook:function(){
388+AJS.addClass(this.g_window,"GB_Window");
389+this.header=AJS.TABLE({"class":"header"});
390+this.header.style.backgroundImage="url("+this.img_header+")";
391+var _59=AJS.TD({"class":"caption"},this.caption);
392+var _5a=AJS.TD({"class":"close"});
393+if(this.show_close_img){
394+var _5b=AJS.IMG({"src":this.img_close});
395+var _5c=AJS.SPAN("Close");
396+var btn=AJS.DIV(_5b,_5c);
397+AJS.AEV([_5b,_5c],"mouseover",function(){
398+AJS.addClass(_5c,"on");
399+});
400+AJS.AEV([_5b,_5c],"mouseout",function(){
401+AJS.removeClass(_5c,"on");
402+});
403+AJS.AEV([_5b,_5c],"mousedown",function(){
404+AJS.addClass(_5c,"click");
405+});
406+AJS.AEV([_5b,_5c],"mouseup",function(){
407+AJS.removeClass(_5c,"click");
408+});
409+AJS.AEV([_5b,_5c],"click",GB_hide);
410+AJS.ACN(_5a,btn);
411+}
412+tbody_header=AJS.TBODY();
413+AJS.ACN(tbody_header,AJS.TR(_59,_5a));
414+AJS.ACN(this.header,tbody_header);
415+AJS.ACN(this.top_cnt,this.header);
416+if(this.fullscreen){
417+AJS.AEV(window,"scroll",AJS.$b(this.setWindowPosition,this));
418+}
419+},setFrameSize:function(){
420+if(this.fullscreen){
421+var _5e=AJS.getWindowSize();
422+overlay_h=_5e.h;
423+this.width=Math.round(this.overlay.offsetWidth-(this.overlay.offsetWidth/100)*10);
424+this.height=Math.round(overlay_h-(overlay_h/100)*10);
425+}
426+AJS.setWidth(this.header,this.width+6);
427+AJS.setWidth(this.iframe,this.width);
428+AJS.setHeight(this.iframe,this.height);
429+},setWindowPosition:function(){
430+var _5f=AJS.getWindowSize();
431+AJS.setLeft(this.g_window,((_5f.w-this.width)/2)-13);
432+if(!this.center_win){
433+AJS.setTop(this.g_window,AJS.getScrollTop());
434+}else{
435+var fl=((_5f.h-this.height)/2)-20+AJS.getScrollTop();
436+if(fl<0){
437+fl=0;
438+}
439+AJS.setTop(this.g_window,fl);
440+}
441+}});
442+AJS.preloadImages(GB_ROOT_DIR+"w_close.gif",GB_ROOT_DIR+"header_bg.gif");
443+
444+
445+script_loaded=true;
\ No newline at end of file
--- /dev/null
+++ b/NP_ImprovedMedia/improvedmedia/greybox/gb_styles.css
@@ -0,0 +1,148 @@
1+/* Last-Modified: 28/06/06 00:08:22 */
2+#GB_overlay {
3+ background-color: #000;
4+ position: absolute;
5+ margin: auto;
6+ top: 0;
7+ left: 0;
8+ z-index: 100;
9+}
10+
11+#GB_window {
12+ left: 0;
13+ top: 0;
14+ font-size: 1px;
15+ position: absolute;
16+ overflow: visible;
17+ z-index: 150;
18+}
19+
20+#GB_window .content {
21+ width: auto;
22+ margin: 0;
23+ padding: 0;
24+}
25+
26+#GB_frame {
27+ border: 0;
28+ margin: 0;
29+ padding: 0;
30+ overflow: auto;
31+ white-space: nowrap;
32+}
33+
34+
35+.GB_Gallery {
36+ margin: 0 22px 0 22px;
37+}
38+
39+.GB_Gallery .content {
40+ background-color: #fff;
41+ border: 3px solid #ddd;
42+}
43+
44+.GB_header {
45+ top: 10px;
46+ left: 0;
47+ margin: 0;
48+ z-index: 500;
49+ position: absolute;
50+ border-bottom: 2px solid #555;
51+ border-top: 2px solid #555;
52+}
53+
54+.GB_header .inner {
55+ background-color: #333;
56+ font-family: Arial, Verdana, sans-serif;
57+ padding: 2px 20px 2px 20px;
58+}
59+
60+.GB_header table {
61+ margin: 0;
62+ width: 100%;
63+ border-collapse: collapse;
64+}
65+
66+.GB_header .caption {
67+ text-align: left;
68+ color: #eee;
69+ white-space: nowrap;
70+ font-size: 20px;
71+}
72+
73+.GB_header .close {
74+ text-align: right;
75+}
76+
77+.GB_header .close img {
78+ z-index: 500;
79+ cursor: pointer;
80+}
81+
82+.GB_header .middle {
83+ white-space: nowrap;
84+ text-align: center;
85+}
86+
87+
88+#GB_middle {
89+ color: #eee;
90+}
91+
92+#GB_middle img {
93+ cursor: pointer;
94+ vertical-align: middle;
95+}
96+
97+#GB_middle .disabled {
98+ cursor: default;
99+}
100+
101+#GB_middle .left {
102+ padding-right: 10px;
103+}
104+
105+#GB_middle .right {
106+ padding-left: 10px;
107+}
108+
109+
110+.GB_Window .content {
111+ background-color: #fff;
112+ border: 3px solid #ccc;
113+ border-top: none;
114+}
115+
116+.GB_Window .header {
117+ border-bottom: 1px solid #aaa;
118+ border-top: 1px solid #999;
119+ border-left: 3px solid #ccc;
120+ border-right: 3px solid #ccc;
121+ margin: 0;
122+
123+ height: 22px;
124+ font-size: 12px;
125+ padding: 3px 0;
126+ color: #333;
127+}
128+
129+.GB_Window .caption {
130+ font-size: 12px;
131+ text-align: left;
132+ font-weight: bold;
133+ white-space: nowrap;
134+ padding-right: 20px;
135+}
136+
137+.GB_Window .close { text-align: right; }
138+.GB_Window .close span {
139+ font-size: 12px;
140+ cursor: pointer;
141+}
142+.GB_Window .close img {
143+ cursor: pointer;
144+ padding: 0 3px 0 0;
145+}
146+
147+.GB_Window .on { border-bottom: 1px solid #333; }
148+.GB_Window .click { border-bottom: 1px solid red; }
Binary files /dev/null and b/NP_ImprovedMedia/improvedmedia/greybox/header_bg.gif differ
--- /dev/null
+++ b/NP_ImprovedMedia/improvedmedia/greybox/index.html
@@ -0,0 +1,11 @@
1+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2+<html xmlns="http://www.w3.org/1999/xhtml">
3+<head>
4+ <title>Nothing Here</title>
5+</head>
6+<body>
7+
8+<h1>Nothing to see here</h1>
9+
10+</body>
11+</html>
\ No newline at end of file
Binary files /dev/null and b/NP_ImprovedMedia/improvedmedia/greybox/indicator.gif differ
--- /dev/null
+++ b/NP_ImprovedMedia/improvedmedia/greybox/loader_frame.html
@@ -0,0 +1,104 @@
1+<!--
2+Notice: I feel so dirty doing this, but its the only way to make it cross browser.
3+-->
4+<html>
5+<head>
6+ <script>
7+ var GB = parent.GB_CURRENT;
8+ document.write('<script type="text/javascript" src="AJS.js"><\/script>');
9+ if(GB.use_fx) {
10+ document.write('<script type="text/javascript" src="AJS_fx.js"><\/script>');
11+ }
12+ </script>
13+ <style>
14+ body {
15+ padding: 0;
16+ margin: 0;
17+ overflow: hidden;
18+ }
19+
20+ #GB_frame {
21+ visibility: hidden;
22+ width: 100%;
23+ height: 100%;
24+ }
25+
26+ #loading {
27+ padding-top: 50px;
28+ position: absolute;
29+ width: 100%;
30+ top: 0;
31+ text-align: center;
32+ vertical-align: middle;
33+ }
34+ </style>
35+</head>
36+<body>
37+
38+<div id="loading">
39+ <img src="indicator.gif">
40+</div>
41+
42+<script>
43+var loading = AJS.$('loading');
44+var gb_type = GB.type;
45+var gb_url = GB.url;
46+
47+//Start loading in the iframe
48+if(gb_type == "page") {
49+ document.write('<iframe id="GB_frame" src="' + gb_url + '" frameborder="0"></iframe>');
50+}
51+else {
52+ var img_holder = new Image();
53+ img_holder.src = gb_url;
54+ document.write('<img id="GB_frame" src="' + gb_url + '">');
55+}
56+var frame = AJS.$('GB_frame');
57+</script>
58+
59+</body>
60+<script>
61+function setupOuterGB() {
62+ frame.style.visibility = 'visible';
63+ GB.setFrameSize();
64+ GB.setWindowPosition();
65+}
66+
67+function loaded() {
68+ AJS.removeElement(loading);
69+
70+ GB.overlay.innerHTML += "&nbsp;"; //Safari bugfix
71+
72+ if(gb_type == "image") {
73+ if(img_holder.width != 0 && img_holder.height != 0) {
74+ var width = img_holder.width;
75+ var height = img_holder.height;
76+
77+ GB.width = width;
78+ GB.height = height;
79+
80+ setupOuterGB();
81+
82+ if(GB.use_fx) {
83+ AJS.setOpacity(frame, 0);
84+ AJS.fx.fadeIn(frame);
85+ }
86+ }
87+ }
88+ else {
89+ GB.width = frame.offsetWidth;
90+ GB.height = frame.offsetHeight;
91+ setupOuterGB();
92+ }
93+}
94+
95+if(GB.show_loading) {
96+ AJS.AEV(window, 'load', function(e) {
97+ loaded();
98+ });
99+}
100+else {
101+ loaded();
102+}
103+</script>
104+</html>
Binary files /dev/null and b/NP_ImprovedMedia/improvedmedia/greybox/next.gif differ
Binary files /dev/null and b/NP_ImprovedMedia/improvedmedia/greybox/prev.gif differ
Binary files /dev/null and b/NP_ImprovedMedia/improvedmedia/greybox/w_close.gif differ
--- /dev/null
+++ b/NP_ImprovedMedia/improvedmedia/help.html
@@ -0,0 +1,465 @@
1+<!--
2+/**
3+ * ImprovedMedia plugin for Nucleus CMS
4+ * Version 3.0.1
5+ * Written By Mocchi, Feb.28, 2010
6+ *
7+ * This program is free software; you can redistribute it and/or
8+ * modify it under the terms of the GNU General Public License
9+ * as published by the Free Software Foundation; either version 3
10+ * of the License, or (at your option) any later version.
11+ */
12+-->
13+<h3>目次</h3>
14+<ul>
15+<li><a href="#chapter1">プラグインの概要</a></li>
16+<li><a href="#chapter2">サポートとバグ報告</a></li>
17+<li><a href="#chapter3">インストール</a></li>
18+<li><a href="#chapter4">アンインストール</a></li>
19+<li><a href="#chapter5">他のプラグインとの競合</a></li>
20+<li><a href="#chapter6">使用上の注意</a></li>
21+<li><a href="#chapter7">スキン変数の実装</a></li>
22+<li><a href="#chapter8">オプションの解説</a></li>
23+<li><a href="#chapter9">グローバル設定の日付の付加による動作の違い</a></li>
24+<li><a href="#chapter10">それぞれのウェブログがある個別ディレクトリでのファイル管理について</a></li>
25+<li><a href="#chapter11">イベントの発生</a></li>
26+<li><a href="#chapter12">バージョン履歴</a></li>
27+<li><a href="#chapter13">動作の仕組み</a></li>
28+</ul>
29+
30+<h3 id="chapter1">プラグインの概要</h3>
31+<p>このプラグインは、Nucleusのmedia.phpという、ファイルの記事への挿入やアップロードを行うプログラムを改良し、プラグインとして利用しやすくしたものです。
32+<a href="http://orangoo.com/" title="外部リンク: Orangoo projects">Orangoo projects</a>の<a href="http://orangoo.com/labs/GreyBox/" title="外部リンク: GreyBox">GreyBox</a> (ver.5.54) を、<a href="http://www.gnu.org/licenses/lgpl-2.1.html" title="外部リンク: GNU LESSER GENERAL PUBLIC LICENSE Version 2.1">LGPL ver.2.1</a>のもと、同梱しています。</p>
33+<p>機能は以下です</p>
34+<ol>
35+<li>アップロード、記事への挿入、ファイル名の変更そして削除、サブディレクトリの作成・削除・名前変更を行う事ができます。</li>
36+<li>media.phpのNucleus Mediaウィンドウから、インターフェースを改良してあります。</li>
37+<li>ファイルの挿入時は、代替テキストの入力を必須としました。これはアクセシビリティの観点に拠ります。</li>
38+<li>プライベート・コレクション・ディレクトリ機能をオン・オフして、共有ディレクトリのみによる運用ができます。</li>
39+<li>オプションで指定することにより、<a href="http://japan.nucleuscms.org/wiki/plugins:eachblogdir" title="Nucleus CMS WIKI - NP_EachBlogDir">NP_EachBlogDir</a>で提供していた機能を利用することができます。</li>
40+</ol>
41+
42+<h3 id="chapter2">サポートとバグ報告</h3>
43+<p><a href="http://japan.nucleuscms.org/bb/viewtopic.php?p=17374" title="NP_ImprovedMedia &lt; プラグイン全般 &lt; Nucleus(JP)フォーラム Forum Index">サポートフォーラム</a>において行います。
44+このヘルプの最新は、<a href="http://japan.nucleuscms.org/wiki/plugins:improvedmedia" title="NP_ImprovedMedia">NP_ImprovedMedia - Nucleus CMS WIKI</a>で参照することができます。</p>
45+
46+<h3 id="chapter3">インストール</h3>
47+<ol>
48+<li>圧縮フォルダを展開し、内容物をPLUGINフォルダにコピー。</li>
49+<li>Nucleusにログインし、「管理ホーム」から、「プラグイン管理」の画面に移動。</li>
50+<li>画面下部の「新しいプラグインをインストール」で、「ImprovedMedia」を選択し、「プラグインのインストール」ボタンをクリック。</li>
51+<li>「プラグインの管理」画面の「インストール済み」のリストに表示されているのを確認します。</li>
52+<li>リスト右の「編集」で、オプションを変更することができます。</li>
53+<li>通常どおり、アイテムの編集画面で外部ファイルを呼び出すボタンをクリックすると、ファイルのアップロード画面が開きます。ファイルのアップロードが成功すると、記事への埋め込みを行う画面となります。</li>
54+</ol>
55+
56+<h3 id="chapter4">アンインストール</h3>
57+<p>オプションデータを持ちますが、そのままプラグイン管理で削除すれば、きれいになくなります。</p>
58+
59+<h3 id="chapter5">他のプラグインとの競合</h3>
60+<p>NP_ImageManager、NP_EachBlogDir、NP_Mediatocuと同時に使う事はできません。その他のプラグインは、おそらく大丈夫だと思います。</p>
61+
62+<h3 id="chapter6">使用上の注意</h3>
63+<ul>
64+<li>ユーザがログアウト状態である時は、ログイン画面を表示します。再度ログインすることで、機能を利用できます。</li>
65+<li>Media Controlウィンドウは呼び出されたウェブログ情報を保持しているので、もしもユーザがウェブログ・チームに所属しておらず、最高管理権限も持っていない場合は、エラー画面を表示します。</li>
66+<li>代替テキストは40文字に制限されています。英数字でも記号でも日本語でも構いません。</li>
67+<li>ファイル名変更時に、拡張子を変更する事はできません。</li>
68+<li>変更後のファイル名は30文字に制限されています。使用できる文字種は、英数字と3種類の記号(ハイフンマイナス、アンダースコア、プラス)です。</li>
69+<li>ファイルを削除するときは、ほんとうに削除していいのか、少し考える時間を設けるとよいでしょう。</li>
70+<li>サブ・ディレクトリの名前は20文字に制限されています。使用できる文字種は、英数字と3種類の記号(ハイフンマイナス、アンダースコア、プラス)です。</li>
71+<li>サブ・ディレクトリを削除すると、その中に保存されているファイルも削除されます。ほんとうに削除していいのか、少し考える時間を設けるとよいでしょう。</li>
72+<li>プライベート・コレクション・ディレクトリ、共有コレクション・ディレクトリをとわず、コレクション・ディレクトリは削除できません。</li>
73+</ul>
74+
75+<h3 id="chapter7">スキン変数の実装</h3>
76+<p>スキンに変数を記述することで、スキンから機能を呼び出すことができます。以下の2つの記述を、スキンに追加してください。
77+なお、テンプレートからの呼び出しはサポートしていません。</p>
78+
79+<h4>&lt;head&gt;&lt;/head&gt;要素内</h4>
80+<pre>
81+&lt;%if(hasplugin,ImprovedMedia)%&gt;
82+&lt;%ImprovedMedia(head)%&gt;
83+&lt;%endif%&gt;</pre>
84+
85+<h4>&lt;body&gt;&lt;/body&gt;要素内</h4>
86+<pre>&lt;%if(hasplugin,ImprovedMedia)%&gt;
87+&lt;%ImprovedMedia(anchor)%&gt;
88+&lt;%endif%&gt;</pre>
89+
90+<p>すると、&lt;%ImprovedMedia(anchor)%&gt;を追加したところにアンカー「ファイル管理」が出現します。
91+このアンカーをクリックすることで、機能の呼び出しをすることができます。
92+なお、こうして呼び出されたMedia Controlは、ファイルの一覧画面をデフォルトで表示します。またボタン「文書に挿入」を持たず、ファイルのアップロード・削除・ファイル名の変更とサブディレクトリ管理のみ利用できます。</p>
93+
94+<h3 id="chapter8">オプションの解説</h3>
95+<p>以下の4つのオプションを持ちます。</p>
96+<h4>プライベート・コレクションのオン・オフ。</h4>
97+<p>デフォルトでは、Nucleusインストール時と同様に、プライベート・コレクション・ディレクトリ機能がオンとなっています。
98+オフにすることで、メンバー間の共有ディレクトリの使用を徹底することができます。<br />
99+なお、メディア・ディレクトリに子ディレクトリ(このプラグインでは、コレクション・ディレクトリと呼んでいます)が作成されていない状態でこの機能をオフにすると、エラーとなります。
100+その場合は、FTPソフトかサーバ提供環境でディレクトリを作成してください。</p>
101+
102+<h4>Media Controlページに表示するファイル数</h4>
103+<p>表示ファイル数を5件から50件の間で指定できます。</p>
104+
105+<h4>GreyBoxユーティリティの利用</h4>
106+<p>GreyBoxの提供する効果によってMedia Controlを開くオプションを追加しています。
107+このオプションを利用しない方は、このプラグインの構成ファイルのうち、ディレクトリ「greybox」を削除するとよいでしょう。</p>
108+
109+<h4>それぞれのウェブログがある個別ディレクトリでのファイル管理</h4>
110+<p><a href="http://japan.nucleuscms.org/wiki/plugins:eachblogdir" title="Nucleus CMS WIKI - NP_EachBlogDir">NP_EachBlogDir</a>で提供していた、それぞれのウェブログがある個別ディレクトリでのファイル管理機能を利用することができます。
111+このオプションは、アップロードしてブログで利用するファイルが、そのブログに属している状態を作り出します。詳しくはこのヘルプの<a href="#chapter9" title="それぞれのウェブログがある個別ディレクトリでのファイル管理について">それぞれのウェブログがある個別ディレクトリでのファイル管理について</a>を参照してください。</p>
112+
113+<h3 id="chapter9">グローバル設定の日付の付加による動作の違い</h3>
114+<p>Nucleusのグローバル設定にある「アップロードするファイル名の頭に日付を付加する」オプションにより
115+一覧画面での日付とファイル名の表示およびファイル名変更時の動作が異なります。</p>
116+<p>「はい」のとき</p>
117+<ul>
118+<li>一覧画面での日付の表示は、「登録日」となり、ファイルの先頭に追加されている日付が入ります。</li>
119+<li>一覧画面でのファイル名の表示は、先頭の日付を取り去ったものとなります。</li>
120+<li>ファイル名変更時に、ファイル名の先頭に日付(数字8桁)+ハイフンがついていないファイルは、そのファイルの最終更新日を先頭に追加します。</li>
121+<li>一覧画面でのファイルの並びは、先頭に付加されている日付を含めたファイル名の降順です。</li>
122+</ul>
123+<p>「いいえ」のとき</p>
124+<ul>
125+<li>一覧画面での日付の表示は、「更新日」となります。</li>
126+<li>一覧画面でのファイル名の表示は、ファイル名そのままとなります。</li>
127+<li>ファイル名変更時に、ファイル名の先頭に日付を付加する事はありません。</li>
128+<li>一覧画面でのファイルの並びは、ファイルの最終更新日の降順です。</li>
129+</ul>
130+
131+<h3 id="chapter10">それぞれのウェブログがある個別ディレクトリでのファイル管理について</h3>
132+
133+<p>複数ウェブログを以下のようなディレクトリ構成で運用する事で、アップロードしたファイルがウェブログに属し、ウェブログ管理チームに所属しているユーザのみ、そのファイルを利用することができるようにします。</p>
134+
135+<pre>
136+Nucleus CMS
137+Nucleus Admin : /(Document Root)/nucleus/
138+
139+Blog1(ShortName1, Default)
140+Weblog Path: /(Document Root)/index.php
141+Media DIR : /(Document Root)/media/
142+
143+Blog2(ShortName2)
144+Weblog Path: /(Document Root)/(shortname2)/index.php
145+Media DIR : /(Document Root)/(shortname2)/media/
146+
147+Blog3(ShortName3)
148+Weblog Path: /(Document Root)/(shortname3)/index.php
149+Media DIR : /(Document Root)/(shortname3)/media/
150+
151+Blog4(ShortName4)
152+...
153+</pre>
154+
155+<p>なお、メディア・ディレクトリの名前は任意ですが、どのウェブログのディレクトリでも共通の名前にしてください。PHPスクリプト・ファイルの名前は、index.phpでなくとも構いません。</p>
156+
157+<p>具体的に言うと、管理領域(Nucleusディレクトリ)と同じ階層に、各ウェブログの短縮名のディレクトリを作成し、その中にPHPファイルとメディアディレクトリを配置。
158+このようにしたときに、プラグイン内の改造を加えたmedia.phpが、それぞれのウェブログにおかれたメディアディレクトリを参照します。
159+また、ウェブログが表示されたときに、アイテムに埋め込まれたファイルへのパスが通るようにします。</p>
160+
161+<p>新規のウェブログの設置方法</p>
162+<ol>
163+<li>新規に作成するウェブログの短縮名を決めます。</li>
164+<li>Nucleusがインストールされているディレクトリと同じ階層に、その短縮名のディレクトリを作成。</li>
165+<li>短縮名のディレクトリの中に、メディアディレクトリを作成します。ディレクトリの名前は、あなたがconfig.phpに記述したメディアディレクトリと同一の名前にしてください。</li>
166+<li>Nucleusにログインし、「新規Blog作成」をクリック。</li>
167+<li>各種項目を入力しますが、「Blogの短縮名」は、先ほど決めたものにします。</li>
168+<li>ボタン「Blogを作成」をクリック。</li>
169+<li>次の画面に表示される「方法1」のスクリプトをコピーし、テキストエディタを開いて貼り付け。</li>
170+<li>テキストファイルの書き換えを行います。include('../config.php')</li>
171+<li>テキストファイルはphpファイルとして、先ほど作成したディレクトリに保存。</li>
172+<li>「URL」を変更します。「(Document Root)/短縮名のディレクトリ/テキストファイルのファイル名」</li>
173+<li>「作成!」をクリック。新規ウェブログを作成します。</li>
174+<li>これまでの設定に不備があっても、「管理ホーム」のウェブログそれぞれの「設定」から修正することができます。</li>
175+<li>通常通り、「アイテムの追加」「アイテムの編集/削除」、スキンから誘導される「アイテムの編集」で使うことができます。</li>
176+</ol>
177+
178+<p>アンインストールの際、プラグインはそっくりなくなるのですが、このプラグインを利用して作成したアイテムにおいて、MEDIAファイルへのアンカー切れが発生します。
179+その時は、それぞれのMEDIAディレクトリの内容をコレクション・ディレクトリごとコピーし、config.phpに書いた$DIR_MEDIAへ移動してください。アンカーが回復します。</p>
180+
181+<p>メディアディレクトリの名前は、すべて統一されたものにしてください。
182+たとえば、あなたがconfig.phpに記述したメディアディレクトリの名前が「media」なら、
183+それぞれのウェブログのフォルダにあるメディアディレクトリも、同じように「media」ディレクトリとしてください。</p>
184+
185+<h3 id="chapter11">イベントの発生</h3>
186+<p>すでにアップロードされているメディア・ファイルの名前を変更する前後、削除する前後にイベントを発生します。それぞれ、「PreMediaRename」、「PostMediaRename」、「PreMediaErase」、「PostMediaErase」です。
187+また、コレクション・ディレクトリにサブ・ディレクトリを作成する前後、サブ・ディレクトリの名前を変更する前後、サブ・ディレクトリを削除する前後にもイベントを発生します。
188+それぞれ、「PreSubdirCreate」、「PostSubdirCreate」、「PreSubdirRename」、「PostSubdirRename」、「PreSubdirRemove」、「PostSubdirRemove」です。
189+Nucleus CMSのバージョン3.3以降では、メディア・ファイルをアップロードする前後のイベント「PreMediaUpload」と「PostMediaUpload」を、コアが提供しています。</p>
190+<p>なお、<a href="http://japan.nucleuscms.org/wiki/plugins:actionlogplus" title="NP_ActionLogPlus - Nucleus CMS WIKI">NP_ActionLogPlus</a>をこのプラグインと一緒に利用している場合、外部ファイルに関する履歴に「ファイル削除」と「ファイル名変更」、「サブ・ディレクトリの作成」、「サブ・ディレクトリの名前変更」、「サブ・ディレクトリの削除」が加わります。このプラグインが発生するイベント「PostRenameMedia」と「PostDeleteMedia」、「PostSubdirCreate」、「PostSubdirRename」、「PostSubdirRemove」をキャッチするからです。このプラグインは「PostMediaUpload」もキャッチします。</p>
191+
192+
193+<table frame="box" rules="all" summary="プラグインNP_ImprovedMediaが発生するイベント">
194+<thead>
195+<tr>
196+<th>名前</th>
197+<th>いつ</th>
198+<th>パラメータ</th>
199+</tr>
200+</thead>
201+<tbody>
202+<tr>
203+<td>PreMediaUpload</td>
204+<td>(Nucleus CMSのバージョン3.3以降)選択したメディア・ファイルがアップロードされる前</td>
205+<td><dl>
206+<dt class="ro">collection</dt>
207+<dd>(参照渡し)アップロードするメディア・ファイルが保存されるコレクション・ディレクトリ</dd>
208+<dt class="ref">uploadfile</dt>
209+<dd>(値渡し)アップロードするメディア・ファイルがサーバ上で一時的に保存されているファイルの名前</dd>
210+<dt class="ro">filename</dt>
211+<dd>(参照渡し)アップロードした後のファイル名</dd>
212+</dl></td>
213+</tr>
214+<tr>
215+<td>PostMediaUpload</td>
216+<td>(Nucleus CMSのバージョン3.3以降)選択したメディア・ファイルがアップロードされた後</td>
217+<td><dl>
218+<dt class="ref">collection</dt>
219+<dd>(値渡し)選択したメディア・ファイルが保存されたコレクション・ディレクトリ</dd>
220+<dt class="ref">mediadir</dt>
221+<dd>(値渡し)アップロードしたメディア・ファイルが保存されたコレクション・ディレクトリのサーバにおけるパス</dd>
222+<dt class="ref">filename</dt>
223+<dd>(値渡し)アップロードした後のファイル名</dd>
224+</dl></td>
225+</tr>
226+<tr>
227+<td>PreRenameMedia</td>
228+<td>選択したメディア・ファイルのファイル名が変更される前</td>
229+<td><dl>
230+<dt class="ref">collection</dt>
231+<dd>(値渡し)選択したメディア・ファイルが保存されているコレクション・ディレクトリ</dd>
232+<dt class="ref">oldfilename</dt>
233+<dd>(値渡し)選択したメディア・ファイルの以前のファイル名</dd>
234+<dt class="ref">newfilename</dt>
235+<dd>(値渡し)選択したメディア・ファイルの現在のファイル名</dd>
236+</dl></td>
237+</tr>
238+<tr>
239+<td>PostRenameMedia</td>
240+<td>選択したメディア・ファイルのファイル名が変更された後</td>
241+<td><dl>
242+<dt class="ref">collection</dt>
243+<dd>(値渡し)選択したメディア・ファイルが保存されているコレクション・ディレクトリ</dd>
244+<dt class="ref">oldfilename</dt>
245+<dd>(値渡し)選択したメディア・ファイルの以前のファイル名</dd>
246+<dt class="ref">newfilename</dt>
247+<dd>(値渡し)選択したメディア・ファイルの現在のファイル名</dd>
248+</dl></td>
249+</tr>
250+<tr>
251+<td>PreDeleteMedia</td>
252+<td>選択したメディア・ファイルが削除される前</td>
253+<td><dl>
254+<dt class="ref">collection</dt>
255+<dd>(値渡し)削除したメディア・ファイルが保存されていたコレクション・ディレクトリ</dd>
256+<dt class="ref">filename</dt>
257+<dd>(値渡し)削除したメディア・ファイルのファイル名</dd>
258+</dl></td>
259+</tr>
260+<tr>
261+<td>PostDeleteMedia</td>
262+<td>選択したメディア・ファイルが削除された後</td>
263+<td><dl>
264+<dt class="ref">collection</dt>
265+<dd>(値渡し)削除したメディア・ファイルが保存されていたコレクション・ディレクトリ</dd>
266+<dt class="ref">filename</dt>
267+<dd>(値渡し)削除したメディア・ファイルのファイル名</dd>
268+</dl></td>
269+</tr>
270+<tr>
271+<td>PreSubdirCreate</td>
272+<td>コレクション・ディレクトリにサブ・ディレクトリが作成される前</td>
273+<td><dl>
274+<dt class="ref">collection</dt>
275+<dd>(値渡し)コレクション・ディレクトリの名前</dd>
276+<dt class="ref">subdir</dt>
277+<dd>(値渡し)サブ・ディレクトリの名前</dd>
278+</dl></td>
279+</tr>
280+<tr>
281+<td>PostSubdirCreate</td>
282+<td>コレクション・ディレクトリにサブ・ディレクトリが作成された後</td>
283+<td><dl>
284+<dt class="ref">collection</dt>
285+<dd>(値渡し)コレクション・ディレクトリの名前</dd>
286+<dt class="ref">subdir</dt>
287+<dd>(値渡し)サブ・ディレクトリの名前</dd>
288+</dl></td>
289+</tr>
290+<tr>
291+<td>PreSubdirRename</td>
292+<td>コレクション・ディレクトリのサブ・ディレクトリの名前が変更される前</td>
293+<td><dl>
294+<dt class="ref">collection</dt>
295+<dd>(値渡し)コレクション・ディレクトリの名前</dd>
296+<dt class="ref">olddirname</dt>
297+<dd>(値渡し)変更前のサブ・ディレクトリの名前</dd>
298+<dt class="ref">newdirname</dt>
299+<dd>(値渡し)変更後のサブ・ディレクトリの名前</dd>
300+</dl></td>
301+</tr>
302+<tr>
303+<td>PostSubdirRename</td>
304+<td>コレクション・ディレクトリのサブ・ディレクトリの名前が変更された後</td>
305+<td><dl>
306+<dt class="ref">collection</dt>
307+<dd>(値渡し)コレクション・ディレクトリの名前</dd>
308+<dt class="ref">olddirname</dt>
309+<dd>(値渡し)変更前のサブ・ディレクトリの名前</dd>
310+<dt class="ref">newsubdirname</dt>
311+<dd>(値渡し)変更後のサブ・ディレクトリの名前</dd>
312+</dl></td>
313+</tr>
314+<tr>
315+<td>PreSubdirRemove</td>
316+<td>コレクション・ディレクトリのサブ・ディレクトリが削除される前</td>
317+<td><dl>
318+<dt class="ref">collection</dt>
319+<dd>(値渡し)コレクション・ディレクトリの名前</dd>
320+<dt class="ref">subdir</dt>
321+<dd>(値渡し)サブ・ディレクトリの名前</dd>
322+</dl></td>
323+</tr>
324+<tr>
325+<td>PostSubdirRemove</td>
326+<td>コレクション・ディレクトリのサブ・ディレクトリが削除された後</td>
327+<td><dl>
328+<dt class="ref">collection</dt>
329+<dd>(値渡し)コレクション・ディレクトリの名前</dd>
330+<dt class="ref">subdir</dt>
331+<dd>(値渡し)サブ・ディレクトリの名前</dd>
332+</dl></td>
333+</tr>
334+</tbody>
335+</table>
336+
337+<h3 id="chapter12">バージョン履歴</h3>
338+<dl>
339+<dt>2010.02.28 Ver.3.0.1</dt>
340+<dd><ul>
341+<li>アイテムの編集画面から呼び出して画像ファイルをアップロードした際、<%media%>でしか埋め込まれない不具合を修正。</li>
342+<li>同梱しているGreyBoxを最新のバージョン(var.5.54)にした。</li>
343+</ul></dd>
344+<dt>2009.02.09 Ver.3.0.0</dt>
345+<dd><ul>
346+<li>サブ・ディレクトリ管理機能を追加。以降、Ver.2.x.xとVer.3.x.x(サブ・ディレクトリ管理機能つき)の2系統とします。</li>
347+</ul></dd>
348+<dt>2009.02.09 Ver.2.2.0</dt>
349+<dd><ul>
350+<li>クラスとその要素(プロパティ)、関数(メソッド)を設定。PHP5を意識してPHP4にも対応するよう再設計した。</li>
351+<li>NP_EachBlogDirをNP_ImprovedMediaに統合した。</li>
352+<li>グローバル設定「アップロードするファイル名の頭に日付を付加する」に応じて、ファイルの並び順を変更するようにした。</li>
353+<li>アイテム編集画面からの呼び出しと、スキンからの呼び出して、アイテムへの埋め込みまでのルーチンが変わるように変更した。</li>
354+<li>ヘルプファイルを更新</li>
355+</ul></dd>
356+<dt>2009.01.20 Ver.2.1.1</dt>
357+<dd><ul>
358+<li>Super Admin権限を持つユーザのみ利用できるようにしていたが、ウェブログの編集権限をひとつでも持つユーザにまで利用範囲を広げた。</li>
359+<li>インターフェースの改善</li>
360+</ul></dd>
361+<dt>2009.01.11 Ver.2.1.0</dt>
362+<dd><ul>
363+<li>URL内の任意の文字列を渡すことによってディレクトリ操作が可能になる脆弱性を防ぐため、ファイル名とディレクトリに関する処理を修正。</li>
364+<li>インターフェースを改善。</li>
365+<li>グローバル設定のAllowUploadにを反映するように修正。</li>
366+<li>プラグインの利用をウェブログ・グループに所属しているユーザに限定。</li>
367+<li>Ver 2.0でマージしたファイル・アップロードに関するコードを削除。アップロードに関しても、コアの機能を最大限に利用します。</li>
368+<li>ヘルプファイルを更新。</li>
369+</ul></dd>
370+<dt>2009.01.06 Ver.2.0.2公開中止</dt>
371+<dd><ul>
372+<li>2008.12.17の<a href="http://japan.nucleuscms.org/bb/viewtopic.php?p=24067#24067" title="メディアマネージャにおける脆弱性について">メディアマネージャにおける脆弱性について</a>で報告された脆弱性を考慮し、公開を中止。修正に着手。</li>
373+</ul></dd>
374+<dt>2008.02.08 Ver.2.0.2</dt>
375+<dd><ul>
376+<li>アイテムへの埋め込み確認の際、埋め込まれるコードを表示をし、コードの再編集への注意を促すように修正。</li>
377+<li>メディア・ファイルを文書に挿入するへのボタンをクリックした際の動作に関して、バグの修正。</li>
378+</ul>
379+</dd>
380+<dt>2008.01.31 Ver.2.0.1</dt>
381+<dd><ul>
382+<li>GreyBox機能がオフの際のコード埋め込み不具合を修正。</li>
383+<li>ヘルプファイルを更新</li>
384+</ul>
385+</dd>
386+<dt>2008.01.15 Ver.2.0</dt>
387+<dd><ul>
388+<li>コードの見直しに伴い、バージョンをあげた。</li>
389+<li>ファイル・アップロード、ファイル名変更、ファイル削除の各プラグイン・イベントを設定。</li>
390+<li>プラグイン・イベントに関するNucleus CMSのバージョン間での違いを吸収するために、ファイル・アップロードに関するコードをマージ。</li>
391+<li>Internet Explorerでファイルを開く際に、ポップアップしないJavaScriptのバグを修正。</li>
392+<li>ヘルプの更新。</li>
393+<li>プラグイン関連のディレクトリ構造の変更。</li>
394+</ul></dd>
395+<dt>2007.11.20 Ver.1.3</dt>
396+<dd><ul>
397+<li>スキン変数を実装。スキンからの呼び出しを可能とした。</li>
398+<li>スキンから呼び出された際は、ボタン「文書へ挿入」を非表示にした。</li>
399+<li>GreyBoxを含むパッケージにした。</li>
400+</ul></dd>
401+<dt>2007.11.06 Ver.1.2(Bundling GreyBox)</dt>
402+<dd><ul>
403+<li>GreyBoxユーティリティによるウィンドウオープンを実装。</li>
404+</ul></dd>
405+<dt>2007.11.01 Ver.1.2</dt>
406+<dd><ul>
407+<li>ヘッダ追加情報の上書き状態を修正。</li>
408+<li>オプションの追加。</li>
409+<li>パースエラーの修正。</li>
410+<li>Nucleus3.3のコードを合体。</li>
411+<li>ヘルプの更新。</li>
412+<li>プラグイン関連のディレクトリ構造の変更。</li>
413+</ul></dd>
414+<dt>2007.06.21 Ver.1.1</dt>
415+<dd><ul>
416+<li>プライベート・コレクションのオン・オフを追加。</li>
417+<li>パースエラーの修正。</li>
418+<li>ヘルプの更新。</li>
419+</ul></dd>
420+<dt>2007.02.17 Ver.1.0.2 (RC3)</dt>
421+<dd><ul>
422+<li>リリースキャンディデート3</li>
423+</ul></dd>
424+<dt>2006.12.31 Ver.1.0.1 (RC2)</dt>
425+<dd><ul>
426+<li>リリースキャンディデート2</li>
427+</ul></dd>
428+<dt>2006.12.29 Ver.1.0 (RC1)</dt>
429+<dd><ul>
430+<li>リリースキャンディデート</li>
431+</ul></dd>
432+<dt>2006.12.22 Beta</dt>
433+<dd><ul>
434+<li>ベータバージョン</li>
435+</ul></dd>
436+<dt>2006.12.20 Alpha</dt>
437+<dd><ul>
438+<li>アルファバージョン</li>
439+</ul></dd>
440+</dl>
441+
442+<h3 id="chapter13">動作の仕組み</h3>
443+
444+<p>備忘録として残しておきます。</p>
445+
446+<h4>アイテムの追加/編集の時</h4>
447+
448+<ol>
449+<li>変数「action」によりイベント「AdminPrePageHead」、「BookmarkletExtraHead」が発生した際、XHTML要素「head」にJavaScript関数を挿入。 action.php経由でプラグインの出力するMedia Controlをポップアップ表示するJavaScript関数「AddMedia()」を埋め込む。</li>
450+<li>また同時に、JavaScript関数「includeImage()」と「includeOtherMedia()」もヘッダに追加。</li>
451+<li>追加したJavaScript関数はXHTMLファイルに直接埋め込まれているため、コアのJavaScript関数「AddMedia()」よりも呼び出し優先される。</li>
452+<li>JavaScript関数「AddMedia()」はMedia Controlにユーザを誘導し、JavaScript関数「includeImage()」と「includeOtherMedia()」は代替テキスト入力を代行する。</li>
453+<li>追加したJavaScript関数「AddMedia()」は、blogidもしくはitemidをget変数としてMedia Controlに渡す。</li>
454+<li>blogid(ない場合はitemid)を用いてグローバル変数の$DIR_MEDIAと$CONF[’MediaURL’]を置き換える。</li>
455+<li>Media Controlが自分を呼び出す際は、必ずblogidをget変数として渡す。</li>
456+<li>あとはコアの機能を利用して、ポップアップや埋め込みのコードが生成される。</li>
457+</ol>
458+
459+<h4>表示される時</h4>
460+<ol>
461+<li>action変数により、イベント「InitSkinParse」が発生したとき、つまりスキンの初期化の直前に、プラグイン内のあるメソッドが実行される。</li>
462+<li>メソッドは、blogオブジェクトからshortnameを参照し、それを用いてグローバル変数の$DIR_MEDIAと$CONF[’MediaURL]を置き換える。</li>
463+<li>画像へのアンカーが、スキン変数&lt;%popup%&gt;、&lt;%image%&gt;において、置き換えられる。</li>
464+<li>イベント発生をPreItemにしなかったのは、ポップアップで呼び出されるウィンドウにも変更を適用したかったから。</li>
465+</ol>
--- /dev/null
+++ b/NP_ImprovedMedia/improvedmedia/index.html
@@ -0,0 +1,11 @@
1+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2+<html xmlns="http://www.w3.org/1999/xhtml">
3+<head>
4+<title>Nothing Here</title>
5+</head>
6+<body>
7+
8+<h1>Nothing to see here</h1>
9+
10+</body>
11+</html>
\ No newline at end of file
--- /dev/null
+++ b/NP_ImprovedMedia/improvedmedia/lang/english.php
@@ -0,0 +1,135 @@
1+<?php
2+/**
3+ * ImprovedMedia plugin for Nucleus CMS
4+ * Version 3.0.1
5+ * Written By Mocchi, Feb.28, 2010
6+ *
7+ * This program is free software; you can redistribute it and/or
8+ * modify it under the terms of the GNU General Public License
9+ * as published by the Free Software Foundation; either version 3
10+ * of the License, or (at your option) any later version.
11+ */
12+
13+define('_IM_DESCRIPTION', 'Provide media function for each weblog on its own directory with erasing and renaming functions');
14+define('_IM_OPTION_PRIVATE', 'Would you like to use your private collection directory in media directory?');
15+define('_IM_OPTION_ITEMDISPLAY', 'How many files do you want to display in a list? (5-50 is preferrable)');
16+define('_IM_OPTION_GREYBOX', 'Would you like to use GreBox utility to open Media Control window?');
17+define('_IM_OPTION_EACHBLOGDIR', 'Would you like to use the media directory belonged to its own weblog directory?');
18+
19+define('_IM_HEADER_TEXT', ' - ImprovedMedia plugin for Nucleus CMS');
20+define('_IM_HEADER_RENAME_CONFIRM', 'File Rename (step 1/1)');
21+define('_IM_HEADER_ERASE_CONFIRM', 'File Erase (step 1/1)');
22+define('_IM_HEADER_UPLOAD_SELECT', 'File Upload (step 1/1)');
23+define('_IM_HEADER_EMBED_CONFIRM', 'File Embed (step 1/2)');
24+define('_IM_HEADER_EMBED', 'File Embed (step 2/2)');
25+define('_IM_HEADER_SUBDIR_CREATE_CONFIRM', 'Sub Directory Create (step1/1)');
26+define('_IM_HEADER_SUBDIR_REMOVE_CONFIRM', 'Sub Directory Remove (step1/1)');
27+define('_IM_HEADER_SUBDIR_RENAME_CONFIRM', 'Sub Directory Rename (step1/1)');
28+
29+define('_IM_ANCHOR_TEXT', 'Media Control');
30+define('_IM_VIEW_TT', ': View this (Open new window)');
31+define('_IM_FILTER', 'Filter: ');
32+define('_IM_FILTER_APPLY', 'Apply Filter');
33+define('_IM_FILTER_LABEL', 'Filter (case-insentive): ');
34+define('_IM_UPLOAD_TO', 'Upload to...');
35+define('_IM_UPLOAD_NEW', 'Upload new file...');
36+define('_IM_UPLOADLINK', 'Upload a new file');
37+define('_IM_COLLECTION_SELECT', 'Select');
38+define('_IM_COLLECTION_TT', 'Switch to this collection directory');
39+define('_IM_COLLECTION_LABEL', 'Current collection directory: ');
40+define('_IM_MODIFIED', 'Modified');
41+define('_IM_FILENAME', 'Filename');
42+define('_IM_DIMENSIONS', 'Dimensions');
43+define('_IM_WEBLOG_LABEL', 'Weblog');
44+
45+define('_IM_FORBIDDEN_ACCESS', 'This access is done with forbidden way.');
46+define('_IM_ALT_TOOLONG', 'Description about this file is restricted within 40 letters.');
47+define('_IM_ERASE_FAILED', 'Fail to erase the file.');
48+define('_IM_MISSING_FILE', 'The request file is missing.');
49+define('_IM_MISSING_DIRECTORY', 'The collection directory is missing.');
50+define('_IM_REMIND_DIRECTORY', 'Please make some directories at the directory for uploading files.');
51+define('_IM_REMIND_MEDIADIR', 'The directory for media files is not appropriate. Confirm the media directory and the permissions.');
52+define('_IM_RENAME_FORBIDDEN', 'Forbidden to access the file. Please check your right of access.');
53+define('_IM_RENAME_FILEEXIST', 'The name you want to rename to already exists.');
54+define('_IM_RENAME_TOOLONG', 'The file name is restricted within 30 letters.');
55+define('_IM_RENAME_WRONG', 'The new name includes some disallowed charactors!');
56+define('_IM_NOTICE', 'NOTICE!');
57+define('_IM_FUNCTION', 'function');
58+define('_IM_RENAME_FAILED', 'Fail to rename the file.');
59+define('_IM_RENAME_BLANK', 'The file name you want to rename to is blank.');
60+define('_IM_RENAME', 'Rename');
61+define('_IM_RENAME_DESCRIPTION', 'Please enter the name you want to rename to, without file prefix. You can use only Alphabets, numbers, underscores, hyphen-minus and plus (Maximum 30 letters).');
62+define('_IM_RENAME_AFTER', 'Name you want to rename to');
63+define('_IM_RENAME_FILENAME', 'Selected file');
64+define('_IM_FILENAME_CLICK', 'File name(Click to open)');
65+define('_IM_FILTER_NONE', 'No Filter');
66+define('_IM_ACTION', 'Action');
67+define('_IM_RETURN', 'Go to Overview');
68+define('_IM_COLLECTION', 'Collection Directory');
69+define('_IM_COLLECTION_DESC', 'Please choose the directory where you will upload.');
70+define('_IM_SHORTNAME', 'Short Name of the website');
71+define('_IM_UPDATE', 'Update');
72+define('_IM_TYPE', 'Type');
73+define('_IM_ERASE', 'Erase');
74+define('_IM_ERASE_CONFIRM', 'Are you sure to erase the file below?');
75+define('_IM_ERASE_DONE', 'Do Erase');
76+define('_IM_INCLUDE', 'Insert this');
77+define('_IM_INCLUDE_DESC', 'Are you sure to insert the file below?');
78+define('_IM_INCLUDE_ALT', 'Description of this file');
79+define('_IM_INCLUDE_ALT_DESC', 'Enter the description of this file. Required!');
80+define('_IM_INCLUDE_MODIFIED', 'Modify');
81+define('_IM_INCLUDE_FILE_SELECTED', 'The file you selected: ');
82+define('_IM_INCLUDE_WAY', 'How to show this file');
83+define('_IM_INCLUDE_WAY_POPUP', 'include this image with the alternative text in the item and popup clicking');
84+define('_IM_INCLUDE_WAY_INLINE', 'Include this image with the original size in the item');
85+define('_IM_INCLUDE_WAY_OTHER', 'The description about this file is shown and the users can display to click it.');
86+define('_IM_INCLUDE_CODE', 'Code which indicates this');
87+define('_IM_INCLUDE_CODE_DESC', 'Following code is embedded in the input screen. Do not reedit this code.');
88+define('_IM_INCLUDE_WAY_DECIDE', 'Decide');
89+define('_IM_UPLOAD_USED_ASCII', 'File name should be in English');
90+define('_IM_UPLOAD_USED_ASCII_DESC1', 'Please name the file in English. <br />It will be the garbled characters and you can\'t access the file if you upload it with Japanese name.');
91+define('_IM_UPLOAD_USED_ASCII_DESC2', 'Then please use the erase function on this plugin.<br />After, rename it and re-upload it.');
92+define('_IM_UPLOAD_USED_FILETYPE', 'Available file types');
93+define('_IM_UPLOAD_CONPLETE', 'The file is uploaded.');
94+define('_IM_COLLECTION_AMOUNT', 'Num. of Files: ');
95+define('_IM_COLLECTION_BRANK', 'Nothing exists at collection directory: ');
96+define('_IM_REQUIREMENT', 'Enter description about the selected file');
97+define('_IM_ITEMDISPLAY_WRONG', 'Too much or too less number of files in a list!');
98+
99+define('_IM_SUBDIR', 'Sub Directory');
100+define('_IM_COLLECTION_FAILED_READ', 'Fail to get the list in this collection directory. COnfirm your permissions to access this directory.');
101+define('_IM_SUBDIR_LABEL', 'Sub Collection Directory: ');
102+define('_IM_SUBDIR_SELECT', 'Select');
103+define('_IM_SUBDIR_NONE', 'Nothing');
104+define('_IM_SUBDIR_TT', 'Switch to this sub collection directory');
105+define('_IM_SUBDIR_DESC', 'Please choose the sub directory where you will upload. if there are no sub directories, the file will be uploaded to the collection directory.');
106+define('_IM_DISPLAY_FILES', 'Display files');
107+define('_IM_SUBDIR_REMOVE', 'Remove directory');
108+define('_IM_DISPLAY_SUBDIR', 'Manage Sub Directory');
109+define('_IM_DISPLAY_SUBDIR_TT', 'Move ');
110+define('_IM_DISPLAY_SUBDIR_SELECT', 'Choice');
111+define('_IM_CREATE_SUBDIR_CONFIRM', 'Create Sub Directory');
112+define('_IM_CREATE_SUBDIR_COLLECTION_LABEL', 'Choose collection directory');
113+define('_IM_CREATE_SUBDIR_COLLECTION', 'Please chose the collection directory where you would like to create sub directory.');
114+define('_IM_CREATE_SUBDIR_INPUT_NAME', 'Name of sub directory');
115+define('_IM_CREATE_SUBDIR_CHARS', 'the name of sub directory should be ');
116+define('_IM_CREATE_SUBDIR_CHARS_DESC', 'For name of directories, the charactors is limited within alphabeds, numbers, underscores, hyphenminus and plus. Maximum 20 letters.');
117+define('_IM_RENAME_SUBDIR_BLANK', '');
118+define('_IM_RENAME_SUBDIR_TOOLONG', 'The sub directory name should be restricted within 20 letters.');
119+define('_IM_RENAME_SUBDIR_WRONG', 'the name for sub directory includes disallowed charactors.');
120+define('_IM_RENAME_SUBDIR_DUPLICATE', 'Directory with the same name is already exists.');
121+define('_IM_CREATE_SUBDIR_WRONG', 'Creating sub directory failed. Please ask the manager of your server.');
122+define('_IM_RENAME_SUBDIR_COLLECTION', 'Sub directory which you want to rename');
123+define('_IM_SUBDIR_NUM_FILES', 'the number of files');
124+define('_IM_DISPLAY_SUBDIR_LABEL1', 'the number of directories: ');
125+define('_IM_DISPLAY_SUBDIR_LABEL2', ', the number of files: ');
126+define('_IM_DISPLAY_SUBDIR_RETURN', 'File list');
127+define('_IM_REMOVE_SUBIDR', 'Remove sub directory');
128+define('_IM_REMOVE_SUBIDR_CONFIRM', 'Confirm to remove sub directory');
129+define('_IM_REMOVE_SUBIDR_REMIND', 'When you remove sub directory, all of files in the sub directory is erased automatically. But the code indicating the file in certain item is not modified automatically. You are not allowd to remove collection directories.');
130+define('_IM_REMOVE_SUBDIR_FAILED', 'Fail to remove this sub directory. Confirm your permissions to this sub directory or included files.');
131+define('_IM_DISPLAY_SUBDIR_CAPTION', 'Sub directory list');
132+define('_IM_DISPLAY_SUBDIR_NOTHING', 'No sub directories');
133+define('_IM_SUBDIR_REMOVE_FAILED', 'Fail to remove this sub directory. Confirm your permission to this sub directory or included files.');
134+define('_IM_SUBDIR_FAILED_READ', 'Fail to get the list of this sub directory. Confirm your permission to access this sub directory.');
135+?>
--- /dev/null
+++ b/NP_ImprovedMedia/improvedmedia/lang/index.html
@@ -0,0 +1,11 @@
1+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2+<html xmlns="http://www.w3.org/1999/xhtml">
3+<head>
4+<title>Nothing Here</title>
5+</head>
6+<body>
7+
8+<h1>Nothing to see here</h1>
9+
10+</body>
11+</html>
\ No newline at end of file
--- /dev/null
+++ b/NP_ImprovedMedia/improvedmedia/lang/japanese-euc.php
@@ -0,0 +1,135 @@
1+<?php
2+/**
3+ * ImprovedMedia plugin for Nucleus CMS
4+ * Version 3.0.1
5+ * Written By Mocchi, Feb.28, 2010
6+ *
7+ * This program is free software; you can redistribute it and/or
8+ * modify it under the terms of the GNU General Public License
9+ * as published by the Free Software Foundation; either version 3
10+ * of the License, or (at your option) any later version.
11+ */
12+
13+define('_IM_DESCRIPTION', 'ファイル削除と名前変更機能、サブ・ディレクトリ管理機能を追加した外部ファイル管理機能に差し替えます。また、設定を変更することにより、メディア・ディレクトリを個別のウェブログのディレクトリに配置した運用を可能とします。');
14+define('_IM_OPTION_PRIVATE', 'プライベート・コレクション・フォルダを使いますか?');
15+define('_IM_OPTION_ITEMDISPLAY', '一つの画面にいくつのファイルを表示しますか?(5から50まで)');
16+define('_IM_OPTION_GREYBOX', 'Media ControlウィンドウにGreyBoxユーティリティを使いますか?');
17+define('_IM_OPTION_EACHBLOGDIR', 'それぞれのウェブログがある個別ディレクトリでのファイル管理を利用しますか?');
18+
19+define('_IM_HEADER_TEXT', ' - ImprovedMedia plugin for Nucleus CMS');
20+define('_IM_HEADER_RENAME_CONFIRM', 'ファイル名の変更(ステップ 1の1)');
21+define('_IM_HEADER_ERASE_CONFIRM', 'ファイルの削除(ステップ 1の1)');
22+define('_IM_HEADER_UPLOAD_SELECT', 'ファイルのアップロード(ステップ 1の1)');
23+define('_IM_HEADER_EMBED_CONFIRM', 'ファイルの挿入(ステップ 2の1)');
24+define('_IM_HEADER_EMBED', 'ファイルの挿入(ステップ 2の2)');
25+define('_IM_HEADER_SUBDIR_CREATE_CONFIRM', 'サブ・ディレクトリの作成');
26+define('_IM_HEADER_SUBDIR_REMOVE_CONFIRM', 'サブ・ディレクトリの削除');
27+define('_IM_HEADER_SUBDIR_RENAME_CONFIRM', 'サブ・ディレクトリ名の変更');
28+
29+define('_IM_ANCHOR_TEXT', 'ファイル管理');
30+define('_IM_VIEW_TT', ' :ファイル表示 (新しいウィンドウが開きます)');
31+define('_IM_FILTER', 'フィルター: ');
32+define('_IM_FILTER_APPLY', 'フィルター適応');
33+define('_IM_FILTER_LABEL', 'フィルター(大文字小文字無関係): ');
34+define('_IM_UPLOAD_TO', 'アップロード先');
35+define('_IM_UPLOAD_NEW', '新規アップロード');
36+define('_IM_UPLOADLINK', '新しいファイルのアップロード');
37+define('_IM_COLLECTION_SELECT', '選択');
38+define('_IM_COLLECTION_TT', 'このコレクション・ディレクトリに切り替え');
39+define('_IM_COLLECTION_LABEL', 'コレクション・ディレクトリの変更: ');
40+define('_IM_MODIFIED', '更新日');
41+define('_IM_FILENAME', 'ファイル名');
42+define('_IM_DIMENSIONS', 'サイズ');
43+define('_IM_WEBLOG_LABEL', 'ウェブログ');
44+
45+define('_IM_FORBIDDEN_ACCESS', '禁止している操作によるアクセスです');
46+define('_IM_ALT_TOOLONG', '説明文が40文字を超えています');
47+define('_IM_ERASE_FAILED', 'ファイルの削除に失敗しました');
48+define('_IM_MISSING_FILE', 'ファイルを見つけることができませんでした');
49+define('_IM_MISSING_DIRECTORY', 'コレクション・ディレクトリを見つけることができませんでした');
50+define('_IM_REMIND_DIRECTORY', 'アップロード用フォルダ内に任意のディレクトリを作成してください。');
51+define('_IM_REMIND_MEDIADIR', 'アップロード用フォルダが適切に設置されていません。アップロード用フォルダとそのアクセス権限を再設定して下さい。');
52+define('_IM_RENAME_FORBIDDEN', 'ファイルにアクセスできませんでした。あなたのアクセス権を確認してください');
53+define('_IM_RENAME_FILEEXIST', '変更したい名前のファイルがすでに存在しています');
54+define('_IM_RENAME_TOOLONG', 'ファイル名が30文字を超えています');
55+define('_IM_RENAME_WRONG', 'ファイル名に指定文字以外が含まれています');
56+define('_IM_NOTICE', '注意!');
57+define('_IM_FUNCTION', '機能');
58+define('_IM_RENAME_FAILED', '名前の変更に失敗しました');
59+define('_IM_RENAME_BLANK', 'ファイル名が空白です');
60+define('_IM_RENAME', '名前変更');
61+define('_IM_RENAME_DESCRIPTION', '変更後の名前を、拡張子ぬきで、30文字までで入力してください。使用できる文字は英数字と3種類の記号(アンダーバー、ハイフン、プラス)です。日本語は使用できません。');
62+define('_IM_RENAME_AFTER', '変更後の名前');
63+define('_IM_RENAME_FILENAME', '名前を変更するファイル');
64+define('_IM_FILENAME_CLICK', 'ファイル名');
65+define('_IM_FILTER_NONE', 'フィルタなし');
66+define('_IM_ACTION', '動作');
67+define('_IM_RETURN', '一覧へ');
68+define('_IM_COLLECTION', 'コレクション・ディレクトリ');
69+define('_IM_COLLECTION_DESC', 'ファイルをアップロードするディレクトリを選択してください。');
70+define('_IM_SHORTNAME', 'ウェブサイトの短縮名');
71+define('_IM_UPDATE', '登録日');
72+define('_IM_TYPE', '種類');
73+define('_IM_ERASE', '削除');
74+define('_IM_ERASE_CONFIRM', '以下のファイルを消去します');
75+define('_IM_ERASE_DONE', '削除する');
76+define('_IM_INCLUDE', '文章に挿入');
77+define('_IM_INCLUDE_DESC', '以下のファイルを文章に挿入します。');
78+define('_IM_INCLUDE_ALT', 'ファイルの説明文');
79+define('_IM_INCLUDE_ALT_DESC', 'ファイルの簡単な説明文を、40文字までで入力してください。必須です。');
80+define('_IM_INCLUDE_MODIFIED', '修正する');
81+define('_IM_INCLUDE_FILE_SELECTED', '選択したファイル');
82+define('_IM_INCLUDE_WAY', 'ファイルの表示方法');
83+define('_IM_INCLUDE_WAY_POPUP', '説明文を記事に表示し、クリックでポップアップ表示');
84+define('_IM_INCLUDE_WAY_INLINE', '画像をそのままのサイズで記事に埋め込む');
85+define('_IM_INCLUDE_WAY_OTHER', 'このファイルは、上で入力した説明文がアンカーテキストとなります。文書中の説明文をクリックすると、ファイルがポップアップ表示されます。');
86+define('_IM_INCLUDE_CODE', '入力画面に埋め込まれるコード');
87+define('_IM_INCLUDE_CODE_DESC', '入力画面には、以下のコードが埋め込まれます。このコードは再編集しないでください。');
88+define('_IM_INCLUDE_WAY_DECIDE', '決定');
89+define('_IM_UPLOAD_USED_ASCII', 'ファイル名は必ず英数字');
90+define('_IM_UPLOAD_USED_ASCII_DESC1', '日本語を用いると、アドレスが文字化けしてブラウザで参照できなくなります可能性があります。');
91+define('_IM_UPLOAD_USED_ASCII_DESC2', 'その場合は、削除機能を用いて削除してください。そして、名前を変更してから、再度アップロードしてください。');
92+define('_IM_UPLOAD_USED_FILETYPE', '現在利用できるファイルのタイプ');
93+define('_IM_UPLOAD_CONPLETE', 'ファイルのアップロードが成功しました');
94+define('_IM_COLLECTION_AMOUNT', 'ファイル数: ');
95+define('_IM_COLLECTION_BRANK', 'ファイルなし');
96+define('_IM_REQUIREMENT', '説明文を入力してください');
97+define('_IM_ITEMDISPLAY_WRONG', '1ページの表示ファイル数を、5件から50件の間で指定してください。');
98+
99+define('_IM_SUBDIR', 'サブ・ディレクトリ');
100+define('_IM_COLLECTION_FAILED_READ', 'コレクション・ディレクトリ情報の取得に失敗しました。アクセス権限を確認して下さい');
101+define('_IM_SUBDIR_LABEL', 'サブ・ディレクトリ: ');
102+define('_IM_SUBDIR_SELECT', '選択');
103+define('_IM_SUBDIR_NONE', 'なし');
104+define('_IM_SUBDIR_TT', 'このサブ・ディレクトリに切り替え');
105+define('_IM_SUBDIR_DESC', 'ファイルをアップロードするサブ・ディレクトリを選択してください。なしの場合はコレクション・ディレクトリに保存されます。');
106+define('_IM_DISPLAY_FILES', 'ファイル表示');
107+define('_IM_SUBDIR_REMOVE', 'ディレクトリ削除');
108+define('_IM_DISPLAY_SUBDIR', 'サブ・ディレクトリ管理');
109+define('_IM_DISPLAY_SUBDIR_TT', 'サブ・ディレクトリの管理画面に移動');
110+define('_IM_DISPLAY_SUBDIR_SELECT', '変 更');
111+define('_IM_CREATE_SUBDIR_CONFIRM', 'サブ・ディレクトリ作成');
112+define('_IM_CREATE_SUBDIR_COLLECTION_LABEL', 'コレクション・ディレクトリの指定');
113+define('_IM_CREATE_SUBDIR_COLLECTION', 'サブ・ディレクトリを作成するコレクション・ディレクトリを指定してください');
114+define('_IM_CREATE_SUBDIR_INPUT_NAME', 'サブ・ディレクトリのディレクトリ名');
115+define('_IM_CREATE_SUBDIR_CHARS', 'サブ・ディレクトリ名に指定された以外の文字種が使われています');
116+define('_IM_CREATE_SUBDIR_CHARS_DESC', 'サブ・ディレクトリ名に利用できる文字は、英数字と3種類の記号(アンダーバー、ハイフン、プラス)です。最長で20文字です。それ以外の文字種や日本語は使用できません。');
117+define('_IM_RENAME_SUBDIR_BLANK', 'サブ・ディレクトリ名が空白です');
118+define('_IM_RENAME_SUBDIR_TOOLONG', 'サブ・ディレクトリ名が20文字を超えています');
119+define('_IM_RENAME_SUBDIR_WRONG', 'サブ・ディレクトリ名に指定された以外の文字種が使われています');
120+define('_IM_RENAME_SUBDIR_DUPLICATE', '同名のサブ・ディレクトリがすでに存在しています。');
121+define('_IM_CREATE_SUBDIR_WRONG', 'サブ・ディレクトリが作成できませんので、サーバ管理者に相談してください');
122+define('_IM_RENAME_SUBDIR_COLLECTION', '名前を変更するサブ・ディレクトリ');
123+define('_IM_SUBDIR_NUM_FILES', 'ファイル数');
124+define('_IM_DISPLAY_SUBDIR_LABEL1', 'サブ・ディレクトリ数: ');
125+define('_IM_DISPLAY_SUBDIR_LABEL2', ', ファイル数: ');
126+define('_IM_DISPLAY_SUBDIR_RETURN', 'ファイル一覧');
127+define('_IM_REMOVE_SUBIDR', '削除するサブ・ディレクトリ');
128+define('_IM_REMOVE_SUBIDR_CONFIRM', 'サブ・ディレクトリの削除の確認');
129+define('_IM_REMOVE_SUBIDR_REMIND', 'サブ・ディレクトリを削除すると、中のファイルもすべて同時に削除されます。その際、すでにアイテム内に挿入されているコードは、この操作を行っても自動で書き換えられません。なお、コレクション・ディレクトリを削除することはできません。');
130+define('_IM_REMOVE_SUBDIR_FAILED', 'サブ・ディレクトリの削除に失敗しています。サブ・ディレクトリもしくは含まれているファイルを確認してください。');
131+define('_IM_DISPLAY_SUBDIR_CAPTION', 'サブ・ディレクトリ一覧');
132+define('_IM_DISPLAY_SUBDIR_NOTHING', 'サブ・ディレクトリなし');
133+define('_IM_SUBDIR_REMOVE_FAILED', 'サブ・ディレクトリの削除に失敗しました。サブ・ディレクトリのアクセス権限もしくはサブ・ディレクトリ内のファイルのアクセス権限を確認して下さい。');
134+define('_IM_SUBDIR_FAILED_READ', 'サブ・ディレクトリ情報の取得に失敗しました。アクセス権限を確認して下さい');
135+?>
--- /dev/null
+++ b/NP_ImprovedMedia/improvedmedia/lang/japanese-utf8.php
@@ -0,0 +1,135 @@
1+<?php
2+/**
3+ * ImprovedMedia plugin for Nucleus CMS
4+ * Version 3.0.1
5+ * Written By Mocchi, Feb.28, 2010
6+ *
7+ * This program is free software; you can redistribute it and/or
8+ * modify it under the terms of the GNU General Public License
9+ * as published by the Free Software Foundation; either version 3
10+ * of the License, or (at your option) any later version.
11+ */
12+
13+define('_IM_DESCRIPTION', 'ファイル削除と名前変更機能、サブ・ディレクトリ管理機能を追加した外部ファイル管理機能に差し替えます。また、設定を変更することにより、メディア・ディレクトリを個別のウェブログのディレクトリに配置した運用を可能とします。');
14+define('_IM_OPTION_PRIVATE', 'プライベート・コレクション・フォルダを使いますか?');
15+define('_IM_OPTION_ITEMDISPLAY', '一つの画面にいくつのファイルを表示しますか?(5から50まで)');
16+define('_IM_OPTION_GREYBOX', 'Media ControlウィンドウにGreyBoxユーティリティを使いますか?');
17+define('_IM_OPTION_EACHBLOGDIR', 'それぞれのウェブログがある個別ディレクトリでのファイル管理を利用しますか?');
18+
19+define('_IM_HEADER_TEXT', ' - ImprovedMedia plugin for Nucleus CMS');
20+define('_IM_HEADER_RENAME_CONFIRM', 'ファイル名の変更(ステップ 1の1)');
21+define('_IM_HEADER_ERASE_CONFIRM', 'ファイルの削除(ステップ 1の1)');
22+define('_IM_HEADER_UPLOAD_SELECT', 'ファイルのアップロード(ステップ 1の1)');
23+define('_IM_HEADER_EMBED_CONFIRM', 'ファイルの挿入(ステップ 2の1)');
24+define('_IM_HEADER_EMBED', 'ファイルの挿入(ステップ 2の2)');
25+define('_IM_HEADER_SUBDIR_CREATE_CONFIRM', 'サブ・ディレクトリの作成');
26+define('_IM_HEADER_SUBDIR_REMOVE_CONFIRM', 'サブ・ディレクトリの削除');
27+define('_IM_HEADER_SUBDIR_RENAME_CONFIRM', 'サブ・ディレクトリ名の変更');
28+
29+define('_IM_ANCHOR_TEXT', 'ファイル管理');
30+define('_IM_VIEW_TT', ' :ファイル表示 (新しいウィンドウが開きます)');
31+define('_IM_FILTER', 'フィルター: ');
32+define('_IM_FILTER_APPLY', 'フィルター適応');
33+define('_IM_FILTER_LABEL', 'フィルター(大文字小文字無関係): ');
34+define('_IM_UPLOAD_TO', 'アップロード先');
35+define('_IM_UPLOAD_NEW', '新規アップロード');
36+define('_IM_UPLOADLINK', '新しいファイルのアップロード');
37+define('_IM_COLLECTION_SELECT', '選択');
38+define('_IM_COLLECTION_TT', 'このコレクション・ディレクトリに切り替え');
39+define('_IM_COLLECTION_LABEL', 'コレクション・ディレクトリの変更: ');
40+define('_IM_MODIFIED', '更新日');
41+define('_IM_FILENAME', 'ファイル名');
42+define('_IM_DIMENSIONS', 'サイズ');
43+define('_IM_WEBLOG_LABEL', 'ウェブログ');
44+
45+define('_IM_FORBIDDEN_ACCESS', '禁止している操作によるアクセスです');
46+define('_IM_ALT_TOOLONG', '説明文が40文字を超えています');
47+define('_IM_ERASE_FAILED', 'ファイルの削除に失敗しました');
48+define('_IM_MISSING_FILE', 'ファイルを見つけることができませんでした');
49+define('_IM_MISSING_DIRECTORY', 'コレクション・ディレクトリを見つけることができませんでした');
50+define('_IM_REMIND_DIRECTORY', 'アップロード用フォルダ内に任意のディレクトリを作成してください。');
51+define('_IM_REMIND_MEDIADIR', 'アップロード用フォルダが適切に設置されていません。アップロード用フォルダとそのアクセス権限を再設定して下さい。');
52+define('_IM_RENAME_FORBIDDEN', 'ファイルにアクセスできませんでした。あなたのアクセス権を確認してください');
53+define('_IM_RENAME_FILEEXIST', '変更したい名前のファイルがすでに存在しています');
54+define('_IM_RENAME_TOOLONG', 'ファイル名が30文字を超えています');
55+define('_IM_RENAME_WRONG', 'ファイル名に指定文字以外が含まれています');
56+define('_IM_NOTICE', '注意!');
57+define('_IM_FUNCTION', '機能');
58+define('_IM_RENAME_FAILED', '名前の変更に失敗しました');
59+define('_IM_RENAME_BLANK', 'ファイル名が空白です');
60+define('_IM_RENAME', '名前変更');
61+define('_IM_RENAME_DESCRIPTION', '変更後の名前を、拡張子ぬきで、30文字までで入力してください。使用できる文字は英数字と3種類の記号(アンダーバー、ハイフン、プラス)です。日本語は使用できません。');
62+define('_IM_RENAME_AFTER', '変更後の名前');
63+define('_IM_RENAME_FILENAME', '名前を変更するファイル');
64+define('_IM_FILENAME_CLICK', 'ファイル名');
65+define('_IM_FILTER_NONE', 'フィルタなし');
66+define('_IM_ACTION', '動作');
67+define('_IM_RETURN', '一覧へ');
68+define('_IM_COLLECTION', 'コレクション・ディレクトリ');
69+define('_IM_COLLECTION_DESC', 'ファイルをアップロードするディレクトリを選択してください。');
70+define('_IM_SHORTNAME', 'ウェブサイトの短縮名');
71+define('_IM_UPDATE', '登録日');
72+define('_IM_TYPE', '種類');
73+define('_IM_ERASE', '削除');
74+define('_IM_ERASE_CONFIRM', '以下のファイルを消去します');
75+define('_IM_ERASE_DONE', '削除する');
76+define('_IM_INCLUDE', '文章に挿入');
77+define('_IM_INCLUDE_DESC', '以下のファイルを文章に挿入します。');
78+define('_IM_INCLUDE_ALT', 'ファイルの説明文');
79+define('_IM_INCLUDE_ALT_DESC', 'ファイルの簡単な説明文を、40文字までで入力してください。必須です。');
80+define('_IM_INCLUDE_MODIFIED', '修正する');
81+define('_IM_INCLUDE_FILE_SELECTED', '選択したファイル');
82+define('_IM_INCLUDE_WAY', 'ファイルの表示方法');
83+define('_IM_INCLUDE_WAY_POPUP', '説明文を記事に表示し、クリックでポップアップ表示');
84+define('_IM_INCLUDE_WAY_INLINE', '画像をそのままのサイズで記事に埋め込む');
85+define('_IM_INCLUDE_WAY_OTHER', 'このファイルは、上で入力した説明文がアンカーテキストとなります。文書中の説明文をクリックすると、ファイルがポップアップ表示されます。');
86+define('_IM_INCLUDE_CODE', '入力画面に埋め込まれるコード');
87+define('_IM_INCLUDE_CODE_DESC', '入力画面には、以下のコードが埋め込まれます。このコードは再編集しないでください。');
88+define('_IM_INCLUDE_WAY_DECIDE', '決定');
89+define('_IM_UPLOAD_USED_ASCII', 'ファイル名は必ず英数字');
90+define('_IM_UPLOAD_USED_ASCII_DESC1', '日本語を用いると、アドレスが文字化けしてブラウザで参照できなくなります可能性があります。');
91+define('_IM_UPLOAD_USED_ASCII_DESC2', 'その場合は、削除機能を用いて削除してください。そして、名前を変更してから、再度アップロードしてください。');
92+define('_IM_UPLOAD_USED_FILETYPE', '現在利用できるファイルのタイプ');
93+define('_IM_UPLOAD_CONPLETE', 'ファイルのアップロードが成功しました');
94+define('_IM_COLLECTION_AMOUNT', 'ファイル数: ');
95+define('_IM_COLLECTION_BRANK', 'ファイルなし');
96+define('_IM_REQUIREMENT', '説明文を入力してください');
97+define('_IM_ITEMDISPLAY_WRONG', '1ページの表示ファイル数を、5件から50件の間で指定してください。');
98+
99+define('_IM_SUBDIR', 'サブ・ディレクトリ');
100+define('_IM_COLLECTION_FAILED_READ', 'コレクション・ディレクトリ情報の取得に失敗しました。アクセス権限を確認して下さい');
101+define('_IM_SUBDIR_LABEL', 'サブ・ディレクトリ: ');
102+define('_IM_SUBDIR_SELECT', '選択');
103+define('_IM_SUBDIR_NONE', 'なし');
104+define('_IM_SUBDIR_TT', 'このサブ・ディレクトリに切り替え');
105+define('_IM_SUBDIR_DESC', 'ファイルをアップロードするサブ・ディレクトリを選択してください。なしの場合はコレクション・ディレクトリに保存されます。');
106+define('_IM_DISPLAY_FILES', 'ファイル表示');
107+define('_IM_SUBDIR_REMOVE', 'ディレクトリ削除');
108+define('_IM_DISPLAY_SUBDIR', 'サブ・ディレクトリ管理');
109+define('_IM_DISPLAY_SUBDIR_TT', 'サブ・ディレクトリの管理画面に移動');
110+define('_IM_DISPLAY_SUBDIR_SELECT', '変 更');
111+define('_IM_CREATE_SUBDIR_CONFIRM', 'サブ・ディレクトリ作成');
112+define('_IM_CREATE_SUBDIR_COLLECTION_LABEL', 'コレクション・ディレクトリの指定');
113+define('_IM_CREATE_SUBDIR_COLLECTION', 'サブ・ディレクトリを作成するコレクション・ディレクトリを指定してください');
114+define('_IM_CREATE_SUBDIR_INPUT_NAME', 'サブ・ディレクトリのディレクトリ名');
115+define('_IM_CREATE_SUBDIR_CHARS', 'サブ・ディレクトリ名に指定された以外の文字種が使われています');
116+define('_IM_CREATE_SUBDIR_CHARS_DESC', 'サブ・ディレクトリ名に利用できる文字は、英数字と3種類の記号(アンダーバー、ハイフン、プラス)です。最長で20文字です。それ以外の文字種や日本語は使用できません。');
117+define('_IM_RENAME_SUBDIR_BLANK', 'サブ・ディレクトリ名が空白です');
118+define('_IM_RENAME_SUBDIR_TOOLONG', 'サブ・ディレクトリ名が20文字を超えています');
119+define('_IM_RENAME_SUBDIR_WRONG', 'サブ・ディレクトリ名に指定された以外の文字種が使われています');
120+define('_IM_RENAME_SUBDIR_DUPLICATE', '同名のサブ・ディレクトリがすでに存在しています。');
121+define('_IM_CREATE_SUBDIR_WRONG', 'サブ・ディレクトリが作成できませんので、サーバ管理者に相談してください');
122+define('_IM_RENAME_SUBDIR_COLLECTION', '名前を変更するサブ・ディレクトリ');
123+define('_IM_SUBDIR_NUM_FILES', 'ファイル数');
124+define('_IM_DISPLAY_SUBDIR_LABEL1', 'サブ・ディレクトリ数: ');
125+define('_IM_DISPLAY_SUBDIR_LABEL2', ', ファイル数: ');
126+define('_IM_DISPLAY_SUBDIR_RETURN', 'ファイル一覧');
127+define('_IM_REMOVE_SUBIDR', '削除するサブ・ディレクトリ');
128+define('_IM_REMOVE_SUBIDR_CONFIRM', 'サブ・ディレクトリの削除の確認');
129+define('_IM_REMOVE_SUBIDR_REMIND', 'サブ・ディレクトリを削除すると、中のファイルもすべて同時に削除されます。その際、すでにアイテム内に挿入されているコードは、この操作を行っても自動で書き換えられません。なお、コレクション・ディレクトリを削除することはできません。');
130+define('_IM_REMOVE_SUBDIR_FAILED', 'サブ・ディレクトリの削除に失敗しています。サブ・ディレクトリもしくは含まれているファイルを確認してください。');
131+define('_IM_DISPLAY_SUBDIR_CAPTION', 'サブ・ディレクトリ一覧');
132+define('_IM_DISPLAY_SUBDIR_NOTHING', 'サブ・ディレクトリなし');
133+define('_IM_SUBDIR_REMOVE_FAILED', 'サブ・ディレクトリの削除に失敗しました。サブ・ディレクトリのアクセス権限もしくはサブ・ディレクトリ内のファイルのアクセス権限を確認して下さい。');
134+define('_IM_SUBDIR_FAILED_READ', 'サブ・ディレクトリ情報の取得に失敗しました。アクセス権限を確認して下さい');
135+?>
\ No newline at end of file
--- /dev/null
+++ b/NP_ImprovedMedia/improvedmedia/popups.css
@@ -0,0 +1,163 @@
1+/**
2+ * ImprovedMedia plugin for Nucleus CMS
3+ * Version 3.0.1
4+ * Written By Mocchi, Feb.28, 2010
5+ *
6+ * This program is free software; you can redistribute it and/or
7+ * modify it under the terms of the GNU General Public License
8+ * as published by the Free Software Foundation; either version 3
9+ * of the License, or (at your option) any later version.
10+ */
11+* {
12+ margin: 0px;
13+ padding: 0px;
14+}
15+
16+body {
17+ margin: 10px;
18+ font-family: verdana, arial;
19+ font-size: small;
20+ background-color: #ffffff;
21+ color: #3F3F3F;
22+}
23+
24+img {
25+ border: none;
26+}
27+
28+a:link,a:visited {
29+ color: #1D3565;
30+ font-weight: bold;
31+ text-decoration: none;
32+ border-bottom: dotted 1px #808080;
33+}
34+
35+a:hover {
36+ border-bottom: dotted 1px #808080;
37+}
38+
39+p {
40+ margin: 4px 0px 4px 20px;
41+}
42+
43+p.line {
44+ margin-left: 100px;
45+}
46+
47+h1 {
48+ font-size: large;
49+ color: #596D9D;
50+ margin-bottom: 3px;
51+}
52+
53+span.header {
54+ color: gray;
55+ font-size: small;
56+}
57+
58+h2 {
59+ font-size: medium;
60+ color: #596D9D;
61+ margin: 0.5em 0em 0.5em 0em;
62+}
63+
64+h3 {
65+ color: #596D9D;
66+ font-size: small;
67+ margin: 10px 10px 5px 10px;
68+}
69+
70+table {
71+ border: none;
72+}
73+
74+table caption {
75+ padding: 3px;
76+ text-align: left;
77+ font-weight: bold;
78+}
79+
80+thead {
81+ background-color: linen;
82+}
83+
84+tbody {
85+ background-color: #DDDDDD;
86+}
87+
88+tfoot {
89+ background-color: #FFFFFF;
90+}
91+
92+th, td {
93+ vertical-align: middle;
94+ font-size: small;
95+ font-weight: normal;
96+}
97+
98+th {
99+ margin: 0px;
100+}
101+
102+td {
103+ padding: 3px;
104+ margin: 0px;
105+}
106+
107+th p, td p {
108+ margin:0px;
109+ padding: 0px;
110+}
111+
112+td.right {
113+ text-align: right;
114+}
115+
116+label {
117+ cursor: pointer;
118+}
119+
120+input.formbutton {
121+ font-size: x-small;
122+ padding: 1px;
123+ background-color: #BFBFBF;
124+}
125+
126+dt {
127+ font-weight: bold;
128+}
129+
130+dd {
131+ margin: 0px 0px 5px 10px;
132+}
133+
134+div.filedetail {
135+ margin: 5px;
136+ border: 1px solid #333333;
137+ padding: 5px 10px 5px 10px;
138+}
139+
140+form {
141+ display: inline;
142+}
143+
144+form p.left {
145+ display: inline;
146+ width: 8em;
147+ float: left;
148+}
149+
150+form p.right {
151+ margin: 0px;
152+ padding: 5px 0px 0px 0px;
153+}
154+
155+p.notice {
156+ font-weight: bold;
157+ font-size: large;
158+ color: #FF5A00;
159+}
160+
161+option {
162+ width: 120px;
163+}
\ No newline at end of file
--- /dev/null
+++ b/NP_MediaUtils/NP_MediaUtils.php
@@ -0,0 +1,122 @@
1+<?php
2+/**
3+ * MediaUtils plugin for Nucleus CMS
4+ * Version 0.9.6 (1.0 RC2) for PHP5
5+ * Written By Mocchi, Apr. 04, 2011
6+ *
7+ * This program is free software; you can redistribute it and/or
8+ * modify it under the terms of the GNU General Public License
9+ * as published by the Free Software Foundation; either version 3
10+ * of the License, or (at your option) any later version.
11+ */
12+
13+class NP_MediaUtils extends NucleusPlugin {
14+ public function getName() { return 'MediaUtils'; }
15+ public function getAuthor() { return 'Mocchi'; }
16+ public function getURL() { return 'http://japan.nucleuscms.org/wiki/plugins:mediautils'; }
17+ public function getVersion() { return '0.9.6 (1.0 RC2)'; }
18+ public function getDescription() { return 'Load MediaUtils, static function set for media management. Another function of this plugin is keeping Cookies for identifying weblog id.'; }
19+
20+ public function getMinNucleusVersion() { return 340; }
21+ public function supportsFeature($feature) { return in_array ($feature, array ('SqlTablePrefix', 'SqlApi')); }
22+ public function getEventList() { return array('PostAuthentication', 'InitSkinParse', 'PreSendContentType'); }
23+
24+ /*
25+ * NOTICE: Event drivened method can get a correct blogid in initSkinParse.
26+ */
27+ public function event_PostAuthentication($data) {
28+ global $CONF;
29+ static $blogid = 0;
30+ static $blogs = array();
31+
32+ if (!class_exists('MediaUtils', FALSE)) {
33+ include ($this->getDirectory() . 'MediaUtils.php');
34+ }
35+
36+ MediaUtils::$lib_path = preg_replace('#/*$#', '', $this->getDirectory());
37+ MediaUtils::$prefix = (boolean) $CONF['MediaPrefix'];
38+ MediaUtils::$maxsize = (integer) $CONF['MaxUploadSize'];
39+
40+ $suffixes = explode(',', $CONF['AllowedTypes']);
41+ foreach ($suffixes as $suffix) {
42+ $suffix = trim($suffix);
43+ if(!in_array($suffix, MediaUtils::$suffixes)) {
44+ MediaUtils::$suffixes[] = strtolower($suffix);
45+ }
46+ }
47+
48+ $result = sql_query('SELECT bnumber, bshortname FROM ' . sql_table('blog') . ';');
49+ while(FALSE !== ($row = sql_fetch_assoc($result))) {
50+ $blogs[$row['bnumber']] = $row['bshortname'];
51+ }
52+ MediaUtils::$blogs = $blogs;
53+
54+ if (array_key_exists('blogid', $_GET)) {
55+ $blogid = (integer) $_GET['blogid'];
56+ } else if (array_key_exists('blogid', $_POST)) {
57+ $blogid = (integer) $_POST['blogid'];
58+ } else if (array_key_exists('itemid', $_GET)) {
59+ $blogid = (integer) getBlogIDFromItemID((integer) $_GET['itemid']);
60+ } else if (array_key_exists('itemid', $_POST)) {
61+ $blogid = (integer) getBlogIDFromItemID((integer) $_POST['itemid']);
62+ } else if (array_key_exists(MediaUtils::$cookiename, $_COOKIE)) {
63+ $blogid = (integer) $_COOKIE['blogid'];
64+ }
65+
66+ if (!$blogid || !array_key_exists($blogid, $blogs)) {
67+ self::setCookie(-1);
68+ return;
69+ }
70+
71+ MediaUtils::$blogid = (integer) $blogid;
72+ MediaUtils::$bshortname = (string) $blogs[$blogid];
73+ self::setCookie(1);
74+
75+ return;
76+ }
77+
78+ public function event_PreSendContentType($data) {
79+ global $blog, $blogid;
80+ if (MediaUtils::$blogid) {
81+ return;
82+ }
83+
84+ if (!$blogid && !$blog) {
85+ self::setCookie(-1);
86+ return;
87+ }
88+
89+ if (!$blogid) {
90+ MediaUtils::$blogid = $blog->getID();
91+ } else {
92+ MediaUtils::$blogid = $blogid;
93+ }
94+
95+ if (!$blog) {
96+ MediaUtils::$bshortname = $manager->getBlog(MediaUtils::$blogid)->getShortName();
97+ } else {
98+ MediaUtils::$bshortname = $blog->getShortName();
99+ }
100+
101+ self::setCookie(1);
102+ return;
103+ }
104+
105+ public function event_InitSkinParse($data) {
106+ global $blogid;
107+ if (MediaUtils::$blogid != $blogid) {
108+ MediaUtils::$blogid = $blogid;
109+ MediaUtils::$bshortname = MediaUtils::$blogs[MediaUtils::$blogid];
110+ self::setCookie(1);
111+ }
112+ return;
113+ }
114+
115+ private function setCookie($factor) {
116+ global $CONF;
117+ $factor = (integer) $factor;
118+
119+ setcookie($CONF['CookiePrefix'] . MediaUtils::$cookiename, MediaUtils::$blogid, time()+180*$factor, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
120+ return;
121+ }
122+}
--- /dev/null
+++ b/NP_MediaUtils/mediautils/MediaUtils.php
@@ -0,0 +1,490 @@
1+<?php
2+/**
3+ * MediaUtils plugin for Nucleus CMS
4+ * Version 0.9.6 (1.0 RC2) for PHP5
5+ * Written By Mocchi, Apr. 04, 2011
6+ *
7+ * This program is free software; you can redistribute it and/or
8+ * modify it under the terms of the GNU General Public License
9+ * as published by the Free Software Foundation; either version 3
10+ * of the License, or (at your option) any later version.
11+ */
12+
13+class MediaUtils {
14+ static public $lib_path = '';
15+
16+ static public $cookiename = 'blogid';
17+ static public $blogid = FALSE;
18+ static public $blogs = array();
19+ static public $bshortname = '';
20+
21+ static public $prefix = TRUE;
22+ static public $maxsize = 2097152;
23+ static public $suffixes = array();
24+
25+ static public $algorism = 'md5';
26+ static public $image_mime
27+ = array('image/jpeg' => '.jpeg',
28+ 'image/png' => '.png',
29+ /* 'image/bmp' => '.bmp', not implemented*/
30+ 'image/gif' => '.gif');
31+
32+/**
33+ * error and exit
34+ * @access Public MediaUtils::error
35+ * @param String $message Error message
36+ * @exit
37+ */
38+ static public function error ($message) {
39+ (string) $message;
40+ header("HTTP/1.0 404 Not Found");
41+ exit($message);
42+ }
43+
44+/**
45+ * send resampled image via HTTP
46+ * @access Public MediaUtils::responseResampledImage
47+ * @param Object $medium Medium Object
48+ * @exit
49+ */
50+ static public function responseResampledImage ($medium) {
51+ if (!class_exists('Medium', FALSE)) {
52+ include(self::$lib_path . '/Medium.php');
53+ }
54+
55+ if ('Medium' !== get_class($medium)) {
56+ self::error ('NP_MediaUtils: Fail to generate resampled image');
57+ return;
58+ }
59+
60+ if (FALSE === ($resampledimage = $medium->getResampledBinary(self::$image_mime))) {
61+ unset ($resampledimage);
62+ self::error ('NP_MediaUtils: Fail to generate resampled image');
63+ return;
64+ }
65+
66+ header ('Content-type: ' . $medium->mime);
67+ echo $resampledimage;
68+ unset ($resampledimage);
69+ exit;
70+ }
71+
72+/**
73+ * Store resampled image binary to filesystem as file
74+ * @access Public MediaUtils::storeResampledImage
75+ * @param String $root root directory for media
76+ * @param String $path Relative path from root to destination
77+ * @param Object $medium Medium Object
78+ * @return Boolean TRUE/FALSE
79+ */
80+ static public function storeResampledImage ($root, $target, $medium) {
81+ if (!class_exists('Medium', FALSE)) {
82+ include(self::$lib_path . '/Medium.php');
83+ }
84+
85+ if ('Medium' !== get_class($medium)) {
86+ return FALSE;
87+ }
88+
89+ if (FALSE === ($resampledimage = $medium->getResampledBinary(self::$image_mime))) {
90+ unset ($resampledimage);
91+ return FALSE;
92+ }
93+
94+ if (FALSE === ($handle = @fopen ("{$root}/{$target}", 'w'))) {
95+ unset ($resampledimage);
96+ return FALSE;
97+ }
98+
99+ if (@fwrite ($handle, $resampledimage) === FALSE) {
100+ unset ($resampledimage);
101+ @unlink ("{$root}/{$target}");
102+ return FALSE;
103+ }
104+
105+ unset ($resampledimage);
106+ fclose ($handle);
107+
108+ if (@chmod ("{$root}/{$target}", 0744) === FALSE) {
109+ @unlink ("{$root}/{$target}");
110+ return FALSE;
111+ }
112+
113+ return TRUE;
114+ }
115+
116+/**
117+ * Check the path as directory and writable
118+ * @access Public MediaUtils::checkDir
119+ * @param String Fullpath
120+ * @return Boolean TRUE/FALSE
121+ */
122+ static public function checkDir ($fullpath) {
123+ $fullpath = (string) $fullpath;
124+
125+ if (file_exists ($fullpath)) {
126+ if (is_dir ($fullpath) && is_writable ($fullpath)) {
127+ return TRUE;
128+ } else {
129+ return FALSE;
130+ }
131+ } else {
132+ if (!@mkdir ($fullpath, 0777)) {
133+ return FALSE;
134+ } else {
135+ return TRUE;
136+ }
137+ }
138+ }
139+
140+/**
141+ * Return file data list
142+ * @access Public MediaUtils::getMediaList
143+ * @param String $root path to media root directory
144+ * @param Boolean $hidden show hidden files (.*) or not
145+ * @param Boolean $recursive follow recursively or not
146+ * @param Boolean $prefix analyze its prefix or not
147+ * @param String $suffix limit by suffix
148+ * @param String $path relative path from root to destination
149+ * @return Array Array(Medium)
150+ */
151+ static public function getMediaList ($root, $hidden=TRUE, $recursive=TRUE, $suffix='', $path='', $media=array()) {
152+ $root = (string) $root;
153+ $hidden = (boolean) $hidden;
154+ $recursive = (boolean) $recursive;
155+ $suffix = (string) $suffix;
156+ $path = (string) $path;
157+ $media = (array) $media;
158+
159+ if (!class_exists('Medium', FALSE)) {
160+ include(self::$lib_path . '/Medium.php');
161+ }
162+
163+ $root = rtrim($root, '/');
164+ if(!$root || !file_exists($root)) {
165+ return FALSE;
166+ }
167+
168+ $fullpath = $root;
169+ if ($path) {
170+ $path = trim($path, '/');
171+ $fullpath = "{$root}/{$path}";
172+ }
173+
174+ if (FALSE === ($handle = @opendir($fullpath))) {
175+ return FALSE;
176+ }
177+ while(FALSE !== ($filename = readdir($handle))) {
178+ if ($filename !== '.' && $filename !== '..') {
179+ if (($hidden && preg_match("#^\.#", $filename))
180+ || ($suffix && !preg_match("#\.$suffix$#", $filename))) {
181+ continue;
182+ }
183+
184+ if($recursive && filetype("{$fullpath}/{$filename}") === "dir") {
185+ $media = self::getMediaList($root, $hidden, $recursive, $suffix, trim("{$path}/{$filename}", '/'), $media);
186+ } else if ($path !== '' && filetype("{$fullpath}/{$filename}") === "file") {
187+ $media[] = new Medium($root, trim("{$path}/{$filename}", '/'), self::$prefix);
188+ continue;
189+ }
190+ }
191+ }
192+ closedir($handle);
193+ return $media;
194+ }
195+
196+/*
197+ * Purge directory
198+ * @access Public MediaUtils::purgeDir
199+ * @param String $root path to media root directory
200+ * @param String $path relative path from root to destination
201+ * @return Array/FALSE $logs
202+ *
203+ */
204+ static public function purgeDir($root, $path='', $logs=array()) {
205+ $root = (string) $root;
206+ $path = (string) $path;
207+ $logs = (array) $logs;
208+
209+ $root = rtrim($root, '/');
210+ if(!$root || !file_exists($root)) {
211+ return FALSE;
212+ }
213+
214+ $fullpath = $root;
215+ if ($path) {
216+ $path = trim($path, '/');
217+ $fullpath = "{$root}/{$path}";
218+ }
219+
220+ if (FALSE === ($handle = @opendir($fullpath))) {
221+ return FALSE;
222+ }
223+ while(FALSE !== ($filename = readdir($handle))) {
224+ if ($filename !== '.' && $filename !== '..') {
225+ if(filetype("{$fullpath}/{$filename}") === "dir") {
226+ $logs = self::purgeDir($root, "{$path}/{$filename}", $logs);
227+ } else {
228+ if(!unlink("{$root}/{$path}/{$filename}")) {
229+ $logs[] = "Exists: {$path}/{$filename}";
230+ } else {
231+ $logs[] = "Removed: {$path}/{$filename}";
232+ }
233+ continue;
234+ }
235+ }
236+ }
237+ if(!rmdir("{$root}/{$path}")) {
238+ $logs[] = "Exists: {$path}";
239+ } else {
240+ $logs[] = "Removed: {$path}";
241+ }
242+ return $logs;
243+ }
244+
245+/*
246+ * Return path list under root
247+ * @access Public MediaUtils::getPathList
248+ * @param String $root full path to root directory
249+ * @param String $path certain path to search
250+ * @param Boolean $private use private directory or not
251+ * @param Boolean $recursize search recursively or not
252+ * @param Boolean $hidden do not list up the directory started with piriod or not
253+ * @return String $name
254+ *
255+ */
256+ static public function getPathList($root, $path='', $private=FALSE, $hidden=TRUE, $recursive=TRUE) {
257+ $root = (string) $root;
258+ $path = (string) $path;
259+ $hidden = (boolean) $hidden;
260+ $recursive = (boolean) $recursive;
261+
262+ $paths=array();
263+
264+ $root = rtrim($root, '/');
265+ if(!$root || !file_exists($root)) {
266+ return FALSE;
267+ }
268+
269+ $fullpath = $root;
270+ if ($path) {
271+ $path = trim($path, '/');
272+ $fullpath = "{$root}/{$path}";
273+ }
274+
275+ if (FALSE === ($handle = @opendir($fullpath))) {
276+ return FALSE;
277+ }
278+ while (FALSE !== ($filename = readdir($handle))) {
279+ if (in_array($filename, array('.', '..', 'CVS'))) {
280+ continue;
281+ } else if (is_file("{$fullpath}/{$filename}")) {
282+ continue;
283+ } else if ($hidden && preg_match('#^\.#', $filename)) {
284+ continue;
285+ } else if ($private && is_numeric($filename) && $path==''&& $private != $filename) {
286+ continue;
287+ }
288+
289+ if (!$path) {
290+ $relpath = $filename;
291+ } else {
292+ $relpath = "{$path}/{$filename}";
293+ }
294+
295+ $paths = self::getPathData($root, $relpath, $private, $hidden, $recursive, $paths);
296+ }
297+ closedir($handle);
298+
299+ if ($path=='' && $private) {
300+ if (!array_key_exists($private, $paths)) {
301+ $paths[$private] = array('root'=>$root , 'path'=>$private, 'files'=>0, 'dirs'=>0);
302+ }
303+ $paths[$private]['label'] = 'PRIVATE';
304+ }
305+
306+ ksort($paths, SORT_STRING);
307+ return $paths;
308+ }
309+
310+/*
311+ * Return path data
312+ * @access Public MediaUtils::getPathData
313+ * @param String $root full path to root directory
314+ * @param String $path relative path from root to target directory
315+ * @param Boolean $private use private directory or not
316+ * @param Boolean $hidden do not list up the directory started with piriod or not
317+ * @param Boolean $recursive search recursively or not
318+ * @return Array Array('root', 'parent', 'name', 'files', 'dirs', 'label')
319+ */
320+ static public function getPathData($root, $path, $private=FALSE, $hidden=TRUE, $recursive=FALSE, $paths=array()) {
321+ $root = (string) $root;
322+ $path = (string) $path;
323+ $private = (boolean) $private;
324+ $hidden = (boolean) $hidden;
325+ $recursive = (boolean) $recursive;
326+
327+ $cnt_files = 0;
328+ $cnt_dirs = 0;
329+
330+ $root = rtrim($root, '/');
331+ if(!$root || !file_exists($root)) {
332+ return FALSE;
333+ }
334+
335+ $fullpath = $root;
336+ if ($path) {
337+ $path = trim($path, '/');
338+ $fullpath = "{$root}/{$path}";
339+ }
340+
341+ if (FALSE === ($handle = @opendir($fullpath))) {
342+ return FALSE;
343+ }
344+ while (FALSE !== ($filename = readdir($handle))) {
345+ if (in_array($filename, array('.', '..', 'CVS'))) {
346+ continue;
347+ } else if (!is_dir("{$fullpath}/{$filename}")) {
348+ if (!$hidden || !preg_match('#^\.#', $filename)){
349+ $cnt_files++;
350+ }
351+ continue;
352+ } else if ($hidden && preg_match('#^\.#', $filename)) {
353+ continue;
354+ }
355+
356+ $cnt_dirs++;
357+
358+ if (!$path) {
359+ $relpath = $filename;
360+ } else {
361+ $relpath = "{$path}/{$filename}";
362+ }
363+
364+ if ($recursive) {
365+ $paths = self::getPathData($root, $relpath, $private, $recursive, $hidden, $paths);
366+ }
367+ }
368+ closedir($handle);
369+
370+ $paths[$path]['root'] = $root;
371+ $paths[$path]['parent'] = trim(str_replace(basename($fullpath), '', $path), '/');
372+ $paths[$path]['name'] = basename($fullpath);
373+ $paths[$path]['files'] = $cnt_files;
374+ $paths[$path]['dirs'] = $cnt_dirs;
375+ if ($private) {
376+ $paths[$path]['label'] = preg_replace("#^$private#", 'PRIVATE', $path);
377+ } else {
378+ $paths[$path]['label'] = $path;
379+ }
380+
381+ return $paths;
382+ }
383+
384+/*
385+ * Store uploaded binary to filesystem
386+ * @access Public MediaUtils::uploadMedium
387+ * @param String $root path to edia root directory
388+ * @param String $path relative path from root to target directory
389+ * @param Array $medium uploaded binary data.
390+ * @param String/FALSE $overwrite overwrite or not if the file already exists
391+ * @param Object $manager Nucleus Manager Object
392+ * @return String $log Return '' if success, others is error messages
393+ *
394+ */
395+ static public function uploadMedium ($root, $path, &$temp, $overwrite='', &$manager='') {
396+ $root = (string) $root;
397+ $path = (string) $path;
398+ $temp = (array) $temp;
399+ $overwrite = (string) $overwrite;
400+ $manager = (object) $manager;
401+
402+ /**
403+ * $temp should be derived from $_FILE
404+ */
405+ foreach(array('name', 'tmp_name','size', 'error') as $key) {
406+ if (!array_key_exists($key, $temp)) {
407+ return 'NP_MediaUtils: Miss uploaded file.';
408+ }
409+ }
410+
411+ $root = rtrim($root, '/');
412+ if(!$root || !file_exists($root) || !$path) {
413+ return 'NP_MediaUtils: Destination is invalid.';
414+ }
415+ $path = trim($path, '/');
416+
417+ /**
418+ * see http://www.php.net/manual/en/features.file-upload.errors.php
419+ */
420+ switch ($temp['error']) {
421+ case UPLOAD_ERR_OK:
422+ break;
423+ case UPLOAD_ERR_INI_SIZE:
424+ case UPLOAD_ERR_FORM_SIZE:
425+ return 'NP_MediaUtils: Binary is too big.';
426+ case UPLOAD_ERR_PARTIAL:
427+ case UPLOAD_ERR_NO_FILE:
428+ case UPLOAD_ERR_NO_TMP_DIR:
429+ case UPLOAD_ERR_CANT_WRITE:
430+ case UPLOAD_ERR_EXTENSION :
431+ default:
432+ return 'NP_MediaUtils: Request rejected';
433+ }
434+
435+ if (preg_match ("#(\\\\|/|\\n)#", $temp['name'])) {
436+ return 'NP_MediaUtils: invalid filename';
437+ }
438+
439+ if ($temp['size'] > self::$maxsize) {
440+ return 'NP_MediaUtils: Binary is too big';
441+ }
442+
443+ if (!empty(self::$suffixes) && is_array(self::$suffixes)) {
444+ preg_match("#\.(.+)$#", $temp['name'], $match);
445+ $suffix = strtolower($match[1]);
446+ if (!in_array($suffix, self::$suffixes)) {
447+ return 'NP_MediaUtils: Forbidden file suffix';
448+ }
449+ }
450+
451+ if (!self::checkDir("{$root}/{$path}")) {
452+ return 'NP_MediaUtils: Invalid target directory';
453+ }
454+
455+ if ($overwrite) {
456+ if (!preg_match("#\.($suffix)$#", strtolower($overwrite), $match)) {
457+ return 'NP_MediaUtils: suffix is not the same.';
458+ }
459+ $temp['name'] = $overwrite;
460+ } else if (self::$prefix) {
461+ $temp['name'] = strftime ("%Y%m%d-", time ()) . $temp['name'];
462+ }
463+
464+ if (!$overwrite && file_exists("{$root}/{$path}/{$temp['name']}")) {
465+ return 'NP_MediaUtils: The same filename already exists in this target directory.';
466+ }
467+
468+ if ($manager) {
469+ $manager->notify('PreMediaUpload',array('collection' => &$path, 'uploadfile' => $temp['tmp_name'], 'filename' => $temp['name']));
470+ }
471+
472+ if (is_uploaded_file($temp['tmp_name'])) {
473+ if (!@move_uploaded_file($temp['tmp_name'], "{$root}/{$path}/{$temp['name']}")) {
474+ return 'NP_MediaUtils: Fail to move uploaded binary to file sytem.';
475+ }
476+ } else if (!copy($temp['tmp_name'], "{$root}/{$path}/{$temp['name']}")) {
477+ return 'NP_MediaUtils: Fail to copy uploaded binary to file sytem.';
478+ }
479+
480+ $oldumask = umask(0000);
481+ @chmod("{$root}/{$path}/{$temp['name']}", 0644);
482+ umask($oldumask);
483+
484+ if ($manager) {
485+ $manager->notify('PostMediaUpload',array('collection' => $path, 'mediadir' => $root, 'filename' => $temp['name']));
486+ }
487+
488+ return '';
489+ }
490+}
--- /dev/null
+++ b/NP_MediaUtils/mediautils/Medium.php
@@ -0,0 +1,229 @@
1+<?php
2+/**
3+ * MediaUtils plugin for Nucleus CMS
4+ * Version 0.9.6 (1.0 RC2) for PHP5
5+ * Written By Mocchi, Apr. 04, 2011
6+ *
7+ * This program is free software; you can redistribute it and/or
8+ * modify it under the terms of the GNU General Public License
9+ * as published by the Free Software Foundation; either version 3
10+ * of the License, or (at your option) any later version.
11+ */
12+
13+class Medium {
14+ public $root = '';
15+ public $path = '';
16+ public $name = '';
17+ public $update = '';
18+ public $prefix = '';
19+ public $suffix = '';
20+ public $filename = '';
21+ public $size = 0;
22+ public $mime = '';
23+ public $width = 0;
24+ public $height = 0;
25+ public $resampledwidth = 0;
26+ public $resampledheight = 0;
27+
28+/**
29+ * Return MEDIUM Object
30+ * @access Public $this->__construnct
31+ * @param String $root
32+ * @param String $relativepath
33+ * @param Boolean $prefix
34+ * @return Object/FALSE
35+ */
36+ public function __construct ($root, $relativepath, $prefix) {
37+ static $fullpath;
38+ static $info;
39+
40+ if ($root == '' || $relativepath == '') {
41+ return FALSE;
42+ }
43+
44+ $root = preg_replace('#/*$#', '', $root);
45+ if ($root == '' || $relativepath == ''
46+ || !file_exists($root)
47+ || FALSE === ($fullpath = realpath(rtrim($root . '/' . ltrim($relativepath, '/'), '/')))
48+ || strpos($fullpath, $root) !== 0
49+ || !file_exists($fullpath)) {
50+ return FALSE;
51+ }
52+
53+ $this->root = $root;
54+ $this->name = basename($fullpath);
55+ $this->path = str_replace(array($this->root.'/', '/'.$this->name), '', $fullpath);
56+
57+ if ($this->path === $this->name) {
58+ $this->path = '';
59+ }
60+
61+ if (FALSE === ($info = @getimagesize ($fullpath))) {
62+ $this->mime = 'application/octet-stream';
63+ $this->width = 0;
64+ $this->height = 0;
65+ } else {
66+ $this->mime = $info['mime'];
67+ $this->width = $info[0];
68+ $this->height = $info[1];
69+ }
70+
71+ set_time_limit(ini_get('max_execution_time'));
72+ if (defined('FILEINFO_MIME_TYPE')
73+ && function_exists ('finfo_open')
74+ && (FALSE !== ($info = finfo_open(FILEINFO_MIME_TYPE)))) {
75+ $this->mime = finfo_file($info, $fullpath);
76+ }
77+
78+ $this->update = date("Y/m/d", @filemtime($fullpath));
79+ $this->size = ceil(filesize($fullpath) / 1000);
80+
81+ if (preg_match('#^(.*)\.([a-zA-Z0-9]{2,})$#', $this->name, $info) === 1) {
82+ $this->filename = $info[1];
83+ $this->suffix = $info[2];
84+ if ($prefix && preg_match('#^([0-9]{8})\-(.*)$#', $this->filename, $info) == 1 ) {
85+ $this->prefix = preg_replace('#^([0-9]{4})([0-9]{2})([0-9]{2})$#', '$1/$2/$3', $info[1]);
86+ $this->filename = $info[2];
87+ }
88+ }
89+
90+ return $this;
91+ }
92+
93+ public function __destruct () {
94+ return;
95+ }
96+
97+/**
98+ * Set resampled size
99+ * @access Public $this->setResampledSize
100+ * @param Integer $maxwidth
101+ * @param Integer $maxheight
102+ * @return Boolean
103+ */
104+ public function setResampledSize($maxwidth=0, $maxheight=0) {
105+ if (($maxwidth == 0) && ($maxheight == 0)) {
106+ return FALSE;
107+ } else if ($this->width == 0 || $this->height == 0) {
108+ return FALSE;
109+ } else if ($this->width < $maxwidth && $this->height < $maxheight) {
110+ $this->resampledwidth = $this->width;
111+ $this->resampledheight = $this->height;
112+ } else if ($maxheight == 0 || $this->width > $this->height) {
113+ $this->resampledheight = intval ($this->height * $maxwidth / $this->width);
114+ $this->resampledwidth = $maxwidth;
115+ } else if ($maxwidth == 0 || $this->width <= $this->height) {
116+ $this->resampledwidth = intval ($this->width * $maxheight / $this->height);
117+ $this->resampledheight = $maxheight;
118+ }
119+ return TRUE;
120+ }
121+
122+/**
123+ * Return resampled image binary
124+ * @access Public $this->getResampledSize
125+ * @param Integer $maxwidth
126+ * @param Integer $maxheight
127+ * @return Boolean
128+ */
129+ public function getResampledBinary ($image_mime) {
130+ static $gdinfo;
131+ static $original;
132+ static $resampledimage;
133+
134+ $gdinfo = gd_info();
135+
136+ if ($this->path !== '') {
137+ $fullpath = "{$this->root}/{$this->path}/{$this->name}";
138+ } else {
139+ $fullpath = "{$this->root}/{$this->name}";
140+ }
141+ if (!file_exists($fullpath)) {
142+ return FALSE;
143+ }
144+
145+ if (!array_key_exists($this->mime, $image_mime)
146+ || $this->width == 0
147+ || $this->height == 0
148+ || $this->resampledwidth == 0
149+ || $this->resampledheight == 0) {
150+ return FALSE;
151+ }
152+
153+ // check current available memory
154+ $memorymax = trim(ini_get("memory_limit"));
155+ switch (strtolower ($memorymax[strlen($memorymax)-1])) {
156+ case 'g':
157+ $memorymax *= 1024;
158+ case 'm':
159+ $memorymax *= 1024;
160+ case 'k':
161+ $memorymax *= 1024;
162+ }
163+
164+ // this code is based on analyze if gd.c in php source code
165+ // if you can read C/C++, please check these elements and notify us if you have some ideas
166+ if ((memory_get_usage() + ($this->resampledwidth * $this->resampledheight * 5 + $this->resampledheight * 24 + 10000) + ($this->width * $this->height * 5 + $this->height * 24 + 10000)) > $memorymax) {
167+ return FALSE;
168+ }
169+
170+ switch ($this->mime) {
171+ case 'image/gif':
172+ if (!$gdinfo['GIF Read Support'] && !$gdinfo['GIF Create Support']) {
173+ return FALSE;
174+ }
175+ $original = imagecreatefromgif ($fullpath);
176+ break;
177+ case 'image/jpeg':
178+ if ((array_key_exists('JPEG Support', $gdinfo) && !$gdinfo['JPEG Support']) && (array_key_exists('JPG Support', $gdinfo) && $gdinfo['JPG Support'])) {
179+ return FALSE;
180+ }
181+ $original = imagecreatefromjpeg ($fullpath);
182+ break;
183+ case 'image/png':
184+ if (!$gdinfo['PNG Support']) {
185+ return FALSE;
186+ }
187+ $original = imagecreatefrompng ($fullpath);
188+ break;
189+ default:
190+ return FALSE;
191+ }
192+
193+ $resampledimage = imagecreatetruecolor ($this->resampledwidth, $this->resampledheight);
194+
195+ if (!$resampledimage) {
196+ return FALSE;
197+ }
198+
199+ set_time_limit(ini_get('max_execution_time'));
200+ if (!ImageCopyResampled ($resampledimage, $original, 0, 0, 0, 0, $this->resampledwidth, $this->resampledheight, $this->width, $this->height)) {
201+ return FALSE;
202+ }
203+
204+ imagedestroy ($original);
205+
206+ ob_start();
207+
208+ switch ($this->mime) {
209+ case 'image/gif':
210+ imagegif ($resampledimage);
211+ break;
212+ case 'image/jpeg':
213+ imagejpeg ($resampledimage);
214+ break;
215+ case 'image/png':
216+ imagepng ($resampledimage);
217+ break;
218+ default:
219+ }
220+
221+ imagedestroy ($resampledimage);
222+
223+ return ob_get_clean();
224+ }
225+
226+ public function getHashedName($algorism) {
227+ return (string) hash($algorism, "{$this->path}/{$this->name}", FALSE);
228+ }
229+}
--- /dev/null
+++ b/NP_Thumbnail/NP_Thumbnail.php
@@ -0,0 +1,529 @@
1+<?php
2+/**
3+ * Thumbnail plugin for Nucleus CMS
4+ * Version 3.9.6 (4.0 RC2) for PHP5
5+ * Written By Mocchi, Apr. 04, 2011
6+ * Original code was written by jirochou, May 23, 2004 and maintained by nakahara21
7+ * This plugin depends on 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+class NP_Thumbnail extends NucleusPlugin {
16+ private static $thumbdir = '.thumb';
17+ private static $max_sync = 10;
18+ private static $authorid = 0;
19+ private static $buffering = FALSE;
20+ private static $table_name = 'plugin_thumbnail'; // not implemented
21+
22+ public function getName() { return 'Thumbnail'; }
23+ public function getAuthor() { return 'Mocchi, nakahara21, jirochou'; }
24+ public function getURL() { return 'http://japan.nucleuscms.org/wiki/plugins:thumbnail'; }
25+ public function getVersion() { return '3.9.6 (4.0 RC2)'; }
26+ public function getDescription() { return _NP_THUMBNAIL_01; }
27+ public function getPluginDep() { return array('NP_MediaUtils');}
28+ public function getMinNucleusVersion() {return 340;}
29+ public function supportsFeature($feature) { return in_array ($feature, array('SqlTablePrefix', 'SqlApi'));}
30+ public function getEventList() { return array('QuickMenu', 'PrePluginOptionsEdit', 'PostAuthentication', 'PreItem', 'PostMediaUpload'); }
31+
32+ public function install () {
33+ $this->createOption('maxwidth', '_NP_THUMBNAIL_02', 'text', '100', 'datatype=numerical');
34+ $this->createOption('maxheight', '_NP_THUMBNAIL_03', 'text', '100', 'datatype=numerical');
35+ $this->createOption('save_thumb', '_NP_THUMBNAIL_04', 'select', 'filesystem', '_NP_THUMBNAIL_05|no|_NP_THUMBNAIL_06|filesystem');
36+ $this->createBlogOption('force_thumb', '_NP_THUMBNAIL_07', 'yesno', 'yes');
37+ $this->createBlogOption('thumb_template', '_NP_THUMBNAIL_08', 'textarea', '<a href="<%rawpopuplink%>" title="<%popuptext%>" onclick="<%popupcode%>"><img src="<%thumb_url%>" width="<%thumb_width%>" height="<%thumb_height%>" alt="<%popuptext%>" /></a>');
38+ return;
39+ }
40+
41+ /*
42+ * plugin options are purged automatically when uninstalled.
43+ */
44+ public function uninstall() {
45+ global $DIR_MEDIA;
46+ MediaUtils::purgeDir($DIR_MEDIA . self::$thumbdir);
47+ return;
48+ }
49+
50+ public function init() {
51+ global $DIR_MEDIA;
52+
53+ if (!class_exists('Medium', FALSE)) {
54+ include(MediaUtils::$lib_path . '/Medium.php');
55+ }
56+
57+ $language = preg_replace('#[/|\\\\]#', '', getLanguageName());
58+
59+ if (!defined('_NP_THUMBNAIL_01')) {
60+ if (file_exists($this->getDirectory() . $language.'.php')) {
61+ include($this->getDirectory() . $language.'.php');
62+ } else {
63+ include($this->getDirectory() . 'english.php');
64+ }
65+ }
66+ return;
67+ }
68+
69+/*
70+ * for translation
71+ */
72+ public function event_PrePluginOptionsEdit ($data) {
73+ if ($data['context'] != 'global') {
74+ foreach($data['options'] as $key => $option) {
75+ if ($option['pid'] == $this->getID()) {
76+ if (defined($option['description'])) {
77+ $data['options'][$key]['description'] = constant($option['description']);
78+ }
79+ if ($option['type'] == 'select') {
80+ foreach (explode('|', $option['typeinfo']) as $option) {
81+ if (defined($option)) {
82+ $data['options'][$key]['typeinfo'] = str_replace($option, constant($option), $data['options'][$key]['typeinfo']);
83+ }
84+ }
85+ }
86+ }
87+ }
88+ } else if ($data['plugid'] == $this->getID()) {
89+ foreach($data['options'] as $key => $option){
90+ if (defined($option['description'])) {
91+ $data['options'][$key]['description'] = constant($option['description']);
92+ }
93+ if ($option['type'] == 'select') {
94+ foreach (explode('|', $option['typeinfo']) as $option) {
95+ if (defined($option)) {
96+ $data['options'][$key]['typeinfo'] = str_replace($option, constant($option), $data['options'][$key]['typeinfo']);
97+ }
98+ }
99+ }
100+ }
101+ }
102+ return;
103+ }
104+
105+/*
106+ * for translation
107+ */
108+ static private function t ($text, $array=array()){
109+ if (is_array($array)) {
110+ $search = array();
111+ $replace = array();
112+
113+ foreach ($array as $key => $value){
114+ if (is_array($value)) {
115+ continue;
116+ }
117+ $search[] = '<%'.preg_replace('/[^a-zA-Z0-9_]+/','',$key).'%>';
118+ $replace[] = $value;
119+ }
120+ }
121+ return htmlspecialchars (str_replace($search, $replace, $text), ENT_QUOTES, _CHARSET);
122+ }
123+
124+ public function event_QuickMenu ($data) {
125+ global $CONF;
126+ if($this->getOption('save_thumb') !== 'no') {
127+ array_push(
128+ $data['options'],
129+ array (
130+ 'title' => 'NP_Thumbnail',
131+ 'url' => "{$CONF['ActionURL']}?action=plugin&name={$this->getname()}&type=admin",
132+ 'tooltip' => _NP_THUMBNAIL_09));
133+ }
134+ return;
135+ }
136+
137+ public function event_PostAuthentication ($data) {
138+ if (array_key_exists('action', $_REQUEST)
139+ && array_key_exists('name', $_REQUEST)
140+ && array_key_exists('type', $_REQUEST)
141+ && array_key_exists('width', $_REQUEST)
142+ && array_key_exists('height', $_REQUEST)
143+ && $_REQUEST['action'] === 'plugin'
144+ && $_REQUEST['name'] === $this->getName()
145+ && $_REQUEST['type'] !== '') {
146+ self::$buffering = ob_start;
147+ }
148+ return;
149+ }
150+
151+ public function doAction ($type) {
152+ global $DIR_MEDIA, $member;
153+
154+ $type = (string) $type;
155+
156+ $path = '';
157+ $maxwidth = '';
158+ $maxheight = '';
159+
160+ if (array_key_exists('path', $_GET)) {
161+ $path = (string) $_GET['path'];
162+ }
163+ if (array_key_exists('width', $_GET)) {
164+ $maxwidth = (integer) $_GET['width'];
165+ }
166+ if (array_key_exists('height', $_GET)) {
167+ $maxheight = (integer) $_GET['height'];
168+ }
169+
170+ if (in_array($type, array('admin', 'clear', 'sync')) && $member->isAdmin()) {
171+ $this->showAdmin($type);
172+ exit;
173+ }
174+
175+ if (self::$buffering) {
176+ ob_end_clean();
177+ }
178+
179+ if ($maxwidth <= 0 || $maxwidth > 1000 || $maxheight <= 0 || $maxheight > 1000 ) {
180+ MediaUtils::error ($this->t(_NP_THUMBNAIL_10, array($maxwidth, $maxheight)));
181+ return;
182+ }
183+
184+ if (FALSE === ($medium = new Medium($DIR_MEDIA, $path, MediaUtils::$prefix))) {
185+ MediaUtils::error ($this->t(_NP_THUMBNAIL_11, array($path)));
186+ return;
187+ }
188+
189+ if (FALSE === $medium->setResampledSize($maxwidth, $maxheight)) {
190+ MediaUtils::error ($this->t(_NP_THUMBNAIL_10, array($maxwidth, $maxheight)));
191+ return;
192+ }
193+
194+ MediaUtils::responseResampledImage($medium);
195+ return;
196+ }
197+
198+ public function doSkinVar ($skinType, $path, $maxwidth=0, $maxheight=0, $alt) {
199+ $path = (string) $path;
200+ $maxwidth = (integer) $maxwidth;
201+ $maxheight = (integer) $maxheight;
202+ $alt = (string) $alt;
203+
204+ if ($this->getBlogOption(MediaUtils::$blogid, 'force_thumb') == 'yes') {
205+ echo $this->getParsedTag(array('', '', $path, 0, 0, $alt), $maxwidth, $maxheight);
206+ }
207+ return;
208+ }
209+
210+ public function event_PreItem($data) {
211+ $item =& $data["item"];
212+ self::$authorid = $item->authorid;
213+ $item->body = preg_replace_callback("#<\%(Thumbnail)\((.*?)\|(.*?)\|(.*?)\|(.*?)\)%\>#", array(&$this, 'getParsedTag'), $item->body);
214+ $item->more = preg_replace_callback("#<\%(Thumbnail)\((.*?)\|(.*?)\|(.*?)\|(.*?)\)%\>#", array(&$this, 'getParsedTag'), $item->more);
215+
216+ if ($this->getBlogOption(MediaUtils::$blogid, 'force_thumb') == 'yes') {
217+ $item->body = preg_replace_callback("#<\%(popup)\((.*?)\|(.*?)\|(.*?)\|(.*?)\)%\>#", array(&$this, 'getParsedTag'), $item->body);
218+ $item->more = preg_replace_callback("#<\%(popup)\((.*?)\|(.*?)\|(.*?)\|(.*?)\)%\>#", array(&$this, 'getParsedTag'), $item->more);
219+ }
220+ return;
221+ }
222+
223+ public function event_PostMediaUpload ($data) {
224+ global $DIR_MEDIA;
225+ if ($this->getOption('save_thumb') == 'no') {
226+ return;
227+ }
228+
229+ $root = rtrim($DIR_MEDIA, '/');
230+ $path = trim($data['collection'], '/');
231+ $filename = trim($data['filename'], '/');
232+ $maxwidth = $this->getOption('maxwidth');
233+ $maxheight = $this->getOption('maxheight');
234+
235+ if (!MediaUtils::checkDir ($root . '/' . self::$thumbdir)) {
236+ return;
237+ }
238+
239+ if (FALSE === ($medium = new Medium($root, "{$path}/{$filename}", MediaUtils::$prefix))) {
240+ return;
241+ }
242+
243+ if (!array_key_exists($medium->mime, MediaUtils::$image_mime)) {
244+ return;
245+ }
246+
247+ if (FALSE === $medium->setResampledSize($maxwidth, $maxheight)) {
248+ return;
249+ }
250+
251+ $target = $this->getThumbPath($medium);
252+
253+ if ($this->getOption('save_thumb') == 'filesystem') {
254+ if (!file_exists("{$root}/{$target}")
255+ && !MediaUtils::storeResampledImage ($DIR_MEDIA, $target, $medium)) {
256+ return;
257+ }
258+ }
259+
260+ return;
261+ }
262+
263+ public function getParsedTag ($match, $maxwidth=0, $maxheight=0) {
264+ global $DIR_MEDIA, $member;
265+
266+ list($code, $tag, $path, $width, $height, $alt) = $match;
267+
268+ if (!preg_match("#^.+?/.+$#", $path) && self::$authorid) {
269+ $path = self::$authorid . '/' . $path;
270+ }
271+
272+ if (FALSE === ($medium = new Medium($DIR_MEDIA, $path, MediaUtils::$prefix))) {
273+ return $this->t('NP_Thumbnail: 指定したメディアファイルを読み込めませんでした。', array($path));
274+ }
275+
276+ if (!array_key_exists($medium->mime, MediaUtils::$image_mime)) {
277+ return $this->t(_NP_THUMBNAIL_12, array($path));
278+ }
279+
280+ if ($tag == 'Thumbnail') {
281+ $maxwidth = (integer) $width;
282+ $maxheight = (integer) $height;
283+ }
284+
285+ if (($maxwidth == 0) && ($maxheight == 0)) {
286+ $maxwidth = (integer) $this->getOption('maxwidth');
287+ $maxheight = (integer) $this->getOption('maxheight');
288+ }
289+
290+ if ($maxwidth < 0 || $maxwidth > 1000 || $maxheight < 0 || $maxheight > 1000) {
291+ return $this->t(_NP_THUMBNAIL_10, array($path));
292+ }
293+
294+ if (FALSE === $medium->setResampledSize($maxwidth, $maxheight)) {
295+ return $this->t('NP_Thumbnail: サムネイルのサイズが不正です。', array($path));
296+ }
297+
298+ if (!$alt) {
299+ $alt =& $path;
300+ }
301+
302+ return $this->generateTag($this->getBlogOption(MediaUtils::$blogid, 'thumb_template'), $medium, $alt);
303+ }
304+
305+ public function generateTag($template, $medium, $alt) {
306+ global $DIR_LIBS;
307+
308+ if (!class_exists('BODYACTIONS', FALSE)) {
309+ include($DIR_LIBS . 'BODYACTIONS.php');
310+ }
311+ $action = new BODYACTIONS;
312+
313+ if (array_key_exists($medium->mime, MediaUtils::$image_mime)
314+ && $this->getOption('save_thumb') == 'filesystem') {
315+ if (!MediaUtils::checkDir ($medium->root . '/' . self::$thumbdir)) {
316+ return $this->t(_NP_THUMBNAIL_13, array(self::$thumbdir));
317+ }
318+ if (!file_exists("{$medium->root}/{$this->getThumbPath($medium)}")) {
319+ MediaUtils::storeResampledImage ($medium->root, $this->getThumbPath($medium), $medium);
320+ }
321+ }
322+
323+ ob_start();
324+ if (array_key_exists($medium->mime, MediaUtils::$image_mime) && $this->getThumbURL($medium)) {
325+ $action->template['POPUP_CODE'] = $template;
326+ $replacements = array(
327+ '<%thumb_width%>' => $medium->resampledwidth,
328+ '<%thumb_height%>' => $medium->resampledheight,
329+ '<%thumb_url%>' => $this->getThumbURL($medium)
330+ );
331+ foreach ($replacements as $target => $replacement) {
332+ $action->template['POPUP_CODE'] = str_replace ($target, $replacement, $action->template['POPUP_CODE']);
333+ }
334+ $action->createPopupCode ("{$medium->path}/{$medium->name}", $medium->width, $medium->height, $alt);
335+ } else {
336+ $action->template['MEDIA_CODE'] = $template;
337+ $action->createMediaCode("{$medium->path}/{$medium->name}", $alt);
338+ }
339+ $tag = ob_get_contents();
340+ ob_get_clean();
341+
342+ return preg_replace('#href="(.*?)imagetext(.*?)"#', 'href="$1imagetext$2&amp;blogid='.MediaUtils::$blogid . '"', $tag);
343+ }
344+
345+ private function showAdmin ($type) {
346+ global $CONF, $DIR_LIBS, $DIR_MEDIA, $manager;
347+
348+ $type = (string) $type;
349+
350+ if (!class_exists ('PLUGINADMIN', FALSE)) {
351+ include ($DIR_LIBS . 'PLUGINADMIN.php');
352+ }
353+
354+ $oPluginAdmin = new PluginAdmin('Thumbnail');
355+ $oPluginAdmin->start();
356+
357+ echo "<h2>NP_Thumbnail</h2>\n";
358+
359+ if($this->getOption('save_thumb') === 'no') {
360+ echo '<p>' . $this->t(_NP_THUMBNAIL_14) . "</p>\n";
361+ $oPluginAdmin->end();
362+ return;
363+ }
364+
365+ if ($type == 'clear') {
366+ if ($this->getOption('save_thumb') == 'filesystem') {
367+ $logs = MediaUtils::purgeDir($DIR_MEDIA, self::$thumbdir . '/');
368+ }
369+ } else if ($type == 'sync') {
370+ $maxwidth = $this->getOption('maxwidth');
371+ $maxheight = $this->getOption('maxheight');
372+ if ($this->getOption('save_thumb') == 'filesystem') {
373+ $logs = $this->syncFilesystem ($DIR_MEDIA, self::$thumbdir, $maxwidth, $maxheight);
374+ }
375+ } else {
376+ $logs = array ();
377+ }
378+
379+ $media = MediaUtils::getMediaList($DIR_MEDIA);
380+ $elected = array();
381+ $rejected = array();
382+
383+ foreach ($media as $medium) {
384+ if (!array_key_exists($medium->mime, MediaUtils::$image_mime)) {
385+ continue;
386+ }
387+ if (file_exists ($DIR_MEDIA . $this->getThumbPath($medium))) {
388+ $rejected[] = &$medium;
389+ continue;
390+ } else {
391+ $elected[] = &$medium;
392+ continue;
393+ }
394+ }
395+
396+ $total_media = count ($media);
397+ $total_elected = count ($elected);
398+ $total_rejected = count ($rejected);
399+ $total_candidates = count ($rejected) + $total_elected;
400+
401+ echo "<p>" . $this->t(_NP_THUMBNAIL_15, array(self::$thumbdir)) . "<br />\n";
402+ echo $this->t(_NP_THUMBNAIL_16, array(self::$max_sync)) . "<br />\n";
403+ echo $this->t(_NP_THUMBNAIL_17) . "</p>\n";
404+
405+ /*
406+ * NOTICE: NP_Improvededia with eachblogdir option rewrite
407+ * global variables of "DIR_MEDIA" and "$CONF['MediaURL']"
408+ * in its initializing process.
409+ * Here are based on its rewriting system.
410+ */
411+ if ($manager->pluginInstalled('NP_ImprovedMedia')) {
412+ $NP_ImprovedMedia =& $manager->getPlugin('NP_ImprovedMedia');
413+ if ($NP_ImprovedMedia->getOption('IM_EACHBLOGDIR') == 'yes') {
414+ echo "<form method=\"post\" action=\"{$CONF['ActionURL']}?action=plugin&name=Thumbnail\" enctype=\"application/x-www-form-urlencoded\">\n";
415+ echo "<p>\n";
416+ echo "<label for=\"blogid\">サムネイル作成対象のウェブログ</label>\n";
417+ echo "<select name=\"blogid\" id=\"blogid\"onchange=\"return form.submit()\">\n";
418+ foreach(MediaUtils::$blogs as $blogid => $bshortname) {
419+ if ($blogid == MediaUtils::$blogid) {
420+ echo "<option value=\"{$blogid}\" selected=\"selected\">{$bshortname}</option>\n";
421+ } else {
422+ echo "<option value=\"{$blogid}\">{$bshortname}</option>\n";
423+ }
424+ }
425+ echo "</select>\n";
426+ echo "<input type=\"hidden\" id=\"admin\" name=\"type\" value=\"admin\">\n";
427+ echo "</p>\n";
428+ echo "</form>\n";
429+ }
430+ }
431+
432+ echo "<form method=\"post\" action=\"{$CONF['ActionURL']}?action=plugin&name=Thumbnail\" enctype=\"application/x-www-form-urlencoded\">\n";
433+ echo "<ul>\n";
434+ echo "<li>" . $this->t(_NP_THUMBNAIL_18, array($total_media)) . "</li>\n";
435+ echo "<li>" . $this->t(_NP_THUMBNAIL_19, array($total_candidates)) . "</li>\n";
436+ echo "<li>" . $this->t(_NP_THUMBNAIL_20, array($total_rejected)) . "</li>\n";
437+ echo "</ul>\n";
438+ echo "<p>\n";
439+ echo '<input type="hidden" name="blogid" value="' . MediaUtils::$blogid . '">' . "\n";
440+ echo "<input type=\"submit\" id=\"sync\" name=\"type\" value=\"sync\">\n";
441+ echo "<input type=\"submit\" id=\"clear\" name=\"type\" value=\"clear\">\n";
442+ echo "</p>\n";
443+
444+ if ($logs) {
445+ echo "<h3>" . $this->t(_NP_THUMBNAIL_21) . "</h3>\n";
446+ echo "<ul>\n";
447+
448+ foreach ($logs as $log) {
449+ echo "<li>{$log}</li>\n";
450+ }
451+ echo "</ul>\n";
452+ }
453+ echo "</form>\n";
454+
455+ $oPluginAdmin->end();
456+ return;
457+ }
458+
459+ public function syncFilesystem ($root, $dest, $maxwidth, $maxheight) {
460+ $logs = array ();
461+
462+ $root = rtrim($root, '/');
463+ if(!$root || !file_exists($root)) {
464+ return FALSE;
465+ }
466+
467+ if (!MediaUtils::checkDir(rtrim($root, '/') . '/' . trim($dest, '/'))) {
468+ return FALSE;
469+ }
470+
471+ $media = MediaUtils::getMediaList($root);
472+ $targets = array();
473+ $count = 1;
474+
475+ foreach ($media as $medium) {
476+ if ($count > self::$max_sync) {
477+ break;
478+ }
479+
480+ if (!array_key_exists ($medium->mime, MediaUtils::$image_mime)) {
481+ continue;
482+ }
483+
484+ if (FALSE === $medium->setResampledSize($maxwidth, $maxheight)) {
485+ continue;
486+ }
487+
488+ $destination = $this->getThumbPath($medium);
489+
490+ if (!file_exists (rtrim($root, '/') . '/' . $destination)) {
491+ if (!MediaUtils::storeResampledImage ($root, $destination, $medium)) {
492+ $logs[] = "Fail: {$medium->name}";
493+ } else {
494+ $logs[] = "Success: {$medium->name}";
495+ }
496+ $count++;
497+ }
498+ }
499+ return $logs;
500+ }
501+
502+ public function getThumbPath($medium) {
503+ if ('Medium' !== get_class($medium)) {
504+ return FALSE;
505+ }
506+ return self::$thumbdir . '/' . $medium->getHashedName(MediaUtils::$algorism) . MediaUtils::$image_mime[$medium->mime];
507+ }
508+
509+ public function getThumbURL($medium) {
510+ global $CONF, $DIR_MEDIA;
511+
512+ if ('Medium' !== get_class($medium)) {
513+ return FALSE;
514+ }
515+
516+ if (($medium->width < $medium->resampledwidth && $medium->height < $medium->resampledheight)
517+ || ($medium->width <= $this->getOption('maxwidth') && $medium->height <= $this->getOption('maxheight'))) {
518+ $url = "{$CONF['MediaURL']}{$medium->path}/{$medium->name}";
519+ } else if ($medium->resampledwidth > $this->getOption('maxwidth') && $medium->resampledheight > $this->getOption('maxheight')) {
520+ $url = "{$CONF['ActionURL']}?action=plugin&amp;name={$this->getName()}&amp;path={$medium->path}/{$medium->name}&amp;width={$medium->resampledwidth}&amp;height={$medium->resampledheight}&amp;blogid=" . MediaUtils::$blogid;
521+ } else if (file_exists($DIR_MEDIA . $this->getThumbPath($medium))) {
522+ $url = "{$CONF['MediaURL']}{$this->getThumbPath($medium)}";
523+ } else {
524+ $url = FALSE;
525+ }
526+ return $url;
527+ }
528+}
529+
--- /dev/null
+++ b/NP_Thumbnail/thumbnail/english.php
@@ -0,0 +1,35 @@
1+<?php
2+/**
3+ * Thumbnail plugin for Nucleus CMS
4+ * Version 3.9.6 (4.0 RC2) for PHP5
5+ * Written By Mocchi, Apr. 04, 2011
6+ * Original code was written by jirochou, May 23, 2004 and maintained by nakahara21
7+ * This plugin depends on 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_THUMBNAIL_01', 'Show thumbnail image on <%Thumbnail%> or <%popup%>, depends on NP_MediaUtils');
16+define ('_NP_THUMBNAIL_02', 'Maxmum width of thumbnail');
17+define ('_NP_THUMBNAIL_03', 'Maxmum height of thumbnail');
18+define ('_NP_THUMBNAIL_04', 'Store thumbnail');
19+define ('_NP_THUMBNAIL_05', 'No Need');
20+define ('_NP_THUMBNAIL_06', 'Filesystem');
21+define ('_NP_THUMBNAIL_07', 'Change <%popup%> to thumbnail');
22+define ('_NP_THUMBNAIL_08', 'Template for <%Thumbnail%> or <%popup%>');
23+define ('_NP_THUMBNAIL_09', 'Thumbnail Images Management');
24+define ('_NP_THUMBNAIL_10', 'Invalid parameter of <%0%> and <%1%>');
25+define ('_NP_THUMBNAIL_11', 'Fail to read <%0%>');
26+define ('_NP_THUMBNAIL_12', 'Fail to generate thumbnail from <%0%>');
27+define ('_NP_THUMBNAIL_13', 'Fail to create <%0%> for store of thumbnails');
28+define ('_NP_THUMBNAIL_14', 'This function is not allowed.');
29+define ('_NP_THUMBNAIL_15', 'Thumbnails is generated in <%0%> on Media directory.');
30+define ('_NP_THUMBNAIL_16', 'One session generates <%0%> thumbnails.');
31+define ('_NP_THUMBNAIL_17', 'There is a possibility to fail to generate thumbnail if original image is too large.');
32+define ('_NP_THUMBNAIL_18', '<%0%> files is in this media directory.');
33+define ('_NP_THUMBNAIL_19', '<%0%> files can generate its own thumbnail.');
34+define ('_NP_THUMBNAIL_20', '<%0%> thumbnails already generated');
35+define ('_NP_THUMBNAIL_21', 'Logs');
--- /dev/null
+++ b/NP_Thumbnail/thumbnail/index.html
@@ -0,0 +1,10 @@
1+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2+<html xmlns="http://www.w3.org/1999/xhtml">
3+<head>
4+<title>Notice</title>
5+</head>
6+<body>
7+<h1>Notice</h1>
8+<p>Nothing to see here</p>
9+</body>
10+</html>
\ No newline at end of file
--- /dev/null
+++ b/NP_Thumbnail/thumbnail/japanese-euc.php
@@ -0,0 +1,35 @@
1+<?php
2+/**
3+ * Thumbnail plugin for Nucleus CMS
4+ * Version 3.9.6 (4.0 RC2) for PHP5
5+ * Written By Mocchi, Apr. 04, 2011
6+ * Original code was written by jirochou, May 23, 2004 and maintained by nakahara21
7+ * This plugin depends on 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_THUMBNAIL_01', '<%Thumbnail%>または<%popup%>でサムネイル表示をします。プラグイン「NP_MediaUtils」と依存関係を持ちます');
16+define ('_NP_THUMBNAIL_02', 'サムネイルの横幅の最大値');
17+define ('_NP_THUMBNAIL_03', 'サムネイルの縦幅の最大値');
18+define ('_NP_THUMBNAIL_04', 'サムネイル画像を保存します');
19+define ('_NP_THUMBNAIL_05', 'いいえ');
20+define ('_NP_THUMBNAIL_06', 'ファイルシステム');
21+define ('_NP_THUMBNAIL_07', 'タグ<%popup%>をサムネイルにします');
22+define ('_NP_THUMBNAIL_08', 'タグ<%Thumbnail%>あるいは<%popup%>を置き換える際のテンプレート');
23+define ('_NP_THUMBNAIL_09', 'サムネイル画像の管理');
24+define ('_NP_THUMBNAIL_10', 'NP_Thumbnail: パラメータ<%0%>と<%1%>が不正です');
25+define ('_NP_THUMBNAIL_11', 'NP_Thumbnail: 要求したファイル<%0%>を読み込めません');
26+define ('_NP_THUMBNAIL_12', 'NP_Thumbnail: <%0%>はサムネイルを作成できないファイルです');
27+define ('_NP_THUMBNAIL_13', 'NP_Thumbnail: サムネイル用ディレクトリ<%0%>の作成に失敗しています');
28+define ('_NP_THUMBNAIL_14', '現在はサムネイルファイルをサーバに保存しない設定となっているため、この画面で出来ることはありません。');
29+define ('_NP_THUMBNAIL_15', 'サムネイルはメディア用ディレクトリの<%0%>に作成されます');
30+define ('_NP_THUMBNAIL_16', '現在は1回あたり<%0%>枚のサムネイルを作成するように設定されています');
31+define ('_NP_THUMBNAIL_17', 'あまりに縦横サイズの大きな画像はサムネイルが作成できない場合があります');
32+define ('_NP_THUMBNAIL_18', '現在<%0%>のメディアが登録されています');
33+define ('_NP_THUMBNAIL_19', 'そのうち、<%0%>の画像のサムネイルが作成可能です');
34+define ('_NP_THUMBNAIL_20', 'そのうち、<%0%>の画像のサムネイルがすでに作成されています。');
35+define ('_NP_THUMBNAIL_21', 'ログ');
--- /dev/null
+++ b/NP_Thumbnail/thumbnail/japanese-utf8.php
@@ -0,0 +1,35 @@
1+<?php
2+/**
3+ * Thumbnail plugin for Nucleus CMS
4+ * Version 3.9.6 (4.0 RC2) for PHP5
5+ * Written By Mocchi, Apr. 04, 2011
6+ * Original code was written by jirochou, May 23, 2004 and maintained by nakahara21
7+ * This plugin depends on 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_THUMBNAIL_01', '<%Thumbnail%>または<%popup%>でサムネイル表示をします。プラグイン「NP_MediaUtils」と依存関係を持ちます');
16+define ('_NP_THUMBNAIL_02', 'サムネイルの横幅の最大値');
17+define ('_NP_THUMBNAIL_03', 'サムネイルの縦幅の最大値');
18+define ('_NP_THUMBNAIL_04', 'サムネイル画像を保存します');
19+define ('_NP_THUMBNAIL_05', 'いいえ');
20+define ('_NP_THUMBNAIL_06', 'ファイルシステム');
21+define ('_NP_THUMBNAIL_07', 'タグ<%popup%>をサムネイルにします');
22+define ('_NP_THUMBNAIL_08', 'タグ<%Thumbnail%>あるいは<%popup%>を置き換える際のテンプレート');
23+define ('_NP_THUMBNAIL_09', 'サムネイル画像の管理');
24+define ('_NP_THUMBNAIL_10', 'NP_Thumbnail: パラメータ<%0%>と<%1%>が不正です');
25+define ('_NP_THUMBNAIL_11', 'NP_Thumbnail: 要求したファイル<%0%>を読み込めません');
26+define ('_NP_THUMBNAIL_12', 'NP_Thumbnail: <%0%>はサムネイルを作成できないファイルです');
27+define ('_NP_THUMBNAIL_13', 'NP_Thumbnail: サムネイル用ディレクトリ<%0%>の作成に失敗しています');
28+define ('_NP_THUMBNAIL_14', '現在はサムネイルファイルをサーバに保存しない設定となっているため、この画面で出来ることはありません。');
29+define ('_NP_THUMBNAIL_15', 'サムネイルはメディア用ディレクトリの<%0%>に作成されます');
30+define ('_NP_THUMBNAIL_16', '現在は1回あたり<%0%>枚のサムネイルを作成するように設定されています');
31+define ('_NP_THUMBNAIL_17', 'あまりに縦横サイズの大きな画像はサムネイルが作成できない場合があります');
32+define ('_NP_THUMBNAIL_18', '現在<%0%>のメディアが登録されています');
33+define ('_NP_THUMBNAIL_19', 'そのうち、<%0%>の画像のサムネイルが作成可能です');
34+define ('_NP_THUMBN