여러가지 이것저것 만져본 결과

 

중간에 삽입할때 멀티미디어 컨텐츠라거나 인용구 접기기능이라거나 그런게 작동을 안하는거였더군요.

 

그리고

 

$output = preg_replace('/<div class="document_([0-9]+)_([0-9]+) xe_content">(.*)<\!--AfterDocument\(([0-9]+),([0-9]+)\)-->/is', '<div class="document_$1_$2 xe_content">'.$content.'</div><!--AfterDocument(${1},${2})-->', $output);

 

이부분이 문제라는것을 알게되었는데

 

여기서 도통 무엇을 바꿔야 변형되지 않고 본문 그대로 출력되는지 잘 모르겠네요..

중간에 본문 삽입을 시키면 에디터 컴포넌트 기능 몇가지가 마비되버리니 말이죠..

설문기능이라거나.. 멀티미디어 컨텐츠라거나.. 인용구 접기 펼치기 기능이라거나.. 완전 마비 상태인데..

 

후.. 도움 부탁드립니다 ㅠㅠ..

 

  • profile
    저도 얼마 전에 안 사실인데, 에디터 컴포넌트의 transHTML 함수 작동 시점이 애드온의 before_display_content 호출 시점 직전이라 하더라구요.
    한 마디로, 애드온이 본문을 다시 쏴주니까 컴포넌트의 처리 결과가 무효화되는 거죠.

    제 경우엔 위의 코드 아래에다,
    에디터 모듈에 있었던가.. transEditorComponent라는 함수를 가져와서 컴포넌트를 다시 한번 쏴주는 식으로 해결했었어요.
  • profile ?
    조금만 더 자세히 알려 주실 수 있나요..!
  • ? profile
    그러니까 output 안에 컴포넌트 패턴('editor_component=')이 있으면,
    컴포넌트 패턴을 에디터 모듈의 함수를 이용해 다시 trans 하는 거죠.
    그리고 그 결과를 다시 output으로 재출력...
  • profile ?
    editor.controller.php에 가서 보는거까진 됬는데..
    이걸 그대로 가져가는건가요..?

    죄송합니다, 제가 이런대에 지식이 없어서 ... ㅠㅠ
  • ? profile
    해당 함수를 애드온 파일 끝나기 직전에 붙여넣으시구요.

    문제가 된다던 $ouput = ~~~; 다음 줄에 아래 소스 정도를 붙여보세요.

    $component_pattern = '!<(?:(div)|img)([^>]*)editor_component=([^>]*)>(?(1)(.*?)</div>)!is';
    if (preg_match($component_pattern, $output, $match))
    {
    $output = preg_replace_callback($component_pattern, transEditorComponent, $output);
    }

    ... 된다는 보장은 못 드려요;;
  • profile ?

    와, 감사합니다. 그냥 무작정 붙여넣기만 한다고 되는게 아니였군요.

    정상적으로 작동이 되는거 같습니다.

     

    다른사람들도 보시라고 적어두겠습니다.

     

    /**
     * @brief Convert editor component code of the contents
     */
    function transEditorComponent($match)
    {
    $script = " {$match[2]} editor_component={$match[3]}";
    $script = preg_replace('/([\w:-]+)\s*=(?:\s*(["\']))?((?(2).*?|[^ ]+))\2/i', '\1="\3"', $script);
    preg_match_all('/([a-z0-9_-]+)="([^"]+)"/is', $script, $m);
    
    $xml_obj = new stdClass;
    $xml_obj->attrs = new stdClass;
    for($i=0,$c=count($m[0]);$i<$c;$i++)
    {
    if(!isset($xml_obj->attrs)) $xml_obj->attrs = new stdClass;
    $xml_obj->attrs->{$m[1][$i]} = $m[2][$i];
    }
    $xml_obj->body = $match[4];
    
    if(!$xml_obj->attrs->editor_component) return $match[0];
    
    // Get converted codes by using component::transHTML()
    $oEditorModel = getModel('editor');
    $oComponent = &$oEditorModel->getComponentObject($xml_obj->attrs->editor_component, 0);
    if(!is_object($oComponent)||!method_exists($oComponent, 'transHTML')) return $match[0];
    
    return $oComponent->transHTML($xml_obj);
    }

    이 부분을 치환하기전 부분에 넣어주고

    output = ~~

    아래에 윤삼님이 적어주신 코드를 그대로 적어주시면 정상적으로 작동합니다.

     

    감사합니다, 윤삼님!

  • ? profile

    아, 맞다ㅎㅎ
    제가 무료포인트 마켓에 올렸던 쪽 나누기 애드온에 그런 방식이 적용되어 있으니,
    코딩 상에 문제가 있거나 하시면
    해당 애드온을 참조해보셔도 좋을 거 같아요.

     

    아, 되었네요!! 

  • profile ?
    아, 감사합니다.
    한번 참고해보겠습니다.
  • profile ?
    아, 궁금한게 하나 있는데

    $component_pattern = '!<(?:(div)|img)([^>]*)editor_component=([^>]*)>(?(1)(.*?)</div>)!is';
    if (preg_match($component_pattern, $output, $match)) $output = preg_replace_callback($component_pattern, transEditorComponentByUserPage, $output);

    이 부분은 윤삼님이 직접 작성하신건가요?
    아니면 어느 부분에 나와있는건가요?

    이런 부분이 어디에 있는지도 보면 공부에 도움이 될거같아서.,.
  • ? profile

    야매라서 저도 잘은 몰라요ㅋㅋ
    정규식은 멀티미디어 컨텐츠 컴포넌트에서 슬쩍했구요 ;)
    그 외에는 일반적인 php 정규식 관련 구문이니까, 뭐... 열심히 구글링을;;;

  • profile ?
    아.. 윤삼님도 독학으로..
    감사합니다, 배우신 지식을 공유한다는게 어려운데.. 알려주셔서 저도 열심히 하겠습니다.. ㅠㅠ