TinyMCE Templates - Version 0.1

Version Description

  • The first release.

=

Download this release

Release Info

Developer miyauchi
Plugin Icon 128x128 TinyMCE Templates
Version 0.1
Comparing to
See all releases

Version 0.1

editor.css ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ table {
2
+ border: 1px dashed #cccccc;
3
+ }
4
+
5
+ th,td {
6
+ border: 1px dashed #cccccc;
7
+ }
img/icon.png ADDED
Binary file
img/large.png ADDED
Binary file
includes/MceTemplatesAdmin.class.php ADDED
@@ -0,0 +1,260 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MceTemplatesAdmin{
4
+ function MceTemplatesAdmin($class)
5
+ {
6
+ global $wpdb;
7
+
8
+ $this->domain = $class->name;
9
+ $this->table = $wpdb->prefix.$class->table;
10
+
11
+ echo '<link rel="stylesheet" href="'.WP_PLUGIN_URL.'/'.$this->domain.'/style.css" type="text/css" media="all" />';
12
+
13
+ echo '<div class="wrap">';
14
+
15
+ if (isset($_GET['page']) && $_GET['page'] == 'edittemplates') {
16
+ if (isset($_GET['id']) && preg_match("/^[a-zA-Z0-9]{32}$/", $_GET['id'])) {
17
+ $this->addView();
18
+ } else {
19
+ $this->editView();
20
+ }
21
+ } elseif (isset($_GET['page']) && $_GET['page'] == 'addnewtemplates') {
22
+ $this->addView();
23
+ }
24
+
25
+ echo '</div>';
26
+ }
27
+
28
+
29
+ function editView()
30
+ {
31
+ global $wpdb;
32
+ global $current_user;
33
+
34
+ echo '<h2>'.__("Edit Templates", $this->domain).'</h2>';
35
+
36
+ if (isset($_POST['templates']) && is_array($_POST['templates'])) {
37
+ $this->delete();
38
+ echo '<div id="message" class="updated fade"><p>'.$n.__("Templates permanently deleted.", $this->domain).'</p></div>';
39
+ }
40
+
41
+ echo "<form method=\"post\" action=\"{$_SERVER['REQUEST_URI']}\">";
42
+ echo '<table class="widefat" cellspacing="0">';
43
+ echo '<thead>';
44
+ echo '<tr>';
45
+ echo '<th scope="col" class="column-cb check-column"><input type="checkbox" /></th>';
46
+ echo '<th scope="col">'.__('Name', $this->domain).'</th>';
47
+ echo '<th scope="col">'.__('Description', $this->domain).'</th>';
48
+ echo '<th scope="col">'.__('Author', $this->domain).'</th>';
49
+ echo '<th scope="col">'.__('Share', $this->domain).'</th>';
50
+ echo '</tr>';
51
+ echo '</thead>';
52
+ echo '<tfoot>';
53
+ echo '<tr>';
54
+ echo '<th scope="col" class="column-cb check-column"><input type="checkbox" /></th>';
55
+ echo '<th scope="col">'.__('Name', $this->domain).'</th>';
56
+ echo '<th scope="col">'.__('Description', $this->domain).'</th>';
57
+ echo '<th scope="col">'.__('Author', $this->domain).'</th>';
58
+ echo '<th scope="col">'.__('Share', $this->domain).'</th>';
59
+ echo '</tr>';
60
+ echo '</tfoot>';
61
+ echo '<tbody>';
62
+
63
+ $sql = "select * from {$this->table}
64
+ where `author`={$current_user->ID} or `share`=1 order by `modified` desc";
65
+ $row = $wpdb->get_results($sql);
66
+
67
+ $i = 0;
68
+ foreach ($row as $tpl) {
69
+ if ($tpl->author === $current_user->ID) {
70
+ $mine = true;
71
+ } else {
72
+ $mine = false;
73
+ }
74
+ if ($i % 2) {
75
+ $class = 'alternate';
76
+ } else {
77
+ $class = '';
78
+ }
79
+ echo '<tr class="'.$class.'" valign="top">';
80
+ if ($mine) {
81
+ echo '<th scope="row" class="check-column">';
82
+ echo "<input type=\"checkbox\" name=\"templates[]\"
83
+ value=\"{$tpl->ID}\" />";
84
+ echo '</th>';
85
+ echo '<td><a href="?page=edittemplates&id='.$tpl->ID.'">'.esc_html($tpl->name).'</a></td>';
86
+ } else {
87
+ echo '<th scope="row" class="check-column">&nbsp;</th>';
88
+ echo '<td>'.esc_html($tpl->name).'</td>';
89
+ }
90
+ echo '<td>'.esc_html($tpl->desc).'</td>';
91
+ $author = get_userdata($tpl->author);
92
+ echo '<td>'.esc_html($author->nickname).'</td>';
93
+ if ($tpl->share) {
94
+ echo '<td>'.__('Shared', $this->domain).'</td>';
95
+ } else {
96
+ echo '<td>'.__('Private', $this->domain).'</td>';
97
+ }
98
+ echo "</tr>";
99
+ $i = $i + 1;
100
+ }
101
+ echo "</tbody>";
102
+ echo "</table>";
103
+ echo '<input type="submit" value="'.__("Delete checked items", $this->domain).'" class="button-secondary" />';
104
+ echo "</form>";
105
+ }
106
+
107
+ function addView()
108
+ {
109
+ global $current_user;
110
+
111
+ if (isset($_POST['save']) && $_POST['save']) {
112
+ if ($this->validate() && $this->save()) {
113
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>".__("Template saved.", $this->domain)."</strong></p></div>";
114
+ global $wpdb;
115
+ $sql = $wpdb->prepare("select * from {$this->table}
116
+ where `id`=%s", $_POST['id']);
117
+ $r = $wpdb->get_row($sql);
118
+ $id = $r->ID;
119
+ $name = $r->name;
120
+ $desc = $r->desc;
121
+ $html = stripslashes($r->html);
122
+ $share = $r->share;
123
+ } else {
124
+ echo "<div id=\"message\" class=\"error fade\"><p><strong>".__("All entry must not be blank.", $this->domain)."</strong></p></div>";
125
+ $id = $_POST['id'];
126
+ $name = $_POST['name'];
127
+ $desc = $_POST['desc'];
128
+ $html = stripslashes($_POST['html']);
129
+ $share = $_POST['share'];
130
+ }
131
+ } elseif (isset($_GET['page']) && $_GET['page'] == 'edittemplates'
132
+ && isset($_GET['id']) && preg_match("/^[a-zA-Z0-9]{32}$/", $_GET['id'])) {
133
+ global $wpdb;
134
+ $sql = $wpdb->prepare("select * from {$this->table}
135
+ where `ID`=%s and author=%s", $_GET['id'], $current_user->ID);
136
+ $r = $wpdb->get_row($sql);
137
+ if ($r) {
138
+ $id = $r->ID;
139
+ $name = $r->name;
140
+ $desc = $r->desc;
141
+ $html = stripslashes($r->html);
142
+ $share = $r->share;
143
+ } else {
144
+ return;
145
+ }
146
+ } else {
147
+ $id = md5(uniqid(rand(), true));
148
+ $name = null;
149
+ $desc = null;
150
+ $html = null;
151
+ $share = null;
152
+ }
153
+
154
+ if (isset($_GET['page']) && $_GET['page'] == 'edittemplates'
155
+ && isset($_GET['id']) && preg_match("/^[a-zA-Z0-9]{32}$/", $_GET['id'])) {
156
+ echo '<h2>'.__("Edit Templates", $this->domain).'</h2>';
157
+ } else {
158
+ echo '<h2>'.__("Add New Templates", $this->domain).'</h2>';
159
+ }
160
+ echo "<form action=\"{$_SERVER["REQUEST_URI"]}\" method=\"post\">";
161
+ echo "<input type=\"hidden\" name=\"save\" value=\"1\" />";
162
+ echo "<input type=\"hidden\" name=\"id\" value=\"{$id}\" />";
163
+ echo "<h3>".__("Template Name", $this->domain)."*</h3>";
164
+ echo "<input type=\"text\" id=\"name\" name=\"name\" value=\"{$name}\" />";
165
+ echo "<h3>".__("Template Description", $this->domain)."*</h3>";
166
+ echo "<textarea id=\"desc\" name=\"desc\">{$desc}</textarea>";
167
+ echo "<h3>".__("Template Contents", $this->domain)."*</h3>";
168
+ echo "<textarea id=\"html\" name=\"html\">{$html}</textarea>";
169
+ echo "<h3>".__("Share", $this->domain)."*</h3>";
170
+ echo "<select name=\"share\" id=\"share\">";
171
+ if ($share == 1) {
172
+ echo "<option value=\"1\" selected=\"selected\">".__("Share", $this->domain)."</option>";
173
+ echo "<option value=\"0\">".__("Private", $this->domain)."</option>";
174
+ } else {
175
+ echo "<option value=\"1\">".__("Share", $this->domain)."</option>";
176
+ echo "<option value=\"0\" selected=\"selected\">".__("Private", $this->domain)."</option>";
177
+ }
178
+ echo "</select>";
179
+ echo "<div id=\"save\">";
180
+ echo "<input type=\"submit\" value=\"".__("Save Template", $this->domain)."\" class=\"button-primary\" />";
181
+ echo "</div>";
182
+ echo "</form>";
183
+ }
184
+
185
+ function save()
186
+ {
187
+ global $wpdb;
188
+ global $current_user;
189
+
190
+ if (!$this->checkAuth($_POST['id'])) {
191
+ return false;
192
+ }
193
+
194
+ $sql = "insert into {$this->table}
195
+ (`ID`, `name`, `desc`, `html`, `share`, `author`)
196
+ values
197
+ (%s, %s, %s, %s, %d, %d)
198
+ on duplicate key
199
+ update
200
+ `name`=values(`name`),
201
+ `desc`=values(`desc`),
202
+ `html`=values(`html`),
203
+ `share`=values(`share`)
204
+ ";
205
+ $sql = $wpdb->prepare($sql, $_POST['id'], $_POST['name'], $_POST['desc'],
206
+ $_POST['html'], $_POST['share'], $current_user->ID);
207
+ $wpdb->query($sql);
208
+ return true;
209
+ }
210
+
211
+ function validate()
212
+ {
213
+ $pars = array('id', 'name', 'desc', 'html', 'share');
214
+ foreach ($pars as $par):
215
+ $_POST[$par] = trim($_POST[$par]);
216
+ if (!isset($_POST[$par]) || !strlen($_POST[$par])) {
217
+ return false;
218
+ }
219
+ endforeach;
220
+
221
+ if (!preg_match("/^[a-zA-Z0-9]{32}$/", $_POST['id'])) {
222
+ return false;
223
+ }
224
+
225
+ if ($_POST['share'] !== '1') {
226
+ $_POST['share'] = '0';
227
+ }
228
+
229
+ return true;
230
+ }
231
+
232
+ function checkAuth($id)
233
+ {
234
+ global $wpdb;
235
+ global $current_user;
236
+
237
+ $sql = $wpdb->prepare("select author from {$this->table} where ID=%s", $id);
238
+ $author = $wpdb->get_var($sql);
239
+
240
+ if (!$author || $author === $current_user->ID) {
241
+ return true;
242
+ } else {
243
+ return false;
244
+ }
245
+ }
246
+
247
+ function delete()
248
+ {
249
+ global $wpdb;
250
+ global $current_user;
251
+
252
+ foreach ($_POST['templates'] as $tpl) {
253
+ $sql = "delete from {$this->table} where ID=%s and author=%s";
254
+ $sql = $wpdb->prepare($sql, $tpl, $current_user->ID);
255
+ $wpdb->query($sql);
256
+ }
257
+ }
258
+ }
259
+
260
+ ?>
includes/TinyMCETemplate.class.php ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ new TinyMCETemplate();
4
+
5
+ class TinyMCETemplate{
6
+
7
+ private $mce_css = null;
8
+
9
+ function __construct()
10
+ {
11
+ $url = WP_PLUGIN_URL.'/tinymce_templates';
12
+ $plugin = $url.'/mce_plugins/plugins/template/editor_plugin.js';
13
+ $path = dirname(__FILE__).'/../mce_plugins/plugins';
14
+ $lang = $path.'/template/langs/langs.php';
15
+ $inits = array();
16
+ $url = get_bloginfo('url');
17
+ $inits['template_external_list_url'] = $url.'/mce_templates.js';
18
+ $this->mce_css = $url.'/editor.css';
19
+ new mcePlugins(
20
+ 'template',
21
+ $plugin,
22
+ $lang,
23
+ array(&$this, 'add_button'),
24
+ $inits
25
+ );
26
+
27
+ add_filter('mce_css', array(&$this, 'addCSS'));
28
+ add_filter('query_vars', array(&$this, 'query_vars'));
29
+ add_filter('rewrite_rules_array', array(&$this, 'rewrite_rules_array'));
30
+ add_action('init', array(&$this, 'init'));
31
+ add_action('wp', array(&$this, 'wp'));
32
+ }
33
+
34
+ public function addCSS($css)
35
+ {
36
+ return $css.','.$this->mce_css;
37
+ }
38
+
39
+ public function add_button($buttons = array())
40
+ {
41
+ array_unshift($buttons, '|');
42
+ array_unshift($buttons, 'template');
43
+ return $buttons;
44
+ }
45
+
46
+ public function init(){
47
+ global $wp_rewrite;
48
+ $rules = $wp_rewrite->wp_rewrite_rules();
49
+ if (!isset($rules['mce_templates.js$'])) {
50
+ $wp_rewrite->flush_rules();
51
+ }
52
+ }
53
+
54
+ public function rewrite_rules_array($rules){
55
+ global $wp_rewrite;
56
+ $new_rules['mce_templates.js$'] = $wp_rewrite->index . '?mce_templates=1';
57
+ $rules = array_merge($new_rules, $rules);
58
+ return $rules;
59
+ }
60
+
61
+ public function query_vars($vars) {
62
+ $vars[] = 'mce_templates';
63
+ return $vars;
64
+ }
65
+
66
+ public function wp(){
67
+ if (get_query_var('mce_templates')) {
68
+ global $wpdb;
69
+ global $user_login;
70
+ global $current_user;
71
+ global $MceTemplates;
72
+
73
+ if (!$user_login) {
74
+ exit;
75
+ }
76
+
77
+ if( isset($_GET['id']) && strlen($_GET['id']) ){
78
+ $sql = "select html from {$wpdb->prefix}{$MceTemplates->table}
79
+ where (`ID`=%s) and (`author`={$current_user->ID} or `share`=1)
80
+ order by `modified` desc";
81
+ $sql = $wpdb->prepare($sql, $_GET['id']);
82
+ $template = $wpdb->get_var($sql);
83
+ if ($template) {
84
+ echo stripslashes($template);
85
+ }
86
+ exit;
87
+ }
88
+
89
+ $sql = "select * from {$wpdb->prefix}{$MceTemplates->table}
90
+ where `author`={$current_user->ID} or `share`=1
91
+ order by `modified` desc";
92
+ $row = $wpdb->get_results($sql);
93
+
94
+ header( 'Content-Type: application/x-javascript; charset=UTF-8' );
95
+ echo 'var tinyMCETemplateList = [';
96
+ $arr = array();
97
+ foreach ($row as $tpl) {
98
+ $ID = esc_html($tpl->ID);
99
+ $name = $tpl->name;
100
+ $desc = esc_html($tpl->desc);
101
+ $arr[] = "[\"{$name}\", \"/mce_templates.js?id={$ID}\", \"{$desc}\"]";
102
+ }
103
+ echo join(',', $arr);
104
+ echo ']';
105
+ exit;
106
+ }
107
+ }
108
+ }
109
+
110
+ ?>
includes/mceplugins.class.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Add TinyMCE plugis easily
4
+
5
+ Parameters
6
+ $plugin_url: url of editor_plugin.js
7
+ $lang_path: path of langs.php
8
+ $plugin_name: name of plugin
9
+ */
10
+ if (!class_exists('mcePlugins')) {
11
+ class mcePlugins{
12
+
13
+ private $name = null;
14
+ private $url = null;
15
+ private $lang_path = null;
16
+ private $inits = array();
17
+
18
+ function __construct($plugin_name, $plugin_url,
19
+ $lang_path = null, $button_callback = null, $inits = array())
20
+ {
21
+ $this->name = $plugin_name;
22
+ $this->url = $plugin_url;
23
+ add_filter('mce_external_plugins', array(&$this, 'external_plugins'));
24
+ if ($lang_path) {
25
+ $this->lang_path = $lang_path;
26
+ add_filter('mce_external_languages', array(&$this, 'external_languages'));
27
+ }
28
+ if ($inits) {
29
+ $this->inits = $inits;
30
+ add_filter('tiny_mce_before_init', array(&$this, 'before_init'));
31
+ }
32
+ if ($button_callback) {
33
+ add_filter('mce_buttons', $button_callback);
34
+ }
35
+ }
36
+
37
+ public function before_init($inits){
38
+ foreach ($this->inits as $key => $value) {
39
+ $inits[$key] = $value;
40
+ }
41
+ return $inits;
42
+ }
43
+
44
+ public function external_plugins($plugins = array())
45
+ {
46
+ $plugins[$this->name] = $this->url;
47
+ return $plugins;
48
+ }
49
+
50
+ public function external_languages($langs)
51
+ {
52
+ $langs[$this->name] = $this->lang_path;
53
+ return $langs;
54
+ }
55
+
56
+ }
57
+ }
58
+
59
+ ?>
langs/tinymce_templates-ja.mo ADDED
Binary file
langs/tinymce_templates-ja.po ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: PACKAGE VERSION\n"
10
+ "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2010-11-21 05:06+0900\n"
12
+ "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "Language: \n"
16
+ "MIME-Version: 1.0\n"
17
+ "Content-Type: text/plain; charset=UTF-8\n"
18
+ "Content-Transfer-Encoding: 8bit\n"
19
+
20
+ #: ..//includes/MceTemplatesAdmin.class.php:34
21
+ #: ..//includes/MceTemplatesAdmin.class.php:156 ..//tinymce_templates.php:103
22
+ msgid "Edit Templates"
23
+ msgstr "テンプレートを編集"
24
+
25
+ #: ..//includes/MceTemplatesAdmin.class.php:38
26
+ msgid "Templates permanently deleted."
27
+ msgstr "テンプレートを削除しました。"
28
+
29
+ #: ..//includes/MceTemplatesAdmin.class.php:46
30
+ #: ..//includes/MceTemplatesAdmin.class.php:55
31
+ msgid "Name"
32
+ msgstr "名前"
33
+
34
+ #: ..//includes/MceTemplatesAdmin.class.php:47
35
+ #: ..//includes/MceTemplatesAdmin.class.php:56
36
+ msgid "Description"
37
+ msgstr "説明"
38
+
39
+ #: ..//includes/MceTemplatesAdmin.class.php:48
40
+ #: ..//includes/MceTemplatesAdmin.class.php:57
41
+ msgid "Author"
42
+ msgstr "作成者"
43
+
44
+ #: ..//includes/MceTemplatesAdmin.class.php:49
45
+ #: ..//includes/MceTemplatesAdmin.class.php:58
46
+ #: ..//includes/MceTemplatesAdmin.class.php:169
47
+ #: ..//includes/MceTemplatesAdmin.class.php:172
48
+ #: ..//includes/MceTemplatesAdmin.class.php:175
49
+ msgid "Share"
50
+ msgstr "共有"
51
+
52
+ #: ..//includes/MceTemplatesAdmin.class.php:94
53
+ msgid "Shared"
54
+ msgstr "共有"
55
+
56
+ #: ..//includes/MceTemplatesAdmin.class.php:96
57
+ #: ..//includes/MceTemplatesAdmin.class.php:173
58
+ #: ..//includes/MceTemplatesAdmin.class.php:176
59
+ msgid "Private"
60
+ msgstr "個人"
61
+
62
+ #: ..//includes/MceTemplatesAdmin.class.php:103
63
+ msgid "Delete checked items"
64
+ msgstr "選択したアイテムを削除"
65
+
66
+ #: ..//includes/MceTemplatesAdmin.class.php:113
67
+ msgid "Template saved."
68
+ msgstr "テンプレートを保存しました。"
69
+
70
+ #: ..//includes/MceTemplatesAdmin.class.php:124
71
+ msgid "All entry must not be blank."
72
+ msgstr "すべての項目に入力してください。"
73
+
74
+ #: ..//includes/MceTemplatesAdmin.class.php:158 ..//tinymce_templates.php:111
75
+ msgid "Add New Templates"
76
+ msgstr "テンプレートの新規登録"
77
+
78
+ #: ..//includes/MceTemplatesAdmin.class.php:163
79
+ msgid "Template Name"
80
+ msgstr "テンプレート名"
81
+
82
+ #: ..//includes/MceTemplatesAdmin.class.php:165
83
+ msgid "Template Description"
84
+ msgstr "テンプレートの説明"
85
+
86
+ #: ..//includes/MceTemplatesAdmin.class.php:167
87
+ msgid "Template Contents"
88
+ msgstr "テンプレート"
89
+
90
+ #: ..//includes/MceTemplatesAdmin.class.php:180
91
+ msgid "Save Template"
92
+ msgstr "テンプレートを保存"
93
+
94
+ #: ..//tinymce_templates.php:94
95
+ msgid "tinyMCE Templates"
96
+ msgstr "テンプレートを編集"
97
+
98
+ #: ..//tinymce_templates.php:95
99
+ msgid "Templates"
100
+ msgstr "テンプレート"
101
+
102
+ #: ..//tinymce_templates.php:104
103
+ msgid "Edit"
104
+ msgstr "編集"
105
+
106
+ #: ..//tinymce_templates.php:112
107
+ msgid "Add New"
108
+ msgstr "新規追加"
langs/tinymce_templates.pot ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: PACKAGE VERSION\n"
10
+ "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2010-11-21 05:10+0900\n"
12
+ "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "Language: \n"
16
+ "MIME-Version: 1.0\n"
17
+ "Content-Type: text/plain; charset=CHARSET\n"
18
+ "Content-Transfer-Encoding: 8bit\n"
19
+
20
+ #: ../includes/MceTemplatesAdmin.class.php:34
21
+ #: ../includes/MceTemplatesAdmin.class.php:156 ../tinymce_templates.php:103
22
+ msgid "Edit Templates"
23
+ msgstr ""
24
+
25
+ #: ../includes/MceTemplatesAdmin.class.php:38
26
+ msgid "Templates permanently deleted."
27
+ msgstr ""
28
+
29
+ #: ../includes/MceTemplatesAdmin.class.php:46
30
+ #: ../includes/MceTemplatesAdmin.class.php:55
31
+ msgid "Name"
32
+ msgstr ""
33
+
34
+ #: ../includes/MceTemplatesAdmin.class.php:47
35
+ #: ../includes/MceTemplatesAdmin.class.php:56
36
+ msgid "Description"
37
+ msgstr ""
38
+
39
+ #: ../includes/MceTemplatesAdmin.class.php:48
40
+ #: ../includes/MceTemplatesAdmin.class.php:57
41
+ msgid "Author"
42
+ msgstr ""
43
+
44
+ #: ../includes/MceTemplatesAdmin.class.php:49
45
+ #: ../includes/MceTemplatesAdmin.class.php:58
46
+ #: ../includes/MceTemplatesAdmin.class.php:169
47
+ #: ../includes/MceTemplatesAdmin.class.php:172
48
+ #: ../includes/MceTemplatesAdmin.class.php:175
49
+ msgid "Share"
50
+ msgstr ""
51
+
52
+ #: ../includes/MceTemplatesAdmin.class.php:94
53
+ msgid "Shared"
54
+ msgstr ""
55
+
56
+ #: ../includes/MceTemplatesAdmin.class.php:96
57
+ #: ../includes/MceTemplatesAdmin.class.php:173
58
+ #: ../includes/MceTemplatesAdmin.class.php:176
59
+ msgid "Private"
60
+ msgstr ""
61
+
62
+ #: ../includes/MceTemplatesAdmin.class.php:103
63
+ msgid "Delete checked items"
64
+ msgstr ""
65
+
66
+ #: ../includes/MceTemplatesAdmin.class.php:113
67
+ msgid "Template saved."
68
+ msgstr ""
69
+
70
+ #: ../includes/MceTemplatesAdmin.class.php:124
71
+ msgid "All entry must not be blank."
72
+ msgstr ""
73
+
74
+ #: ../includes/MceTemplatesAdmin.class.php:158 ../tinymce_templates.php:111
75
+ msgid "Add New Templates"
76
+ msgstr ""
77
+
78
+ #: ../includes/MceTemplatesAdmin.class.php:163
79
+ msgid "Template Name"
80
+ msgstr ""
81
+
82
+ #: ../includes/MceTemplatesAdmin.class.php:165
83
+ msgid "Template Description"
84
+ msgstr ""
85
+
86
+ #: ../includes/MceTemplatesAdmin.class.php:167
87
+ msgid "Template Contents"
88
+ msgstr ""
89
+
90
+ #: ../includes/MceTemplatesAdmin.class.php:180
91
+ msgid "Save Template"
92
+ msgstr ""
93
+
94
+ #: ../tinymce_templates.php:94
95
+ msgid "tinyMCE Templates"
96
+ msgstr ""
97
+
98
+ #: ../tinymce_templates.php:95
99
+ msgid "Templates"
100
+ msgstr ""
101
+
102
+ #: ../tinymce_templates.php:104
103
+ msgid "Edit"
104
+ msgstr ""
105
+
106
+ #: ../tinymce_templates.php:112
107
+ msgid "Add New"
108
+ msgstr ""
mce_plugins/plugins/template/blank.htm ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <html xmlns="http://www.w3.org/1999/xhtml">
2
+ <head>
3
+ <title>blank_page</title>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
5
+ <script type="text/javascript">
6
+ parent.TemplateDialog.loadCSSFiles(document);
7
+ </script>
8
+ </head>
9
+ <body id="mceTemplatePreview" class="mceContentBody">
10
+
11
+ </body>
12
+ </html>
mce_plugins/plugins/template/css/template.css ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #frmbody {
2
+ padding: 10px;
3
+ background-color: #FFF;
4
+ border: 1px solid #CCC;
5
+ }
6
+
7
+ .frmRow {
8
+ margin-bottom: 10px;
9
+ }
10
+
11
+ #templatesrc {
12
+ border: none;
13
+ width: 320px;
14
+ height: 240px;
15
+ }
16
+
17
+ .title {
18
+ padding-bottom: 5px;
19
+ }
20
+
21
+ .mceActionPanel {
22
+ padding-top: 5px;
23
+ }
mce_plugins/plugins/template/editor_plugin.js ADDED
@@ -0,0 +1 @@
 
1
+ (function(){var a=tinymce.each;tinymce.create("tinymce.plugins.TemplatePlugin",{init:function(b,c){var d=this;d.editor=b;b.addCommand("mceTemplate",function(e){b.windowManager.open({file:c+"/template.htm",width:b.getParam("template_popup_width",400),height:b.getParam("template_popup_height",300),inline:1},{plugin_url:c})});b.addCommand("mceInsertTemplate",d._insertTemplate,d);b.addButton("template",{title:"template.desc",cmd:"mceTemplate"});b.onPreProcess.add(function(e,g){var f=e.dom;a(f.select("div",g.node),function(h){if(f.hasClass(h,"mceTmpl")){a(f.select("*",h),function(i){if(f.hasClass(i,e.getParam("template_mdate_classes","mdate").replace(/\s+/g,"|"))){i.innerHTML=d._getDateTime(new Date(),e.getParam("template_mdate_format",e.getLang("template.mdate_format")))}});d._replaceVals(h)}})})},getInfo:function(){return{longname:"Template plugin",author:"Moxiecode Systems AB",authorurl:"http://www.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/template",version:tinymce.majorVersion+"."+tinymce.minorVersion}},_insertTemplate:function(i,j){var k=this,g=k.editor,f,c,d=g.dom,b=g.selection.getContent();f=j.content;a(k.editor.getParam("template_replace_values"),function(l,h){if(typeof(l)!="function"){f=f.replace(new RegExp("\\{\\$"+h+"\\}","g"),l)}});c=d.create("div",null,f);n=d.select(".mceTmpl",c);if(n&&n.length>0){c=d.create("div",null);c.appendChild(n[0].cloneNode(true))}function e(l,h){return new RegExp("\\b"+h+"\\b","g").test(l.className)}a(d.select("*",c),function(h){if(e(h,g.getParam("template_cdate_classes","cdate").replace(/\s+/g,"|"))){h.innerHTML=k._getDateTime(new Date(),g.getParam("template_cdate_format",g.getLang("template.cdate_format")))}if(e(h,g.getParam("template_mdate_classes","mdate").replace(/\s+/g,"|"))){h.innerHTML=k._getDateTime(new Date(),g.getParam("template_mdate_format",g.getLang("template.mdate_format")))}if(e(h,g.getParam("template_selected_content_classes","selcontent").replace(/\s+/g,"|"))){h.innerHTML=b}});k._replaceVals(c);g.execCommand("mceInsertContent",false,c.innerHTML);g.addVisual()},_replaceVals:function(c){var d=this.editor.dom,b=this.editor.getParam("template_replace_values");a(d.select("*",c),function(f){a(b,function(g,e){if(d.hasClass(f,e)){if(typeof(b[e])=="function"){b[e](f)}}})})},_getDateTime:function(e,b){if(!b){return""}function c(g,d){var f;g=""+g;if(g.length<d){for(f=0;f<(d-g.length);f++){g="0"+g}}return g}b=b.replace("%D","%m/%d/%y");b=b.replace("%r","%I:%M:%S %p");b=b.replace("%Y",""+e.getFullYear());b=b.replace("%y",""+e.getYear());b=b.replace("%m",c(e.getMonth()+1,2));b=b.replace("%d",c(e.getDate(),2));b=b.replace("%H",""+c(e.getHours(),2));b=b.replace("%M",""+c(e.getMinutes(),2));b=b.replace("%S",""+c(e.getSeconds(),2));b=b.replace("%I",""+((e.getHours()+11)%12+1));b=b.replace("%p",""+(e.getHours()<12?"AM":"PM"));b=b.replace("%B",""+this.editor.getLang("template_months_long").split(",")[e.getMonth()]);b=b.replace("%b",""+this.editor.getLang("template_months_short").split(",")[e.getMonth()]);b=b.replace("%A",""+this.editor.getLang("template_day_long").split(",")[e.getDay()]);b=b.replace("%a",""+this.editor.getLang("template_day_short").split(",")[e.getDay()]);b=b.replace("%%","%");return b}});tinymce.PluginManager.add("template",tinymce.plugins.TemplatePlugin)})();
mce_plugins/plugins/template/editor_plugin_src.js ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
3
+ *
4
+ * @author Moxiecode
5
+ * @copyright Copyright � 2004-2008, Moxiecode Systems AB, All rights reserved.
6
+ */
7
+
8
+ (function() {
9
+ var each = tinymce.each;
10
+
11
+ tinymce.create('tinymce.plugins.TemplatePlugin', {
12
+ init : function(ed, url) {
13
+ var t = this;
14
+
15
+ t.editor = ed;
16
+
17
+ // Register commands
18
+ ed.addCommand('mceTemplate', function(ui) {
19
+ ed.windowManager.open({
20
+ file : url + '/template.htm',
21
+ width : ed.getParam('template_popup_width', 750),
22
+ height : ed.getParam('template_popup_height', 600),
23
+ inline : 1
24
+ }, {
25
+ plugin_url : url
26
+ });
27
+ });
28
+
29
+ ed.addCommand('mceInsertTemplate', t._insertTemplate, t);
30
+
31
+ // Register buttons
32
+ ed.addButton('template', {title : 'template.desc', cmd : 'mceTemplate'});
33
+
34
+ ed.onPreProcess.add(function(ed, o) {
35
+ var dom = ed.dom;
36
+
37
+ each(dom.select('div', o.node), function(e) {
38
+ if (dom.hasClass(e, 'mceTmpl')) {
39
+ each(dom.select('*', e), function(e) {
40
+ if (dom.hasClass(e, ed.getParam('template_mdate_classes', 'mdate').replace(/\s+/g, '|')))
41
+ e.innerHTML = t._getDateTime(new Date(), ed.getParam("template_mdate_format", ed.getLang("template.mdate_format")));
42
+ });
43
+
44
+ t._replaceVals(e);
45
+ }
46
+ });
47
+ });
48
+ },
49
+
50
+ getInfo : function() {
51
+ return {
52
+ longname : 'Template plugin',
53
+ author : 'Moxiecode Systems AB',
54
+ authorurl : 'http://www.moxiecode.com',
55
+ infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/template',
56
+ version : tinymce.majorVersion + "." + tinymce.minorVersion
57
+ };
58
+ },
59
+
60
+ _insertTemplate : function(ui, v) {
61
+ var t = this, ed = t.editor, h, el, dom = ed.dom, sel = ed.selection.getContent();
62
+
63
+ h = v.content;
64
+
65
+ each(t.editor.getParam('template_replace_values'), function(v, k) {
66
+ if (typeof(v) != 'function')
67
+ h = h.replace(new RegExp('\\{\\$' + k + '\\}', 'g'), v);
68
+ });
69
+
70
+ el = dom.create('div', null, h);
71
+
72
+ // Find template element within div
73
+ n = dom.select('.mceTmpl', el);
74
+ if (n && n.length > 0) {
75
+ el = dom.create('div', null);
76
+ el.appendChild(n[0].cloneNode(true));
77
+ }
78
+
79
+ function hasClass(n, c) {
80
+ return new RegExp('\\b' + c + '\\b', 'g').test(n.className);
81
+ };
82
+
83
+ each(dom.select('*', el), function(n) {
84
+ // Replace cdate
85
+ if (hasClass(n, ed.getParam('template_cdate_classes', 'cdate').replace(/\s+/g, '|')))
86
+ n.innerHTML = t._getDateTime(new Date(), ed.getParam("template_cdate_format", ed.getLang("template.cdate_format")));
87
+
88
+ // Replace mdate
89
+ if (hasClass(n, ed.getParam('template_mdate_classes', 'mdate').replace(/\s+/g, '|')))
90
+ n.innerHTML = t._getDateTime(new Date(), ed.getParam("template_mdate_format", ed.getLang("template.mdate_format")));
91
+
92
+ // Replace selection
93
+ if (hasClass(n, ed.getParam('template_selected_content_classes', 'selcontent').replace(/\s+/g, '|')))
94
+ n.innerHTML = sel;
95
+ });
96
+
97
+ t._replaceVals(el);
98
+
99
+ ed.execCommand('mceInsertContent', false, el.innerHTML);
100
+ ed.addVisual();
101
+ },
102
+
103
+ _replaceVals : function(e) {
104
+ var dom = this.editor.dom, vl = this.editor.getParam('template_replace_values');
105
+
106
+ each(dom.select('*', e), function(e) {
107
+ each(vl, function(v, k) {
108
+ if (dom.hasClass(e, k)) {
109
+ if (typeof(vl[k]) == 'function')
110
+ vl[k](e);
111
+ }
112
+ });
113
+ });
114
+ },
115
+
116
+ _getDateTime : function(d, fmt) {
117
+ if (!fmt)
118
+ return "";
119
+
120
+ function addZeros(value, len) {
121
+ var i;
122
+
123
+ value = "" + value;
124
+
125
+ if (value.length < len) {
126
+ for (i=0; i<(len-value.length); i++)
127
+ value = "0" + value;
128
+ }
129
+
130
+ return value;
131
+ }
132
+
133
+ fmt = fmt.replace("%D", "%m/%d/%y");
134
+ fmt = fmt.replace("%r", "%I:%M:%S %p");
135
+ fmt = fmt.replace("%Y", "" + d.getFullYear());
136
+ fmt = fmt.replace("%y", "" + d.getYear());
137
+ fmt = fmt.replace("%m", addZeros(d.getMonth()+1, 2));
138
+ fmt = fmt.replace("%d", addZeros(d.getDate(), 2));
139
+ fmt = fmt.replace("%H", "" + addZeros(d.getHours(), 2));
140
+ fmt = fmt.replace("%M", "" + addZeros(d.getMinutes(), 2));
141
+ fmt = fmt.replace("%S", "" + addZeros(d.getSeconds(), 2));
142
+ fmt = fmt.replace("%I", "" + ((d.getHours() + 11) % 12 + 1));
143
+ fmt = fmt.replace("%p", "" + (d.getHours() < 12 ? "AM" : "PM"));
144
+ fmt = fmt.replace("%B", "" + this.editor.getLang("template_months_long").split(',')[d.getMonth()]);
145
+ fmt = fmt.replace("%b", "" + this.editor.getLang("template_months_short").split(',')[d.getMonth()]);
146
+ fmt = fmt.replace("%A", "" + this.editor.getLang("template_day_long").split(',')[d.getDay()]);
147
+ fmt = fmt.replace("%a", "" + this.editor.getLang("template_day_short").split(',')[d.getDay()]);
148
+ fmt = fmt.replace("%%", "%");
149
+
150
+ return fmt;
151
+ }
152
+ });
153
+
154
+ // Register plugin
155
+ tinymce.PluginManager.add('template', tinymce.plugins.TemplatePlugin);
156
+ })();
mce_plugins/plugins/template/js/template.js ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ tinyMCEPopup.requireLangPack();
2
+
3
+ var TemplateDialog = {
4
+ preInit : function() {
5
+ var url = tinyMCEPopup.getParam("template_external_list_url");
6
+
7
+ if (url != null)
8
+ document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></sc'+'ript>');
9
+ },
10
+
11
+ init : function() {
12
+ var ed = tinyMCEPopup.editor, tsrc, sel, x, u;
13
+
14
+ tsrc = ed.getParam("template_templates", false);
15
+ sel = document.getElementById('tpath');
16
+
17
+ // Setup external template list
18
+ if (!tsrc && typeof(tinyMCETemplateList) != 'undefined') {
19
+ for (x=0, tsrc = []; x<tinyMCETemplateList.length; x++)
20
+ tsrc.push({title : tinyMCETemplateList[x][0], src : tinyMCETemplateList[x][1], description : tinyMCETemplateList[x][2]});
21
+ }
22
+
23
+ for (x=0; x<tsrc.length; x++)
24
+ sel.options[sel.options.length] = new Option(tsrc[x].title, tinyMCEPopup.editor.documentBaseURI.toAbsolute(tsrc[x].src));
25
+
26
+ this.resize();
27
+ this.tsrc = tsrc;
28
+ },
29
+
30
+ resize : function() {
31
+ var w, h, e;
32
+
33
+ if (!self.innerWidth) {
34
+ w = document.body.clientWidth - 50;
35
+ h = document.body.clientHeight - 160;
36
+ } else {
37
+ w = self.innerWidth - 50;
38
+ h = self.innerHeight - 170;
39
+ }
40
+
41
+ e = document.getElementById('templatesrc');
42
+
43
+ if (e) {
44
+ e.style.height = Math.abs(h) + 'px';
45
+ e.style.width = Math.abs(w - 5) + 'px';
46
+ }
47
+ },
48
+
49
+ loadCSSFiles : function(d) {
50
+ var ed = tinyMCEPopup.editor;
51
+
52
+ tinymce.each(ed.getParam("content_css", '').split(','), function(u) {
53
+ d.write('<link href="' + ed.documentBaseURI.toAbsolute(u) + '" rel="stylesheet" type="text/css" />');
54
+ });
55
+ },
56
+
57
+ selectTemplate : function(u, ti) {
58
+ var d = window.frames['templatesrc'].document, x, tsrc = this.tsrc;
59
+
60
+ if (!u)
61
+ return;
62
+
63
+ d.body.innerHTML = this.templateHTML = this.getFileContents(u);
64
+
65
+ for (x=0; x<tsrc.length; x++) {
66
+ if (tsrc[x].title == ti)
67
+ document.getElementById('tmpldesc').innerHTML = tsrc[x].description || '';
68
+ }
69
+ },
70
+
71
+ insert : function() {
72
+ tinyMCEPopup.execCommand('mceInsertTemplate', false, {
73
+ content : this.templateHTML,
74
+ selection : tinyMCEPopup.editor.selection.getContent()
75
+ });
76
+
77
+ tinyMCEPopup.close();
78
+ },
79
+
80
+ getFileContents : function(u) {
81
+ var x, d, t = 'text/plain';
82
+
83
+ function g(s) {
84
+ x = 0;
85
+
86
+ try {
87
+ x = new ActiveXObject(s);
88
+ } catch (s) {
89
+ }
90
+
91
+ return x;
92
+ };
93
+
94
+ x = window.ActiveXObject ? g('Msxml2.XMLHTTP') || g('Microsoft.XMLHTTP') : new XMLHttpRequest();
95
+
96
+ // Synchronous AJAX load file
97
+ x.overrideMimeType && x.overrideMimeType(t);
98
+ x.open("GET", u, false);
99
+ x.send(null);
100
+
101
+ return x.responseText;
102
+ }
103
+ };
104
+
105
+ TemplateDialog.preInit();
106
+ tinyMCEPopup.onInit.add(TemplateDialog.init, TemplateDialog);
mce_plugins/plugins/template/langs/en_dlg.js ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ tinyMCE.addI18n('en.template_dlg',{
2
+ title:"Templates",
3
+ label:"Template",
4
+ desc_label:"Description",
5
+ desc:"Insert predefined template content",
6
+ select:"Select a template",
7
+ preview:"Preview",
8
+ warning:"Warning: Updating a template with a different one may cause data loss.",
9
+ mdate_format:"%Y-%m-%d %H:%M:%S",
10
+ cdate_format:"%Y-%m-%d %H:%M:%S",
11
+ months_long:"January,February,March,April,May,June,July,August,September,October,November,December",
12
+ months_short:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec",
13
+ day_long:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday",
14
+ day_short:"Sun,Mon,Tue,Wed,Thu,Fri,Sat,Sun"
15
+ });
mce_plugins/plugins/template/langs/ja_dlg.js ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ tinyMCE.addI18n('ja.template_dlg',{
2
+ title:"\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8",
3
+ label:"\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8",
4
+ desc_label:"\u8AAC\u660E",
5
+ desc:"\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u306E\u633F\u5165",
6
+ select:"\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u3092\u9078\u629E",
7
+ preview:"\u30D7\u30EC\u30D3\u30E5\u30FC",
8
+ warning:"\u8B66\u544A\uFF1A\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u3092\u4E0A\u66F8\u304D\u3059\u308B\u3068\u4EE5\u524D\u306E\u30C7\u30FC\u30BF\u306F\u5931\u308F\u308C\u307E\u3059\u3002",
9
+ mdate_format:"%Y-%m-%d %H:%M:%S",
10
+ cdate_format:"%Y-%m-%d %H:%M:%S",
11
+ months_long:"January,February,March,April,May,June,July,August,September,October,November,December",
12
+ months_short:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec",
13
+ day_long:"\u65E5\u66DC\u65E5,\u6708\u66DC\u65E5,\u706B\u66DC\u65E5,\u6C34\u66DC\u65E5,\u6728\u66DC\u65E5,\u91D1\u66DC\u65E5,\u571F\u66DC\u65E5,\u65E5\u66DC\u65E5",
14
+ day_short:"(\u65E5),(\u6708),(\u706B),(\u6C34),(\u6728),(\u91D1),(\u571F),(\u65E5)"
15
+ });
mce_plugins/plugins/template/langs/langs.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $path = dirname(__FILE__).'/'.$mce_locale.'_dlg.js';
4
+ $strings = file_get_contents($path);
5
+
6
+ ?>
mce_plugins/plugins/template/template.htm ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <html xmlns="http://www.w3.org/1999/xhtml">
2
+ <head>
3
+ <title>{#template_dlg.title}</title>
4
+ <script type="text/javascript" src="../../tiny_mce_popup.js"></script>
5
+ <script type="text/javascript" src="js/template.js"></script>
6
+ <link href="css/template.css" rel="stylesheet" type="text/css" />
7
+ </head>
8
+ <body onresize="TemplateDialog.resize();">
9
+ <form onsubmit="TemplateDialog.insert();return false;">
10
+ <div id="frmbody">
11
+ <div class="title">{#template_dlg.desc}</div>
12
+ <div class="frmRow"><label for="tpath" title="{#template_dlg.select}">{#template_dlg.label}:</label>
13
+ <select id="tpath" name="tpath" onchange="TemplateDialog.selectTemplate(this.options[this.selectedIndex].value, this.options[this.selectedIndex].text);" class="mceFocus">
14
+ <option value="">{#template_dlg.select}...</option>
15
+ </select>
16
+ <span id="warning"></span></div>
17
+ <div class="frmRow"><label for="tdesc">{#template_dlg.desc_label}:</label>
18
+ <span id="tmpldesc"></span></div>
19
+ <fieldset>
20
+ <legend>{#template_dlg.preview}</legend>
21
+ <iframe id="templatesrc" name="templatesrc" src="blank.htm" width="690" height="400" frameborder="0"></iframe>
22
+ </fieldset>
23
+ </div>
24
+
25
+ <div class="mceActionPanel">
26
+ <div style="float: left">
27
+ <input type="submit" id="insert" name="insert" value="{#insert}" />
28
+ </div>
29
+
30
+ <div style="float: right">
31
+ <input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
32
+ </div>
33
+
34
+ <br style="clear:both" />
35
+ </div>
36
+ </form>
37
+ </body>
38
+ </html>
mce_plugins/tiny_mce_popup.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+
2
+ // Uncomment and change this document.domain value if you are loading the script cross subdomains
3
+ // document.domain = 'moxiecode.com';
4
+
5
+ var tinymce=null,tinyMCEPopup,tinyMCE;tinyMCEPopup={init:function(){var b=this,a,c;a=b.getWin();tinymce=a.tinymce;tinyMCE=a.tinyMCE;b.editor=tinymce.EditorManager.activeEditor;b.params=b.editor.windowManager.params;b.features=b.editor.windowManager.features;b.dom=b.editor.windowManager.createInstance("tinymce.dom.DOMUtils",document);if(b.features.popup_css!==false){b.dom.loadCSS(b.features.popup_css||b.editor.settings.popup_css)}b.listeners=[];b.onInit={add:function(e,d){b.listeners.push({func:e,scope:d})}};b.isWindow=!b.getWindowArg("mce_inline");b.id=b.getWindowArg("mce_window_id");b.editor.windowManager.onOpen.dispatch(b.editor.windowManager,window)},getWin:function(){return(!window.frameElement&&window.dialogArguments)||opener||parent||top},getWindowArg:function(c,b){var a=this.params[c];return tinymce.is(a)?a:b},getParam:function(b,a){return this.editor.getParam(b,a)},getLang:function(b,a){return this.editor.getLang(b,a)},execCommand:function(d,c,e,b){b=b||{};b.skip_focus=1;this.restoreSelection();return this.editor.execCommand(d,c,e,b)},resizeToInnerSize:function(){var e=this,g,a=document.body,c=e.dom.getViewPort(window),d,f;d=e.getWindowArg("mce_width")-c.w;f=e.getWindowArg("mce_height")-c.h;if(e.isWindow){window.resizeBy(d,f)}else{e.editor.windowManager.resizeBy(d,f,e.id)}},executeOnLoad:function(s){this.onInit.add(function(){eval(s)})},storeSelection:function(){this.editor.windowManager.bookmark=tinyMCEPopup.editor.selection.getBookmark(1)},restoreSelection:function(){var a=tinyMCEPopup;if(!a.isWindow&&tinymce.isIE){a.editor.selection.moveToBookmark(a.editor.windowManager.bookmark)}},requireLangPack:function(){var b=this,a=b.getWindowArg("plugin_url")||b.getWindowArg("theme_url");if(a&&b.editor.settings.language&&b.features.translate_i18n!==false){a+="/langs/"+b.editor.settings.language+"_dlg.js";if(!tinymce.ScriptLoader.isDone(a)){document.write('<script type="text/javascript" src="'+tinymce._addVer(a)+'"><\/script>');tinymce.ScriptLoader.markDone(a)}}},pickColor:function(b,a){this.execCommand("mceColorPicker",true,{color:document.getElementById(a).value,func:function(e){document.getElementById(a).value=e;try{document.getElementById(a).onchange()}catch(d){}}})},openBrowser:function(a,c,b){tinyMCEPopup.restoreSelection();this.editor.execCallback("file_browser_callback",a,document.getElementById(a).value,c,window)},confirm:function(b,a,c){this.editor.windowManager.confirm(b,a,c,window)},alert:function(b,a,c){this.editor.windowManager.alert(b,a,c,window)},close:function(){var a=this;function b(){a.editor.windowManager.close(window);tinymce=tinyMCE=a.editor=a.params=a.dom=a.dom.doc=null}if(tinymce.isOpera){a.getWin().setTimeout(b,0)}else{b()}},_restoreSelection:function(){var a=window.event.srcElement;if(a.nodeName=="INPUT"&&(a.type=="submit"||a.type=="button")){tinyMCEPopup.restoreSelection()}},_onDOMLoaded:function(){var b=tinyMCEPopup,d=document.title,e,c,a;if(b.domLoaded){return}b.domLoaded=1;if(b.features.translate_i18n!==false){c=document.body.innerHTML;if(tinymce.isIE){c=c.replace(/ (value|title|alt)=([^"][^\s>]+)/gi,' $1="$2"')}document.dir=b.editor.getParam("directionality","");if((a=b.editor.translate(c))&&a!=c){document.body.innerHTML=a}if((a=b.editor.translate(d))&&a!=d){document.title=d=a}}document.body.style.display="";if(tinymce.isIE){document.attachEvent("onmouseup",tinyMCEPopup._restoreSelection);b.dom.add(b.dom.select("head")[0],"base",{target:"_self"})}b.restoreSelection();b.resizeToInnerSize();if(!b.isWindow){b.editor.windowManager.setTitle(window,d)}else{window.focus()}if(!tinymce.isIE&&!b.isWindow){tinymce.dom.Event._add(document,"focus",function(){b.editor.windowManager.focus(b.id)})}tinymce.each(b.dom.select("select"),function(f){f.onkeydown=tinyMCEPopup._accessHandler});tinymce.each(b.listeners,function(f){f.func.call(f.scope,b.editor)});if(b.getWindowArg("mce_auto_focus",true)){window.focus();tinymce.each(document.forms,function(g){tinymce.each(g.elements,function(f){if(b.dom.hasClass(f,"mceFocus")&&!f.disabled){f.focus();return false}})})}document.onkeyup=tinyMCEPopup._closeWinKeyHandler},_accessHandler:function(a){a=a||window.event;if(a.keyCode==13||a.keyCode==32){a=a.target||a.srcElement;if(a.onchange){a.onchange()}return tinymce.dom.Event.cancel(a)}},_closeWinKeyHandler:function(a){a=a||window.event;if(a.keyCode==27){tinyMCEPopup.close()}},_wait:function(){if(document.attachEvent){document.attachEvent("onreadystatechange",function(){if(document.readyState==="complete"){document.detachEvent("onreadystatechange",arguments.callee);tinyMCEPopup._onDOMLoaded()}});if(document.documentElement.doScroll&&window==window.top){(function(){if(tinyMCEPopup.domLoaded){return}try{document.documentElement.doScroll("left")}catch(a){setTimeout(arguments.callee,0);return}tinyMCEPopup._onDOMLoaded()})()}document.attachEvent("onload",tinyMCEPopup._onDOMLoaded)}else{if(document.addEventListener){window.addEventListener("DOMContentLoaded",tinyMCEPopup._onDOMLoaded,false);window.addEventListener("load",tinyMCEPopup._onDOMLoaded,false)}}}};tinyMCEPopup.init();tinyMCEPopup._wait();
mce_plugins/utils/editable_selects.js ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * $Id: editable_selects.js 867 2008-06-09 20:33:40Z spocke $
3
+ *
4
+ * Makes select boxes editable.
5
+ *
6
+ * @author Moxiecode
7
+ * @copyright Copyright � 2004-2008, Moxiecode Systems AB, All rights reserved.
8
+ */
9
+
10
+ var TinyMCE_EditableSelects = {
11
+ editSelectElm : null,
12
+
13
+ init : function() {
14
+ var nl = document.getElementsByTagName("select"), i, d = document, o;
15
+
16
+ for (i=0; i<nl.length; i++) {
17
+ if (nl[i].className.indexOf('mceEditableSelect') != -1) {
18
+ o = new Option('(value)', '__mce_add_custom__');
19
+
20
+ o.className = 'mceAddSelectValue';
21
+
22
+ nl[i].options[nl[i].options.length] = o;
23
+ nl[i].onchange = TinyMCE_EditableSelects.onChangeEditableSelect;
24
+ }
25
+ }
26
+ },
27
+
28
+ onChangeEditableSelect : function(e) {
29
+ var d = document, ne, se = window.event ? window.event.srcElement : e.target;
30
+
31
+ if (se.options[se.selectedIndex].value == '__mce_add_custom__') {
32
+ ne = d.createElement("input");
33
+ ne.id = se.id + "_custom";
34
+ ne.name = se.name + "_custom";
35
+ ne.type = "text";
36
+
37
+ ne.style.width = se.offsetWidth + 'px';
38
+ se.parentNode.insertBefore(ne, se);
39
+ se.style.display = 'none';
40
+ ne.focus();
41
+ ne.onblur = TinyMCE_EditableSelects.onBlurEditableSelectInput;
42
+ ne.onkeydown = TinyMCE_EditableSelects.onKeyDown;
43
+ TinyMCE_EditableSelects.editSelectElm = se;
44
+ }
45
+ },
46
+
47
+ onBlurEditableSelectInput : function() {
48
+ var se = TinyMCE_EditableSelects.editSelectElm;
49
+
50
+ if (se) {
51
+ if (se.previousSibling.value != '') {
52
+ addSelectValue(document.forms[0], se.id, se.previousSibling.value, se.previousSibling.value);
53
+ selectByValue(document.forms[0], se.id, se.previousSibling.value);
54
+ } else
55
+ selectByValue(document.forms[0], se.id, '');
56
+
57
+ se.style.display = 'inline';
58
+ se.parentNode.removeChild(se.previousSibling);
59
+ TinyMCE_EditableSelects.editSelectElm = null;
60
+ }
61
+ },
62
+
63
+ onKeyDown : function(e) {
64
+ e = e || window.event;
65
+
66
+ if (e.keyCode == 13)
67
+ TinyMCE_EditableSelects.onBlurEditableSelectInput();
68
+ }
69
+ };
mce_plugins/utils/form_utils.js ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * $Id: form_utils.js 1184 2009-08-11 11:47:27Z spocke $
3
+ *
4
+ * Various form utilitiy functions.
5
+ *
6
+ * @author Moxiecode
7
+ * @copyright Copyright � 2004-2008, Moxiecode Systems AB, All rights reserved.
8
+ */
9
+
10
+ var themeBaseURL = tinyMCEPopup.editor.baseURI.toAbsolute('themes/' + tinyMCEPopup.getParam("theme"));
11
+
12
+ function getColorPickerHTML(id, target_form_element) {
13
+ var h = "";
14
+
15
+ h += '<a id="' + id + '_link" href="javascript:;" onclick="tinyMCEPopup.pickColor(event,\'' + target_form_element +'\');" onmousedown="return false;" class="pickcolor">';
16
+ h += '<span id="' + id + '" title="' + tinyMCEPopup.getLang('browse') + '">&nbsp;</span></a>';
17
+
18
+ return h;
19
+ }
20
+
21
+ function updateColor(img_id, form_element_id) {
22
+ document.getElementById(img_id).style.backgroundColor = document.forms[0].elements[form_element_id].value;
23
+ }
24
+
25
+ function setBrowserDisabled(id, state) {
26
+ var img = document.getElementById(id);
27
+ var lnk = document.getElementById(id + "_link");
28
+
29
+ if (lnk) {
30
+ if (state) {
31
+ lnk.setAttribute("realhref", lnk.getAttribute("href"));
32
+ lnk.removeAttribute("href");
33
+ tinyMCEPopup.dom.addClass(img, 'disabled');
34
+ } else {
35
+ if (lnk.getAttribute("realhref"))
36
+ lnk.setAttribute("href", lnk.getAttribute("realhref"));
37
+
38
+ tinyMCEPopup.dom.removeClass(img, 'disabled');
39
+ }
40
+ }
41
+ }
42
+
43
+ function getBrowserHTML(id, target_form_element, type, prefix) {
44
+ var option = prefix + "_" + type + "_browser_callback", cb, html;
45
+
46
+ cb = tinyMCEPopup.getParam(option, tinyMCEPopup.getParam("file_browser_callback"));
47
+
48
+ if (!cb)
49
+ return "";
50
+
51
+ html = "";
52
+ html += '<a id="' + id + '_link" href="javascript:openBrowser(\'' + id + '\',\'' + target_form_element + '\', \'' + type + '\',\'' + option + '\');" onmousedown="return false;" class="browse">';
53
+ html += '<span id="' + id + '" title="' + tinyMCEPopup.getLang('browse') + '">&nbsp;</span></a>';
54
+
55
+ return html;
56
+ }
57
+
58
+ function openBrowser(img_id, target_form_element, type, option) {
59
+ var img = document.getElementById(img_id);
60
+
61
+ if (img.className != "mceButtonDisabled")
62
+ tinyMCEPopup.openBrowser(target_form_element, type, option);
63
+ }
64
+
65
+ function selectByValue(form_obj, field_name, value, add_custom, ignore_case) {
66
+ if (!form_obj || !form_obj.elements[field_name])
67
+ return;
68
+
69
+ var sel = form_obj.elements[field_name];
70
+
71
+ var found = false;
72
+ for (var i=0; i<sel.options.length; i++) {
73
+ var option = sel.options[i];
74
+
75
+ if (option.value == value || (ignore_case && option.value.toLowerCase() == value.toLowerCase())) {
76
+ option.selected = true;
77
+ found = true;
78
+ } else
79
+ option.selected = false;
80
+ }
81
+
82
+ if (!found && add_custom && value != '') {
83
+ var option = new Option(value, value);
84
+ option.selected = true;
85
+ sel.options[sel.options.length] = option;
86
+ sel.selectedIndex = sel.options.length - 1;
87
+ }
88
+
89
+ return found;
90
+ }
91
+
92
+ function getSelectValue(form_obj, field_name) {
93
+ var elm = form_obj.elements[field_name];
94
+
95
+ if (elm == null || elm.options == null || elm.selectedIndex === -1)
96
+ return "";
97
+
98
+ return elm.options[elm.selectedIndex].value;
99
+ }
100
+
101
+ function addSelectValue(form_obj, field_name, name, value) {
102
+ var s = form_obj.elements[field_name];
103
+ var o = new Option(name, value);
104
+ s.options[s.options.length] = o;
105
+ }
106
+
107
+ function addClassesToList(list_id, specific_option) {
108
+ // Setup class droplist
109
+ var styleSelectElm = document.getElementById(list_id);
110
+ var styles = tinyMCEPopup.getParam('theme_advanced_styles', false);
111
+ styles = tinyMCEPopup.getParam(specific_option, styles);
112
+
113
+ if (styles) {
114
+ var stylesAr = styles.split(';');
115
+
116
+ for (var i=0; i<stylesAr.length; i++) {
117
+ if (stylesAr != "") {
118
+ var key, value;
119
+
120
+ key = stylesAr[i].split('=')[0];
121
+ value = stylesAr[i].split('=')[1];
122
+
123
+ styleSelectElm.options[styleSelectElm.length] = new Option(key, value);
124
+ }
125
+ }
126
+ } else {
127
+ tinymce.each(tinyMCEPopup.editor.dom.getClasses(), function(o) {
128
+ styleSelectElm.options[styleSelectElm.length] = new Option(o.title || o['class'], o['class']);
129
+ });
130
+ }
131
+ }
132
+
133
+ function isVisible(element_id) {
134
+ var elm = document.getElementById(element_id);
135
+
136
+ return elm && elm.style.display != "none";
137
+ }
138
+
139
+ function convertRGBToHex(col) {
140
+ var re = new RegExp("rgb\\s*\\(\\s*([0-9]+).*,\\s*([0-9]+).*,\\s*([0-9]+).*\\)", "gi");
141
+
142
+ var rgb = col.replace(re, "$1,$2,$3").split(',');
143
+ if (rgb.length == 3) {
144
+ r = parseInt(rgb[0]).toString(16);
145
+ g = parseInt(rgb[1]).toString(16);
146
+ b = parseInt(rgb[2]).toString(16);
147
+
148
+ r = r.length == 1 ? '0' + r : r;
149
+ g = g.length == 1 ? '0' + g : g;
150
+ b = b.length == 1 ? '0' + b : b;
151
+
152
+ return "#" + r + g + b;
153
+ }
154
+
155
+ return col;
156
+ }
157
+
158
+ function convertHexToRGB(col) {
159
+ if (col.indexOf('#') != -1) {
160
+ col = col.replace(new RegExp('[^0-9A-F]', 'gi'), '');
161
+
162
+ r = parseInt(col.substring(0, 2), 16);
163
+ g = parseInt(col.substring(2, 4), 16);
164
+ b = parseInt(col.substring(4, 6), 16);
165
+
166
+ return "rgb(" + r + "," + g + "," + b + ")";
167
+ }
168
+
169
+ return col;
170
+ }
171
+
172
+ function trimSize(size) {
173
+ return size.replace(/([0-9\.]+)px|(%|in|cm|mm|em|ex|pt|pc)/, '$1$2');
174
+ }
175
+
176
+ function getCSSSize(size) {
177
+ size = trimSize(size);
178
+
179
+ if (size == "")
180
+ return "";
181
+
182
+ // Add px
183
+ if (/^[0-9]+$/.test(size))
184
+ size += 'px';
185
+
186
+ return size;
187
+ }
188
+
189
+ function getStyle(elm, attrib, style) {
190
+ var val = tinyMCEPopup.dom.getAttrib(elm, attrib);
191
+
192
+ if (val != '')
193
+ return '' + val;
194
+
195
+ if (typeof(style) == 'undefined')
196
+ style = attrib;
197
+
198
+ return tinyMCEPopup.dom.getStyle(elm, style);
199
+ }
mce_plugins/utils/mctabs.js ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * $Id: mctabs.js 758 2008-03-30 13:53:29Z spocke $
3
+ *
4
+ * Moxiecode DHTML Tabs script.
5
+ *
6
+ * @author Moxiecode
7
+ * @copyright Copyright � 2004-2008, Moxiecode Systems AB, All rights reserved.
8
+ */
9
+
10
+ function MCTabs() {
11
+ this.settings = [];
12
+ };
13
+
14
+ MCTabs.prototype.init = function(settings) {
15
+ this.settings = settings;
16
+ };
17
+
18
+ MCTabs.prototype.getParam = function(name, default_value) {
19
+ var value = null;
20
+
21
+ value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];
22
+
23
+ // Fix bool values
24
+ if (value == "true" || value == "false")
25
+ return (value == "true");
26
+
27
+ return value;
28
+ };
29
+
30
+ MCTabs.prototype.displayTab = function(tab_id, panel_id) {
31
+ var panelElm, panelContainerElm, tabElm, tabContainerElm, selectionClass, nodes, i;
32
+
33
+ panelElm= document.getElementById(panel_id);
34
+ panelContainerElm = panelElm ? panelElm.parentNode : null;
35
+ tabElm = document.getElementById(tab_id);
36
+ tabContainerElm = tabElm ? tabElm.parentNode : null;
37
+ selectionClass = this.getParam('selection_class', 'current');
38
+
39
+ if (tabElm && tabContainerElm) {
40
+ nodes = tabContainerElm.childNodes;
41
+
42
+ // Hide all other tabs
43
+ for (i = 0; i < nodes.length; i++) {
44
+ if (nodes[i].nodeName == "LI")
45
+ nodes[i].className = '';
46
+ }
47
+
48
+ // Show selected tab
49
+ tabElm.className = 'current';
50
+ }
51
+
52
+ if (panelElm && panelContainerElm) {
53
+ nodes = panelContainerElm.childNodes;
54
+
55
+ // Hide all other panels
56
+ for (i = 0; i < nodes.length; i++) {
57
+ if (nodes[i].nodeName == "DIV")
58
+ nodes[i].className = 'panel';
59
+ }
60
+
61
+ // Show selected panel
62
+ panelElm.className = 'current';
63
+ }
64
+ };
65
+
66
+ MCTabs.prototype.getAnchor = function() {
67
+ var pos, url = document.location.href;
68
+
69
+ if ((pos = url.lastIndexOf('#')) != -1)
70
+ return url.substring(pos + 1);
71
+
72
+ return "";
73
+ };
74
+
75
+ // Global instance
76
+ var mcTabs = new MCTabs();
mce_plugins/utils/validate.js ADDED
@@ -0,0 +1,219 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * $Id: validate.js 758 2008-03-30 13:53:29Z spocke $
3
+ *
4
+ * Various form validation methods.
5
+ *
6
+ * @author Moxiecode
7
+ * @copyright Copyright � 2004-2008, Moxiecode Systems AB, All rights reserved.
8
+ */
9
+
10
+ /**
11
+ // String validation:
12
+
13
+ if (!Validator.isEmail('myemail'))
14
+ alert('Invalid email.');
15
+
16
+ // Form validation:
17
+
18
+ var f = document.forms['myform'];
19
+
20
+ if (!Validator.isEmail(f.myemail))
21
+ alert('Invalid email.');
22
+ */
23
+
24
+ var Validator = {
25
+ isEmail : function(s) {
26
+ return this.test(s, '^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$');
27
+ },
28
+
29
+ isAbsUrl : function(s) {
30
+ return this.test(s, '^(news|telnet|nttp|file|http|ftp|https)://[-A-Za-z0-9\\.]+\\/?.*$');
31
+ },
32
+
33
+ isSize : function(s) {
34
+ return this.test(s, '^[0-9]+(%|in|cm|mm|em|ex|pt|pc|px)?$');
35
+ },
36
+
37
+ isId : function(s) {
38
+ return this.test(s, '^[A-Za-z_]([A-Za-z0-9_])*$');
39
+ },
40
+
41
+ isEmpty : function(s) {
42
+ var nl, i;
43
+
44
+ if (s.nodeName == 'SELECT' && s.selectedIndex < 1)
45
+ return true;
46
+
47
+ if (s.type == 'checkbox' && !s.checked)
48
+ return true;
49
+
50
+ if (s.type == 'radio') {
51
+ for (i=0, nl = s.form.elements; i<nl.length; i++) {
52
+ if (nl[i].type == "radio" && nl[i].name == s.name && nl[i].checked)
53
+ return false;
54
+ }
55
+
56
+ return true;
57
+ }
58
+
59
+ return new RegExp('^\\s*$').test(s.nodeType == 1 ? s.value : s);
60
+ },
61
+
62
+ isNumber : function(s, d) {
63
+ return !isNaN(s.nodeType == 1 ? s.value : s) && (!d || !this.test(s, '^-?[0-9]*\\.[0-9]*$'));
64
+ },
65
+
66
+ test : function(s, p) {
67
+ s = s.nodeType == 1 ? s.value : s;
68
+
69
+ return s == '' || new RegExp(p).test(s);
70
+ }
71
+ };
72
+
73
+ var AutoValidator = {
74
+ settings : {
75
+ id_cls : 'id',
76
+ int_cls : 'int',
77
+ url_cls : 'url',
78
+ number_cls : 'number',
79
+ email_cls : 'email',
80
+ size_cls : 'size',
81
+ required_cls : 'required',
82
+ invalid_cls : 'invalid',
83
+ min_cls : 'min',
84
+ max_cls : 'max'
85
+ },
86
+
87
+ init : function(s) {
88
+ var n;
89
+
90
+ for (n in s)
91
+ this.settings[n] = s[n];
92
+ },
93
+
94
+ validate : function(f) {
95
+ var i, nl, s = this.settings, c = 0;
96
+
97
+ nl = this.tags(f, 'label');
98
+ for (i=0; i<nl.length; i++)
99
+ this.removeClass(nl[i], s.invalid_cls);
100
+
101
+ c += this.validateElms(f, 'input');
102
+ c += this.validateElms(f, 'select');
103
+ c += this.validateElms(f, 'textarea');
104
+
105
+ return c == 3;
106
+ },
107
+
108
+ invalidate : function(n) {
109
+ this.mark(n.form, n);
110
+ },
111
+
112
+ reset : function(e) {
113
+ var t = ['label', 'input', 'select', 'textarea'];
114
+ var i, j, nl, s = this.settings;
115
+
116
+ if (e == null)
117
+ return;
118
+
119
+ for (i=0; i<t.length; i++) {
120
+ nl = this.tags(e.form ? e.form : e, t[i]);
121
+ for (j=0; j<nl.length; j++)
122
+ this.removeClass(nl[j], s.invalid_cls);
123
+ }
124
+ },
125
+
126
+ validateElms : function(f, e) {
127
+ var nl, i, n, s = this.settings, st = true, va = Validator, v;
128
+
129
+ nl = this.tags(f, e);
130
+ for (i=0; i<nl.length; i++) {
131
+ n = nl[i];
132
+
133
+ this.removeClass(n, s.invalid_cls);
134
+
135
+ if (this.hasClass(n, s.required_cls) && va.isEmpty(n))
136
+ st = this.mark(f, n);
137
+
138
+ if (this.hasClass(n, s.number_cls) && !va.isNumber(n))
139
+ st = this.mark(f, n);
140
+
141
+ if (this.hasClass(n, s.int_cls) && !va.isNumber(n, true))
142
+ st = this.mark(f, n);
143
+
144
+ if (this.hasClass(n, s.url_cls) && !va.isAbsUrl(n))
145
+ st = this.mark(f, n);
146
+
147
+ if (this.hasClass(n, s.email_cls) && !va.isEmail(n))
148
+ st = this.mark(f, n);
149
+
150
+ if (this.hasClass(n, s.size_cls) && !va.isSize(n))
151
+ st = this.mark(f, n);
152
+
153
+ if (this.hasClass(n, s.id_cls) && !va.isId(n))
154
+ st = this.mark(f, n);
155
+
156
+ if (this.hasClass(n, s.min_cls, true)) {
157
+ v = this.getNum(n, s.min_cls);
158
+
159
+ if (isNaN(v) || parseInt(n.value) < parseInt(v))
160
+ st = this.mark(f, n);
161
+ }
162
+
163
+ if (this.hasClass(n, s.max_cls, true)) {
164
+ v = this.getNum(n, s.max_cls);
165
+
166
+ if (isNaN(v) || parseInt(n.value) > parseInt(v))
167
+ st = this.mark(f, n);
168
+ }
169
+ }
170
+
171
+ return st;
172
+ },
173
+
174
+ hasClass : function(n, c, d) {
175
+ return new RegExp('\\b' + c + (d ? '[0-9]+' : '') + '\\b', 'g').test(n.className);
176
+ },
177
+
178
+ getNum : function(n, c) {
179
+ c = n.className.match(new RegExp('\\b' + c + '([0-9]+)\\b', 'g'))[0];
180
+ c = c.replace(/[^0-9]/g, '');
181
+
182
+ return c;
183
+ },
184
+
185
+ addClass : function(n, c, b) {
186
+ var o = this.removeClass(n, c);
187
+ n.className = b ? c + (o != '' ? (' ' + o) : '') : (o != '' ? (o + ' ') : '') + c;
188
+ },
189
+
190
+ removeClass : function(n, c) {
191
+ c = n.className.replace(new RegExp("(^|\\s+)" + c + "(\\s+|$)"), ' ');
192
+ return n.className = c != ' ' ? c : '';
193
+ },
194
+
195
+ tags : function(f, s) {
196
+ return f.getElementsByTagName(s);
197
+ },
198
+
199
+ mark : function(f, n) {
200
+ var s = this.settings;
201
+
202
+ this.addClass(n, s.invalid_cls);
203
+ this.markLabels(f, n, s.invalid_cls);
204
+
205
+ return false;
206
+ },
207
+
208
+ markLabels : function(f, n, ic) {
209
+ var nl, i;
210
+
211
+ nl = this.tags(f, "label");
212
+ for (i=0; i<nl.length; i++) {
213
+ if (nl[i].getAttribute("for") == n.id || nl[i].htmlFor == n.id)
214
+ this.addClass(nl[i], ic);
215
+ }
216
+
217
+ return null;
218
+ }
219
+ };
readme.txt ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === TinyMCE Templates ===
2
+ Contributors: miyauchi
3
+ Donate link: http://firegoby.theta.ne.jp/
4
+ Tags: tinymce, Visual Editor, template
5
+ Requires at least: 3.0
6
+ Tested up to: 3.0
7
+ Stable tag: 0.1
8
+
9
+ TinyMCE Template plugin will enable to use HTML template on WordPress Visual Editor.
10
+ You can edit and share this template with WordPress users.
11
+
12
+ == Description ==
13
+
14
+ TinyMCE Template plugin will enable to use HTML template on WordPress Visual Editor.
15
+ You can edit and share this template with WordPress users.
16
+
17
+ If you will install this plugin, You will be very easy to edit posts and pages.
18
+
19
+ * [Plugin Homepage](http://firegoby.theta.ne.jp/wp/tinymce_templates) (Japanese)
20
+ * [Support](http://wordpress.org/tags/tinymce_templates)
21
+
22
+ = Some features: =
23
+
24
+ * Add "Insert Template" button to Visual Editor.
25
+ * You can edit template on WordPress admin.
26
+ * Share template with WordPress Users.
27
+
28
+ = Translators: =
29
+
30
+ * Japanese(ja) - [Takayuki Miyauchi](http://firegoby.theta.ne.jp/)
31
+
32
+ You can send your own language pack to me.
33
+
34
+
35
+ == Installation ==
36
+
37
+ * A plug-in installation screen is displayed on the WordPress admin panel.
38
+ * It installs it in `wp-content/plugins`.
39
+ * The plug-in is made effective.
40
+ * Open 'Template' menu.
41
+
42
+ == Screenshots ==
43
+
44
+ 1. Template Admin.
45
+ 2. Visual Editor.
46
+
47
+ == Changelog ==
48
+ = 0.1 =
49
+ * The first release.
50
+
51
+ == Credits ==
52
+
53
+ This plug-in is not guaranteed though the user of WordPress can freely use this plug-in free of charge regardless of the purpose.
54
+ The author must acknowledge the thing that the operation guarantee and the support in this plug-in use are not done at all beforehand.
55
+
56
+ WordPress のユーザーは目的を問わず、このプラグインを無償で自由に利用することができますがこのプラグインは無保証です。
57
+ 作者はこのプラグインの利用における一切の動作保証とサポートを行わない事を予めご了承下さい。
58
+
59
+ == Contact ==
60
+
61
+ email to miya[at]theta.ne.jp
62
+
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
style.css ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .wrap h2
2
+ {
3
+ padding-left: 40px;
4
+ margin-bottom: 1em;
5
+ background-image: url(img/large.png);
6
+ background-repeat: no-repeat;
7
+ background-position: left center;
8
+ line-height: 32px;
9
+ height: 32px;
10
+ }
11
+
12
+ .ex
13
+ {
14
+ margin: 1em 0;
15
+ background-color: #ffffff;
16
+ font-family: monospace !important;
17
+ border: 1px dashed #dedede;
18
+ padding: 1em;
19
+ font-size: 14px;
20
+ }
21
+
22
+ .button-secondary
23
+ {
24
+ margin: 0.5em 0;
25
+ }
26
+
27
+ .note
28
+ {
29
+ margin-top: 2em;
30
+ }
31
+
32
+ .widefat
33
+ {
34
+ margin: 8px 0;
35
+ }
36
+
37
+ #name,
38
+ #desc,
39
+ #html
40
+ {
41
+ width: 100%;
42
+ }
43
+
44
+ #desc
45
+ {
46
+ height: 3em;
47
+ }
48
+
49
+ #html
50
+ {
51
+ height: 10em;
52
+ }
53
+
54
+ #save
55
+ {
56
+ margin: 1em 0;
57
+ }
tinymce_templates.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: TinyMCE Templates
4
+ Plugin URI: http://firegoby.theta.ne.jp/wp/mce_templates
5
+ Description: Manage & Add Tiny MCE template.
6
+ Author: Takayuki Miyauchi (THETA NETWORKS Co,.Ltd)
7
+ Version: 0.1
8
+ Author URI: http://firegoby.theta.ne.jp/
9
+ */
10
+
11
+ /*
12
+ Copyright (c) 2010 Takayuki Miyauchi (THETA NETWORKS Co,.Ltd).
13
+
14
+ Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ of this software and associated documentation files (the "Software"), to deal
16
+ in the Software without restriction, including without limitation the rights
17
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ copies of the Software, and to permit persons to whom the Software is
19
+ furnished to do so, subject to the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be included in
22
+ all copies or substantial portions of the Software.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30
+ THE SOFTWARE.
31
+ */
32
+
33
+ require_once(dirname(__FILE__).'/includes/mceplugins.class.php');
34
+ require_once(dirname(__FILE__).'/includes/TinyMCETemplate.class.php');
35
+ require_once(dirname(__FILE__).'/includes/MceTemplatesAdmin.class.php');
36
+
37
+ $MceTemplates = new MceTemplates();
38
+ register_activation_hook (__FILE__, array(&$MceTemplates, 'activation'));
39
+ register_deactivation_hook (__FILE__, array(&$MceTemplates, 'deactivation'));
40
+
41
+ class MceTemplates{
42
+
43
+ var $name = 'tinymce_templates';
44
+ var $table = 'mce_template';
45
+
46
+ //
47
+ // construct
48
+ //
49
+ function MceTemplates()
50
+ {
51
+ add_action('admin_menu', array(&$this, 'loadAdmin'));
52
+ }
53
+
54
+ function activation()
55
+ {
56
+ global $wpdb;
57
+
58
+ $this->table = $wpdb->prefix.$this->table;
59
+
60
+ $sql = "CREATE TABLE ".$this->table." (
61
+ `ID` varchar(32) NOT NULL,
62
+ `name` varchar(50) NOT NULL,
63
+ `desc` varchar(100) NOT NULL,
64
+ `html` text NOT NULL,
65
+ `share` tinyint(1) unsigned NOT NULL,
66
+ `author` bigint(20) unsigned NOT NULL,
67
+ `modified` timestamp NOT NULL,
68
+ UNIQUE KEY ID (`ID`))
69
+ ENGINE = MYISAM
70
+ CHARACTER SET utf8
71
+ COLLATE utf8_unicode_ci;
72
+ ";
73
+ require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
74
+ dbDelta($sql);
75
+ }
76
+
77
+ function deactivation()
78
+ {
79
+ // nothing to do
80
+ }
81
+
82
+ //
83
+ // add admin menu
84
+ //
85
+ function loadAdmin()
86
+ {
87
+ load_plugin_textdomain(
88
+ $this->name,
89
+ PLUGINDIR.'/'.dirname(plugin_basename(__FILE__)).'/langs',
90
+ dirname(plugin_basename(__FILE__)).'/langs'
91
+ );
92
+
93
+ add_menu_page(
94
+ __('tinyMCE Templates', $this->name),
95
+ __('Templates', $this->name),
96
+ 'edit_pages',
97
+ 'edittemplates',
98
+ '',
99
+ WP_PLUGIN_URL.'/'.$this->name.'/img/icon.png'
100
+ );
101
+ add_submenu_page(
102
+ 'edittemplates',
103
+ __('Edit Templates', $this->name),
104
+ __('Edit', $this->name),
105
+ 'edit_pages',
106
+ 'edittemplates',
107
+ array(&$this, 'adminPage')
108
+ );
109
+ add_submenu_page(
110
+ 'edittemplates',
111
+ __('Add New Templates', $this->name),
112
+ __('Add New', $this->name),
113
+ 'edit_pages',
114
+ 'addnewtemplates',
115
+ array(&$this, 'adminPage')
116
+ );
117
+ }
118
+
119
+
120
+ //
121
+ // display mcetemplates list
122
+ //
123
+ function adminPage()
124
+ {
125
+ new MceTemplatesAdmin($this);
126
+ }
127
+
128
+ }
129
+ ?>