• R/O
  • HTTP
  • SSH
  • HTTPS

nucleus-plugins: Commit

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


Commit MetaInfo

Revisionadc6db4a7f5e051b59c70c9cfa300f8db08f3d87 (tree)
Time2008-09-28 16:23:33
Authorkadota <kadota@1ca2...>
Commiterkadota

Log Message

v0.3 - javascript code fixed.

git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@711 1ca29b6e-896d-4ea0-84a5-967f57386b96

Change Summary

Incremental Difference

--- a/trunk/NP_ItemFormat/NP_ItemFormat.php
+++ b/trunk/NP_ItemFormat/NP_ItemFormat.php
@@ -1,101 +1,106 @@
1-<?php
2-/*
3- This program is free software; you can redistribute it and/or
4- modify it under the terms of the GNU General Public License
5- as published by the Free Software Foundation; either version 2
6- of the License, or (at your option) any later version.
7- (see nucleus/documentation/index.html#license for more info)
8-*/
9-
10-
11-class NP_ItemFormat extends NucleusPlugin {
12-
13- function getName() { return 'Item Format'; }
14- function getAuthor() { return 'yu'; }
15- function getURL() { return 'http://nucleus.datoka.jp/'; }
16- function getVersion() { return '0.2'; }
17- function getMinNucleusVersion() { return 250; }
18- function getEventList() { return array('AdminPrePageHead','AdminPrePageFoot'); }
19-
20- function getDescription() {
21- return "Prepare item format. Fill form in category option.";
22- }
23-
24- function supportsFeature($what) {
25- switch($what){
26- case 'SqlTablePrefix':
27- return 1;
28- default:
29- return 0;
30- }
31- }
32-
33- function install() {
34- $this->createCategoryOption("title", "title", "text", "");
35- $this->createCategoryOption("body", "body", "textarea", "");
36- $this->createCategoryOption("more", "more", "textarea", "");
37- }
38-
39- /*function event_PreAddItemForm(&$data) {
40- $contents =& $data['contents'];
41-
42- if (! $contents['hasBeenSet']) {
43- $contents['title'] = $this->getOption('title');
44- $contents['body'] = $this->getOption('body');
45- $contents['more'] = $this->getOption('more');
46- $contents['hasBeenSet'] = 1;
47- }
48- }*/
49-
50- function doAction($type) {
51- global $member;
52- if (! $member->isLoggedIn()) return;
53-
54- switch ($type) {
55- case 'get':
56- $cid = intGetVar('cid');
57- if ($cid < 1) return;
58-
59- $data = array();
60- $data[]= $this->getCategoryOption($cid, 'title');
61- $data[]= $this->getCategoryOption($cid, 'body');
62- $data[]= $this->getCategoryOption($cid, 'more');
63- echo @join("[[[ itemformat_splitter ]]]", $data);
64- break;
65- default:
66- break;
67- }
68- }
69-
70- function event_AdminPrePageHead(&$data){
71- global $CONF;
72- $path = $CONF['PluginURL'];
73-
74- switch ($data['action']) {
75- case 'createitem':
76- $data['extrahead'] = <<< EOS
77-<script type="text/javascript" src="{$path}itemformat/itemformat_js.php"></script>
78-
79-EOS;
80- break;
81- default:
82- return;
83- }
84-
85- $this->ob_ok = ob_start();
86- }
87-
88- function event_AdminPrePageFoot(){
89- if (!$this->ob_ok) return;
90-
91- $html = ob_get_contents();
92- ob_end_clean();
93-
94- // add event
95- $target = '<td><select name="catid"';
96- $replace = '<td><select name="catid" onchange="plug_itemf_change(this)"';
97- echo str_replace($target, $replace, $html);
98- }
99-
100-}
1+<?php
2+/*
3+ This program is free software; you can redistribute it and/or
4+ modify it under the terms of the GNU General Public License
5+ as published by the Free Software Foundation; either version 2
6+ of the License, or (at your option) any later version.
7+ (see nucleus/documentation/index.html#license for more info)
8+
9+ History
10+ -------
11+ v0.3 [2008/08/23] Improve javascript code.
12+ v0.21 [2007/06/07]
13+*/
14+
15+
16+class NP_ItemFormat extends NucleusPlugin {
17+
18+ function getName() { return 'Item Format'; }
19+ function getAuthor() { return 'yu'; }
20+ function getURL() { return 'http://nucleus.datoka.jp/'; }
21+ function getVersion() { return '0.3'; }
22+ function getMinNucleusVersion() { return 250; }
23+ function getEventList() { return array('AdminPrePageHead','AdminPrePageFoot'); }
24+
25+ function getDescription() {
26+ return "Prepare item format. Fill form in category option.";
27+ }
28+
29+ function supportsFeature($what) {
30+ switch($what){
31+ case 'SqlTablePrefix':
32+ return 1;
33+ default:
34+ return 0;
35+ }
36+ }
37+
38+ function install() {
39+ $this->createCategoryOption("title", "title", "text", "");
40+ $this->createCategoryOption("body", "body", "textarea", "");
41+ $this->createCategoryOption("more", "more", "textarea", "");
42+ }
43+
44+ /*function event_PreAddItemForm(&$data) {
45+ $contents =& $data['contents'];
46+
47+ if (! $contents['hasBeenSet']) {
48+ $contents['title'] = $this->getOption('title');
49+ $contents['body'] = $this->getOption('body');
50+ $contents['more'] = $this->getOption('more');
51+ $contents['hasBeenSet'] = 1;
52+ }
53+ }*/
54+
55+ function doAction($type) {
56+ global $member;
57+ if (! $member->isLoggedIn()) return;
58+
59+ switch ($type) {
60+ case 'get':
61+ $cid = intGetVar('cid');
62+ if ($cid < 1) return;
63+
64+ $data = array();
65+ $data[]= $this->getCategoryOption($cid, 'title');
66+ $data[]= $this->getCategoryOption($cid, 'body');
67+ $data[]= $this->getCategoryOption($cid, 'more');
68+ echo @join("[[[ itemformat_splitter ]]]", $data);
69+ break;
70+ default:
71+ break;
72+ }
73+ }
74+
75+ function event_AdminPrePageHead(&$data){
76+ global $CONF;
77+ $path = $CONF['PluginURL'];
78+
79+ switch ($data['action']) {
80+ case 'createitem':
81+ $data['extrahead'] .= <<< EOS
82+<script type="text/javascript" src="{$path}itemformat/itemformat_js.php"></script>
83+
84+EOS;
85+ break;
86+ default:
87+ return;
88+ }
89+
90+ $this->ob_ok = ob_start();
91+ }
92+
93+ function event_AdminPrePageFoot(){
94+ if (!$this->ob_ok) return;
95+
96+ $html = ob_get_contents();
97+ ob_end_clean();
98+
99+ // add event
100+ $target = '<td><select name="catid"';
101+ $replace = '<td><select name="catid" onchange="plug_itemf_change(this)"';
102+ echo str_replace($target, $replace, $html);
103+ }
104+
105+}
101106 ?>
\ No newline at end of file
--- a/trunk/NP_ItemFormat/itemformat/itemformat_js.php
+++ b/trunk/NP_ItemFormat/itemformat/itemformat_js.php
@@ -1,85 +1,90 @@
1-<?php
2- $strRel = '../../../';
3- include($strRel . 'config.php');
4-
5-?>
6-var plug_itemf_cid = -1;
7-var plug_itemf_url = "<?php echo $CONF['ActionURL'];?>";
8-var plug_itemf_xobj = false;
9-
10-window.onload = function() {
11- var o = document.getElementsByName('catid');
12- plug_itemf_init(o);
13- //o.addEventListener('change', plug_itemf_change, true);
14-};
15-
16-
17-function plug_itemf_init(o) {
18- plug_itemf_cid = o[0].value;
19- plug_itemf_xmlhttp();
20-}
21-
22-function plug_itemf_change(o) {
23- plug_itemf_cid = o[o.selectedIndex].value;
24- plug_itemf_xmlhttp();
25-}
26-
27-/*function plug_itemf_change(e) {
28- alert('event:'+ e.target.selectedIndex);
29- var plug_itemf_cid = e.target[e.target.selectedIndex].value;
30- plug_itemf_set();
31-}*/
32-
33-function plug_itemf_set(data){
34- var v = data.split("[[[ itemformat_splitter ]]]");
35- document.getElementById('inputtitle').value = v[0];
36- document.getElementById('inputbody').value = v[1];
37- document.getElementById('inputmore').value = v[2];
38-}
39-
40-function plug_itemf_receive()
41-{
42- if (plug_itemf_xobj.readyState == 4 && plug_itemf_xobj.status == 200)
43- {
44- plug_itemf_set(plug_itemf_xobj.responseText);
45- }
46-}
47-
48-function plug_itemf_xmlhttp_connect()
49-{
50- var pname = 'ItemFormat';
51- var url = plug_itemf_url + '?action=plugin&name=' + pname + '&type=get&cid=' + plug_itemf_cid;
52-
53- plug_itemf_xobj.onreadystatechange=plug_itemf_receive
54- plug_itemf_xobj.open("GET",url,true)
55- plug_itemf_xobj.send('')
56-}
57-
58-function plug_itemf_xmlhttp() {
59- try
60- {
61- plug_itemf_xobj = new ActiveXObject("Msxml2.XMLHTTP");
62- }
63- catch (e)
64- {
65- try
66- {
67- plug_itemf_xobj = new ActiveXObject("Microsoft.XMLHTTP");
68- }
69- catch (e)
70- {
71- plug_itemf_xobj = false;
72- }
73- }
74-
75- if (! plug_itemf_xobj && typeof XMLHttpRequest!='undefined')
76- {
77- plug_itemf_xobj = new XMLHttpRequest();
78- }
79-
80- if (plug_itemf_xobj)
81- {
82- plug_itemf_xmlhttp_connect();
83- }
84-}
85-
1+<?php
2+ $strRel = '../../../';
3+ include($strRel . 'config.php');
4+
5+?>
6+var plug_itemf_cid = -1;
7+var plug_itemf_url = "<?php echo $CONF['ActionURL'];?>";
8+var plug_itemf_xobj = false;
9+
10+window.onload = function() {
11+ var o = document.getElementsByName('catid');
12+ plug_itemf_init(o);
13+ //o.addEventListener('change', plug_itemf_change, true);
14+};
15+
16+
17+function plug_itemf_init(o) {
18+ plug_itemf_cid = o[0].value;
19+ plug_itemf_xmlhttp();
20+}
21+
22+function plug_itemf_change(o) {
23+ plug_itemf_cid = o[o.selectedIndex].value;
24+ plug_itemf_xmlhttp();
25+}
26+
27+/*function plug_itemf_change(e) {
28+ alert('event:'+ e.target.selectedIndex);
29+ var plug_itemf_cid = e.target[e.target.selectedIndex].value;
30+ plug_itemf_set();
31+}*/
32+
33+function plug_itemf_set(data){
34+ var v = data.split("[[[ itemformat_splitter ]]]");
35+
36+ var otitle = document.getElementById('inputtitle');
37+ var obody = document.getElementById('inputbody');
38+ var omore = document.getElementById('inputmore');
39+
40+ if (otitle.value == '') otitle.value = v[0];
41+ if (obody.value == '') obody.value = v[1];
42+ if (omore.value == '') omore.value = v[2];
43+}
44+
45+function plug_itemf_receive()
46+{
47+ if (plug_itemf_xobj.readyState == 4 && plug_itemf_xobj.status == 200)
48+ {
49+ plug_itemf_set(plug_itemf_xobj.responseText);
50+ }
51+}
52+
53+function plug_itemf_xmlhttp_connect()
54+{
55+ var pname = 'ItemFormat';
56+ var url = plug_itemf_url + '?action=plugin&name=' + pname + '&type=get&cid=' + plug_itemf_cid;
57+
58+ plug_itemf_xobj.onreadystatechange=plug_itemf_receive
59+ plug_itemf_xobj.open("GET",url,true)
60+ plug_itemf_xobj.send('')
61+}
62+
63+function plug_itemf_xmlhttp() {
64+ try
65+ {
66+ plug_itemf_xobj = new ActiveXObject("Msxml2.XMLHTTP");
67+ }
68+ catch (e)
69+ {
70+ try
71+ {
72+ plug_itemf_xobj = new ActiveXObject("Microsoft.XMLHTTP");
73+ }
74+ catch (e)
75+ {
76+ plug_itemf_xobj = false;
77+ }
78+ }
79+
80+ if (! plug_itemf_xobj && typeof XMLHttpRequest!='undefined')
81+ {
82+ plug_itemf_xobj = new XMLHttpRequest();
83+ }
84+
85+ if (plug_itemf_xobj)
86+ {
87+ plug_itemf_xmlhttp_connect();
88+ }
89+}
90+
Show on old repository browser