1

주제: ViewPostContent event에서...

ViewPostContent event에서...
[wiki:xxx]
이런걸 처리하는 플러그인을 개인적으로 만들어보려 합니다..
근데 이부분이 인식이 안되네요..
ViewCommentContent
ViewGuestCommentContent
ViewNoticeContent
에서는 되는듯 합니다.
하지만, 저부분에서는 저게 안됩니다.
왜그런지....

Yesterday is history, tomorrow is a mystery, and today is a gift; that's why we call it - present

2

답글: ViewPostContent event에서...

htna 작성:

ViewPostContent event에서...
[wiki:xxx]
이런걸 처리하는 플러그인을 개인적으로 만들어보려 합니다..
근데 이부분이 인식이 안되네요..
ViewCommentContent
ViewGuestCommentContent
ViewNoticeContent
에서는 되는듯 합니다.
하지만, 저부분에서는 저게 안됩니다.
왜그런지....

ViewPostContent 이벤트의 정상동작을 확인했습니다(rev. 2632). 소스 코드를 보여주셔야 할 것 같은데요...

graphittie (2006-12-04 11:12:23)에 의해 마지막으로 수정

3

답글: ViewPostContent event에서...

function WikiLink($value,$hostURL, $blogURL)
{
    // [wiki:value] 의 "value"를 받아서
    // "<a href=xxx/keylog/value>value</a>"를 리턴하는 역활을 합니다.
    if(($mid=strpos($value," "))==true) {
        $name = substr($value,$mid+1);
        $value = substr($value,0,$mid);
    } else {
        $name = $value; 
    }
    $link = "<a class=\"key1\" href='" . $hostURL . $blogURL . "/keylog/" . $value . "'>";
    $link .= $name; //"<font color=#177fcd>" . $name . "</font>";
    $link .= "</a>";
    return $link;
}

function Wiki($target, $mother) {
    global $hostURL, $blogURL;

    while(($start=strpos($target,"[wiki:"))==true
        && ($end=strpos($target,"]",$start+6))==true )
    {
        $prefix  = substr($target,0,$start);
        $value   = substr($target,$start+6,$end-$start-6);
        $postfix = substr($target,$end+1);

        $target  = $prefix;
        $target .= WikiLink($value,$hostURL, $blogURL);
        $target .= $postfix;
    }

    return $target;
}

소스 올립니다.

htna (2006-12-04 14:27:03)에 의해 마지막으로 수정

Yesterday is history, tomorrow is a mystery, and today is a gift; that's why we call it - present

4

답글: ViewPostContent event에서...

잘 되는데요? index.xml 파일에서 이벤트 event listener 부분의 정보가 정확한지 확인해 주세요. "<listener event='ViewPostContent'>Wiki</listener>"라고 입력되어 있어야 합니다(너무 초보적인 답변이라 죄송합니다).

5

답글: ViewPostContent event에서...

graphittie 작성:

잘 되는데요? index.xml 파일에서 이벤트 event listener 부분의 정보가 정확한지 확인해 주세요. "<listener event='ViewPostContent'>Wiki</listener>"라고 입력되어 있어야 합니다(너무 초보적인 답변이라 죄송합니다).

네 되어있습니다.

특이하게도...
Wiki 함수를

function Wiki($target, $mother) {
    return $target."XXX";
}

와 같이 작성하면, 글 마지막에 XXX는 찍힙니다.
제 생각에 아무래도, 'ViewPostContent'에서만 호출되기 이전에 '['나 ']'를 다른키워드로 치환하거나 하지 않나 생각이 듭니다.
ViewCommentContent, ViewGuestCommentContent, ViewNoticeContent 모두 저 이벤트를 주었습니다.
어느게 어느거인지는 모르겠지만, keyword 문서에서는 제대로 처리됩니다.

Yesterday is history, tomorrow is a mystery, and today is a gift; that's why we call it - present

6

답글: ViewPostContent event에서...

htna 작성:
graphittie 작성:

잘 되는데요? index.xml 파일에서 이벤트 event listener 부분의 정보가 정확한지 확인해 주세요. "<listener event='ViewPostContent'>Wiki</listener>"라고 입력되어 있어야 합니다(너무 초보적인 답변이라 죄송합니다).

네 되어있습니다.

특이하게도...
Wiki 함수를

function Wiki($target, $mother) {
    return $target."XXX";
}

와 같이 작성하면, 글 마지막에 XXX는 찍힙니다.
제 생각에 아무래도, 'ViewPostContent'에서만 호출되기 이전에 '['나 ']'를 다른키워드로 치환하거나 하지 않나 생각이 듭니다.
ViewCommentContent, ViewGuestCommentContent, ViewNoticeContent 모두 저 이벤트를 주었습니다.
어느게 어느거인지는 모르겠지만, keyword 문서에서는 제대로 처리됩니다.

저 함수 고대로 옮겨가 의도하신대로 동작하는 것을 확인했거든요. 다른 플러그인이 뭔가 먼저 건드리고 있는 게 아닐까요? 한 번 $target을 echo로 찍어 보시지요?

graphittie (2006-12-04 17:19:18)에 의해 마지막으로 수정

7

답글: ViewPostContent event에서...

graphittie 작성:

저 함수 고대로 옮겨가 의도하신대로 동작하는 것을 확인했거든요. 다른 플러그인이 뭔가 먼저 건드리고 있는 게 아닐까요? 한 번 $target을 echo로 찍어 보시지요?

음.. 그럴수도 있겠군요...

근데...
방금
preg_match_all 와 str_replace로 처리하도록 함수를 바꿔봤습니다.
이거 첨보는 함수들이라, 익히는데 혼동했네요...
이거는 왜 될까요???

솔직히 내부에서 regular expression을 사용할 용도가 아니라면,
저런정도의 코드만으로도 충분한데...

Yesterday is history, tomorrow is a mystery, and today is a gift; that's why we call it - present

8

답글: ViewPostContent event에서...

htna 작성:
graphittie 작성:

저 함수 고대로 옮겨가 의도하신대로 동작하는 것을 확인했거든요. 다른 플러그인이 뭔가 먼저 건드리고 있는 게 아닐까요? 한 번 $target을 echo로 찍어 보시지요?

음.. 그럴수도 있겠군요...

근데...
방금
preg_match_all 와 str_replace로 처리하도록 함수를 바꿔봤습니다.
이거 첨보는 함수들이라, 익히는데 혼동했네요...
이거는 왜 될까요???

솔직히 내부에서 regular expression을 사용할 용도가 아니라면,
저런정도의 코드만으로도 충분한데...

흐흐... 그러게요. 왜 될까요. 의문이네...

결국 정규식을 쓰셨군요. 소스 가독성면에서는 정규식이 낫지 않을까 싶습니다.

9

답글: ViewPostContent event에서...

아 그러고보니..
"$target을 echo로 찍어 보시지요?"
어케하는 건가요 ???

Yesterday is history, tomorrow is a mystery, and today is a gift; that's why we call it - present

10

답글: ViewPostContent event에서...

htna 작성:

아 그러고보니..
"$target을 echo로 찍어 보시지요?"
어케하는 건가요 ???

그냥 "echo $target;"입니다. echo는 print와 비슷한 기능을 합니다만, 함수가 아니기 때문에(정확히는 language construct) 괄호는 필요 없습니다.