OSDN Git Service

FIX: NP_MediaUtilsをNucleus 3.65/PHP5.4/MySQL5.5で動作するよう修正
[nucleus-jp/nucleus-plugins.git] / trunk / NP_ItemFormat / NP_ItemFormat.php
1 <?php\r
2 /*\r
3         This program is free software; you can redistribute it and/or\r
4         modify it under the terms of the GNU General Public License\r
5         as published by the Free Software Foundation; either version 2\r
6         of the License, or (at your option) any later version.\r
7         (see nucleus/documentation/index.html#license for more info)\r
8 \r
9         History\r
10         -------\r
11         v0.3   [2008/08/23] Improve javascript code.\r
12         v0.21  [2007/06/07] \r
13 */\r
14 \r
15 \r
16 class NP_ItemFormat extends NucleusPlugin {\r
17 \r
18         function getName() { return 'Item Format'; }\r
19         function getAuthor()  { return 'yu'; }\r
20         function getURL() { return 'http://nucleus.datoka.jp/'; }\r
21         function getVersion() { return '0.3'; }\r
22         function getMinNucleusVersion() { return 250; }\r
23         function getEventList() { return array('AdminPrePageHead','AdminPrePageFoot'); }\r
24 \r
25         function getDescription() { \r
26                 return "Prepare item format. Fill form in category option.";\r
27         }\r
28 \r
29         function supportsFeature($what) {\r
30                 switch($what){\r
31                         case 'SqlTablePrefix':\r
32                                 return 1;\r
33                         default:\r
34                                 return 0;\r
35                 }\r
36         }\r
37 \r
38         function install() {\r
39                 $this->createCategoryOption("title", "title", "text", "");\r
40                 $this->createCategoryOption("body", "body", "textarea", "");\r
41                 $this->createCategoryOption("more", "more", "textarea", "");\r
42         }\r
43 \r
44         /*function event_PreAddItemForm(&$data) {\r
45                 $contents =& $data['contents'];\r
46                 \r
47                 if (! $contents['hasBeenSet']) {\r
48                         $contents['title'] = $this->getOption('title');\r
49                         $contents['body']  = $this->getOption('body');\r
50                         $contents['more']  = $this->getOption('more');\r
51                         $contents['hasBeenSet'] = 1;\r
52                 }\r
53         }*/\r
54 \r
55         function doAction($type) {\r
56                 global $member;\r
57                 if (! $member->isLoggedIn()) return;\r
58                 \r
59                 switch ($type) {\r
60                 case 'get':\r
61                         $cid = intGetVar('cid');\r
62                         if ($cid < 1) return;\r
63                         \r
64                         $data = array();\r
65                         $data[]= $this->getCategoryOption($cid, 'title');\r
66                         $data[]= $this->getCategoryOption($cid, 'body');\r
67                         $data[]= $this->getCategoryOption($cid, 'more');\r
68                         echo @join("[[[ itemformat_splitter ]]]", $data);\r
69                         break;\r
70                 default:\r
71                         break;\r
72                 }\r
73         }\r
74 \r
75         function event_AdminPrePageHead(&$data){\r
76                 global $CONF;\r
77                 $path = $CONF['PluginURL'];\r
78                 \r
79                 switch ($data['action']) {\r
80                 case 'createitem':\r
81                         $data['extrahead'] .= <<< EOS\r
82 <script type="text/javascript" src="{$path}itemformat/itemformat_js.php"></script>\r
83 \r
84 EOS;\r
85                         break;\r
86                 default:\r
87                         return;\r
88                 }\r
89                 \r
90                 $this->ob_ok = ob_start();\r
91         }\r
92 \r
93         function event_AdminPrePageFoot(){\r
94                 if (!$this->ob_ok) return;\r
95                 \r
96                 $html = ob_get_contents();\r
97                 ob_end_clean();\r
98                 \r
99                 // add event\r
100                 $target  = '<td><select name="catid"';\r
101                 $replace = '<td><select name="catid" onchange="plug_itemf_change(this)"';\r
102                 echo str_replace($target, $replace, $html);\r
103         }\r
104 \r
105 }\r
106 ?>