aahh, another one using my favourite js-editor! I guess you are using Klaus Teichler's TinyMCE script that can be downloaded from the wiki. In fact I don't really know it, but it should be easy to integrate one of this two solutions for the internal (image) links.
that adds the two select boxes for images and internal links.
I found another solution that passes the image and internal link lists to the TinyMCE plugins advimg and advlink (I think they are integrated by default). So they are one click further away but you can manage the internal links with the ease of TinyMCE.
files. The tinymce.php, of course, placed in the folder cmsimple. Here is the code:
Code: Select all
<?php
if(!$cf['tinymce']['folder']) {
$cf['tinymce']['folder']="tiny_mce";
}
if(!@is_dir($pth['folder']['base'].$cf['tinymce']['folder'])){
e('cntopen','folder',$cf['tinymce']['folder']);
}
function get_the_links($h, $u, $l,$sn,$downloads_path){
$list='';
for($i = 0; $i < count($h); $i++){
$spacer = '';
if($l[$i] > 1){
$spacer = str_repeat(' ', $l[$i]-1);
}
$list.='["'.$spacer.substr(str_replace('"','"',$h[$i]),0,30).'", "'.$sn.'?'.$u[$i].'"],';
}
if(@is_dir($downloads_path)){
$list .= '["DOWNLOADS:",""],';
$fs = sortdir($downloads_path);
foreach($fs as $p){
if(preg_match("/.+\..+$/",$p)){
$list .= '[" '.substr($p,0,25).' ('.(round((filesize($downloads_path.'/'.$p))/102.4)/10).' KB)", "'.$sn.'?download='.$p.'"],';
}
}
}
$list = substr($list, 0,-1);
return($list);
}
function get_the_images($directory) {
$files = array();
$handle = opendir($directory);
$i = 0;
while(($file = readdir($handle))){
if(eregi("(\.jpg$|\.gif$|\.png$|\.jpeg$)",$file)) {
$files[$i]['name'] = $file;
$files[$i]['path'] = $directory. "" .$file;
$i++;
}
}
closedir($handle);
sort($files);
$list = '';
foreach($files as $i) {
$list .='["'. ($i['name']). '", "'.($i['path']) . '"],';
}
$list = substr($list, 0, -1);
return($list);
}
$hjs .='
<script language="javascript" type="text/javascript" src="'.$pth['folder']['base'].$cf['tinymce']['folder'].'/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">';
$hjs .= '
var MyImageList = new Array('.get_the_images($pth['folder']['images']).');
var MyLinkList = new Array('.get_the_links($h, $u, $l,$sn,$pth['folder']['downloads']).');
tinyMCE.init({
mode: "textareas",
theme: "advanced",
language: "'.$sl.'",
elements : "ctrl_text",
plugins : "safari,style,table,save,advimage,advlink,media,searchreplace,contextmenu,paste,nonbreaking,xhtmlxtras",
theme_advanced_buttons1 : "undo, redo,|, "
+"charmap,|,outdent,indent,blockquote,|,bullist,numlist,|,tablecontrols,|,help",
theme_advanced_buttons2 : "save,|,formatselect,|,image,media,|,link, unlink, anchor,|,bold,italic,underline,|,styleselect,|,cleanup,code",
theme_advanced_buttons3 : "cite,abbr,acronym,del,ins,attribs,|, cut,copy,paste,pasteword,|,hr,media,styleprops,|,sub,sup,nonbreaking,|,forecolor,backcolor,|,",
theme_advanced_blockformats : "h1,h2,h3,p,h4,h5,h6",
relative_urls : true,
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
external_image_list_url : "'.$pth['folder']['base'].$cf['tinymce']['folder'].'/cmsimple_image_list.js",
external_link_list_url : "'.$pth['folder']['base'].$cf['tinymce']['folder'].'/cmsimple_link_list.js",
advlink_styles : "",
advimage_styles : "leftInset=left;rightInset=right",
content_css: "'.$sn.'cmsimple/tinymce.css, '.$sn.'?&stylesheet",
inline_styles : true,
visual : true,
verify_css_classes: false,
verify_html: false,
trim_span_elements: true,
theme_advanced_resizing : true,
valid_elements: "*[*]"
});
</script>';
$o .= "\n".'<form method="post" id="ta" action="'.$sn.'">'."\n\t".tag('input type="hidden" name="selected" value="'.$u[$s].'"')."\n\t".tag('input type="hidden" name="function" value="save"')."\n\t".'<textarea name="text" id="text" rows="40" cols="80">'."\n".$c[$s]."\n\t".'</textarea>'."\n".'</form>';
?>
and those files have to be put into the tiny_mce folder. Their code is rather short. cmsimple_link_list.js: