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 += '

Articles List

'; if (items.length > 0) { htmlstr += ''; htmlstr += ''; for (i=0;i=3) { htmlstr += ''; htmlstr += ''; htmlstr += ''; htmlstr += ''; htmlstr += ''; } } htmlstr += '
titlelast modified 
'+data[1]+''+data[2]+'delete
'; } else { 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 += '

Adding New Article

'; htmlstr += ''; htmlstr += ''; htmlstr += ''; htmlstr += ''; htmlstr += ''; htmlstr += ''; htmlstr += ''; htmlstr += ''; htmlstr += '
Title
Date
Summary
Content
Keywords
Thumbnail
'; htmlstr += '
'; htmlstr += ' '; document.getElementById('plugin_article_admin').innerHTML = htmlstr; //niceditor nicEditorShop = new nicEditor({buttonList : ['bold','italic','underline','forecolor','fontFormat','fontSize','fontFamily','left','center','right','justify','hr','ol','ul','removeformat','link','unlink','cmsmedia','xhtml']}).panelInstance('plugin_article_form_content'); } function plugin_article_edit(id) { document.getElementById('plugin_article_admin').innerHTML = '

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 += '

Editing Article

'; htmlstr += ''; htmlstr += ''; htmlstr += ''; htmlstr += ''; htmlstr += ''; htmlstr += ''; htmlstr += ''; htmlstr += ''; htmlstr += ''; htmlstr += '
Title
Date
Summary
Content
Keywords
Thumbnail
'; htmlstr += '
'; htmlstr += ' '; document.getElementById('plugin_article_admin').innerHTML = htmlstr; //niceditor nicEditorShop = new nicEditor({buttonList : ['bold','italic','underline','forecolor','fontFormat','fontSize','fontFamily','left','center','right','justify','hr','ol','ul','removeformat','link','unlink','cmsmedia','xhtml']}).panelInstance('plugin_article_form_content'); } else { alert(http.responseText); plugin_article_list(); } } } http.send(); } function plugin_article_delete(id) { document.getElementById('plugin_article_admin').innerHTML = '

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 += '

Deleting Article

'; htmlstr += ''; htmlstr += ''; htmlstr += ''; htmlstr += ''; htmlstr += ''; htmlstr += '
Title'+data[0]+'
Summary'+data[1]+'
'; htmlstr += '
'; htmlstr += '

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 += '

Edit Settings

'; if (items.length > 0) { htmlstr += ''; for (i=0;i'; } htmlstr += '
'; if (inArray(data[0],plugin_article_options_pagetype)) { htmlstr += ''; } else { htmlstr += ''; } htmlstr += '
'; htmlstr += '
'; htmlstr += '

'; } else { 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;i=4) { htmlstr += '
'; htmlstr += '

'+data[1]+'

'; htmlstr += ''; htmlstr += '
'+data[3]+'...
'; htmlstr += '

read more

'; htmlstr += '
'; } } htmlstr += ''; document.getElementById('plugin_article').innerHTML = htmlstr; } } http.send(); }