'Textcube/Plug-in Develoment'에 해당되는 글 2건

Posted on 2006/02/03 10:00
Filed Under Textcube/Plug-in Develoment

태터툴즈에 현재 지원되는 이벤트가 많지 않습니다. 이제 시작이지요. 1.0 RC3에서 정의된 이벤트는 다음과 같습니다.
  • CommenterPrinting
  • CommentPrinting
  • GuestCommenterPrinting
  • GuestCommentPrinting
  • /plugin/*
정말 없네요 --;

계속 이벤트를 정의해 나가겠습니다만, 임시로 이벤트를 정의하는 방법을 알려드리겠습니다.

특별히 이벤트를 정의할 필요없이 이벤트를 생성(fire)해 주면 됩니다. 생성하는 함수는 fireEvent로 그것의 interface는 다음과 같습니다.

function fireEvent($event, $target = null, $mother = null, $condition = true)

  • $event

    string값으로 이벤트 식별자입니다. 위의 'CommenterPrintring', '/plugin/MetaWebLogAPI/' 처럼 임의로 지정해 주시면 되겠습니다. 새로운 글이 포스팅됐을 때를 처리하기 위해 'EntryPosting'을 사용해 봅시다.
  • $target

    특별히 type이 정해지지 않았으며, 이벤트의 종류에 따라 implicitly 결정됩니다. 'EntryPosting'을 위해 한 entry 정보를 담고 있는 array로 사용해 봅시다.
  • $mother

    $target과 관련하여 추가로 제공하는 정보이며, 역시 이벤트의 종속적으로 type이 결정됩니다.
  • $condition

    boolean으로 이벤트를 생성(fire)할 지 여부를 programmable하게 결정합니다.
  • RETURN

    이벤트 처리자(listener)가 $target을 기반으로 리턴한 값을 되돌려 줍니다. 이벤트 처리자는 아무런 처리도 하지 않았다면 반드시 $target을 그대로 리턴해야 합니다.
이제 EntryPosting 이벤트를 생성해 봅시다. 새로운 글을 처리하는 소스 파일은 blog/owner/entry/add/index.php입니다. 소스를 보면 적당한 위치가 제일 마지막 줄(957)입니다. 이 줄을 다음과 같이 수정합니다.
respondResultPage(addEntry($owner,$entry)!==false);?>

-->

respondResultPage(addEntry($owner,fireEvent('EntryPosting', $entry))!==false);?>

이제 EntryPosting 이벤트를 받아 처리하는 플러그인을 하나 만드셔서, 새로운 글이 추가되기 직전에 글의 내용을 보완하거나 싸이월드 등에 동기화시킬 수도 있겠습니다.

2006/02/03 10:00 2006/02/03 10:00

Posted on 2006/02/03 10:00
Filed Under Textcube/Plug-in Develoment

tattertools/plugins/ 위치에 디렉토리별로 존재



[BlogIcon] 라고 할때



tattertools/BlogIcon/



안에 index.xml과 index.php가 조재



[index.php]

<?
function showBlogIcon($target, $mother) {
    if (empty($mother['homepage']))
        return $target;
    $slash = ($mother['homepage']{strlen($mother['homepage']) - 1} == '/' ? '' : '/');
    return "<img src=\"{$mother['homepage']}{$slash}index.gif\" width=\"16\" height=\"16\" onerror=\"this.parentNode.removeChild(this)\"/> $target";
}
?>




[index.xml]

<?xml version="1.0" encoding="utf-8"?>

<plugin version="1.0">

  <title>블로그 아이콘 표시</title>

  <version>1.0</version>

  <description>댓글의 홈페이지에 블로그 아이콘(index.gif)이 있으면 댓글에 표시됩니다.</description>

  <license>TPL</license>

  <link>http://www.tattertools.com/plugins/BlogIcon</link>

  <author link="http://www.tattertools.com"><![CDATA[Tatter & Company]]></author>

  <safety changeData="no" exposeData="no" accessLocal="no" accessRemote="no" accessRaw="no" />

  <requirements>

   <tattertools>1.0</tattertools>

  </requirements>

  <listeners>

   <listener event="CommenterPrinting">showBlogIcon</listener>

  </listeners>

</plugin>
2006/02/03 10:00 2006/02/03 10:00

Counter

· Total
: 361645
· Today
: 93
· Yesterday
: 110