if (typeof(script_root) == "undefined") { var script_root = ''; } var nicEditorShop; function article_init() { //.. } var plugin_article_options_pagetype = new Array('list_page','preview_pages'); /*---- admin functions ----*/ function plugin_article_list() { document.getElementById('plugin_article_admin').innerHTML = '
Retrieving Articles...
'; var url = script_root+'plugins/article/ajax.php?action=list'; var http = AJAX_obj(); http.open("GET", url, true) http.onreadystatechange = function() {//Call a function when the state changes. if(http.readyState == 4 && http.status == 200) { var htmlstr = '', i, items = http.responseText.split("]/*delim_item[*/"), data; htmlstr += '
| title | last modified | |
|---|---|---|
| '+data[1]+' | '; htmlstr += ''+data[2]+' | '; htmlstr += 'delete | '; htmlstr += '
no article added yet.
'; } htmlstr += ''; document.getElementById('plugin_article_admin').innerHTML = htmlstr document.getElementById('plugin_article_admin_menu').innerHTML = 'Edit Settings'; } } http.send(); } function plugin_article_add() { var action = 'add'; var htmlstr = ''; htmlstr += '| Title | |
|---|---|
| Date | |
| Summary | |
| Content | |
| Keywords | |
| Thumbnail |
Retrieving article data...
'; var url = script_root+'plugins/article/ajax.php?action=info&id='+id; var http = AJAX_obj(); http.open("GET", url, true) http.onreadystatechange = function() {//Call a function when the state changes. if(http.readyState == 4 && http.status == 200) { var htmlstr = '', data = http.responseText.split("]/*delim_data[*/"); if (data.length>=4) { var action = 'edit'; htmlstr += '
| Title | |
|---|---|
| Date | |
| Summary | |
| Content | |
| Keywords | |
| Thumbnail |
Retrieving article data...
'; var url = script_root+'plugins/article/ajax.php?action=info&id='+id; var http = AJAX_obj(); http.open("GET", url, true) http.onreadystatechange = function() {//Call a function when the state changes. if(http.readyState == 4 && http.status == 200) { var htmlstr = '', data = http.responseText.split("]/*delim_data[*/"); if (data.length>=4) { var action = 'delete'; htmlstr += '
| Title | '+data[0]+' | |
|---|---|---|
| Summary | '+data[1]+' |
Are you sure you want to delete this article?
'; htmlstr += ''; document.getElementById('plugin_article_admin').innerHTML = htmlstr; } else { alert(http.responseText); plugin_article_list(); } } } http.send(); } function plugin_article_process() { var button_text = document.getElementById('plugin_article_button').value; document.getElementById('plugin_article_button').value = 'Processing...'; document.getElementById('plugin_article_button').disabled = true; var url = script_root+'plugins/article/ajax.php?action=process'; var params = ''; var action = document.getElementById('plugin_article_form_action').value; params += '&form_action='+action; if (action!='add') { params += '&article_id='+document.getElementById('plugin_article_id').value; } if (action!='delete') { params += '&article_date='+post_escape(document.getElementById('plugin_article_form_date').value); params += '&title='+post_escape(document.getElementById('plugin_article_form_title').value); params += '&summary='+post_escape(document.getElementById('plugin_article_form_summary').value); params += '&keywords='+post_escape(document.getElementById('plugin_article_form_keywords').value); params += '&thumb='+post_escape(document.getElementById('plugin_article_form_thumb').value); if (nicEditorShop.instanceById('plugin_article_form_content')) { params += '&content='+post_escape(nicEditorShop.instanceById('plugin_article_form_content').getContent()); } else { params += '&content='+post_escape(document.getElementById('plugin_article_form_content').value); } } var http = AJAX_obj(); http.open("POST", url, true) http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http.setRequestHeader("Content-length", params.length); http.setRequestHeader("Connection", "close"); http.onreadystatechange = function() {//Call a function when the state changes. if(http.readyState == 4) { if (http.status == 200) { if (http.responseText=='success') { alert('Changes successfully saved!'); plugin_article_list(); } else { if (http.responseText) { alert(http.responseText); } else { alert('Something is wrong with the system. Please try again later.'); } document.getElementById('plugin_article_button').value = button_text; document.getElementById('plugin_article_button').disabled = false; } } else { alert('Ajax Status: '+http.status); document.getElementById('plugin_article_button').value = button_text; document.getElementById('plugin_article_button').disabled = false; } } } http.send(params); } function plugin_article_options() { document.getElementById('plugin_article_admin').innerHTML = '
Retrieving Settings...
'; var url = script_root+'plugins/article/ajax.php?action=option'; var http = AJAX_obj(); http.open("GET", url, true) http.onreadystatechange = function() {//Call a function when the state changes. if(http.readyState == 4 && http.status == 200) { var htmlstr = '', i, data, items = http.responseText.split("]/*delim_item[*/"); htmlstr += '
| '+data[1].replace(/ /g,' ')+' | ';
if (inArray(data[0],plugin_article_options_pagetype)) {
htmlstr += '';
htmlstr += '';
var k;
for (k=0;k | ';
}
htmlstr += '
|---|
no settings to edit.
'; } document.getElementById('plugin_article_admin').innerHTML = htmlstr document.getElementById('plugin_article_admin_menu').innerHTML = 'Back to Article List'; } } http.send(); } function plugin_article_options_save() { var url = script_root+'plugins/article/ajax.php?action=option_save'; var params = '';; params += 'action=save'; var i, inputs = document.getElementsByName('plugin_article_option[]'); for (i=0;iDate: '+data[2]+'