public
Description: Git mirror of the CMS Made Simple 2.0 rewrite
Homepage: http://cmsmadesimple.org
Clone URL: git://github.com/tedkulp/cmsmadesimple-2-0.git
AJAX apply for HTML blobs (global content blocks). Added a language string 
for successful update ('edithtmlblobsuccess').


git-svn-id: http://svn.cmsmadesimple.org/svn/cmsmadesimple/trunk@3955 
3d254a34-79dc-0310-9e5f-be208747d8a0
tgmayfield (author)
Fri May 11 10:19:06 -0700 2007
commit  44a426c3c13e405051b4909ab1b2458d29702fc8
tree    5f35570264613bbd477a95db97ec6f458d4b5c90
parent  ee55d3ac1c8643936501884d11dcf9c282493938
...
40
41
42
 
 
 
43
44
45
...
150
151
152
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
154
155
...
166
167
168
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
 
 
 
 
170
171
172
...
219
220
221
222
 
223
224
225
226
227
228
 
229
230
231
...
259
260
261
262
 
263
264
265
...
40
41
42
43
44
45
46
47
48
...
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
...
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
...
318
319
320
 
321
322
323
324
325
326
 
327
328
329
330
...
358
359
360
 
361
362
363
364
0
@@ -40,6 +40,9 @@ if (isset($_POST['content'])) $content = $_POST['content'];
0
 $owner_id = "";
0
 if (isset($_POST['owner_id'])) $owner_id = $_POST['owner_id'];
0
 
0
+$ajax = false;
0
+if (isset($_POST['ajax']) && $_POST['ajax']) $ajax = true;
0
+
0
 $htmlblob_id = -1;
0
 if (isset($_POST["htmlblob_id"])) $htmlblob_id = $_POST["htmlblob_id"];
0
 else if (isset($_GET["htmlblob_id"])) $htmlblob_id = $_GET["htmlblob_id"];
0
@@ -150,6 +153,25 @@ if ($access)
0
         $error .= "<li>".lang('errorinsertingblob')."</li>";
0
       }
0
     }
0
+
0
+ if ($ajax)
0
+ {
0
+ header('Content-Type: text/xml');
0
+ print '<?xml version="1.0" encoding="UTF-8"?>';
0
+ print '<EditBlob>';
0
+ if ($error)
0
+ {
0
+ print '<Response>Error</Response>';
0
+ print '<Details><![CDATA[' . $error . ']]></Details>';
0
+ }
0
+ else
0
+ {
0
+ print '<Response>Success</Response>';
0
+ print '<Details><![CDATA[' . lang('edithtmlblobsuccess') . ']]></Details>';
0
+ }
0
+ print '</EditBlob>';
0
+ exit;
0
+ }
0
   }
0
   else if ($htmlblob_id != -1)
0
   {
0
@@ -166,7 +188,84 @@ if (strlen($htmlblob) > 0)
0
     $CMS_ADMIN_SUBTITLE = $htmlblob;
0
     }
0
 
0
+$addlScriptSubmit = '';
0
+foreach (array_keys($gCms->modules) as $moduleKey)
0
+{
0
+ $module =& $gCms->modules[$moduleKey];
0
+ if (!($module['installed'] && $module['active'] && $module['object']->IsSyntaxHighlighter()))
0
+ {
0
+ continue;
0
+ }
0
+
0
+ if ($module['object']->SyntaxActive() or get_preference(get_userid(), 'syntaxhighlighter') == $module['object']->GetName())
0
+ {
0
+ $addlScriptSubmit .= $module['object']->SyntaxPageFormSubmit();
0
+ }
0
+}
0
+
0
+$headtext = <<<EOSCRIPT
0
+<script type="text/javascript">
0
+window.Edit_Blob_Apply = function(button)
0
+{
0
+ $addlScriptSubmit
0
+ $('Edit_Blob_Result').innerHTML = '';
0
+ button.disabled = 'disabled';
0
+
0
+ var data = new Array();
0
+ data.push('ajax=1');
0
+ data.push('apply=1');
0
+ var elements = Form.getElements($('Edit_Blob'));
0
+ for (var cnt = 0; cnt < elements.length; cnt++)
0
+ {
0
+ var elem = elements[cnt];
0
+ if (elem.type == 'submit')
0
+ {
0
+ continue;
0
+ }
0
+ var query = Form.Element.serialize(elem);
0
+ data.push(query);
0
+ }
0
+
0
+ new Ajax.Request(
0
+ '{$_SERVER['REQUEST_URI']}'
0
+ , {
0
+ method: 'post'
0
+ , parameters: data.join('&')
0
+ , onSuccess: function(t)
0
+ {
0
+ button.removeAttribute('disabled');
0
+ var response = t.responseXML.documentElement.firstChild;
0
+ var details = t.responseXML.documentElement.lastChild;
0
+ var htmlShow = '';
0
+ if (response.textContent == 'Success')
0
+ {
0
+ htmlShow = '<div class="pagemcontainer"><p class="pagemessage">' + details.textContent + '</p></div>';
0
+ }
0
+ else
0
+ {
0
+ htmlShow = '<div class="pageerrorcontainer"><ul class="pageerror">';
0
+ htmlShow += details.textContent;
0
+ htmlShow += '</ul></div>';
0
+ }
0
+ $('Edit_Blob_Result').innerHTML = htmlShow;
0
+ }
0
+ , onFailure: function(t)
0
+ {
0
+ alert('Could not save: ' + t.status + ' -- ' + t.statusText);
0
+ }
0
+ }
0
+ );
0
+
0
+ return false;
0
+}
0
+</script>
0
+EOSCRIPT;
0
+
0
 include_once("header.php");
0
+
0
+// Holder for AJAX apply result
0
+print '<div id="Edit_Blob_Result"></div>';
0
+
0
 global $gCms;
0
 $db =& $gCms->GetDb();
0
 
0
@@ -219,13 +318,13 @@ else
0
 
0
 <div class="pagecontainer">
0
   <?php echo $themeObject->ShowHeader('edithtmlblob'); ?>
0
- <form method="post" action="edithtmlblob.php">
0
+ <form id="Edit_Blob" method="post" action="edithtmlblob.php">
0
     <div class="pageoverflow">
0
       <p class="pagetext">&nbsp;</p>
0
       <p class="pageinput">
0
       <input type="submit" value="<?php echo lang('submit')?>" class="pagebutton" onmouseover="this.className='pagebuttonhover'" onmouseout="this.className='pagebutton'" />
0
       <input type="submit" name="cancel" value="<?php echo lang('cancel')?>" class="pagebutton" onmouseover="this.className='pagebuttonhover'" onmouseout="this.className='pagebutton'" />
0
- <input type="submit" name="apply" value="<?php echo lang('apply')?>" class="pagebutton" onmouseover="this.className='pagebuttonhover'" onmouseout="this.className='pagebutton'" />
0
+ <input type="submit" onclick="return window.Edit_Blob_Apply(this);" name="apply" value="<?php echo lang('apply')?>" class="pagebutton" onmouseover="this.className='pagebuttonhover'" onmouseout="this.className='pagebutton'" />
0
       </p>
0
     </div>
0
     <div class="pageoverflow">
0
@@ -259,7 +358,7 @@ else
0
           <input type="hidden" name="owner_id" value="<?php echo $owner_id ?>" />
0
         <?php } ?>
0
         <input type="submit" name="cancel" value="<?php echo lang('cancel')?>" class="pagebutton" onmouseover="this.className='pagebuttonhover'" onmouseout="this.className='pagebutton'" />
0
- <input type="submit" name="apply" value="<?php echo lang('apply')?>" class="pagebutton" onmouseover="this.className='pagebuttonhover'" onmouseout="this.className='pagebutton'" />
0
+ <input type="submit" onclick="return window.Edit_Blob_Apply(this);" name="apply" value="<?php echo lang('apply')?>" class="pagebutton" onmouseover="this.className='pagebuttonhover'" onmouseout="this.className='pagebutton'" />
0
       </p>
0
     </div>
0
   </form>
...
302
303
304
 
305
306
307
...
302
303
304
305
306
307
308
0
@@ -302,6 +302,7 @@ $lang['admin']['blobmanagement'] = 'Global Content Block Management';
0
 $lang['admin']['errorinsertingblob'] = 'There was an error inserting the Global Content Block';
0
 $lang['admin']['addhtmlblob'] = 'Add Global Content Block';
0
 $lang['admin']['edithtmlblob'] = 'Edit Global Content Block';
0
+$lang['admin']['edithtmlblobsuccess'] = 'Global content block updated';
0
 $lang['admin']['gcb_wysiwyg'] = 'Enable GCB WYSIWYG';
0
 $lang['admin']['gcb_wysiwyg_help'] = 'Enable the WYSIWYG editor while editing Global Content Blocks';
0
 $lang['admin']['filemanager'] = 'File Manager';

Comments

    No one has commented yet.