OSDN Git Service

ADD: Mocchiが手がけたファイル管理プラグイン一式をコミット
authorsakamocchi <o-takashi@sakamocchi.jp>
Sat, 20 Oct 2012 00:44:04 +0000 (09:44 +0900)
committersakamocchi <o-takashi@sakamocchi.jp>
Sat, 20 Oct 2012 00:44:04 +0000 (09:44 +0900)
NP_Attach 0.9.6:
 http://japan.nucleuscms.org/wiki/plugins:attach
NP_ImageLimitSize 0.9.6:
 http://japan.nucleuscms.org/wiki/plugins:imagelimitsize
NP_ImprovedMedia 3.0.1:
 http://japan.nucleuscms.org/wiki/plugins:improvedmedia
NP_MediaUtils 0.9.6:
 http://japan.nucleuscms.org/wiki/plugins:mediautils
NP_Thumbnail 3.9.6:
 http://japan.nucleuscms.org/wiki/plugins:thumbnail

41 files changed:
NP_Attach/NP_Attach.php [new file with mode: 0755]
NP_Attach/attach/english.php [new file with mode: 0755]
NP_Attach/attach/index.html [new file with mode: 0755]
NP_Attach/attach/japanese-euc.php [new file with mode: 0755]
NP_Attach/attach/japanese-utf8.php [new file with mode: 0755]
NP_ImageLimitSize/NP_ImageLimitSize.php [new file with mode: 0755]
NP_ImageLimitSize/imagelimitsize/english.php [new file with mode: 0755]
NP_ImageLimitSize/imagelimitsize/index.html [new file with mode: 0755]
NP_ImageLimitSize/imagelimitsize/japanese-euc.php [new file with mode: 0755]
NP_ImageLimitSize/imagelimitsize/japanese-utf8.php [new file with mode: 0755]
NP_ImprovedMedia/NP_ImprovedMedia.php [new file with mode: 0755]
NP_ImprovedMedia/improvedmedia/MEDIA_CONTROL.php [new file with mode: 0755]
NP_ImprovedMedia/improvedmedia/MEDIA_VARIABLES.php [new file with mode: 0755]
NP_ImprovedMedia/improvedmedia/greybox/AJS.js [new file with mode: 0755]
NP_ImprovedMedia/improvedmedia/greybox/AJS_fx.js [new file with mode: 0755]
NP_ImprovedMedia/improvedmedia/greybox/LGPL.txt [new file with mode: 0755]
NP_ImprovedMedia/improvedmedia/greybox/g_close.gif [new file with mode: 0755]
NP_ImprovedMedia/improvedmedia/greybox/gb_scripts.js [new file with mode: 0755]
NP_ImprovedMedia/improvedmedia/greybox/gb_styles.css [new file with mode: 0755]
NP_ImprovedMedia/improvedmedia/greybox/header_bg.gif [new file with mode: 0755]
NP_ImprovedMedia/improvedmedia/greybox/index.html [new file with mode: 0755]
NP_ImprovedMedia/improvedmedia/greybox/indicator.gif [new file with mode: 0755]
NP_ImprovedMedia/improvedmedia/greybox/loader_frame.html [new file with mode: 0755]
NP_ImprovedMedia/improvedmedia/greybox/next.gif [new file with mode: 0755]
NP_ImprovedMedia/improvedmedia/greybox/prev.gif [new file with mode: 0755]
NP_ImprovedMedia/improvedmedia/greybox/w_close.gif [new file with mode: 0755]
NP_ImprovedMedia/improvedmedia/help.html [new file with mode: 0755]
NP_ImprovedMedia/improvedmedia/index.html [new file with mode: 0755]
NP_ImprovedMedia/improvedmedia/lang/english.php [new file with mode: 0755]
NP_ImprovedMedia/improvedmedia/lang/index.html [new file with mode: 0755]
NP_ImprovedMedia/improvedmedia/lang/japanese-euc.php [new file with mode: 0755]
NP_ImprovedMedia/improvedmedia/lang/japanese-utf8.php [new file with mode: 0755]
NP_ImprovedMedia/improvedmedia/popups.css [new file with mode: 0755]
NP_MediaUtils/NP_MediaUtils.php [new file with mode: 0755]
NP_MediaUtils/mediautils/MediaUtils.php [new file with mode: 0755]
NP_MediaUtils/mediautils/Medium.php [new file with mode: 0755]
NP_Thumbnail/NP_Thumbnail.php [new file with mode: 0755]
NP_Thumbnail/thumbnail/english.php [new file with mode: 0755]
NP_Thumbnail/thumbnail/index.html [new file with mode: 0755]
NP_Thumbnail/thumbnail/japanese-euc.php [new file with mode: 0755]
NP_Thumbnail/thumbnail/japanese-utf8.php [new file with mode: 0755]

diff --git a/NP_Attach/NP_Attach.php b/NP_Attach/NP_Attach.php
new file mode 100755 (executable)
index 0000000..0cf61b0
--- /dev/null
@@ -0,0 +1,530 @@
+<?php\r
+/**\r
+ * Attach plugin for Nucleus CMS\r
+ * Version 0.9.6 (1.0 RC2) for PHP5\r
+ * Written By Mocchi, Apr. 04, 2011\r
+ * Original code was written by NKJG and yamamoto, May 02, 2009\r
+ * This plugin depends on NP_Thumbnail and NP_MediaUtils\r
+ * \r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 3\r
+ * of the License, or (at your option) any later version.\r
+ */\r
+\r
+// TODO (hard) If itemOption is set as "hidden", PrePluginOptionsUpdate event is not generated, related Nucleus CMS library problem.\r
+// TODO (hard) There are no ways to show the error message even if upload processing is failed.\r
+// TODO (medium) all of the plugin options are purged when uninstalling plugins.\r
+\r
+class NP_Attach extends NucleusPlugin {\r
+       static private  $buffer = false;\r
+       static private  $blogid = 0;\r
+       static private  $itemid = 0;\r
+       static private  $amount = 0;\r
+       static private  $data   = array();\r
+       \r
+       public function getName()                       { return 'Attach'; }\r
+       public function getAuthor()             { return 'Mocchi, yamamoto, NKJG'; }\r
+       public function getURL()                        { return 'http://japan.nucleuscms.org/wiki/plugins:attach'; }\r
+       public function getVersion()            { return '0.9.6 (1.0 RC2)'; }\r
+       public function getDescription()        { return _NP_ATTACH_01; }\r
+       public function getPluginDep()  { return array('NP_MediaUtils', 'NP_Thumbnail');}\r
+       public function getMinNucleusVersion()          {return 340;}\r
+       public function supportsFeature($feature)       { return in_array ($feature, array ('SqlTablePrefix', 'SqlApi'));}\r
+       public function getEventList() {\r
+               return array (\r
+                       'PrePluginOptionsEdit', \r
+                       'AdminPrePageHead',\r
+                       'BookmarkletExtraHead',\r
+                       'PreItem',\r
+                       'PreAddItem',\r
+                       'PreUpdateItem',\r
+                       'PostAddItem',\r
+                       'PostUpdateItem',\r
+                       'PrePluginOptionsUpdate',\r
+                       'AddItemFormExtras',\r
+                       'EditItemFormExtras');\r
+       }\r
+       \r
+       public function install () {\r
+               $this->createOption('maxwidth', '_NP_ATTACH_02', 'text', '90',  'datatype=numerical');\r
+               $this->createOption('maxheight', '_NP_ATTACH_03', 'text', '90',  'datatype=numerical');\r
+               $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>');\r
+               $this->createOption('admin_media_template', '_NP_ATTACH_05', 'textarea', '<a href="<%link%>" title="<%text%>"><%text%></a>');\r
+               $this->createBlogOption('amount', '_NP_ATTACH_06', 'text', '3');\r
+               $this->createBlogOption('blog_image_template', '_NP_ATTACH_07', 'textarea', '<img src="<%link%>" width="<%width%>" height="<%height%>" alt="<%text%>" />');\r
+               $this->createBlogOption('blog_media_template', '_NP_ATTACH_08', 'textarea', '<a href="<%link%>" title="<%text%>"><%text%></a>');\r
+               $this->createItemOption('media', '_NP_ATTACH_09', 'text', '');\r
+               return;\r
+       }\r
+       \r
+       public function uninstall () {\r
+               return;\r
+       }\r
+       \r
+       public function init() {\r
+               if(!defined('_NP_ATTACH_01')) {\r
+                       $language = preg_replace('#[/|\\\\]#', '', getLanguageName());\r
+                       if (file_exists($this->getDirectory() . $language.'.php')) {\r
+                               include($this->getDirectory() . $language.'.php');\r
+                       } else {\r
+                               include($this->getDirectory() . 'english.php');\r
+                       }\r
+               }\r
+               return;\r
+       }\r
+       \r
+/*\r
+ * for translation\r
+ */\r
+       public function event_PrePluginOptionsEdit ($data)\r
+       {\r
+               if ($data['context'] != 'global') {\r
+                       foreach($data['options'] as $key => $option) {\r
+                               if ($option['pid'] == $this->getID()) {\r
+                                       if (defined($option['description'])) {\r
+                                               $data['options'][$key]['description'] = constant($option['description']);\r
+                                       }\r
+                                       if ($option['type'] == 'select') {\r
+                                               foreach (explode('|', $option['typeinfo']) as $option) {\r
+                                                       if (defined($option)) {\r
+                                                               $data['options'][$key]['typeinfo'] = str_replace($option, constant($option), $data['options'][$key]['typeinfo']);\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                               }\r
+                       }\r
+               } else if ($data['plugid'] == $this->getID()) {\r
+                       foreach($data['options'] as $key => $option){\r
+                               if (defined($option['description'])) {\r
+                                       $data['options'][$key]['description'] = constant($option['description']);\r
+                               }\r
+                               if ($option['type'] == 'select') {\r
+                                               foreach (explode('|', $option['typeinfo']) as $option) {\r
+                                                       if (defined($option)) {\r
+                                                               $data['options'][$key]['typeinfo'] = str_replace($option, constant($option), $data['options'][$key]['typeinfo']);\r
+                                                       }\r
+                                               }\r
+                               }\r
+                       }\r
+               }\r
+               return;\r
+       }\r
+       \r
+/*\r
+ * for translation\r
+ */\r
+       static private function t ($text,$array=array()){\r
+               if (is_array($array)) {\r
+                       $search = array();\r
+                       $replace = array();\r
+                       \r
+                       foreach ($array as $key => $value){\r
+                               if (is_array($value)) {\r
+                                       continue;\r
+                               }\r
+                               $search[] = '<%'.preg_replace('/[^a-zA-Z0-9_]+/','',$key).'%>';\r
+                               $replace[] = $value;\r
+                       }\r
+               }\r
+               return htmlspecialchars (str_replace($search, $replace, $text), ENT_QUOTES, _CHARSET);\r
+       }\r
+       \r
+/*\r
+ * Change enctype attribute of form element as 'multipart/form-data'\r
+ * Insert interface\r
+ */\r
+       public function event_AdminPrePageHead ($data) {\r
+               if (!in_array ($data['action'], array ('createitem', 'itemedit'))) {\r
+                return;\r
+               }\r
+               \r
+               self::prepareEnctype ();\r
+               return;\r
+       }\r
+       \r
+       public function event_BookmarkletExtraHead ($data) {\r
+               self::prepareEnctype ();\r
+               return;\r
+       }\r
+       \r
+       public function event_AddItemFormExtras ($data) {\r
+               global $DIR_MEDIA;\r
+               $blog = $data['blog'];\r
+               self::$blogid = $blog->blogid;\r
+               self::$itemid = 0;\r
+               self::setEnctype ();\r
+               $this->setData($DIR_MEDIA);\r
+               $this->showInterface ();\r
+               return;\r
+       }\r
+       \r
+       public function event_EditItemFormExtras ($data) {\r
+               global $DIR_MEDIA;\r
+               $blog = $data['blog'];\r
+               self::$blogid = $blog->blogid;\r
+               self::$itemid = $data['itemid'];\r
+               self::setEnctype ();\r
+               $this->setData($DIR_MEDIA);\r
+               $this->showInterface ();\r
+               return;\r
+       }\r
+       \r
+/*\r
+ * Process upload and update plugin item option\r
+ */\r
+       public function event_PreAddItem ($data) {\r
+               self::$blogid = $data['blog']->blogid;\r
+               return;\r
+       }\r
+       public function event_PreUpdateItem ($data) {\r
+               self::$blogid = $data['blog']->blogid;\r
+               return;\r
+       }\r
+       public function event_PostAddItem ($data) {\r
+               self::$itemid = $data['itemid'];\r
+               return;\r
+       }\r
+       public function event_PostUpdateItem ($data) {\r
+               self::$itemid = $data['itemid'];\r
+               return;\r
+       }\r
+       public function event_PrePluginOptionsUpdate ($data) {\r
+               global $DIR_MEDIA, $member;\r
+               \r
+               if ($data['plugid'] != $this->getID () || $data['optionname'] != 'media') {\r
+                       return;\r
+               }\r
+               \r
+               $this->setData($DIR_MEDIA);\r
+               self::batchRequest ($DIR_MEDIA, $member->getID());\r
+               \r
+               $value = '';\r
+               foreach (self::$data as $datum) {\r
+                       if (!$datum['path']) {\r
+                               continue;\r
+                       }\r
+                       $value .= "{$datum['path']}:{$datum['alt']}:{$datum['way']};";\r
+               }\r
+               \r
+               $data['value'] = $value;\r
+               return;\r
+       }\r
+       \r
+/*\r
+ * Show media in item\r
+ */\r
+       public function event_PreItem($data) {\r
+               global $DIR_MEDIA;\r
+               self::$blogid =& $data['blog']->blogid;\r
+               self::$itemid =& $data["item"]->itemid;\r
+               $this->setData($DIR_MEDIA);\r
+               \r
+               $data["item"]->body = preg_replace_callback("#<\%Attach\((.+?)(,.+?)?(,.+?)?\)%\>#", array(&$this, 'getParsedTag'), $data["item"]->body);\r
+               $data["item"]->more = preg_replace_callback("#<\%Attach\((.+?)(,.+?)?(,.+?)?\)%\>#", array(&$this, 'getParsedTag'), $data["item"]->more);\r
+               return;\r
+       }\r
+       public function doTemplateVar($item, $mediumid) {\r
+               global $DIR_MEDIA, $blogid;\r
+               \r
+               if (!self::$itemid || !self::$blogid) {\r
+                       self::$blogid = $blogid;\r
+                       self::$itemid = $item->itemid;\r
+                       $this->setData($DIR_MEDIA);\r
+               }\r
+               $this->getParsedTag(array('item', $mediumid));\r
+               return;\r
+       }\r
+       \r
+       private function getParsedTag($match) {\r
+               global $DIR_MEDIA, $manager;\r
+               \r
+               $maxwidth = 0;\r
+               $maxheight = 0;\r
+               if (array_key_exists(3, $match)) {\r
+                       $maxheight = (integer) trim($match[3], ',');\r
+               }\r
+               if (array_key_exists(2, $match)) {\r
+                       $maxwidth = (integer) trim($match[2], ',');\r
+               }\r
+               \r
+               $data = &self::$data;\r
+               $mediumid = $match[1];\r
+               $mediumid--;\r
+               \r
+               if (!array_key_exists ($mediumid, $data) || !$data[$mediumid]['path']) {\r
+                       return;\r
+               }\r
+               \r
+               $NP_Thumbnail =& $manager->getPlugin('NP_Thumbnail');\r
+               \r
+               if ($maxwidth==0 && $maxheight==0) {\r
+                       $maxwidth = $NP_Thumbnail->getOption('maxwidth');\r
+                       $maxheight = $NP_Thumbnail->getOption('maxheight');\r
+               }\r
+               \r
+               if (FALSE === ($medium = new MEDIUM($DIR_MEDIA, $data[$mediumid]['path'], MediaUtils::$prefix))) {\r
+                       return;\r
+               }\r
+               \r
+               if (array_key_exists($medium->mime, MediaUtils::$image_mime)\r
+                && !$medium->setResampledSize($maxwidth, $maxheight)) {\r
+                       return;\r
+               }\r
+               \r
+               if (!array_key_exists($medium->mime, MediaUtils::$image_mime)\r
+                || $data[$mediumid]['way'] == 'anchor') {\r
+                       $template = $this->getBlogOption(self::$blogid, 'blog_media_template');\r
+               } else if ($data[$mediumid]['way'] == 'original') {\r
+                       $template = $this->getBlogOption(self::$blogid, 'blog_image_template');\r
+               } else {\r
+                       $template = $NP_Thumbnail->getBlogOption(self::$blogid, 'thumb_template');\r
+               }\r
+               return $NP_Thumbnail->generateTag($template, $medium, $data[$mediumid]['alt']);\r
+       }\r
+       \r
+       private function showInterface () {\r
+               global $CONF, $DIR_LIBS, $DIR_MEDIA, $manager;\r
+               \r
+               if (!class_exists('BODYACTIONS', FALSE)) {\r
+                       include ($DIR_LIBS . 'BODYACTIONS.php');\r
+               }\r
+               $action = new BODYACTIONS;\r
+               \r
+               if (!$manager->pluginInstalled('NP_Thumbnail')) {\r
+                       return;\r
+               }\r
+               $NP_Thumbnail = &$manager->getPlugin('NP_Thumbnail');\r
+               $maxwidth = $NP_Thumbnail->getOption('maxwidth');\r
+               $maxheight = $NP_Thumbnail->getOption('maxheight');\r
+                       \r
+               if (!self::$amount) {\r
+                       return;\r
+               }\r
+               \r
+               $data = self::$data;\r
+               \r
+               if (empty($data)) {\r
+                       return;\r
+               }\r
+               \r
+               echo "<table frame=\"box\" rules=\"all\" summary=\"Attached Media\">\n";\r
+               echo "<thead>\n";\r
+               echo "<tr>\n";\r
+               echo "<th>" . _NP_ATTACH_10 . "</th>\n";\r
+               echo "<th>" . _NP_ATTACH_11 . "</th>\n";\r
+               echo "<th>" . _NP_ATTACH_12 . "</th>\n";\r
+               echo "</tr>\n";\r
+               echo "</thead>\n";\r
+               echo "<tbody>\n";\r
+               \r
+               for ($count = 0; $count < self::$amount; $count++) {\r
+                       $id = $count + 1;\r
+                       \r
+                       echo "<tr>\n";\r
+                       echo "<td>\n";\r
+                       echo "<label for=\"alt{$count}\"><%Attach({$id})%></label>\n";\r
+                       \r
+                       if ($data[$count]['path']) {\r
+                               echo "<br />\n";\r
+                               echo "<input type=\"checkbox\" id=\"delete{$count}\" name=\"delete[{$count}]\" value=\"1\" />\n";\r
+                               echo "<label for=\"delete{$count}\">" . _NP_ATTACH_13 . "</label>\n";\r
+                       }\r
+                       \r
+                       echo "</td>\n";\r
+                       echo "<td>\n";\r
+                       \r
+                       if (!$data[$count]['path']) {\r
+                               echo "<input type=\"file\" id=\"medium{$count}\" name=\"medium[{$count}]\" size=\"1\" /><br />\n";\r
+                       } else {\r
+                               if (FALSE === ($medium = new MEDIUM($DIR_MEDIA, $data[$count]['path'], MediaUtils::$prefix))) {\r
+                                       return;\r
+                               }\r
+                               \r
+                               if (array_key_exists($medium->mime, MediaUtils::$image_mime)\r
+                                && !$medium->setResampledSize($maxwidth, $maxheight)) {\r
+                                       return;\r
+                               }\r
+                               \r
+                               if (array_key_exists($medium->mime, MediaUtils::$image_mime)) {\r
+                                       $template = $this->getOption('admin_popup_template');\r
+                               } else {\r
+                                       $template = $this->getOption('admin_media_template');\r
+                               }\r
+                               \r
+                               echo $NP_Thumbnail->generateTag($template, $medium, $data[$count]['alt']) . "<br />\n";\r
+                               echo "<input type=\"hidden\" id=\"path{$count}\" name=\"path[{$count}]\" value=\"{$data[$count]['path']}\" /><br />\n";\r
+                       }\r
+                       echo "<input type=\"text\" id=\"alt{$count}\" name=\"alt[{$count}]\" value=\"{$data[$count]['alt']}\" size=\"12\" />\n";\r
+                       echo "</td>\n";\r
+                       echo "<td>\n";\r
+                       \r
+                       if ($data[$count]['path'] && !array_key_exists($data[$count]['mime'], MediaUtils::$image_mime)) {\r
+                               echo "<input type=\"hidden\" name=\"way[{$count}]\" value=\"anchor\" />\n";\r
+                               echo _NP_ATTACH_14 . "\n";\r
+                       } else {\r
+                               $thumbnail_checked = "";\r
+                               $original_checked = "";\r
+                               $anchor_checked = "";\r
+                               \r
+                               if ($data[$count]['way'] == 'original') {\r
+                                       $original_checked = 'checked="checked"';\r
+                               } else if ($data[$count]['way'] == 'anchor') {\r
+                                       $anchor_checked = 'checked="checked"';\r
+                               } else {\r
+                                       $thumbnail_checked = 'checked="checked"';\r
+                               }\r
+                               \r
+                               echo "<input type=\"radio\" id=\"way{$count}-anchor\" name=\"way[{$count}]\" value=\"anchor\" {$anchor_checked} />\n";\r
+                               echo "<label for=\"way{$count}-anchor\">" . _NP_ATTACH_15 . "<label><br />\n";\r
+                               echo "<input type=\"radio\" id=\"way{$count}-small\" name=\"way[{$count}]\" value=\"thumbnail\" {$thumbnail_checked} />\n";\r
+                               echo "<label for=\"way{$count}-small\">" . _NP_ATTACH_16 . "<label><br />\n";\r
+                               echo "<input type=\"radio\" id=\"way{$count}-original\" name=\"way[{$count}]\" value=\"original\" {$original_checked} />\n";\r
+                               echo "<label for=\"way{$count}-original\">" . _NP_ATTACH_17 . "<label>\n";\r
+                       }\r
+                       echo "</td>\n";\r
+                       echo "</tr>\n";\r
+               }\r
+               \r
+               echo "</tbody>\n";\r
+               echo "</table>\n";\r
+               return;\r
+       }\r
+       \r
+       private function setData($root) {\r
+               if(self::$blogid === 0 || !self::$itemid === 0) {\r
+                return;\r
+               }\r
+               \r
+               self::$amount = $this->getBlogOption(self::$blogid, 'amount');\r
+               $media = explode(';', $this->getitemOption (self::$itemid, 'media'));\r
+               $data = array();\r
+               \r
+               for ($count = 0; $count < self::$amount; $count++) {\r
+                       if((self::$itemid != 0) && array_key_exists ($count, $media) && !empty ($media[$count])) {\r
+                               $medium = explode (':', $media[$count]);\r
+                               $data[$count]['path'] = $medium[0];\r
+                               $data[$count]['alt'] = $medium[1];\r
+                               $data[$count]['way'] = $medium[2];\r
+                               \r
+                               if (FALSE === ($file = new Medium($root, $data[$count]['path'], MediaUtils::$prefix))) {\r
+                                       $data[$count] = array ('path' => "", 'alt' => "", 'way' => "");\r
+                               }\r
+                               \r
+                               $data[$count]['mime'] = $file->mime;\r
+                               $data[$count]['width'] = $file->width;\r
+                               $data[$count]['height'] = $file->height;\r
+                       } else {\r
+                               $data[$count] = array ('path' => "", 'alt' => "", 'way' => "");\r
+                       }\r
+               }\r
+               \r
+               self::$data = $data;\r
+               return;\r
+       }\r
+       \r
+       static private function batchRequest($root, $collection) {\r
+               global $CONF, $manager;\r
+               $media = array ();\r
+               $paths = array ();\r
+               $alts = array ();\r
+               $ways = array ();\r
+               $deletes = array ();\r
+               \r
+               if (array_key_exists ('medium', $_FILES)) {\r
+                       $media = $_FILES['medium'];\r
+               }\r
+               \r
+               if (array_key_exists ('path', $_POST)) {\r
+                       $paths = $_POST['path'];\r
+               }\r
+               \r
+               if (array_key_exists ('alt', $_POST)) {\r
+                       $alts = $_POST['alt'];\r
+               }\r
+               \r
+               if (array_key_exists ('way', $_POST)) {\r
+                       $ways = $_POST['way'];\r
+               }\r
+               \r
+               if (array_key_exists ('delete', $_POST)) {\r
+                       $deletes = $_POST['delete'];\r
+               }\r
+               \r
+               $data = &self::$data;\r
+               \r
+               if (!$manager->pluginInstalled('NP_Thumbnail')) {\r
+                       return;\r
+               }\r
+               $NP_Thumbnail = &$manager->getPlugin('NP_Thumbnail');\r
+               \r
+               foreach ($data as $key => $value) {\r
+                       if ($media && array_key_exists ($key, $media['name']) && !empty ($media['name'][$key])) {\r
+                               $medium = array ();\r
+                               if (preg_match ("#(\\\\|/|\\n)#", $media['name'][$key])) {\r
+                                       $data[$key] = array ('path' => "", 'alt' => "", 'way' => "");\r
+                                       continue;\r
+                               }\r
+                               \r
+                               $medium['name'] = &$media['name'][$key];\r
+                               $medium['size'] = $media['size'][$key];\r
+                               $medium['tmp_name'] = $media['tmp_name'][$key];\r
+                               $medium['error'] = $media['error'][$key];\r
+                               \r
+                               $result = MediaUtils::uploadMedium ($root, $collection, $medium, $medium['name'], $manager);\r
+                               \r
+                               if ($result) {\r
+                                       $data[$key]['path'] = "";\r
+                                       $data[$key]['alt']  = $result . ' (' . $medium['name'] . ')';\r
+                                       $data[$key]['way']  = "";\r
+                                       continue;\r
+                               } else {\r
+                                       $data[$key]['path'] = $collection . '/' . $medium['name'];\r
+                               }\r
+                       } else if (array_key_exists($key, $paths) && !empty ($paths[$key])) {\r
+                               if (FALSE === ($medium = new MEDIUM($root, $paths[$key], MediaUtils::$prefix))) {\r
+                                       $data[$key] = array ('path' => "", 'alt' => "", 'way' => "");\r
+                                       continue;\r
+                               }\r
+                               if ($deletes && array_key_exists ($key, $deletes) && $deletes[$key] == 1) {\r
+                                       if (@ unlink ($root . $paths[$key])) {\r
+                                               if (array_key_exists($medium->mime, MediaUtils::$image_mime)) {\r
+                                                       @ unlink ($root . $NP_Thumbnail->getThumbPath($medium));\r
+                                               }\r
+                                               $data[$key] = array ('path' => "", 'alt' => "", 'way' => "");\r
+                                               continue;\r
+                                       }\r
+                               }\r
+                       }\r
+                       \r
+                       if (array_key_exists ($key, $alts) && $alts[$key] != $value['alt']) {\r
+                               $data[$key]['alt'] = htmlspecialchars ($alts[$key], ENT_QUOTES, _CHARSET);\r
+                       }\r
+                       \r
+                       if (array_key_exists ($key, $ways) && $ways[$key] != $value['way']) {\r
+                               if (!in_array ($ways[$key], array ('thumbnail', 'original', 'anchor'))) {\r
+                                       $data[$key]['way'] = 'thumbnail';\r
+                               } else {\r
+                                       $data[$key]['way'] = $ways[$key];\r
+                               }\r
+                       }\r
+               }\r
+               return;\r
+       }\r
+       \r
+       static private function prepareEnctype () {\r
+               self::$buffer = ob_start ();\r
+               return;\r
+       }\r
+       \r
+       static private function setEnctype () {\r
+               if (!self::$buffer) {\r
+                       return;\r
+               }\r
+               $strings = ob_get_contents ();\r
+               ob_end_clean ();\r
+               $strings = preg_replace ('#action="(index.php|bookmarklet.php)"#', '$0 enctype="multipart/form-data"', $strings);\r
+               echo $strings;\r
+               return;\r
+       }\r
+}\r
diff --git a/NP_Attach/attach/english.php b/NP_Attach/attach/english.php
new file mode 100755 (executable)
index 0000000..202e305
--- /dev/null
@@ -0,0 +1,31 @@
+<?php\r
+/**\r
+ * Attach plugin for Nucleus CMS\r
+ * Version 0.9.6 (1.0 RC2) for PHP5\r
+ * Written By Mocchi, Apr. 04, 2011\r
+ * Original code was written by NKJG and yamamoto, May 02, 2009\r
+ * This plugin depends on NP_Thumbnail and NP_MediaUtils\r
+ * \r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 3\r
+ * of the License, or (at your option) any later version.\r
+ */\r
+\r
+define('_NP_ATTACH_01', 'Attach files directly on item. <%Attach%> can show these files on item.');\r
+define('_NP_ATTACH_02', 'Maximum width for thumbnail on item edit page');\r
+define('_NP_ATTACH_03', 'Maximum height for thumbnail on item edit page');\r
+define('_NP_ATTACH_04', 'Template for thumbnail on item edit page');\r
+define('_NP_ATTACH_05', 'Template for normal file on item edit page');\r
+define('_NP_ATTACH_06', 'Maximum number of files on an item');\r
+define('_NP_ATTACH_07', 'Template for original image on weblog. Template for thumbnail is based on NP_Thumbnail.');\r
+define('_NP_ATTACH_08', 'Template for normal file on weblog.');\r
+define('_NP_ATTACH_09', 'Media Information');\r
+define('_NP_ATTACH_10', 'Tag');\r
+define('_NP_ATTACH_11', 'Media file and alternative text');\r
+define('_NP_ATTACH_12', 'Way to embed');\r
+define('_NP_ATTACH_13', 'Erase');\r
+define('_NP_ATTACH_14', 'Anchor');\r
+define('_NP_ATTACH_15', 'Anchor');\r
+define('_NP_ATTACH_16', 'Thumbnail');\r
+define('_NP_ATTACH_17', 'Original');\r
diff --git a/NP_Attach/attach/index.html b/NP_Attach/attach/index.html
new file mode 100755 (executable)
index 0000000..dd9f433
--- /dev/null
@@ -0,0 +1,11 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>Nothing Here</title>
+</head>
+<body>
+
+<h1>Nothing to see here</h1>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/NP_Attach/attach/japanese-euc.php b/NP_Attach/attach/japanese-euc.php
new file mode 100755 (executable)
index 0000000..593d9ee
--- /dev/null
@@ -0,0 +1,31 @@
+<?php\r
+/**\r
+ * Attach plugin for Nucleus CMS\r
+ * Version 0.9.6 (1.0 RC2) for PHP5\r
+ * Written By Mocchi, Apr. 04, 2011\r
+ * Original code was written by NKJG and yamamoto, May 02, 2009\r
+ * This plugin depends on NP_Thumbnail and NP_MediaUtils\r
+ * \r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 3\r
+ * of the License, or (at your option) any later version.\r
+ */\r
+\r
+define('_NP_ATTACH_01', '¥¢¥¤¥Æ¥à¤ËľÀÜ¡¢¥Õ¥¡¥¤¥ë¤òźÉÕ¤·¤Þ¤¹¡£ÅºÉÕ¤·¤¿¥Õ¥¡¥¤¥ë¤Ï¥¿¥°<%Attach%>¤Ç¥¢¥¤¥Æ¥àÃæ¤Ëɽ¼¨¤Ç¤­¤Þ¤¹');\r
+define('_NP_ATTACH_02', '´ÉÍý²èÌ̤Ëɽ¼¨¤¹¤ë¥µ¥à¥Í¥¤¥ë¤Î²£Éý¤ÎºÇÂçÃÍ');\r
+define('_NP_ATTACH_03', '´ÉÍý²èÌ̤Ëɽ¼¨¤¹¤ë¥µ¥à¥Í¥¤¥ë¤Î½ÄÉý¤ÎºÇÂçÃÍ');\r
+define('_NP_ATTACH_04', '´ÉÍý²èÌ̤Ëɽ¼¨¤¹¤ë½Ì¾®²èÁü¤Î¥Æ¥ó¥×¥ì¡¼¥È');\r
+define('_NP_ATTACH_05', '´ÉÍý²èÌ̤Ëɽ¼¨¤¹¤ë²èÁü°Ê³°¤Î¥Æ¥ó¥×¥ì¡¼¥È');\r
+define('_NP_ATTACH_06', '¥¢¥¤¥Æ¥à¤ËźÉդǤ­¤ë¥Õ¥¡¥¤¥ë¤Î¿ô');\r
+define('_NP_ATTACH_07', '¥¦¥§¥Ö¥í¥°¤Ëɽ¼¨¤¹¤ë¸¶À£²èÁü¤Î¥Æ¥ó¥×¥ì¡¼¥È¡£½Ì¾®²èÁü¤Î¥Æ¥ó¥×¥ì¡¼¥È¤ÏNP_Thumbnail¤Î¥Æ¥ó¥×¥ì¡¼¥È¤Ë½à¤¸¤Æ¤Þ¤¹¡£');\r
+define('_NP_ATTACH_08', '¥¦¥§¥Ö¥í¥°¤Ëɽ¼¨¤¹¤ë²èÁü°Ê³°¤Î¥Æ¥ó¥×¥ì¡¼¥È');\r
+define('_NP_ATTACH_09', '¥Õ¥¡¥¤¥ë¤Î¾ðÊó');\r
+define('_NP_ATTACH_10', '¥¿¥°');\r
+define('_NP_ATTACH_11', '¥Õ¥¡¥¤¥ë¤ÈÀâÌÀʸ');\r
+define('_NP_ATTACH_12', 'Ëä¤á¹þ¤ßÊýË¡');\r
+define('_NP_ATTACH_13', 'ºï½ü');\r
+define('_NP_ATTACH_14', '¥ê¥ó¥¯');\r
+define('_NP_ATTACH_15', '¥ê¥ó¥¯');\r
+define('_NP_ATTACH_16', '½Ì¾®');\r
+define('_NP_ATTACH_17', '¼ÂÀ£');\r
diff --git a/NP_Attach/attach/japanese-utf8.php b/NP_Attach/attach/japanese-utf8.php
new file mode 100755 (executable)
index 0000000..358b326
--- /dev/null
@@ -0,0 +1,31 @@
+<?php\r
+/**\r
+ * Attach plugin for Nucleus CMS\r
+ * Version 0.9.6 (1.0 RC2) for PHP5\r
+ * Written By Mocchi, Apr. 04, 2011\r
+ * Original code was written by NKJG and yamamoto, May 02, 2009\r
+ * This plugin depends on NP_Thumbnail and NP_MediaUtils\r
+ * \r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 3\r
+ * of the License, or (at your option) any later version.\r
+ */\r
+\r
+define('_NP_ATTACH_01', 'アイテムに直接、ファイルを添付します。添付したファイルはタグ<%Attach%>でアイテム中に表示できます');\r
+define('_NP_ATTACH_02', '管理画面に表示するサムネイルの横幅の最大値');\r
+define('_NP_ATTACH_03', '管理画面に表示するサムネイルの縦幅の最大値');\r
+define('_NP_ATTACH_04', '管理画面に表示する縮小画像のテンプレート');\r
+define('_NP_ATTACH_05', '管理画面に表示する画像以外のテンプレート');\r
+define('_NP_ATTACH_06', 'アイテムに添付できるファイルの数');\r
+define('_NP_ATTACH_07', 'ウェブログに表示する原寸画像のテンプレート。縮小画像のテンプレートはNP_Thumbnailのテンプレートに準じてます。');\r
+define('_NP_ATTACH_08', 'ウェブログに表示する画像以外のテンプレート');\r
+define('_NP_ATTACH_09', 'ファイルの情報');\r
+define('_NP_ATTACH_10', 'タグ');\r
+define('_NP_ATTACH_11', 'ファイルと説明文');\r
+define('_NP_ATTACH_12', '埋め込み方法');\r
+define('_NP_ATTACH_13', '削除');\r
+define('_NP_ATTACH_14', 'リンク');\r
+define('_NP_ATTACH_15', 'リンク');\r
+define('_NP_ATTACH_16', '縮小');\r
+define('_NP_ATTACH_17', '実寸');\r
diff --git a/NP_ImageLimitSize/NP_ImageLimitSize.php b/NP_ImageLimitSize/NP_ImageLimitSize.php
new file mode 100755 (executable)
index 0000000..c5d3202
--- /dev/null
@@ -0,0 +1,164 @@
+<?php\r
+/**\r
+ * ImageLimitSize plugin for Nucleus CMS\r
+ * Version 0.9.6 (1.0 RC2) for PHP5\r
+ * Written By Mocchi, Apr. 04, 2011\r
+ * Original code was written by Kai Greve and maintained by shizuki and yamamoto\r
+ * This plugin depends on NP_MediaUtils\r
+ * \r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 3\r
+ * of the License, or (at your option) any later version.\r
+ */\r
+\r
+class NP_ImageLimitSize extends NucleusPlugin {\r
+       public function getName()                       {return 'ImageLimitSize';}\r
+       public function getAuthor()             {return 'Mocchi, shizuki, yamamoto, Kai Greve';}\r
+       public function getURL()                        {return 'http://japan.nucleuscms.org/wiki/plugins:imagelimitsize';}\r
+       public function getVersion()            {return '0.9.6 (1.0 RC2)';}\r
+       public function getDescription()        {return _NP_IMAGELIMITSIZE_01;}\r
+       public function getPluginDep()  {return array('NP_MediaUtils');}\r
+       public function getMinNucleusVersion()          {return 360;}\r
+       public function supportsFeature($feature)       { return in_array ($feature, array ('SqlTablePrefix', 'SqlApi'));}\r
+       public function getEventList()  {return array('PrePluginOptionsEdit', 'PreMediaUpload', 'MediaUploadFormExtras');}\r
+       \r
+       public function install() {\r
+               $this->createOption('maxwidth', '_NP_IMAGELIMITSIZE_02', 'text', '550', 'datatype=numerical');\r
+               $this->createOption('maxheight', '_NP_IMAGELIMITSIZE_03', 'text', '0', 'datatype=numerical');\r
+               $this->createBlogOption('status', '_NP_IMAGELIMITSIZE_04', 'yesno', 'yes');\r
+               $this->createBlogOption('blog_maxwidth', '_NP_IMAGELIMITSIZE_05', 'text', '0', 'datatype=numerical');\r
+               $this->createBlogOption('blog_maxheight', '_NP_IMAGELIMITSIZE_06', 'text', '0', 'datatype=numerical');\r
+               return;\r
+       }\r
+       \r
+       public function uninstall() {\r
+               // plugin options are purged automatically when uninstalled.\r
+               return;\r
+       }\r
+       \r
+       public function init() {\r
+               if((string)$_REQUEST['action'] == 'pluginlist' && !defined('_NP_IMAGELIMITSIZE_01')) {\r
+                       $language = preg_replace('#[/|\\\\]#', '', getLanguageName());\r
+                       if (file_exists($this->getDirectory() . $language.'.php')) {\r
+                               include($this->getDirectory() . $language.'.php');\r
+                       } else {\r
+                               include($this->getDirectory() . 'english.php');\r
+                       }\r
+               }\r
+               return;\r
+       }\r
+       \r
+/*\r
+ * for translation\r
+ */\r
+       public function event_PrePluginOptionsEdit ($data) {\r
+               if(!defined('_NP_IMAGELIMITSIZE_01')) {\r
+                       $language = preg_replace('#[/|\\\\]#', '', getLanguageName());\r
+                       if (file_exists($this->getDirectory() . $language.'.php')) {\r
+                               include($this->getDirectory() . $language.'.php');\r
+                       } else {\r
+                               include($this->getDirectory() . 'english.php');\r
+                       }\r
+               }\r
+               if ($data['context'] != 'global') {\r
+                       foreach($data['options'] as $key => $option) {\r
+                               if ($option['pid'] == $this->getID()) {\r
+                                       if (defined($option['description'])) {\r
+                                               $data['options'][$key]['description'] = constant($option['description']);\r
+                                       }\r
+                                       if ($option['type'] == 'select') {\r
+                                               foreach (explode('|', $option['typeinfo']) as $option) {\r
+                                                       if (defined($option)) {\r
+                                                               $data['options'][$key]['typeinfo'] = str_replace($option, constant($option), $data['options'][$key]['typeinfo']);\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                               }\r
+                       }\r
+               } else if ($data['plugid'] == $this->getID()) {\r
+                       foreach($data['options'] as $key => $option){\r
+                               if (defined($option['description'])) {\r
+                                       $data['options'][$key]['description'] = constant($option['description']);\r
+                               }\r
+                               if ($option['type'] == 'select') {\r
+                                               foreach (explode('|', $option['typeinfo']) as $option) {\r
+                                                       if (defined($option)) {\r
+                                                               $data['options'][$key]['typeinfo'] = str_replace($option, constant($option), $data['options'][$key]['typeinfo']);\r
+                                                       }\r
+                                               }\r
+                               }\r
+                       }\r
+               }\r
+               return;\r
+       }\r
+       \r
+/*\r
+ * for translation\r
+ */\r
+       static private function t($text,$array=array()) {\r
+               if (is_array($array)) {\r
+                       $search = array();\r
+                       $replace = array();\r
+                       \r
+                       foreach ($array as $key => $value){\r
+                               if (is_array($value)) {\r
+                                       continue;\r
+                               }\r
+                               $search[] = '<%'.preg_replace('/[^a-zA-Z0-9_]+/','',$key).'%>';\r
+                               $replace[] = $value;\r
+                       }\r
+               }\r
+               return htmlspecialchars (str_replace($search, $replace, $text), ENT_QUOTES, _CHARSET);\r
+       }\r
+       \r
+       public function event_PreMediaUpload($data) {\r
+               global $CONF, $manager;\r
+               \r
+               if (!class_exists('MediaUtils', FALSE)) {\r
+                       return;\r
+               }\r
+               \r
+               if (MediaUtils::$blogid == 0) {\r
+                       return;\r
+               }\r
+               \r
+               if ($this->getBlogOption(MediaUtils::$blogid, 'status') == 'no') {\r
+                       return;\r
+               }\r
+               \r
+               if (0 == ($maxwidth = $this->getBlogOption(MediaUtils::$blogid, 'blog_maxwidth'))) {\r
+                       $maxwidth = $this->getOption('maxwidth');\r
+               }\r
+               \r
+               if (0 == ($maxheight = $this->getBlogOption(MediaUtils::$blogid, 'blog_maxheight'))) {\r
+                       $maxheight = $this->getOption('maxheight');\r
+               }\r
+               \r
+               $path = basename($data['uploadfile']);\r
+               $root = str_replace('/' . $path, '', $data['uploadfile']);\r
+               \r
+               if (FALSE === ($medium = new MEDIUM($root, $path, MediaUtils::$prefix))) {\r
+                       return;\r
+               }\r
+               \r
+               if (!array_key_exists($medium->mime, MediaUtils::$image_mime)\r
+                || ($maxwidth >= $medium->width && $maxheight >= $medium->height)) {\r
+                       return;\r
+               }\r
+               \r
+               if (FALSE === $medium->setResampledSize($maxwidth, $maxheight)) {\r
+                       return;\r
+               }\r
+               \r
+               if (!MediaUtils::storeResampledImage($root, $path, $medium)) {\r
+                       return;\r
+               }\r
+               return;\r
+       }\r
+       \r
+       public function event_MediaUploadFormExtras() {\r
+               echo '<input type="hidden" name="blogid" value="' . MediaUtils::$blogid . '" />' . "\n";\r
+               return;\r
+       }\r
+}\r
diff --git a/NP_ImageLimitSize/imagelimitsize/english.php b/NP_ImageLimitSize/imagelimitsize/english.php
new file mode 100755 (executable)
index 0000000..c91173f
--- /dev/null
@@ -0,0 +1,20 @@
+<?php\r
+/**\r
+ * ImageLimitSize plugin for Nucleus CMS\r
+ * Version 0.9.6 (1.0 RC2) for PHP5\r
+ * Written By Mocchi, Apr. 04, 2011\r
+ * Original code was written by Kai Greve and maintained by shizuki and yamamoto\r
+ * This plugin depends on NP_MediaUtils\r
+ * \r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 3\r
+ * of the License, or (at your option) any later version.\r
+ */\r
+\r
+define('_NP_IMAGELIMITSIZE_01',        'Resample uploaded image just after uploading if bigger than defined size');\r
+define('_NP_IMAGELIMITSIZE_02',        'Maximam height for image');\r
+define('_NP_IMAGELIMITSIZE_03',        'Maximum width for image');\r
+define('_NP_IMAGELIMITSIZE_04',        'Enable Resampling');\r
+define('_NP_IMAGELIMITSIZE_05',        'Maximum height for image. Plugin\'s global option is applied if blank');\r
+define('_NP_IMAGELIMITSIZE_06',        'Maximal height for image. Plugin\'s global option is applied if blank');\r
diff --git a/NP_ImageLimitSize/imagelimitsize/index.html b/NP_ImageLimitSize/imagelimitsize/index.html
new file mode 100755 (executable)
index 0000000..498e4ea
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>Notice</title>
+</head>
+<body>
+<h1>Notice</h1>
+<p>Nothing to see here</p>
+</body>
+</html>
\ No newline at end of file
diff --git a/NP_ImageLimitSize/imagelimitsize/japanese-euc.php b/NP_ImageLimitSize/imagelimitsize/japanese-euc.php
new file mode 100755 (executable)
index 0000000..f5182a4
--- /dev/null
@@ -0,0 +1,20 @@
+<?php\r
+/**\r
+ * ImageLimitSize plugin for Nucleus CMS\r
+ * Version 0.9.6 (1.0 RC2) for PHP5\r
+ * Written By Mocchi, Apr. 04, 2011\r
+ * Original code was written by Kai Greve and maintained by shizuki and yamamoto\r
+ * This plugin depends on NP_MediaUtils\r
+ * \r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 3\r
+ * of the License, or (at your option) any later version.\r
+ */\r
+\r
+define('_NP_IMAGELIMITSIZE_01',        '¥Õ¥¡¥¤¥ë¤ò¥¢¥Ã¥×¥í¡¼¥É¤·¤¿Ä¾¸å¤Ë¡¢²èÁü¥Õ¥¡¥¤¥ë¤Ç¤¢¤ê¤«¤Ä½Ä²£¥µ¥¤¥º¤¬ÀßÄêÃͤè¤êÂ礭¤«¤Ã¤¿¾ì¹ç¡¢½Ì¾®¤·¤¿²èÁü¥Õ¥¡¥¤¥ë¤òÂå¤ï¤ê¤ËÊݸ¤·¤Þ¤¹');\r
+define('_NP_IMAGELIMITSIZE_02',        'ºÇÂç¤Î²£Éý');\r
+define('_NP_IMAGELIMITSIZE_03',        'ºÇÂç¤Î¹â¤µ');\r
+define('_NP_IMAGELIMITSIZE_04',        'µ¡Ç½¤òÍ­¸ú¤Ë¤·¤Þ¤¹');\r
+define('_NP_IMAGELIMITSIZE_05',        'ºÇÂç¤Î²£Éý¡£0¤Î¾ì¹ç¤Ï¥×¥é¥°¥¤¥ó¥ª¥×¥·¥ç¥ó¤ÎÃͤòŬÍѤ·¤Þ¤¹');\r
+define('_NP_IMAGELIMITSIZE_06',        'ºÇÂç¤Î¹â¤µ¡£0¤Î¾ì¹ç¤Ï¥×¥é¥°¥¤¥ó¥ª¥×¥·¥ç¥ó¤ÎÃͤòŬÍѤ·¤Þ¤¹');\r
diff --git a/NP_ImageLimitSize/imagelimitsize/japanese-utf8.php b/NP_ImageLimitSize/imagelimitsize/japanese-utf8.php
new file mode 100755 (executable)
index 0000000..86e0b14
--- /dev/null
@@ -0,0 +1,20 @@
+<?php\r
+/**\r
+ * ImageLimitSize plugin for Nucleus CMS\r
+ * Version 0.9.6 (1.0 RC2) for PHP5\r
+ * Written By Mocchi, Apr. 04, 2011\r
+ * Original code was written by Kai Greve and maintained by shizuki and yamamoto\r
+ * This plugin depends on NP_MediaUtils\r
+ * \r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 3\r
+ * of the License, or (at your option) any later version.\r
+ */\r
+\r
+define('_NP_IMAGELIMITSIZE_01',        'ファイルをアップロードした直後に、画像ファイルでありかつ縦横サイズが設定値より大きかった場合、縮小した画像ファイルを代わりに保存します');\r
+define('_NP_IMAGELIMITSIZE_02',        '最大の横幅');\r
+define('_NP_IMAGELIMITSIZE_03',        '最大の高さ');\r
+define('_NP_IMAGELIMITSIZE_04',        '機能を有効にします');\r
+define('_NP_IMAGELIMITSIZE_05',        '最大の横幅。0の場合はプラグインオプションの値を適用します');\r
+define('_NP_IMAGELIMITSIZE_06',        '最大の高さ。0の場合はプラグインオプションの値を適用します');\r
diff --git a/NP_ImprovedMedia/NP_ImprovedMedia.php b/NP_ImprovedMedia/NP_ImprovedMedia.php
new file mode 100755 (executable)
index 0000000..62bbf8b
--- /dev/null
@@ -0,0 +1,278 @@
+<?php\r
+/**\r
+ * ImprovedMedia plugin for Nucleus CMS\r
+ * Version 3.0.1 for PHP5\r
+ * Written By Mocchi, Feb.28, 2010\r
+ * \r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 3\r
+ * of the License, or (at your option) any later version.\r
+ */\r
+\r
+class NP_ImprovedMedia extends NucleusPlugin {\r
+ // private\r
+ private $baseUrl = ''; //string\r
+ // private\r
+ private $blog = FALSE; //object\r
+ // private\r
+ private $blogid = 1; //integer\r
\r
+ // public\r
+ public function __construct() {\r
+  global $CONF;\r
+  $this->baseUrl = str_replace($CONF['AdminURL'], '', $this->getAdminURL());\r
+  self::setBlogObject();\r
+  return;\r
+ }\r
\r
+ // public\r
+ public function getName() { return 'ImprovedMedia'; }\r
+ // public\r
+ public function getAuthor() { return 'Mocchi'; }\r
+ // public\r
+ public function getURL() { return 'http://japan.nucleuscms.org/wiki/plugins:improvedmedia'; }\r
+ // public\r
+ public function getVersion() { return '3.0.1 for PHP5'; }\r
+ // public\r
+ public function getMinNucleusVersion() { return 223; }\r
+ // public\r
+ public function getDescription() { return _IM_DESCRIPTION; }\r
\r
+ // public\r
+ public function supportsFeature($what) {\r
+  global $CONF;\r
+  switch($what) {\r
+  case 'HelpPage':\r
+  case 'SqlTablePrefix':\r
+   return 1;\r
+  default:\r
+   return 0;\r
+  }\r
+ }\r
\r
+ // public\r
+ public function init() {\r
+  $language = preg_replace( '#[/|\\\\]#', '', getLanguageName());\r
+  if(file_exists($this->getDirectory() .'lang/' .  $language.'.php'))\r
+   include_once($this->getDirectory() . 'lang/' . $language.'.php');\r
+  else\r
+   include_once($this->getDirectory() . 'lang/english.php');\r
+  \r
+  if($this->getOption('IM_EACHBLOGDIR') == 'yes')\r
+   self::setDirectories();\r
+  \r
+  return;\r
+ }\r
\r
+ // public\r
+ public function install() {\r
+  $this->createOption('IM_PRIVATE', _IM_OPTION_PRIVATE , 'yesno', 'yes');\r
+  $this->createOption('IM_ITEMDISPLAY', _IM_OPTION_ITEMDISPLAY , 'text', '10', 'datatype=numerical' );\r
+  $this->createOption('IM_GREYBOX', _IM_OPTION_GREYBOX , 'yesno', 'no');\r
+  $this->createOption('IM_EACHBLOGDIR', _IM_OPTION_EACHBLOGDIR , 'yesno', 'no');\r
+  return;\r
+ }\r
\r
+ // public\r
+ public function unInstall() {\r
+  $this->deleteOption('IM_PRIVATE');\r
+  $this->deleteOption('IM_ITEMDISPLAY');\r
+  $this->deleteOption('IM_GREYBOX');\r
+  $this->deleteOption('IM_EACHBLOGDIR');\r
+  return;\r
+ }\r
\r
+ // public\r
+ public function getEventList() {\r
+  return array('InitSkinParse', 'AdminPrePageHead', 'BookmarkletExtraHead');\r
+ }\r
\r
+ // public\r
+ public function doAction($type) {\r
+  global $DIR_LIBS;\r
+  if(!class_exists('MEDIA', FALSE))\r
+   include($DIR_LIBS . 'MEDIA.php');\r
+  if(!class_exists('MEDIA_VARIABLES', FALSE))\r
+   include($this->getDirectory() . 'MEDIA_VARIABLES.php');\r
+  if(!class_exists('MEDIA_CONTROL', FALSE))\r
+   include($this->getDirectory() . 'MEDIA_CONTROL.php');\r
+  \r
+  new MEDIA_CONTROL($this);\r
+  exit;\r
+ }\r
\r
+ // public\r
+ public function doSkinVar($data, $place) {\r
+  global $CONF, $member;\r
+  if($member->isLoggedIn()) {\r
+   if($this->getOption('IM_GREYBOX') == 'yes') {\r
+    switch($place) {\r
+    case 'head':\r
+     echo '<script type="text/javascript">' . "\n" .\r
+      '<!--' . "\n" . \r
+      ' var GB_ROOT_DIR = "' . $CONF['AdminURL'] . $this->baseUrl . 'greybox/";' . "\n" .\r
+      '// -->' . "\n" .\r
+      '</script>' . "\n" .\r
+      '<script type="text/javascript" src="' . $CONF['AdminURL'] . $this->baseUrl . 'greybox/AJS.js"></script>' . "\n" .\r
+      '<script type="text/javascript" src="' . $CONF['AdminURL'] . $this->baseUrl . 'greybox/AJS_fx.js"></script>' . "\n" .\r
+      '<script type="text/javascript" src="' . $CONF['AdminURL'] . $this->baseUrl . 'greybox/gb_scripts.js"></script>' . "\n".\r
+      '<link href="' . $CONF['AdminURL'] . $this->baseUrl . 'greybox/gb_styles.css" rel="stylesheet" type="text/css" />' . "\n";\r
+     break;\r
+    case 'anchor':\r
+     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>';\r
+     break;\r
+    default:\r
+     break;\r
+    }\r
+   } else {\r
+    if($place == 'anchor') {\r
+     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>';\r
+    }\r
+   }\r
+  }\r
+  return;\r
+ }\r
\r
+ // public\r
+ public function event_InitSkinParse(&$data) {\r
+  return;\r
+ }\r
\r
+ // public\r
+ public function event_BookmarkletExtraHead(&$data) {\r
+  self::addHeader($data['extrahead']);\r
+  return;\r
+ }\r
\r
+ // public\r
+ public function event_AdminPrePageHead(&$data) {\r
+  if(($data['action'] == 'createitem') || ($data['action'] == 'itemedit'))\r
+   self::addHeader($data['extrahead']);\r
+  return;\r
+ }\r
\r
+ // private\r
+ private function addHeader(&$extrahead) {\r
+  global $CONF;\r
+  \r
+  if($this->getOption('IM_GREYBOX') == 'yes') {\r
+   $extrahead .= '<script type="text/javascript">' ."\n" .\r
+   '<!--' ."\n".\r
+   'function addMedia() {' ."\n".\r
+   ' GB_showCenter(\'Media Control' . _IM_HEADER_TEXT . '\',\'' . $CONF['ActionURL'] . '?action=plugin&name=ImprovedMedia&mode=upload_select&astool=0&blogid=' . $this->blogid . '\',540,600);' . "\n" .\r
+   '}' . "\n";\r
+  } else {\r
+   $extrahead .= '<script type="text/javascript">' ."\n" .\r
+   '<!--' ."\n".\r
+   'function addMedia() {' ."\n".\r
+   ' window.open(\'' . $CONF['ActionURL'] . '?action=plugin&name=ImprovedMedia&mode=upload_select&astool=0&blogid=' . $this->blogid . '\' , \'MediaControl\' , \'width=600 , height=600, scrollbars=1\');' . "\n" .\r
+   '}' . "\n";\r
+  }\r
+  $extrahead .= 'function includeImage(collection, filename, type, width, height, text) {' . "\n" .\r
+  ' var fullName;' . "\n" .\r
+  ' if(isNaN(collection) || (nucleusAuthorId != collection)) {' . "\n" .\r
+  '  fullName = collection + \'/\' + filename;' . "\n" .\r
+  ' } else {' . "\n" .\r
+  '  fullName = filename;' . "\n" .\r
+  ' }' . "\n" .\r
+  ' var replaceBy;' . "\n" .\r
+  ' switch(type) {' . "\n" .\r
+  ' case \'popup\':' . "\n" .\r
+  '  replaceBy = \'<%popup(\' +  fullName + \'|\'+width+\'|\'+height+\'|\' + text +\')%>\';' . "\n" .\r
+  '  break;' . "\n" .\r
+  ' case \'inline\':' . "\n" .\r
+  ' default:' . "\n" .\r
+  '  replaceBy = \'<%image(\' +  fullName + \'|\'+width+\'|\'+height+\'|\' + text +\')%>\';' . "\n" .\r
+  ' }' . "\n" .\r
+  ' insertAtCaret(replaceBy);' . "\n" .\r
+  ' updAllPreviews();' . "\n" .\r
+  '}' . "\n" .\r
+  '' . "\n" .\r
+  'function includeOtherMedia(collection, filename, text) {' . "\n" .\r
+  ' var fullName;' . "\n" .\r
+  ' if(isNaN(collection) || (nucleusAuthorId != collection)) {' . "\n" .\r
+  '  fullName = collection + \'/\' + filename;' . "\n" .\r
+  ' } else {' . "\n" .\r
+  '  fullName = filename;' . "\n" .\r
+  ' }' . "\n" .\r
+  ' var replaceBy = \'<%media(\' +  fullName + \'|\' + text +\')%>\';' . "\n" .\r
+  ' insertAtCaret(replaceBy);' . "\n" .\r
+  ' updAllPreviews();' . "\n" .\r
+  '}' .\r
+  '// -->' ."\n".\r
+  '</script>'."\n";\r
+  \r
+  if($this->getOption('IM_GREYBOX') == 'yes') {\r
+   $extrahead .= '<script type="text/javascript">' . "\n" .\r
+   '<!--' . "\n" .\r
+   ' var GB_ROOT_DIR = "' . $CONF['AdminURL'] . $this->baseUrl . 'greybox/";' . "\n" .\r
+   '// -->' . "\n" .\r
+   '</script>' . "\n" .\r
+   '<script type="text/javascript" src="' . $CONF['AdminURL'] . $this->baseUrl . 'greybox/AJS.js"></script>' . "\n" .\r
+   '<script type="text/javascript" src="' . $CONF['AdminURL'] . $this->baseUrl . 'greybox/AJS_fx.js"></script>' . "\n" .\r
+   '<script type="text/javascript" src="' . $CONF['AdminURL'] . $this->baseUrl . 'greybox/gb_scripts.js"></script>' . "\n" .\r
+   '<link href="' . $CONF['AdminURL'] . $this->baseUrl . 'greybox/gb_styles.css" rel="stylesheet" type="text/css" />' . "\n";\r
+  }\r
+  return;\r
+ }\r
\r
+ // private\r
+ private function setBlogObject() {\r
+  global $manager, $blog;\r
+  \r
+  $blogid = intRequestVar('blogid');\r
+  $itemid = intRequestVar('itemid');\r
+  \r
+  if($blog) {\r
+   $this->blog =& $blog;\r
+   $this->blogid =& $blog->getID();\r
+   return;\r
+  }\r
+  \r
+  if($blogid && $manager->existsBlogID($blogid)) {\r
+   $this->blog =& $manager->getBlog($blogid);\r
+   $this->blogid =& $this->blog->getID();\r
+   return;\r
+  }\r
+  \r
+  if($itemid && $manager->existsItem($itemid, 1, 1)) {\r
+   $this->blog =& $manager->getBlog(getBlogIDFromItemID($itemid));\r
+   $this->blogid =& $this->blog->getID();\r
+   return;\r
+  }\r
+ }\r
\r
+ // private\r
+ private function setDirectories() {\r
+  global $DIR_MEDIA, $CONF;\r
+  \r
+  if(!$this->blog)\r
+   return;\r
+  \r
+  $blog =& $this->blog;\r
+  $bshortname =& $blog->getShortName();\r
+  \r
+  if($this->blogid !== 1) {\r
+   $DIR_MEDIA = preg_replace('#(.+)/(.+)?/$#',"$1/$bshortname/$2/",$DIR_MEDIA);\r
+   $CONF['MediaURL'] = preg_replace( '#(.+)/(.+)?/$#' , "$1/$bshortname/$2/" , $CONF['MediaURL'] );\r
+  }\r
+  return;\r
+ }\r
\r
+ // public\r
+ public function & getBlog() {\r
+  return $this->blog;\r
+ }\r
\r
+ // public\r
+ public function & getBlogid() {\r
+  return $this->blogid;\r
+ }\r
\r
+ // public\r
+ public function getBaseURL() {\r
+  return $this->baseUrl;\r
+ }\r
+}\r
+?>
\ No newline at end of file
diff --git a/NP_ImprovedMedia/improvedmedia/MEDIA_CONTROL.php b/NP_ImprovedMedia/improvedmedia/MEDIA_CONTROL.php
new file mode 100755 (executable)
index 0000000..65f0b24
--- /dev/null
@@ -0,0 +1,1733 @@
+<?php
+/**
+ * ImprovedMedia plugin for Nucleus CMS
+ * Version 3.0.1 for PHP5
+ * Written By Mocchi, Feb.28, 2010
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ */
+
+class MEDIA_CONTROL extends MEDIA_VARIABLES {
+ public function __construct(&$PluginObject) {
+  global $CONF, $manager, $member;
+  
+  parent::__construct(&$PluginObject);
+  self::setMode();
+  
+  // login routine from globalfunctions.php
+  // this should be checked and changes as soon as the core program is updated
+  if(self::getMode() == 'login') {
+   if (!isset($CONF['secureCookieKey']))
+    $CONF['secureCookieKey'] = 24;
+   switch($CONF['secureCookieKey']){
+    case 8:
+     $CONF['secureCookieKeyIP'] = preg_replace('#\.[0-9]+\.[0-9]+\.[0-9]+$#', '', serverVar('REMOTE_ADDR'));
+     break;
+    case 16:
+     $CONF['secureCookieKeyIP'] = preg_replace('#\.[0-9]+\.[0-9]+$#', '', serverVar('REMOTE_ADDR'));
+     break;
+    case 24:
+     $CONF['secureCookieKeyIP'] = preg_replace('#\.[0-9]+$#', '', serverVar('REMOTE_ADDR'));
+     break;
+    case 32:
+     $CONF['secureCookieKeyIP'] = serverVar('REMOTE_ADDR');
+     break;
+    default:
+     $CONF['secureCookieKeyIP'] = '';
+   }
+   
+   $login = postVar('login');
+   $pw = substr(postVar('password'),0,40);
+   $shared = intPostVar('shared');
+   
+   if($member->login($login, $pw)) {
+    $member->newCookieKey();
+    $member->setCookies($shared);
+    
+    if ($CONF['secureCookieKey'] !=='none') {
+     $member->setCookieKey(md5($member->getCookieKey() . $CONF['secureCookieKeyIP']));
+     $member->write();
+    }
+    
+    $manager->notify('LoginSuccess', array('member' => &$member));
+    ACTIONLOG::add(INFO, "Login successful for $login (sharedpc=$shared)");
+   } else {
+    $manager->notify('LoginFailed', array('username' => $login));
+    ACTIONLOG::add(INFO, "Login failed for $login");
+   }
+  }
+  
+  self::setAlttext();
+  self::setAstool();
+  self::setCollection();
+  self::setSubDir();
+  self::setFilename();
+  self::setNewFilename();
+  self::setOffset();
+  self::setWay();
+  self::setFilter();
+  
+  if(!$member->isLoggedIn()) {
+   self::media_loginAndPassThrough();
+   return;
+  }
+  
+  if(!$PluginObject->getBlogid()) {
+   self::media_doError(_IM_FORBIDDEN_ACCESS);
+   return;
+  }
+  
+  if(!$member->isAdmin() && !$member->isTeamMember(self::getBlogid())) {
+   self::media_doError(_ERROR_NOTONTEAM);
+   return;
+  }
+  
+  if(!in_array(self::getMode(), parent::$modesNotToCheck) && !$manager->checkTicket()) {
+   self::media_doError(_ERROR_BADTICKET);
+   return;
+  }
+  
+  if(!is_dir(self::getDirMedia()) || !is_writable(self::getDirMedia())) {
+   self::media_doError(_IM_REMIND_MEDIADIR);
+   return;
+  }
+  
+  if(self::getCollections() === 'error') {
+   self::media_doError(_IM_REMIND_DIRECTORY);
+   return;
+  }
+  
+  if(self::getCollection() === 'error') {
+   self::media_doError(_IM_MISSING_DIRECTORY);
+   return;
+  }
+  
+  if(self::getSubdirs() === 'error') {
+   self::media_doError(_IM_COLLECTION_FAILED_READ);
+   return;
+  }
+  
+  if(self::getFilename() === 'error') {
+   self::media_doError(_IM_MISSING_FILE);
+   return;
+  }
+  
+  switch(self::getMode()) {
+   case 'rename_confirm';
+    self::media_rename_confirm();
+   return;
+   case 'rename';
+    self::media_rename();
+    return;
+   case 'erase_confirm':
+    self::media_erase_confirm();
+    return;
+   case 'erase';
+    self::media_erase();
+    return;
+   case 'upload_select':
+   case _IM_UPLOAD_NEW:
+    self::media_upload_select();
+    return;
+   case 'upload':
+    self::media_upload();
+    return;
+   case 'embed_confirm':
+    self::media_embed_confirm();
+    return;
+   case 'embed':
+    self::media_embed();
+    return;
+   case 'directory_remove_confirm':
+    self::media_directory_remove_confirm();
+    return;
+   case 'directory_remove':
+    self::media_directory_remove();
+    return;
+   case _IM_CREATE_SUBDIR_CONFIRM:
+    self::media_directory_create_confirm();
+    return;
+   case 'directory_create':
+    self::media_directory_create();
+    return;
+   case 'directory_rename_confirm':
+    self::media_directory_rename_confirm();
+    return;
+   case 'directory_rename':
+    self::media_directory_rename();
+    return;
+   case _IM_DISPLAY_SUBDIR:
+   case _IM_DISPLAY_SUBDIR_SELECT:
+   case 'directory_display':
+    self::media_directory_display();
+    return;
+   case _IM_COLLECTION_SELECT:
+   case _IM_FILTER_APPLY:
+   case 'display':
+   default:
+    self::media_display();
+    return;
+  }
+  return;
+ }
+ private function showMediaList() {
+  global $manager, $member;
+  
+  $collections = self::getCollections();
+  
+  if(!self::getSubdir()) $combinedcollection = self::getCollection();
+  else $combinedcollection = self::getCollection() . '/' . self::getSubdir();
+  
+  $arr = MEDIA::getMediaListByCollection($combinedcollection, self::getFilter());
+  $list = array();
+  
+  foreach($arr as $obj) {
+   if(!is_dir(self::getDirMedia() . $obj->collection . '/' . $obj->filename)
+    && preg_match('#^(.+)\.([a-zA-Z0-9]{2,})$#', $obj->filename))
+    array_push($list, $obj);
+  }
+  
+  if(self::getMediaprefix())
+   usort($list, array("MEDIA_CONTROL", "sort_media_by_filename"));
+  
+  $fileamount = count($list);
+  
+  if($fileamount > 0) {
+   $idxStart = ceil(self::getOffset() / self::getItemdisplay()) * self::getItemdisplay();
+   $idxEnd = $idxStart + self::getItemdisplay();
+   if($idxEnd > $fileamount)
+    $idxEnd = $fileamount;
+   $idxPrev = $idxStart - self::getItemdisplay();
+   if($idxPrev < 0)
+    $idxPrev = 0;
+   $idxNext = $idxStart + self::getItemdisplay();
+   
+   echo '<table frame="void" rules="none" summary="FILE LIST" width="100%">' . "\n";
+   echo '<caption>' . _IM_COLLECTION_AMOUNT . $fileamount . ' (';
+   if(!self::getFilter())
+    echo _IM_FILTER_NONE;
+   else
+    echo _IM_FILTER . self::getFilter();
+   echo ') &gt;&gt; ';
+   if(self::getSubdir())
+    echo self::getSubdir() . ' &gt;&gt; ';
+   echo $collections[self::getCollection()];
+   if(self::getBlogShortName() && self::getEachblogdir())
+    echo ' &gt;&gt; ' . self::getBlogShortName();
+   echo "</caption>\n";
+   echo "<thead>\n";
+   echo "<tr>\n";
+   
+   if(self::getMediaprefix())
+    echo '<th>' . _IM_UPDATE . "</th>\n";
+   else
+    echo '<th>' . _MEDIA_MODIFIED . "</th>\n";
+   
+   echo '<th>' . _IM_FILENAME_CLICK . "</th>\n";
+   echo '<th>' . _IM_TYPE . "</th>\n";
+   
+   if(!self::getAstool())
+    echo '<th>' . _IM_ACTION . "</th>\n";
+   
+   echo '<th>' . _IM_DIMENSIONS . "</th>\n";
+   echo '<th colspan="2">' . _IM_FUNCTION . "</th>\n";
+   echo "</tr>\n";
+   echo "</thead>\n";
+   echo "<tfoot>";
+   echo "<tr>\n";
+   echo '<td colspan="2">'. "\n";
+   if($idxStart > 0)
+    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> ';
+   if(($idxStart + 1) != $idxEnd)
+    echo ($idxStart + 1) . ' to ' . $idxEnd . ' / ' . $fileamount . ' ';
+   if($idxEnd < $fileamount)
+    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> ';
+   echo "</td>\n";
+   if(!self::getAstool())
+    echo '<td colspan="5" class="right">'. "\n";
+   else
+    echo '<td colspan="4" class="right">'. "\n";
+   if(self::getBlogName() && self::getEachblogdir())
+    echo _IM_WEBLOG_LABEL . ': ' . self::getBlogName();
+   echo "</td>\n";
+   echo "</tr>\n";
+   echo "</tfoot>\n";
+   echo "<tbody>\n";
+   
+   for($i = $idxStart; $i < $idxEnd; $i++) {
+    $obj = $list[$i];
+    
+    list($width, $height, $filetype, $filesize) = self::getFileData($combinedcollection, $obj->filename);
+    list($update, $onlyfilename, $onlyprefix) = self::getSplitFilename($combinedcollection, $obj->filename);
+    
+    echo "<tr>\n";
+    echo "<td>" . $update . "</td>\n";
+    echo "<td>\n";
+    if($filetype != 0 && !self::getSubdir())
+     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";
+    elseif($filetype == 0 && !self::getSubdir())
+     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";
+    elseif($filetype != 0 && self::getSubdir())
+     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";
+    else
+     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";
+    
+    if(!self::getAstool())
+     echo shorten($onlyfilename . '.' . $onlyprefix, 15, '...') . "\n";
+    else
+     echo shorten($onlyfilename . '.' . $onlyprefix, 30, '...') . "\n";
+    
+    echo "</a>\n";
+    echo "</td>\n";
+    echo '<td>' . $onlyprefix . "</td>\n";
+    if(!self::getAstool()) {
+     echo "<td>\n";
+     echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
+     echo "<p>\n";
+     echo '<input type="hidden" name="mode" value="embed_confirm" />' . "\n";
+     echo $manager->addTicketHidden() . "\n";
+     echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
+     echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
+     echo '<input type="hidden" name="filename" value="' . $obj->filename . '" />' . "\n";
+     echo '<input type="hidden" name="filter" value="'. self::getFilter() . '" />' . "\n";
+     echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
+     echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
+     echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+     if($filetype != 0)
+      echo '<input type="hidden" name="type" value="image" />' . "\n";
+     else
+      echo '<input type="hidden" name="type" value="other" />' . "\n";
+     echo '<input type="submit" name="button" value="' . _IM_INCLUDE .'" class="formbutton" />' . "\n";
+     echo "</p>\n";
+     echo '</form>' . "\n";
+     echo '</td>' . "\n";
+    }
+    if($filetype != 0)
+     echo '<td>' . $width . '&nbsp;x&nbsp;' . $height . "</td>\n";
+    else
+     echo '<td>' . $filesize . "&nbsp;KB</td>\n";
+    echo '<td>' . "\n";
+    echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
+    echo "<p>\n";
+    echo '<input type="hidden" name="mode" value="erase_confirm" />' . "\n";
+    echo $manager->addTicketHidden() . "\n";
+    echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
+    echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
+    echo '<input type="hidden" name="filename" value="' . $obj->filename . '" />' . "\n";
+    echo '<input type="hidden" name="filter" value="'. self::getFilter() . '" />' . "\n";
+    echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
+    echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
+    echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+    echo '<input type="submit" name="button" value="' . _IM_ERASE . '" class="formbutton" />' . "\n";
+    echo "</p>\n";
+    echo '</form>' . "\n";
+    echo '</td>' . "\n";
+    echo '<td>' . "\n";
+    echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
+    echo "<p>\n";
+    echo '<input type="hidden" name="mode" value="rename_confirm" />' . "\n";
+    echo $manager->addTicketHidden() . "\n";
+    echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
+    echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
+    echo '<input type="hidden" name="filename" value="' . $obj->filename . '" />' . "\n";
+    echo '<input type="hidden" name="filter" value="'. self::getFilter() . '" />' . "\n";
+    echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
+    echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
+    echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+    echo '<input type="submit" name="button" value="' . _IM_RENAME . '" class="formbutton" />' . "\n";
+    echo "</p>\n";
+    echo '</form>' . "\n";
+    echo '</td>' . "\n";
+    echo '</tr>' . "\n";
+   }
+   echo "</tbody>\n";
+   echo "</table>\n";
+  } else {
+   echo '<p>' . _IM_COLLECTION_BRANK . ' (';
+   if(!self::getFilter())
+    echo _IM_FILTER_NONE;
+   else
+    echo _IM_FILTER . self::getFilter();
+   echo ') ' . ' &gt;&gt; ';
+   if(self::getSubdir())
+    echo self::getSubdir() . ' &gt;&gt; ';
+   echo $collections[self::getCollection()];
+   if(self::getBlogShortName() && self::getEachblogdir())
+    echo ' &gt;&gt; ' . self::getBlogShortName();
+   echo "</p>\n";
+  }
+  return;
+ }
+ private function media_display() {
+  global $manager, $member;
+  
+  $collections = self::getCollections();
+  $subdirs = self::getSubdirs();
+  
+  array_shift($subdirs);
+  
+  if(self::getItemdisplay() != strval(intval(self::getItemdisplay())) || (self::getItemdisplay() < 5) || (self::getItemdisplay() > 50 )) {
+   self::media_doError(_IM_ITEMDISPLAY_WRONG);
+   return;
+  }
+  
+  self::media_head();
+  
+  echo '<form method="post" action="' . self::getAccessURL() . '" enctype="application/x-www-form-urlencoded">' . "\n";
+  echo '<p>' . "\n";
+  
+  if(count($collections) > 1) {
+   echo '<label for="media_collection">' . _IM_COLLECTION_LABEL . '</label>' . "\n";
+   echo '<select name="collection" id="media_collection">' . "\n";
+   foreach($collections as $dirname => $description) {
+    if((string)$dirname == (string)self::getCollection())
+     echo '<option value="' . $dirname . '" selected="selected">' . $description . "</option>\n";
+    else
+     echo '<option value="' . $dirname . '">' . $description . "</option>\n";
+   }
+   echo '</select>' . "\n";
+   echo '<input type="submit" name="mode" value="' . _IM_COLLECTION_SELECT . '" title="' . _IM_COLLECTION_TT . '" class="formbutton" />' . "\n";
+  } else {
+   echo _IM_COLLECTION . ': ' . $collections[self::getCollection()] . '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
+  }
+  echo '<input type="submit" name="mode" value="' . _IM_UPLOAD_NEW . '" title="' . _IM_UPLOADLINK . '" class="formbutton" />' . "\n";
+  echo $manager->addTicketHidden() . "\n";
+  echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
+  echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
+  echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+  echo '</p>' . "\n";
+  echo '</form>' . "\n";
+  
+  echo '<form method="post" action="' . self::getAccessURL() . '" enctype="application/x-www-form-urlencoded">' . "\n";
+  echo '<p>' . "\n";
+  if(count($subdirs) > 0) {
+   echo '<label for="media_subdir">' . _IM_SUBDIR_LABEL . '</label>' . "\n";
+   echo '<select name="subdir" id="media_subdir">' . "\n";
+   if(self::getSubdir() == '')
+    echo '<option value="" selected="selected">' . _IM_SUBDIR_NONE . "</option>\n";
+   else
+    echo '<option value="">' . _IM_SUBDIR_NONE . "</option>\n";
+   foreach($subdirs as $key => $options) {
+    if($options['subdirname'] == self::getSubdir())
+     echo '<option value="' . $options['subdirname'] . '" selected="selected">' . $options['subdirname'] . "</option>\n";
+    else
+     echo '<option value="' . $options['subdirname'] . '">' . $options['subdirname'] . "</option>\n";
+   }
+   echo '</select>' . "\n";
+   echo '<input type="submit" name="mode" value="' . _IM_SUBDIR_SELECT . '" title="' . _IM_SUBDIR_TT . '" class="formbutton" />' . "\n";
+  } elseif(self::getSubdir() == '') {
+   echo _IM_SUBDIR_LABEL . _IM_SUBDIR_NONE . '<input type="hidden" name="subdir" value="" />' . "\n";
+  }
+  echo '<input type="submit" name="mode" value="' . _IM_DISPLAY_SUBDIR . '" title="' . _IM_DISPLAY_SUBDIR_TT. '" class="formbutton" />' . "\n";
+  echo $manager->addTicketHidden() . "\n";
+  echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
+  echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
+  echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+  echo '</p>' . "\n";
+  echo '</form>' . "\n";
+  
+  echo '<form method="post" action="' . self::getAccessURL() . '" enctype="application/x-www-form-urlencoded">' . "\n";
+  echo '<p>' . "\n";
+  echo '<label for="media_filter">' . _IM_FILTER_LABEL . '</label>' . "\n";
+  echo '<select name="filter" id="media_filter">' . "\n";
+  if(self::getFilter() == '')
+   echo '<option value="" selected="selected">' . _IM_FILTER_NONE . "</option>\n";
+  else
+   echo '<option value="">' . _IM_FILTER_NONE . "</option>\n";
+  if(is_array(self::getAllowedtypes())) {
+   foreach(self::getAllowedtypes() as $allowedtype) {
+    if($allowedtype == self::getFilter())
+     echo '<option value="' . $allowedtype . '" selected="selected">' . $allowedtype . "</option>\n";
+    else
+     echo '<option value="' . $allowedtype . '">' . $allowedtype . "</option>\n";
+   }
+  }
+  echo '</select>' . "\n";
+  echo '<input type="submit" name="mode" value="' . _IM_FILTER_APPLY . '" class="formbutton" />' . "\n";
+  echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
+  echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
+  echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
+  echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+  echo '</p>' . "\n";
+  echo '</form>' . "\n";
+  echo '<hr />' . "\n";
+  
+  self::showMediaList();
+  self::media_foot();
+  return;
+ }
+ private function media_erase() {
+  global $manager;
+  
+  if(!self::getSubdir()) $combinedfilename = self::getFilename();
+  else $combinedfilename = self::getSubdir() . '/' . self::getFilename();
+  
+  $manager->notify('PreMediaErase',array('collection' => self::getCollection(), 'filename' => $combinedfilename));
+  
+  if(!@unlink(self::getDirMedia() . self::getCollection() . '/' . $combinedfilename)) {
+   self::media_doError(_IM_ERASE_FAILED . ': ' . self::getCollection() . '/' . $combinedfilename);
+   return;
+  }
+  $manager->notify('PostMediaErase',array('collection' => self::getCollection(), 'filename' => $combinedfilename));
+  
+  self::resetFilter();
+  self::resetOffset();
+  self::media_display();
+  return;
+ }
+ private function media_rename() {
+  global $manager;
+  
+  $newfilename = self::getNewfilename();
+  
+  if($newfilename == '') {
+   self::media_rename_confirm(_IM_RENAME_BLANK);
+   return;
+  } elseif(mb_strlen($newfilename, _CHARSET) > 30) {
+   self::media_rename_confirm(_IM_RENAME_TOOLONG);
+   return;
+  } elseif(!preg_match('#^[a-zA-Z0-9 \_\-\+]+$#', $newfilename)) {
+   self::media_rename_confirm(_IM_RENAME_WRONG);
+   return;
+  } elseif(stristr($newfilename, '%00')) {
+   self::media_doError(_IM_RENAME_FORBIDDEN);
+   return;
+  }
+  
+  if(!self::getSubdir()) $combinedfilename = self::getFilename();
+  else $combinedfilename = self::getSubdir() . '/' . self::getFilename();
+  
+  list($update, $onlyfilename, $onlyprefix) = self::getSplitFilename(self::getCollection(), $combinedfilename);
+  $update = preg_replace('#/|\\\\#', '', $update);
+  
+  if(self::getMediaprefix())
+   $newfilename = $update . '-' . $newfilename . '.' . $onlyprefix;
+  else
+   $newfilename = $newfilename . '.' . $onlyprefix;
+  
+  if(!self::getSubdir()) $combinednewfilename = $newfilename;
+  else $combinednewfilename = self::getSubdir() . '/' . $newfilename;
+  
+  $manager->notify('PreMediaRename',array('collection' => self::getCollection(), 'oldfilename' => $combinedfilename, 'newfilename' => $combinednewfilename));
+  
+  if(!@rename(self::getDirMedia() . self::getCollection() . '/' . $combinedfilename, self::getDirMedia() . self::getCollection() . '/' . $combinednewfilename)) {
+   self::media_doError(_IM_RENAME_FAILED . ': ' . self::getCollection() . '/' . $combinedfilename);
+   return;
+  }
+  
+  $manager->notify('PostMediaRename',array('collection' => self::getCollection(), 'oldfilename' => $combinedfilename, 'newfilename' => $combinednewfilename));
+  
+  self::resetFilter();
+  self::resetOffset();
+  self::media_display();
+  return;
+ }
+ private function media_upload() {
+  global $CONF;
+  if(!$CONF['AllowUpload']) {
+   self::media_doError(_ERROR_DISALLOWED);
+   return;
+  }
+  
+  $uploadInfo = postFileInfo('uploadfile');
+  $filename = $uploadInfo['name'];
+  $filetype = $uploadInfo['type'];
+  $filesize = $uploadInfo['size'];
+  $filetempname = $uploadInfo['tmp_name'];
+  $fileerror = intval($uploadInfo['error']);
+  
+  // include error code for debugging
+  // (see http://www.php.net/manual/en/features.file-upload.errors.php)
+  switch($fileerror) {
+   case 0: // = UPLOAD_ERR_OK
+   break;
+   case 1: // = UPLOAD_ERR_INI_SIZE
+   case 2: // = UPLOAD_ERR_FORM_SIZE
+    self::media_doError(_ERROR_FILE_TOO_BIG);
+    return;
+   case 3: // = UPLOAD_ERR_PARTIAL
+   case 4: // = UPLOAD_ERR_NO_FILE
+   case 6: // = UPLOAD_ERR_NO_TMP_DIR
+   case 7: // = UPLOAD_ERR_CANT_WRITE
+   default:
+   self::media_doError(_ERROR_BADREQUEST . ' (' . $fileerror . ')');
+   return;
+  }
+  
+  if($filesize > self::getMaxuploadsize()) {
+   self::media_doError(_ERROR_FILE_TOO_BIG);
+   return;
+  }
+  
+  $ok = 0;
+  foreach(self::getAllowedtypes() as $allowedtype) {
+   if(eregi("\." . $allowedtype . "$",$filename))
+    $ok = 1;
+  }
+  
+  if(!$ok) {
+   self::media_doError(_ERROR_BADFILETYPE);
+   return;
+  }
+  
+  if(!is_uploaded_file($filetempname)) {
+   self::media_doError(_ERROR_BADREQUEST);
+   return;
+  }
+  
+  // prefix filename with current date (YYYY-MM-DD-) to avoid nameclashes
+  if(self::getMediaprefix())
+   $filename = strftime("%Y%m%d-", time()) . $filename;
+  
+  if(!self::getSubdir()) $combinedfilename = $filename;
+  else $combinedfilename = self::getSubdir() . '/' . $filename;
+  
+  $message = MEDIA::addMediaObject(self::getCollection(), $filetempname, $combinedfilename);
+  
+  if($message != '') {
+   self::media_doError($message);
+   return;
+  }
+  
+  self::resetFilter();
+  self::resetOffset();
+  
+  if(!self::getAstool()) {
+   $tempfilename =& self::getFilename();
+   $tempfilename = $filename;
+   self::media_embed_confirm(_IM_UPLOAD_CONPLETE);
+   return;
+  } else {
+   self::media_display();
+  }
+ }
+ private function media_embed() {
+  global $manager, $member;
+  
+  $collections = self::getCollections();
+  
+  if(!self::getSubdir()) $combinedfilename = self::getFilename();
+  else $combinedfilename = self::getSubdir() . '/' . self::getFilename();
+  
+  $jsCollection = str_replace("'","\\'", self::getCollection());
+  $jsFileName = str_replace("'","\\'", $combinedfilename);
+  
+  list($width, $height, $filetype, $filesize) = self::getFileData(self::getCollection(), $combinedfilename);
+  
+  if(self::getAlttext() == '') {
+   self::media_embed_confirm(_IM_REQUIREMENT);
+   return;
+  } elseif(mb_strlen(self::getAlttext(), _CHARSET) > 40 ) {
+   self::media_embed_confirm(_IM_ALT_TOOLONG);
+   return;
+  }
+  
+  self::media_head();
+  echo '<h2>' . _IM_HEADER_EMBED  . "</h2>\n";
+  echo '<h3>' . _IM_INCLUDE_DESC . '</h3>' . "\n";
+  echo '<div class="filedetail">' . "\n";
+  echo '<dl>' . "\n";
+  echo '<dt>' . _IM_FILENAME . '</dt>' . "\n";
+  echo '<dd>' . self::getFilename() . '</dd>' . "\n";
+  echo '<dt>' . _IM_INCLUDE_ALT . '</dt>' . "\n";
+  echo '<dd>' . self::getAlttext() . '</dd>' . "\n";
+  
+  if(self::getSubdir()) {
+   echo '<dt>' . _IM_SUBDIR  . "</dt>\n";
+   echo '<dd>' . self::getSubdir()  . "</dd>\n";
+  }
+  
+  echo '<dt>' . _IM_COLLECTION . '</dt>' . "\n";
+  echo '<dd>' . $collections[self::getCollection()] . '</dd>' . "\n";
+  
+  if(self::getBlogName() && self::getEachblogdir()) {
+   echo '<dt>' . _IM_WEBLOG_LABEL . "</dt>\n";
+   echo '<dd>' . self::getBlogName() . "</dd>\n";
+  }
+  
+  if(self::getWay() == 'popup') {
+   echo '<dt>' . _IM_DIMENSIONS . '</dt>' . "\n";
+   echo '<dd>' . $width . ' x ' . $height . ' (' . $filesize . 'KB)</dd>' . "\n";
+   echo '<dt>' . _IM_INCLUDE_WAY . '</dt>' . "\n";
+   echo '<dd>' . _IM_INCLUDE_WAY_POPUP . '</dd>' . "\n";
+  } elseif(self::getWay()  == 'inline') {
+   echo '<dt>' . _IM_DIMENSIONS . '</dt>' . "\n";
+   echo '<dd>' . $width . ' x ' . $height . ' (' . $filesize . 'KB)</dd>' . "\n";
+   echo '<dt>' . _IM_INCLUDE_WAY . '</dt>' . "\n";
+   echo '<dd>' . _IM_INCLUDE_WAY_INLINE . '</dd>';
+  } elseif(self::getWay() == 'other') {
+   echo '<dt>' . _IM_DIMENSIONS . '</dt>' . "\n";
+   echo '<dd>' . $filesize . 'KB' . '</dd>' . "\n";
+   echo '<dt>' . _IM_INCLUDE_WAY . '</dt>' . "\n";
+   echo '<dd>' . _IM_INCLUDE_WAY_OTHER . '</dd>';
+  }
+  
+  echo '</dl>' . "\n";
+  echo '</div>' . "\n";
+  
+  echo '<h3>' . _IM_INCLUDE_CODE . '</h3>' . "\n";
+  echo '<p>' . _IM_INCLUDE_CODE_DESC . '</p>' . "\n";
+  
+  if(self::getWay() == 'popup') {
+   echo '<p>&lt;%popup(' . self::getCollection() . '/' . $combinedfilename . '|' . $width . '|' . $height . '|' . self::getAlttext() . ')%&gt;</p>' . "\n";
+   echo '<form method="post" action="' . self::getAccessURL() . '" enctype="application/x-www-form-urlencoded" onclick="chooseImage(\'' . $jsCollection . '\',\'' . $jsFileName . '\',\'popup\',\'' . $width . '\',\'' . $height . '\',\'' . self::getAlttext() . '\'' . ')" >' . "\n";
+  } elseif(self::getWay() == 'inline') {
+   echo '<p>&lt;%image(' . self::getCollection() . '/' . $combinedfilename . '|' . $width . '|' . $height . '|' . self::getAlttext() . ')%&gt;</p>' . "\n";
+   echo '<form method="post" action="' . self::getAccessURL() . '" enctype="application/x-www-form-urlencoded" onclick="chooseImage(\'' . $jsCollection . '\',\'' . $jsFileName . '\',\'inline\',\'' . $width . '\',\'' . $height . '\',\'' . self::getAlttext() . '\'' . ')" >' . "\n";
+  } else {
+   echo '<p>&lt;%media(' . self::getCollection() . '/' . $combinedfilename . '|' . self::getAlttext() . ')%&gt;</p>' . "\n";
+   echo '<form method="post" action="' . self::getAccessURL() . '" enctype="application/x-www-form-urlencoded" onclick="chooseOther(\'' . $jsCollection . '\',\'' . $jsFileName . '\',\'' . self::getAlttext() . '\'' . ')" >' . "\n";
+  }
+  
+  echo '<p class="left">' . "\n";
+  echo '<input type="submit" value="' . _IM_INCLUDE . '" />' . "\n";
+  echo '</p>' . "\n";
+  echo '</form>' . "\n";
+  
+  echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
+  echo '<p class="right">' . "\n";
+  echo '<input type="hidden" name="mode" value="embed_confirm" />' . "\n";
+  echo $manager->addTicketHidden() . "\n";
+  echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
+  echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
+  echo '<input type="hidden" name="filename" value="' . self::getFilename() . '" />' . "\n";
+  echo '<input type="hidden" name="alttext" value="' . self::getAlttext() . '" />' . "\n";
+  echo '<input type="hidden" name="way" value="' . self::getWay() . '" />' . "\n";
+  echo '<input type="hidden" name="filter" value="'. self::getFilter() . '" />' . "\n";
+  echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
+  echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
+  echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+  echo '<input type="submit" value="' . _IM_INCLUDE_MODIFIED . '" />' . "\n";
+  echo '</p>' . "\n";
+  echo '</form>' . "\n";
+  
+  self::media_foot();
+  return;
+ }
+ private function media_erase_confirm() {
+  global $manager, $member;
+  
+  $collections = self::getCollections();
+  
+  if(!self::getSubdir()) $combinedcollection = self::getCollection();
+  else $combinedcollection = self::getCollection() . '/' . self::getSubdir();
+  
+  list($width, $height, $filetype, $filesize) = self::getFileData($combinedcollection, self::getFilename());
+  
+  self::media_head();
+  echo '<h2>' . _IM_HEADER_ERASE_CONFIRM  . "</h2>\n";
+  echo '<h3>' . _IM_ERASE_CONFIRM . '</h3>' . "\n";
+  echo '<div class="filedetail">' . "\n";
+  echo '<dl>' . "\n";
+  echo '<dt>' . _IM_FILENAME . '</dt>' . "\n";
+  echo '<dd>' . self::getFilename() . '</dd>' . "\n";
+  
+  if(self::getSubdir()) {
+   echo '<dt>' . _IM_SUBDIR  . "</dt>\n";
+   echo '<dd>' . self::getSubdir()  . "</dd>\n";
+  }
+  
+  echo '<dt>' . _IM_COLLECTION . '</dt>' . "\n";
+  echo '<dd>' . $collections[self::getCollection()] . '</dd>' . "\n";
+  
+  if(self::getBlogName() && self::getEachblogdir()) {
+   echo '<dt>' . _IM_WEBLOG_LABEL . "</dt>\n";
+   echo '<dd>' . self::getBlogName() . "</dd>\n";
+  }
+   
+  echo '<dt>' . _IM_DIMENSIONS . '</dt>' . "\n";
+  echo '<dd>' . $filesize . 'KB' . '</dd>' . "\n";
+  echo '</dl>' . "\n";
+  echo '</div>' . "\n";
+  echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
+  echo '<p class="left">' . "\n";
+  echo '<input type="hidden" name="mode" value="erase" />' . "\n";
+  echo $manager->addTicketHidden() . "\n";
+  echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
+  echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
+  echo '<input type="hidden" name="filename" value="' . self::getFilename() . '" />' . "\n";
+  echo '<input type="hidden" name="filter" value="'. self::getFilter() . '" />' . "\n";
+  echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
+  echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
+  echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+  echo '<input type="submit" value="' . _IM_ERASE_DONE . '" />' . "\n";
+  echo '</p>' . "\n";
+  echo '</form>' . "\n";
+  echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
+  echo '<p class="right">' . "\n";
+  echo $manager->addTicketHidden() . "\n";
+  echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
+  echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
+  echo '<input type="hidden" name="filter" value="'. self::getFilter() . '" />' . "\n";
+  echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
+  echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
+  echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+  echo '<input type="submit" name="button" value="' . _IM_RETURN . '" />' . "\n";
+  echo '</p>' . "\n";
+  echo '</form>' . "\n";
+  
+  self::media_foot();
+  return;
+ }
+ private function media_rename_confirm($notice = '') {
+  global $manager, $member;
+  
+  $collections = self::getCollections();
+  
+  self::media_head();
+  echo '<h2>' . _IM_HEADER_ERASE_CONFIRM  . "</h2>\n";
+  
+  if($notice) {
+   echo '<h3>' . _IM_NOTICE . "</h3>\n";
+   echo '<p class="notice">' .  $notice . "</p>\n";
+  }
+  
+  if(!self::getSubdir()) $combinedcollection = self::getCollection();
+  else $combinedcollection = self::getCollection() . '/' . self::getSubdir();
+  
+  list($update, $onlyfilename, $onlyprefix) = self::getSplitFilename($combinedcollection, self::getFilename());
+  
+  echo '<h3>' . _IM_RENAME_FILENAME . '</h3>' . "\n";
+  echo '<div class="filedetail">'."\n";
+  echo "<dl>\n";
+  echo '<dt>' . _IM_FILENAME . '</dt>' . "\n";
+  echo '<dd>' . $onlyfilename . '</dd>' . "\n";
+  echo '<dt>' . _IM_TYPE . '</dt>' . "\n";
+  echo '<dd>' . $onlyprefix . '</dd>' . "\n";
+  
+  if(self::getSubdir()) {
+   echo '<dt>' . _IM_SUBDIR  . "</dt>\n";
+   echo '<dd>' . self::getSubdir()  . "</dd>\n";
+  }
+  
+  echo '<dt>' . _IM_COLLECTION . '</dt>' . "\n";
+  echo '<dd>' . $collections[self::getCollection()] . '</dd>' . "\n";
+  
+  if(self::getBlogName() && self::getEachblogdir()) {
+   echo '<dt>' . _IM_WEBLOG_LABEL . "</dt>\n";
+   echo '<dd>' . self::getBlogName() . "</dd>\n";
+  }
+   
+   if(self::getMediaprefix())
+   echo '<dt>'. _IM_UPDATE . "</dt>\n";
+  else
+   echo '<dt>'. _MEDIA_MODIFIED . "</dt>\n";  
+  
+  echo '<dd>' . $update . '</dd>' . "\n";
+  echo '</dl>' . "\n";
+  echo '</div>' . "\n";
+  echo '<h3>' ._IM_RENAME_AFTER . '</h3>' . "\n";
+  echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
+  echo '<p>' ._IM_RENAME_DESCRIPTION . '</p>' . "\n";
+  echo '<p>' . "\n";
+  
+  if(self::getNewfilename())
+   echo '<input type="text" name="newfilename" value="' . self::getNewfilename() . '" size="40" />' . "\n";
+  else
+   echo '<input type="text" name="newfilename" value="' . $onlyfilename . '" size="40" />' . "\n";
+  
+  echo '</p>' . "\n";
+  echo '<p class="left">' . "\n";
+  echo '<input type="hidden" name="mode" value="rename" />' . "\n";
+  echo $manager->addTicketHidden() . "\n";
+  echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
+  echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
+  echo '<input type="hidden" name="filename" value="' . self::getFilename() . '" />' . "\n";
+  echo '<input type="hidden" name="filter" value="' . self::getFilter() . '" />' . "\n";
+  echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
+  echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
+  echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+  echo '<input type="submit" value="' . _IM_RENAME . '" />' . "\n";
+  echo '</p>' . "\n";
+  echo '</form>' . "\n";
+  
+  echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
+  echo '<p class="right">' . "\n";
+  echo $manager->addTicketHidden() . "\n";
+  echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
+  echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
+  echo '<input type="hidden" name="filter" value="' . self::getFilter() . '" />' . "\n";
+  echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
+  echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
+  echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+  echo '<input type="submit" name="button" value="' . _IM_RETURN . '" />' . "\n";
+  echo '</p>' . "\n";
+  echo '</form>' . "\n";
+  
+  self::media_foot();
+  return;
+ }
+ private function media_upload_select() {
+  global $CONF, $manager, $member;
+  
+  if(!$CONF['AllowUpload']) {
+   self::media_doError(_ERROR_DISALLOWED);
+   return;
+  }
+  
+  $collections = self::getCollections();
+  $subdirs = self::getSubdirs();
+  
+  if($subdirs)
+   array_shift($subdirs);
+  
+  self::media_head();
+  echo '<h2>' . _IM_HEADER_UPLOAD_SELECT  . "</h2>\n";
+  echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
+  
+  if(self::getBlogName() && self::getEachblogdir()) {
+   echo '<h3>' . _IM_WEBLOG_LABEL . "</h3>\n";
+   echo '<p>' . self::getBlogName() . "</p>\n";
+  }
+  
+  echo '<h3><label for="upload_collection">' . _IM_COLLECTION . "</label></h3>\n";
+  echo "<p>\n";
+  
+  if(count($collections) > 1) {
+   echo _IM_COLLECTION_DESC . "<br />\n";
+   echo '<select name="collection" id="upload_collection">' . "\n";
+   foreach($collections as $dirname => $description) {
+    if((string)$dirname == (string)self::getCollection())
+     echo '<option value="' . $dirname . '" selected="selected">' . $description . "</option>\n";
+    else
+     echo '<option value="' . $dirname . '">' . $description . "</option>\n";
+   }
+   echo '</select>' . "\n";
+   echo '<input type="submit" name="button" value="' . _IM_COLLECTION_SELECT . '" title="' . _IM_COLLECTION_TT . '" class="formbutton" />' . "\n";
+  } else {
+   echo _IM_COLLECTION . ': ' . $collections[self::getCollection()] . '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
+  }
+  echo '<input type="hidden" name="mode" value="upload_select" />' . "\n";
+  echo $manager->addTicketHidden() . "\n";
+  echo '<input type="hidden" name="subdir" value="" />' . "\n";
+  echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
+  echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+  echo '</p>' . "\n";
+  echo '</form>' . "\n";
+  
+  echo '<form  mode="' . self::getAccessURL() . '" method="post" enctype="multipart/form-data">' . "\n";
+  echo '<h3><label for="media_subdir">' . _IM_SUBDIR . "</label></h3>\n";
+  echo "<p>\n";
+  
+  if(count($subdirs) > 0) {
+   echo _IM_SUBDIR_DESC . '<br />';
+   echo '<select name="subdir" id="media_subdir">' . "\n";
+   if(self::getSubdir() == '')
+    echo '<option value="" selected="selected">' . _IM_SUBDIR_NONE . "</option>\n";
+   else
+    echo '<option value="">' . _IM_SUBDIR_NONE . "</option>\n";
+   foreach($subdirs as $key => $options) {
+    if($options['subdirname'] == self::getSubdir())
+     echo '<option value="' . $options['subdirname'] . '" selected="selected">' . $options['subdirname'] . "</option>\n";
+    else
+     echo '<option value="' . $options['subdirname'] . '">' . $options['subdirname'] . "</option>\n";
+   }
+   echo '</select>' . "\n";
+  } elseif(self::getSubdir() == '') {
+   echo _IM_SUBDIR_LABEL . _IM_SUBDIR_NONE . '<input type="hidden" name="subdir" value="" />' . "\n";
+  }
+  echo "</p>\n";
+  
+  echo '<h3>' . _IM_UPLOAD_USED_FILETYPE . "</h3>\n";
+  echo '<p>' . implode(', ', self::getAllowedtypes() ) . "</p>\n";
+  echo '<h3><label for="uploadfile">' . _UPLOAD_TITLE . "</label></h3>\n";
+  echo '<p><input type="file" name="uploadfile" id="uploadfile" size="30" />' . "</p>\n";
+  echo '<h3>' . _IM_UPLOAD_USED_ASCII . "</h3>\n";
+  echo '<p>' . _IM_UPLOAD_USED_ASCII_DESC1 . "</p>\n";
+  echo '<p>' . _IM_UPLOAD_USED_ASCII_DESC2 . "</p>\n";
+  echo '<p class="left">' . "\n";
+  echo '<input type="hidden" name="mode" value="upload" />' . "\n";
+  echo $manager->addTicketHidden() . "\n";
+  echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
+  echo '<input type="hidden" name="MAX_FILE_SIZE" value="' . self::getMaxuploadsize() . ' " />' . "\n";
+  echo '<input type="hidden" name="filter" value="' . self::getFilter() . '" />' . "\n";
+  echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
+  echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
+  echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+  echo '<input type="submit" value="' . _UPLOAD_BUTTON . '" />' . "\n";
+  echo '</p>' . "\n";
+  echo '</form>' . "\n";
+  echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
+  echo '<p class="right">' . "\n";
+  echo $manager->addTicketHidden . "\n";
+  echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
+  echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
+  echo '<input type="hidden" name="filter" value="' . self::getFilter() . '" />' . "\n";
+  echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
+  echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
+  echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+  echo '<input type="submit" name="button" value="' . _IM_RETURN . '" />' . "\n";
+  echo '</p>' . "\n";
+  echo '</form>' . "\n";
+  
+  self::media_foot();
+  return;
+ }
+ private function media_embed_confirm($notice = '') {
+  global $manager, $member;
+  
+  $collections = self::getCollections();
+  
+  if(!self::getSubdir()) $combinedcollection = self::getCollection();
+  else $combinedcollection = self::getCollection() . '/' . self::getSubdir();
+  
+  list($width, $height, $filetype, $filesize) = self::getFileData($combinedcollection, self::getFilename());
+  
+  self::media_head();
+  echo '<h2>' . _IM_HEADER_EMBED_CONFIRM  . "</h2>\n";
+  
+  if($notice) {
+   echo '<h3>' . _IM_NOTICE . "</h3>\n";
+   echo '<p class="notice">' . $notice . "</p>\n";
+  }
+  
+  echo '<h3>'. _IM_INCLUDE_FILE_SELECTED . '</h3>' . "\n";
+  echo '<div class="filedetail">' . "\n";
+  echo '<dl>' . "\n";
+  echo '<dt>' . _IM_FILENAME . '</dt>' . "\n";
+  echo '<dd>' . self::getFilename() . '</dd>' . "\n";
+  
+  if(self::getSubdir()) {
+   echo '<dt>' . _IM_SUBDIR  . "</dt>\n";
+   echo '<dd>' . self::getSubdir()  . "</dd>\n";
+  }
+  
+  echo '<dt>' . _IM_COLLECTION . '</dt>' . "\n";
+  echo '<dd>' . $collections[self::getCollection()] . '</dd>' . "\n";
+  
+  if(self::getBlogName() && self::getEachblogdir()) {
+   echo '<dt>' . _IM_WEBLOG_LABEL . "</dt>\n";
+   echo '<dd>' . self::getBlogName() . "</dd>\n";
+  }
+  
+  echo '<dt>' . _IM_DIMENSIONS . '</dt>' . "\n";
+  
+  if($filetype !== 0)
+   echo '<dd>' . $width . ' x ' . $height . ' (' . $filesize . 'KB)</dd>' . "\n";
+  else
+   echo '<dd>' . $filesize . 'KB' . '</dd>' . "\n";
+  
+  echo '</dl>' . "\n";
+  echo '</div>' . "\n";
+  echo '<h3>'. _IM_INCLUDE_ALT . '</h3>' . "\n";
+  echo '<p><label for="alt">'. _IM_INCLUDE_ALT_DESC . "</label></p>\n";
+  echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
+  echo '<p>' . "\n";
+  echo '<input type="text" name="alttext" value="'. self::getAlttext() . '" size="40" id="alt" />' . "\n";
+  echo '</p>'. "\n";
+  echo '<h3>'. _IM_INCLUDE_WAY . "</h3>\n";
+  
+  if($filetype !== 0) {
+   echo '<p>'. "\n";
+   if(self::getWay() == 'inline') {
+    echo '<input type="radio" name="way" value="popup" id="popup" />'. "\n";
+    echo '<label for="popup">'. _IM_INCLUDE_WAY_POPUP . '</label><br />'. "\n";
+    echo '<input type="radio" name="way" value="inline" id="inline" checked="checked" />'. "\n";
+    echo '<label for="inline">'. _IM_INCLUDE_WAY_INLINE . '</label>'. "\n";
+   } else {
+    echo '<input type="radio" name="way" value="popup" id="popup" checked="checked" />'. "\n";
+    echo '<label for="popup">'. _IM_INCLUDE_WAY_POPUP . '</label><br />'. "\n";
+    echo '<input type="radio" name="way" value="inline" id="inline" />'. "\n";
+    echo '<label for="inline">'. _IM_INCLUDE_WAY_INLINE . '</label>'. "\n";
+   }
+   echo '</p>'. "\n";
+  } else {
+   echo '<p>'. _IM_INCLUDE_WAY_OTHER . "\n";
+   echo '<input type="hidden" name="way" value="other" /></p>'. "\n";
+  }
+  
+  echo '<p class="left">'. "\n";
+  echo '<input type="hidden" name="mode" value="embed" />' . "\n";
+  echo $manager->addTicketHidden() . "\n";
+  echo '<input type="hidden" name="collection" value="'. self::getCollection() . '" />' . "\n";
+  echo '<input type="hidden" name="subdir" value="'. self::getSubdir() . '" />' . "\n";
+  echo '<input type="hidden" name="filename" value="'. self::getFilename() . '" />' . "\n";
+  echo '<input type="hidden" name="filter" value="' . self::getFilter() . '" />' . "\n";
+  echo '<input type="hidden" name="offset" value="'. self::getOffset() . '" />' . "\n";
+  echo '<input type="hidden" name="astool" value="'. self::getAstool() . '" />'. "\n";
+  echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+  echo '<input type="submit" value="'. _IM_INCLUDE_WAY_DECIDE . '" />'. "\n";
+  echo '</p>'. "\n";
+  echo '</form>'. "\n";
+  echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">'. "\n";
+  echo '<p class="right">'. "\n";
+  echo $manager->addTicketHidden() . "\n";
+  echo '<input type="hidden" name="collection" value="'. self::getCollection() . '" />'. "\n";
+  echo '<input type="hidden" name="subdir" value="'. self::getSubdir() . '" />' . "\n";
+  echo '<input type="hidden" name="filter" value="' . self::getFilter() . '" />' . "\n";
+  echo '<input type="hidden" name="offset" value="'. self::getOffset() . '" />'. "\n";
+  echo '<input type="hidden" name="astool" value="'. self::getAstool() . '" />'. "\n";
+  echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+  echo '<input type="submit" name="button" value="'. _IM_RETURN . '" />'. "\n";
+  echo '</p>'. "\n";
+  echo '</form>'. "\n";
+  
+  self::media_foot();
+  return;
+ }
+ private function media_directory_remove_confirm($notice = '') {
+  global $manager, $member;
+  
+  $collections = self::getCollections();
+  $subdirs = self::getSubdirs();
+  
+  self::media_head();
+  echo '<h2>' . _IM_HEADER_SUBDIR_REMOVE_CONFIRM  . "</h2>\n";
+  
+  if($notice) {
+   echo '<h3>' . _IM_NOTICE . "</h3>\n";
+   echo '<p class="notice">' .  $notice . "</p>\n";
+  }
+  
+  echo '<h3>' . _IM_REMOVE_SUBIDR . "</h3>\n";
+  echo '<div class="filedetail">'."\n";
+  echo "<dl>\n";
+  echo '<dt>' . _IM_SUBDIR . "</dt>\n";
+  echo '<dd>' . self::getSubdir() . '</dd>' . "\n";
+  echo '<dt>' . _IM_SUBDIR_NUM_FILES . "</dt>\n";
+  
+  foreach($subdirs as $key => $options) {
+   if($options['subdirname'] == self::getSubdir())
+    echo '<dd>' . $options['number'] . "</dd>\n";
+  }
+  
+  echo '<dt>' . _IM_COLLECTION .  "</dt>\n";
+  echo '<dd>' . $collections[self::getCollection()] . '</dd>' . "\n";
+  
+  if(self::getBlogName() && self::getEachblogdir()) {
+   echo '<dt>' . _IM_WEBLOG_LABEL . "</dt>\n";
+   echo '<dd>' . self::getBlogName() . "</dd>\n";
+  }
+   
+  echo "</dl>\n";
+  echo "</div>\n";
+  
+  echo '<h3>' . _IM_REMOVE_SUBIDR_CONFIRM . "</h3>\n";
+  echo '<p>' . _IM_REMOVE_SUBIDR_REMIND . "</p>\n";
+  
+  echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
+  echo '<p class="left">' . "\n";
+  echo '<input type="hidden" name="mode" value="directory_remove" />' . "\n";
+  echo $manager->addTicketHidden() . "\n";
+  echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
+  echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
+  echo '<input type="hidden" name="filename" value="' . self::getFilename() . '" />' . "\n";
+  echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
+  echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
+  echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+  echo '<input type="submit" value="' . _IM_ERASE_DONE . '" />' . "\n";
+  echo '</p>' . "\n";
+  echo '</form>' . "\n";
+  echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
+  echo '<p class="right">' . "\n";
+  echo $manager->addTicketHidden() . "\n";
+  echo '<input type="hidden" name="mode" value="directory_display" />' . "\n";
+  echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
+  echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
+  echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
+  echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
+  echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+  echo '<input type="submit" name="button" value="' . _IM_RETURN . '" />' . "\n";
+  echo '</p>' . "\n";
+  echo '</form>' . "\n";
+  
+  self::media_foot();
+  return;
+ }
+ private function media_directory_remove() {
+  global $manager;
+  
+  if(self::getSubdir() == '') {
+   self::media_doError(_IM_SUBDIR_FAILED_READ . ' (' . self::getCollection() . '/' . self::getSubdir() . ')');
+   return;
+  }
+  
+  $manager->notify('PreSubdirRemove', array('collection' => self::getCollection(), 'subdir' => self::getSubdir()));
+  
+  $log = self::removeSubdir(self::getCollection(), self::getSubdir());
+  
+  if($log) {
+   self::media_doError($log);
+   return;
+  }
+  
+  $manager->notify('PostSubdirRemove',array('collection' => self::getCollection(), 'subdir' => self::getSubdir()));
+  
+  self::resetOffset();
+  self::media_directory_display();
+  return;
+ }
+ private function media_directory_create_confirm($notice = '') {
+  global $manager;
+  
+  $collections = self::getCollections();
+  
+  self::media_head();
+  echo '<h2>' . _IM_HEADER_SUBDIR_CREATE_CONFIRM  . "</h2>\n";
+  
+  if($notice) {
+   echo '<h3>' . _IM_NOTICE . "</h3>\n";
+   echo '<p class="notice">' .  $notice . "</p>\n";
+  }
+  
+  if(self::getBlogName() && self::getEachblogdir()) {
+   echo '<h3>' . _IM_WEBLOG_LABEL . "</h3>\n";
+   echo '<p>' . self::getBlogName() . "</p>\n";
+  }
+  
+  echo "<h3>" . _IM_CREATE_SUBDIR_COLLECTION_LABEL . "</h3>\n";
+  
+  echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
+  echo "<p>\n";
+  echo '<label for="media_collection">' . _IM_CREATE_SUBDIR_COLLECTION . "</label><br />\n";
+  echo '<select name="collection" id="media_collection">' . "\n";
+  foreach ($collections as $dirname => $description){
+   if((string)$dirname == (string)self::getCollection())
+    echo '<option value="' . $dirname . '" selected="selected">' . $description . "</option>\n";
+   else
+    echo '<option value="' . $dirname . '">' . $description . "</option>\n";
+  }
+  echo '</select>' . "\n";
+  echo "</p>\n";
+  
+  echo '<h3>' . _IM_CREATE_SUBDIR_INPUT_NAME . "</h3>\n";
+  echo "<p>" . _IM_CREATE_SUBDIR_CHARS_DESC . "</p>\n";
+  echo '<p>' . "\n";
+  echo $manager->addTicketHidden() . "\n";
+  if(self::getNewfilename() != '')
+   echo '<input type="text" name="newfilename" value="' . self::getNewfilename() . '" size="20" />' . "\n";
+  else
+   echo '<input type="text" name="newfilename" value="" size="20" />' . "\n";
+  echo '</p>' . "\n";
+  echo '<p class="left">' . "\n";
+  echo '<input type="hidden" name="mode" value="directory_create" />' . "\n";
+  echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
+  echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
+  echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+  echo '<input type="submit" value="' . _IM_CREATE_SUBDIR_CONFIRM . '" />' . "\n";
+  echo '</p>' . "\n";
+  echo '</form>' . "\n";
+  
+  echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
+  echo '<p class="right">' . "\n";
+  echo '<input type="hidden" name="mode" value="directory_display" />' . "\n";
+  echo $manager->addTicketHidden() . "\n";
+  echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
+  echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
+  echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
+  echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+  echo '<input type="submit" name="button" value="' . _IM_RETURN . '" />' . "\n";
+  echo '</p>' . "\n";
+  echo '</form>' . "\n";
+  
+  self::media_foot();
+  return;
+ }
+ private function media_directory_create() {
+  global $manager;
+  $newdirname = self::getNewfilename();
+  
+  if($newdirname == '') {
+   self::media_directory_create_confirm(_IM_RENAME_SUBDIR_BLANK);
+    return;
+  } elseif(mb_strlen($newdirname,_CHARSET) > 20) {
+   self::media_directory_create_confirm(_IM_RENAME_SUBDIR_TOOLONG);
+    return;
+  } elseif(!preg_match('#^[a-zA-Z0-9 \_\-\+]+$#', $newdirname)) {
+   self::media_directory_create_confirm(_IM_RENAME_SUBDIR_WRONG);
+    return;
+  } elseif(stristr($newdirname, '%00')) {
+   self::media_doError(_IM_RENAME_FORBIDDEN);
+    return;
+  } elseif(is_dir(self::getDirMedia() . self::getCollection() . '/' . $newdirname)) {
+   self::media_directory_create_confirm(_IM_RENAME_SUBDIR_DUPLICATE);
+    return;
+  } elseif(!@is_dir(self::getDirMedia() . self::getCollection()) && is_numeric(self::getCollection())) {
+   $oldumask = umask(0000);
+   if(!@mkdir(self::getDirMedia() . self::getCollection(), 0777)) {
+    self::media_doError(_ERROR_BADPERMISSIONS);
+    return;
+   }
+   umask($oldumask);
+  }
+  
+  $manager->notify('PreSubdirCreate',array('collection' => self::getCollection(), 'subdir' => $newdirname));
+  
+  $oldumask = umask(0000);
+  if(!@mkdir(self::getDirMedia() . self::getCollection() . '/' . $newdirname))
+   self::media_directory_create_confirm(_IM_CREATE_SUBDIR_WRONG . '(' . $collection . '/' . $newdirname . ')');
+  umask($oldumask);
+  @chmod(self::getDirMedia() . self::getCollection() . '/' . $newdirname, 0777);
+  
+  $manager->notify('PostSubdirCreate',array('collection' => self::getCollection(), 'subdir' => $newdirname));
+  
+  self::resetOffset();
+  self::media_directory_display();
+  return;
+ }
+ private function media_directory_rename_confirm($notice = '') {
+  global $manager, $member;
+  
+  $collections = self::getCollections();
+  $newdirname = self::getNewfilename();
+  $subdirs = self::getSubdirs();
+  
+  self::media_head();
+  echo '<h2>' . _IM_HEADER_SUBDIR_RENAME_CONFIRM  . "</h2>\n";
+  
+  if($notice) {
+   echo '<h3>' . _IM_NOTICE . "</h3>\n";
+   echo '<p class="notice">' .  $notice . "</p>\n";
+  }
+  
+  echo '<h3>' . _IM_RENAME_SUBDIR_COLLECTION . "</h3>\n";
+  echo '<div class="filedetail">'."\n";
+  echo "<dl>\n";
+  echo '<dt>' . _IM_SUBDIR . "</dt>\n";
+  echo '<dd>' . self::getSubdir() . '</dd>' . "\n";
+  echo '<dt>' . _IM_SUBDIR_NUM_FILES . "</dt>\n";
+  
+  foreach($subdirs as $key => $options) {
+   if($options['subdirname'] == self::getSubdir())
+    echo '<dd>' . $options['number'] . "</dd>\n";
+  }
+  
+  echo '<dt>' . _IM_COLLECTION . "</dt>\n";
+  echo '<dd>' . $collections[self::getCollection()] . '</dd>' . "\n";
+  
+  if(self::getBlogName() && self::getEachblogdir()) {
+   echo '<dt>' . _IM_WEBLOG_LABEL . "</dt>\n";
+   echo '<dd>' . self::getBlogName() . "</dd>\n";
+  }
+  
+  echo '</dl>' . "\n";
+  echo '</div>' . "\n";
+  echo '<h3>' ._IM_RENAME_AFTER . '</h3>' . "\n";
+  echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
+  echo '<p>' ._IM_RENAME_DESCRIPTION . '</p>' . "\n";
+  echo '<p>' . "\n";
+  if($newdirname != '')
+   echo '<input type="text" name="newfilename" value="' . $newdirname . '" size="40" />' . "\n";
+  else
+   echo '<input type="text" name="newfilename" value="' . self::getSubdir() . '" size="40" />' . "\n";
+  echo '</p>' . "\n";
+  
+  echo '<p class="left">' . "\n";
+  echo '<input type="hidden" name="mode" value="directory_rename" />' . "\n";
+  echo $manager->addTicketHidden() . "\n";
+  echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
+  echo '<input type="hidden" name="subdir" value="' . self::getSubdir() . '" />' . "\n";
+  echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
+  echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
+  echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+  echo '<input type="submit" value="' . _IM_RENAME . '"  class="formbutton" />' . "\n";
+  echo '</p>' . "\n";
+  echo '</form>' . "\n";
+  
+  echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
+  echo '<p class="right">' . "\n";
+  echo $manager->addTicketHidden() . "\n";
+  echo '<input type="hidden" name="mode" value="directory_display" />' . "\n";
+  echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
+  echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
+  echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
+  echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+  echo '<input type="submit" name="button" value="' . _IM_RETURN . '" />' . "\n";
+  echo '</p>' . "\n";
+  echo '</form>' . "\n";
+  
+  self::media_foot();
+  return;
+ }
+ private function media_directory_rename() {
+  global $manager;
+  
+  $newdirname = self::getNewfilename();
+  
+  if(self::getSubdir() == '') {
+   self::media_doError(_IM_SUBDIR_FAILED_READ);
+  }
+  
+  if($newdirname == '') {
+   self::media_directory_rename_confirm(_IM_RENAME_SUBDIR_BLANK);
+   return;
+  } elseif(mb_strlen($newdirname,_CHARSET) > 20) {
+   self::media_directory_rename_confirm(_IM_RENAME_SUBDIR_TOOLONG);
+   return;
+  } elseif(!preg_match('#^[a-zA-Z0-9 \_\-\+]+$#',$newdirname)) {
+   self::media_directory_rename_confirm(_IM_RENAME_SUBDIR_WRONG);
+   return;
+  } elseif(stristr($newdirname, '%00')) {
+   self::media_doError(_IM_RENAME_FORBIDDEN);
+   return;
+  } elseif(!is_dir(self::getDirMedia() . self::getCollection() . '/' . self::getSubdir())) {
+   self::media_doError(_IM_MISSING_DIRECTORY);
+   return;
+  } elseif(is_dir(self::getDirMedia() . self::getCollection() . '/' . $newdirname)) {
+   self::media_directory_rename_confirm(_IM_RENAME_SUBDIR_DUPLICATE);
+   return;
+  }
+    
+  $manager->notify('PreSubdirRename',array('collection' => self::getCollection(), 'olddirname' => self::getSubdir(), 'newdirname' => $newdirname));
+  
+  if(!@rename(self::getDirMedia() . self::getCollection() . '/' . self::getSubdir(), self::getDirMedia() . self::getCollection() . '/' . $newdirname)) {
+   self::media_doError(_IM_RENAME_FAILED . ': ' . $collection . '/' . self::getSubdir() . '/' . $filename);
+   return;
+  }
+    
+  $manager->notify('PostSubdirRename',array('collection' => self::getCollection(), 'olddirname' => self::getSubdir(), 'newdirname' => $newdirname));
+  
+  self::resetOffset();
+  self::media_directory_display();
+  return;
+ }
+ private function media_directory_display() {
+  global $manager, $member;
+  
+  $collections = self::getCollections();
+  $subdirs = self::getSubdirs();
+  $fileamount = count($subdirs) -1;
+  
+  self::media_head();
+  
+  echo '<form method="post" action="' . self::getAccessURL() . '" enctype="application/x-www-form-urlencoded">' . "\n";
+  echo '<p>' . "\n";
+  
+  echo '<label for="media_collection">' . _IM_COLLECTION_LABEL . '</label>' . "\n";
+  echo '<select name="collection" id="media_collection">' . "\n";
+  foreach ($collections as $dirname => $description){
+   if ((string)$dirname == (string)self::getCollection())
+    echo '<option value="' . $dirname . '" selected="selected">' . $description . "</option>\n";
+   else
+    echo '<option value="' . $dirname . '">' . $description . "</option>\n";
+  }
+  echo '</select>' . "\n";
+  echo '<input type="submit" name="mode" value="' . _IM_DISPLAY_SUBDIR_SELECT . '" class="formbutton" />' . "\n";
+  echo '<input type="submit" name="mode" value="' . _IM_CREATE_SUBDIR_CONFIRM . '" class="formbutton" />' . "\n";
+  echo $manager->addTicketHidden() . "\n";
+  echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
+  echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
+  echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+  echo '</p>' . "\n";
+  echo '</form>' . "\n";
+  
+  echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
+  echo '<p>' . _IM_DISPLAY_SUBDIR_LABEL1 . $fileamount . _IM_DISPLAY_SUBDIR_LABEL2 . $subdirs[0]['number'] .  "\n";
+  echo $manager->addTicketHidden() . "\n";
+  echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
+  echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
+  echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
+  echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+  echo '<input type="submit" name="button" value="' . _IM_DISPLAY_SUBDIR_RETURN . '"  class="formbutton" />' . "\n";
+  echo '</p>' . "\n";
+  echo '</form>' . "\n";
+  
+  echo "<hr />\n";
+  
+  
+  if($fileamount > 0) {
+   $idxStart = ceil(self::getOffset() / self::getItemdisplay()) * self::getItemdisplay();
+   $idxEnd = $idxStart + self::getItemdisplay();
+   if($idxEnd > $fileamount)
+    $idxEnd = $fileamount;
+   $idxPrev = $idxStart - self::getItemdisplay();
+   if($idxPrev < 0)
+    $idxPrev =0;
+   $idxNext = $idxStart + self::getItemdisplay();
+   
+   array_shift($subdirs);
+   
+   echo '<table frame="void" rules="none" summary="Directory List" width="100%">' . "\n";
+   echo '<caption>' . _IM_DISPLAY_SUBDIR_CAPTION . ' &gt;&gt; ' . $collections[self::getCollection()];
+   if(self::getBlogShortName() && self::getEachblogdir())
+    echo ' &gt;&gt; ' . self::getBlogShortName();
+   echo "</caption>\n";
+   echo '<thead>' . "\n";
+   echo '<tr>' . "\n";
+   echo '<th>' . _IM_SUBDIR . "</th>\n";
+   echo '<th>' . _IM_SUBDIR_NUM_FILES . "</th>\n";
+   echo '<th colspan="3">' . _IM_ACTION . "</th>\n";
+   echo '</tr>' . "\n";
+   echo '</thead>' . "\n";
+   echo '<tfoot>' . "\n";
+   echo '<tr>' . "\n";
+   echo '<td colspan="2">' . "\n";
+   if ($idxStart > 0)
+    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> ';
+   if(($idxStart + 1) !=  $idxEnd)
+    echo ($idxStart + 1) . ' to ' . $idxEnd . '&nbsp;';
+   if ($idxEnd < $fileamount )
+    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>';
+   echo "</td>\n";
+   echo '<td colspan="3" class="right">'. "\n";
+   if(self::getBlogName() && self::getEachblogdir())
+    echo _IM_WEBLOG_LABEL . ': ' . self::getBlogName();
+   echo "</td>\n";
+   echo "</tr>\n";
+   echo '</tfoot>' . "\n";
+   echo '<tbody>' . "\n";
+   
+   for($i = $idxStart; $i < $idxEnd; $i++) {
+    $options = $subdirs[$i];
+    echo '<tr>' . "\n";
+    if($options['subdirname'] == ".")
+     echo '<td>' . _IM_SUBDIR_NONE . '</td>' . "\n";
+    else
+     echo '<td>' . $options['subdirname'] . '</td>' . "\n";
+    echo '<td>' . $options['number'] . '</td>' . "\n";
+    echo '<td>' . "\n";
+    echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
+    echo "<p>\n";
+    echo '<input type="hidden" name="mode" value="display" />' . "\n";
+    echo $manager->addTicketHidden() . "\n";
+    echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
+    echo '<input type="hidden" name="subdir" value="' . $options['subdirname'] . '" />' . "\n";
+    echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
+    echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
+    echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+    echo '<input type="submit" name="button" value="' . _IM_DISPLAY_FILES . '" class="formbutton" />' . "\n";
+    echo "</p>\n";
+    echo '</form>' . "\n";
+    echo '</td>' . "\n";
+    
+    if($options['subdirname'] == ".") {
+     echo "<td></td>\n";
+     echo "<td></td>\n";
+     echo "</tr>\n";
+    } else {
+     echo '<td>' . "\n";
+     echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
+     echo "<p>\n";
+     echo '<input type="hidden" name="mode" value="directory_remove_confirm" />' . "\n";
+     echo $manager->addTicketHidden() . "\n";
+     echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
+     echo '<input type="hidden" name="subdir" value="' . $options['subdirname'] . '" />' . "\n";
+     echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
+     echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
+     echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+     echo '<input type="submit" name="button" value="' . _IM_SUBDIR_REMOVE . '" class="formbutton" />' . "\n";
+     echo "</p>\n";
+     echo '</form>' . "\n";
+     echo '</td>' . "\n";
+     echo '<td>' . "\n";
+     echo '<form action="' . self::getAccessURL() . '" method="post">' . "\n";
+     echo "<p>\n";
+     echo '<input type="hidden" name="mode" value="directory_rename_confirm" />' . "\n";
+     echo $manager->addTicketHidden() . "\n";
+     echo '<input type="hidden" name="collection" value="' . self::getCollection() . '" />' . "\n";
+     echo '<input type="hidden" name="subdir" value="' . $options['subdirname'] . '" />' . "\n";
+     echo '<input type="hidden" name="offset" value="' . self::getOffset() . '" />' . "\n";
+     echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
+     echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+     echo '<input type="submit" name="button" value="' . _IM_RENAME . '" class="formbutton" />' . "\n";
+     echo "</p>\n";
+     echo '</form>' . "\n";
+     echo '</td>' . "\n";
+     echo '</tr>' . "\n";
+    }
+   }
+   echo '</tbody>' . "\n";
+   echo '</table>' . "\n";
+  } else {
+   if(self::getBlogShortName() && self::getEachblogdir())
+    echo "<p>" . _IM_DISPLAY_SUBDIR_NOTHING . ' &gt;&gt; ' . $collections[self::getCollection()] . ' &gt;&gt; ' . self::getBlogShortName() . "</p>\n";
+   else
+    echo "<p>" . _IM_DISPLAY_SUBDIR_NOTHING . ' &gt;&gt; ' . $collections[self::getCollection()] . "</p>\n";
+  }
+  
+  self::media_foot();
+  return;
+ }
+ private function media_loginAndPassThrough() {
+  self::media_head();
+  
+  echo '<h2>' . _LOGIN_PLEASE . "</h2>\n";
+  echo '<form method="post" action="' . self::getAccessURL() . '" enctype="application/x-www-form-urlencoded">' . "\n";
+  echo '<p>' . "\n";
+  echo _LOGINFORM_NAME . '<br />' . "\n";
+  echo '<input name="login"  size="20" maxlength="40" value="" /><br />' . "\n";
+  echo _LOGINFORM_PWD . '<br />' . "\n";
+  echo '<input name="password" type="password" size="20" maxlength="40" /><br />' . "\n";
+  echo '<input type="checkbox" value="1" name="shared" id="nucleus_lf_shared" checked="checked" />' . "\n";
+  echo '<label for="nucleus_lf_shared">' . _LOGINFORM_SHARED . "</label>\n";
+  echo "</p>\n";
+  echo "<p>\n";
+  echo '<input name="mode" value="login" type="hidden" />' . "\n";
+  echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
+  echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+  echo '<input type="submit" value="' . _LOGIN . '" />' . "\n";
+  echo "</p>\n";
+  echo "</form>\n";
+  
+  self::media_foot();
+  return;
+ }
+ private function media_doError($message) {
+  global $manager;
+  
+  self::media_head();
+  
+  echo '<h2>' . _ERROR . "</h2>\n";
+  echo '<p>' . $message . "</p>\n";
+  echo '<form action="' . self::getAccessURL() . '" method="post" enctype="application/x-www-form-urlencoded">' . "\n";
+  echo '<p class="right">' . "\n";
+  echo '<input type="hidden" name="mode" value="display" />' . "\n";
+  echo $manager->addTicketHidden() . "\n";
+  echo '<input type="hidden" name="astool" value="' . self::getAstool() . '" />' . "\n";
+  echo '<input type="hidden" name="blogid" value="' . self::getBlogid() . '" />' . "\n";
+  echo '<input type="submit" name="button" value="' . _IM_RETURN . '" />' . "\n";
+  echo '</p>' . "\n";
+  echo '</form>' . "\n";
+  
+  self::media_foot();
+  return;
+ }
+ private function media_head() {
+  sendContentType('application/xhtml+xml', 'media');
+  echo '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . "\n";
+  echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n";
+  echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">' . "\n";
+  echo '<head>' . "\n";
+  echo '<title>Media Control' . _IM_HEADER_TEXT . '</title>' . "\n";
+  echo '<meta http-equiv="content-style-type" content="text/css" />' . "\n";
+  echo '<link rel="stylesheet" type="text/css" href="' . self::getPluginDir() . 'popups.css" />' . "\n";
+  echo '<meta http-equiv="content-script-type" content="text/javascript" />' . "\n";
+  echo '<script type="text/javascript">' . "\n";
+  
+  if(self::getGreybox()) {
+   echo 'function chooseImage(collection, filename, type, width, height, text) {' . "\n";
+   echo ' top.window.focus();' . "\n";
+   echo ' top.window.includeImage(collection, filename, type, width, height, text);' . "\n";
+   echo ' top.window.GB_hide();' . "\n";
+   echo '}' . "\n";
+   echo 'function chooseOther(collection, filename, text) {' . "\n";
+   echo ' top.window.focus();' . "\n";
+   echo ' top.window.includeOtherMedia(collection, filename, text);' . "\n";
+   echo ' top.window.GB_hide();' . "\n";
+   echo '}' . "\n";
+  } else {
+   echo 'function chooseImage(collection, filename, type, width, height, text) {' . "\n";
+   echo ' top.opener.focus();' . "\n";
+   echo ' top.opener.includeImage(collection, filename, type, width, height, text);' . "\n";
+   echo ' window.close();' . "\n";
+   echo '}' . "\n";
+   echo 'function chooseOther(collection, filename, text) {' . "\n";
+   echo ' top.opener.focus();' . "\n";
+   echo ' top.opener.includeOtherMedia(collection, filename, text);' . "\n";
+   echo ' window.close();' . "\n";
+   echo '}' . "\n";
+  }
+  
+  echo '</script>' . "\n";
+  echo '</head>' . "\n";
+  echo '<body>' . "\n";
+  
+  if(!self::getGreybox()) {
+   echo '<h1>Media Control<span class="header">' . _IM_HEADER_TEXT . '</span></h1>' . "\n";
+   echo '<hr />' . "\n";
+  }
+  return;
+ }
+ private function media_foot() {
+  echo "</body>\n";
+  echo "</html>";
+  exit;
+ }
+ private function getSplitFilename(&$collection, &$filename) {
+  if(self::getMediaprefix()) {
+   if(preg_match('#^([0-9]{8})\-(.*)\.([a-zA-Z0-9]{2,})$#', $filename, $filealt) == 1 ) {
+    $update = preg_replace('#^([0-9]{4})([0-9]{2})([0-9]{2})$#', '$1/$2/$3', $filealt[1]);
+    $onlyfilename = $filealt[2];
+    $onlyprefix = $filealt[3];
+   } else {
+    preg_match('#^(.*)\.([a-zA-Z0-9]{2,})$#', $filename, $filealt);  
+    $update = date("Y/m/d", @filemtime( self::getDirMedia() . $collection . '/' . $filename));
+    $onlyfilename = $filealt[1];
+    $onlyprefix = $filealt[2];
+   } 
+  } else {
+   preg_match('#^(.*)\.([a-zA-Z0-9]{2,})$#', $filename, $filealt);
+   $update = date("Y/m/d", @filemtime( self::getDirMedia() . $collection . '/' . $filename));
+   $onlyfilename = $filealt[1];
+   $onlyprefix = $filealt[2];
+  }
+  return array((string)$update, (string)$onlyfilename, (string)$onlyprefix);
+ }
+ private function getFileData(&$collection, &$filename) {
+  $old_level = error_reporting(0);
+  $size = @GetImageSize(self::getDirMedia() . $collection . '/' .$filename);
+  error_reporting($old_level);
+  $width = $size[0];
+  $height = $size[1];
+  $filetype = $size[2];
+  $filesize = number_format(ceil((@filesize(self::getDirMedia() . $collection . '/' . $filename) / 1000)));
+  
+  return array((int)$width, (int)$height, (int)$filetype, (int)$filesize);
+ }
+ private function sort_media_by_filename($a, $b) {
+  if($a->filename == $b->filename) return 0;
+  elseif($a->filename > $b->filename) return -1;
+  else return 1;
+ }
+ private function removeSubdir($collection, $subdir, $log = '') {
+  $dirname = self::getDirMedia() . $collection . '/' . $subdir;
+  
+  if(!is_dir($dirname)) {
+   $log .= _IM_SUBDIR_FAILED_READ . ' (' . $collection . '/' . $subdir . ')<br />';
+   return $log;
+  }
+  
+  if(($dir = @opendir($dirname)) == FALSE) {
+   $log .= _IM_SUBDIR_FAILED_READ . ' (' . $collection . '/' . $subdir . ')<br />';
+   return $log;
+  } else {
+   while(($file = readdir($dir)) !== false) {
+    if($file != "." && $file != "..") {
+     if(filetype($dirname . "/" . $file) == "dir")
+      $log .= self::removeSubdir($collection, $subdir . "/" . $file, $log);
+     else
+      if(@unlink($dirname . "/" . $file) == false)
+       $log .= _IM_SUBDIR_REMOVE_FAILED . ' (' . $collection . '/' . $subdir . '/' . $file . ")<br />";
+    }
+   }
+  }
+  closedir($dir);
+  
+  if($log)
+   return $log;
+  
+  if(@rmdir($dirname) == false) {
+   $log .= _IM_SUBDIR_REMOVE_FAILED  . ' (' . $collection . '/' . $subdir . ')<br />';
+   return $log;
+  }
+ }
+}
+?>
diff --git a/NP_ImprovedMedia/improvedmedia/MEDIA_VARIABLES.php b/NP_ImprovedMedia/improvedmedia/MEDIA_VARIABLES.php
new file mode 100755 (executable)
index 0000000..349aa11
--- /dev/null
@@ -0,0 +1,447 @@
+<?php
+/**
+ * ImprovedMedia plugin for Nucleus CMS
+ * Version 3.0.1 for PHP5
+ * Written By Mocchi, Feb.28, 2010
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ */
+
+class MEDIA_VARIABLES {
+ private $accessurl = 'media.php'; //string
+ // privete
+ private $plugindir = ''; //string
+ private $private = 1; //boolean
+ private $greybox = 0; //boolean
+ private $itemdisplay = 10; //integer
+ private $eachblogdir = 0; //boolean
+ private $allowedtypes = array(); //array
+ private $mediaprefix = 0; //boolean
+ private $maxuploadsize = 0; //integer
+ private $mediaurl = ''; //string
+ private $dirmedia = ''; //string
+ private $blog = FALSE; //object
+ private $blogid = 1; //object
+ private $mode = 'display'; //string
+ private $alttext = ''; //string
+ private $astool = 0; //boolean
+ private $collection = ''; //string
+ private $subdir = ''; //string
+ private $filename= ''; //string
+ private $newfilename = ''; //string
+ private $offset = 0; //integer
+ private $way = 'popup'; //string
+ private $filter = ''; //string
+ private static $modes = array('rename_confirm', 'rename', 'erase_confirm', 'erase',
+  'upload_select', _IM_UPLOAD_NEW, 'upload', 'embed_confirm', 'embed',
+   _IM_COLLECTION_SELECT, _IM_FILTER_APPLY, 'display', 'login',
+   'directory_remove_confirm', 'directory_remove', _IM_CREATE_SUBDIR_CONFIRM, 'directory_create',
+    'directory_rename_confirm', 'directory_rename',
+    _IM_DISPLAY_SUBDIR, _IM_DISPLAY_SUBDIR_SELECT, 'directory_display');
+ // protected
+ protected static $modesNotToCheck
+  = array('display', _IM_FILTER_APPLY, _IM_COLLECTION_SELECT, 'login', 'upload_select',
+   _IM_DISPLAY_SUBDIR, _IM_DISPLAY_SUBDIR_SELECT, 'directory_display');
+    
+ public function __construct(&$PluginObject) {
+  global $CONF;
+  $this->blog =& $PluginObject->getBlog();
+  $this->blogid =& $PluginObject->getBlogid();
+  $this->accessurl = $CONF['ActionURL'] . '?action=plugin&amp;name=ImprovedMedia';
+  $this->plugindir = $CONF['AdminURL'] . $PluginObject->getBaseURL();
+  self::setOptions($PluginObject);
+  
+  self::setAllowedTypes();
+  self::setMediaPrefix();
+  self::setMaxUploadSize();
+  
+  self::setMediaURL();
+  self::setDIR_MEDIA();
+  
+  return;
+ }
+ public function __destruct() {return;}
+ protected function setMode() {
+  $mode = htmlspecialchars(requestVar('mode'), ENT_QUOTES, _CHARSET);
+  if(in_array($mode, self::$modes))
+   $this->mode = (string)$mode;
+  return;
+ }
+ protected function setAlttext() {
+  $alttext = htmlspecialchars(requestVar('alttext'), ENT_QUOTES, _CHARSET);
+  trim($alttext);
+  $this->alttext = (string)$alttext;
+  return;
+ }
+ protected function setAstool() {
+  $astool = intRequestVar('astool');
+  if($astool)
+   $this->astool = (int)1;
+  return;
+ }
+ public function getCollections() {
+  $collections = array();
+  $collections = MEDIA::getCollectionList();
+  
+  if(!$this->private) {
+   if(count($collections) < 2)
+    return (string)'error';
+   else
+    array_shift($collections);
+  }
+  ksort($collections, SORT_STRING);
+  return (array)$collections;
+ }
+ protected function setCollection() {
+  global $member;
+  $collection = htmlspecialchars(requestVar('collection'), ENT_QUOTES, _CHARSET);
+  $collections = $this->getCollections();
+  
+  if($collections == 'error') {
+   $this->collection = (string)'error';
+   return;
+  }
+  
+  if(!$this->private) {
+   if($collection == '') {
+    $keys = array_keys($collections);
+    $this->collection = (string)$collections[$keys[0]];
+    return;
+   }
+   if(!array_key_exists($collection, $collections)) {
+    $this->collection = (string)'error';
+    return;
+   }
+   $this->collection = (string)$collection;
+   return;
+  } else {
+   if($collection == '') {
+    $this->collection = (string)$member->getID();
+       return;
+   }
+   if(!array_key_exists($collection, $collections)) {
+    $this->collection = (string)'error';
+       return;
+   }
+   $this->collection = (string)$collection;
+   return;
+  }
+ }
+ public function getSubdirs() {
+  $subdirs = array();
+  $temp = array();
+  $number = 0;
+  
+  if($this->collection == 'error') {
+   return (string)'error';
+  }
+  
+  if(!is_dir($this->dirmedia . $this->collection)) {
+   $subdirs[] = array('subdirname' => '.', 'number' => 0, 'collection' => $this->collection);
+   return $subdirs;
+  }
+  
+  $dirhandle = @opendir($this->dirmedia . $this->collection);
+  
+  if(!$dirhandle) return (string)'error';
+  
+  while(($subdirname = readdir($dirhandle)) !== FALSE) {
+   if(is_dir($this->dirmedia . $this->collection . '/' . $subdirname) && $subdirname != "..") {
+    $number = 0;
+     if($subdirhandle = @opendir($this->dirmedia . $this->collection . '/' . $subdirname)) {
+     if(!$subdirhandle) {
+      return (string)'error';
+     }
+     while(($file = readdir($subdirhandle)) !== FALSE)
+      if($file != '..' && $file != '.' && !is_dir($this->dirmedia . $this->collection . '/' . $subdirname . '/' . $file))
+       ++$number;
+     closedir($subdirhandle);
+    }
+    $temp[$subdirname] = array('number' => $number, 'collection' => $this->collection);
+   }
+  }
+  closedir($dirhandle);
+  ksort($temp);
+  foreach($temp as $subdirname => $options) {
+   $subdirs[] = array('subdirname' => $subdirname, 'number' => $options['number'], 'collection' => $options['collection']);
+  }
+  return (array)$subdirs;
+ }
+ protected function setSubDir() {
+  $subdir = htmlspecialchars(requestVar('subdir'), ENT_QUOTES, _CHARSET);
+  $subdirs = self::getSubdirs();
+  $list = array();
+  
+  if($subdir == '') {
+   $this->subdir = (string)'';
+  }
+    
+  if($subdirs == 'error') {
+   $this->subdir = (string)'error';
+   return;
+  }
+  
+  if(count($subdirs) < 2) {
+   $this->subdir = (string)'';
+   return;
+  }
+  
+  array_shift($subdirs);
+  
+  foreach($subdirs as $key => $options) {
+   if((string)$options['subdirname'] == (string)$subdir) {
+    $this->subdir = (string)$subdir;
+    break;
+   }
+  }
+ }
+ protected function setFilename() {
+  $filename = htmlspecialchars(requestVar('filename'), ENT_QUOTES, _CHARSET);
+  
+  if($filename == '') {
+   $this->filename = (string)'';
+   return;
+  }
+  
+  if($this->collection === 'error') {
+   $this->filename = (string)'error';
+   return;
+  }
+  
+  if($this->subdir === 'error') {
+   $this->filename = (string)'error';
+   return;
+  }
+    
+  if(!$this->subdir)
+   $fileobjectlist = MEDIA::getMediaListByCollection($this->collection);
+  else
+   $fileobjectlist = MEDIA::getMediaListByCollection($this->collection . '/' . $this->subdir);
+  
+  foreach($fileobjectlist as $fileobject) {
+   if((string)$fileobject->filename == (string)$filename) {
+    $this->filename = $fileobject->filename;
+    break;
+   }
+  }
+  return;
+ }
+ protected function setNewFilename() {
+  $newfilename = htmlspecialchars(requestVar('newfilename'), ENT_QUOTES, _CHARSET);
+  trim($newfilename);
+  $this->newfilename = (string)$newfilename;
+  return;
+ }
+ protected function setOffset() {
+  $offset = intRequestVar('offset');
+  if($offset >= 0)
+   $this->offset = (int)$offset;
+  return;
+ }
+ protected function setWay() {
+  $way = htmlspecialchars(requestVar('way'), ENT_QUOTES, _CHARSET);
+  $ways = array('popup','inline','other');
+  if(in_array($way, $ways))
+   $this->way = (string)$way;
+  return;
+ }
+ protected function setFilter() {
+  $filter = htmlspecialchars(requestVar('filter'), ENT_QUOTES, _CHARSET);
+  if($this->allowedtypes === array()) {
+   $this->filter = (string)'';
+   return;
+  }
+  if(in_array($filter, $this->allowedtypes))
+   $this->filter = (string)$filter;
+  return;
+ }
+ private function setAllowedTypes() {
+  global $CONF;
+  if($CONF['AllowedTypes'] == '')
+   return array();
+  $allowedtypes = explode(',', $CONF['AllowedTypes']);
+  if(is_array($allowedtypes)) {
+   sort($allowedtypes);
+   $this->allowedtypes = (array)$allowedtypes;
+  }
+  return;
+ }
+ private function setMediaPrefix() {
+  global $CONF;
+  $this->mediaprefix = (string)$CONF['MediaPrefix'];
+  return;
+ }
+ private function setMediaURL() {
+  global $CONF;
+  $this->mediaurl = (string)$CONF['MediaURL'];
+  return;
+ }
+ private function setMaxUploadSize() {
+  global $CONF;
+  $this->maxuploadsize = (int)$CONF['MaxUploadSize'];
+  return;
+ }
+ private function setDIR_MEDIA() {
+  global $DIR_MEDIA;
+  $this->dirmedia = (string)$DIR_MEDIA;
+  return;
+ }
+ private function setOptions(&$PluginObject) {
+  if($PluginObject->getOption('IM_PRIVATE') == 'no')
+   $this->private = (int)0;
+  
+  if($PluginObject->getOption('IM_GREYBOX') == 'yes')
+   $this->greybox = (int)1;
+  
+  $this->itemdisplay =& $PluginObject->getOption('IM_ITEMDISPLAY');
+  
+  if($PluginObject->getOption('IM_EACHBLOGDIR') == 'yes')
+   $this->eachblogdir = (int)1;
+  
+  return;
+ }
+ public function getAccessURL() {
+  return $this->accessurl;
+ }
+ public function getPluginDir() {
+  return $this->plugindir;
+ }
+ public function & getBlog() {
+  return $this->blog;
+ }
+ public function & getBlogid() {
+  return $this->blogid; 
+ }
+ public function & getBlogName() {
+  $blog =& $this->blog;
+  if(!$blog)
+   return '';
+  else
+   return $blog->getName();
+ }
+ public function & getBlogShortName() {
+  $blog =& $this->blog;
+  if(!$blog)
+   return '';
+  else
+   return $blog->getShortName();
+ }
+  public function getPrivate() {
+  return $this->private;
+ }
+ public function getGreybox() {
+  return $this->greybox;
+ }
+ public function getEachblogdir() {
+  return $this->eachblogdir;
+ }
+ public function getItemdisplay() {
+  return $this->itemdisplay;
+ }
+ public function getAllowedtypes() {
+  return $this->allowedtypes;
+ }
+ public function getMediaprefix() {
+  return $this->mediaprefix;
+ }
+ public function getMaxuploadsize() {
+  return $this->maxuploadsize;
+ }
+ public function getMediaURL() {
+  return $this->mediaurl;
+ }
+ public function getDirMedia() {
+  return $this->dirmedia;
+ }
+ public function getMode() {
+  return $this->mode;
+ }
+ public function getAlttext() {
+  return $this->alttext;
+ }
+ public function getAstool() {
+  return $this->astool;
+ }
+ public function getCollection() {
+  return $this->collection;
+ }
+ public function getSubdir() {
+  return $this->subdir;
+ }
+ public function & getFilename() {
+  return $this->filename;
+ }
+ public function getNewfilename() {
+  return $this->newfilename;
+ }
+ public function & getOffset() {
+  return $this->offset;
+ }
+ public function getWay() {
+  return $this->way;
+ }
+ public function getFilter() {
+  return $this->filter;
+ }
+ public function resetOffset() {
+  $this->offset = 0;
+ }
+ public function resetFilter() {
+  $this->filter = '';
+ }
+}
+?>
\ No newline at end of file
diff --git a/NP_ImprovedMedia/improvedmedia/greybox/AJS.js b/NP_ImprovedMedia/improvedmedia/greybox/AJS.js
new file mode 100755 (executable)
index 0000000..1793160
--- /dev/null
@@ -0,0 +1,514 @@
+AJS={BASE_URL:"",drag_obj:null,drag_elm:null,_drop_zones:[],_cur_pos:null,getScrollTop:function(){
+var t;
+if(document.documentElement&&document.documentElement.scrollTop){
+t=document.documentElement.scrollTop;
+}else{
+if(document.body){
+t=document.body.scrollTop;
+}
+}
+return t;
+},addClass:function(){
+var _2=AJS.forceArray(arguments);
+var _3=_2.pop();
+var _4=function(o){
+if(!new RegExp("(^|\\s)"+_3+"(\\s|$)").test(o.className)){
+o.className+=(o.className?" ":"")+_3;
+}
+};
+AJS.map(_2,function(_6){
+_4(_6);
+});
+},setStyle:function(){
+var _7=AJS.forceArray(arguments);
+var _8=_7.pop();
+var _9=_7.pop();
+AJS.map(_7,function(_a){
+_a.style[_9]=AJS.getCssDim(_8);
+});
+},extend:function(_b){
+var _c=new this("no_init");
+for(k in _b){
+var _d=_c[k];
+var _e=_b[k];
+if(_d&&_d!=_e&&typeof _e=="function"){
+_e=this._parentize(_e,_d);
+}
+_c[k]=_e;
+}
+return new AJS.Class(_c);
+},log:function(o){
+if(window.console){
+console.log(o);
+}else{
+var div=AJS.$("ajs_logger");
+if(!div){
+div=AJS.DIV({id:"ajs_logger","style":"color: green; position: absolute; left: 0"});
+div.style.top=AJS.getScrollTop()+"px";
+AJS.ACN(AJS.getBody(),div);
+}
+AJS.setHTML(div,""+o);
+}
+},setHeight:function(){
+var _11=AJS.forceArray(arguments);
+_11.splice(_11.length-1,0,"height");
+AJS.setStyle.apply(null,_11);
+},_getRealScope:function(fn,_13){
+_13=AJS.$A(_13);
+var _14=fn._cscope||window;
+return function(){
+var _15=AJS.$FA(arguments).concat(_13);
+return fn.apply(_14,_15);
+};
+},documentInsert:function(elm){
+if(typeof (elm)=="string"){
+elm=AJS.HTML2DOM(elm);
+}
+document.write("<span id=\"dummy_holder\"></span>");
+AJS.swapDOM(AJS.$("dummy_holder"),elm);
+},getWindowSize:function(doc){
+doc=doc||document;
+var _18,_19;
+if(self.innerHeight){
+_18=self.innerWidth;
+_19=self.innerHeight;
+}else{
+if(doc.documentElement&&doc.documentElement.clientHeight){
+_18=doc.documentElement.clientWidth;
+_19=doc.documentElement.clientHeight;
+}else{
+if(doc.body){
+_18=doc.body.clientWidth;
+_19=doc.body.clientHeight;
+}
+}
+}
+return {"w":_18,"h":_19};
+},flattenList:function(_1a){
+var r=[];
+var _1c=function(r,l){
+AJS.map(l,function(o){
+if(o==null){
+}else{
+if(AJS.isArray(o)){
+_1c(r,o);
+}else{
+r.push(o);
+}
+}
+});
+};
+_1c(r,_1a);
+return r;
+},isFunction:function(obj){
+return (typeof obj=="function");
+},setEventKey:function(e){
+e.key=e.keyCode?e.keyCode:e.charCode;
+if(window.event){
+e.ctrl=window.event.ctrlKey;
+e.shift=window.event.shiftKey;
+}else{
+e.ctrl=e.ctrlKey;
+e.shift=e.shiftKey;
+}
+switch(e.key){
+case 63232:
+e.key=38;
+break;
+case 63233:
+e.key=40;
+break;
+case 63235:
+e.key=39;
+break;
+case 63234:
+e.key=37;
+break;
+}
+},removeElement:function(){
+var _22=AJS.forceArray(arguments);
+AJS.map(_22,function(elm){
+AJS.swapDOM(elm,null);
+});
+},_unloadListeners:function(){
+if(AJS.listeners){
+AJS.map(AJS.listeners,function(elm,_25,fn){
+AJS.REV(elm,_25,fn);
+});
+}
+AJS.listeners=[];
+},join:function(_27,_28){
+try{
+return _28.join(_27);
+}
+catch(e){
+var r=_28[0]||"";
+AJS.map(_28,function(elm){
+r+=_27+elm;
+},1);
+return r+"";
+}
+},getIndex:function(elm,_2c,_2d){
+for(var i=0;i<_2c.length;i++){
+if(_2d&&_2d(_2c[i])||elm==_2c[i]){
+return i;
+}
+}
+return -1;
+},isIn:function(elm,_30){
+var i=AJS.getIndex(elm,_30);
+if(i!=-1){
+return true;
+}else{
+return false;
+}
+},isArray:function(obj){
+return obj instanceof Array;
+},setLeft:function(){
+var _33=AJS.forceArray(arguments);
+_33.splice(_33.length-1,0,"left");
+AJS.setStyle.apply(null,_33);
+},appendChildNodes:function(elm){
+if(arguments.length>=2){
+AJS.map(arguments,function(n){
+if(AJS.isString(n)){
+n=AJS.TN(n);
+}
+if(AJS.isDefined(n)){
+elm.appendChild(n);
+}
+},1);
+}
+return elm;
+},getElementsByTagAndClassName:function(_36,_37,_38,_39){
+var _3a=[];
+if(!AJS.isDefined(_38)){
+_38=document;
+}
+if(!AJS.isDefined(_36)){
+_36="*";
+}
+var els=_38.getElementsByTagName(_36);
+var _3c=els.length;
+var _3d=new RegExp("(^|\\s)"+_37+"(\\s|$)");
+for(i=0,j=0;i<_3c;i++){
+if(_3d.test(els[i].className)||_37==null){
+_3a[j]=els[i];
+j++;
+}
+}
+if(_39){
+return _3a[0];
+}else{
+return _3a;
+}
+},isOpera:function(){
+return (navigator.userAgent.toLowerCase().indexOf("opera")!=-1);
+},isString:function(obj){
+return (typeof obj=="string");
+},hideElement:function(elm){
+var _40=AJS.forceArray(arguments);
+AJS.map(_40,function(elm){
+elm.style.display="none";
+});
+},setOpacity:function(elm,p){
+elm.style.opacity=p;
+elm.style.filter="alpha(opacity="+p*100+")";
+},insertBefore:function(elm,_45){
+_45.parentNode.insertBefore(elm,_45);
+return elm;
+},setWidth:function(){
+var _46=AJS.forceArray(arguments);
+_46.splice(_46.length-1,0,"width");
+AJS.setStyle.apply(null,_46);
+},createArray:function(v){
+if(AJS.isArray(v)&&!AJS.isString(v)){
+return v;
+}else{
+if(!v){
+return [];
+}else{
+return [v];
+}
+}
+},isDict:function(o){
+var _49=String(o);
+return _49.indexOf(" Object")!=-1;
+},isMozilla:function(){
+return (navigator.userAgent.toLowerCase().indexOf("gecko")!=-1&&navigator.productSub>=20030210);
+},removeEventListener:function(elm,_4b,fn,_4d){
+var _4e="ajsl_"+_4b+fn;
+if(!_4d){
+_4d=false;
+}
+fn=elm[_4e]||fn;
+if(elm["on"+_4b]==fn){
+elm["on"+_4b]=elm[_4e+"old"];
+}
+if(elm.removeEventListener){
+elm.removeEventListener(_4b,fn,_4d);
+if(AJS.isOpera()){
+elm.removeEventListener(_4b,fn,!_4d);
+}
+}else{
+if(elm.detachEvent){
+elm.detachEvent("on"+_4b,fn);
+}
+}
+},callLater:function(fn,_50){
+var _51=function(){
+fn();
+};
+window.setTimeout(_51,_50);
+},setTop:function(){
+var _52=AJS.forceArray(arguments);
+_52.splice(_52.length-1,0,"top");
+AJS.setStyle.apply(null,_52);
+},_createDomShortcuts:function(){
+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"];
+var _54=function(elm){
+AJS[elm.toUpperCase()]=function(){
+return AJS.createDOM.apply(null,[elm,arguments]);
+};
+};
+AJS.map(_53,_54);
+AJS.TN=function(_56){
+return document.createTextNode(_56);
+};
+},addCallback:function(fn){
+this.callbacks.unshift(fn);
+},bindMethods:function(_58){
+for(var k in _58){
+var _5a=_58[k];
+if(typeof (_5a)=="function"){
+_58[k]=AJS.$b(_5a,_58);
+}
+}
+},partial:function(fn){
+var _5c=AJS.$FA(arguments);
+_5c.shift();
+return function(){
+_5c=_5c.concat(AJS.$FA(arguments));
+return fn.apply(window,_5c);
+};
+},isNumber:function(obj){
+return (typeof obj=="number");
+},getCssDim:function(dim){
+if(AJS.isString(dim)){
+return dim;
+}else{
+return dim+"px";
+}
+},isIe:function(){
+return (navigator.userAgent.toLowerCase().indexOf("msie")!=-1&&navigator.userAgent.toLowerCase().indexOf("opera")==-1);
+},removeClass:function(){
+var _5f=AJS.forceArray(arguments);
+var cls=_5f.pop();
+var _61=function(o){
+o.className=o.className.replace(new RegExp("\\s?"+cls,"g"),"");
+};
+AJS.map(_5f,function(elm){
+_61(elm);
+});
+},setHTML:function(elm,_65){
+elm.innerHTML=_65;
+return elm;
+},map:function(_66,fn,_68,_69){
+var i=0,l=_66.length;
+if(_68){
+i=_68;
+}
+if(_69){
+l=_69;
+}
+for(i;i<l;i++){
+var val=fn(_66[i],i);
+if(val!=undefined){
+return val;
+}
+}
+},addEventListener:function(elm,_6e,fn,_70,_71){
+var _72="ajsl_"+_6e+fn;
+if(!_71){
+_71=false;
+}
+AJS.listeners=AJS.$A(AJS.listeners);
+if(AJS.isIn(_6e,["keypress","keydown","keyup","click"])){
+var _73=fn;
+fn=function(e){
+AJS.setEventKey(e);
+return _73.apply(window,arguments);
+};
+}
+var _75=AJS.isIn(_6e,["submit","load","scroll","resize"]);
+var _76=AJS.$A(elm);
+AJS.map(_76,function(_77){
+if(_70){
+var _78=fn;
+fn=function(e){
+AJS.REV(_77,_6e,fn);
+return _78.apply(window,arguments);
+};
+}
+if(_75){
+var _7a=_77["on"+_6e];
+var _7b=function(){
+if(_7a){
+fn(arguments);
+return _7a(arguments);
+}else{
+return fn(arguments);
+}
+};
+_77[_72]=_7b;
+_77[_72+"old"]=_7a;
+elm["on"+_6e]=_7b;
+}else{
+_77[_72]=fn;
+if(_77.attachEvent){
+_77.attachEvent("on"+_6e,fn);
+}else{
+if(_77.addEventListener){
+_77.addEventListener(_6e,fn,_71);
+}
+}
+AJS.listeners.push([_77,_6e,fn]);
+}
+});
+},preloadImages:function(){
+AJS.AEV(window,"load",AJS.$p(function(_7c){
+AJS.map(_7c,function(src){
+var pic=new Image();
+pic.src=src;
+});
+},arguments));
+},forceArray:function(_7f){
+var r=[];
+AJS.map(_7f,function(elm){
+r.push(elm);
+});
+return r;
+},update:function(l1,l2){
+for(var i in l2){
+l1[i]=l2[i];
+}
+return l1;
+},getBody:function(){
+return AJS.$bytc("body")[0];
+},HTML2DOM:function(_85,_86){
+var d=AJS.DIV();
+d.innerHTML=_85;
+if(_86){
+return d.childNodes[0];
+}else{
+return d;
+}
+},getElement:function(id){
+if(AJS.isString(id)||AJS.isNumber(id)){
+return document.getElementById(id);
+}else{
+return id;
+}
+},showElement:function(){
+var _89=AJS.forceArray(arguments);
+AJS.map(_89,function(elm){
+elm.style.display="";
+});
+},bind:function(fn,_8c,_8d){
+fn._cscope=_8c;
+return AJS._getRealScope(fn,_8d);
+},createDOM:function(_8e,_8f){
+var i=0,_91;
+var elm=document.createElement(_8e);
+var _93=_8f[0];
+if(AJS.isDict(_8f[i])){
+for(k in _93){
+_91=_93[k];
+if(k=="style"||k=="s"){
+elm.style.cssText=_91;
+}else{
+if(k=="c"||k=="class"||k=="className"){
+elm.className=_91;
+}else{
+elm.setAttribute(k,_91);
+}
+}
+}
+i++;
+}
+if(_93==null){
+i=1;
+}
+for(var j=i;j<_8f.length;j++){
+var _91=_8f[j];
+if(_91){
+var _95=typeof (_91);
+if(_95=="string"||_95=="number"){
+_91=AJS.TN(_91);
+}
+elm.appendChild(_91);
+}
+}
+return elm;
+},swapDOM:function(_96,src){
+_96=AJS.getElement(_96);
+var _98=_96.parentNode;
+if(src){
+src=AJS.getElement(src);
+_98.replaceChild(src,_96);
+}else{
+_98.removeChild(_96);
+}
+return src;
+},isDefined:function(o){
+return (o!="undefined"&&o!=null);
+}};
+AJS.$=AJS.getElement;
+AJS.$$=AJS.getElements;
+AJS.$f=AJS.getFormElement;
+AJS.$p=AJS.partial;
+AJS.$b=AJS.bind;
+AJS.$A=AJS.createArray;
+AJS.DI=AJS.documentInsert;
+AJS.ACN=AJS.appendChildNodes;
+AJS.RCN=AJS.replaceChildNodes;
+AJS.AEV=AJS.addEventListener;
+AJS.REV=AJS.removeEventListener;
+AJS.$bytc=AJS.getElementsByTagAndClassName;
+AJS.$AP=AJS.absolutePosition;
+AJS.$FA=AJS.forceArray;
+AJS.addEventListener(window,"unload",AJS._unloadListeners);
+AJS._createDomShortcuts();
+AJS.Class=function(_9a){
+var fn=function(){
+if(arguments[0]!="no_init"){
+return this.init.apply(this,arguments);
+}
+};
+fn.prototype=_9a;
+AJS.update(fn,AJS.Class.prototype);
+return fn;
+};
+AJS.Class.prototype={extend:function(_9c){
+var _9d=new this("no_init");
+for(k in _9c){
+var _9e=_9d[k];
+var cur=_9c[k];
+if(_9e&&_9e!=cur&&typeof cur=="function"){
+cur=this._parentize(cur,_9e);
+}
+_9d[k]=cur;
+}
+return new AJS.Class(_9d);
+},implement:function(_a0){
+AJS.update(this.prototype,_a0);
+},_parentize:function(cur,_a2){
+return function(){
+this.parent=_a2;
+return cur.apply(this,arguments);
+};
+}};
+script_loaded=true;
+
+
+script_loaded=true;
\ No newline at end of file
diff --git a/NP_ImprovedMedia/improvedmedia/greybox/AJS_fx.js b/NP_ImprovedMedia/improvedmedia/greybox/AJS_fx.js
new file mode 100755 (executable)
index 0000000..8f64452
--- /dev/null
@@ -0,0 +1,138 @@
+AJS.fx={_shades:{0:"ffffff",1:"ffffee",2:"ffffdd",3:"ffffcc",4:"ffffbb",5:"ffffaa",6:"ffff99"},highlight:function(_1,_2){
+var _3=new AJS.fx.Base();
+_3.elm=AJS.$(_1);
+_3.options.duration=600;
+_3.setOptions(_2);
+AJS.update(_3,{increase:function(){
+if(this.now==7){
+_1.style.backgroundColor="#fff";
+}else{
+_1.style.backgroundColor="#"+AJS.fx._shades[Math.floor(this.now)];
+}
+}});
+return _3.custom(6,0);
+},fadeIn:function(_4,_5){
+_5=_5||{};
+if(!_5.from){
+_5.from=0;
+AJS.setOpacity(_4,0);
+}
+if(!_5.to){
+_5.to=1;
+}
+var s=new AJS.fx.Style(_4,"opacity",_5);
+return s.custom(_5.from,_5.to);
+},fadeOut:function(_7,_8){
+_8=_8||{};
+if(!_8.from){
+_8.from=1;
+}
+if(!_8.to){
+_8.to=0;
+}
+_8.duration=300;
+var s=new AJS.fx.Style(_7,"opacity",_8);
+return s.custom(_8.from,_8.to);
+},setWidth:function(_a,_b){
+var s=new AJS.fx.Style(_a,"width",_b);
+return s.custom(_b.from,_b.to);
+},setHeight:function(_d,_e){
+var s=new AJS.fx.Style(_d,"height",_e);
+return s.custom(_e.from,_e.to);
+}};
+AJS.fx.Base=new AJS.Class({init:function(_10){
+this.options={onStart:function(){
+},onComplete:function(){
+},transition:AJS.fx.Transitions.sineInOut,duration:500,wait:true,fps:50};
+AJS.update(this.options,_10);
+AJS.bindMethods(this);
+},setOptions:function(_11){
+AJS.update(this.options,_11);
+},step:function(){
+var _12=new Date().getTime();
+if(_12<this.time+this.options.duration){
+this.cTime=_12-this.time;
+this.setNow();
+}else{
+setTimeout(AJS.$b(this.options.onComplete,this,[this.elm]),10);
+this.clearTimer();
+this.now=this.to;
+}
+this.increase();
+},setNow:function(){
+this.now=this.compute(this.from,this.to);
+},compute:function(_13,to){
+var _15=to-_13;
+return this.options.transition(this.cTime,_13,_15,this.options.duration);
+},clearTimer:function(){
+clearInterval(this.timer);
+this.timer=null;
+return this;
+},_start:function(_16,to){
+if(!this.options.wait){
+this.clearTimer();
+}
+if(this.timer){
+return;
+}
+setTimeout(AJS.$p(this.options.onStart,this.elm),10);
+this.from=_16;
+this.to=to;
+this.time=new Date().getTime();
+this.timer=setInterval(this.step,Math.round(1000/this.options.fps));
+return this;
+},custom:function(_18,to){
+return this._start(_18,to);
+},set:function(to){
+this.now=to;
+this.increase();
+return this;
+},setStyle:function(elm,_1c,val){
+if(this.property=="opacity"){
+AJS.setOpacity(elm,val);
+}else{
+AJS.setStyle(elm,_1c,val);
+}
+}});
+AJS.fx.Style=AJS.fx.Base.extend({init:function(elm,_1f,_20){
+this.parent();
+this.elm=elm;
+this.setOptions(_20);
+this.property=_1f;
+},increase:function(){
+this.setStyle(this.elm,this.property,this.now);
+}});
+AJS.fx.Styles=AJS.fx.Base.extend({init:function(elm,_22){
+this.parent();
+this.elm=AJS.$(elm);
+this.setOptions(_22);
+this.now={};
+},setNow:function(){
+for(p in this.from){
+this.now[p]=this.compute(this.from[p],this.to[p]);
+}
+},custom:function(obj){
+if(this.timer&&this.options.wait){
+return;
+}
+var _24={};
+var to={};
+for(p in obj){
+_24[p]=obj[p][0];
+to[p]=obj[p][1];
+}
+return this._start(_24,to);
+},increase:function(){
+for(var p in this.now){
+this.setStyle(this.elm,p,this.now[p]);
+}
+}});
+AJS.fx.Transitions={linear:function(t,b,c,d){
+return c*t/d+b;
+},sineInOut:function(t,b,c,d){
+return -c/2*(Math.cos(Math.PI*t/d)-1)+b;
+}};
+script_loaded=true;
+
+
+script_loaded=true;
\ No newline at end of file
diff --git a/NP_ImprovedMedia/improvedmedia/greybox/LGPL.txt b/NP_ImprovedMedia/improvedmedia/greybox/LGPL.txt
new file mode 100755 (executable)
index 0000000..8add30a
--- /dev/null
@@ -0,0 +1,504 @@
+                 GNU LESSER GENERAL PUBLIC LICENSE
+                      Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+     51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+\f
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+\f
+                 GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+\f
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+\f
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+\f
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+\f
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+\f
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+\f
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+                           NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+\f
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/NP_ImprovedMedia/improvedmedia/greybox/g_close.gif b/NP_ImprovedMedia/improvedmedia/greybox/g_close.gif
new file mode 100755 (executable)
index 0000000..8707668
Binary files /dev/null and b/NP_ImprovedMedia/improvedmedia/greybox/g_close.gif differ
diff --git a/NP_ImprovedMedia/improvedmedia/greybox/gb_scripts.js b/NP_ImprovedMedia/improvedmedia/greybox/gb_scripts.js
new file mode 100755 (executable)
index 0000000..f1b261d
--- /dev/null
@@ -0,0 +1,445 @@
+var GB_CURRENT=null;
+GB_hide=function(cb){
+GB_CURRENT.hide(cb);
+};
+GreyBox=new AJS.Class({init:function(_2){
+this.use_fx=AJS.fx;
+this.type="page";
+this.overlay_click_close=false;
+this.salt=0;
+this.root_dir=GB_ROOT_DIR;
+this.callback_fns=[];
+this.reload_on_close=false;
+this.src_loader=this.root_dir+"loader_frame.html";
+var _3=window.location.hostname.indexOf("www");
+var _4=this.src_loader.indexOf("www");
+if(_3!=-1&&_4==-1){
+this.src_loader=this.src_loader.replace("://","://www.");
+}
+if(_3==-1&&_4!=-1){
+this.src_loader=this.src_loader.replace("://www.","://");
+}
+this.show_loading=true;
+AJS.update(this,_2);
+},addCallback:function(fn){
+if(fn){
+this.callback_fns.push(fn);
+}
+},show:function(_6){
+GB_CURRENT=this;
+this.url=_6;
+var _7=[AJS.$bytc("object"),AJS.$bytc("select")];
+AJS.map(AJS.flattenList(_7),function(_8){
+_8.style.visibility="hidden";
+});
+this.createElements();
+return false;
+},hide:function(cb){
+var me=this;
+AJS.callLater(function(){
+var _b=me.callback_fns;
+if(_b!=[]){
+AJS.map(_b,function(fn){
+fn();
+});
+}
+me.onHide();
+if(me.use_fx){
+var _d=me.overlay;
+AJS.fx.fadeOut(me.overlay,{onComplete:function(){
+AJS.removeElement(_d);
+_d=null;
+},duration:300});
+AJS.removeElement(me.g_window);
+}else{
+AJS.removeElement(me.g_window,me.overlay);
+}
+me.removeFrame();
+AJS.REV(window,"scroll",_GB_setOverlayDimension);
+AJS.REV(window,"resize",_GB_update);
+var _e=[AJS.$bytc("object"),AJS.$bytc("select")];
+AJS.map(AJS.flattenList(_e),function(_f){
+_f.style.visibility="visible";
+});
+GB_CURRENT=null;
+if(me.reload_on_close){
+window.location.reload();
+}
+if(AJS.isFunction(cb)){
+cb();
+}
+},10);
+},update:function(){
+this.setOverlayDimension();
+this.setFrameSize();
+this.setWindowPosition();
+},createElements:function(){
+this.initOverlay();
+this.g_window=AJS.DIV({"id":"GB_window"});
+AJS.hideElement(this.g_window);
+AJS.getBody().insertBefore(this.g_window,this.overlay.nextSibling);
+this.initFrame();
+this.initHook();
+this.update();
+var me=this;
+if(this.use_fx){
+AJS.fx.fadeIn(this.overlay,{duration:300,to:0.7,onComplete:function(){
+me.onShow();
+AJS.showElement(me.g_window);
+me.startLoading();
+}});
+}else{
+AJS.setOpacity(this.overlay,0.7);
+AJS.showElement(this.g_window);
+this.onShow();
+this.startLoading();
+}
+AJS.AEV(window,"scroll",_GB_setOverlayDimension);
+AJS.AEV(window,"resize",_GB_update);
+},removeFrame:function(){
+try{
+AJS.removeElement(this.iframe);
+}
+catch(e){
+}
+this.iframe=null;
+},startLoading:function(){
+this.iframe.src=this.src_loader+"?s="+this.salt++;
+AJS.showElement(this.iframe);
+},setOverlayDimension:function(){
+var _11=AJS.getWindowSize();
+if(AJS.isMozilla()||AJS.isOpera()){
+AJS.setWidth(this.overlay,"100%");
+}else{
+AJS.setWidth(this.overlay,_11.w);
+}
+var _12=Math.max(AJS.getScrollTop()+_11.h,AJS.getScrollTop()+this.height);
+if(_12<AJS.getScrollTop()){
+AJS.setHeight(this.overlay,_12);
+}else{
+AJS.setHeight(this.overlay,AJS.getScrollTop()+_11.h);
+}
+},initOverlay:function(){
+this.overlay=AJS.DIV({"id":"GB_overlay"});
+if(this.overlay_click_close){
+AJS.AEV(this.overlay,"click",GB_hide);
+}
+AJS.setOpacity(this.overlay,0);
+AJS.getBody().insertBefore(this.overlay,AJS.getBody().firstChild);
+},initFrame:function(){
+if(!this.iframe){
+var d={"name":"GB_frame","class":"GB_frame","frameBorder":0};
+if(AJS.isIe()){
+d.src="javascript:false;document.write(\"\");";
+}
+this.iframe=AJS.IFRAME(d);
+this.middle_cnt=AJS.DIV({"class":"content"},this.iframe);
+this.top_cnt=AJS.DIV();
+this.bottom_cnt=AJS.DIV();
+AJS.ACN(this.g_window,this.top_cnt,this.middle_cnt,this.bottom_cnt);
+}
+},onHide:function(){
+},onShow:function(){
+},setFrameSize:function(){
+},setWindowPosition:function(){
+},initHook:function(){
+}});
+_GB_update=function(){
+if(GB_CURRENT){
+GB_CURRENT.update();
+}
+};
+_GB_setOverlayDimension=function(){
+if(GB_CURRENT){
+GB_CURRENT.setOverlayDimension();
+}
+};
+AJS.preloadImages(GB_ROOT_DIR+"indicator.gif");
+script_loaded=true;
+var GB_SETS={};
+function decoGreyboxLinks(){
+var as=AJS.$bytc("a");
+AJS.map(as,function(a){
+if(a.getAttribute("href")&&a.getAttribute("rel")){
+var rel=a.getAttribute("rel");
+if(rel.indexOf("gb_")==0){
+var _17=rel.match(/\w+/)[0];
+var _18=rel.match(/\[(.*)\]/)[1];
+var _19=0;
+var _1a={"caption":a.title||"","url":a.href};
+if(_17=="gb_pageset"||_17=="gb_imageset"){
+if(!GB_SETS[_18]){
+GB_SETS[_18]=[];
+}
+GB_SETS[_18].push(_1a);
+_19=GB_SETS[_18].length;
+}
+if(_17=="gb_pageset"){
+a.onclick=function(){
+GB_showFullScreenSet(GB_SETS[_18],_19);
+return false;
+};
+}
+if(_17=="gb_imageset"){
+a.onclick=function(){
+GB_showImageSet(GB_SETS[_18],_19);
+return false;
+};
+}
+if(_17=="gb_image"){
+a.onclick=function(){
+GB_showImage(_1a.caption,_1a.url);
+return false;
+};
+}
+if(_17=="gb_page"){
+a.onclick=function(){
+var sp=_18.split(/, ?/);
+GB_show(_1a.caption,_1a.url,parseInt(sp[1]),parseInt(sp[0]));
+return false;
+};
+}
+if(_17=="gb_page_fs"){
+a.onclick=function(){
+GB_showFullScreen(_1a.caption,_1a.url);
+return false;
+};
+}
+if(_17=="gb_page_center"){
+a.onclick=function(){
+var sp=_18.split(/, ?/);
+GB_showCenter(_1a.caption,_1a.url,parseInt(sp[1]),parseInt(sp[0]));
+return false;
+};
+}
+}
+}
+});
+}
+AJS.AEV(window,"load",decoGreyboxLinks);
+GB_showImage=function(_1d,url,_1f){
+var _20={width:300,height:300,type:"image",fullscreen:false,center_win:true,caption:_1d,callback_fn:_1f};
+var win=new GB_Gallery(_20);
+return win.show(url);
+};
+GB_showPage=function(_22,url,_24){
+var _25={type:"page",caption:_22,callback_fn:_24,fullscreen:true,center_win:false};
+var win=new GB_Gallery(_25);
+return win.show(url);
+};
+GB_Gallery=GreyBox.extend({init:function(_27){
+this.parent({});
+this.img_close=this.root_dir+"g_close.gif";
+AJS.update(this,_27);
+this.addCallback(this.callback_fn);
+},initHook:function(){
+AJS.addClass(this.g_window,"GB_Gallery");
+var _28=AJS.DIV({"class":"inner"});
+this.header=AJS.DIV({"class":"GB_header"},_28);
+AJS.setOpacity(this.header,0);
+AJS.getBody().insertBefore(this.header,this.overlay.nextSibling);
+var _29=AJS.TD({"id":"GB_caption","class":"caption","width":"40%"},this.caption);
+var _2a=AJS.TD({"id":"GB_middle","class":"middle","width":"20%"});
+var _2b=AJS.IMG({"src":this.img_close});
+AJS.AEV(_2b,"click",GB_hide);
+var _2c=AJS.TD({"class":"close","width":"40%"},_2b);
+var _2d=AJS.TBODY(AJS.TR(_29,_2a,_2c));
+var _2e=AJS.TABLE({"cellspacing":"0","cellpadding":0,"border":0},_2d);
+AJS.ACN(_28,_2e);
+if(this.fullscreen){
+AJS.AEV(window,"scroll",AJS.$b(this.setWindowPosition,this));
+}else{
+AJS.AEV(window,"scroll",AJS.$b(this._setHeaderPos,this));
+}
+},setFrameSize:function(){
+var _2f=this.overlay.offsetWidth;
+var _30=AJS.getWindowSize();
+if(this.fullscreen){
+this.width=_2f-40;
+this.height=_30.h-80;
+}
+AJS.setWidth(this.iframe,this.width);
+AJS.setHeight(this.iframe,this.height);
+AJS.setWidth(this.header,_2f);
+},_setHeaderPos:function(){
+AJS.setTop(this.header,AJS.getScrollTop()+10);
+},setWindowPosition:function(){
+var _31=this.overlay.offsetWidth;
+var _32=AJS.getWindowSize();
+AJS.setLeft(this.g_window,((_31-50-this.width)/2));
+var _33=AJS.getScrollTop()+55;
+if(!this.center_win){
+AJS.setTop(this.g_window,_33);
+}else{
+var fl=((_32.h-this.height)/2)+20+AJS.getScrollTop();
+if(fl<0){
+fl=0;
+}
+if(_33>fl){
+fl=_33;
+}
+AJS.setTop(this.g_window,fl);
+}
+this._setHeaderPos();
+},onHide:function(){
+AJS.removeElement(this.header);
+AJS.removeClass(this.g_window,"GB_Gallery");
+},onShow:function(){
+if(this.use_fx){
+AJS.fx.fadeIn(this.header,{to:1});
+}else{
+AJS.setOpacity(this.header,1);
+}
+}});
+AJS.preloadImages(GB_ROOT_DIR+"g_close.gif");
+GB_showFullScreenSet=function(set,_36,_37){
+var _38={type:"page",fullscreen:true,center_win:false};
+var _39=new GB_Sets(_38,set);
+_39.addCallback(_37);
+_39.showSet(_36-1);
+return false;
+};
+GB_showImageSet=function(set,_3b,_3c){
+var _3d={type:"image",fullscreen:false,center_win:true,width:300,height:300};
+var _3e=new GB_Sets(_3d,set);
+_3e.addCallback(_3c);
+_3e.showSet(_3b-1);
+return false;
+};
+GB_Sets=GB_Gallery.extend({init:function(_3f,set){
+this.parent(_3f);
+if(!this.img_next){
+this.img_next=this.root_dir+"next.gif";
+}
+if(!this.img_prev){
+this.img_prev=this.root_dir+"prev.gif";
+}
+this.current_set=set;
+},showSet:function(_41){
+this.current_index=_41;
+var _42=this.current_set[this.current_index];
+this.show(_42.url);
+this._setCaption(_42.caption);
+this.btn_prev=AJS.IMG({"class":"left",src:this.img_prev});
+this.btn_next=AJS.IMG({"class":"right",src:this.img_next});
+AJS.AEV(this.btn_prev,"click",AJS.$b(this.switchPrev,this));
+AJS.AEV(this.btn_next,"click",AJS.$b(this.switchNext,this));
+GB_STATUS=AJS.SPAN({"class":"GB_navStatus"});
+AJS.ACN(AJS.$("GB_middle"),this.btn_prev,GB_STATUS,this.btn_next);
+this.updateStatus();
+},updateStatus:function(){
+AJS.setHTML(GB_STATUS,(this.current_index+1)+" / "+this.current_set.length);
+if(this.current_index==0){
+AJS.addClass(this.btn_prev,"disabled");
+}else{
+AJS.removeClass(this.btn_prev,"disabled");
+}
+if(this.current_index==this.current_set.length-1){
+AJS.addClass(this.btn_next,"disabled");
+}else{
+AJS.removeClass(this.btn_next,"disabled");
+}
+},_setCaption:function(_43){
+AJS.setHTML(AJS.$("GB_caption"),_43);
+},updateFrame:function(){
+var _44=this.current_set[this.current_index];
+this._setCaption(_44.caption);
+this.url=_44.url;
+this.startLoading();
+},switchPrev:function(){
+if(this.current_index!=0){
+this.current_index--;
+this.updateFrame();
+this.updateStatus();
+}
+},switchNext:function(){
+if(this.current_index!=this.current_set.length-1){
+this.current_index++;
+this.updateFrame();
+this.updateStatus();
+}
+}});
+AJS.AEV(window,"load",function(){
+AJS.preloadImages(GB_ROOT_DIR+"next.gif",GB_ROOT_DIR+"prev.gif");
+});
+GB_show=function(_45,url,_47,_48,_49){
+var _4a={caption:_45,height:_47||500,width:_48||500,fullscreen:false,callback_fn:_49};
+var win=new GB_Window(_4a);
+return win.show(url);
+};
+GB_showCenter=function(_4c,url,_4e,_4f,_50){
+var _51={caption:_4c,center_win:true,height:_4e||500,width:_4f||500,fullscreen:false,callback_fn:_50};
+var win=new GB_Window(_51);
+return win.show(url);
+};
+GB_showFullScreen=function(_53,url,_55){
+var _56={caption:_53,fullscreen:true,callback_fn:_55};
+var win=new GB_Window(_56);
+return win.show(url);
+};
+GB_Window=GreyBox.extend({init:function(_58){
+this.parent({});
+this.img_header=this.root_dir+"header_bg.gif";
+this.img_close=this.root_dir+"w_close.gif";
+this.show_close_img=true;
+AJS.update(this,_58);
+this.addCallback(this.callback_fn);
+},initHook:function(){
+AJS.addClass(this.g_window,"GB_Window");
+this.header=AJS.TABLE({"class":"header"});
+this.header.style.backgroundImage="url("+this.img_header+")";
+var _59=AJS.TD({"class":"caption"},this.caption);
+var _5a=AJS.TD({"class":"close"});
+if(this.show_close_img){
+var _5b=AJS.IMG({"src":this.img_close});
+var _5c=AJS.SPAN("Close");
+var btn=AJS.DIV(_5b,_5c);
+AJS.AEV([_5b,_5c],"mouseover",function(){
+AJS.addClass(_5c,"on");
+});
+AJS.AEV([_5b,_5c],"mouseout",function(){
+AJS.removeClass(_5c,"on");
+});
+AJS.AEV([_5b,_5c],"mousedown",function(){
+AJS.addClass(_5c,"click");
+});
+AJS.AEV([_5b,_5c],"mouseup",function(){
+AJS.removeClass(_5c,"click");
+});
+AJS.AEV([_5b,_5c],"click",GB_hide);
+AJS.ACN(_5a,btn);
+}
+tbody_header=AJS.TBODY();
+AJS.ACN(tbody_header,AJS.TR(_59,_5a));
+AJS.ACN(this.header,tbody_header);
+AJS.ACN(this.top_cnt,this.header);
+if(this.fullscreen){
+AJS.AEV(window,"scroll",AJS.$b(this.setWindowPosition,this));
+}
+},setFrameSize:function(){
+if(this.fullscreen){
+var _5e=AJS.getWindowSize();
+overlay_h=_5e.h;
+this.width=Math.round(this.overlay.offsetWidth-(this.overlay.offsetWidth/100)*10);
+this.height=Math.round(overlay_h-(overlay_h/100)*10);
+}
+AJS.setWidth(this.header,this.width+6);
+AJS.setWidth(this.iframe,this.width);
+AJS.setHeight(this.iframe,this.height);
+},setWindowPosition:function(){
+var _5f=AJS.getWindowSize();
+AJS.setLeft(this.g_window,((_5f.w-this.width)/2)-13);
+if(!this.center_win){
+AJS.setTop(this.g_window,AJS.getScrollTop());
+}else{
+var fl=((_5f.h-this.height)/2)-20+AJS.getScrollTop();
+if(fl<0){
+fl=0;
+}
+AJS.setTop(this.g_window,fl);
+}
+}});
+AJS.preloadImages(GB_ROOT_DIR+"w_close.gif",GB_ROOT_DIR+"header_bg.gif");
+
+
+script_loaded=true;
\ No newline at end of file
diff --git a/NP_ImprovedMedia/improvedmedia/greybox/gb_styles.css b/NP_ImprovedMedia/improvedmedia/greybox/gb_styles.css
new file mode 100755 (executable)
index 0000000..52fdc17
--- /dev/null
@@ -0,0 +1,148 @@
+/* Last-Modified: 28/06/06 00:08:22 */
+#GB_overlay {
+    background-color: #000;
+    position: absolute;
+    margin: auto;
+    top: 0;
+    left: 0;
+    z-index: 100;
+}
+
+#GB_window {
+    left: 0;
+    top: 0;
+    font-size: 1px;
+    position: absolute;
+    overflow: visible;
+    z-index: 150;
+}
+
+#GB_window .content {
+    width: auto;
+    margin: 0;
+    padding: 0;
+}
+
+#GB_frame {
+    border: 0;
+    margin: 0;
+    padding: 0;
+    overflow: auto;
+    white-space: nowrap;
+}
+
+
+.GB_Gallery {
+    margin: 0 22px 0 22px;
+}
+
+.GB_Gallery .content {
+    background-color: #fff;
+    border: 3px solid #ddd;
+}
+
+.GB_header {
+    top: 10px;
+    left: 0;
+    margin: 0;
+    z-index: 500;
+    position: absolute;
+    border-bottom: 2px solid #555;
+    border-top: 2px solid #555;
+}
+
+.GB_header .inner {
+    background-color: #333;
+    font-family: Arial, Verdana, sans-serif;
+    padding: 2px 20px 2px 20px;
+}
+
+.GB_header table {
+    margin: 0;
+    width: 100%;
+    border-collapse: collapse;
+}
+
+.GB_header .caption {
+    text-align: left;
+    color: #eee;
+    white-space: nowrap;
+    font-size: 20px;
+}
+
+.GB_header .close {
+    text-align: right;
+}
+
+.GB_header .close img {
+    z-index: 500;
+    cursor: pointer;
+}
+
+.GB_header .middle {
+    white-space: nowrap;
+    text-align: center;
+}
+
+
+#GB_middle {
+    color: #eee;
+}
+
+#GB_middle img {
+    cursor: pointer;
+    vertical-align: middle;
+}
+
+#GB_middle .disabled {
+    cursor: default;
+}
+
+#GB_middle .left {
+    padding-right: 10px;
+}
+
+#GB_middle .right {
+    padding-left: 10px;
+}
+
+
+.GB_Window .content {
+    background-color: #fff;
+    border: 3px solid #ccc;
+    border-top: none;
+}
+
+.GB_Window .header {
+    border-bottom: 1px solid #aaa;
+    border-top: 1px solid #999;
+    border-left: 3px solid #ccc;
+    border-right: 3px solid #ccc;
+    margin: 0;
+
+    height: 22px;
+    font-size: 12px;
+    padding: 3px 0;
+    color: #333;
+}
+
+.GB_Window .caption {
+    font-size: 12px;
+    text-align: left;
+    font-weight: bold;
+    white-space: nowrap;
+    padding-right: 20px;
+}
+
+.GB_Window .close { text-align: right; }
+.GB_Window .close span { 
+    font-size: 12px;
+    cursor: pointer; 
+}
+.GB_Window .close img {
+    cursor: pointer;
+    padding: 0 3px 0 0;
+}
+
+.GB_Window .on { border-bottom: 1px solid #333; }
+.GB_Window .click { border-bottom: 1px solid red; }
diff --git a/NP_ImprovedMedia/improvedmedia/greybox/header_bg.gif b/NP_ImprovedMedia/improvedmedia/greybox/header_bg.gif
new file mode 100755 (executable)
index 0000000..3913cfd
Binary files /dev/null and b/NP_ImprovedMedia/improvedmedia/greybox/header_bg.gif differ
diff --git a/NP_ImprovedMedia/improvedmedia/greybox/index.html b/NP_ImprovedMedia/improvedmedia/greybox/index.html
new file mode 100755 (executable)
index 0000000..3974d80
--- /dev/null
@@ -0,0 +1,11 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+       <title>Nothing Here</title>
+</head>
+<body>
+
+<h1>Nothing to see here</h1>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/NP_ImprovedMedia/improvedmedia/greybox/indicator.gif b/NP_ImprovedMedia/improvedmedia/greybox/indicator.gif
new file mode 100755 (executable)
index 0000000..02bdbdd
Binary files /dev/null and b/NP_ImprovedMedia/improvedmedia/greybox/indicator.gif differ
diff --git a/NP_ImprovedMedia/improvedmedia/greybox/loader_frame.html b/NP_ImprovedMedia/improvedmedia/greybox/loader_frame.html
new file mode 100755 (executable)
index 0000000..30dcb26
--- /dev/null
@@ -0,0 +1,104 @@
+<!--
+Notice: I feel so dirty doing this, but its the only way to make it cross browser.
+-->
+<html>
+<head>
+  <script>
+    var GB = parent.GB_CURRENT;
+    document.write('<script type="text/javascript" src="AJS.js"><\/script>');
+    if(GB.use_fx) {
+        document.write('<script type="text/javascript" src="AJS_fx.js"><\/script>');
+    }
+  </script>
+  <style>
+    body {
+      padding: 0;
+      margin: 0;
+      overflow: hidden;
+    }
+
+    #GB_frame {
+      visibility: hidden;
+      width: 100%;
+      height: 100%;
+    }
+
+    #loading {
+      padding-top: 50px;
+      position: absolute;
+      width: 100%;
+      top: 0;
+      text-align: center;
+      vertical-align: middle;
+    }
+  </style>
+</head>
+<body>
+
+<div id="loading">
+  <img src="indicator.gif">
+</div>
+
+<script>
+var loading = AJS.$('loading');
+var gb_type = GB.type;
+var gb_url = GB.url;
+
+//Start loading in the iframe
+if(gb_type == "page") {
+  document.write('<iframe id="GB_frame" src="' + gb_url + '" frameborder="0"></iframe>');
+}
+else {
+  var img_holder = new Image();
+  img_holder.src = gb_url;
+  document.write('<img id="GB_frame" src="' + gb_url + '">');
+}
+var frame = AJS.$('GB_frame');
+</script>
+
+</body>
+<script>
+function setupOuterGB() {
+    frame.style.visibility = 'visible';
+    GB.setFrameSize();
+    GB.setWindowPosition();
+}
+
+function loaded() {
+    AJS.removeElement(loading);
+
+    GB.overlay.innerHTML += "&nbsp;"; //Safari bugfix
+    
+    if(gb_type == "image") {
+        if(img_holder.width != 0 && img_holder.height != 0) {
+            var width = img_holder.width;
+            var height = img_holder.height;
+
+            GB.width = width;
+            GB.height = height;
+
+            setupOuterGB();
+
+            if(GB.use_fx) {
+                AJS.setOpacity(frame, 0);
+                AJS.fx.fadeIn(frame);
+            }
+        }
+    }
+    else {
+        GB.width = frame.offsetWidth;
+        GB.height = frame.offsetHeight;
+        setupOuterGB();
+    }
+}
+
+if(GB.show_loading) {
+    AJS.AEV(window, 'load', function(e) {
+        loaded();
+    });
+}
+else {
+    loaded();
+}
+</script>
+</html>
diff --git a/NP_ImprovedMedia/improvedmedia/greybox/next.gif b/NP_ImprovedMedia/improvedmedia/greybox/next.gif
new file mode 100755 (executable)
index 0000000..c0f8908
Binary files /dev/null and b/NP_ImprovedMedia/improvedmedia/greybox/next.gif differ
diff --git a/NP_ImprovedMedia/improvedmedia/greybox/prev.gif b/NP_ImprovedMedia/improvedmedia/greybox/prev.gif
new file mode 100755 (executable)
index 0000000..d20e095
Binary files /dev/null and b/NP_ImprovedMedia/improvedmedia/greybox/prev.gif differ
diff --git a/NP_ImprovedMedia/improvedmedia/greybox/w_close.gif b/NP_ImprovedMedia/improvedmedia/greybox/w_close.gif
new file mode 100755 (executable)
index 0000000..3c05b15
Binary files /dev/null and b/NP_ImprovedMedia/improvedmedia/greybox/w_close.gif differ
diff --git a/NP_ImprovedMedia/improvedmedia/help.html b/NP_ImprovedMedia/improvedmedia/help.html
new file mode 100755 (executable)
index 0000000..be96704
--- /dev/null
@@ -0,0 +1,465 @@
+<!--
+/**
+ * ImprovedMedia plugin for Nucleus CMS
+ * Version 3.0.1
+ * Written By Mocchi, Feb.28, 2010
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ */
+-->
+<h3>目次</h3>
+<ul>
+<li><a href="#chapter1">プラグインの概要</a></li>
+<li><a href="#chapter2">サポートとバグ報告</a></li>
+<li><a href="#chapter3">インストール</a></li>
+<li><a href="#chapter4">アンインストール</a></li>
+<li><a href="#chapter5">他のプラグインとの競合</a></li>
+<li><a href="#chapter6">使用上の注意</a></li>
+<li><a href="#chapter7">スキン変数の実装</a></li>
+<li><a href="#chapter8">オプションの解説</a></li>
+<li><a href="#chapter9">グローバル設定の日付の付加による動作の違い</a></li>
+<li><a href="#chapter10">それぞれのウェブログがある個別ディレクトリでのファイル管理について</a></li>
+<li><a href="#chapter11">イベントの発生</a></li>
+<li><a href="#chapter12">バージョン履歴</a></li>
+<li><a href="#chapter13">動作の仕組み</a></li>
+</ul>
+
+<h3 id="chapter1">プラグインの概要</h3>
+<p>このプラグインは、Nucleusのmedia.phpという、ファイルの記事への挿入やアップロードを行うプログラムを改良し、プラグインとして利用しやすくしたものです。
+<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>
+<p>機能は以下です</p>
+<ol>
+<li>アップロード、記事への挿入、ファイル名の変更そして削除、サブディレクトリの作成・削除・名前変更を行う事ができます。</li>
+<li>media.phpのNucleus Mediaウィンドウから、インターフェースを改良してあります。</li>
+<li>ファイルの挿入時は、代替テキストの入力を必須としました。これはアクセシビリティの観点に拠ります。</li>
+<li>プライベート・コレクション・ディレクトリ機能をオン・オフして、共有ディレクトリのみによる運用ができます。</li>
+<li>オプションで指定することにより、<a href="http://japan.nucleuscms.org/wiki/plugins:eachblogdir" title="Nucleus CMS WIKI - NP_EachBlogDir">NP_EachBlogDir</a>で提供していた機能を利用することができます。</li>
+</ol>
+
+<h3 id="chapter2">サポートとバグ報告</h3>
+<p><a href="http://japan.nucleuscms.org/bb/viewtopic.php?p=17374" title="NP_ImprovedMedia &lt; プラグイン全般 &lt; Nucleus(JP)フォーラム Forum Index">サポートフォーラム</a>において行います。
+このヘルプの最新は、<a href="http://japan.nucleuscms.org/wiki/plugins:improvedmedia" title="NP_ImprovedMedia">NP_ImprovedMedia - Nucleus CMS WIKI</a>で参照することができます。</p>
+
+<h3 id="chapter3">インストール</h3>
+<ol>
+<li>圧縮フォルダを展開し、内容物をPLUGINフォルダにコピー。</li>
+<li>Nucleusにログインし、「管理ホーム」から、「プラグイン管理」の画面に移動。</li>
+<li>画面下部の「新しいプラグインをインストール」で、「ImprovedMedia」を選択し、「プラグインのインストール」ボタンをクリック。</li>
+<li>「プラグインの管理」画面の「インストール済み」のリストに表示されているのを確認します。</li>
+<li>リスト右の「編集」で、オプションを変更することができます。</li>
+<li>通常どおり、アイテムの編集画面で外部ファイルを呼び出すボタンをクリックすると、ファイルのアップロード画面が開きます。ファイルのアップロードが成功すると、記事への埋め込みを行う画面となります。</li>
+</ol>
+
+<h3 id="chapter4">アンインストール</h3>
+<p>オプションデータを持ちますが、そのままプラグイン管理で削除すれば、きれいになくなります。</p>
+
+<h3 id="chapter5">他のプラグインとの競合</h3>
+<p>NP_ImageManager、NP_EachBlogDir、NP_Mediatocuと同時に使う事はできません。その他のプラグインは、おそらく大丈夫だと思います。</p>
+
+<h3 id="chapter6">使用上の注意</h3>
+<ul>
+<li>ユーザがログアウト状態である時は、ログイン画面を表示します。再度ログインすることで、機能を利用できます。</li>
+<li>Media Controlウィンドウは呼び出されたウェブログ情報を保持しているので、もしもユーザがウェブログ・チームに所属しておらず、最高管理権限も持っていない場合は、エラー画面を表示します。</li>
+<li>代替テキストは40文字に制限されています。英数字でも記号でも日本語でも構いません。</li>
+<li>ファイル名変更時に、拡張子を変更する事はできません。</li>
+<li>変更後のファイル名は30文字に制限されています。使用できる文字種は、英数字と3種類の記号(ハイフンマイナス、アンダースコア、プラス)です。</li>
+<li>ファイルを削除するときは、ほんとうに削除していいのか、少し考える時間を設けるとよいでしょう。</li>
+<li>サブ・ディレクトリの名前は20文字に制限されています。使用できる文字種は、英数字と3種類の記号(ハイフンマイナス、アンダースコア、プラス)です。</li>
+<li>サブ・ディレクトリを削除すると、その中に保存されているファイルも削除されます。ほんとうに削除していいのか、少し考える時間を設けるとよいでしょう。</li>
+<li>プライベート・コレクション・ディレクトリ、共有コレクション・ディレクトリをとわず、コレクション・ディレクトリは削除できません。</li>
+</ul>
+
+<h3 id="chapter7">スキン変数の実装</h3>
+<p>スキンに変数を記述することで、スキンから機能を呼び出すことができます。以下の2つの記述を、スキンに追加してください。
+なお、テンプレートからの呼び出しはサポートしていません。</p>
+
+<h4>&lt;head&gt;&lt;/head&gt;要素内</h4>
+<pre>
+&lt;%if(hasplugin,ImprovedMedia)%&gt;
+&lt;%ImprovedMedia(head)%&gt;
+&lt;%endif%&gt;</pre>
+
+<h4>&lt;body&gt;&lt;/body&gt;要素内</h4>
+<pre>&lt;%if(hasplugin,ImprovedMedia)%&gt;
+&lt;%ImprovedMedia(anchor)%&gt;
+&lt;%endif%&gt;</pre>
+
+<p>すると、&lt;%ImprovedMedia(anchor)%&gt;を追加したところにアンカー「ファイル管理」が出現します。
+このアンカーをクリックすることで、機能の呼び出しをすることができます。
+なお、こうして呼び出されたMedia Controlは、ファイルの一覧画面をデフォルトで表示します。またボタン「文書に挿入」を持たず、ファイルのアップロード・削除・ファイル名の変更とサブディレクトリ管理のみ利用できます。</p>
+
+<h3 id="chapter8">オプションの解説</h3>
+<p>以下の4つのオプションを持ちます。</p>
+<h4>プライベート・コレクションのオン・オフ。</h4>
+<p>デフォルトでは、Nucleusインストール時と同様に、プライベート・コレクション・ディレクトリ機能がオンとなっています。
+オフにすることで、メンバー間の共有ディレクトリの使用を徹底することができます。<br />
+なお、メディア・ディレクトリに子ディレクトリ(このプラグインでは、コレクション・ディレクトリと呼んでいます)が作成されていない状態でこの機能をオフにすると、エラーとなります。
+その場合は、FTPソフトかサーバ提供環境でディレクトリを作成してください。</p>
+
+<h4>Media Controlページに表示するファイル数</h4>
+<p>表示ファイル数を5件から50件の間で指定できます。</p>
+
+<h4>GreyBoxユーティリティの利用</h4>
+<p>GreyBoxの提供する効果によってMedia Controlを開くオプションを追加しています。
+このオプションを利用しない方は、このプラグインの構成ファイルのうち、ディレクトリ「greybox」を削除するとよいでしょう。</p>
+
+<h4>それぞれのウェブログがある個別ディレクトリでのファイル管理</h4>
+<p><a href="http://japan.nucleuscms.org/wiki/plugins:eachblogdir" title="Nucleus CMS WIKI - NP_EachBlogDir">NP_EachBlogDir</a>で提供していた、それぞれのウェブログがある個別ディレクトリでのファイル管理機能を利用することができます。
+このオプションは、アップロードしてブログで利用するファイルが、そのブログに属している状態を作り出します。詳しくはこのヘルプの<a href="#chapter9" title="それぞれのウェブログがある個別ディレクトリでのファイル管理について">それぞれのウェブログがある個別ディレクトリでのファイル管理について</a>を参照してください。</p>
+
+<h3 id="chapter9">グローバル設定の日付の付加による動作の違い</h3>
+<p>Nucleusのグローバル設定にある「アップロードするファイル名の頭に日付を付加する」オプションにより
+一覧画面での日付とファイル名の表示およびファイル名変更時の動作が異なります。</p>
+<p>「はい」のとき</p>
+<ul>
+<li>一覧画面での日付の表示は、「登録日」となり、ファイルの先頭に追加されている日付が入ります。</li>
+<li>一覧画面でのファイル名の表示は、先頭の日付を取り去ったものとなります。</li>
+<li>ファイル名変更時に、ファイル名の先頭に日付(数字8桁)+ハイフンがついていないファイルは、そのファイルの最終更新日を先頭に追加します。</li>
+<li>一覧画面でのファイルの並びは、先頭に付加されている日付を含めたファイル名の降順です。</li>
+</ul>
+<p>「いいえ」のとき</p>
+<ul>
+<li>一覧画面での日付の表示は、「更新日」となります。</li>
+<li>一覧画面でのファイル名の表示は、ファイル名そのままとなります。</li>
+<li>ファイル名変更時に、ファイル名の先頭に日付を付加する事はありません。</li>
+<li>一覧画面でのファイルの並びは、ファイルの最終更新日の降順です。</li>
+</ul>
+
+<h3 id="chapter10">それぞれのウェブログがある個別ディレクトリでのファイル管理について</h3>
+
+<p>複数ウェブログを以下のようなディレクトリ構成で運用する事で、アップロードしたファイルがウェブログに属し、ウェブログ管理チームに所属しているユーザのみ、そのファイルを利用することができるようにします。</p>
+
+<pre>
+Nucleus CMS
+Nucleus Admin : /(Document Root)/nucleus/
+
+Blog1(ShortName1, Default)
+Weblog Path: /(Document Root)/index.php
+Media  DIR : /(Document Root)/media/
+
+Blog2(ShortName2)
+Weblog Path: /(Document Root)/(shortname2)/index.php
+Media  DIR : /(Document Root)/(shortname2)/media/
+
+Blog3(ShortName3)
+Weblog Path: /(Document Root)/(shortname3)/index.php
+Media  DIR : /(Document Root)/(shortname3)/media/
+
+Blog4(ShortName4)
+...
+</pre>
+
+<p>なお、メディア・ディレクトリの名前は任意ですが、どのウェブログのディレクトリでも共通の名前にしてください。PHPスクリプト・ファイルの名前は、index.phpでなくとも構いません。</p>
+
+<p>具体的に言うと、管理領域(Nucleusディレクトリ)と同じ階層に、各ウェブログの短縮名のディレクトリを作成し、その中にPHPファイルとメディアディレクトリを配置。
+このようにしたときに、プラグイン内の改造を加えたmedia.phpが、それぞれのウェブログにおかれたメディアディレクトリを参照します。
+また、ウェブログが表示されたときに、アイテムに埋め込まれたファイルへのパスが通るようにします。</p>
+
+<p>新規のウェブログの設置方法</p>
+<ol>
+<li>新規に作成するウェブログの短縮名を決めます。</li>
+<li>Nucleusがインストールされているディレクトリと同じ階層に、その短縮名のディレクトリを作成。</li>
+<li>短縮名のディレクトリの中に、メディアディレクトリを作成します。ディレクトリの名前は、あなたがconfig.phpに記述したメディアディレクトリと同一の名前にしてください。</li>
+<li>Nucleusにログインし、「新規Blog作成」をクリック。</li>
+<li>各種項目を入力しますが、「Blogの短縮名」は、先ほど決めたものにします。</li>
+<li>ボタン「Blogを作成」をクリック。</li>
+<li>次の画面に表示される「方法1」のスクリプトをコピーし、テキストエディタを開いて貼り付け。</li>
+<li>テキストファイルの書き換えを行います。include('../config.php')</li>
+<li>テキストファイルはphpファイルとして、先ほど作成したディレクトリに保存。</li>
+<li>「URL」を変更します。「(Document Root)/短縮名のディレクトリ/テキストファイルのファイル名」</li>
+<li>「作成!」をクリック。新規ウェブログを作成します。</li>
+<li>これまでの設定に不備があっても、「管理ホーム」のウェブログそれぞれの「設定」から修正することができます。</li>
+<li>通常通り、「アイテムの追加」「アイテムの編集/削除」、スキンから誘導される「アイテムの編集」で使うことができます。</li>
+</ol>
+
+<p>アンインストールの際、プラグインはそっくりなくなるのですが、このプラグインを利用して作成したアイテムにおいて、MEDIAファイルへのアンカー切れが発生します。
+その時は、それぞれのMEDIAディレクトリの内容をコレクション・ディレクトリごとコピーし、config.phpに書いた$DIR_MEDIAへ移動してください。アンカーが回復します。</p>
+
+<p>メディアディレクトリの名前は、すべて統一されたものにしてください。
+たとえば、あなたがconfig.phpに記述したメディアディレクトリの名前が「media」なら、
+それぞれのウェブログのフォルダにあるメディアディレクトリも、同じように「media」ディレクトリとしてください。</p>
+
+<h3 id="chapter11">イベントの発生</h3>
+<p>すでにアップロードされているメディア・ファイルの名前を変更する前後、削除する前後にイベントを発生します。それぞれ、「PreMediaRename」、「PostMediaRename」、「PreMediaErase」、「PostMediaErase」です。
+また、コレクション・ディレクトリにサブ・ディレクトリを作成する前後、サブ・ディレクトリの名前を変更する前後、サブ・ディレクトリを削除する前後にもイベントを発生します。
+それぞれ、「PreSubdirCreate」、「PostSubdirCreate」、「PreSubdirRename」、「PostSubdirRename」、「PreSubdirRemove」、「PostSubdirRemove」です。
+Nucleus CMSのバージョン3.3以降では、メディア・ファイルをアップロードする前後のイベント「PreMediaUpload」と「PostMediaUpload」を、コアが提供しています。</p>
+<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>
+
+
+<table frame="box" rules="all" summary="プラグインNP_ImprovedMediaが発生するイベント">
+<thead>
+<tr>
+<th>名前</th>
+<th>いつ</th>
+<th>パラメータ</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td>PreMediaUpload</td>
+<td>(Nucleus CMSのバージョン3.3以降)選択したメディア・ファイルがアップロードされる前</td>
+<td><dl>
+<dt class="ro">collection</dt>
+<dd>(参照渡し)アップロードするメディア・ファイルが保存されるコレクション・ディレクトリ</dd>
+<dt class="ref">uploadfile</dt>
+<dd>(値渡し)アップロードするメディア・ファイルがサーバ上で一時的に保存されているファイルの名前</dd>
+<dt class="ro">filename</dt>
+<dd>(参照渡し)アップロードした後のファイル名</dd>
+</dl></td>
+</tr>
+<tr>
+<td>PostMediaUpload</td>
+<td>(Nucleus CMSのバージョン3.3以降)選択したメディア・ファイルがアップロードされた後</td>
+<td><dl>
+<dt class="ref">collection</dt>
+<dd>(値渡し)選択したメディア・ファイルが保存されたコレクション・ディレクトリ</dd>
+<dt class="ref">mediadir</dt>
+<dd>(値渡し)アップロードしたメディア・ファイルが保存されたコレクション・ディレクトリのサーバにおけるパス</dd>
+<dt class="ref">filename</dt>
+<dd>(値渡し)アップロードした後のファイル名</dd>
+</dl></td>
+</tr>
+<tr>
+<td>PreRenameMedia</td>
+<td>選択したメディア・ファイルのファイル名が変更される前</td>
+<td><dl>
+<dt class="ref">collection</dt>
+<dd>(値渡し)選択したメディア・ファイルが保存されているコレクション・ディレクトリ</dd>
+<dt class="ref">oldfilename</dt>
+<dd>(値渡し)選択したメディア・ファイルの以前のファイル名</dd>
+<dt class="ref">newfilename</dt>
+<dd>(値渡し)選択したメディア・ファイルの現在のファイル名</dd>
+</dl></td>
+</tr>
+<tr>
+<td>PostRenameMedia</td>
+<td>選択したメディア・ファイルのファイル名が変更された後</td>
+<td><dl>
+<dt class="ref">collection</dt>
+<dd>(値渡し)選択したメディア・ファイルが保存されているコレクション・ディレクトリ</dd>
+<dt class="ref">oldfilename</dt>
+<dd>(値渡し)選択したメディア・ファイルの以前のファイル名</dd>
+<dt class="ref">newfilename</dt>
+<dd>(値渡し)選択したメディア・ファイルの現在のファイル名</dd>
+</dl></td>
+</tr>
+<tr>
+<td>PreDeleteMedia</td>
+<td>選択したメディア・ファイルが削除される前</td>
+<td><dl>
+<dt class="ref">collection</dt>
+<dd>(値渡し)削除したメディア・ファイルが保存されていたコレクション・ディレクトリ</dd>
+<dt class="ref">filename</dt>
+<dd>(値渡し)削除したメディア・ファイルのファイル名</dd>
+</dl></td>
+</tr>
+<tr>
+<td>PostDeleteMedia</td>
+<td>選択したメディア・ファイルが削除された後</td>
+<td><dl>
+<dt class="ref">collection</dt>
+<dd>(値渡し)削除したメディア・ファイルが保存されていたコレクション・ディレクトリ</dd>
+<dt class="ref">filename</dt>
+<dd>(値渡し)削除したメディア・ファイルのファイル名</dd>
+</dl></td>
+</tr>
+<tr>
+<td>PreSubdirCreate</td>
+<td>コレクション・ディレクトリにサブ・ディレクトリが作成される前</td>
+<td><dl>
+<dt class="ref">collection</dt>
+<dd>(値渡し)コレクション・ディレクトリの名前</dd>
+<dt class="ref">subdir</dt>
+<dd>(値渡し)サブ・ディレクトリの名前</dd>
+</dl></td>
+</tr>
+<tr>
+<td>PostSubdirCreate</td>
+<td>コレクション・ディレクトリにサブ・ディレクトリが作成された後</td>
+<td><dl>
+<dt class="ref">collection</dt>
+<dd>(値渡し)コレクション・ディレクトリの名前</dd>
+<dt class="ref">subdir</dt>
+<dd>(値渡し)サブ・ディレクトリの名前</dd>
+</dl></td>
+</tr>
+<tr>
+<td>PreSubdirRename</td>
+<td>コレクション・ディレクトリのサブ・ディレクトリの名前が変更される前</td>
+<td><dl>
+<dt class="ref">collection</dt>
+<dd>(値渡し)コレクション・ディレクトリの名前</dd>
+<dt class="ref">olddirname</dt>
+<dd>(値渡し)変更前のサブ・ディレクトリの名前</dd>
+<dt class="ref">newdirname</dt>
+<dd>(値渡し)変更後のサブ・ディレクトリの名前</dd>
+</dl></td>
+</tr>
+<tr>
+<td>PostSubdirRename</td>
+<td>コレクション・ディレクトリのサブ・ディレクトリの名前が変更された後</td>
+<td><dl>
+<dt class="ref">collection</dt>
+<dd>(値渡し)コレクション・ディレクトリの名前</dd>
+<dt class="ref">olddirname</dt>
+<dd>(値渡し)変更前のサブ・ディレクトリの名前</dd>
+<dt class="ref">newsubdirname</dt>
+<dd>(値渡し)変更後のサブ・ディレクトリの名前</dd>
+</dl></td>
+</tr>
+<tr>
+<td>PreSubdirRemove</td>
+<td>コレクション・ディレクトリのサブ・ディレクトリが削除される前</td>
+<td><dl>
+<dt class="ref">collection</dt>
+<dd>(値渡し)コレクション・ディレクトリの名前</dd>
+<dt class="ref">subdir</dt>
+<dd>(値渡し)サブ・ディレクトリの名前</dd>
+</dl></td>
+</tr>
+<tr>
+<td>PostSubdirRemove</td>
+<td>コレクション・ディレクトリのサブ・ディレクトリが削除された後</td>
+<td><dl>
+<dt class="ref">collection</dt>
+<dd>(値渡し)コレクション・ディレクトリの名前</dd>
+<dt class="ref">subdir</dt>
+<dd>(値渡し)サブ・ディレクトリの名前</dd>
+</dl></td>
+</tr>
+</tbody>
+</table>
+
+<h3 id="chapter12">バージョン履歴</h3>
+<dl>
+<dt>2010.02.28 Ver.3.0.1</dt>
+<dd><ul>
+<li>アイテムの編集画面から呼び出して画像ファイルをアップロードした際、<%media%>でしか埋め込まれない不具合を修正。</li>
+<li>同梱しているGreyBoxを最新のバージョン(var.5.54)にした。</li>
+</ul></dd>
+<dt>2009.02.09 Ver.3.0.0</dt>
+<dd><ul>
+<li>サブ・ディレクトリ管理機能を追加。以降、Ver.2.x.xとVer.3.x.x(サブ・ディレクトリ管理機能つき)の2系統とします。</li>
+</ul></dd>
+<dt>2009.02.09 Ver.2.2.0</dt>
+<dd><ul>
+<li>クラスとその要素(プロパティ)、関数(メソッド)を設定。PHP5を意識してPHP4にも対応するよう再設計した。</li>
+<li>NP_EachBlogDirをNP_ImprovedMediaに統合した。</li>
+<li>グローバル設定「アップロードするファイル名の頭に日付を付加する」に応じて、ファイルの並び順を変更するようにした。</li>
+<li>アイテム編集画面からの呼び出しと、スキンからの呼び出して、アイテムへの埋め込みまでのルーチンが変わるように変更した。</li>
+<li>ヘルプファイルを更新</li>
+</ul></dd>
+<dt>2009.01.20 Ver.2.1.1</dt>
+<dd><ul>
+<li>Super Admin権限を持つユーザのみ利用できるようにしていたが、ウェブログの編集権限をひとつでも持つユーザにまで利用範囲を広げた。</li>
+<li>インターフェースの改善</li>
+</ul></dd>
+<dt>2009.01.11 Ver.2.1.0</dt>
+<dd><ul>
+<li>URL内の任意の文字列を渡すことによってディレクトリ操作が可能になる脆弱性を防ぐため、ファイル名とディレクトリに関する処理を修正。</li>
+<li>インターフェースを改善。</li>
+<li>グローバル設定のAllowUploadにを反映するように修正。</li>
+<li>プラグインの利用をウェブログ・グループに所属しているユーザに限定。</li>
+<li>Ver 2.0でマージしたファイル・アップロードに関するコードを削除。アップロードに関しても、コアの機能を最大限に利用します。</li>
+<li>ヘルプファイルを更新。</li>
+</ul></dd>
+<dt>2009.01.06 Ver.2.0.2公開中止</dt>
+<dd><ul>
+<li>2008.12.17の<a href="http://japan.nucleuscms.org/bb/viewtopic.php?p=24067#24067" title="メディアマネージャにおける脆弱性について">メディアマネージャにおける脆弱性について</a>で報告された脆弱性を考慮し、公開を中止。修正に着手。</li>
+</ul></dd>
+<dt>2008.02.08 Ver.2.0.2</dt>
+<dd><ul>
+<li>アイテムへの埋め込み確認の際、埋め込まれるコードを表示をし、コードの再編集への注意を促すように修正。</li>
+<li>メディア・ファイルを文書に挿入するへのボタンをクリックした際の動作に関して、バグの修正。</li>
+</ul>
+</dd>
+<dt>2008.01.31 Ver.2.0.1</dt>
+<dd><ul>
+<li>GreyBox機能がオフの際のコード埋め込み不具合を修正。</li>
+<li>ヘルプファイルを更新</li>
+</ul>
+</dd>
+<dt>2008.01.15 Ver.2.0</dt>
+<dd><ul>
+<li>コードの見直しに伴い、バージョンをあげた。</li>
+<li>ファイル・アップロード、ファイル名変更、ファイル削除の各プラグイン・イベントを設定。</li>
+<li>プラグイン・イベントに関するNucleus CMSのバージョン間での違いを吸収するために、ファイル・アップロードに関するコードをマージ。</li>
+<li>Internet Explorerでファイルを開く際に、ポップアップしないJavaScriptのバグを修正。</li>
+<li>ヘルプの更新。</li>
+<li>プラグイン関連のディレクトリ構造の変更。</li>
+</ul></dd>
+<dt>2007.11.20 Ver.1.3</dt>
+<dd><ul>
+<li>スキン変数を実装。スキンからの呼び出しを可能とした。</li>
+<li>スキンから呼び出された際は、ボタン「文書へ挿入」を非表示にした。</li>
+<li>GreyBoxを含むパッケージにした。</li>
+</ul></dd>
+<dt>2007.11.06 Ver.1.2(Bundling GreyBox)</dt>
+<dd><ul>
+<li>GreyBoxユーティリティによるウィンドウオープンを実装。</li>
+</ul></dd>
+<dt>2007.11.01 Ver.1.2</dt>
+<dd><ul>
+<li>ヘッダ追加情報の上書き状態を修正。</li>
+<li>オプションの追加。</li>
+<li>パースエラーの修正。</li>
+<li>Nucleus3.3のコードを合体。</li>
+<li>ヘルプの更新。</li>
+<li>プラグイン関連のディレクトリ構造の変更。</li>
+</ul></dd>
+<dt>2007.06.21 Ver.1.1</dt>
+<dd><ul>
+<li>プライベート・コレクションのオン・オフを追加。</li>
+<li>パースエラーの修正。</li>
+<li>ヘルプの更新。</li>
+</ul></dd>
+<dt>2007.02.17 Ver.1.0.2 (RC3)</dt>
+<dd><ul>
+<li>リリースキャンディデート3</li>
+</ul></dd>
+<dt>2006.12.31 Ver.1.0.1 (RC2)</dt>
+<dd><ul>
+<li>リリースキャンディデート2</li>
+</ul></dd>
+<dt>2006.12.29 Ver.1.0 (RC1)</dt>
+<dd><ul>
+<li>リリースキャンディデート</li>
+</ul></dd>
+<dt>2006.12.22 Beta</dt>
+<dd><ul>
+<li>ベータバージョン</li>
+</ul></dd>
+<dt>2006.12.20 Alpha</dt>
+<dd><ul>
+<li>アルファバージョン</li>
+</ul></dd>
+</dl>
+
+<h3 id="chapter13">動作の仕組み</h3>
+
+<p>備忘録として残しておきます。</p>
+
+<h4>アイテムの追加/編集の時</h4>
+
+<ol>
+<li>変数「action」によりイベント「AdminPrePageHead」、「BookmarkletExtraHead」が発生した際、XHTML要素「head」にJavaScript関数を挿入。 action.php経由でプラグインの出力するMedia Controlをポップアップ表示するJavaScript関数「AddMedia()」を埋め込む。</li>
+<li>また同時に、JavaScript関数「includeImage()」と「includeOtherMedia()」もヘッダに追加。</li>
+<li>追加したJavaScript関数はXHTMLファイルに直接埋め込まれているため、コアのJavaScript関数「AddMedia()」よりも呼び出し優先される。</li>
+<li>JavaScript関数「AddMedia()」はMedia Controlにユーザを誘導し、JavaScript関数「includeImage()」と「includeOtherMedia()」は代替テキスト入力を代行する。</li>
+<li>追加したJavaScript関数「AddMedia()」は、blogidもしくはitemidをget変数としてMedia Controlに渡す。</li>
+<li>blogid(ない場合はitemid)を用いてグローバル変数の$DIR_MEDIAと$CONF[’MediaURL’]を置き換える。</li>
+<li>Media Controlが自分を呼び出す際は、必ずblogidをget変数として渡す。</li>
+<li>あとはコアの機能を利用して、ポップアップや埋め込みのコードが生成される。</li>
+</ol>
+
+<h4>表示される時</h4>
+<ol>
+<li>action変数により、イベント「InitSkinParse」が発生したとき、つまりスキンの初期化の直前に、プラグイン内のあるメソッドが実行される。</li>
+<li>メソッドは、blogオブジェクトからshortnameを参照し、それを用いてグローバル変数の$DIR_MEDIAと$CONF[’MediaURL]を置き換える。</li>
+<li>画像へのアンカーが、スキン変数&lt;%popup%&gt;、&lt;%image%&gt;において、置き換えられる。</li>
+<li>イベント発生をPreItemにしなかったのは、ポップアップで呼び出されるウィンドウにも変更を適用したかったから。</li>
+</ol>
diff --git a/NP_ImprovedMedia/improvedmedia/index.html b/NP_ImprovedMedia/improvedmedia/index.html
new file mode 100755 (executable)
index 0000000..dd9f433
--- /dev/null
@@ -0,0 +1,11 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>Nothing Here</title>
+</head>
+<body>
+
+<h1>Nothing to see here</h1>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/NP_ImprovedMedia/improvedmedia/lang/english.php b/NP_ImprovedMedia/improvedmedia/lang/english.php
new file mode 100755 (executable)
index 0000000..829ed67
--- /dev/null
@@ -0,0 +1,135 @@
+<?php\r
+/**\r
+ * ImprovedMedia plugin for Nucleus CMS\r
+ * Version 3.0.1\r
+ * Written By Mocchi, Feb.28, 2010\r
+ * \r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 3\r
+ * of the License, or (at your option) any later version.\r
+ */\r
+\r
+define('_IM_DESCRIPTION',      'Provide media function for each weblog on its own directory with erasing and renaming functions');\r
+define('_IM_OPTION_PRIVATE',   'Would you like to use your private collection directory in media directory?');\r
+define('_IM_OPTION_ITEMDISPLAY',       'How many files do you want to display in a list? (5-50 is preferrable)');\r
+define('_IM_OPTION_GREYBOX',   'Would you like to use GreBox utility to open Media Control window?');\r
+define('_IM_OPTION_EACHBLOGDIR',       'Would you like to use the media directory belonged to its own weblog directory?');\r
+\r
+define('_IM_HEADER_TEXT',      ' - ImprovedMedia plugin for Nucleus CMS');\r
+define('_IM_HEADER_RENAME_CONFIRM',    'File Rename (step 1/1)');\r
+define('_IM_HEADER_ERASE_CONFIRM',     'File Erase (step 1/1)');\r
+define('_IM_HEADER_UPLOAD_SELECT',     'File Upload (step 1/1)');\r
+define('_IM_HEADER_EMBED_CONFIRM',     'File Embed (step 1/2)');\r
+define('_IM_HEADER_EMBED',     'File Embed (step 2/2)');\r
+define('_IM_HEADER_SUBDIR_CREATE_CONFIRM',     'Sub Directory Create (step1/1)');\r
+define('_IM_HEADER_SUBDIR_REMOVE_CONFIRM',     'Sub Directory Remove (step1/1)');\r
+define('_IM_HEADER_SUBDIR_RENAME_CONFIRM',     'Sub Directory Rename (step1/1)');\r
+\r
+define('_IM_ANCHOR_TEXT',      'Media Control');\r
+define('_IM_VIEW_TT',  ': View this (Open new window)');\r
+define('_IM_FILTER',   'Filter: ');\r
+define('_IM_FILTER_APPLY',     'Apply Filter');\r
+define('_IM_FILTER_LABEL',     'Filter (case-insentive): ');\r
+define('_IM_UPLOAD_TO',        'Upload to...');\r
+define('_IM_UPLOAD_NEW',       'Upload new file...');\r
+define('_IM_UPLOADLINK',       'Upload a new file');\r
+define('_IM_COLLECTION_SELECT',        'Select');\r
+define('_IM_COLLECTION_TT',    'Switch to this collection directory');\r
+define('_IM_COLLECTION_LABEL', 'Current collection directory: ');\r
+define('_IM_MODIFIED', 'Modified');\r
+define('_IM_FILENAME', 'Filename');\r
+define('_IM_DIMENSIONS',       'Dimensions');\r
+define('_IM_WEBLOG_LABEL',     'Weblog');\r
+\r
+define('_IM_FORBIDDEN_ACCESS', 'This access is done with forbidden way.');\r
+define('_IM_ALT_TOOLONG',      'Description about this file is restricted within 40 letters.');\r
+define('_IM_ERASE_FAILED',     'Fail to erase the file.');\r
+define('_IM_MISSING_FILE',     'The request file is missing.');\r
+define('_IM_MISSING_DIRECTORY',        'The collection directory is missing.');\r
+define('_IM_REMIND_DIRECTORY', 'Please make some directories at the directory for uploading files.');\r
+define('_IM_REMIND_MEDIADIR',  'The directory for media files is not appropriate. Confirm the media directory and the permissions.');\r
+define('_IM_RENAME_FORBIDDEN', 'Forbidden to access the file. Please check your right of access.');\r
+define('_IM_RENAME_FILEEXIST', 'The name you want to rename to already exists.');\r
+define('_IM_RENAME_TOOLONG',   'The file name is restricted within 30 letters.');\r
+define('_IM_RENAME_WRONG',     'The new name includes some disallowed charactors!');\r
+define('_IM_NOTICE',   'NOTICE!');\r
+define('_IM_FUNCTION', 'function');\r
+define('_IM_RENAME_FAILED',    'Fail to rename the file.');\r
+define('_IM_RENAME_BLANK',     'The file name you want to rename to is blank.');\r
+define('_IM_RENAME',   'Rename');\r
+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).');\r
+define('_IM_RENAME_AFTER',     'Name you want to rename to');\r
+define('_IM_RENAME_FILENAME',  'Selected file');\r
+define('_IM_FILENAME_CLICK',   'File name(Click to open)');\r
+define('_IM_FILTER_NONE',      'No Filter');\r
+define('_IM_ACTION',   'Action');\r
+define('_IM_RETURN',   'Go to Overview');\r
+define('_IM_COLLECTION',       'Collection Directory');\r
+define('_IM_COLLECTION_DESC',  'Please choose the directory where you will upload.');\r
+define('_IM_SHORTNAME',        'Short Name of the website');\r
+define('_IM_UPDATE',   'Update');\r
+define('_IM_TYPE',     'Type');\r
+define('_IM_ERASE',    'Erase');\r
+define('_IM_ERASE_CONFIRM',    'Are you sure to erase the file below?');\r
+define('_IM_ERASE_DONE',       'Do Erase');\r
+define('_IM_INCLUDE',  'Insert this');\r
+define('_IM_INCLUDE_DESC',     'Are you sure to insert the file below?');\r
+define('_IM_INCLUDE_ALT',      'Description of this file');\r
+define('_IM_INCLUDE_ALT_DESC', 'Enter the description of this file. Required!');\r
+define('_IM_INCLUDE_MODIFIED', 'Modify');\r
+define('_IM_INCLUDE_FILE_SELECTED',    'The file you selected: ');\r
+define('_IM_INCLUDE_WAY',      'How to show this file');\r
+define('_IM_INCLUDE_WAY_POPUP',        'include this image with the alternative text in the item and popup clicking');\r
+define('_IM_INCLUDE_WAY_INLINE',       'Include this image with the original size in the item');\r
+define('_IM_INCLUDE_WAY_OTHER',        'The description about this file is shown and the users can display to click it.');\r
+define('_IM_INCLUDE_CODE',     'Code which indicates this');\r
+define('_IM_INCLUDE_CODE_DESC',        'Following code is embedded in the input screen. Do not reedit this code.');\r
+define('_IM_INCLUDE_WAY_DECIDE',       'Decide');\r
+define('_IM_UPLOAD_USED_ASCII',        'File name should be in English');\r
+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.');\r
+define('_IM_UPLOAD_USED_ASCII_DESC2',  'Then please use the erase function on this plugin.<br />After, rename it and re-upload it.');\r
+define('_IM_UPLOAD_USED_FILETYPE',     'Available file types');\r
+define('_IM_UPLOAD_CONPLETE',  'The file is uploaded.');\r
+define('_IM_COLLECTION_AMOUNT',        'Num. of Files: ');\r
+define('_IM_COLLECTION_BRANK', 'Nothing exists at collection directory: ');\r
+define('_IM_REQUIREMENT',      'Enter description about the selected file');\r
+define('_IM_ITEMDISPLAY_WRONG',        'Too much or too less number of files in a list!');\r
+\r
+define('_IM_SUBDIR',   'Sub Directory');\r
+define('_IM_COLLECTION_FAILED_READ',   'Fail to get the list in this collection directory. COnfirm your permissions to access this directory.');\r
+define('_IM_SUBDIR_LABEL',     'Sub Collection Directory: ');\r
+define('_IM_SUBDIR_SELECT',    'Select');\r
+define('_IM_SUBDIR_NONE',      'Nothing');\r
+define('_IM_SUBDIR_TT',        'Switch to this sub collection directory');\r
+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.');\r
+define('_IM_DISPLAY_FILES',    'Display files');\r
+define('_IM_SUBDIR_REMOVE',    'Remove directory');\r
+define('_IM_DISPLAY_SUBDIR',   'Manage Sub Directory');\r
+define('_IM_DISPLAY_SUBDIR_TT',        'Move ');\r
+define('_IM_DISPLAY_SUBDIR_SELECT',    'Choice');\r
+define('_IM_CREATE_SUBDIR_CONFIRM',    'Create Sub Directory');\r
+define('_IM_CREATE_SUBDIR_COLLECTION_LABEL',   'Choose collection directory');\r
+define('_IM_CREATE_SUBDIR_COLLECTION', 'Please chose the collection directory where you would like to create sub directory.');\r
+define('_IM_CREATE_SUBDIR_INPUT_NAME', 'Name of sub directory');\r
+define('_IM_CREATE_SUBDIR_CHARS',      'the name of sub directory should be ');\r
+define('_IM_CREATE_SUBDIR_CHARS_DESC', 'For name of directories, the charactors is limited within alphabeds, numbers, underscores, hyphenminus and plus. Maximum 20 letters.');\r
+define('_IM_RENAME_SUBDIR_BLANK',      '');\r
+define('_IM_RENAME_SUBDIR_TOOLONG',    'The sub directory name should be restricted within 20 letters.');\r
+define('_IM_RENAME_SUBDIR_WRONG',      'the name for sub directory includes disallowed charactors.');\r
+define('_IM_RENAME_SUBDIR_DUPLICATE',  'Directory with the same name is already exists.');\r
+define('_IM_CREATE_SUBDIR_WRONG',      'Creating sub directory failed. Please ask the manager of your server.');\r
+define('_IM_RENAME_SUBDIR_COLLECTION', 'Sub directory which you want to rename');\r
+define('_IM_SUBDIR_NUM_FILES', 'the number of files');\r
+define('_IM_DISPLAY_SUBDIR_LABEL1',    'the number of directories: ');\r
+define('_IM_DISPLAY_SUBDIR_LABEL2',    ', the number of files: ');\r
+define('_IM_DISPLAY_SUBDIR_RETURN',    'File list');\r
+define('_IM_REMOVE_SUBIDR',    'Remove sub directory');\r
+define('_IM_REMOVE_SUBIDR_CONFIRM',    'Confirm to remove sub directory');\r
+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.');\r
+define('_IM_REMOVE_SUBDIR_FAILED',     'Fail to remove this sub directory. Confirm your permissions to this sub directory or included files.');\r
+define('_IM_DISPLAY_SUBDIR_CAPTION',   'Sub directory list');\r
+define('_IM_DISPLAY_SUBDIR_NOTHING',   'No sub directories');\r
+define('_IM_SUBDIR_REMOVE_FAILED',     'Fail to remove this sub directory. Confirm your permission to this sub directory or included files.');\r
+define('_IM_SUBDIR_FAILED_READ',       'Fail to get the list of this sub directory. Confirm your permission to access this sub directory.');\r
+?>
diff --git a/NP_ImprovedMedia/improvedmedia/lang/index.html b/NP_ImprovedMedia/improvedmedia/lang/index.html
new file mode 100755 (executable)
index 0000000..dd9f433
--- /dev/null
@@ -0,0 +1,11 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>Nothing Here</title>
+</head>
+<body>
+
+<h1>Nothing to see here</h1>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/NP_ImprovedMedia/improvedmedia/lang/japanese-euc.php b/NP_ImprovedMedia/improvedmedia/lang/japanese-euc.php
new file mode 100755 (executable)
index 0000000..a666899
--- /dev/null
@@ -0,0 +1,135 @@
+<?php\r
+/**\r
+ * ImprovedMedia plugin for Nucleus CMS\r
+ * Version 3.0.1\r
+ * Written By Mocchi, Feb.28, 2010\r
+ * \r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 3\r
+ * of the License, or (at your option) any later version.\r
+ */\r
+\r
+define('_IM_DESCRIPTION',      '¥Õ¥¡¥¤¥ëºï½ü¤È̾Á°Êѹ¹µ¡Ç½¡¢¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê´ÉÍýµ¡Ç½¤òÄɲä·¤¿³°Éô¥Õ¥¡¥¤¥ë´ÉÍýµ¡Ç½¤Ëº¹¤·Âؤ¨¤Þ¤¹¡£¤Þ¤¿¡¢ÀßÄê¤òÊѹ¹¤¹¤ë¤³¤È¤Ë¤è¤ê¡¢¥á¥Ç¥£¥¢¡¦¥Ç¥£¥ì¥¯¥È¥ê¤ò¸ÄÊ̤Υ¦¥§¥Ö¥í¥°¤Î¥Ç¥£¥ì¥¯¥È¥ê¤ËÇÛÃÖ¤·¤¿±¿ÍѤò²Äǽ¤È¤·¤Þ¤¹¡£');\r
+define('_IM_OPTION_PRIVATE',   '¥×¥é¥¤¥Ù¡¼¥È¡¦¥³¥ì¥¯¥·¥ç¥ó¡¦¥Õ¥©¥ë¥À¤ò»È¤¤¤Þ¤¹¤«¡©');\r
+define('_IM_OPTION_ITEMDISPLAY',       '°ì¤Ä¤Î²èÌ̤ˤ¤¤¯¤Ä¤Î¥Õ¥¡¥¤¥ë¤òɽ¼¨¤·¤Þ¤¹¤«¡©¡Ê5¤«¤é50¤Þ¤Ç¡Ë');\r
+define('_IM_OPTION_GREYBOX',   'Media Control¥¦¥£¥ó¥É¥¦¤ËGreyBox¥æ¡¼¥Æ¥£¥ê¥Æ¥£¤ò»È¤¤¤Þ¤¹¤«¡©');\r
+define('_IM_OPTION_EACHBLOGDIR',       '¤½¤ì¤¾¤ì¤Î¥¦¥§¥Ö¥í¥°¤¬¤¢¤ë¸ÄÊ̥ǥ£¥ì¥¯¥È¥ê¤Ç¤Î¥Õ¥¡¥¤¥ë´ÉÍý¤òÍøÍѤ·¤Þ¤¹¤«¡©');\r
+\r
+define('_IM_HEADER_TEXT',      ' - ImprovedMedia plugin for Nucleus CMS');\r
+define('_IM_HEADER_RENAME_CONFIRM',    '¥Õ¥¡¥¤¥ë̾¤ÎÊѹ¹¡Ê¥¹¥Æ¥Ã¥× 1¤Î1¡Ë');\r
+define('_IM_HEADER_ERASE_CONFIRM',     '¥Õ¥¡¥¤¥ë¤Îºï½ü¡Ê¥¹¥Æ¥Ã¥× 1¤Î1¡Ë');\r
+define('_IM_HEADER_UPLOAD_SELECT',     '¥Õ¥¡¥¤¥ë¤Î¥¢¥Ã¥×¥í¡¼¥É¡Ê¥¹¥Æ¥Ã¥× 1¤Î1¡Ë');\r
+define('_IM_HEADER_EMBED_CONFIRM',     '¥Õ¥¡¥¤¥ë¤ÎÁÞÆþ¡Ê¥¹¥Æ¥Ã¥× 2¤Î1¡Ë');\r
+define('_IM_HEADER_EMBED',     '¥Õ¥¡¥¤¥ë¤ÎÁÞÆþ¡Ê¥¹¥Æ¥Ã¥× 2¤Î2¡Ë');\r
+define('_IM_HEADER_SUBDIR_CREATE_CONFIRM',     '¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê¤ÎºîÀ®');\r
+define('_IM_HEADER_SUBDIR_REMOVE_CONFIRM',     '¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê¤Îºï½ü');\r
+define('_IM_HEADER_SUBDIR_RENAME_CONFIRM',     '¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê̾¤ÎÊѹ¹');\r
+\r
+define('_IM_ANCHOR_TEXT',      '¥Õ¥¡¥¤¥ë´ÉÍý');\r
+define('_IM_VIEW_TT',  ' :¥Õ¥¡¥¤¥ëɽ¼¨ (¿·¤·¤¤¥¦¥£¥ó¥É¥¦¤¬³«¤­¤Þ¤¹)');\r
+define('_IM_FILTER',   '¥Õ¥£¥ë¥¿¡¼: ');\r
+define('_IM_FILTER_APPLY',     '¥Õ¥£¥ë¥¿¡¼Å¬±þ');\r
+define('_IM_FILTER_LABEL',     '¥Õ¥£¥ë¥¿¡¼¡ÊÂçʸ»ú¾®Ê¸»ú̵´Ø·¸¡Ë: ');\r
+define('_IM_UPLOAD_TO',        '¥¢¥Ã¥×¥í¡¼¥ÉÀè');\r
+define('_IM_UPLOAD_NEW',       '¿·µ¬¥¢¥Ã¥×¥í¡¼¥É');\r
+define('_IM_UPLOADLINK',       '¿·¤·¤¤¥Õ¥¡¥¤¥ë¤Î¥¢¥Ã¥×¥í¡¼¥É');\r
+define('_IM_COLLECTION_SELECT',        'ÁªÂò');\r
+define('_IM_COLLECTION_TT',    '¤³¤Î¥³¥ì¥¯¥·¥ç¥ó¡¦¥Ç¥£¥ì¥¯¥È¥ê¤ËÀÚ¤êÂؤ¨');\r
+define('_IM_COLLECTION_LABEL', '¥³¥ì¥¯¥·¥ç¥ó¡¦¥Ç¥£¥ì¥¯¥È¥ê¤ÎÊѹ¹: ');\r
+define('_IM_MODIFIED', '¹¹¿·Æü');\r
+define('_IM_FILENAME', '¥Õ¥¡¥¤¥ë̾');\r
+define('_IM_DIMENSIONS',       '¥µ¥¤¥º');\r
+define('_IM_WEBLOG_LABEL',     '¥¦¥§¥Ö¥í¥°');\r
+\r
+define('_IM_FORBIDDEN_ACCESS', '¶Ø»ß¤·¤Æ¤¤¤ëÁàºî¤Ë¤è¤ë¥¢¥¯¥»¥¹¤Ç¤¹');\r
+define('_IM_ALT_TOOLONG',      'ÀâÌÀʸ¤¬40ʸ»ú¤òĶ¤¨¤Æ¤¤¤Þ¤¹');\r
+define('_IM_ERASE_FAILED',     '¥Õ¥¡¥¤¥ë¤Îºï½ü¤Ë¼ºÇÔ¤·¤Þ¤·¤¿');\r
+define('_IM_MISSING_FILE',     '¥Õ¥¡¥¤¥ë¤ò¸«¤Ä¤±¤ë¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿');\r
+define('_IM_MISSING_DIRECTORY',        '¥³¥ì¥¯¥·¥ç¥ó¡¦¥Ç¥£¥ì¥¯¥È¥ê¤ò¸«¤Ä¤±¤ë¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿');\r
+define('_IM_REMIND_DIRECTORY', '¥¢¥Ã¥×¥í¡¼¥ÉÍÑ¥Õ¥©¥ë¥ÀÆâ¤ËǤ°Õ¤Î¥Ç¥£¥ì¥¯¥È¥ê¤òºîÀ®¤·¤Æ¤¯¤À¤µ¤¤¡£');\r
+define('_IM_REMIND_MEDIADIR',  '¥¢¥Ã¥×¥í¡¼¥ÉÍÑ¥Õ¥©¥ë¥À¤¬Å¬ÀÚ¤ËÀßÃÖ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£¥¢¥Ã¥×¥í¡¼¥ÉÍÑ¥Õ¥©¥ë¥À¤È¤½¤Î¥¢¥¯¥»¥¹¸¢¸Â¤òºÆÀßÄꤷ¤Æ²¼¤µ¤¤¡£');\r
+define('_IM_RENAME_FORBIDDEN', '¥Õ¥¡¥¤¥ë¤Ë¥¢¥¯¥»¥¹¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£¤¢¤Ê¤¿¤Î¥¢¥¯¥»¥¹¸¢¤ò³Îǧ¤·¤Æ¤¯¤À¤µ¤¤');\r
+define('_IM_RENAME_FILEEXIST', 'Êѹ¹¤·¤¿¤¤Ì¾Á°¤Î¥Õ¥¡¥¤¥ë¤¬¤¹¤Ç¤Ë¸ºß¤·¤Æ¤¤¤Þ¤¹');\r
+define('_IM_RENAME_TOOLONG',   '¥Õ¥¡¥¤¥ë̾¤¬30ʸ»ú¤òĶ¤¨¤Æ¤¤¤Þ¤¹');\r
+define('_IM_RENAME_WRONG',     '¥Õ¥¡¥¤¥ë̾¤Ë»ØÄêʸ»ú°Ê³°¤¬´Þ¤Þ¤ì¤Æ¤¤¤Þ¤¹');\r
+define('_IM_NOTICE',   'Ãí°Õ¡ª');\r
+define('_IM_FUNCTION', 'µ¡Ç½');\r
+define('_IM_RENAME_FAILED',    '̾Á°¤ÎÊѹ¹¤Ë¼ºÇÔ¤·¤Þ¤·¤¿');\r
+define('_IM_RENAME_BLANK',     '¥Õ¥¡¥¤¥ë̾¤¬¶õÇò¤Ç¤¹');\r
+define('_IM_RENAME',   '̾Á°Êѹ¹');\r
+define('_IM_RENAME_DESCRIPTION',       'Êѹ¹¸å¤Î̾Á°¤ò¡¢³ÈÄ¥»Ò¤Ì¤­¤Ç¡¢30ʸ»ú¤Þ¤Ç¤ÇÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£»ÈÍѤǤ­¤ëʸ»ú¤Ï±Ñ¿ô»ú¤È3¼ïÎà¤Îµ­¹æ¡Ê¥¢¥ó¥À¡¼¥Ð¡¼¡¢¥Ï¥¤¥Õ¥ó¡¢¥×¥é¥¹¡Ë¤Ç¤¹¡£ÆüËܸì¤Ï»ÈÍѤǤ­¤Þ¤»¤ó¡£');\r
+define('_IM_RENAME_AFTER',     'Êѹ¹¸å¤Î̾Á°');\r
+define('_IM_RENAME_FILENAME',  '̾Á°¤òÊѹ¹¤¹¤ë¥Õ¥¡¥¤¥ë');\r
+define('_IM_FILENAME_CLICK',   '¥Õ¥¡¥¤¥ë̾');\r
+define('_IM_FILTER_NONE',      '¥Õ¥£¥ë¥¿¤Ê¤·');\r
+define('_IM_ACTION',   'Æ°ºî');\r
+define('_IM_RETURN',   '°ìÍ÷¤Ø');\r
+define('_IM_COLLECTION',       '¥³¥ì¥¯¥·¥ç¥ó¡¦¥Ç¥£¥ì¥¯¥È¥ê');\r
+define('_IM_COLLECTION_DESC',  '¥Õ¥¡¥¤¥ë¤ò¥¢¥Ã¥×¥í¡¼¥É¤¹¤ë¥Ç¥£¥ì¥¯¥È¥ê¤òÁªÂò¤·¤Æ¤¯¤À¤µ¤¤¡£');\r
+define('_IM_SHORTNAME',        '¥¦¥§¥Ö¥µ¥¤¥È¤Îû½Ì̾');\r
+define('_IM_UPDATE',   'ÅÐÏ¿Æü');\r
+define('_IM_TYPE',     '¼ïÎà');\r
+define('_IM_ERASE',    'ºï½ü');\r
+define('_IM_ERASE_CONFIRM',    '°Ê²¼¤Î¥Õ¥¡¥¤¥ë¤ò¾Ãµî¤·¤Þ¤¹');\r
+define('_IM_ERASE_DONE',       'ºï½ü¤¹¤ë');\r
+define('_IM_INCLUDE',  'ʸ¾Ï¤ËÁÞÆþ');\r
+define('_IM_INCLUDE_DESC',     '°Ê²¼¤Î¥Õ¥¡¥¤¥ë¤òʸ¾Ï¤ËÁÞÆþ¤·¤Þ¤¹¡£');\r
+define('_IM_INCLUDE_ALT',      '¥Õ¥¡¥¤¥ë¤ÎÀâÌÀʸ');\r
+define('_IM_INCLUDE_ALT_DESC', '¥Õ¥¡¥¤¥ë¤Î´Êñ¤ÊÀâÌÀʸ¤ò¡¢40ʸ»ú¤Þ¤Ç¤ÇÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£É¬¿Ü¤Ç¤¹¡£');\r
+define('_IM_INCLUDE_MODIFIED', '½¤Àµ¤¹¤ë');\r
+define('_IM_INCLUDE_FILE_SELECTED',    'ÁªÂò¤·¤¿¥Õ¥¡¥¤¥ë');\r
+define('_IM_INCLUDE_WAY',      '¥Õ¥¡¥¤¥ë¤Îɽ¼¨ÊýË¡');\r
+define('_IM_INCLUDE_WAY_POPUP',        'ÀâÌÀʸ¤òµ­»ö¤Ëɽ¼¨¤·¡¢¥¯¥ê¥Ã¥¯¤Ç¥Ý¥Ã¥×¥¢¥Ã¥×ɽ¼¨');\r
+define('_IM_INCLUDE_WAY_INLINE',       '²èÁü¤ò¤½¤Î¤Þ¤Þ¤Î¥µ¥¤¥º¤Çµ­»ö¤ËËä¤á¹þ¤à');\r
+define('_IM_INCLUDE_WAY_OTHER',        '¤³¤Î¥Õ¥¡¥¤¥ë¤Ï¡¢¾å¤ÇÆþÎϤ·¤¿ÀâÌÀʸ¤¬¥¢¥ó¥«¡¼¥Æ¥­¥¹¥È¤È¤Ê¤ê¤Þ¤¹¡£Ê¸½ñÃæ¤ÎÀâÌÀʸ¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤È¡¢¥Õ¥¡¥¤¥ë¤¬¥Ý¥Ã¥×¥¢¥Ã¥×ɽ¼¨¤µ¤ì¤Þ¤¹¡£');\r
+define('_IM_INCLUDE_CODE',     'ÆþÎϲèÌ̤ËËä¤á¹þ¤Þ¤ì¤ë¥³¡¼¥É');\r
+define('_IM_INCLUDE_CODE_DESC',        'ÆþÎϲèÌ̤ˤϡ¢°Ê²¼¤Î¥³¡¼¥É¤¬Ëä¤á¹þ¤Þ¤ì¤Þ¤¹¡£¤³¤Î¥³¡¼¥É¤ÏºÆÊÔ½¸¤·¤Ê¤¤¤Ç¤¯¤À¤µ¤¤¡£');\r
+define('_IM_INCLUDE_WAY_DECIDE',       '·èÄê');\r
+define('_IM_UPLOAD_USED_ASCII',        '¥Õ¥¡¥¤¥ë̾¤Ïɬ¤º±Ñ¿ô»ú');\r
+define('_IM_UPLOAD_USED_ASCII_DESC1',  'ÆüËܸì¤òÍѤ¤¤ë¤È¡¢¥¢¥É¥ì¥¹¤¬Ê¸»ú²½¤±¤·¤Æ¥Ö¥é¥¦¥¶¤Ç»²¾È¤Ç¤­¤Ê¤¯¤Ê¤ê¤Þ¤¹²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£');\r
+define('_IM_UPLOAD_USED_ASCII_DESC2',  '¤½¤Î¾ì¹ç¤Ï¡¢ºï½üµ¡Ç½¤òÍѤ¤¤Æºï½ü¤·¤Æ¤¯¤À¤µ¤¤¡£¤½¤·¤Æ¡¢Ì¾Á°¤òÊѹ¹¤·¤Æ¤«¤é¡¢ºÆÅÙ¥¢¥Ã¥×¥í¡¼¥É¤·¤Æ¤¯¤À¤µ¤¤¡£');\r
+define('_IM_UPLOAD_USED_FILETYPE',     '¸½ºßÍøÍѤǤ­¤ë¥Õ¥¡¥¤¥ë¤Î¥¿¥¤¥×');\r
+define('_IM_UPLOAD_CONPLETE',  '¥Õ¥¡¥¤¥ë¤Î¥¢¥Ã¥×¥í¡¼¥É¤¬À®¸ù¤·¤Þ¤·¤¿');\r
+define('_IM_COLLECTION_AMOUNT',        '¥Õ¥¡¥¤¥ë¿ô: ');\r
+define('_IM_COLLECTION_BRANK', '¥Õ¥¡¥¤¥ë¤Ê¤·');\r
+define('_IM_REQUIREMENT',      'ÀâÌÀʸ¤òÆþÎϤ·¤Æ¤¯¤À¤µ¤¤');\r
+define('_IM_ITEMDISPLAY_WRONG',        '1¥Ú¡¼¥¸¤Îɽ¼¨¥Õ¥¡¥¤¥ë¿ô¤ò¡¢5·ï¤«¤é50·ï¤Î´Ö¤Ç»ØÄꤷ¤Æ¤¯¤À¤µ¤¤¡£');\r
+\r
+define('_IM_SUBDIR',   '¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê');\r
+define('_IM_COLLECTION_FAILED_READ',   '¥³¥ì¥¯¥·¥ç¥ó¡¦¥Ç¥£¥ì¥¯¥È¥ê¾ðÊó¤Î¼èÆÀ¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£¥¢¥¯¥»¥¹¸¢¸Â¤ò³Îǧ¤·¤Æ²¼¤µ¤¤');\r
+define('_IM_SUBDIR_LABEL',     '¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê: ');\r
+define('_IM_SUBDIR_SELECT',    'ÁªÂò');\r
+define('_IM_SUBDIR_NONE',      '¤Ê¤·');\r
+define('_IM_SUBDIR_TT',        '¤³¤Î¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê¤ËÀÚ¤êÂؤ¨');\r
+define('_IM_SUBDIR_DESC',      '¥Õ¥¡¥¤¥ë¤ò¥¢¥Ã¥×¥í¡¼¥É¤¹¤ë¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê¤òÁªÂò¤·¤Æ¤¯¤À¤µ¤¤¡£¤Ê¤·¤Î¾ì¹ç¤Ï¥³¥ì¥¯¥·¥ç¥ó¡¦¥Ç¥£¥ì¥¯¥È¥ê¤ËÊݸ¤µ¤ì¤Þ¤¹¡£');\r
+define('_IM_DISPLAY_FILES',    '¥Õ¥¡¥¤¥ëɽ¼¨');\r
+define('_IM_SUBDIR_REMOVE',    '¥Ç¥£¥ì¥¯¥È¥êºï½ü');\r
+define('_IM_DISPLAY_SUBDIR',   '¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê´ÉÍý');\r
+define('_IM_DISPLAY_SUBDIR_TT',        '¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê¤Î´ÉÍý²èÌ̤˰ÜÆ°');\r
+define('_IM_DISPLAY_SUBDIR_SELECT',    'ÊÑ ¹¹');\r
+define('_IM_CREATE_SUBDIR_CONFIRM',    '¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥êºîÀ®');\r
+define('_IM_CREATE_SUBDIR_COLLECTION_LABEL',   '¥³¥ì¥¯¥·¥ç¥ó¡¦¥Ç¥£¥ì¥¯¥È¥ê¤Î»ØÄê');\r
+define('_IM_CREATE_SUBDIR_COLLECTION', '¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê¤òºîÀ®¤¹¤ë¥³¥ì¥¯¥·¥ç¥ó¡¦¥Ç¥£¥ì¥¯¥È¥ê¤ò»ØÄꤷ¤Æ¤¯¤À¤µ¤¤');\r
+define('_IM_CREATE_SUBDIR_INPUT_NAME', '¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê¤Î¥Ç¥£¥ì¥¯¥È¥ê̾');\r
+define('_IM_CREATE_SUBDIR_CHARS',      '¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê̾¤Ë»ØÄꤵ¤ì¤¿°Ê³°¤Îʸ»ú¼ï¤¬»È¤ï¤ì¤Æ¤¤¤Þ¤¹');\r
+define('_IM_CREATE_SUBDIR_CHARS_DESC', '¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê̾¤ËÍøÍѤǤ­¤ëʸ»ú¤Ï¡¢±Ñ¿ô»ú¤È3¼ïÎà¤Îµ­¹æ¡Ê¥¢¥ó¥À¡¼¥Ð¡¼¡¢¥Ï¥¤¥Õ¥ó¡¢¥×¥é¥¹¡Ë¤Ç¤¹¡£ºÇŤÇ20ʸ»ú¤Ç¤¹¡£¤½¤ì°Ê³°¤Îʸ»ú¼ï¤äÆüËܸì¤Ï»ÈÍѤǤ­¤Þ¤»¤ó¡£');\r
+define('_IM_RENAME_SUBDIR_BLANK',      '¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê̾¤¬¶õÇò¤Ç¤¹');\r
+define('_IM_RENAME_SUBDIR_TOOLONG',    '¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê̾¤¬20ʸ»ú¤òĶ¤¨¤Æ¤¤¤Þ¤¹');\r
+define('_IM_RENAME_SUBDIR_WRONG',      '¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê̾¤Ë»ØÄꤵ¤ì¤¿°Ê³°¤Îʸ»ú¼ï¤¬»È¤ï¤ì¤Æ¤¤¤Þ¤¹');\r
+define('_IM_RENAME_SUBDIR_DUPLICATE',  'Ʊ̾¤Î¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê¤¬¤¹¤Ç¤Ë¸ºß¤·¤Æ¤¤¤Þ¤¹¡£');\r
+define('_IM_CREATE_SUBDIR_WRONG',      '¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê¤¬ºîÀ®¤Ç¤­¤Þ¤»¤ó¤Î¤Ç¡¢¥µ¡¼¥Ð´ÉÍý¼Ô¤ËÁêÃ̤·¤Æ¤¯¤À¤µ¤¤');\r
+define('_IM_RENAME_SUBDIR_COLLECTION', '̾Á°¤òÊѹ¹¤¹¤ë¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê');\r
+define('_IM_SUBDIR_NUM_FILES', '¥Õ¥¡¥¤¥ë¿ô');\r
+define('_IM_DISPLAY_SUBDIR_LABEL1',    '¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê¿ô: ');\r
+define('_IM_DISPLAY_SUBDIR_LABEL2',    ', ¥Õ¥¡¥¤¥ë¿ô: ');\r
+define('_IM_DISPLAY_SUBDIR_RETURN',    '¥Õ¥¡¥¤¥ë°ìÍ÷');\r
+define('_IM_REMOVE_SUBIDR',    'ºï½ü¤¹¤ë¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê');\r
+define('_IM_REMOVE_SUBIDR_CONFIRM',    '¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê¤Îºï½ü¤Î³Îǧ');\r
+define('_IM_REMOVE_SUBIDR_REMIND',     '¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê¤òºï½ü¤¹¤ë¤È¡¢Ãæ¤Î¥Õ¥¡¥¤¥ë¤â¤¹¤Ù¤ÆƱ»þ¤Ëºï½ü¤µ¤ì¤Þ¤¹¡£¤½¤ÎºÝ¡¢¤¹¤Ç¤Ë¥¢¥¤¥Æ¥àÆâ¤ËÁÞÆþ¤µ¤ì¤Æ¤¤¤ë¥³¡¼¥É¤Ï¡¢¤³¤ÎÁàºî¤ò¹Ô¤Ã¤Æ¤â¼«Æ°¤Ç½ñ¤­´¹¤¨¤é¤ì¤Þ¤»¤ó¡£¤Ê¤ª¡¢¥³¥ì¥¯¥·¥ç¥ó¡¦¥Ç¥£¥ì¥¯¥È¥ê¤òºï½ü¤¹¤ë¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó¡£');\r
+define('_IM_REMOVE_SUBDIR_FAILED',     '¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê¤Îºï½ü¤Ë¼ºÇÔ¤·¤Æ¤¤¤Þ¤¹¡£¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê¤â¤·¤¯¤Ï´Þ¤Þ¤ì¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¤ò³Îǧ¤·¤Æ¤¯¤À¤µ¤¤¡£');\r
+define('_IM_DISPLAY_SUBDIR_CAPTION',   '¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê°ìÍ÷');\r
+define('_IM_DISPLAY_SUBDIR_NOTHING',   '¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê¤Ê¤·');\r
+define('_IM_SUBDIR_REMOVE_FAILED',     '¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê¤Îºï½ü¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê¤Î¥¢¥¯¥»¥¹¸¢¸Â¤â¤·¤¯¤Ï¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥êÆâ¤Î¥Õ¥¡¥¤¥ë¤Î¥¢¥¯¥»¥¹¸¢¸Â¤ò³Îǧ¤·¤Æ²¼¤µ¤¤¡£');\r
+define('_IM_SUBDIR_FAILED_READ',       '¥µ¥Ö¡¦¥Ç¥£¥ì¥¯¥È¥ê¾ðÊó¤Î¼èÆÀ¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£¥¢¥¯¥»¥¹¸¢¸Â¤ò³Îǧ¤·¤Æ²¼¤µ¤¤');\r
+?>
diff --git a/NP_ImprovedMedia/improvedmedia/lang/japanese-utf8.php b/NP_ImprovedMedia/improvedmedia/lang/japanese-utf8.php
new file mode 100755 (executable)
index 0000000..6ee5bcb
--- /dev/null
@@ -0,0 +1,135 @@
+<?php\r
+/**\r
+ * ImprovedMedia plugin for Nucleus CMS\r
+ * Version 3.0.1\r
+ * Written By Mocchi, Feb.28, 2010\r
+ * \r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 3\r
+ * of the License, or (at your option) any later version.\r
+ */\r
+\r
+define('_IM_DESCRIPTION',      'ファイル削除と名前変更機能、サブ・ディレクトリ管理機能を追加した外部ファイル管理機能に差し替えます。また、設定を変更することにより、メディア・ディレクトリを個別のウェブログのディレクトリに配置した運用を可能とします。');\r
+define('_IM_OPTION_PRIVATE',   'プライベート・コレクション・フォルダを使いますか?');\r
+define('_IM_OPTION_ITEMDISPLAY',       '一つの画面にいくつのファイルを表示しますか?(5から50まで)');\r
+define('_IM_OPTION_GREYBOX',   'Media ControlウィンドウにGreyBoxユーティリティを使いますか?');\r
+define('_IM_OPTION_EACHBLOGDIR',       'それぞれのウェブログがある個別ディレクトリでのファイル管理を利用しますか?');\r
+\r
+define('_IM_HEADER_TEXT',      ' - ImprovedMedia plugin for Nucleus CMS');\r
+define('_IM_HEADER_RENAME_CONFIRM',    'ファイル名の変更(ステップ 1の1)');\r
+define('_IM_HEADER_ERASE_CONFIRM',     'ファイルの削除(ステップ 1の1)');\r
+define('_IM_HEADER_UPLOAD_SELECT',     'ファイルのアップロード(ステップ 1の1)');\r
+define('_IM_HEADER_EMBED_CONFIRM',     'ファイルの挿入(ステップ 2の1)');\r
+define('_IM_HEADER_EMBED',     'ファイルの挿入(ステップ 2の2)');\r
+define('_IM_HEADER_SUBDIR_CREATE_CONFIRM',     'サブ・ディレクトリの作成');\r
+define('_IM_HEADER_SUBDIR_REMOVE_CONFIRM',     'サブ・ディレクトリの削除');\r
+define('_IM_HEADER_SUBDIR_RENAME_CONFIRM',     'サブ・ディレクトリ名の変更');\r
+\r
+define('_IM_ANCHOR_TEXT',      'ファイル管理');\r
+define('_IM_VIEW_TT',  ' :ファイル表示 (新しいウィンドウが開きます)');\r
+define('_IM_FILTER',   'フィルター: ');\r
+define('_IM_FILTER_APPLY',     'フィルター適応');\r
+define('_IM_FILTER_LABEL',     'フィルター(大文字小文字無関係): ');\r
+define('_IM_UPLOAD_TO',        'アップロード先');\r
+define('_IM_UPLOAD_NEW',       '新規アップロード');\r
+define('_IM_UPLOADLINK',       '新しいファイルのアップロード');\r
+define('_IM_COLLECTION_SELECT',        '選択');\r
+define('_IM_COLLECTION_TT',    'このコレクション・ディレクトリに切り替え');\r
+define('_IM_COLLECTION_LABEL', 'コレクション・ディレクトリの変更: ');\r
+define('_IM_MODIFIED', '更新日');\r
+define('_IM_FILENAME', 'ファイル名');\r
+define('_IM_DIMENSIONS',       'サイズ');\r
+define('_IM_WEBLOG_LABEL',     'ウェブログ');\r
+\r
+define('_IM_FORBIDDEN_ACCESS', '禁止している操作によるアクセスです');\r
+define('_IM_ALT_TOOLONG',      '説明文が40文字を超えています');\r
+define('_IM_ERASE_FAILED',     'ファイルの削除に失敗しました');\r
+define('_IM_MISSING_FILE',     'ファイルを見つけることができませんでした');\r
+define('_IM_MISSING_DIRECTORY',        'コレクション・ディレクトリを見つけることができませんでした');\r
+define('_IM_REMIND_DIRECTORY', 'アップロード用フォルダ内に任意のディレクトリを作成してください。');\r
+define('_IM_REMIND_MEDIADIR',  'アップロード用フォルダが適切に設置されていません。アップロード用フォルダとそのアクセス権限を再設定して下さい。');\r
+define('_IM_RENAME_FORBIDDEN', 'ファイルにアクセスできませんでした。あなたのアクセス権を確認してください');\r
+define('_IM_RENAME_FILEEXIST', '変更したい名前のファイルがすでに存在しています');\r
+define('_IM_RENAME_TOOLONG',   'ファイル名が30文字を超えています');\r
+define('_IM_RENAME_WRONG',     'ファイル名に指定文字以外が含まれています');\r
+define('_IM_NOTICE',   '注意!');\r
+define('_IM_FUNCTION', '機能');\r
+define('_IM_RENAME_FAILED',    '名前の変更に失敗しました');\r
+define('_IM_RENAME_BLANK',     'ファイル名が空白です');\r
+define('_IM_RENAME',   '名前変更');\r
+define('_IM_RENAME_DESCRIPTION',       '変更後の名前を、拡張子ぬきで、30文字までで入力してください。使用できる文字は英数字と3種類の記号(アンダーバー、ハイフン、プラス)です。日本語は使用できません。');\r
+define('_IM_RENAME_AFTER',     '変更後の名前');\r
+define('_IM_RENAME_FILENAME',  '名前を変更するファイル');\r
+define('_IM_FILENAME_CLICK',   'ファイル名');\r
+define('_IM_FILTER_NONE',      'フィルタなし');\r
+define('_IM_ACTION',   '動作');\r
+define('_IM_RETURN',   '一覧へ');\r
+define('_IM_COLLECTION',       'コレクション・ディレクトリ');\r
+define('_IM_COLLECTION_DESC',  'ファイルをアップロードするディレクトリを選択してください。');\r
+define('_IM_SHORTNAME',        'ウェブサイトの短縮名');\r
+define('_IM_UPDATE',   '登録日');\r
+define('_IM_TYPE',     '種類');\r
+define('_IM_ERASE',    '削除');\r
+define('_IM_ERASE_CONFIRM',    '以下のファイルを消去します');\r
+define('_IM_ERASE_DONE',       '削除する');\r
+define('_IM_INCLUDE',  '文章に挿入');\r
+define('_IM_INCLUDE_DESC',     '以下のファイルを文章に挿入します。');\r
+define('_IM_INCLUDE_ALT',      'ファイルの説明文');\r
+define('_IM_INCLUDE_ALT_DESC', 'ファイルの簡単な説明文を、40文字までで入力してください。必須です。');\r
+define('_IM_INCLUDE_MODIFIED', '修正する');\r
+define('_IM_INCLUDE_FILE_SELECTED',    '選択したファイル');\r
+define('_IM_INCLUDE_WAY',      'ファイルの表示方法');\r
+define('_IM_INCLUDE_WAY_POPUP',        '説明文を記事に表示し、クリックでポップアップ表示');\r
+define('_IM_INCLUDE_WAY_INLINE',       '画像をそのままのサイズで記事に埋め込む');\r
+define('_IM_INCLUDE_WAY_OTHER',        'このファイルは、上で入力した説明文がアンカーテキストとなります。文書中の説明文をクリックすると、ファイルがポップアップ表示されます。');\r
+define('_IM_INCLUDE_CODE',     '入力画面に埋め込まれるコード');\r
+define('_IM_INCLUDE_CODE_DESC',        '入力画面には、以下のコードが埋め込まれます。このコードは再編集しないでください。');\r
+define('_IM_INCLUDE_WAY_DECIDE',       '決定');\r
+define('_IM_UPLOAD_USED_ASCII',        'ファイル名は必ず英数字');\r
+define('_IM_UPLOAD_USED_ASCII_DESC1',  '日本語を用いると、アドレスが文字化けしてブラウザで参照できなくなります可能性があります。');\r
+define('_IM_UPLOAD_USED_ASCII_DESC2',  'その場合は、削除機能を用いて削除してください。そして、名前を変更してから、再度アップロードしてください。');\r
+define('_IM_UPLOAD_USED_FILETYPE',     '現在利用できるファイルのタイプ');\r
+define('_IM_UPLOAD_CONPLETE',  'ファイルのアップロードが成功しました');\r
+define('_IM_COLLECTION_AMOUNT',        'ファイル数: ');\r
+define('_IM_COLLECTION_BRANK', 'ファイルなし');\r
+define('_IM_REQUIREMENT',      '説明文を入力してください');\r
+define('_IM_ITEMDISPLAY_WRONG',        '1ページの表示ファイル数を、5件から50件の間で指定してください。');\r
+\r
+define('_IM_SUBDIR',   'サブ・ディレクトリ');\r
+define('_IM_COLLECTION_FAILED_READ',   'コレクション・ディレクトリ情報の取得に失敗しました。アクセス権限を確認して下さい');\r
+define('_IM_SUBDIR_LABEL',     'サブ・ディレクトリ: ');\r
+define('_IM_SUBDIR_SELECT',    '選択');\r
+define('_IM_SUBDIR_NONE',      'なし');\r
+define('_IM_SUBDIR_TT',        'このサブ・ディレクトリに切り替え');\r
+define('_IM_SUBDIR_DESC',      'ファイルをアップロードするサブ・ディレクトリを選択してください。なしの場合はコレクション・ディレクトリに保存されます。');\r
+define('_IM_DISPLAY_FILES',    'ファイル表示');\r
+define('_IM_SUBDIR_REMOVE',    'ディレクトリ削除');\r
+define('_IM_DISPLAY_SUBDIR',   'サブ・ディレクトリ管理');\r
+define('_IM_DISPLAY_SUBDIR_TT',        'サブ・ディレクトリの管理画面に移動');\r
+define('_IM_DISPLAY_SUBDIR_SELECT',    '変 更');\r
+define('_IM_CREATE_SUBDIR_CONFIRM',    'サブ・ディレクトリ作成');\r
+define('_IM_CREATE_SUBDIR_COLLECTION_LABEL',   'コレクション・ディレクトリの指定');\r
+define('_IM_CREATE_SUBDIR_COLLECTION', 'サブ・ディレクトリを作成するコレクション・ディレクトリを指定してください');\r
+define('_IM_CREATE_SUBDIR_INPUT_NAME', 'サブ・ディレクトリのディレクトリ名');\r
+define('_IM_CREATE_SUBDIR_CHARS',      'サブ・ディレクトリ名に指定された以外の文字種が使われています');\r
+define('_IM_CREATE_SUBDIR_CHARS_DESC', 'サブ・ディレクトリ名に利用できる文字は、英数字と3種類の記号(アンダーバー、ハイフン、プラス)です。最長で20文字です。それ以外の文字種や日本語は使用できません。');\r
+define('_IM_RENAME_SUBDIR_BLANK',      'サブ・ディレクトリ名が空白です');\r
+define('_IM_RENAME_SUBDIR_TOOLONG',    'サブ・ディレクトリ名が20文字を超えています');\r
+define('_IM_RENAME_SUBDIR_WRONG',      'サブ・ディレクトリ名に指定された以外の文字種が使われています');\r
+define('_IM_RENAME_SUBDIR_DUPLICATE',  '同名のサブ・ディレクトリがすでに存在しています。');\r
+define('_IM_CREATE_SUBDIR_WRONG',      'サブ・ディレクトリが作成できませんので、サーバ管理者に相談してください');\r
+define('_IM_RENAME_SUBDIR_COLLECTION', '名前を変更するサブ・ディレクトリ');\r
+define('_IM_SUBDIR_NUM_FILES', 'ファイル数');\r
+define('_IM_DISPLAY_SUBDIR_LABEL1',    'サブ・ディレクトリ数: ');\r
+define('_IM_DISPLAY_SUBDIR_LABEL2',    ', ファイル数: ');\r
+define('_IM_DISPLAY_SUBDIR_RETURN',    'ファイル一覧');\r
+define('_IM_REMOVE_SUBIDR',    '削除するサブ・ディレクトリ');\r
+define('_IM_REMOVE_SUBIDR_CONFIRM',    'サブ・ディレクトリの削除の確認');\r
+define('_IM_REMOVE_SUBIDR_REMIND',     'サブ・ディレクトリを削除すると、中のファイルもすべて同時に削除されます。その際、すでにアイテム内に挿入されているコードは、この操作を行っても自動で書き換えられません。なお、コレクション・ディレクトリを削除することはできません。');\r
+define('_IM_REMOVE_SUBDIR_FAILED',     'サブ・ディレクトリの削除に失敗しています。サブ・ディレクトリもしくは含まれているファイルを確認してください。');\r
+define('_IM_DISPLAY_SUBDIR_CAPTION',   'サブ・ディレクトリ一覧');\r
+define('_IM_DISPLAY_SUBDIR_NOTHING',   'サブ・ディレクトリなし');\r
+define('_IM_SUBDIR_REMOVE_FAILED',     'サブ・ディレクトリの削除に失敗しました。サブ・ディレクトリのアクセス権限もしくはサブ・ディレクトリ内のファイルのアクセス権限を確認して下さい。');\r
+define('_IM_SUBDIR_FAILED_READ',       'サブ・ディレクトリ情報の取得に失敗しました。アクセス権限を確認して下さい');\r
+?>
\ No newline at end of file
diff --git a/NP_ImprovedMedia/improvedmedia/popups.css b/NP_ImprovedMedia/improvedmedia/popups.css
new file mode 100755 (executable)
index 0000000..ce5c6ec
--- /dev/null
@@ -0,0 +1,163 @@
+/**\r
+ * ImprovedMedia plugin for Nucleus CMS\r
+ * Version 3.0.1\r
+ * Written By Mocchi, Feb.28, 2010\r
+ * \r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 3\r
+ * of the License, or (at your option) any later version.\r
+ */\r
+* {\r
+ margin: 0px;\r
+ padding: 0px;\r
+}\r
+\r
+body {\r
+ margin: 10px;\r
+ font-family: verdana, arial;\r
+ font-size: small;\r
+ background-color: #ffffff;\r
+ color: #3F3F3F;\r
+}\r
+\r
+img {\r
+ border: none;\r
+}\r
+\r
+a:link,a:visited {\r
+ color: #1D3565;\r
+ font-weight: bold;\r
+ text-decoration: none;\r
+ border-bottom: dotted 1px #808080;\r
+}\r
+\r
+a:hover {\r
+ border-bottom: dotted 1px #808080;\r
+}\r
+\r
+p {\r
+ margin: 4px 0px 4px 20px;\r
+}\r
+\r
+p.line {\r
+ margin-left: 100px;\r
+}\r
+\r
+h1 {\r
+ font-size: large;\r
+ color: #596D9D;\r
+ margin-bottom: 3px;\r
+}\r
+\r
+span.header {\r
+ color: gray;\r
+ font-size: small;\r
+}\r
+\r
+h2 {\r
+ font-size: medium;\r
+ color: #596D9D;\r
+ margin: 0.5em 0em 0.5em 0em;\r
+}\r
+\r
+h3 {\r
+ color: #596D9D;\r
+ font-size: small;\r
+ margin: 10px 10px 5px 10px;\r
+}\r
+\r
+table {\r
+ border: none;\r
+}\r
+\r
+table caption {\r
+ padding: 3px;\r
+ text-align: left;\r
+ font-weight: bold;\r
+}\r
+\r
+thead {\r
+ background-color: linen;\r
+}\r
+\r
+tbody {\r
+ background-color: #DDDDDD;\r
+}\r
+\r
+tfoot {\r
+ background-color: #FFFFFF;\r
+}\r
+\r
+th, td {\r
+ vertical-align: middle;\r
+ font-size: small;\r
+ font-weight: normal;\r
+}\r
+\r
+th {\r
+ margin: 0px;\r
+}\r
+\r
+td {\r
+ padding: 3px;\r
+ margin: 0px;\r
+}\r
+\r
+th p, td p {\r
+ margin:0px;\r
+ padding: 0px;\r
+}\r
+\r
+td.right {\r
+ text-align: right;\r
+}\r
+\r
+label {\r
+ cursor: pointer;\r
+}\r
+\r
+input.formbutton {\r
+ font-size: x-small;\r
+ padding: 1px;\r
+ background-color: #BFBFBF;\r
+}\r
+\r
+dt {\r
+ font-weight: bold;\r
+}\r
+\r
+dd {\r
+ margin: 0px 0px 5px 10px;\r
+}\r
+\r
+div.filedetail {\r
+ margin: 5px;\r
+ border: 1px solid #333333;\r
+ padding: 5px 10px 5px 10px;\r
+}\r
+\r
+form {\r
+ display: inline;\r
+}\r
+\r
+form p.left {\r
+ display: inline;\r
+ width: 8em;\r
+ float: left;\r
+}\r
+\r
+form p.right {\r
+ margin: 0px;\r
+ padding: 5px 0px 0px 0px;\r
+}\r
+\r
+p.notice {\r
+ font-weight: bold;\r
+ font-size: large;\r
+ color: #FF5A00;\r
+}\r
+\r
+option {\r
+ width: 120px;\r
+}
\ No newline at end of file
diff --git a/NP_MediaUtils/NP_MediaUtils.php b/NP_MediaUtils/NP_MediaUtils.php
new file mode 100755 (executable)
index 0000000..a59d12a
--- /dev/null
@@ -0,0 +1,122 @@
+<?php\r
+/**\r
+ * MediaUtils plugin for Nucleus CMS\r
+ * Version 0.9.6 (1.0 RC2) for PHP5\r
+ * Written By Mocchi, Apr. 04, 2011\r
+ * \r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 3\r
+ * of the License, or (at your option) any later version.\r
+ */\r
+\r
+class NP_MediaUtils extends NucleusPlugin {\r
+       public function getName()                       { return 'MediaUtils'; }\r
+       public function getAuthor()             { return 'Mocchi'; }\r
+       public function getURL()                        { return 'http://japan.nucleuscms.org/wiki/plugins:mediautils'; }\r
+       public function getVersion()            { return '0.9.6 (1.0 RC2)'; }\r
+       public function getDescription()        { return 'Load MediaUtils, static function set for media management. Another function of this plugin is keeping Cookies for identifying weblog id.'; }\r
+       \r
+       public function getMinNucleusVersion()  { return 340; }\r
+       public function supportsFeature($feature) { return in_array ($feature, array ('SqlTablePrefix', 'SqlApi')); }\r
+       public function getEventList()  { return array('PostAuthentication', 'InitSkinParse', 'PreSendContentType'); }\r
+       \r
+       /*\r
+        * NOTICE: Event drivened method can get a correct blogid in initSkinParse.\r
+        */\r
+       public function event_PostAuthentication($data) {\r
+               global $CONF;\r
+               static $blogid = 0;\r
+               static $blogs = array();\r
+               \r
+               if (!class_exists('MediaUtils', FALSE)) {\r
+                       include ($this->getDirectory() . 'MediaUtils.php');\r
+               }\r
+               \r
+               MediaUtils::$lib_path = preg_replace('#/*$#', '', $this->getDirectory());\r
+               MediaUtils::$prefix = (boolean) $CONF['MediaPrefix'];\r
+               MediaUtils::$maxsize = (integer) $CONF['MaxUploadSize'];\r
+               \r
+               $suffixes = explode(',', $CONF['AllowedTypes']);\r
+               foreach ($suffixes as $suffix) {\r
+                       $suffix = trim($suffix);\r
+                       if(!in_array($suffix, MediaUtils::$suffixes)) {\r
+                               MediaUtils::$suffixes[] = strtolower($suffix);\r
+                       }\r
+               }\r
+               \r
+               $result = sql_query('SELECT bnumber, bshortname FROM ' . sql_table('blog') . ';');\r
+               while(FALSE !== ($row = sql_fetch_assoc($result))) {\r
+                       $blogs[$row['bnumber']] = $row['bshortname'];\r
+               }\r
+               MediaUtils::$blogs = $blogs;\r
+               \r
+               if (array_key_exists('blogid', $_GET)) {\r
+                       $blogid = (integer) $_GET['blogid'];\r
+               } else if (array_key_exists('blogid', $_POST)) {\r
+                       $blogid = (integer) $_POST['blogid'];\r
+               } else if (array_key_exists('itemid', $_GET)) {\r
+                       $blogid = (integer) getBlogIDFromItemID((integer) $_GET['itemid']);\r
+               } else if (array_key_exists('itemid', $_POST)) {\r
+                       $blogid = (integer) getBlogIDFromItemID((integer) $_POST['itemid']);\r
+               } else if (array_key_exists(MediaUtils::$cookiename, $_COOKIE)) {\r
+                       $blogid = (integer) $_COOKIE['blogid'];\r
+               }\r
+               \r
+               if (!$blogid || !array_key_exists($blogid, $blogs)) {\r
+                       self::setCookie(-1);\r
+                       return;\r
+               }\r
+               \r
+               MediaUtils::$blogid = (integer) $blogid;\r
+               MediaUtils::$bshortname = (string) $blogs[$blogid];\r
+               self::setCookie(1);\r
+               \r
+               return;\r
+       }\r
+       \r
+       public function event_PreSendContentType($data) {\r
+               global $blog, $blogid;\r
+               if (MediaUtils::$blogid) {\r
+                       return;\r
+               }\r
+               \r
+               if (!$blogid && !$blog) {\r
+                       self::setCookie(-1);\r
+                       return;\r
+               }\r
+               \r
+               if (!$blogid) {\r
+                       MediaUtils::$blogid = $blog->getID();\r
+               } else {\r
+                       MediaUtils::$blogid = $blogid;\r
+               }\r
+               \r
+               if (!$blog) {\r
+                       MediaUtils::$bshortname = $manager->getBlog(MediaUtils::$blogid)->getShortName();\r
+               } else {\r
+                       MediaUtils::$bshortname = $blog->getShortName();\r
+               }\r
+               \r
+               self::setCookie(1);\r
+               return;\r
+       }\r
+       \r
+       public function event_InitSkinParse($data) {\r
+               global $blogid;\r
+               if (MediaUtils::$blogid != $blogid) {\r
+                       MediaUtils::$blogid = $blogid;\r
+                       MediaUtils::$bshortname = MediaUtils::$blogs[MediaUtils::$blogid];\r
+                       self::setCookie(1);\r
+               }\r
+               return;\r
+       }\r
+       \r
+       private function setCookie($factor) {\r
+               global $CONF;\r
+               $factor = (integer) $factor;\r
+               \r
+               setcookie($CONF['CookiePrefix'] . MediaUtils::$cookiename, MediaUtils::$blogid, time()+180*$factor, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);\r
+               return;\r
+       }\r
+}\r
diff --git a/NP_MediaUtils/mediautils/MediaUtils.php b/NP_MediaUtils/mediautils/MediaUtils.php
new file mode 100755 (executable)
index 0000000..0766c01
--- /dev/null
@@ -0,0 +1,490 @@
+<?php
+/**
+ * MediaUtils plugin for Nucleus CMS
+ * Version 0.9.6 (1.0 RC2) for PHP5
+ * Written By Mocchi, Apr. 04, 2011
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ */
+
+class MediaUtils {
+       static public $lib_path = '';
+       
+       static public $cookiename = 'blogid';
+       static public $blogid = FALSE;
+       static public $blogs = array();
+       static public $bshortname = '';
+       
+       static public $prefix = TRUE;
+       static public $maxsize = 2097152;
+       static public $suffixes = array();
+       
+       static public $algorism = 'md5';
+       static public $image_mime
+               = array('image/jpeg'    => '.jpeg',
+                               'image/png'     => '.png',
+                       /*      'image/bmp'     => '.bmp', not implemented*/
+                               'image/gif'     => '.gif');
+       
+/**
+ * error and exit
+ * @access     Public  MediaUtils::error
+ * @param      String  $message                Error message
+ * @exit       
+ */
+       static public function error ($message) {
+               (string)        $message;
+               header("HTTP/1.0 404 Not Found");
+               exit($message);
+       }
+       
+/**
+ * send resampled image via HTTP
+ * @access     Public  MediaUtils::responseResampledImage
+ * @param      Object  $medium         Medium Object
+ * @exit       
+ */
+       static public function responseResampledImage ($medium) {
+               if (!class_exists('Medium', FALSE)) {
+                       include(self::$lib_path . '/Medium.php');
+               }
+               
+               if ('Medium' !== get_class($medium)) {
+                       self::error ('NP_MediaUtils: Fail to generate resampled image');
+                       return;
+               }
+               
+               if (FALSE === ($resampledimage = $medium->getResampledBinary(self::$image_mime))) {
+                       unset ($resampledimage);
+                       self::error ('NP_MediaUtils: Fail to generate resampled image');
+                       return;
+               }
+               
+               header ('Content-type: ' . $medium->mime);
+               echo $resampledimage;
+               unset ($resampledimage);
+               exit;
+       }
+       
+/**
+ * Store resampled image binary to filesystem as file
+ * @access     Public  MediaUtils::storeResampledImage
+ * @param      String  $root                   root directory for media
+ * @param      String  $path                   Relative path from root to destination
+ * @param      Object  $medium         Medium Object
+ * @return     Boolean TRUE/FALSE
+ */
+       static public function storeResampledImage ($root, $target, $medium) {
+               if (!class_exists('Medium', FALSE)) {
+                       include(self::$lib_path . '/Medium.php');
+               }
+               
+               if ('Medium' !== get_class($medium)) {
+                       return FALSE;
+               }
+               
+               if (FALSE === ($resampledimage = $medium->getResampledBinary(self::$image_mime))) {
+                       unset ($resampledimage);
+                       return FALSE;
+               }
+               
+               if (FALSE === ($handle = @fopen ("{$root}/{$target}", 'w'))) {
+                       unset ($resampledimage);
+                       return FALSE;
+               }
+               
+               if (@fwrite ($handle, $resampledimage) === FALSE) {
+                       unset ($resampledimage);
+                       @unlink ("{$root}/{$target}");
+                       return FALSE;
+               }
+               
+               unset ($resampledimage);
+               fclose ($handle);
+               
+               if (@chmod ("{$root}/{$target}", 0744) === FALSE) {
+                       @unlink ("{$root}/{$target}");
+                       return FALSE;
+               }
+               
+               return TRUE;
+       }
+       
+/**
+ * Check the path as directory and writable
+ * @access     Public  MediaUtils::checkDir
+ * @param      String  Fullpath
+ * @return     Boolean TRUE/FALSE
+ */
+       static public function checkDir ($fullpath) {
+               $fullpath = (string) $fullpath;
+               
+               if (file_exists ($fullpath)) {
+                       if (is_dir ($fullpath) && is_writable ($fullpath)) {
+                               return TRUE;
+                       } else {
+                               return FALSE;
+                       }
+               } else {
+                       if (!@mkdir ($fullpath, 0777)) {
+                               return FALSE;
+                       } else {
+                               return TRUE;
+                       }
+               }
+       }
+       
+/**
+ * Return file data list
+ * @access     Public  MediaUtils::getMediaList
+ * @param      String  $root           path to media root directory
+ * @param      Boolean $hidden show hidden files (.*) or not
+ * @param      Boolean $recursive      follow recursively or not
+ * @param      Boolean $prefix analyze its prefix or not
+ * @param      String  $suffix limit by suffix
+ * @param      String  $path           relative path from root to destination
+ * @return     Array           Array(Medium)
+ */
+       static public function getMediaList ($root, $hidden=TRUE, $recursive=TRUE, $suffix='', $path='', $media=array()) {
+               $root           = (string)      $root;
+               $hidden = (boolean) $hidden;
+               $recursive      = (boolean) $recursive;
+               $suffix = (string) $suffix;
+               $path           = (string) $path;
+               $media  = (array) $media;
+               
+               if (!class_exists('Medium', FALSE)) {
+                       include(self::$lib_path . '/Medium.php');
+               }
+               
+               $root = rtrim($root, '/');
+               if(!$root || !file_exists($root)) {
+                       return FALSE;
+               }
+               
+               $fullpath = $root;
+               if ($path) {
+                       $path = trim($path, '/');
+                       $fullpath = "{$root}/{$path}";
+               }
+               
+               if (FALSE === ($handle = @opendir($fullpath))) {
+                       return FALSE;
+               }
+               while(FALSE !== ($filename = readdir($handle))) {
+                       if ($filename !== '.' && $filename !== '..') {
+                               if (($hidden && preg_match("#^\.#", $filename))
+                                || ($suffix && !preg_match("#\.$suffix$#", $filename))) {
+                                       continue;
+                               }
+                               
+                               if($recursive && filetype("{$fullpath}/{$filename}") === "dir") {
+                                       $media = self::getMediaList($root, $hidden, $recursive, $suffix, trim("{$path}/{$filename}", '/'), $media);
+                               } else if ($path !== '' && filetype("{$fullpath}/{$filename}") === "file") {
+                                       $media[] = new Medium($root, trim("{$path}/{$filename}", '/'), self::$prefix);
+                                       continue;
+                               }
+                       }
+               }
+               closedir($handle);
+               return $media;
+       }
+       
+/*
+ * Purge directory
+ * @access     Public  MediaUtils::purgeDir
+ * @param      String  $root           path to media root directory
+ * @param      String  $path           relative path from root to destination
+ * @return     Array/FALSE             $logs           
+ * 
+ */
+       static public function purgeDir($root, $path='', $logs=array()) {
+               $root   = (string) $root;
+               $path   = (string) $path;
+               $logs   = (array) $logs;
+               
+               $root = rtrim($root, '/');
+               if(!$root || !file_exists($root)) {
+                       return FALSE;
+               }
+               
+               $fullpath = $root;
+               if ($path) {
+                       $path = trim($path, '/');
+                       $fullpath = "{$root}/{$path}";
+               }
+               
+               if (FALSE === ($handle = @opendir($fullpath))) {
+                       return FALSE;
+               }
+               while(FALSE !== ($filename = readdir($handle))) {
+                       if ($filename !== '.' && $filename !== '..') {
+                               if(filetype("{$fullpath}/{$filename}") === "dir") {
+                                       $logs = self::purgeDir($root, "{$path}/{$filename}", $logs);
+                               } else {
+                                       if(!unlink("{$root}/{$path}/{$filename}")) {
+                                               $logs[] = "Exists: {$path}/{$filename}";
+                                       } else {
+                                               $logs[] = "Removed: {$path}/{$filename}";
+                                       }
+                                       continue;
+                               }
+                       }
+               }
+               if(!rmdir("{$root}/{$path}")) {
+                       $logs[] = "Exists: {$path}";
+               } else {
+                       $logs[] = "Removed: {$path}";
+               }
+               return $logs;
+       }
+
+/*
+ * Return path list under root
+ * @access     Public  MediaUtils::getPathList
+ * @param      String  $root           full path to root directory
+ * @param      String  $path           certain path to search
+ * @param      Boolean $private        use private directory or not
+ * @param      Boolean $recursize      search recursively or not
+ * @param      Boolean $hidden do not list up the directory started with piriod or not
+ * @return     String  $name   
+ * 
+ */
+       static public function getPathList($root, $path='', $private=FALSE, $hidden=TRUE, $recursive=TRUE) {
+               $root           = (string) $root;
+               $path           = (string) $path;
+               $hidden = (boolean) $hidden;
+               $recursive = (boolean) $recursive;
+               
+               $paths=array();
+               
+               $root = rtrim($root, '/');
+               if(!$root || !file_exists($root)) {
+                       return FALSE;
+               }
+               
+               $fullpath = $root;
+               if ($path) {
+                       $path = trim($path, '/');
+                       $fullpath = "{$root}/{$path}";
+               }
+               
+               if (FALSE === ($handle = @opendir($fullpath))) {
+                       return FALSE;
+               }
+               while (FALSE !== ($filename = readdir($handle))) {
+                       if (in_array($filename, array('.', '..', 'CVS'))) {
+                               continue;
+                       } else if (is_file("{$fullpath}/{$filename}")) {
+                               continue;
+                       } else if ($hidden && preg_match('#^\.#', $filename)) {
+                               continue;
+                       } else if ($private && is_numeric($filename) && $path==''&& $private != $filename) {
+                               continue;
+                       }
+                       
+                       if (!$path) {
+                               $relpath = $filename;
+                       } else {
+                               $relpath = "{$path}/{$filename}";
+                       }
+                       
+                       $paths = self::getPathData($root, $relpath, $private, $hidden, $recursive, $paths);
+               }
+               closedir($handle);
+               
+               if ($path=='' && $private) {
+                       if (!array_key_exists($private, $paths)) {
+                               $paths[$private] = array('root'=>$root , 'path'=>$private, 'files'=>0, 'dirs'=>0);
+                       }
+                       $paths[$private]['label'] = 'PRIVATE';
+               }
+               
+               ksort($paths, SORT_STRING);
+               return $paths;
+       }
+       
+/*
+ * Return path data
+ * @access     Public  MediaUtils::getPathData
+ * @param      String  $root                   full path to root directory
+ * @param      String  $path                   relative path from root to target directory
+ * @param      Boolean $private                use private directory or not
+ * @param      Boolean $hidden         do not list up the directory started with piriod or not
+ * @param      Boolean $recursive      search recursively or not
+ * @return     Array           Array('root', 'parent', 'name', 'files', 'dirs', 'label')
+ */
+       static public function getPathData($root, $path, $private=FALSE, $hidden=TRUE, $recursive=FALSE, $paths=array()) {
+               $root           = (string)      $root;
+               $path           = (string)      $path;
+               $private        = (boolean) $private;
+               $hidden = (boolean) $hidden;
+               $recursive = (boolean) $recursive;
+               
+               $cnt_files = 0;
+               $cnt_dirs = 0;
+               
+               $root = rtrim($root, '/');
+               if(!$root || !file_exists($root)) {
+                       return FALSE;
+               }
+               
+               $fullpath = $root;
+               if ($path) {
+                       $path = trim($path, '/');
+                       $fullpath = "{$root}/{$path}";
+               }
+               
+               if (FALSE === ($handle = @opendir($fullpath))) {
+                       return FALSE;
+               }
+               while (FALSE !== ($filename = readdir($handle))) {
+                       if (in_array($filename, array('.', '..', 'CVS'))) {
+                               continue;
+                       } else if (!is_dir("{$fullpath}/{$filename}")) {
+                               if (!$hidden || !preg_match('#^\.#', $filename)){
+                                       $cnt_files++;
+                               }
+                               continue;
+                       } else if ($hidden && preg_match('#^\.#', $filename)) {
+                               continue;
+                       }
+                       
+                       $cnt_dirs++;
+                       
+                       if (!$path) {
+                               $relpath = $filename;
+                       } else {
+                               $relpath = "{$path}/{$filename}";
+                       }
+                       
+                       if ($recursive) {
+                               $paths = self::getPathData($root, $relpath, $private, $recursive, $hidden, $paths);
+                       }
+               }
+               closedir($handle);
+               
+               $paths[$path]['root'] = $root;
+               $paths[$path]['parent'] = trim(str_replace(basename($fullpath), '', $path), '/');
+               $paths[$path]['name'] = basename($fullpath);
+               $paths[$path]['files'] = $cnt_files;
+               $paths[$path]['dirs'] = $cnt_dirs;
+               if ($private) {
+                       $paths[$path]['label'] = preg_replace("#^$private#", 'PRIVATE', $path);
+               } else {
+                       $paths[$path]['label'] = $path;
+               }
+               
+               return $paths;
+       }
+       
+/*
+ * Store uploaded binary to filesystem
+ * @access     Public  MediaUtils::uploadMedium
+ * @param      String  $root                   path to edia root directory
+ * @param      String  $path                   relative path from root to target directory
+ * @param      Array           $medium         uploaded binary data.
+ * @param      String/FALSE    $overwrite      overwrite or not if the file already exists
+ * @param      Object  $manager                Nucleus Manager Object
+ * @return     String  $log                    Return '' if success, others is error messages
+ * 
+ */
+       static public function uploadMedium ($root, $path, &$temp, $overwrite='', &$manager='') {
+               $root    = (string) $root;
+               $path    = (string) $path;
+               $temp = (array) $temp;
+               $overwrite = (string) $overwrite;
+               $manager = (object) $manager;
+               
+               /**
+                * $temp should be derived from $_FILE
+                */
+               foreach(array('name', 'tmp_name','size', 'error') as $key) {
+                       if (!array_key_exists($key, $temp)) {
+                               return 'NP_MediaUtils: Miss uploaded file.';
+                       }
+               }
+               
+               $root = rtrim($root, '/');
+               if(!$root || !file_exists($root) || !$path) {
+                       return 'NP_MediaUtils: Destination is invalid.';
+               }
+               $path = trim($path, '/');
+               
+               /**
+                * see http://www.php.net/manual/en/features.file-upload.errors.php
+                */
+               switch ($temp['error']) {
+                       case UPLOAD_ERR_OK:
+                               break;
+                       case UPLOAD_ERR_INI_SIZE:
+                       case UPLOAD_ERR_FORM_SIZE:
+                               return 'NP_MediaUtils: Binary is too big.';
+                       case UPLOAD_ERR_PARTIAL:
+                       case UPLOAD_ERR_NO_FILE:
+                       case UPLOAD_ERR_NO_TMP_DIR:
+                       case UPLOAD_ERR_CANT_WRITE:
+                       case UPLOAD_ERR_EXTENSION :
+                       default:
+                               return 'NP_MediaUtils: Request rejected';
+               }
+               
+               if (preg_match ("#(\\\\|/|\\n)#", $temp['name'])) {
+                       return 'NP_MediaUtils: invalid filename';
+               }
+               
+               if ($temp['size'] > self::$maxsize) {
+                       return 'NP_MediaUtils: Binary is too big';
+               }
+               
+               if (!empty(self::$suffixes) && is_array(self::$suffixes)) {
+                       preg_match("#\.(.+)$#", $temp['name'], $match);
+                       $suffix = strtolower($match[1]);
+                       if (!in_array($suffix, self::$suffixes)) {
+                               return 'NP_MediaUtils: Forbidden file suffix';
+                       }
+               }
+               
+               if (!self::checkDir("{$root}/{$path}")) {
+                       return 'NP_MediaUtils: Invalid target directory';
+               }
+               
+               if ($overwrite) {
+                       if (!preg_match("#\.($suffix)$#", strtolower($overwrite), $match)) {
+                               return 'NP_MediaUtils: suffix is not the same.';
+                       }
+                       $temp['name'] = $overwrite;
+               } else if (self::$prefix) {
+                       $temp['name'] = strftime ("%Y%m%d-", time ()) . $temp['name'];
+               }
+               
+               if (!$overwrite && file_exists("{$root}/{$path}/{$temp['name']}")) {
+                       return 'NP_MediaUtils: The same filename already exists in this target directory.';
+               }
+               
+               if ($manager) {
+                       $manager->notify('PreMediaUpload',array('collection' => &$path, 'uploadfile' => $temp['tmp_name'], 'filename' => $temp['name']));
+               }
+               
+               if (is_uploaded_file($temp['tmp_name'])) {
+                       if (!@move_uploaded_file($temp['tmp_name'], "{$root}/{$path}/{$temp['name']}")) {
+                                       return 'NP_MediaUtils: Fail to move uploaded binary to file sytem.';
+                       }
+               } else if (!copy($temp['tmp_name'], "{$root}/{$path}/{$temp['name']}")) {
+                               return 'NP_MediaUtils: Fail to copy uploaded binary to file sytem.';
+               }
+               
+               $oldumask = umask(0000);
+               @chmod("{$root}/{$path}/{$temp['name']}", 0644);
+               umask($oldumask);
+               
+               if ($manager) {
+                       $manager->notify('PostMediaUpload',array('collection' => $path, 'mediadir' => $root, 'filename' => $temp['name']));
+               }
+               
+               return '';
+       }
+}
diff --git a/NP_MediaUtils/mediautils/Medium.php b/NP_MediaUtils/mediautils/Medium.php
new file mode 100755 (executable)
index 0000000..2ab43f0
--- /dev/null
@@ -0,0 +1,229 @@
+<?php
+/**
+ * MediaUtils plugin for Nucleus CMS
+ * Version 0.9.6 (1.0 RC2) for PHP5
+ * Written By Mocchi, Apr. 04, 2011
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ */
+
+class Medium  {
+       public $root = '';
+       public $path = '';
+       public $name = '';
+       public $update = '';
+       public $prefix = '';
+       public $suffix = '';
+       public $filename = '';
+       public $size = 0;
+       public $mime = '';
+       public $width = 0;
+       public $height = 0;
+       public $resampledwidth = 0;
+       public $resampledheight = 0;
+       
+/**
+ * Return MEDIUM Object
+ * @access     Public  $this->__construnct
+ * @param      String  $root
+ * @param      String  $relativepath
+ * @param      Boolean $prefix
+ * @return     Object/FALSE
+ */
+       public function __construct ($root, $relativepath, $prefix) {
+               static $fullpath;
+               static $info;
+               
+               if ($root == '' || $relativepath == '') {
+                       return FALSE;
+               }
+               
+               $root = preg_replace('#/*$#', '', $root);
+               if ($root == '' || $relativepath == ''
+                || !file_exists($root)
+                || FALSE === ($fullpath = realpath(rtrim($root . '/' . ltrim($relativepath, '/'), '/')))
+                || strpos($fullpath, $root) !== 0
+                || !file_exists($fullpath)) {
+                       return FALSE;
+               }
+               
+               $this->root = $root;
+               $this->name = basename($fullpath);
+               $this->path = str_replace(array($this->root.'/', '/'.$this->name), '', $fullpath);
+               
+               if ($this->path === $this->name) {
+                       $this->path = ''; 
+               }
+               
+               if (FALSE === ($info = @getimagesize ($fullpath))) {
+                       $this->mime = 'application/octet-stream';
+                       $this->width = 0;
+                       $this->height = 0;
+               } else {
+                       $this->mime = $info['mime'];
+                       $this->width = $info[0];
+                       $this->height = $info[1];
+               }
+               
+               set_time_limit(ini_get('max_execution_time'));
+               if (defined('FILEINFO_MIME_TYPE')
+                && function_exists ('finfo_open')
+                && (FALSE !== ($info = finfo_open(FILEINFO_MIME_TYPE)))) {
+                       $this->mime = finfo_file($info, $fullpath);
+               }
+               
+               $this->update = date("Y/m/d", @filemtime($fullpath));
+               $this->size = ceil(filesize($fullpath) / 1000);
+               
+               if (preg_match('#^(.*)\.([a-zA-Z0-9]{2,})$#', $this->name, $info) === 1) {
+                       $this->filename = $info[1];
+                       $this->suffix = $info[2];
+                       if ($prefix && preg_match('#^([0-9]{8})\-(.*)$#', $this->filename, $info) == 1 ) {
+                               $this->prefix = preg_replace('#^([0-9]{4})([0-9]{2})([0-9]{2})$#', '$1/$2/$3', $info[1]);
+                               $this->filename = $info[2];
+                       }
+               }
+               
+               return $this;
+       }
+       
+       public function __destruct () {
+               return;
+       }
+       
+/**
+ * Set resampled size
+ * @access     Public  $this->setResampledSize
+ * @param      Integer $maxwidth
+ * @param      Integer $maxheight
+ * @return     Boolean
+ */
+       public function setResampledSize($maxwidth=0, $maxheight=0) {
+               if (($maxwidth == 0) && ($maxheight == 0)) {
+                       return FALSE;
+               } else if ($this->width == 0 || $this->height  == 0) {
+                       return FALSE;
+               } else if ($this->width < $maxwidth && $this->height < $maxheight) {
+                       $this->resampledwidth = $this->width;
+                       $this->resampledheight = $this->height;
+               } else if ($maxheight == 0 || $this->width > $this->height) {
+                       $this->resampledheight = intval ($this->height * $maxwidth / $this->width);
+                       $this->resampledwidth = $maxwidth;
+               } else if ($maxwidth == 0 || $this->width <= $this->height) {
+                       $this->resampledwidth = intval ($this->width * $maxheight / $this->height);
+                       $this->resampledheight = $maxheight;
+               }
+               return TRUE;
+       }
+       
+/**
+ * Return resampled image binary
+ * @access     Public  $this->getResampledSize
+ * @param      Integer $maxwidth
+ * @param      Integer $maxheight
+ * @return     Boolean
+ */
+       public function getResampledBinary ($image_mime) {
+               static $gdinfo;
+               static $original;
+               static $resampledimage;
+               
+               $gdinfo = gd_info();
+               
+               if ($this->path !== '') {
+                       $fullpath = "{$this->root}/{$this->path}/{$this->name}";
+               } else {
+                       $fullpath = "{$this->root}/{$this->name}";
+               }
+               if (!file_exists($fullpath)) {
+                       return FALSE;
+               }
+               
+               if (!array_key_exists($this->mime, $image_mime)
+                || $this->width == 0
+                || $this->height == 0
+                || $this->resampledwidth == 0
+                || $this->resampledheight == 0) {
+                       return FALSE;
+               }
+               
+               // check current available memory
+               $memorymax = trim(ini_get("memory_limit"));
+               switch (strtolower ($memorymax[strlen($memorymax)-1])) {
+                case 'g':
+                $memorymax *= 1024;
+                case 'm':
+                $memorymax *= 1024;
+                case 'k':
+                $memorymax *= 1024;
+               }
+               
+               // this code is based on analyze if gd.c in php source code
+               // if you can read C/C++, please check these elements and notify us if you have some ideas
+               if ((memory_get_usage() + ($this->resampledwidth * $this->resampledheight * 5 + $this->resampledheight * 24 + 10000) + ($this->width * $this->height * 5 + $this->height * 24 + 10000)) > $memorymax) {
+                       return FALSE;
+               }
+               
+               switch ($this->mime) {
+                       case 'image/gif':
+                               if (!$gdinfo['GIF Read Support'] && !$gdinfo['GIF Create Support']) {
+                                       return FALSE;
+                               }
+                               $original = imagecreatefromgif ($fullpath);
+                               break;
+                       case 'image/jpeg':
+                               if ((array_key_exists('JPEG Support', $gdinfo) && !$gdinfo['JPEG Support']) && (array_key_exists('JPG Support', $gdinfo) && $gdinfo['JPG Support'])) {
+                                       return FALSE;
+                               }
+                               $original = imagecreatefromjpeg ($fullpath);
+                               break;
+                       case 'image/png':
+                               if (!$gdinfo['PNG Support']) {
+                                       return FALSE;
+                               }
+                               $original = imagecreatefrompng ($fullpath);
+                               break;
+                       default:
+                               return FALSE;
+               }
+               
+               $resampledimage = imagecreatetruecolor ($this->resampledwidth, $this->resampledheight);
+               
+               if (!$resampledimage) {
+                       return FALSE;
+               }
+               
+               set_time_limit(ini_get('max_execution_time'));
+               if (!ImageCopyResampled ($resampledimage, $original, 0, 0, 0, 0, $this->resampledwidth, $this->resampledheight, $this->width, $this->height)) {
+                       return FALSE;
+               }
+               
+               imagedestroy ($original);
+               
+               ob_start();
+               
+               switch ($this->mime) {
+                case 'image/gif':
+                 imagegif ($resampledimage);
+                 break;
+                case 'image/jpeg':
+                 imagejpeg ($resampledimage);
+                 break;
+                case 'image/png':
+                 imagepng ($resampledimage);
+                 break;
+                default:
+               }
+               
+               imagedestroy ($resampledimage);
+               
+               return ob_get_clean();
+       }
+       
+       public function getHashedName($algorism) {
+               return (string) hash($algorism, "{$this->path}/{$this->name}", FALSE);
+       }
+}
diff --git a/NP_Thumbnail/NP_Thumbnail.php b/NP_Thumbnail/NP_Thumbnail.php
new file mode 100755 (executable)
index 0000000..b73f456
--- /dev/null
@@ -0,0 +1,529 @@
+<?php
+/**
+ * Thumbnail plugin for Nucleus CMS
+ * Version 3.9.6 (4.0 RC2) for PHP5
+ * Written By Mocchi, Apr. 04, 2011
+ * Original code was written by jirochou, May 23, 2004 and maintained by nakahara21
+ * This plugin depends on NP_MediaUtils
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ */
+
+class NP_Thumbnail extends NucleusPlugin {
+       private static $thumbdir        = '.thumb';
+       private static $max_sync        = 10;
+       private static $authorid        = 0;
+       private static $buffering       = FALSE;
+       private static $table_name      = 'plugin_thumbnail'; // not implemented
+       
+       public function getName()                       { return 'Thumbnail'; }
+       public function getAuthor()             { return 'Mocchi, nakahara21, jirochou'; }
+       public function getURL()                        { return 'http://japan.nucleuscms.org/wiki/plugins:thumbnail'; }
+       public function getVersion()            { return '3.9.6 (4.0 RC2)'; }
+       public function getDescription()        { return _NP_THUMBNAIL_01; }
+       public function getPluginDep()  { return array('NP_MediaUtils');}
+       public function getMinNucleusVersion()  {return 340;}
+       public function supportsFeature($feature) { return in_array ($feature, array('SqlTablePrefix', 'SqlApi'));}
+       public function getEventList()  { return array('QuickMenu', 'PrePluginOptionsEdit', 'PostAuthentication', 'PreItem', 'PostMediaUpload'); }
+       
+       public function install () {
+               $this->createOption('maxwidth', '_NP_THUMBNAIL_02', 'text', '100', 'datatype=numerical');
+               $this->createOption('maxheight', '_NP_THUMBNAIL_03', 'text', '100', 'datatype=numerical');
+               $this->createOption('save_thumb', '_NP_THUMBNAIL_04', 'select', 'filesystem', '_NP_THUMBNAIL_05|no|_NP_THUMBNAIL_06|filesystem');
+               $this->createBlogOption('force_thumb', '_NP_THUMBNAIL_07', 'yesno', 'yes');
+               $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>');
+               return;
+       }
+       
+       /*
+        * plugin options are purged automatically when uninstalled.
+        */
+       public function uninstall() {
+               global $DIR_MEDIA;
+               MediaUtils::purgeDir($DIR_MEDIA . self::$thumbdir);
+               return;
+       }
+       
+       public function init() {
+               global $DIR_MEDIA;
+               
+               if (!class_exists('Medium', FALSE)) {
+                       include(MediaUtils::$lib_path . '/Medium.php');
+               }
+               
+               $language = preg_replace('#[/|\\\\]#', '', getLanguageName());
+               
+               if (!defined('_NP_THUMBNAIL_01')) {
+                       if (file_exists($this->getDirectory() . $language.'.php')) {
+                               include($this->getDirectory() . $language.'.php');
+                       } else {
+                               include($this->getDirectory() . 'english.php');
+                       }
+               }
+               return;
+       }
+       
+/*
+ * for translation
+ */
+       public function event_PrePluginOptionsEdit ($data) {
+               if ($data['context'] != 'global') {
+                       foreach($data['options'] as $key => $option) {
+                               if ($option['pid'] == $this->getID()) {
+                                       if (defined($option['description'])) {
+                                               $data['options'][$key]['description'] = constant($option['description']);
+                                       }
+                                       if ($option['type'] == 'select') {
+                                               foreach (explode('|', $option['typeinfo']) as $option) {
+                                                       if (defined($option)) {
+                                                               $data['options'][$key]['typeinfo'] = str_replace($option, constant($option), $data['options'][$key]['typeinfo']);
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               } else if ($data['plugid'] == $this->getID()) {
+                       foreach($data['options'] as $key => $option){
+                               if (defined($option['description'])) {
+                                       $data['options'][$key]['description'] = constant($option['description']);
+                               }
+                               if ($option['type'] == 'select') {
+                                               foreach (explode('|', $option['typeinfo']) as $option) {
+                                                       if (defined($option)) {
+                                                               $data['options'][$key]['typeinfo'] = str_replace($option, constant($option), $data['options'][$key]['typeinfo']);
+                                                       }
+                                               }
+                               }
+                       }
+               }
+               return;
+       }
+       
+/*
+ * for translation
+ */
+       static private function t ($text, $array=array()){
+               if (is_array($array)) {
+                       $search = array();
+                       $replace = array();
+                       
+                       foreach ($array as $key => $value){
+                               if (is_array($value)) {
+                                       continue;
+                               }
+                               $search[] = '<%'.preg_replace('/[^a-zA-Z0-9_]+/','',$key).'%>';
+                               $replace[] = $value;
+                       }
+               }
+               return htmlspecialchars (str_replace($search, $replace, $text), ENT_QUOTES, _CHARSET);
+       }
+       
+       public function event_QuickMenu ($data) {
+               global $CONF;
+               if($this->getOption('save_thumb') !== 'no') {
+                       array_push(
+                               $data['options'],
+                               array (
+                                       'title'   => 'NP_Thumbnail',
+                                       'url'     => "{$CONF['ActionURL']}?action=plugin&name={$this->getname()}&type=admin",
+                                       'tooltip' => _NP_THUMBNAIL_09));
+               }
+               return;
+       }
+       
+       public function event_PostAuthentication ($data) {
+               if (array_key_exists('action', $_REQUEST)
+                && array_key_exists('name', $_REQUEST)
+                && array_key_exists('type', $_REQUEST)
+                && array_key_exists('width', $_REQUEST)
+                && array_key_exists('height', $_REQUEST)
+                && $_REQUEST['action'] === 'plugin'
+                && $_REQUEST['name'] === $this->getName()
+                && $_REQUEST['type'] !== '') {
+                       self::$buffering = ob_start;
+               }
+               return;
+       }
+       
+       public function doAction ($type) {
+               global $DIR_MEDIA, $member;
+               
+               $type = (string) $type;
+               
+               $path = '';
+               $maxwidth = '';
+               $maxheight = '';
+               
+               if (array_key_exists('path', $_GET)) {
+                       $path = (string)  $_GET['path'];
+               }
+               if (array_key_exists('width', $_GET)) {
+                       $maxwidth = (integer) $_GET['width'];
+               }
+               if (array_key_exists('height', $_GET)) {
+                       $maxheight = (integer) $_GET['height'];
+               }
+               
+               if (in_array($type, array('admin', 'clear', 'sync')) && $member->isAdmin()) {
+                       $this->showAdmin($type);
+                       exit;
+               }
+               
+               if (self::$buffering) {
+                       ob_end_clean();
+               }
+               
+               if ($maxwidth <= 0 || $maxwidth > 1000 || $maxheight <= 0 || $maxheight > 1000 ) {
+                       MediaUtils::error ($this->t(_NP_THUMBNAIL_10, array($maxwidth, $maxheight)));
+                       return;
+               }
+               
+               if (FALSE === ($medium = new Medium($DIR_MEDIA, $path, MediaUtils::$prefix))) {
+                       MediaUtils::error ($this->t(_NP_THUMBNAIL_11, array($path)));
+                       return;
+               }
+               
+               if (FALSE === $medium->setResampledSize($maxwidth, $maxheight)) {
+                       MediaUtils::error ($this->t(_NP_THUMBNAIL_10, array($maxwidth, $maxheight)));
+                       return;
+               }
+               
+               MediaUtils::responseResampledImage($medium);
+               return;
+       }
+       
+       public function doSkinVar ($skinType, $path, $maxwidth=0, $maxheight=0, $alt) {
+               $path = (string)  $path;
+               $maxwidth = (integer) $maxwidth;
+               $maxheight = (integer) $maxheight;
+               $alt = (string) $alt;
+               
+               if ($this->getBlogOption(MediaUtils::$blogid, 'force_thumb') == 'yes') {
+                       echo $this->getParsedTag(array('', '', $path, 0, 0, $alt), $maxwidth, $maxheight);
+               }
+               return;
+       }
+       
+       public function event_PreItem($data) {
+               $item =& $data["item"];
+               self::$authorid = $item->authorid;
+               $item->body = preg_replace_callback("#<\%(Thumbnail)\((.*?)\|(.*?)\|(.*?)\|(.*?)\)%\>#", array(&$this, 'getParsedTag'), $item->body);
+               $item->more = preg_replace_callback("#<\%(Thumbnail)\((.*?)\|(.*?)\|(.*?)\|(.*?)\)%\>#", array(&$this, 'getParsedTag'), $item->more);
+               
+               if ($this->getBlogOption(MediaUtils::$blogid, 'force_thumb') == 'yes') {
+                       $item->body = preg_replace_callback("#<\%(popup)\((.*?)\|(.*?)\|(.*?)\|(.*?)\)%\>#", array(&$this, 'getParsedTag'), $item->body);
+                       $item->more = preg_replace_callback("#<\%(popup)\((.*?)\|(.*?)\|(.*?)\|(.*?)\)%\>#", array(&$this, 'getParsedTag'), $item->more);
+               }
+               return;
+       }
+       
+       public function event_PostMediaUpload ($data) {
+               global $DIR_MEDIA;
+               if ($this->getOption('save_thumb') == 'no') {
+                       return;
+               }
+               
+               $root = rtrim($DIR_MEDIA, '/');
+               $path = trim($data['collection'], '/');
+               $filename = trim($data['filename'], '/');
+               $maxwidth  = $this->getOption('maxwidth');
+               $maxheight = $this->getOption('maxheight');
+               
+               if (!MediaUtils::checkDir ($root . '/' . self::$thumbdir)) {
+                       return;
+               }
+               
+               if (FALSE === ($medium = new Medium($root, "{$path}/{$filename}", MediaUtils::$prefix))) {
+                       return;
+               }
+               
+               if (!array_key_exists($medium->mime, MediaUtils::$image_mime)) {
+                       return;
+               }
+               
+               if (FALSE === $medium->setResampledSize($maxwidth, $maxheight)) {
+                       return;
+               }
+               
+               $target = $this->getThumbPath($medium);
+               
+               if ($this->getOption('save_thumb') == 'filesystem') {
+                       if (!file_exists("{$root}/{$target}")
+                               && !MediaUtils::storeResampledImage ($DIR_MEDIA, $target, $medium)) {
+                               return;
+                       }
+               }
+               
+               return;
+       }
+       
+       public function getParsedTag ($match, $maxwidth=0, $maxheight=0) {
+               global $DIR_MEDIA, $member;
+               
+               list($code, $tag, $path, $width, $height, $alt) = $match;
+               
+               if (!preg_match("#^.+?/.+$#", $path) && self::$authorid) {
+                       $path = self::$authorid . '/' . $path;
+               }
+               
+               if (FALSE === ($medium = new Medium($DIR_MEDIA, $path, MediaUtils::$prefix))) {
+                       return $this->t('NP_Thumbnail: 指定したメディアファイルを読み込めませんでした。', array($path));
+               }
+               
+               if (!array_key_exists($medium->mime, MediaUtils::$image_mime)) {
+                       return $this->t(_NP_THUMBNAIL_12, array($path));
+               }
+               
+               if ($tag == 'Thumbnail') {
+                       $maxwidth  = (integer) $width;
+                       $maxheight = (integer) $height;
+               }
+               
+               if (($maxwidth == 0) && ($maxheight == 0)) {
+                       $maxwidth  = (integer) $this->getOption('maxwidth');
+                       $maxheight = (integer) $this->getOption('maxheight');
+               }
+               
+               if ($maxwidth < 0 || $maxwidth > 1000 || $maxheight < 0 || $maxheight > 1000) {
+                       return $this->t(_NP_THUMBNAIL_10, array($path));
+               }
+               
+               if (FALSE === $medium->setResampledSize($maxwidth, $maxheight)) {
+                       return $this->t('NP_Thumbnail: サムネイルのサイズが不正です。', array($path));
+               }
+               
+               if (!$alt) {
+                       $alt =& $path;
+               }
+               
+               return $this->generateTag($this->getBlogOption(MediaUtils::$blogid, 'thumb_template'), $medium, $alt);
+       }
+       
+       public function generateTag($template, $medium, $alt) {
+               global $DIR_LIBS;
+               
+               if (!class_exists('BODYACTIONS', FALSE)) {
+                       include($DIR_LIBS . 'BODYACTIONS.php');
+               }
+               $action = new BODYACTIONS;
+               
+               if (array_key_exists($medium->mime, MediaUtils::$image_mime)
+                && $this->getOption('save_thumb') == 'filesystem') {
+                       if (!MediaUtils::checkDir ($medium->root . '/' . self::$thumbdir)) {
+                               return $this->t(_NP_THUMBNAIL_13, array(self::$thumbdir));
+                       }
+                       if (!file_exists("{$medium->root}/{$this->getThumbPath($medium)}")) {
+                               MediaUtils::storeResampledImage ($medium->root, $this->getThumbPath($medium), $medium);
+                       }
+               }
+               
+               ob_start();
+               if (array_key_exists($medium->mime, MediaUtils::$image_mime) && $this->getThumbURL($medium)) {
+                       $action->template['POPUP_CODE'] = $template;
+                       $replacements = array(
+                               '<%thumb_width%>' => $medium->resampledwidth,
+                               '<%thumb_height%>' => $medium->resampledheight,
+                               '<%thumb_url%>' => $this->getThumbURL($medium)
+                       );
+                       foreach ($replacements as $target => $replacement) {
+                               $action->template['POPUP_CODE'] = str_replace ($target, $replacement, $action->template['POPUP_CODE']);
+                       }
+                       $action->createPopupCode ("{$medium->path}/{$medium->name}", $medium->width, $medium->height, $alt);
+               } else {
+                       $action->template['MEDIA_CODE'] = $template;
+                       $action->createMediaCode("{$medium->path}/{$medium->name}", $alt);
+               }
+               $tag = ob_get_contents();
+               ob_get_clean();
+               
+               return preg_replace('#href="(.*?)imagetext(.*?)"#', 'href="$1imagetext$2&amp;blogid='.MediaUtils::$blogid . '"', $tag);
+       }
+       
+       private function showAdmin ($type) {
+               global $CONF, $DIR_LIBS, $DIR_MEDIA, $manager;
+               
+               $type = (string) $type;
+               
+               if (!class_exists ('PLUGINADMIN', FALSE)) {
+                       include ($DIR_LIBS . 'PLUGINADMIN.php');
+               }
+               
+               $oPluginAdmin = new PluginAdmin('Thumbnail');
+               $oPluginAdmin->start();
+               
+               echo "<h2>NP_Thumbnail</h2>\n";
+               
+               if($this->getOption('save_thumb') === 'no') {
+                       echo '<p>' . $this->t(_NP_THUMBNAIL_14) . "</p>\n";
+                       $oPluginAdmin->end();
+                       return;
+               }
+               
+               if ($type == 'clear') {
+                       if ($this->getOption('save_thumb') == 'filesystem') {
+                               $logs = MediaUtils::purgeDir($DIR_MEDIA, self::$thumbdir . '/');
+                       }
+               } else if ($type == 'sync') {
+                       $maxwidth = $this->getOption('maxwidth');
+                       $maxheight = $this->getOption('maxheight');
+                       if ($this->getOption('save_thumb') == 'filesystem') {
+                               $logs = $this->syncFilesystem ($DIR_MEDIA, self::$thumbdir, $maxwidth, $maxheight);
+                       }
+               } else {
+                       $logs = array ();
+               }
+               
+               $media = MediaUtils::getMediaList($DIR_MEDIA);
+               $elected = array();
+               $rejected = array();
+               
+               foreach ($media as $medium) {
+                       if (!array_key_exists($medium->mime, MediaUtils::$image_mime)) {
+                               continue;
+                       }
+                       if (file_exists ($DIR_MEDIA . $this->getThumbPath($medium))) {
+                               $rejected[] = &$medium;
+                               continue;
+                       } else {
+                               $elected[] = &$medium;
+                               continue;
+                       }
+               }
+               
+               $total_media = count ($media);
+               $total_elected = count ($elected);
+               $total_rejected = count ($rejected);
+               $total_candidates = count ($rejected) + $total_elected;
+               
+               echo "<p>" . $this->t(_NP_THUMBNAIL_15, array(self::$thumbdir)) . "<br />\n";
+               echo $this->t(_NP_THUMBNAIL_16, array(self::$max_sync)) . "<br />\n";
+               echo $this->t(_NP_THUMBNAIL_17) . "</p>\n";
+               
+               /*
+                * NOTICE: NP_Improvededia with eachblogdir option rewrite
+                * global variables of "DIR_MEDIA" and "$CONF['MediaURL']"
+                * in its initializing process.
+                * Here are based on its rewriting system.
+                */
+               if ($manager->pluginInstalled('NP_ImprovedMedia')) {
+                       $NP_ImprovedMedia =& $manager->getPlugin('NP_ImprovedMedia');
+                       if ($NP_ImprovedMedia->getOption('IM_EACHBLOGDIR') == 'yes') {
+                               echo "<form method=\"post\" action=\"{$CONF['ActionURL']}?action=plugin&name=Thumbnail\" enctype=\"application/x-www-form-urlencoded\">\n";
+                               echo "<p>\n";
+                               echo "<label for=\"blogid\">サムネイル作成対象のウェブログ</label>\n";
+                               echo "<select name=\"blogid\" id=\"blogid\"onchange=\"return form.submit()\">\n";
+                               foreach(MediaUtils::$blogs as $blogid => $bshortname) {
+                                       if ($blogid == MediaUtils::$blogid) {
+                                               echo "<option value=\"{$blogid}\" selected=\"selected\">{$bshortname}</option>\n";
+                                       } else {
+                                               echo "<option value=\"{$blogid}\">{$bshortname}</option>\n";
+                                       }
+                               }
+                               echo "</select>\n";
+                               echo "<input type=\"hidden\" id=\"admin\" name=\"type\" value=\"admin\">\n";
+                               echo "</p>\n";
+                               echo "</form>\n";
+                       }
+               }
+               
+               echo "<form method=\"post\" action=\"{$CONF['ActionURL']}?action=plugin&name=Thumbnail\" enctype=\"application/x-www-form-urlencoded\">\n";
+               echo "<ul>\n";
+               echo "<li>" . $this->t(_NP_THUMBNAIL_18, array($total_media)) . "</li>\n";
+               echo "<li>" . $this->t(_NP_THUMBNAIL_19, array($total_candidates)) . "</li>\n";
+               echo "<li>" . $this->t(_NP_THUMBNAIL_20, array($total_rejected)) . "</li>\n";
+               echo "</ul>\n";
+               echo "<p>\n";
+               echo '<input type="hidden" name="blogid" value="' . MediaUtils::$blogid . '">' . "\n";
+               echo "<input type=\"submit\" id=\"sync\" name=\"type\" value=\"sync\">\n";
+               echo "<input type=\"submit\" id=\"clear\" name=\"type\" value=\"clear\">\n";
+               echo "</p>\n";
+               
+               if ($logs) {
+                       echo "<h3>" . $this->t(_NP_THUMBNAIL_21) . "</h3>\n";
+                       echo "<ul>\n";
+                       
+                       foreach ($logs as $log) {
+                               echo "<li>{$log}</li>\n";
+                       }
+                       echo "</ul>\n";
+               }
+               echo "</form>\n";
+               
+               $oPluginAdmin->end();
+               return;
+       }
+       
+       public function syncFilesystem ($root, $dest, $maxwidth, $maxheight) {
+               $logs = array ();
+               
+               $root = rtrim($root, '/');
+               if(!$root || !file_exists($root)) {
+                       return FALSE;
+               }
+               
+               if (!MediaUtils::checkDir(rtrim($root, '/') . '/' . trim($dest, '/'))) {
+                       return FALSE;
+               }
+               
+               $media = MediaUtils::getMediaList($root);
+               $targets = array();
+               $count = 1;
+               
+               foreach ($media as $medium) {
+                       if ($count > self::$max_sync) {
+                               break;
+                       }
+                       
+                       if (!array_key_exists ($medium->mime, MediaUtils::$image_mime)) {
+                               continue;
+                       }
+                       
+                       if (FALSE === $medium->setResampledSize($maxwidth, $maxheight)) {
+                               continue;
+                       }
+                       
+                       $destination = $this->getThumbPath($medium);
+                       
+                       if (!file_exists (rtrim($root, '/') . '/' . $destination)) {
+                               if (!MediaUtils::storeResampledImage ($root, $destination, $medium)) {
+                                       $logs[] = "Fail: {$medium->name}";
+                               } else {
+                                       $logs[] = "Success: {$medium->name}";
+                               }
+                               $count++;
+                       }
+               }
+               return $logs;
+       }
+       
+       public function getThumbPath($medium) {
+               if ('Medium' !== get_class($medium)) {
+                       return FALSE;
+               }
+               return self::$thumbdir . '/' . $medium->getHashedName(MediaUtils::$algorism) . MediaUtils::$image_mime[$medium->mime];
+       }
+       
+       public function getThumbURL($medium) {
+               global $CONF, $DIR_MEDIA;
+               
+               if ('Medium' !== get_class($medium)) {
+                       return FALSE;
+               }
+               
+               if (($medium->width < $medium->resampledwidth && $medium->height < $medium->resampledheight)
+                || ($medium->width <= $this->getOption('maxwidth') && $medium->height <= $this->getOption('maxheight'))) {
+                       $url = "{$CONF['MediaURL']}{$medium->path}/{$medium->name}";
+               } else if ($medium->resampledwidth > $this->getOption('maxwidth') && $medium->resampledheight > $this->getOption('maxheight')) {
+                       $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;
+               } else if (file_exists($DIR_MEDIA . $this->getThumbPath($medium))) {
+                       $url = "{$CONF['MediaURL']}{$this->getThumbPath($medium)}";
+               } else {
+                       $url = FALSE;
+               }
+               return $url;
+       }
+}
+
diff --git a/NP_Thumbnail/thumbnail/english.php b/NP_Thumbnail/thumbnail/english.php
new file mode 100755 (executable)
index 0000000..ce240c4
--- /dev/null
@@ -0,0 +1,35 @@
+<?php\r
+/**\r
+ * Thumbnail plugin for Nucleus CMS\r
+ * Version 3.9.6 (4.0 RC2) for PHP5\r
+ * Written By Mocchi, Apr. 04, 2011\r
+ * Original code was written by jirochou, May 23, 2004 and maintained by nakahara21\r
+ * This plugin depends on NP_MediaUtils\r
+ * \r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 3\r
+ * of the License, or (at your option) any later version.\r
+ */\r
+\r
+define ('_NP_THUMBNAIL_01', 'Show thumbnail image on <%Thumbnail%> or <%popup%>, depends on NP_MediaUtils');\r
+define ('_NP_THUMBNAIL_02', 'Maxmum width of thumbnail');\r
+define ('_NP_THUMBNAIL_03', 'Maxmum height of thumbnail');\r
+define ('_NP_THUMBNAIL_04', 'Store thumbnail');\r
+define ('_NP_THUMBNAIL_05', 'No Need');\r
+define ('_NP_THUMBNAIL_06', 'Filesystem');\r
+define ('_NP_THUMBNAIL_07', 'Change <%popup%> to thumbnail');\r
+define ('_NP_THUMBNAIL_08', 'Template for <%Thumbnail%> or <%popup%>');\r
+define ('_NP_THUMBNAIL_09', 'Thumbnail Images Management');\r
+define ('_NP_THUMBNAIL_10', 'Invalid parameter of <%0%> and <%1%>');\r
+define ('_NP_THUMBNAIL_11', 'Fail to read <%0%>');\r
+define ('_NP_THUMBNAIL_12', 'Fail to generate thumbnail from <%0%>');\r
+define ('_NP_THUMBNAIL_13', 'Fail to create <%0%> for store of thumbnails');\r
+define ('_NP_THUMBNAIL_14', 'This function is not allowed.');\r
+define ('_NP_THUMBNAIL_15', 'Thumbnails is generated in <%0%> on Media directory.');\r
+define ('_NP_THUMBNAIL_16', 'One session generates <%0%> thumbnails.');\r
+define ('_NP_THUMBNAIL_17', 'There is a possibility to fail to generate thumbnail if original image is too large.');\r
+define ('_NP_THUMBNAIL_18', '<%0%> files is in this media directory.');\r
+define ('_NP_THUMBNAIL_19', '<%0%> files can generate its own thumbnail.');\r
+define ('_NP_THUMBNAIL_20', '<%0%> thumbnails already generated');\r
+define ('_NP_THUMBNAIL_21', 'Logs');\r
diff --git a/NP_Thumbnail/thumbnail/index.html b/NP_Thumbnail/thumbnail/index.html
new file mode 100755 (executable)
index 0000000..498e4ea
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>Notice</title>
+</head>
+<body>
+<h1>Notice</h1>
+<p>Nothing to see here</p>
+</body>
+</html>
\ No newline at end of file
diff --git a/NP_Thumbnail/thumbnail/japanese-euc.php b/NP_Thumbnail/thumbnail/japanese-euc.php
new file mode 100755 (executable)
index 0000000..a349052
--- /dev/null
@@ -0,0 +1,35 @@
+<?php\r
+/**\r
+ * Thumbnail plugin for Nucleus CMS\r
+ * Version 3.9.6 (4.0 RC2) for PHP5\r
+ * Written By Mocchi, Apr. 04, 2011\r
+ * Original code was written by jirochou, May 23, 2004 and maintained by nakahara21\r
+ * This plugin depends on NP_MediaUtils\r
+ * \r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 3\r
+ * of the License, or (at your option) any later version.\r
+ */\r
+\r
+define ('_NP_THUMBNAIL_01', '<%Thumbnail%>¤Þ¤¿¤Ï<%popup%>¤Ç¥µ¥à¥Í¥¤¥ëɽ¼¨¤ò¤·¤Þ¤¹¡£¥×¥é¥°¥¤¥ó¡ÖNP_MediaUtils¡×¤È°Í¸´Ø·¸¤ò»ý¤Á¤Þ¤¹');\r
+define ('_NP_THUMBNAIL_02', '¥µ¥à¥Í¥¤¥ë¤Î²£Éý¤ÎºÇÂçÃÍ');\r
+define ('_NP_THUMBNAIL_03', '¥µ¥à¥Í¥¤¥ë¤Î½ÄÉý¤ÎºÇÂçÃÍ');\r
+define ('_NP_THUMBNAIL_04', '¥µ¥à¥Í¥¤¥ë²èÁü¤òÊݸ¤·¤Þ¤¹');\r
+define ('_NP_THUMBNAIL_05', '¤¤¤¤¤¨');\r
+define ('_NP_THUMBNAIL_06', '¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à');\r
+define ('_NP_THUMBNAIL_07', '¥¿¥°<%popup%>¤ò¥µ¥à¥Í¥¤¥ë¤Ë¤·¤Þ¤¹');\r
+define ('_NP_THUMBNAIL_08', '¥¿¥°<%Thumbnail%>¤¢¤ë¤¤¤Ï<%popup%>¤òÃÖ¤­´¹¤¨¤ëºÝ¤Î¥Æ¥ó¥×¥ì¡¼¥È');\r
+define ('_NP_THUMBNAIL_09', '¥µ¥à¥Í¥¤¥ë²èÁü¤Î´ÉÍý');\r
+define ('_NP_THUMBNAIL_10', 'NP_Thumbnail: ¥Ñ¥é¥á¡¼¥¿<%0%>¤È<%1%>¤¬ÉÔÀµ¤Ç¤¹');\r
+define ('_NP_THUMBNAIL_11', 'NP_Thumbnail: Í׵ᤷ¤¿¥Õ¥¡¥¤¥ë<%0%>¤òÆɤ߹þ¤á¤Þ¤»¤ó');\r
+define ('_NP_THUMBNAIL_12', 'NP_Thumbnail: <%0%>¤Ï¥µ¥à¥Í¥¤¥ë¤òºîÀ®¤Ç¤­¤Ê¤¤¥Õ¥¡¥¤¥ë¤Ç¤¹');\r
+define ('_NP_THUMBNAIL_13', 'NP_Thumbnail: ¥µ¥à¥Í¥¤¥ëÍѥǥ£¥ì¥¯¥È¥ê<%0%>¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Æ¤¤¤Þ¤¹');\r
+define ('_NP_THUMBNAIL_14', '¸½ºß¤Ï¥µ¥à¥Í¥¤¥ë¥Õ¥¡¥¤¥ë¤ò¥µ¡¼¥Ð¤ËÊݸ¤·¤Ê¤¤ÀßÄê¤È¤Ê¤Ã¤Æ¤¤¤ë¤¿¤á¡¢¤³¤Î²èÌ̤ǽÐÍè¤ë¤³¤È¤Ï¤¢¤ê¤Þ¤»¤ó¡£');\r
+define ('_NP_THUMBNAIL_15', '¥µ¥à¥Í¥¤¥ë¤Ï¥á¥Ç¥£¥¢Íѥǥ£¥ì¥¯¥È¥ê¤Î<%0%>¤ËºîÀ®¤µ¤ì¤Þ¤¹');\r
+define ('_NP_THUMBNAIL_16', '¸½ºß¤Ï1²ó¤¢¤¿¤ê<%0%>Ëç¤Î¥µ¥à¥Í¥¤¥ë¤òºîÀ®¤¹¤ë¤è¤¦¤ËÀßÄꤵ¤ì¤Æ¤¤¤Þ¤¹');\r
+define ('_NP_THUMBNAIL_17', '¤¢¤Þ¤ê¤Ë½Ä²£¥µ¥¤¥º¤ÎÂ礭¤Ê²èÁü¤Ï¥µ¥à¥Í¥¤¥ë¤¬ºîÀ®¤Ç¤­¤Ê¤¤¾ì¹ç¤¬¤¢¤ê¤Þ¤¹');\r
+define ('_NP_THUMBNAIL_18', '¸½ºß<%0%>¤Î¥á¥Ç¥£¥¢¤¬ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Þ¤¹');\r
+define ('_NP_THUMBNAIL_19', '¤½¤Î¤¦¤Á¡¢<%0%>¤Î²èÁü¤Î¥µ¥à¥Í¥¤¥ë¤¬ºîÀ®²Äǽ¤Ç¤¹');\r
+define ('_NP_THUMBNAIL_20', '¤½¤Î¤¦¤Á¡¢<%0%>¤Î²èÁü¤Î¥µ¥à¥Í¥¤¥ë¤¬¤¹¤Ç¤ËºîÀ®¤µ¤ì¤Æ¤¤¤Þ¤¹¡£');\r
+define ('_NP_THUMBNAIL_21', '¥í¥°');\r
diff --git a/NP_Thumbnail/thumbnail/japanese-utf8.php b/NP_Thumbnail/thumbnail/japanese-utf8.php
new file mode 100755 (executable)
index 0000000..65238e4
--- /dev/null
@@ -0,0 +1,35 @@
+<?php\r
+/**\r
+ * Thumbnail plugin for Nucleus CMS\r
+ * Version 3.9.6 (4.0 RC2) for PHP5\r
+ * Written By Mocchi, Apr. 04, 2011\r
+ * Original code was written by jirochou, May 23, 2004 and maintained by nakahara21\r
+ * This plugin depends on NP_MediaUtils\r
+ * \r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 3\r
+ * of the License, or (at your option) any later version.\r
+ */\r
+\r
+define ('_NP_THUMBNAIL_01', '<%Thumbnail%>または<%popup%>でサムネイル表示をします。プラグイン「NP_MediaUtils」と依存関係を持ちます');\r
+define ('_NP_THUMBNAIL_02', 'サムネイルの横幅の最大値');\r
+define ('_NP_THUMBNAIL_03', 'サムネイルの縦幅の最大値');\r
+define ('_NP_THUMBNAIL_04', 'サムネイル画像を保存します');\r
+define ('_NP_THUMBNAIL_05', 'いいえ');\r
+define ('_NP_THUMBNAIL_06', 'ファイルシステム');\r
+define ('_NP_THUMBNAIL_07', 'タグ<%popup%>をサムネイルにします');\r
+define ('_NP_THUMBNAIL_08', 'タグ<%Thumbnail%>あるいは<%popup%>を置き換える際のテンプレート');\r
+define ('_NP_THUMBNAIL_09', 'サムネイル画像の管理');\r
+define ('_NP_THUMBNAIL_10', 'NP_Thumbnail: パラメータ<%0%>と<%1%>が不正です');\r
+define ('_NP_THUMBNAIL_11', 'NP_Thumbnail: 要求したファイル<%0%>を読み込めません');\r
+define ('_NP_THUMBNAIL_12', 'NP_Thumbnail: <%0%>はサムネイルを作成できないファイルです');\r
+define ('_NP_THUMBNAIL_13', 'NP_Thumbnail: サムネイル用ディレクトリ<%0%>の作成に失敗しています');\r
+define ('_NP_THUMBNAIL_14', '現在はサムネイルファイルをサーバに保存しない設定となっているため、この画面で出来ることはありません。');\r
+define ('_NP_THUMBNAIL_15', 'サムネイルはメディア用ディレクトリの<%0%>に作成されます');\r
+define ('_NP_THUMBNAIL_16', '現在は1回あたり<%0%>枚のサムネイルを作成するように設定されています');\r
+define ('_NP_THUMBNAIL_17', 'あまりに縦横サイズの大きな画像はサムネイルが作成できない場合があります');\r
+define ('_NP_THUMBNAIL_18', '現在<%0%>のメディアが登録されています');\r
+define ('_NP_THUMBNAIL_19', 'そのうち、<%0%>の画像のサムネイルが作成可能です');\r
+define ('_NP_THUMBNAIL_20', 'そのうち、<%0%>の画像のサムネイルがすでに作成されています。');\r
+define ('_NP_THUMBNAIL_21', 'ログ');\r