Changeset 6379

Show
Ignore:
Timestamp:
07/05/08 03:28:28 (6 months ago)
Author:
coolengineer
Message:
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/1.7/plugins/CL_Moblog/index.php

    r6348 r6379  
    174174    } 
    175175 
     176    /** 
     177     * Extract tags from {tag1,tag2,tag3,...} format string in the mms message. 
     178     * $mail will be changed to be removed tags. 
     179     */ 
     180    function extractTags( & $mail ) 
     181    { 
     182        $p = '/{([^}]*)}/'; 
     183        $tags = array(); 
     184        if( preg_match( $p, $mail['text'], $m ) ) { 
     185            $tags = split( ',', $m[1] ); 
     186            $mail['text'] = preg_replace( $p, '', $mail['text'] ); 
     187        } 
     188        return $tags; 
     189    } 
     190 
    176191    function retrieveCallback( $lines, $uid ) 
    177192    { 
     
    203218 
    204219        if( $post->open( "slogan = '$slogan'" ) ) { 
     220            $post->loadTags(); 
    205221            $this->log( "* 기존 글을 엽니다. (SLOGAN:$slogan)" ); 
     222            if( empty($post->tags) ) { 
     223                $post->tags = array(); 
     224            } 
     225            $tags = $this->extractTags( $mail ); /* mail content will be changed */ 
     226            $post->tags = array_merge( $post->tags, $tags ); 
    206227            $post->content .= $moblog_begin.$this->_getDecoratedContent( $mail, $docid ); 
    207228            $post->modified = time(); 
     
    218239            $post->userid = $this->userid; 
    219240            $post->category = $this->category; 
     241            $post->tags = $this->extractTags( $mail ); /* Go with csv string, Tag class supports both string and array */ 
    220242            $post->content = $moblog_begin.$this->_getDecoratedContent( $mail, $docid ); 
    221243            $post->contentFormatter = getDefaultFormatter();