Thanks for replying Filou.
The main problem is that the instructions in your hack do not match the versions of addnews.mdu and editnews.mdu that I have, even down to the point where 'if($use_wysiwyg){' does not appear in it anywhere. This is from the file downloaded in the last couple of weeks and I have put it in full at the end of the post. Also there is no file called 'filemanager.php' in the CKFinder folder so made the assumption that 'ckfinder.php' was the file to use.
What I did was try to work out where your hack should be implemented in this version of the file and clearly I got it wrong. So, where I am at the moment is back to a clean install with no modified files and CKEditor switched on as the wysiwyg editor in CuteNews options. The editor itself is working fine this way.
The strange thing is that both using your hack, or using the CKE option in CN, the result was exactly the same - when you click on 'Browse Server' the pop-up window initially opens to around the same dimensions of the CKFinder window but then reduces to a simple single folder as in the cnimages.gif attachment.
I am not sure if when I was trying to figure out where to put the hack I messed up any paths. Everything is stored under 'root/edit/news' and I have added another attachment 'structure.gif' to show the set-up and exactly what files I have in the CKFinder folder.
To be honest, although I like CKFinder, at this moment even if I could get what I have to allow uploads and browsing of multiple folders then I would settle for that until there was a solution.
Once again thanks for replying and thanks in advance for any suggestion you can put my way!!
Steve
addnews.mdu
<?PHP
if($member_db[1] > 3){ msg('error', 'Access Denied', 'You don't have permission to add news'); }
$orig_cat_lines = file('./data/category.db.php');
//only show allowed categories
$allowed_cats = array();
$cat_lines = array();
foreach($orig_cat_lines as $single_line){
$ocat_arr = explode('|', $single_line);
if($member_db[1] <= $ocat_arr[3] or ($ocat_arr[3] == '0' || $ocat_arr[3] == '')){
$cat_lines[] = $single_line;
$allowed_cats[] = $ocat_arr[0];
}
}
$utf8_error = false;
if($action == 'addnews'){
echoheader('addnews', 'Add News');
$short_story_id = 'short_story';
$full_story_id = 'full_story';
//
// Are we using the WYSIWYG ?
//
if($config_use_wysiwyg != 'none'){
$use_wysiwyg = $config_use_wysiwyg;
$article_format_options = "
<label for='convert'>
<input id='convert' style="border:0; background-color:transparent" type=checkbox value="yes" name="if_convert_new_lines" disabled=disabled> Convert new lines to
</label>
<br/>
<label for='html'>
<input id='html' style="border:0; background-color:transparent" type=checkbox value="yes" name="dummi" checked disabled="disabled"> Use HTML in this article</label>
<input type=hidden name="if_use_html" value="yes">
<br/>";
}
else{
$use_wysiwyg = 'none';
$article_format_options = "
<label for='convert'>
<input id='convert' style="border:0; background-color:transparent" type=checkbox value="yes" name="if_convert_new_lines" checked=checked> Convert new lines to
</label>
<label for='html'>
<input id='html' style="border:0; background-color:transparent" type=checkbox value="yes" name="if_use_html" checked=checked> Use HTML in this article</label>
";
}
echo "
<script language="JavaScript">
function insert_smilie(ttarget, url, name){
url = "[img]"+url+[/img]";
insert_HTML(ttarget, url);
}
function insert_HTML(ttarget, html){
MYRTE=document.getElementById(ttarget).contentWindow;
currentRTE=ttarget;
MYRTE.document.body.innerHTML += html;
}
function preview(){
if(document.addnews.short_story.value == '' || document.addnews.title.value == ''){ alert('Your article must have at least Title and Short Story'); }
else{
dd=window.open('','prv','height=400,width=750,resizable=1,scrollbars=1')
document.addnews.mod.value='preview';document.addnews.target='prv'
document.addnews.submit();dd.focus()
setTimeout("document.addnews.mod.value='addnews';document.addnews.target='_self'",500)
}
}
function increaseTextarea(area){
if(document.getElementById(area).style.height == ''){
document.getElementById(area).style.height = '300px';
}
else{
var pattern = new RegExp("\d+",'ig');
var currHeight = document.getElementById(area).style.height.match(pattern);
var newHeight = +currHeight + 100;
document.getElementById(area).style.height = newHeight + 'px';
}
}
function submitForm(){
//make sure hidden and iframe values are in sync before submitting form
//to sync only 1 rte, use updateRTE(rte)
//to sync all rtes, use updateRTEs
updateRTE('short_story');
updateRTE('full_story');
//updateRTEs();
//change the following line to true to submit form
return true;
}
function increaseTextareaBug(){";
if($use_wysiwyg != 'none'){
echo "var area = '$full_story_id';
if (document.getElementById(area).style.height == '') {
document.getElementById(area).style.height = '250px';
}
else{
var pattern = new RegExp("\d+",'ig');
var currHeight = document.getElementById(area).style.height.match(pattern);
var newHeight = +currHeight + 1;
document.getElementById(area).style.height = newHeight + 'px';
}";
}
echo '}
onload=focus;function focus(){document.forms[0].title.focus();}
</script>
<form accept-charset="utf-8" onSubmit="return submitForm();" method=post name=addnews action="'.$PHP_SELF.'">
<table border=0 cellpading=0 cellspacing=0 width="100%">
<tr>
<td width="75">Title</td>
<td colspan="2"><input type=text size="55" name="title" tabindex=1>
</tr>';
if($config_use_avatar == 'yes'){
echo"<tr>
<td width="75">Avatar URL
<td colspan="2"><input tabindex=2 type=text size="42" value="$member_db[8]" name="manual_avatar" >Â Â Â <font style="font-size:7pt">(optional)</font>
</tr>";
}
/* Old Single Category Code */
if(count($cat_lines) > 0){
echo '<tr id="singlecat">
<td width="75">Category
<td colspan="2">
<select id="selecsinglecat" name=category tabindex=3>
<option value=""> </option>';
foreach($cat_lines as $single_line){
$cat_arr = explode('|', $single_line);
$if_is_selected = '';
if($category == $cat_arr[0]){ $if_is_selected = ' selected '; }
echo "<option $if_is_selected value="$cat_arr[0]">$cat_arr[1]</option>n";
}
echo "</select> [url=java script:ShowOrHide(](multiple categories)[/url]</tr>";
}
### New multi category code
if(count($cat_lines) > 0){
echo '<tr style="display:none" id="multicat">
<td width="75">Category
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="panel">';
foreach($cat_lines as $single_line){
$cat_arr = explode('|', $single_line);
$if_is_selected = '';
if($category == $cat_arr[0]){ $if_is_selected = 'checked="checked" ';
}
echo "
<td style='font-size:10px;' valign=top>
<label for='cat{$cat_arr[0]}'>
<input $if_is_selected style='background-color:transparent;border:0px;' type=checkbox name='category[]' id='cat{$cat_arr[0]}' value='{$cat_arr[0]}'>$cat_arr[1]</label>";
$i++;
if($i%4 == 0){ echo'<tr>'; }
}
echo '</tr></table> <td></td>';
}
echo '<tr>
<td width="75" valign="top">
Short Story
<td>';
if($use_wysiwyg == 'none'){
echo '<textarea rows="12" style="width:100%;" id="short_story" name="short_story" tabindex=4></textarea>';
}
else{
utf8_wysiwyg('short');
}
if($use_wysiwyg != 'cke') { echo "<td width="108" valign="top" style='background: url(skins/images/baloon.gif) no-repeat top left'>
<p align="center">
<!--[if gt IE 7]>[url= onclick=]<![endif]-->
<![if (!IE)|(lte IE 7)]><a href=# onclick="window.open('$PHP_SELF?&mod=images&action=quick&area=$short_story_id&wysiwyg=$use_wysiwyg&noie', '_Addimage', 'HEIGHT=500,resizable=yes,scrollbars=yes,WIDTH=360');return false;" target="_Addimage"><![endif]>
[insert image][/url]
<!-- [url= onclick=][quick tags][/url]
-->
[url= onclick=][expand][/url]
";
}
echo insertSmilies($short_story_id, 4, true, $use_wysiwyg);
echo "</tr>
<tr id='full-story' style='display:none;z-index:1;'>
<td width="75" valign="top">
Full Story
<font style="font-size:7pt">(optional)</font>
<td>
";
if($use_wysiwyg == 'none'){
echo '<textarea rows="12" style="width:100%;" id="full_story" name="full_story" tabindex=5></textarea>';
}
else{
utf8_wysiwyg('full');
}
if($use_wysiwyg != 'cke') { echo "
<td width="108" valign="top" style='background: url(skins/images/baloon.gif) no-repeat top left'>
<p align="center">
<!--[if gt IE 7]>[url= onclick=][insert image][/url]<![endif]-->
<![if (!IE)|(lte IE 7)]>[url= onclick=][insert image][/url]<![endif]>
<!-- [url= onclick=][quick tags][/url]
-->
[url= onclick=][expand][/url]
";
}
echo insertSmilies($full_story_id, 4, true, $use_wysiwyg);
echo "
</tr>
<tr>
<td><td>
<table border=0 cellspacing=0 cellpadding=0 width=100%>
<tr><td width=50%>
<input type=submit style='font-weight:bold' title="Post the New Article" value=" Add News " accesskey="s">
</td>
<td width=50% align=right>
<input style='width:110px;'type=button onClick="ShowOrHide('full-story',''); setTimeout('increaseTextareaBug()',310);" value="Toggle Full-Story"> <input style='width:90px;' type=button onClick="ShowOrHide('options','');" value="Article Options">
</td>
</tr>
</table>
</tr>
<tr id='options' style='display:none;'>
<td width="75">
Options
<td colspan="4">
$article_format_options
<label for='active'><input CHECKED id='active' style="border:0; background-color:transparent" type=radio value="active" name="postpone_draft">
[b]Normal[/b], add article as active</label>
<label for='draft'><input id='draft' style="border:0; background-color:transparent" type=radio value="draft" name="postpone_draft">
[b]Draft[/b], add article as unapproved</label>
<label for='postpone'><input id='postpone' style="border:0; background-color:transparent" type=radio value="postpone" name="postpone_draft">
[b]Postpone[/b], make article active at</label>
<select name=from_date_day>";
for($i=1; $i<32; $i++){
if(date('j') == $i){ echo "<option selected value=$i>$i</option> n"; }
else{ echo "<option value=$i>$i</option> n"; }
}
echo "</select> n <select name=from_date_month> n";
for($i=1;$i<13;$i++){
$timestamp = mktime(0,0,0,$i,1,2003);
if(date('n') == $i){ echo"<option selected value=$i>". date('M', $timestamp) ."</option> n"; }
else{ echo"<option value=$i>". date("M", $timestamp) ."</option> n"; }
}
echo "</select> n <select name=from_date_year>";
for($i= (date('Y')-2); $i < (date('Y')+3); $i++){
if(date('Y') == $i){ echo "<option selected value=$i>$i</option> n"; }
else{ echo"<option value=$i>$i</option> n"; }
}
$date_hour = date('H');
$date_minutes = date('i');
echo "
</select>
@ <input value='$date_hour' title='24 Hour format [hh]' name=from_date_hour size=2 type=text /> : <input value='$date_minutes' title='Minutes [mm]' name=from_date_minutes size=2 type=text />
</tr>
<input type=hidden name=mod value=addnews>
<input type=hidden name=action value=doaddnews>
<input type=hidden name=token value='".$_SERVER['REMOTE_ADDR']."'>
</table></form>";
echofooter();
}
// *******************
// Do add news to news.txt
// *******************
elseif($action == 'doaddnews'){
if($_POST['token'] != $_SERVER['REMOTE_ADDR']){
msg('error', 'Error', 'The IP address of the form does not match your current one. Please refresh the page and re-submit the form.');
}
///
//Format our categories variable
///
if(is_array($category)){ //User has selected multiple categories
$nice_category = '';
$ccount = 0;
foreach($category as $ckey=>$cvalue){
if(!in_array($cvalue,$allowed_cats)){ die('not allowed category'); }
if($ccount == 0){ $nice_category = $cvalue; }//first cat
else{ $nice_category = $nice_category.','.$cvalue; }
$ccount++;
}
}
else{ //Single or not category
//don't format $nice_cats because we have not selected any.
if($category != '' and isset($category) and !in_array($category,$allowed_cats)){ die('not allowed category'); }
$nice_category = $category;
}
if($member_db[1] == 3 or $postpone_draft == 'draft'){
//if the user is Journalist, add the article as unapproved
$decide_news_file = "./data/unapproved_news.txt";
$added_time = time()+ ($config_date_adjust*60);
$postpone = FALSE;
$unapproved_status_msg = "The article was marked as unapproved!";
}
elseif($postpone_draft == 'postpone'){
if(!ereg("^[[:digit:]]{1,}$", $from_date_hour) or !ereg("^[[:digit:]]{1,}$", $from_date_minutes)){ msg('error','Error!','You want to add a postponed article, but the hour format is invalid.', 'java script:history.go(-1)'); }
$postpone = TRUE;
$added_time = mktime($from_date_hour,$from_date_minutes,0,$from_date_month,$from_date_day,$from_date_year) + ($config_date_adjust*60);
$decide_news_file = './data/postponed_news.txt';
}
else{
$postpone = FALSE;
$added_time = time()+ ($config_date_adjust*60);
$decide_news_file = "./data/news.txt";
}
if($if_convert_new_lines == 'yes'){ $n_to_br = TRUE; }
if($if_use_html == 'yes'){ $use_html = TRUE; }
$full_story = replace_news('add', $full_story, $n_to_br, $use_html);
$short_story = replace_news('add', $short_story, $n_to_br, $use_html);
$title = replace_news('add', $title, TRUE, FALSE);
if(trim($title) == '' or !$title){ msg('error','Error!','The title cannot be blank.', 'java script:history.go(-1)'); }
if(trim($short_story) == '' or !$short_story){ msg('error','Error!','The story can not be blank.', 'java script:history.go(-1)'); }
if(isset($utf8_error) && $utf8_error === true){
msg('error', 'Error', 'Please send your data in UTF-8!', 'java script:history.go(-1)');
}
if($member_db[7] == 1){ $added_by_email = $member_db[5]; }
else{ $added_by_email = 'none'; }
// Save the news article in active_news_file
$all_db = file($decide_news_file);
foreach($all_db as $news_line){
$news_arr = explode('|', $news_line);
if($news_arr[0] == $added_time){ $added_time++; }
}
$news_file = fopen($decide_news_file, 'w');
fwrite($news_file, "$added_time|$member_db[2]|$title|$short_story|$full_story|$manual_avatar|$nice_category||n");
foreach ($all_db as $line){ fwrite($news_file, $line); }
fclose($news_file);
// Add blank comment in the active_comments_file
$old_com_db = file('./data/comments.txt');
$new_com_db = fopen('./data/comments.txt', 'w');
fwrite($new_com_db, "$added_time|>|n");
foreach ($old_com_db as $line){ fwrite($new_com_db, $line); }
fclose($new_com_db);
// Incrase by 1 the number of written news for current user
$old_user_db = file('./data/users.db.php');
$new_user_db = fopen('./data/users.db.php', 'w');
foreach($old_user_db as $old_user_db_line){
$old_user_db_arr = explode('|', $old_user_db_line);
if($username!=$old_user_db_arr[2]){
fwrite($new_user_db, $old_user_db_line);
}
else{
$countplus = $old_user_db_arr[6]+1;
fwrite($new_user_db,"$old_user_db_arr[0]|$old_user_db_arr[1]|$old_user_db_arr[2]|$old_user_db_arr[3]|$old_user_db_arr[4]|$old_user_db_arr[5]|$countplus|$old_user_db_arr[7]|$old_user_db_arr[8]|$old_user_db_arr[9]||n");
}
}
fclose($new_user_db);
if($member_db[1] == 3){
//user is journalist and the article needs to be approved, notify!
utf8_hardlog($member_db[2], 'article_new_unapproved['.$title.']['.$added_time.']');
if($config_notify_unapproved == 'yes' and $config_notify_status == 'active'){
send_mail($config_notify_email, 'CuteNews - Unapproved article was Added', "The user $member_db[2] (journalist) posted article '$title' which needs first to be Approved.");
}
}
else{ utf8_hardlog($member_db[2], 'article_new['.$title.']['.$added_time.']'); }
if($postpone){
utf8_hardlog($member_db[2], 'article_new_postponed['.$title.']['.$added_time.']');
msg('info', 'News added (Postponed)', 'The news item was successfully added to the database as postponed.<br/>It will be activated at '.date('r', $added_time));
}
else{
msg('info', 'News added', 'The news item was successfully added.</br>'.$unapproved_status_msg);
}
}
?>