Changeset 169

Show
Ignore:
Timestamp:
2008-11-29 19:24:42 (3 years ago)
Author:
hannes
Message:

allow multiple posts to be inserted into posting area as quotes automatically (ticket #54)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/classes/misc/Post.php

    r166 r169  
    8484        } 
    8585        // post header (time of post etc.) 
    86         $table->addRow(Array('<td colspan="2" class="postheader">' . $LANG['Posted'] . ' ' . $F->datetime($this->post->posttime) . ' | <a href="' . $F->link('reply') . 'id=' . $INPUT['id'] . '&amp;quote=' . $this->id . '">' . $LANG['Quote'] . '</a> | ' . $_showip . '<a href="' . $F->link('edit') . 'id=' . $this->id . '">' . $LANG['Edit'] . '</a> | <a href="' . $F->link('delete') . 'id=' . $this->id . '">' . $LANG['Delete'] . '</a> ' . $_split . '</td>')); 
     86        $_row = '<td colspan="2" class="postheader">' . $LANG['Posted'] . ' ' . $F->datetime($this->post->posttime) . ' | <a href="'; 
     87        if ($INPUT['show'] == 'reply') { 
     88            $_row .= 'javascript:quote(' . $this->id . ');'; 
     89            $js_post = '<script type="text/javascript">post_quote[' . $this->id . "] = '" . strtr(strtr($this->post->post, Array("\r\n"=>'\n')), Array("\n"=>'\n', "\r"=>'\n')) . "';</script>"; 
     90        } else { 
     91            $_row .= $F->link('reply') . 'id=' . $INPUT['id'] . '&amp;quote=' . $this->id; 
     92            $js_post = ''; 
     93        } 
     94        $_row .= '">' . $LANG['Quote'] . '</a> | ' . $_showip . '<a href="' . $F->link('edit') . 'id=' . $this->id . '">' . $LANG['Edit'] . '</a> | <a href="' . $F->link('delete') . 'id=' . $this->id . '">' . $LANG['Delete'] . '</a> ' . $_split . '</td>'; 
     95        $table->addRow(Array($_row)); 
    8796        // get member info 
    8897        if ($this->post->postedbymember == 0) { 
     
    92101        } 
    93102        // assemble parts of post 
    94         $_post = '<div class="post">' . $F->post($this->post->post) . '</div>'
     103        $_post = '<div class="post">' . $F->post($this->post->post) . '</div>' . $js_post
    95104        // attachment 
    96105        if ($this->post->attachment != '') { 
  • trunk/classes/pages/Reply.php

    r166 r169  
    9595                $h2 = $this->html->body->addChild('h2'); 
    9696                $this->html->body->addElement(new XMLElement('<h2>' . str_replace('%n%', $SETTINGS['postsperpage'], $LANG['Last_x_Posts']) . ' (<a href="' . $F->link('topic') . 'id=' . $INPUT['id'] . '" target="_blank">' . $LANG['View_All'] . '</a>)</h2>')); 
     97                $this->html->body->addElement(new XMLElement('<script type="text/javascript">post_quote = new Array();</script>')); 
    9798                // get posts from database (last $SETTINGS['postsperpage'] in reversed order) 
    9899                $q2 = $C->prepare('SELECT postid FROM ' . $SETTINGS['dbtableprefix'] . 'posts WHERE topic=:topic ORDER BY posttime DESC LIMIT 0, ' . $SETTINGS['postsperpage']); 
  • trunk/includes/js/js.js

    r63 r169  
    121121    document.images.avatarpic.src = val[val.selectedIndex].value; 
    122122} 
     123 
     124function quote(id) { 
     125    // the textarea 
     126    var obj = document.getElementsByName('postform')[0].post; 
     127    if (obj.selectionStart !== false) { 
     128        // Gecko / Opera 
     129        var start = obj.selectionStart; 
     130        var end   = obj.selectionEnd; 
     131        obj.value = obj.value.substr(0, start) + '[quote=' + id + ']' + post_quote[id] + '[/quote]' + obj.value.substr(end, obj.value.length); 
     132        obj.focus(); 
     133        var pos = start + post_quote[id].length; 
     134        obj.setSelectionRange(pos, pos); 
     135    } else if (document.selection !== false) { 
     136        // Internet Exploder (*choke*) 
     137        obj.focus(); 
     138        document.selection.createRange().text = '[quote=' + id + ']' + post_quote[id] + '[/quote]'; 
     139    } else { 
     140        // other browsers 
     141        obj.value += '[quote=' + id + ']' + post_quote[id] + '[/quote]'; 
     142        obj.focus(); 
     143    } 
     144}