From: sakamocchi Date: Sat, 20 Oct 2012 00:44:04 +0000 (+0900) Subject: ADD: Mocchiが手がけたファイル管理プラグイン一式をコミット X-Git-Url: http://git.osdn.net/view?p=nucleus-jp%2Fnucleus-plugins.git;a=commitdiff_plain;h=352fb8238c9004b36f81760777b7965178869b19 ADD: Mocchiが手がけたファイル管理プラグイン一式をコミット 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 --- diff --git a/NP_Attach/NP_Attach.php b/NP_Attach/NP_Attach.php new file mode 100755 index 0000000..0cf61b0 --- /dev/null +++ b/NP_Attach/NP_Attach.php @@ -0,0 +1,530 @@ +createOption('maxwidth', '_NP_ATTACH_02', 'text', '90', 'datatype=numerical'); + $this->createOption('maxheight', '_NP_ATTACH_03', 'text', '90', 'datatype=numerical'); + $this->createOption('admin_popup_template', '_NP_ATTACH_04', 'textarea', '<%popuptext%>'); + $this->createOption('admin_media_template', '_NP_ATTACH_05', 'textarea', '<%text%>'); + $this->createBlogOption('amount', '_NP_ATTACH_06', 'text', '3'); + $this->createBlogOption('blog_image_template', '_NP_ATTACH_07', 'textarea', '<%text%>'); + $this->createBlogOption('blog_media_template', '_NP_ATTACH_08', 'textarea', '<%text%>'); + $this->createItemOption('media', '_NP_ATTACH_09', 'text', ''); + return; + } + + public function uninstall () { + return; + } + + public function init() { + if(!defined('_NP_ATTACH_01')) { + $language = preg_replace('#[/|\\\\]#', '', getLanguageName()); + 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); + } + +/* + * Change enctype attribute of form element as 'multipart/form-data' + * Insert interface + */ + public function event_AdminPrePageHead ($data) { + if (!in_array ($data['action'], array ('createitem', 'itemedit'))) { + return; + } + + self::prepareEnctype (); + return; + } + + public function event_BookmarkletExtraHead ($data) { + self::prepareEnctype (); + return; + } + + public function event_AddItemFormExtras ($data) { + global $DIR_MEDIA; + $blog = $data['blog']; + self::$blogid = $blog->blogid; + self::$itemid = 0; + self::setEnctype (); + $this->setData($DIR_MEDIA); + $this->showInterface (); + return; + } + + public function event_EditItemFormExtras ($data) { + global $DIR_MEDIA; + $blog = $data['blog']; + self::$blogid = $blog->blogid; + self::$itemid = $data['itemid']; + self::setEnctype (); + $this->setData($DIR_MEDIA); + $this->showInterface (); + return; + } + +/* + * Process upload and update plugin item option + */ + public function event_PreAddItem ($data) { + self::$blogid = $data['blog']->blogid; + return; + } + public function event_PreUpdateItem ($data) { + self::$blogid = $data['blog']->blogid; + return; + } + public function event_PostAddItem ($data) { + self::$itemid = $data['itemid']; + return; + } + public function event_PostUpdateItem ($data) { + self::$itemid = $data['itemid']; + return; + } + public function event_PrePluginOptionsUpdate ($data) { + global $DIR_MEDIA, $member; + + if ($data['plugid'] != $this->getID () || $data['optionname'] != 'media') { + return; + } + + $this->setData($DIR_MEDIA); + self::batchRequest ($DIR_MEDIA, $member->getID()); + + $value = ''; + foreach (self::$data as $datum) { + if (!$datum['path']) { + continue; + } + $value .= "{$datum['path']}:{$datum['alt']}:{$datum['way']};"; + } + + $data['value'] = $value; + return; + } + +/* + * Show media in item + */ + public function event_PreItem($data) { + global $DIR_MEDIA; + self::$blogid =& $data['blog']->blogid; + self::$itemid =& $data["item"]->itemid; + $this->setData($DIR_MEDIA); + + $data["item"]->body = preg_replace_callback("#<\%Attach\((.+?)(,.+?)?(,.+?)?\)%\>#", array(&$this, 'getParsedTag'), $data["item"]->body); + $data["item"]->more = preg_replace_callback("#<\%Attach\((.+?)(,.+?)?(,.+?)?\)%\>#", array(&$this, 'getParsedTag'), $data["item"]->more); + return; + } + public function doTemplateVar($item, $mediumid) { + global $DIR_MEDIA, $blogid; + + if (!self::$itemid || !self::$blogid) { + self::$blogid = $blogid; + self::$itemid = $item->itemid; + $this->setData($DIR_MEDIA); + } + $this->getParsedTag(array('item', $mediumid)); + return; + } + + private function getParsedTag($match) { + global $DIR_MEDIA, $manager; + + $maxwidth = 0; + $maxheight = 0; + if (array_key_exists(3, $match)) { + $maxheight = (integer) trim($match[3], ','); + } + if (array_key_exists(2, $match)) { + $maxwidth = (integer) trim($match[2], ','); + } + + $data = &self::$data; + $mediumid = $match[1]; + $mediumid--; + + if (!array_key_exists ($mediumid, $data) || !$data[$mediumid]['path']) { + return; + } + + $NP_Thumbnail =& $manager->getPlugin('NP_Thumbnail'); + + if ($maxwidth==0 && $maxheight==0) { + $maxwidth = $NP_Thumbnail->getOption('maxwidth'); + $maxheight = $NP_Thumbnail->getOption('maxheight'); + } + + if (FALSE === ($medium = new MEDIUM($DIR_MEDIA, $data[$mediumid]['path'], MediaUtils::$prefix))) { + return; + } + + if (array_key_exists($medium->mime, MediaUtils::$image_mime) + && !$medium->setResampledSize($maxwidth, $maxheight)) { + return; + } + + if (!array_key_exists($medium->mime, MediaUtils::$image_mime) + || $data[$mediumid]['way'] == 'anchor') { + $template = $this->getBlogOption(self::$blogid, 'blog_media_template'); + } else if ($data[$mediumid]['way'] == 'original') { + $template = $this->getBlogOption(self::$blogid, 'blog_image_template'); + } else { + $template = $NP_Thumbnail->getBlogOption(self::$blogid, 'thumb_template'); + } + return $NP_Thumbnail->generateTag($template, $medium, $data[$mediumid]['alt']); + } + + private function showInterface () { + global $CONF, $DIR_LIBS, $DIR_MEDIA, $manager; + + if (!class_exists('BODYACTIONS', FALSE)) { + include ($DIR_LIBS . 'BODYACTIONS.php'); + } + $action = new BODYACTIONS; + + if (!$manager->pluginInstalled('NP_Thumbnail')) { + return; + } + $NP_Thumbnail = &$manager->getPlugin('NP_Thumbnail'); + $maxwidth = $NP_Thumbnail->getOption('maxwidth'); + $maxheight = $NP_Thumbnail->getOption('maxheight'); + + if (!self::$amount) { + return; + } + + $data = self::$data; + + if (empty($data)) { + return; + } + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + for ($count = 0; $count < self::$amount; $count++) { + $id = $count + 1; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + + echo "\n"; + echo "
" . _NP_ATTACH_10 . "" . _NP_ATTACH_11 . "" . _NP_ATTACH_12 . "
\n"; + echo "\n"; + + if ($data[$count]['path']) { + echo "
\n"; + echo "\n"; + echo "\n"; + } + + echo "
\n"; + + if (!$data[$count]['path']) { + echo "
\n"; + } else { + if (FALSE === ($medium = new MEDIUM($DIR_MEDIA, $data[$count]['path'], MediaUtils::$prefix))) { + return; + } + + if (array_key_exists($medium->mime, MediaUtils::$image_mime) + && !$medium->setResampledSize($maxwidth, $maxheight)) { + return; + } + + if (array_key_exists($medium->mime, MediaUtils::$image_mime)) { + $template = $this->getOption('admin_popup_template'); + } else { + $template = $this->getOption('admin_media_template'); + } + + echo $NP_Thumbnail->generateTag($template, $medium, $data[$count]['alt']) . "
\n"; + echo "
\n"; + } + echo "\n"; + echo "
\n"; + + if ($data[$count]['path'] && !array_key_exists($data[$count]['mime'], MediaUtils::$image_mime)) { + echo "\n"; + echo _NP_ATTACH_14 . "\n"; + } else { + $thumbnail_checked = ""; + $original_checked = ""; + $anchor_checked = ""; + + if ($data[$count]['way'] == 'original') { + $original_checked = 'checked="checked"'; + } else if ($data[$count]['way'] == 'anchor') { + $anchor_checked = 'checked="checked"'; + } else { + $thumbnail_checked = 'checked="checked"'; + } + + echo "\n"; + echo "
\n"; + return; + } + + private function setData($root) { + if(self::$blogid === 0 || !self::$itemid === 0) { + return; + } + + self::$amount = $this->getBlogOption(self::$blogid, 'amount'); + $media = explode(';', $this->getitemOption (self::$itemid, 'media')); + $data = array(); + + for ($count = 0; $count < self::$amount; $count++) { + if((self::$itemid != 0) && array_key_exists ($count, $media) && !empty ($media[$count])) { + $medium = explode (':', $media[$count]); + $data[$count]['path'] = $medium[0]; + $data[$count]['alt'] = $medium[1]; + $data[$count]['way'] = $medium[2]; + + if (FALSE === ($file = new Medium($root, $data[$count]['path'], MediaUtils::$prefix))) { + $data[$count] = array ('path' => "", 'alt' => "", 'way' => ""); + } + + $data[$count]['mime'] = $file->mime; + $data[$count]['width'] = $file->width; + $data[$count]['height'] = $file->height; + } else { + $data[$count] = array ('path' => "", 'alt' => "", 'way' => ""); + } + } + + self::$data = $data; + return; + } + + static private function batchRequest($root, $collection) { + global $CONF, $manager; + $media = array (); + $paths = array (); + $alts = array (); + $ways = array (); + $deletes = array (); + + if (array_key_exists ('medium', $_FILES)) { + $media = $_FILES['medium']; + } + + if (array_key_exists ('path', $_POST)) { + $paths = $_POST['path']; + } + + if (array_key_exists ('alt', $_POST)) { + $alts = $_POST['alt']; + } + + if (array_key_exists ('way', $_POST)) { + $ways = $_POST['way']; + } + + if (array_key_exists ('delete', $_POST)) { + $deletes = $_POST['delete']; + } + + $data = &self::$data; + + if (!$manager->pluginInstalled('NP_Thumbnail')) { + return; + } + $NP_Thumbnail = &$manager->getPlugin('NP_Thumbnail'); + + foreach ($data as $key => $value) { + if ($media && array_key_exists ($key, $media['name']) && !empty ($media['name'][$key])) { + $medium = array (); + if (preg_match ("#(\\\\|/|\\n)#", $media['name'][$key])) { + $data[$key] = array ('path' => "", 'alt' => "", 'way' => ""); + continue; + } + + $medium['name'] = &$media['name'][$key]; + $medium['size'] = $media['size'][$key]; + $medium['tmp_name'] = $media['tmp_name'][$key]; + $medium['error'] = $media['error'][$key]; + + $result = MediaUtils::uploadMedium ($root, $collection, $medium, $medium['name'], $manager); + + if ($result) { + $data[$key]['path'] = ""; + $data[$key]['alt'] = $result . ' (' . $medium['name'] . ')'; + $data[$key]['way'] = ""; + continue; + } else { + $data[$key]['path'] = $collection . '/' . $medium['name']; + } + } else if (array_key_exists($key, $paths) && !empty ($paths[$key])) { + if (FALSE === ($medium = new MEDIUM($root, $paths[$key], MediaUtils::$prefix))) { + $data[$key] = array ('path' => "", 'alt' => "", 'way' => ""); + continue; + } + if ($deletes && array_key_exists ($key, $deletes) && $deletes[$key] == 1) { + if (@ unlink ($root . $paths[$key])) { + if (array_key_exists($medium->mime, MediaUtils::$image_mime)) { + @ unlink ($root . $NP_Thumbnail->getThumbPath($medium)); + } + $data[$key] = array ('path' => "", 'alt' => "", 'way' => ""); + continue; + } + } + } + + if (array_key_exists ($key, $alts) && $alts[$key] != $value['alt']) { + $data[$key]['alt'] = htmlspecialchars ($alts[$key], ENT_QUOTES, _CHARSET); + } + + if (array_key_exists ($key, $ways) && $ways[$key] != $value['way']) { + if (!in_array ($ways[$key], array ('thumbnail', 'original', 'anchor'))) { + $data[$key]['way'] = 'thumbnail'; + } else { + $data[$key]['way'] = $ways[$key]; + } + } + } + return; + } + + static private function prepareEnctype () { + self::$buffer = ob_start (); + return; + } + + static private function setEnctype () { + if (!self::$buffer) { + return; + } + $strings = ob_get_contents (); + ob_end_clean (); + $strings = preg_replace ('#action="(index.php|bookmarklet.php)"#', '$0 enctype="multipart/form-data"', $strings); + echo $strings; + return; + } +} diff --git a/NP_Attach/attach/english.php b/NP_Attach/attach/english.php new file mode 100755 index 0000000..202e305 --- /dev/null +++ b/NP_Attach/attach/english.php @@ -0,0 +1,31 @@ + can show these files on item.'); +define('_NP_ATTACH_02', 'Maximum width for thumbnail on item edit page'); +define('_NP_ATTACH_03', 'Maximum height for thumbnail on item edit page'); +define('_NP_ATTACH_04', 'Template for thumbnail on item edit page'); +define('_NP_ATTACH_05', 'Template for normal file on item edit page'); +define('_NP_ATTACH_06', 'Maximum number of files on an item'); +define('_NP_ATTACH_07', 'Template for original image on weblog. Template for thumbnail is based on NP_Thumbnail.'); +define('_NP_ATTACH_08', 'Template for normal file on weblog.'); +define('_NP_ATTACH_09', 'Media Information'); +define('_NP_ATTACH_10', 'Tag'); +define('_NP_ATTACH_11', 'Media file and alternative text'); +define('_NP_ATTACH_12', 'Way to embed'); +define('_NP_ATTACH_13', 'Erase'); +define('_NP_ATTACH_14', 'Anchor'); +define('_NP_ATTACH_15', 'Anchor'); +define('_NP_ATTACH_16', 'Thumbnail'); +define('_NP_ATTACH_17', 'Original'); diff --git a/NP_Attach/attach/index.html b/NP_Attach/attach/index.html new file mode 100755 index 0000000..dd9f433 --- /dev/null +++ b/NP_Attach/attach/index.html @@ -0,0 +1,11 @@ + + + +Nothing Here + + + +

Nothing to see here

+ + + \ 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 index 0000000..593d9ee --- /dev/null +++ b/NP_Attach/attach/japanese-euc.php @@ -0,0 +1,31 @@ +¤Ç¥¢¥¤¥Æ¥àÃæ¤Ëɽ¼¨¤Ç¤­¤Þ¤¹'); +define('_NP_ATTACH_02', '´ÉÍý²èÌ̤Ëɽ¼¨¤¹¤ë¥µ¥à¥Í¥¤¥ë¤Î²£Éý¤ÎºÇÂçÃÍ'); +define('_NP_ATTACH_03', '´ÉÍý²èÌ̤Ëɽ¼¨¤¹¤ë¥µ¥à¥Í¥¤¥ë¤Î½ÄÉý¤ÎºÇÂçÃÍ'); +define('_NP_ATTACH_04', '´ÉÍý²èÌ̤Ëɽ¼¨¤¹¤ë½Ì¾®²èÁü¤Î¥Æ¥ó¥×¥ì¡¼¥È'); +define('_NP_ATTACH_05', '´ÉÍý²èÌ̤Ëɽ¼¨¤¹¤ë²èÁü°Ê³°¤Î¥Æ¥ó¥×¥ì¡¼¥È'); +define('_NP_ATTACH_06', '¥¢¥¤¥Æ¥à¤ËźÉդǤ­¤ë¥Õ¥¡¥¤¥ë¤Î¿ô'); +define('_NP_ATTACH_07', '¥¦¥§¥Ö¥í¥°¤Ëɽ¼¨¤¹¤ë¸¶À£²èÁü¤Î¥Æ¥ó¥×¥ì¡¼¥È¡£½Ì¾®²èÁü¤Î¥Æ¥ó¥×¥ì¡¼¥È¤ÏNP_Thumbnail¤Î¥Æ¥ó¥×¥ì¡¼¥È¤Ë½à¤¸¤Æ¤Þ¤¹¡£'); +define('_NP_ATTACH_08', '¥¦¥§¥Ö¥í¥°¤Ëɽ¼¨¤¹¤ë²èÁü°Ê³°¤Î¥Æ¥ó¥×¥ì¡¼¥È'); +define('_NP_ATTACH_09', '¥Õ¥¡¥¤¥ë¤Î¾ðÊó'); +define('_NP_ATTACH_10', '¥¿¥°'); +define('_NP_ATTACH_11', '¥Õ¥¡¥¤¥ë¤ÈÀâÌÀʸ'); +define('_NP_ATTACH_12', 'Ëä¤á¹þ¤ßÊýË¡'); +define('_NP_ATTACH_13', 'ºï½ü'); +define('_NP_ATTACH_14', '¥ê¥ó¥¯'); +define('_NP_ATTACH_15', '¥ê¥ó¥¯'); +define('_NP_ATTACH_16', '½Ì¾®'); +define('_NP_ATTACH_17', '¼ÂÀ£'); diff --git a/NP_Attach/attach/japanese-utf8.php b/NP_Attach/attach/japanese-utf8.php new file mode 100755 index 0000000..358b326 --- /dev/null +++ b/NP_Attach/attach/japanese-utf8.php @@ -0,0 +1,31 @@ +でアイテム中に表示できます'); +define('_NP_ATTACH_02', '管理画面に表示するサムネイルの横幅の最大値'); +define('_NP_ATTACH_03', '管理画面に表示するサムネイルの縦幅の最大値'); +define('_NP_ATTACH_04', '管理画面に表示する縮小画像のテンプレート'); +define('_NP_ATTACH_05', '管理画面に表示する画像以外のテンプレート'); +define('_NP_ATTACH_06', 'アイテムに添付できるファイルの数'); +define('_NP_ATTACH_07', 'ウェブログに表示する原寸画像のテンプレート。縮小画像のテンプレートはNP_Thumbnailのテンプレートに準じてます。'); +define('_NP_ATTACH_08', 'ウェブログに表示する画像以外のテンプレート'); +define('_NP_ATTACH_09', 'ファイルの情報'); +define('_NP_ATTACH_10', 'タグ'); +define('_NP_ATTACH_11', 'ファイルと説明文'); +define('_NP_ATTACH_12', '埋め込み方法'); +define('_NP_ATTACH_13', '削除'); +define('_NP_ATTACH_14', 'リンク'); +define('_NP_ATTACH_15', 'リンク'); +define('_NP_ATTACH_16', '縮小'); +define('_NP_ATTACH_17', '実寸'); diff --git a/NP_ImageLimitSize/NP_ImageLimitSize.php b/NP_ImageLimitSize/NP_ImageLimitSize.php new file mode 100755 index 0000000..c5d3202 --- /dev/null +++ b/NP_ImageLimitSize/NP_ImageLimitSize.php @@ -0,0 +1,164 @@ +createOption('maxwidth', '_NP_IMAGELIMITSIZE_02', 'text', '550', 'datatype=numerical'); + $this->createOption('maxheight', '_NP_IMAGELIMITSIZE_03', 'text', '0', 'datatype=numerical'); + $this->createBlogOption('status', '_NP_IMAGELIMITSIZE_04', 'yesno', 'yes'); + $this->createBlogOption('blog_maxwidth', '_NP_IMAGELIMITSIZE_05', 'text', '0', 'datatype=numerical'); + $this->createBlogOption('blog_maxheight', '_NP_IMAGELIMITSIZE_06', 'text', '0', 'datatype=numerical'); + return; + } + + public function uninstall() { + // plugin options are purged automatically when uninstalled. + return; + } + + public function init() { + if((string)$_REQUEST['action'] == 'pluginlist' && !defined('_NP_IMAGELIMITSIZE_01')) { + $language = preg_replace('#[/|\\\\]#', '', getLanguageName()); + 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(!defined('_NP_IMAGELIMITSIZE_01')) { + $language = preg_replace('#[/|\\\\]#', '', getLanguageName()); + if (file_exists($this->getDirectory() . $language.'.php')) { + include($this->getDirectory() . $language.'.php'); + } else { + include($this->getDirectory() . 'english.php'); + } + } + 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_PreMediaUpload($data) { + global $CONF, $manager; + + if (!class_exists('MediaUtils', FALSE)) { + return; + } + + if (MediaUtils::$blogid == 0) { + return; + } + + if ($this->getBlogOption(MediaUtils::$blogid, 'status') == 'no') { + return; + } + + if (0 == ($maxwidth = $this->getBlogOption(MediaUtils::$blogid, 'blog_maxwidth'))) { + $maxwidth = $this->getOption('maxwidth'); + } + + if (0 == ($maxheight = $this->getBlogOption(MediaUtils::$blogid, 'blog_maxheight'))) { + $maxheight = $this->getOption('maxheight'); + } + + $path = basename($data['uploadfile']); + $root = str_replace('/' . $path, '', $data['uploadfile']); + + if (FALSE === ($medium = new MEDIUM($root, $path, MediaUtils::$prefix))) { + return; + } + + if (!array_key_exists($medium->mime, MediaUtils::$image_mime) + || ($maxwidth >= $medium->width && $maxheight >= $medium->height)) { + return; + } + + if (FALSE === $medium->setResampledSize($maxwidth, $maxheight)) { + return; + } + + if (!MediaUtils::storeResampledImage($root, $path, $medium)) { + return; + } + return; + } + + public function event_MediaUploadFormExtras() { + echo '' . "\n"; + return; + } +} diff --git a/NP_ImageLimitSize/imagelimitsize/english.php b/NP_ImageLimitSize/imagelimitsize/english.php new file mode 100755 index 0000000..c91173f --- /dev/null +++ b/NP_ImageLimitSize/imagelimitsize/english.php @@ -0,0 +1,20 @@ + + + +Notice + + +

Notice

+

Nothing to see here

+ + \ 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 index 0000000..f5182a4 --- /dev/null +++ b/NP_ImageLimitSize/imagelimitsize/japanese-euc.php @@ -0,0 +1,20 @@ +baseUrl = str_replace($CONF['AdminURL'], '', $this->getAdminURL()); + self::setBlogObject(); + return; + } + + // public + public function getName() { return 'ImprovedMedia'; } + // public + public function getAuthor() { return 'Mocchi'; } + // public + public function getURL() { return 'http://japan.nucleuscms.org/wiki/plugins:improvedmedia'; } + // public + public function getVersion() { return '3.0.1 for PHP5'; } + // public + public function getMinNucleusVersion() { return 223; } + // public + public function getDescription() { return _IM_DESCRIPTION; } + + // public + public function supportsFeature($what) { + global $CONF; + switch($what) { + case 'HelpPage': + case 'SqlTablePrefix': + return 1; + default: + return 0; + } + } + + // public + public function init() { + $language = preg_replace( '#[/|\\\\]#', '', getLanguageName()); + if(file_exists($this->getDirectory() .'lang/' . $language.'.php')) + include_once($this->getDirectory() . 'lang/' . $language.'.php'); + else + include_once($this->getDirectory() . 'lang/english.php'); + + if($this->getOption('IM_EACHBLOGDIR') == 'yes') + self::setDirectories(); + + return; + } + + // public + public function install() { + $this->createOption('IM_PRIVATE', _IM_OPTION_PRIVATE , 'yesno', 'yes'); + $this->createOption('IM_ITEMDISPLAY', _IM_OPTION_ITEMDISPLAY , 'text', '10', 'datatype=numerical' ); + $this->createOption('IM_GREYBOX', _IM_OPTION_GREYBOX , 'yesno', 'no'); + $this->createOption('IM_EACHBLOGDIR', _IM_OPTION_EACHBLOGDIR , 'yesno', 'no'); + return; + } + + // public + public function unInstall() { + $this->deleteOption('IM_PRIVATE'); + $this->deleteOption('IM_ITEMDISPLAY'); + $this->deleteOption('IM_GREYBOX'); + $this->deleteOption('IM_EACHBLOGDIR'); + return; + } + + // public + public function getEventList() { + return array('InitSkinParse', 'AdminPrePageHead', 'BookmarkletExtraHead'); + } + + // public + public function doAction($type) { + global $DIR_LIBS; + if(!class_exists('MEDIA', FALSE)) + include($DIR_LIBS . 'MEDIA.php'); + if(!class_exists('MEDIA_VARIABLES', FALSE)) + include($this->getDirectory() . 'MEDIA_VARIABLES.php'); + if(!class_exists('MEDIA_CONTROL', FALSE)) + include($this->getDirectory() . 'MEDIA_CONTROL.php'); + + new MEDIA_CONTROL($this); + exit; + } + + // public + public function doSkinVar($data, $place) { + global $CONF, $member; + if($member->isLoggedIn()) { + if($this->getOption('IM_GREYBOX') == 'yes') { + switch($place) { + case 'head': + echo '' . "\n" . + '' . "\n" . + '' . "\n" . + '' . "\n". + '' . "\n"; + break; + case 'anchor': + echo '' . _IM_ANCHOR_TEXT . ''; + break; + default: + break; + } + } else { + if($place == 'anchor') { + echo '' . _IM_ANCHOR_TEXT . ''; + } + } + } + return; + } + + // public + public function event_InitSkinParse(&$data) { + return; + } + + // public + public function event_BookmarkletExtraHead(&$data) { + self::addHeader($data['extrahead']); + return; + } + + // public + public function event_AdminPrePageHead(&$data) { + if(($data['action'] == 'createitem') || ($data['action'] == 'itemedit')) + self::addHeader($data['extrahead']); + return; + } + + // private + private function addHeader(&$extrahead) { + global $CONF; + + if($this->getOption('IM_GREYBOX') == 'yes') { + $extrahead .= ''."\n"; + + if($this->getOption('IM_GREYBOX') == 'yes') { + $extrahead .= '' . "\n" . + '' . "\n" . + '' . "\n" . + '' . "\n" . + '' . "\n"; + } + return; + } + + // private + private function setBlogObject() { + global $manager, $blog; + + $blogid = intRequestVar('blogid'); + $itemid = intRequestVar('itemid'); + + if($blog) { + $this->blog =& $blog; + $this->blogid =& $blog->getID(); + return; + } + + if($blogid && $manager->existsBlogID($blogid)) { + $this->blog =& $manager->getBlog($blogid); + $this->blogid =& $this->blog->getID(); + return; + } + + if($itemid && $manager->existsItem($itemid, 1, 1)) { + $this->blog =& $manager->getBlog(getBlogIDFromItemID($itemid)); + $this->blogid =& $this->blog->getID(); + return; + } + } + + // private + private function setDirectories() { + global $DIR_MEDIA, $CONF; + + if(!$this->blog) + return; + + $blog =& $this->blog; + $bshortname =& $blog->getShortName(); + + if($this->blogid !== 1) { + $DIR_MEDIA = preg_replace('#(.+)/(.+)?/$#',"$1/$bshortname/$2/",$DIR_MEDIA); + $CONF['MediaURL'] = preg_replace( '#(.+)/(.+)?/$#' , "$1/$bshortname/$2/" , $CONF['MediaURL'] ); + } + return; + } + + // public + public function & getBlog() { + return $this->blog; + } + + // public + public function & getBlogid() { + return $this->blogid; + } + + // public + public function getBaseURL() { + return $this->baseUrl; + } +} +?> \ 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 index 0000000..65f0b24 --- /dev/null +++ b/NP_ImprovedMedia/improvedmedia/MEDIA_CONTROL.php @@ -0,0 +1,1733 @@ +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 '' . "\n"; + echo '\n"; + echo "\n"; + echo "\n"; + + if(self::getMediaprefix()) + echo '\n"; + else + echo '\n"; + + echo '\n"; + echo '\n"; + + if(!self::getAstool()) + echo '\n"; + + echo '\n"; + echo '\n"; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo '\n"; + if(!self::getAstool()) + echo '\n"; + echo "\n"; + echo "\n"; + echo "\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 "\n"; + echo "\n"; + echo "\n"; + echo '\n"; + if(!self::getAstool()) { + echo "' . "\n"; + } + if($filetype != 0) + echo '\n"; + else + echo '\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + } + echo "\n"; + echo "
' . _IM_COLLECTION_AMOUNT . $fileamount . ' ('; + if(!self::getFilter()) + echo _IM_FILTER_NONE; + else + echo _IM_FILTER . self::getFilter(); + echo ') >> '; + if(self::getSubdir()) + echo self::getSubdir() . ' >> '; + echo $collections[self::getCollection()]; + if(self::getBlogShortName() && self::getEachblogdir()) + echo ' >> ' . self::getBlogShortName(); + echo "
' . _IM_UPDATE . "' . _MEDIA_MODIFIED . "' . _IM_FILENAME_CLICK . "' . _IM_TYPE . "' . _IM_ACTION . "' . _IM_DIMENSIONS . "' . _IM_FUNCTION . "
'. "\n"; + if($idxStart > 0) + echo '' . _LISTS_PREV . ' < '; + if(($idxStart + 1) != $idxEnd) + echo ($idxStart + 1) . ' to ' . $idxEnd . ' / ' . $fileamount . ' '; + if($idxEnd < $fileamount) + echo '< ' . _LISTS_NEXT . ' '; + echo "'. "\n"; + else + echo ''. "\n"; + if(self::getBlogName() && self::getEachblogdir()) + echo _IM_WEBLOG_LABEL . ': ' . self::getBlogName(); + echo "
" . $update . "\n"; + if($filetype != 0 && !self::getSubdir()) + echo '' . "\n"; + elseif($filetype == 0 && !self::getSubdir()) + echo ''."\n"; + elseif($filetype != 0 && self::getSubdir()) + echo '' . "\n"; + else + echo ''."\n"; + + if(!self::getAstool()) + echo shorten($onlyfilename . '.' . $onlyprefix, 15, '...') . "\n"; + else + echo shorten($onlyfilename . '.' . $onlyprefix, 30, '...') . "\n"; + + echo "\n"; + echo "' . $onlyprefix . "\n"; + echo '
' . "\n"; + echo "

\n"; + echo '' . "\n"; + echo $manager->addTicketHidden() . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + if($filetype != 0) + echo '' . "\n"; + else + echo '' . "\n"; + echo '' . "\n"; + echo "

\n"; + echo '
' . "\n"; + echo '
' . $width . ' x ' . $height . "' . $filesize . " KB' . "\n"; + echo '
' . "\n"; + echo "

\n"; + echo '' . "\n"; + echo $manager->addTicketHidden() . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo "

\n"; + echo '
' . "\n"; + echo '
' . "\n"; + echo '
' . "\n"; + echo "

\n"; + echo '' . "\n"; + echo $manager->addTicketHidden() . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo "

\n"; + echo '
' . "\n"; + echo '
\n"; + } else { + echo '

' . _IM_COLLECTION_BRANK . ' ('; + if(!self::getFilter()) + echo _IM_FILTER_NONE; + else + echo _IM_FILTER . self::getFilter(); + echo ') ' . ' >> '; + if(self::getSubdir()) + echo self::getSubdir() . ' >> '; + echo $collections[self::getCollection()]; + if(self::getBlogShortName() && self::getEachblogdir()) + echo ' >> ' . self::getBlogShortName(); + echo "

\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 '
' . "\n"; + echo '

' . "\n"; + + if(count($collections) > 1) { + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + } else { + echo _IM_COLLECTION . ': ' . $collections[self::getCollection()] . '' . "\n"; + } + echo '' . "\n"; + echo $manager->addTicketHidden() . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '

' . "\n"; + echo '
' . "\n"; + + echo '
' . "\n"; + echo '

' . "\n"; + if(count($subdirs) > 0) { + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + } elseif(self::getSubdir() == '') { + echo _IM_SUBDIR_LABEL . _IM_SUBDIR_NONE . '' . "\n"; + } + echo '' . "\n"; + echo $manager->addTicketHidden() . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '

' . "\n"; + echo '
' . "\n"; + + echo '
' . "\n"; + echo '

' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '

' . "\n"; + echo '
' . "\n"; + echo '
' . "\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 '

' . _IM_HEADER_EMBED . "

\n"; + echo '

' . _IM_INCLUDE_DESC . '

' . "\n"; + echo '
' . "\n"; + echo '
' . "\n"; + echo '
' . _IM_FILENAME . '
' . "\n"; + echo '
' . self::getFilename() . '
' . "\n"; + echo '
' . _IM_INCLUDE_ALT . '
' . "\n"; + echo '
' . self::getAlttext() . '
' . "\n"; + + if(self::getSubdir()) { + echo '
' . _IM_SUBDIR . "
\n"; + echo '
' . self::getSubdir() . "
\n"; + } + + echo '
' . _IM_COLLECTION . '
' . "\n"; + echo '
' . $collections[self::getCollection()] . '
' . "\n"; + + if(self::getBlogName() && self::getEachblogdir()) { + echo '
' . _IM_WEBLOG_LABEL . "
\n"; + echo '
' . self::getBlogName() . "
\n"; + } + + if(self::getWay() == 'popup') { + echo '
' . _IM_DIMENSIONS . '
' . "\n"; + echo '
' . $width . ' x ' . $height . ' (' . $filesize . 'KB)
' . "\n"; + echo '
' . _IM_INCLUDE_WAY . '
' . "\n"; + echo '
' . _IM_INCLUDE_WAY_POPUP . '
' . "\n"; + } elseif(self::getWay() == 'inline') { + echo '
' . _IM_DIMENSIONS . '
' . "\n"; + echo '
' . $width . ' x ' . $height . ' (' . $filesize . 'KB)
' . "\n"; + echo '
' . _IM_INCLUDE_WAY . '
' . "\n"; + echo '
' . _IM_INCLUDE_WAY_INLINE . '
'; + } elseif(self::getWay() == 'other') { + echo '
' . _IM_DIMENSIONS . '
' . "\n"; + echo '
' . $filesize . 'KB' . '
' . "\n"; + echo '
' . _IM_INCLUDE_WAY . '
' . "\n"; + echo '
' . _IM_INCLUDE_WAY_OTHER . '
'; + } + + echo '
' . "\n"; + echo '
' . "\n"; + + echo '

' . _IM_INCLUDE_CODE . '

' . "\n"; + echo '

' . _IM_INCLUDE_CODE_DESC . '

' . "\n"; + + if(self::getWay() == 'popup') { + echo '

<%popup(' . self::getCollection() . '/' . $combinedfilename . '|' . $width . '|' . $height . '|' . self::getAlttext() . ')%>

' . "\n"; + echo '
' . "\n"; + } elseif(self::getWay() == 'inline') { + echo '

<%image(' . self::getCollection() . '/' . $combinedfilename . '|' . $width . '|' . $height . '|' . self::getAlttext() . ')%>

' . "\n"; + echo '' . "\n"; + } else { + echo '

<%media(' . self::getCollection() . '/' . $combinedfilename . '|' . self::getAlttext() . ')%>

' . "\n"; + echo '' . "\n"; + } + + echo '

' . "\n"; + echo '' . "\n"; + echo '

' . "\n"; + echo '
' . "\n"; + + echo '
' . "\n"; + echo '

' . "\n"; + echo '' . "\n"; + echo $manager->addTicketHidden() . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '

' . "\n"; + echo '
' . "\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 '

' . _IM_HEADER_ERASE_CONFIRM . "

\n"; + echo '

' . _IM_ERASE_CONFIRM . '

' . "\n"; + echo '
' . "\n"; + echo '
' . "\n"; + echo '
' . _IM_FILENAME . '
' . "\n"; + echo '
' . self::getFilename() . '
' . "\n"; + + if(self::getSubdir()) { + echo '
' . _IM_SUBDIR . "
\n"; + echo '
' . self::getSubdir() . "
\n"; + } + + echo '
' . _IM_COLLECTION . '
' . "\n"; + echo '
' . $collections[self::getCollection()] . '
' . "\n"; + + if(self::getBlogName() && self::getEachblogdir()) { + echo '
' . _IM_WEBLOG_LABEL . "
\n"; + echo '
' . self::getBlogName() . "
\n"; + } + + echo '
' . _IM_DIMENSIONS . '
' . "\n"; + echo '
' . $filesize . 'KB' . '
' . "\n"; + echo '
' . "\n"; + echo '
' . "\n"; + echo '
' . "\n"; + echo '

' . "\n"; + echo '' . "\n"; + echo $manager->addTicketHidden() . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '

' . "\n"; + echo '
' . "\n"; + echo '
' . "\n"; + echo '

' . "\n"; + echo $manager->addTicketHidden() . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '

' . "\n"; + echo '
' . "\n"; + + self::media_foot(); + return; + } + + private function media_rename_confirm($notice = '') { + global $manager, $member; + + $collections = self::getCollections(); + + self::media_head(); + echo '

' . _IM_HEADER_ERASE_CONFIRM . "

\n"; + + if($notice) { + echo '

' . _IM_NOTICE . "

\n"; + echo '

' . $notice . "

\n"; + } + + if(!self::getSubdir()) $combinedcollection = self::getCollection(); + else $combinedcollection = self::getCollection() . '/' . self::getSubdir(); + + list($update, $onlyfilename, $onlyprefix) = self::getSplitFilename($combinedcollection, self::getFilename()); + + echo '

' . _IM_RENAME_FILENAME . '

' . "\n"; + echo '
'."\n"; + echo "
\n"; + echo '
' . _IM_FILENAME . '
' . "\n"; + echo '
' . $onlyfilename . '
' . "\n"; + echo '
' . _IM_TYPE . '
' . "\n"; + echo '
' . $onlyprefix . '
' . "\n"; + + if(self::getSubdir()) { + echo '
' . _IM_SUBDIR . "
\n"; + echo '
' . self::getSubdir() . "
\n"; + } + + echo '
' . _IM_COLLECTION . '
' . "\n"; + echo '
' . $collections[self::getCollection()] . '
' . "\n"; + + if(self::getBlogName() && self::getEachblogdir()) { + echo '
' . _IM_WEBLOG_LABEL . "
\n"; + echo '
' . self::getBlogName() . "
\n"; + } + + if(self::getMediaprefix()) + echo '
'. _IM_UPDATE . "
\n"; + else + echo '
'. _MEDIA_MODIFIED . "
\n"; + + echo '
' . $update . '
' . "\n"; + echo '
' . "\n"; + echo '
' . "\n"; + echo '

' ._IM_RENAME_AFTER . '

' . "\n"; + echo '
' . "\n"; + echo '

' ._IM_RENAME_DESCRIPTION . '

' . "\n"; + echo '

' . "\n"; + + if(self::getNewfilename()) + echo '' . "\n"; + else + echo '' . "\n"; + + echo '

' . "\n"; + echo '

' . "\n"; + echo '' . "\n"; + echo $manager->addTicketHidden() . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '

' . "\n"; + echo '
' . "\n"; + + echo '
' . "\n"; + echo '

' . "\n"; + echo $manager->addTicketHidden() . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '

' . "\n"; + echo '
' . "\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 '

' . _IM_HEADER_UPLOAD_SELECT . "

\n"; + echo '
' . "\n"; + + if(self::getBlogName() && self::getEachblogdir()) { + echo '

' . _IM_WEBLOG_LABEL . "

\n"; + echo '

' . self::getBlogName() . "

\n"; + } + + echo '

\n"; + echo "

\n"; + + if(count($collections) > 1) { + echo _IM_COLLECTION_DESC . "
\n"; + echo '' . "\n"; + echo '' . "\n"; + } else { + echo _IM_COLLECTION . ': ' . $collections[self::getCollection()] . '' . "\n"; + } + echo '' . "\n"; + echo $manager->addTicketHidden() . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '

' . "\n"; + echo '
' . "\n"; + + echo '
' . "\n"; + echo '

\n"; + echo "

\n"; + + if(count($subdirs) > 0) { + echo _IM_SUBDIR_DESC . '
'; + echo '' . "\n"; + } elseif(self::getSubdir() == '') { + echo _IM_SUBDIR_LABEL . _IM_SUBDIR_NONE . '' . "\n"; + } + echo "

\n"; + + echo '

' . _IM_UPLOAD_USED_FILETYPE . "

\n"; + echo '

' . implode(', ', self::getAllowedtypes() ) . "

\n"; + echo '

\n"; + echo '

' . "

\n"; + echo '

' . _IM_UPLOAD_USED_ASCII . "

\n"; + echo '

' . _IM_UPLOAD_USED_ASCII_DESC1 . "

\n"; + echo '

' . _IM_UPLOAD_USED_ASCII_DESC2 . "

\n"; + echo '

' . "\n"; + echo '' . "\n"; + echo $manager->addTicketHidden() . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '

' . "\n"; + echo '
' . "\n"; + echo '
' . "\n"; + echo '

' . "\n"; + echo $manager->addTicketHidden . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '

' . "\n"; + echo '
' . "\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 '

' . _IM_HEADER_EMBED_CONFIRM . "

\n"; + + if($notice) { + echo '

' . _IM_NOTICE . "

\n"; + echo '

' . $notice . "

\n"; + } + + echo '

'. _IM_INCLUDE_FILE_SELECTED . '

' . "\n"; + echo '
' . "\n"; + echo '
' . "\n"; + echo '
' . _IM_FILENAME . '
' . "\n"; + echo '
' . self::getFilename() . '
' . "\n"; + + if(self::getSubdir()) { + echo '
' . _IM_SUBDIR . "
\n"; + echo '
' . self::getSubdir() . "
\n"; + } + + echo '
' . _IM_COLLECTION . '
' . "\n"; + echo '
' . $collections[self::getCollection()] . '
' . "\n"; + + if(self::getBlogName() && self::getEachblogdir()) { + echo '
' . _IM_WEBLOG_LABEL . "
\n"; + echo '
' . self::getBlogName() . "
\n"; + } + + echo '
' . _IM_DIMENSIONS . '
' . "\n"; + + if($filetype !== 0) + echo '
' . $width . ' x ' . $height . ' (' . $filesize . 'KB)
' . "\n"; + else + echo '
' . $filesize . 'KB' . '
' . "\n"; + + echo '
' . "\n"; + echo '
' . "\n"; + echo '

'. _IM_INCLUDE_ALT . '

' . "\n"; + echo '

\n"; + echo '
' . "\n"; + echo '

' . "\n"; + echo '' . "\n"; + echo '

'. "\n"; + echo '

'. _IM_INCLUDE_WAY . "

\n"; + + if($filetype !== 0) { + echo '

'. "\n"; + if(self::getWay() == 'inline') { + echo ''. "\n"; + echo '
'. "\n"; + echo ''. "\n"; + echo ''. "\n"; + } else { + echo ''. "\n"; + echo '
'. "\n"; + echo ''. "\n"; + echo ''. "\n"; + } + echo '

'. "\n"; + } else { + echo '

'. _IM_INCLUDE_WAY_OTHER . "\n"; + echo '

'. "\n"; + } + + echo '

'. "\n"; + echo '' . "\n"; + echo $manager->addTicketHidden() . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo ''. "\n"; + echo '' . "\n"; + echo ''. "\n"; + echo '

'. "\n"; + echo '
'. "\n"; + echo '
'. "\n"; + echo '

'. "\n"; + echo $manager->addTicketHidden() . "\n"; + echo ''. "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo ''. "\n"; + echo ''. "\n"; + echo '' . "\n"; + echo ''. "\n"; + echo '

'. "\n"; + echo '
'. "\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 '

' . _IM_HEADER_SUBDIR_REMOVE_CONFIRM . "

\n"; + + if($notice) { + echo '

' . _IM_NOTICE . "

\n"; + echo '

' . $notice . "

\n"; + } + + echo '

' . _IM_REMOVE_SUBIDR . "

\n"; + echo '
'."\n"; + echo "
\n"; + echo '
' . _IM_SUBDIR . "
\n"; + echo '
' . self::getSubdir() . '
' . "\n"; + echo '
' . _IM_SUBDIR_NUM_FILES . "
\n"; + + foreach($subdirs as $key => $options) { + if($options['subdirname'] == self::getSubdir()) + echo '
' . $options['number'] . "
\n"; + } + + echo '
' . _IM_COLLECTION . "
\n"; + echo '
' . $collections[self::getCollection()] . '
' . "\n"; + + if(self::getBlogName() && self::getEachblogdir()) { + echo '
' . _IM_WEBLOG_LABEL . "
\n"; + echo '
' . self::getBlogName() . "
\n"; + } + + echo "
\n"; + echo "
\n"; + + echo '

' . _IM_REMOVE_SUBIDR_CONFIRM . "

\n"; + echo '

' . _IM_REMOVE_SUBIDR_REMIND . "

\n"; + + echo '
' . "\n"; + echo '

' . "\n"; + echo '' . "\n"; + echo $manager->addTicketHidden() . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '

' . "\n"; + echo '
' . "\n"; + echo '
' . "\n"; + echo '

' . "\n"; + echo $manager->addTicketHidden() . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '

' . "\n"; + echo '
' . "\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 '

' . _IM_HEADER_SUBDIR_CREATE_CONFIRM . "

\n"; + + if($notice) { + echo '

' . _IM_NOTICE . "

\n"; + echo '

' . $notice . "

\n"; + } + + if(self::getBlogName() && self::getEachblogdir()) { + echo '

' . _IM_WEBLOG_LABEL . "

\n"; + echo '

' . self::getBlogName() . "

\n"; + } + + echo "

" . _IM_CREATE_SUBDIR_COLLECTION_LABEL . "

\n"; + + echo '
' . "\n"; + echo "

\n"; + echo '
\n"; + echo '' . "\n"; + echo "

\n"; + + echo '

' . _IM_CREATE_SUBDIR_INPUT_NAME . "

\n"; + echo "

" . _IM_CREATE_SUBDIR_CHARS_DESC . "

\n"; + echo '

' . "\n"; + echo $manager->addTicketHidden() . "\n"; + if(self::getNewfilename() != '') + echo '' . "\n"; + else + echo '' . "\n"; + echo '

' . "\n"; + echo '

' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '

' . "\n"; + echo '
' . "\n"; + + echo '
' . "\n"; + echo '

' . "\n"; + echo '' . "\n"; + echo $manager->addTicketHidden() . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '

' . "\n"; + echo '
' . "\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 '

' . _IM_HEADER_SUBDIR_RENAME_CONFIRM . "

\n"; + + if($notice) { + echo '

' . _IM_NOTICE . "

\n"; + echo '

' . $notice . "

\n"; + } + + echo '

' . _IM_RENAME_SUBDIR_COLLECTION . "

\n"; + echo '
'."\n"; + echo "
\n"; + echo '
' . _IM_SUBDIR . "
\n"; + echo '
' . self::getSubdir() . '
' . "\n"; + echo '
' . _IM_SUBDIR_NUM_FILES . "
\n"; + + foreach($subdirs as $key => $options) { + if($options['subdirname'] == self::getSubdir()) + echo '
' . $options['number'] . "
\n"; + } + + echo '
' . _IM_COLLECTION . "
\n"; + echo '
' . $collections[self::getCollection()] . '
' . "\n"; + + if(self::getBlogName() && self::getEachblogdir()) { + echo '
' . _IM_WEBLOG_LABEL . "
\n"; + echo '
' . self::getBlogName() . "
\n"; + } + + echo '
' . "\n"; + echo '
' . "\n"; + echo '

' ._IM_RENAME_AFTER . '

' . "\n"; + echo '
' . "\n"; + echo '

' ._IM_RENAME_DESCRIPTION . '

' . "\n"; + echo '

' . "\n"; + if($newdirname != '') + echo '' . "\n"; + else + echo '' . "\n"; + echo '

' . "\n"; + + echo '

' . "\n"; + echo '' . "\n"; + echo $manager->addTicketHidden() . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '

' . "\n"; + echo '
' . "\n"; + + echo '
' . "\n"; + echo '

' . "\n"; + echo $manager->addTicketHidden() . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '

' . "\n"; + echo '
' . "\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 '
' . "\n"; + echo '

' . "\n"; + + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo $manager->addTicketHidden() . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '

' . "\n"; + echo '
' . "\n"; + + echo '
' . "\n"; + echo '

' . _IM_DISPLAY_SUBDIR_LABEL1 . $fileamount . _IM_DISPLAY_SUBDIR_LABEL2 . $subdirs[0]['number'] . "\n"; + echo $manager->addTicketHidden() . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '

' . "\n"; + echo '
' . "\n"; + + echo "
\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 '' . "\n"; + echo '\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '\n"; + echo '\n"; + echo '\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '\n"; + echo '\n"; + echo "\n"; + echo '' . "\n"; + echo '' . "\n"; + + for($i = $idxStart; $i < $idxEnd; $i++) { + $options = $subdirs[$i]; + echo '' . "\n"; + if($options['subdirname'] == ".") + echo '' . "\n"; + else + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + + if($options['subdirname'] == ".") { + echo "\n"; + echo "\n"; + echo "\n"; + } else { + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + } + } + echo '' . "\n"; + echo '
' . _IM_DISPLAY_SUBDIR_CAPTION . ' >> ' . $collections[self::getCollection()]; + if(self::getBlogShortName() && self::getEachblogdir()) + echo ' >> ' . self::getBlogShortName(); + echo "
' . _IM_SUBDIR . "' . _IM_SUBDIR_NUM_FILES . "' . _IM_ACTION . "
' . "\n"; + if ($idxStart > 0) + echo '' . _LISTS_PREV . ' < '; + if(($idxStart + 1) != $idxEnd) + echo ($idxStart + 1) . ' to ' . $idxEnd . ' '; + if ($idxEnd < $fileamount ) + echo '' . '> ' . _LISTS_NEXT . ''; + echo "'. "\n"; + if(self::getBlogName() && self::getEachblogdir()) + echo _IM_WEBLOG_LABEL . ': ' . self::getBlogName(); + echo "
' . _IM_SUBDIR_NONE . '' . $options['subdirname'] . '' . $options['number'] . '' . "\n"; + echo '
' . "\n"; + echo "

\n"; + echo '' . "\n"; + echo $manager->addTicketHidden() . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo "

\n"; + echo '
' . "\n"; + echo '
' . "\n"; + echo '
' . "\n"; + echo "

\n"; + echo '' . "\n"; + echo $manager->addTicketHidden() . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo "

\n"; + echo '
' . "\n"; + echo '
' . "\n"; + echo '
' . "\n"; + echo "

\n"; + echo '' . "\n"; + echo $manager->addTicketHidden() . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo "

\n"; + echo '
' . "\n"; + echo '
' . "\n"; + } else { + if(self::getBlogShortName() && self::getEachblogdir()) + echo "

" . _IM_DISPLAY_SUBDIR_NOTHING . ' >> ' . $collections[self::getCollection()] . ' >> ' . self::getBlogShortName() . "

\n"; + else + echo "

" . _IM_DISPLAY_SUBDIR_NOTHING . ' >> ' . $collections[self::getCollection()] . "

\n"; + } + + self::media_foot(); + return; + } + + private function media_loginAndPassThrough() { + self::media_head(); + + echo '

' . _LOGIN_PLEASE . "

\n"; + echo '
' . "\n"; + echo '

' . "\n"; + echo _LOGINFORM_NAME . '
' . "\n"; + echo '
' . "\n"; + echo _LOGINFORM_PWD . '
' . "\n"; + echo '
' . "\n"; + echo '' . "\n"; + echo '\n"; + echo "

\n"; + echo "

\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo "

\n"; + echo "
\n"; + + self::media_foot(); + return; + } + + private function media_doError($message) { + global $manager; + + self::media_head(); + + echo '

' . _ERROR . "

\n"; + echo '

' . $message . "

\n"; + echo '
' . "\n"; + echo '

' . "\n"; + echo '' . "\n"; + echo $manager->addTicketHidden() . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '

' . "\n"; + echo '
' . "\n"; + + self::media_foot(); + return; + } + + private function media_head() { + sendContentType('application/xhtml+xml', 'media'); + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo 'Media Control' . _IM_HEADER_TEXT . '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + + if(!self::getGreybox()) { + echo '

Media Control' . _IM_HEADER_TEXT . '

' . "\n"; + echo '
' . "\n"; + } + return; + } + + private function media_foot() { + echo "\n"; + echo ""; + 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 . ')
'; + return $log; + } + + if(($dir = @opendir($dirname)) == FALSE) { + $log .= _IM_SUBDIR_FAILED_READ . ' (' . $collection . '/' . $subdir . ')
'; + 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 . ")
"; + } + } + } + closedir($dir); + + if($log) + return $log; + + if(@rmdir($dirname) == false) { + $log .= _IM_SUBDIR_REMOVE_FAILED . ' (' . $collection . '/' . $subdir . ')
'; + return $log; + } + } +} +?> diff --git a/NP_ImprovedMedia/improvedmedia/MEDIA_VARIABLES.php b/NP_ImprovedMedia/improvedmedia/MEDIA_VARIABLES.php new file mode 100755 index 0000000..349aa11 --- /dev/null +++ b/NP_ImprovedMedia/improvedmedia/MEDIA_VARIABLES.php @@ -0,0 +1,447 @@ +blog =& $PluginObject->getBlog(); + $this->blogid =& $PluginObject->getBlogid(); + $this->accessurl = $CONF['ActionURL'] . '?action=plugin&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 index 0000000..1793160 --- /dev/null +++ b/NP_ImprovedMedia/improvedmedia/greybox/AJS.js @@ -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(""); +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 + Copyright (C) + + 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. + + , 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 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 index 0000000..f1b261d --- /dev/null +++ b/NP_ImprovedMedia/improvedmedia/greybox/gb_scripts.js @@ -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(_12fl){ +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 index 0000000..52fdc17 --- /dev/null +++ b/NP_ImprovedMedia/improvedmedia/greybox/gb_styles.css @@ -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 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 index 0000000..3974d80 --- /dev/null +++ b/NP_ImprovedMedia/improvedmedia/greybox/index.html @@ -0,0 +1,11 @@ + + + + Nothing Here + + + +

Nothing to see here

+ + + \ 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 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 index 0000000..30dcb26 --- /dev/null +++ b/NP_ImprovedMedia/improvedmedia/greybox/loader_frame.html @@ -0,0 +1,104 @@ + + + + + + + + +
+ +
+ + + + + + diff --git a/NP_ImprovedMedia/improvedmedia/greybox/next.gif b/NP_ImprovedMedia/improvedmedia/greybox/next.gif new file mode 100755 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 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 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 index 0000000..be96704 --- /dev/null +++ b/NP_ImprovedMedia/improvedmedia/help.html @@ -0,0 +1,465 @@ + +

目次

+ + +

プラグインの概要

+

このプラグインは、Nucleusのmedia.phpという、ファイルの記事への挿入やアップロードを行うプログラムを改良し、プラグインとして利用しやすくしたものです。 +Orangoo projectsのGreyBox (ver.5.54) を、LGPL ver.2.1のもと、同梱しています。

+

機能は以下です

+
    +
  1. アップロード、記事への挿入、ファイル名の変更そして削除、サブディレクトリの作成・削除・名前変更を行う事ができます。
  2. +
  3. media.phpのNucleus Mediaウィンドウから、インターフェースを改良してあります。
  4. +
  5. ファイルの挿入時は、代替テキストの入力を必須としました。これはアクセシビリティの観点に拠ります。
  6. +
  7. プライベート・コレクション・ディレクトリ機能をオン・オフして、共有ディレクトリのみによる運用ができます。
  8. +
  9. オプションで指定することにより、NP_EachBlogDirで提供していた機能を利用することができます。
  10. +
+ +

サポートとバグ報告

+

サポートフォーラムにおいて行います。 +このヘルプの最新は、NP_ImprovedMedia - Nucleus CMS WIKIで参照することができます。

+ +

インストール

+
    +
  1. 圧縮フォルダを展開し、内容物をPLUGINフォルダにコピー。
  2. +
  3. Nucleusにログインし、「管理ホーム」から、「プラグイン管理」の画面に移動。
  4. +
  5. 画面下部の「新しいプラグインをインストール」で、「ImprovedMedia」を選択し、「プラグインのインストール」ボタンをクリック。
  6. +
  7. 「プラグインの管理」画面の「インストール済み」のリストに表示されているのを確認します。
  8. +
  9. リスト右の「編集」で、オプションを変更することができます。
  10. +
  11. 通常どおり、アイテムの編集画面で外部ファイルを呼び出すボタンをクリックすると、ファイルのアップロード画面が開きます。ファイルのアップロードが成功すると、記事への埋め込みを行う画面となります。
  12. +
+ +

アンインストール

+

オプションデータを持ちますが、そのままプラグイン管理で削除すれば、きれいになくなります。

+ +

他のプラグインとの競合

+

NP_ImageManager、NP_EachBlogDir、NP_Mediatocuと同時に使う事はできません。その他のプラグインは、おそらく大丈夫だと思います。

+ +

使用上の注意

+
    +
  • ユーザがログアウト状態である時は、ログイン画面を表示します。再度ログインすることで、機能を利用できます。
  • +
  • Media Controlウィンドウは呼び出されたウェブログ情報を保持しているので、もしもユーザがウェブログ・チームに所属しておらず、最高管理権限も持っていない場合は、エラー画面を表示します。
  • +
  • 代替テキストは40文字に制限されています。英数字でも記号でも日本語でも構いません。
  • +
  • ファイル名変更時に、拡張子を変更する事はできません。
  • +
  • 変更後のファイル名は30文字に制限されています。使用できる文字種は、英数字と3種類の記号(ハイフンマイナス、アンダースコア、プラス)です。
  • +
  • ファイルを削除するときは、ほんとうに削除していいのか、少し考える時間を設けるとよいでしょう。
  • +
  • サブ・ディレクトリの名前は20文字に制限されています。使用できる文字種は、英数字と3種類の記号(ハイフンマイナス、アンダースコア、プラス)です。
  • +
  • サブ・ディレクトリを削除すると、その中に保存されているファイルも削除されます。ほんとうに削除していいのか、少し考える時間を設けるとよいでしょう。
  • +
  • プライベート・コレクション・ディレクトリ、共有コレクション・ディレクトリをとわず、コレクション・ディレクトリは削除できません。
  • +
+ +

スキン変数の実装

+

スキンに変数を記述することで、スキンから機能を呼び出すことができます。以下の2つの記述を、スキンに追加してください。 +なお、テンプレートからの呼び出しはサポートしていません。

+ +

<head></head>要素内

+
+<%if(hasplugin,ImprovedMedia)%>
+<%ImprovedMedia(head)%>
+<%endif%>
+ +

<body></body>要素内

+
<%if(hasplugin,ImprovedMedia)%>
+<%ImprovedMedia(anchor)%>
+<%endif%>
+ +

すると、<%ImprovedMedia(anchor)%>を追加したところにアンカー「ファイル管理」が出現します。 +このアンカーをクリックすることで、機能の呼び出しをすることができます。 +なお、こうして呼び出されたMedia Controlは、ファイルの一覧画面をデフォルトで表示します。またボタン「文書に挿入」を持たず、ファイルのアップロード・削除・ファイル名の変更とサブディレクトリ管理のみ利用できます。

+ +

オプションの解説

+

以下の4つのオプションを持ちます。

+

プライベート・コレクションのオン・オフ。

+

デフォルトでは、Nucleusインストール時と同様に、プライベート・コレクション・ディレクトリ機能がオンとなっています。 +オフにすることで、メンバー間の共有ディレクトリの使用を徹底することができます。
+なお、メディア・ディレクトリに子ディレクトリ(このプラグインでは、コレクション・ディレクトリと呼んでいます)が作成されていない状態でこの機能をオフにすると、エラーとなります。 +その場合は、FTPソフトかサーバ提供環境でディレクトリを作成してください。

+ +

Media Controlページに表示するファイル数

+

表示ファイル数を5件から50件の間で指定できます。

+ +

GreyBoxユーティリティの利用

+

GreyBoxの提供する効果によってMedia Controlを開くオプションを追加しています。 +このオプションを利用しない方は、このプラグインの構成ファイルのうち、ディレクトリ「greybox」を削除するとよいでしょう。

+ +

それぞれのウェブログがある個別ディレクトリでのファイル管理

+

NP_EachBlogDirで提供していた、それぞれのウェブログがある個別ディレクトリでのファイル管理機能を利用することができます。 +このオプションは、アップロードしてブログで利用するファイルが、そのブログに属している状態を作り出します。詳しくはこのヘルプのそれぞれのウェブログがある個別ディレクトリでのファイル管理についてを参照してください。

+ +

グローバル設定の日付の付加による動作の違い

+

Nucleusのグローバル設定にある「アップロードするファイル名の頭に日付を付加する」オプションにより +一覧画面での日付とファイル名の表示およびファイル名変更時の動作が異なります。

+

「はい」のとき

+
    +
  • 一覧画面での日付の表示は、「登録日」となり、ファイルの先頭に追加されている日付が入ります。
  • +
  • 一覧画面でのファイル名の表示は、先頭の日付を取り去ったものとなります。
  • +
  • ファイル名変更時に、ファイル名の先頭に日付(数字8桁)+ハイフンがついていないファイルは、そのファイルの最終更新日を先頭に追加します。
  • +
  • 一覧画面でのファイルの並びは、先頭に付加されている日付を含めたファイル名の降順です。
  • +
+

「いいえ」のとき

+
    +
  • 一覧画面での日付の表示は、「更新日」となります。
  • +
  • 一覧画面でのファイル名の表示は、ファイル名そのままとなります。
  • +
  • ファイル名変更時に、ファイル名の先頭に日付を付加する事はありません。
  • +
  • 一覧画面でのファイルの並びは、ファイルの最終更新日の降順です。
  • +
+ +

それぞれのウェブログがある個別ディレクトリでのファイル管理について

+ +

複数ウェブログを以下のようなディレクトリ構成で運用する事で、アップロードしたファイルがウェブログに属し、ウェブログ管理チームに所属しているユーザのみ、そのファイルを利用することができるようにします。

+ +
+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)
+...
+
+ +

なお、メディア・ディレクトリの名前は任意ですが、どのウェブログのディレクトリでも共通の名前にしてください。PHPスクリプト・ファイルの名前は、index.phpでなくとも構いません。

+ +

具体的に言うと、管理領域(Nucleusディレクトリ)と同じ階層に、各ウェブログの短縮名のディレクトリを作成し、その中にPHPファイルとメディアディレクトリを配置。 +このようにしたときに、プラグイン内の改造を加えたmedia.phpが、それぞれのウェブログにおかれたメディアディレクトリを参照します。 +また、ウェブログが表示されたときに、アイテムに埋め込まれたファイルへのパスが通るようにします。

+ +

新規のウェブログの設置方法

+
    +
  1. 新規に作成するウェブログの短縮名を決めます。
  2. +
  3. Nucleusがインストールされているディレクトリと同じ階層に、その短縮名のディレクトリを作成。
  4. +
  5. 短縮名のディレクトリの中に、メディアディレクトリを作成します。ディレクトリの名前は、あなたがconfig.phpに記述したメディアディレクトリと同一の名前にしてください。
  6. +
  7. Nucleusにログインし、「新規Blog作成」をクリック。
  8. +
  9. 各種項目を入力しますが、「Blogの短縮名」は、先ほど決めたものにします。
  10. +
  11. ボタン「Blogを作成」をクリック。
  12. +
  13. 次の画面に表示される「方法1」のスクリプトをコピーし、テキストエディタを開いて貼り付け。
  14. +
  15. テキストファイルの書き換えを行います。include('../config.php')
  16. +
  17. テキストファイルはphpファイルとして、先ほど作成したディレクトリに保存。
  18. +
  19. 「URL」を変更します。「(Document Root)/短縮名のディレクトリ/テキストファイルのファイル名」
  20. +
  21. 「作成!」をクリック。新規ウェブログを作成します。
  22. +
  23. これまでの設定に不備があっても、「管理ホーム」のウェブログそれぞれの「設定」から修正することができます。
  24. +
  25. 通常通り、「アイテムの追加」「アイテムの編集/削除」、スキンから誘導される「アイテムの編集」で使うことができます。
  26. +
+ +

アンインストールの際、プラグインはそっくりなくなるのですが、このプラグインを利用して作成したアイテムにおいて、MEDIAファイルへのアンカー切れが発生します。 +その時は、それぞれのMEDIAディレクトリの内容をコレクション・ディレクトリごとコピーし、config.phpに書いた$DIR_MEDIAへ移動してください。アンカーが回復します。

+ +

メディアディレクトリの名前は、すべて統一されたものにしてください。 +たとえば、あなたがconfig.phpに記述したメディアディレクトリの名前が「media」なら、 +それぞれのウェブログのフォルダにあるメディアディレクトリも、同じように「media」ディレクトリとしてください。

+ +

イベントの発生

+

すでにアップロードされているメディア・ファイルの名前を変更する前後、削除する前後にイベントを発生します。それぞれ、「PreMediaRename」、「PostMediaRename」、「PreMediaErase」、「PostMediaErase」です。 +また、コレクション・ディレクトリにサブ・ディレクトリを作成する前後、サブ・ディレクトリの名前を変更する前後、サブ・ディレクトリを削除する前後にもイベントを発生します。 +それぞれ、「PreSubdirCreate」、「PostSubdirCreate」、「PreSubdirRename」、「PostSubdirRename」、「PreSubdirRemove」、「PostSubdirRemove」です。 +Nucleus CMSのバージョン3.3以降では、メディア・ファイルをアップロードする前後のイベント「PreMediaUpload」と「PostMediaUpload」を、コアが提供しています。

+

なお、NP_ActionLogPlusをこのプラグインと一緒に利用している場合、外部ファイルに関する履歴に「ファイル削除」と「ファイル名変更」、「サブ・ディレクトリの作成」、「サブ・ディレクトリの名前変更」、「サブ・ディレクトリの削除」が加わります。このプラグインが発生するイベント「PostRenameMedia」と「PostDeleteMedia」、「PostSubdirCreate」、「PostSubdirRename」、「PostSubdirRemove」をキャッチするからです。このプラグインは「PostMediaUpload」もキャッチします。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
名前いつパラメータ
PreMediaUpload(Nucleus CMSのバージョン3.3以降)選択したメディア・ファイルがアップロードされる前
+
collection
+
(参照渡し)アップロードするメディア・ファイルが保存されるコレクション・ディレクトリ
+
uploadfile
+
(値渡し)アップロードするメディア・ファイルがサーバ上で一時的に保存されているファイルの名前
+
filename
+
(参照渡し)アップロードした後のファイル名
+
PostMediaUpload(Nucleus CMSのバージョン3.3以降)選択したメディア・ファイルがアップロードされた後
+
collection
+
(値渡し)選択したメディア・ファイルが保存されたコレクション・ディレクトリ
+
mediadir
+
(値渡し)アップロードしたメディア・ファイルが保存されたコレクション・ディレクトリのサーバにおけるパス
+
filename
+
(値渡し)アップロードした後のファイル名
+
PreRenameMedia選択したメディア・ファイルのファイル名が変更される前
+
collection
+
(値渡し)選択したメディア・ファイルが保存されているコレクション・ディレクトリ
+
oldfilename
+
(値渡し)選択したメディア・ファイルの以前のファイル名
+
newfilename
+
(値渡し)選択したメディア・ファイルの現在のファイル名
+
PostRenameMedia選択したメディア・ファイルのファイル名が変更された後
+
collection
+
(値渡し)選択したメディア・ファイルが保存されているコレクション・ディレクトリ
+
oldfilename
+
(値渡し)選択したメディア・ファイルの以前のファイル名
+
newfilename
+
(値渡し)選択したメディア・ファイルの現在のファイル名
+
PreDeleteMedia選択したメディア・ファイルが削除される前
+
collection
+
(値渡し)削除したメディア・ファイルが保存されていたコレクション・ディレクトリ
+
filename
+
(値渡し)削除したメディア・ファイルのファイル名
+
PostDeleteMedia選択したメディア・ファイルが削除された後
+
collection
+
(値渡し)削除したメディア・ファイルが保存されていたコレクション・ディレクトリ
+
filename
+
(値渡し)削除したメディア・ファイルのファイル名
+
PreSubdirCreateコレクション・ディレクトリにサブ・ディレクトリが作成される前
+
collection
+
(値渡し)コレクション・ディレクトリの名前
+
subdir
+
(値渡し)サブ・ディレクトリの名前
+
PostSubdirCreateコレクション・ディレクトリにサブ・ディレクトリが作成された後
+
collection
+
(値渡し)コレクション・ディレクトリの名前
+
subdir
+
(値渡し)サブ・ディレクトリの名前
+
PreSubdirRenameコレクション・ディレクトリのサブ・ディレクトリの名前が変更される前
+
collection
+
(値渡し)コレクション・ディレクトリの名前
+
olddirname
+
(値渡し)変更前のサブ・ディレクトリの名前
+
newdirname
+
(値渡し)変更後のサブ・ディレクトリの名前
+
PostSubdirRenameコレクション・ディレクトリのサブ・ディレクトリの名前が変更された後
+
collection
+
(値渡し)コレクション・ディレクトリの名前
+
olddirname
+
(値渡し)変更前のサブ・ディレクトリの名前
+
newsubdirname
+
(値渡し)変更後のサブ・ディレクトリの名前
+
PreSubdirRemoveコレクション・ディレクトリのサブ・ディレクトリが削除される前
+
collection
+
(値渡し)コレクション・ディレクトリの名前
+
subdir
+
(値渡し)サブ・ディレクトリの名前
+
PostSubdirRemoveコレクション・ディレクトリのサブ・ディレクトリが削除された後
+
collection
+
(値渡し)コレクション・ディレクトリの名前
+
subdir
+
(値渡し)サブ・ディレクトリの名前
+
+ +

バージョン履歴

+
+
2010.02.28 Ver.3.0.1
+
    +
  • アイテムの編集画面から呼び出して画像ファイルをアップロードした際、<%media%>でしか埋め込まれない不具合を修正。
  • +
  • 同梱しているGreyBoxを最新のバージョン(var.5.54)にした。
  • +
+
2009.02.09 Ver.3.0.0
+
    +
  • サブ・ディレクトリ管理機能を追加。以降、Ver.2.x.xとVer.3.x.x(サブ・ディレクトリ管理機能つき)の2系統とします。
  • +
+
2009.02.09 Ver.2.2.0
+
    +
  • クラスとその要素(プロパティ)、関数(メソッド)を設定。PHP5を意識してPHP4にも対応するよう再設計した。
  • +
  • NP_EachBlogDirをNP_ImprovedMediaに統合した。
  • +
  • グローバル設定「アップロードするファイル名の頭に日付を付加する」に応じて、ファイルの並び順を変更するようにした。
  • +
  • アイテム編集画面からの呼び出しと、スキンからの呼び出して、アイテムへの埋め込みまでのルーチンが変わるように変更した。
  • +
  • ヘルプファイルを更新
  • +
+
2009.01.20 Ver.2.1.1
+
    +
  • Super Admin権限を持つユーザのみ利用できるようにしていたが、ウェブログの編集権限をひとつでも持つユーザにまで利用範囲を広げた。
  • +
  • インターフェースの改善
  • +
+
2009.01.11 Ver.2.1.0
+
    +
  • URL内の任意の文字列を渡すことによってディレクトリ操作が可能になる脆弱性を防ぐため、ファイル名とディレクトリに関する処理を修正。
  • +
  • インターフェースを改善。
  • +
  • グローバル設定のAllowUploadにを反映するように修正。
  • +
  • プラグインの利用をウェブログ・グループに所属しているユーザに限定。
  • +
  • Ver 2.0でマージしたファイル・アップロードに関するコードを削除。アップロードに関しても、コアの機能を最大限に利用します。
  • +
  • ヘルプファイルを更新。
  • +
+
2009.01.06 Ver.2.0.2公開中止
+
+
2008.02.08 Ver.2.0.2
+
    +
  • アイテムへの埋め込み確認の際、埋め込まれるコードを表示をし、コードの再編集への注意を促すように修正。
  • +
  • メディア・ファイルを文書に挿入するへのボタンをクリックした際の動作に関して、バグの修正。
  • +
+
+
2008.01.31 Ver.2.0.1
+
    +
  • GreyBox機能がオフの際のコード埋め込み不具合を修正。
  • +
  • ヘルプファイルを更新
  • +
+
+
2008.01.15 Ver.2.0
+
    +
  • コードの見直しに伴い、バージョンをあげた。
  • +
  • ファイル・アップロード、ファイル名変更、ファイル削除の各プラグイン・イベントを設定。
  • +
  • プラグイン・イベントに関するNucleus CMSのバージョン間での違いを吸収するために、ファイル・アップロードに関するコードをマージ。
  • +
  • Internet Explorerでファイルを開く際に、ポップアップしないJavaScriptのバグを修正。
  • +
  • ヘルプの更新。
  • +
  • プラグイン関連のディレクトリ構造の変更。
  • +
+
2007.11.20 Ver.1.3
+
    +
  • スキン変数を実装。スキンからの呼び出しを可能とした。
  • +
  • スキンから呼び出された際は、ボタン「文書へ挿入」を非表示にした。
  • +
  • GreyBoxを含むパッケージにした。
  • +
+
2007.11.06 Ver.1.2(Bundling GreyBox)
+
    +
  • GreyBoxユーティリティによるウィンドウオープンを実装。
  • +
+
2007.11.01 Ver.1.2
+
    +
  • ヘッダ追加情報の上書き状態を修正。
  • +
  • オプションの追加。
  • +
  • パースエラーの修正。
  • +
  • Nucleus3.3のコードを合体。
  • +
  • ヘルプの更新。
  • +
  • プラグイン関連のディレクトリ構造の変更。
  • +
+
2007.06.21 Ver.1.1
+
    +
  • プライベート・コレクションのオン・オフを追加。
  • +
  • パースエラーの修正。
  • +
  • ヘルプの更新。
  • +
+
2007.02.17 Ver.1.0.2 (RC3)
+
    +
  • リリースキャンディデート3
  • +
+
2006.12.31 Ver.1.0.1 (RC2)
+
    +
  • リリースキャンディデート2
  • +
+
2006.12.29 Ver.1.0 (RC1)
+
    +
  • リリースキャンディデート
  • +
+
2006.12.22 Beta
+
    +
  • ベータバージョン
  • +
+
2006.12.20 Alpha
+
    +
  • アルファバージョン
  • +
+
+ +

動作の仕組み

+ +

備忘録として残しておきます。

+ +

アイテムの追加/編集の時

+ +
    +
  1. 変数「action」によりイベント「AdminPrePageHead」、「BookmarkletExtraHead」が発生した際、XHTML要素「head」にJavaScript関数を挿入。 action.php経由でプラグインの出力するMedia Controlをポップアップ表示するJavaScript関数「AddMedia()」を埋め込む。
  2. +
  3. また同時に、JavaScript関数「includeImage()」と「includeOtherMedia()」もヘッダに追加。
  4. +
  5. 追加したJavaScript関数はXHTMLファイルに直接埋め込まれているため、コアのJavaScript関数「AddMedia()」よりも呼び出し優先される。
  6. +
  7. JavaScript関数「AddMedia()」はMedia Controlにユーザを誘導し、JavaScript関数「includeImage()」と「includeOtherMedia()」は代替テキスト入力を代行する。
  8. +
  9. 追加したJavaScript関数「AddMedia()」は、blogidもしくはitemidをget変数としてMedia Controlに渡す。
  10. +
  11. blogid(ない場合はitemid)を用いてグローバル変数の$DIR_MEDIAと$CONF[’MediaURL’]を置き換える。
  12. +
  13. Media Controlが自分を呼び出す際は、必ずblogidをget変数として渡す。
  14. +
  15. あとはコアの機能を利用して、ポップアップや埋め込みのコードが生成される。
  16. +
+ +

表示される時

+
    +
  1. action変数により、イベント「InitSkinParse」が発生したとき、つまりスキンの初期化の直前に、プラグイン内のあるメソッドが実行される。
  2. +
  3. メソッドは、blogオブジェクトからshortnameを参照し、それを用いてグローバル変数の$DIR_MEDIAと$CONF[’MediaURL]を置き換える。
  4. +
  5. 画像へのアンカーが、スキン変数<%popup%>、<%image%>において、置き換えられる。
  6. +
  7. イベント発生をPreItemにしなかったのは、ポップアップで呼び出されるウィンドウにも変更を適用したかったから。
  8. +
diff --git a/NP_ImprovedMedia/improvedmedia/index.html b/NP_ImprovedMedia/improvedmedia/index.html new file mode 100755 index 0000000..dd9f433 --- /dev/null +++ b/NP_ImprovedMedia/improvedmedia/index.html @@ -0,0 +1,11 @@ + + + +Nothing Here + + + +

Nothing to see here

+ + + \ 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 index 0000000..829ed67 --- /dev/null +++ b/NP_ImprovedMedia/improvedmedia/lang/english.php @@ -0,0 +1,135 @@ +It will be the garbled characters and you can\'t access the file if you upload it with Japanese name.'); +define('_IM_UPLOAD_USED_ASCII_DESC2', 'Then please use the erase function on this plugin.
After, rename it and re-upload it.'); +define('_IM_UPLOAD_USED_FILETYPE', 'Available file types'); +define('_IM_UPLOAD_CONPLETE', 'The file is uploaded.'); +define('_IM_COLLECTION_AMOUNT', 'Num. of Files: '); +define('_IM_COLLECTION_BRANK', 'Nothing exists at collection directory: '); +define('_IM_REQUIREMENT', 'Enter description about the selected file'); +define('_IM_ITEMDISPLAY_WRONG', 'Too much or too less number of files in a list!'); + +define('_IM_SUBDIR', 'Sub Directory'); +define('_IM_COLLECTION_FAILED_READ', 'Fail to get the list in this collection directory. COnfirm your permissions to access this directory.'); +define('_IM_SUBDIR_LABEL', 'Sub Collection Directory: '); +define('_IM_SUBDIR_SELECT', 'Select'); +define('_IM_SUBDIR_NONE', 'Nothing'); +define('_IM_SUBDIR_TT', 'Switch to this sub collection directory'); +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.'); +define('_IM_DISPLAY_FILES', 'Display files'); +define('_IM_SUBDIR_REMOVE', 'Remove directory'); +define('_IM_DISPLAY_SUBDIR', 'Manage Sub Directory'); +define('_IM_DISPLAY_SUBDIR_TT', 'Move '); +define('_IM_DISPLAY_SUBDIR_SELECT', 'Choice'); +define('_IM_CREATE_SUBDIR_CONFIRM', 'Create Sub Directory'); +define('_IM_CREATE_SUBDIR_COLLECTION_LABEL', 'Choose collection directory'); +define('_IM_CREATE_SUBDIR_COLLECTION', 'Please chose the collection directory where you would like to create sub directory.'); +define('_IM_CREATE_SUBDIR_INPUT_NAME', 'Name of sub directory'); +define('_IM_CREATE_SUBDIR_CHARS', 'the name of sub directory should be '); +define('_IM_CREATE_SUBDIR_CHARS_DESC', 'For name of directories, the charactors is limited within alphabeds, numbers, underscores, hyphenminus and plus. Maximum 20 letters.'); +define('_IM_RENAME_SUBDIR_BLANK', ''); +define('_IM_RENAME_SUBDIR_TOOLONG', 'The sub directory name should be restricted within 20 letters.'); +define('_IM_RENAME_SUBDIR_WRONG', 'the name for sub directory includes disallowed charactors.'); +define('_IM_RENAME_SUBDIR_DUPLICATE', 'Directory with the same name is already exists.'); +define('_IM_CREATE_SUBDIR_WRONG', 'Creating sub directory failed. Please ask the manager of your server.'); +define('_IM_RENAME_SUBDIR_COLLECTION', 'Sub directory which you want to rename'); +define('_IM_SUBDIR_NUM_FILES', 'the number of files'); +define('_IM_DISPLAY_SUBDIR_LABEL1', 'the number of directories: '); +define('_IM_DISPLAY_SUBDIR_LABEL2', ', the number of files: '); +define('_IM_DISPLAY_SUBDIR_RETURN', 'File list'); +define('_IM_REMOVE_SUBIDR', 'Remove sub directory'); +define('_IM_REMOVE_SUBIDR_CONFIRM', 'Confirm to remove sub directory'); +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.'); +define('_IM_REMOVE_SUBDIR_FAILED', 'Fail to remove this sub directory. Confirm your permissions to this sub directory or included files.'); +define('_IM_DISPLAY_SUBDIR_CAPTION', 'Sub directory list'); +define('_IM_DISPLAY_SUBDIR_NOTHING', 'No sub directories'); +define('_IM_SUBDIR_REMOVE_FAILED', 'Fail to remove this sub directory. Confirm your permission to this sub directory or included files.'); +define('_IM_SUBDIR_FAILED_READ', 'Fail to get the list of this sub directory. Confirm your permission to access this sub directory.'); +?> diff --git a/NP_ImprovedMedia/improvedmedia/lang/index.html b/NP_ImprovedMedia/improvedmedia/lang/index.html new file mode 100755 index 0000000..dd9f433 --- /dev/null +++ b/NP_ImprovedMedia/improvedmedia/lang/index.html @@ -0,0 +1,11 @@ + + + +Nothing Here + + + +

Nothing to see here

+ + + \ 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 index 0000000..a666899 --- /dev/null +++ b/NP_ImprovedMedia/improvedmedia/lang/japanese-euc.php @@ -0,0 +1,135 @@ + diff --git a/NP_ImprovedMedia/improvedmedia/lang/japanese-utf8.php b/NP_ImprovedMedia/improvedmedia/lang/japanese-utf8.php new file mode 100755 index 0000000..6ee5bcb --- /dev/null +++ b/NP_ImprovedMedia/improvedmedia/lang/japanese-utf8.php @@ -0,0 +1,135 @@ + \ No newline at end of file diff --git a/NP_ImprovedMedia/improvedmedia/popups.css b/NP_ImprovedMedia/improvedmedia/popups.css new file mode 100755 index 0000000..ce5c6ec --- /dev/null +++ b/NP_ImprovedMedia/improvedmedia/popups.css @@ -0,0 +1,163 @@ +/** + * 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. + */ +* { + margin: 0px; + padding: 0px; +} + +body { + margin: 10px; + font-family: verdana, arial; + font-size: small; + background-color: #ffffff; + color: #3F3F3F; +} + +img { + border: none; +} + +a:link,a:visited { + color: #1D3565; + font-weight: bold; + text-decoration: none; + border-bottom: dotted 1px #808080; +} + +a:hover { + border-bottom: dotted 1px #808080; +} + +p { + margin: 4px 0px 4px 20px; +} + +p.line { + margin-left: 100px; +} + +h1 { + font-size: large; + color: #596D9D; + margin-bottom: 3px; +} + +span.header { + color: gray; + font-size: small; +} + +h2 { + font-size: medium; + color: #596D9D; + margin: 0.5em 0em 0.5em 0em; +} + +h3 { + color: #596D9D; + font-size: small; + margin: 10px 10px 5px 10px; +} + +table { + border: none; +} + +table caption { + padding: 3px; + text-align: left; + font-weight: bold; +} + +thead { + background-color: linen; +} + +tbody { + background-color: #DDDDDD; +} + +tfoot { + background-color: #FFFFFF; +} + +th, td { + vertical-align: middle; + font-size: small; + font-weight: normal; +} + +th { + margin: 0px; +} + +td { + padding: 3px; + margin: 0px; +} + +th p, td p { + margin:0px; + padding: 0px; +} + +td.right { + text-align: right; +} + +label { + cursor: pointer; +} + +input.formbutton { + font-size: x-small; + padding: 1px; + background-color: #BFBFBF; +} + +dt { + font-weight: bold; +} + +dd { + margin: 0px 0px 5px 10px; +} + +div.filedetail { + margin: 5px; + border: 1px solid #333333; + padding: 5px 10px 5px 10px; +} + +form { + display: inline; +} + +form p.left { + display: inline; + width: 8em; + float: left; +} + +form p.right { + margin: 0px; + padding: 5px 0px 0px 0px; +} + +p.notice { + font-weight: bold; + font-size: large; + color: #FF5A00; +} + +option { + width: 120px; +} \ No newline at end of file diff --git a/NP_MediaUtils/NP_MediaUtils.php b/NP_MediaUtils/NP_MediaUtils.php new file mode 100755 index 0000000..a59d12a --- /dev/null +++ b/NP_MediaUtils/NP_MediaUtils.php @@ -0,0 +1,122 @@ +getDirectory() . 'MediaUtils.php'); + } + + MediaUtils::$lib_path = preg_replace('#/*$#', '', $this->getDirectory()); + MediaUtils::$prefix = (boolean) $CONF['MediaPrefix']; + MediaUtils::$maxsize = (integer) $CONF['MaxUploadSize']; + + $suffixes = explode(',', $CONF['AllowedTypes']); + foreach ($suffixes as $suffix) { + $suffix = trim($suffix); + if(!in_array($suffix, MediaUtils::$suffixes)) { + MediaUtils::$suffixes[] = strtolower($suffix); + } + } + + $result = sql_query('SELECT bnumber, bshortname FROM ' . sql_table('blog') . ';'); + while(FALSE !== ($row = sql_fetch_assoc($result))) { + $blogs[$row['bnumber']] = $row['bshortname']; + } + MediaUtils::$blogs = $blogs; + + if (array_key_exists('blogid', $_GET)) { + $blogid = (integer) $_GET['blogid']; + } else if (array_key_exists('blogid', $_POST)) { + $blogid = (integer) $_POST['blogid']; + } else if (array_key_exists('itemid', $_GET)) { + $blogid = (integer) getBlogIDFromItemID((integer) $_GET['itemid']); + } else if (array_key_exists('itemid', $_POST)) { + $blogid = (integer) getBlogIDFromItemID((integer) $_POST['itemid']); + } else if (array_key_exists(MediaUtils::$cookiename, $_COOKIE)) { + $blogid = (integer) $_COOKIE['blogid']; + } + + if (!$blogid || !array_key_exists($blogid, $blogs)) { + self::setCookie(-1); + return; + } + + MediaUtils::$blogid = (integer) $blogid; + MediaUtils::$bshortname = (string) $blogs[$blogid]; + self::setCookie(1); + + return; + } + + public function event_PreSendContentType($data) { + global $blog, $blogid; + if (MediaUtils::$blogid) { + return; + } + + if (!$blogid && !$blog) { + self::setCookie(-1); + return; + } + + if (!$blogid) { + MediaUtils::$blogid = $blog->getID(); + } else { + MediaUtils::$blogid = $blogid; + } + + if (!$blog) { + MediaUtils::$bshortname = $manager->getBlog(MediaUtils::$blogid)->getShortName(); + } else { + MediaUtils::$bshortname = $blog->getShortName(); + } + + self::setCookie(1); + return; + } + + public function event_InitSkinParse($data) { + global $blogid; + if (MediaUtils::$blogid != $blogid) { + MediaUtils::$blogid = $blogid; + MediaUtils::$bshortname = MediaUtils::$blogs[MediaUtils::$blogid]; + self::setCookie(1); + } + return; + } + + private function setCookie($factor) { + global $CONF; + $factor = (integer) $factor; + + setcookie($CONF['CookiePrefix'] . MediaUtils::$cookiename, MediaUtils::$blogid, time()+180*$factor, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']); + return; + } +} diff --git a/NP_MediaUtils/mediautils/MediaUtils.php b/NP_MediaUtils/mediautils/MediaUtils.php new file mode 100755 index 0000000..0766c01 --- /dev/null +++ b/NP_MediaUtils/mediautils/MediaUtils.php @@ -0,0 +1,490 @@ + '.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 index 0000000..2ab43f0 --- /dev/null +++ b/NP_MediaUtils/mediautils/Medium.php @@ -0,0 +1,229 @@ +__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 index 0000000..b73f456 --- /dev/null +++ b/NP_Thumbnail/NP_Thumbnail.php @@ -0,0 +1,529 @@ +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', '<%popuptext%>'); + 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&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 "

NP_Thumbnail

\n"; + + if($this->getOption('save_thumb') === 'no') { + echo '

' . $this->t(_NP_THUMBNAIL_14) . "

\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 "

" . $this->t(_NP_THUMBNAIL_15, array(self::$thumbdir)) . "
\n"; + echo $this->t(_NP_THUMBNAIL_16, array(self::$max_sync)) . "
\n"; + echo $this->t(_NP_THUMBNAIL_17) . "

\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 "
\n"; + echo "

\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

\n"; + echo "
\n"; + } + } + + echo "
\n"; + echo "
    \n"; + echo "
  • " . $this->t(_NP_THUMBNAIL_18, array($total_media)) . "
  • \n"; + echo "
  • " . $this->t(_NP_THUMBNAIL_19, array($total_candidates)) . "
  • \n"; + echo "
  • " . $this->t(_NP_THUMBNAIL_20, array($total_rejected)) . "
  • \n"; + echo "
\n"; + echo "

\n"; + echo '' . "\n"; + echo "\n"; + echo "\n"; + echo "

\n"; + + if ($logs) { + echo "

" . $this->t(_NP_THUMBNAIL_21) . "

\n"; + echo "
    \n"; + + foreach ($logs as $log) { + echo "
  • {$log}
  • \n"; + } + echo "
\n"; + } + echo "
\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&name={$this->getName()}&path={$medium->path}/{$medium->name}&width={$medium->resampledwidth}&height={$medium->resampledheight}&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 index 0000000..ce240c4 --- /dev/null +++ b/NP_Thumbnail/thumbnail/english.php @@ -0,0 +1,35 @@ + or <%popup%>, depends on NP_MediaUtils'); +define ('_NP_THUMBNAIL_02', 'Maxmum width of thumbnail'); +define ('_NP_THUMBNAIL_03', 'Maxmum height of thumbnail'); +define ('_NP_THUMBNAIL_04', 'Store thumbnail'); +define ('_NP_THUMBNAIL_05', 'No Need'); +define ('_NP_THUMBNAIL_06', 'Filesystem'); +define ('_NP_THUMBNAIL_07', 'Change <%popup%> to thumbnail'); +define ('_NP_THUMBNAIL_08', 'Template for <%Thumbnail%> or <%popup%>'); +define ('_NP_THUMBNAIL_09', 'Thumbnail Images Management'); +define ('_NP_THUMBNAIL_10', 'Invalid parameter of <%0%> and <%1%>'); +define ('_NP_THUMBNAIL_11', 'Fail to read <%0%>'); +define ('_NP_THUMBNAIL_12', 'Fail to generate thumbnail from <%0%>'); +define ('_NP_THUMBNAIL_13', 'Fail to create <%0%> for store of thumbnails'); +define ('_NP_THUMBNAIL_14', 'This function is not allowed.'); +define ('_NP_THUMBNAIL_15', 'Thumbnails is generated in <%0%> on Media directory.'); +define ('_NP_THUMBNAIL_16', 'One session generates <%0%> thumbnails.'); +define ('_NP_THUMBNAIL_17', 'There is a possibility to fail to generate thumbnail if original image is too large.'); +define ('_NP_THUMBNAIL_18', '<%0%> files is in this media directory.'); +define ('_NP_THUMBNAIL_19', '<%0%> files can generate its own thumbnail.'); +define ('_NP_THUMBNAIL_20', '<%0%> thumbnails already generated'); +define ('_NP_THUMBNAIL_21', 'Logs'); diff --git a/NP_Thumbnail/thumbnail/index.html b/NP_Thumbnail/thumbnail/index.html new file mode 100755 index 0000000..498e4ea --- /dev/null +++ b/NP_Thumbnail/thumbnail/index.html @@ -0,0 +1,10 @@ + + + +Notice + + +

Notice

+

Nothing to see here

+ + \ 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 index 0000000..a349052 --- /dev/null +++ b/NP_Thumbnail/thumbnail/japanese-euc.php @@ -0,0 +1,35 @@ +¤Þ¤¿¤Ï<%popup%>¤Ç¥µ¥à¥Í¥¤¥ëɽ¼¨¤ò¤·¤Þ¤¹¡£¥×¥é¥°¥¤¥ó¡ÖNP_MediaUtils¡×¤È°Í¸´Ø·¸¤ò»ý¤Á¤Þ¤¹'); +define ('_NP_THUMBNAIL_02', '¥µ¥à¥Í¥¤¥ë¤Î²£Éý¤ÎºÇÂçÃÍ'); +define ('_NP_THUMBNAIL_03', '¥µ¥à¥Í¥¤¥ë¤Î½ÄÉý¤ÎºÇÂçÃÍ'); +define ('_NP_THUMBNAIL_04', '¥µ¥à¥Í¥¤¥ë²èÁü¤òÊݸ¤·¤Þ¤¹'); +define ('_NP_THUMBNAIL_05', '¤¤¤¤¤¨'); +define ('_NP_THUMBNAIL_06', '¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à'); +define ('_NP_THUMBNAIL_07', '¥¿¥°<%popup%>¤ò¥µ¥à¥Í¥¤¥ë¤Ë¤·¤Þ¤¹'); +define ('_NP_THUMBNAIL_08', '¥¿¥°<%Thumbnail%>¤¢¤ë¤¤¤Ï<%popup%>¤òÃÖ¤­´¹¤¨¤ëºÝ¤Î¥Æ¥ó¥×¥ì¡¼¥È'); +define ('_NP_THUMBNAIL_09', '¥µ¥à¥Í¥¤¥ë²èÁü¤Î´ÉÍý'); +define ('_NP_THUMBNAIL_10', 'NP_Thumbnail: ¥Ñ¥é¥á¡¼¥¿<%0%>¤È<%1%>¤¬ÉÔÀµ¤Ç¤¹'); +define ('_NP_THUMBNAIL_11', 'NP_Thumbnail: Í׵ᤷ¤¿¥Õ¥¡¥¤¥ë<%0%>¤òÆɤ߹þ¤á¤Þ¤»¤ó'); +define ('_NP_THUMBNAIL_12', 'NP_Thumbnail: <%0%>¤Ï¥µ¥à¥Í¥¤¥ë¤òºîÀ®¤Ç¤­¤Ê¤¤¥Õ¥¡¥¤¥ë¤Ç¤¹'); +define ('_NP_THUMBNAIL_13', 'NP_Thumbnail: ¥µ¥à¥Í¥¤¥ëÍѥǥ£¥ì¥¯¥È¥ê<%0%>¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Æ¤¤¤Þ¤¹'); +define ('_NP_THUMBNAIL_14', '¸½ºß¤Ï¥µ¥à¥Í¥¤¥ë¥Õ¥¡¥¤¥ë¤ò¥µ¡¼¥Ð¤ËÊݸ¤·¤Ê¤¤ÀßÄê¤È¤Ê¤Ã¤Æ¤¤¤ë¤¿¤á¡¢¤³¤Î²èÌ̤ǽÐÍè¤ë¤³¤È¤Ï¤¢¤ê¤Þ¤»¤ó¡£'); +define ('_NP_THUMBNAIL_15', '¥µ¥à¥Í¥¤¥ë¤Ï¥á¥Ç¥£¥¢Íѥǥ£¥ì¥¯¥È¥ê¤Î<%0%>¤ËºîÀ®¤µ¤ì¤Þ¤¹'); +define ('_NP_THUMBNAIL_16', '¸½ºß¤Ï1²ó¤¢¤¿¤ê<%0%>Ëç¤Î¥µ¥à¥Í¥¤¥ë¤òºîÀ®¤¹¤ë¤è¤¦¤ËÀßÄꤵ¤ì¤Æ¤¤¤Þ¤¹'); +define ('_NP_THUMBNAIL_17', '¤¢¤Þ¤ê¤Ë½Ä²£¥µ¥¤¥º¤ÎÂ礭¤Ê²èÁü¤Ï¥µ¥à¥Í¥¤¥ë¤¬ºîÀ®¤Ç¤­¤Ê¤¤¾ì¹ç¤¬¤¢¤ê¤Þ¤¹'); +define ('_NP_THUMBNAIL_18', '¸½ºß<%0%>¤Î¥á¥Ç¥£¥¢¤¬ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Þ¤¹'); +define ('_NP_THUMBNAIL_19', '¤½¤Î¤¦¤Á¡¢<%0%>¤Î²èÁü¤Î¥µ¥à¥Í¥¤¥ë¤¬ºîÀ®²Äǽ¤Ç¤¹'); +define ('_NP_THUMBNAIL_20', '¤½¤Î¤¦¤Á¡¢<%0%>¤Î²èÁü¤Î¥µ¥à¥Í¥¤¥ë¤¬¤¹¤Ç¤ËºîÀ®¤µ¤ì¤Æ¤¤¤Þ¤¹¡£'); +define ('_NP_THUMBNAIL_21', '¥í¥°'); diff --git a/NP_Thumbnail/thumbnail/japanese-utf8.php b/NP_Thumbnail/thumbnail/japanese-utf8.php new file mode 100755 index 0000000..65238e4 --- /dev/null +++ b/NP_Thumbnail/thumbnail/japanese-utf8.php @@ -0,0 +1,35 @@ +または<%popup%>でサムネイル表示をします。プラグイン「NP_MediaUtils」と依存関係を持ちます'); +define ('_NP_THUMBNAIL_02', 'サムネイルの横幅の最大値'); +define ('_NP_THUMBNAIL_03', 'サムネイルの縦幅の最大値'); +define ('_NP_THUMBNAIL_04', 'サムネイル画像を保存します'); +define ('_NP_THUMBNAIL_05', 'いいえ'); +define ('_NP_THUMBNAIL_06', 'ファイルシステム'); +define ('_NP_THUMBNAIL_07', 'タグ<%popup%>をサムネイルにします'); +define ('_NP_THUMBNAIL_08', 'タグ<%Thumbnail%>あるいは<%popup%>を置き換える際のテンプレート'); +define ('_NP_THUMBNAIL_09', 'サムネイル画像の管理'); +define ('_NP_THUMBNAIL_10', 'NP_Thumbnail: パラメータ<%0%>と<%1%>が不正です'); +define ('_NP_THUMBNAIL_11', 'NP_Thumbnail: 要求したファイル<%0%>を読み込めません'); +define ('_NP_THUMBNAIL_12', 'NP_Thumbnail: <%0%>はサムネイルを作成できないファイルです'); +define ('_NP_THUMBNAIL_13', 'NP_Thumbnail: サムネイル用ディレクトリ<%0%>の作成に失敗しています'); +define ('_NP_THUMBNAIL_14', '現在はサムネイルファイルをサーバに保存しない設定となっているため、この画面で出来ることはありません。'); +define ('_NP_THUMBNAIL_15', 'サムネイルはメディア用ディレクトリの<%0%>に作成されます'); +define ('_NP_THUMBNAIL_16', '現在は1回あたり<%0%>枚のサムネイルを作成するように設定されています'); +define ('_NP_THUMBNAIL_17', 'あまりに縦横サイズの大きな画像はサムネイルが作成できない場合があります'); +define ('_NP_THUMBNAIL_18', '現在<%0%>のメディアが登録されています'); +define ('_NP_THUMBNAIL_19', 'そのうち、<%0%>の画像のサムネイルが作成可能です'); +define ('_NP_THUMBNAIL_20', 'そのうち、<%0%>の画像のサムネイルがすでに作成されています。'); +define ('_NP_THUMBNAIL_21', 'ログ');