2011-01-25 4 views
3

저는 클라이언트 용으로 구축 할 새 웹 사이트에서 tinyMCE를 테스트하고 있습니다. 여기 TinyMCE 이미지 URL에 슬래시를 추가합니다.

나는 이미지 삽입을하고 이미지 중 하나를 선택하면

http://simplicity.s462.sureserver.com/editor.php

난 데 문제는 ... 에디터의 테스트 페이지입니다 TinyMCE에받는 추가 슬래시를 추가 이미지 URL. 따라서 이미지를 찾을 수 없습니다. 여분의 슬래시를 수동으로 제거하면 이미지가 발견됩니다.

어떻게 tinyMCE가 이러한 여분의 슬래시를 추가하지 못하게합니까? 나는 간단한 대답이있을 것이라고 확신하지만, 몇 시간 동안 수색 해왔고 그 해답을 찾는 행운이 없다. 내가 도대체 ​​뭘 잘못하고있는 겁니까??

다음
<?php // this must be the very first line in your PHP file! 

// You can't simply echo everything right away because we need to set some headers first! 
$output = ''; // Here we buffer the JavaScript code we want to send to the browser. 
$delimiter = ""; // for eye candy... code gets new lines 

$output .= 'var tinyMCEImageList = new Array('; 

$directory = "../../images"; // Use your correct (relative!) path here 

// Since TinyMCE3.x you need absolute image paths in the list... 
$abspath = preg_replace('~^/?(.*)/[^/]+$~', '/$1', $_SERVER['SCRIPT_NAME']); 

if (is_dir($directory)) { 
    $direc = opendir($directory); 

    while ($file = readdir($direc)) { 
     if (preg_match('~^.~', $file)) { // no hidden files/directories here... 
      if (is_file("$directory/$file") && getimagesize("$directory/$file") != FALSE) { 
       // We got ourselves a file! Make an array entry: 
       $output .= $delimiter 
        . '["' 
        . utf8_encode($file) 
        . '", "' 
        . utf8_encode("$abspath/$directory/$file") 
        . '"],'; 

      } 
     } 
    } 

    $output = substr($output, 0, -1); // remove last comma from array item list (breaks some browsers) 
    $output .= $delimiter; 

    closedir($direc); 
} 
else 
{ 
    echo "false"; 
} 

// Finish code: end of array definition. Now we have the JavaScript code ready! 
$output .= ');'; 

// Make output a real JavaScript file! 
header('Content-type: text/javascript'); // browser will now recognize the file as a valid JS file 

// prevent browser from caching 
header('pragma: no-cache'); 
header('expires: 0'); // i.e. contents have already expired 

// Now we can send data to the browser because all headers have been set! 
echo $output; 

?> 

는 TinyMCE에 대한 설정은 다음과 같습니다 :

여기에 이미지 목록 채우는 데 사용되는 PHP 코드 도와

 // General options 
    mode : "textareas", 
    theme : "advanced", 
    plugins : "spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template", 

    // Theme options 
    theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect", 
    theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor", 
    theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen", 
    theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage", 
    theme_advanced_toolbar_location : "top", 
    theme_advanced_toolbar_align : "left", 
    theme_advanced_statusbar_location : "bottom", 
    theme_advanced_resizing : true, 
    relative_urls : false, 
    convert_urls : false, 


    // Example content CSS (should be your site CSS) 
    content_css : "css/example.css", 

    // Drop lists for link/image/media/template dialogs 
    template_external_list_url : "js/template_list.js", 
    external_link_list_url : "js/link_list.js", 
    external_image_list_url : "external_image_list_url.php", 
    media_external_list_url : "js/media_list.js", 

감사합니다!

+0

혹시 해결책을 찾았나요 :

tinymce.init({ selector: '#relurlstopage', relative_urls: true, document_base_url: 'http://www.tinymce.com/tryit/' }); 

는 URL의

tinymce.init({ plugins: 'link image code', convert_urls: false }); 

소스를 변환하지 마십시오. URL을 추가 할 때 동일한 문제가 발생합니다. – Aaron

답변

1

PHP에 이중 슬래시가 삽입 된 것처럼 보입니다. 나는 $abspath/되는 끝 당신은 이미 거기에 슬래시를 추가하는

utf8_encode("$abspath/$directory/$file") 

을 말할 때 $directory 그렇게 images/되는 끝 같은데요. 첫 번째 단계는 PHP 내부에 $abspath, $directory$file의 값을 검사하는 것입니다.

예에서 모든 이미지는 하나의 디렉토리에 있으며 웹 서버와 관련하여 디렉토리가 /images 인 것을 알고 있습니다. 따라서 문제를 해결하고 간단히 말하면 다음과 같이 말할 수 있습니다.

utf8_encode("/images/$file") 

경로 조작 및 붙여 넣기를 수행하는 것이 아니라

5

다음은 tinymce 웹 사이트의 몇 가지 예입니다.

그들은 내가 가지고있는 문제를 ../../ 슬래시로 수정했습니다.

절대 URL의

tinymce.init({ 
    relative_urls: false 
}); 

절대 URL의 호스트 이름. 해당 페이지

tinymce.init({ 
    relative_urls: false, 
    remove_script_host: false 
}); 

상대 URL의

tinymce.init({ 
    relative_urls: true 
}); 

URL의 상대.http://www.tinymce.com/tryit/url_conversion.php

관련 문제