SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    India
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to do Gmail like "Show Quoted Text"?

    Hi all,

    I am scripting a mail client and I would like to implement GMAIL like "Show Quoted/Hide Quoted" options. What would be the best way to go about implementing it?

    1) Should I do a character by character matching?

    2) Or should I consider patterns like <BLOCKQUOTE> and make use of preg_replace?

    I tried one such pattern here. The pattern to be matched is

    PHP Code:
    $pattern="/<BLOCKQUOTE type=\"cite\">
    (.*?)
    <\/BLOCKQUOTE>/is"

    and I tried replacing it with

    PHP Code:
    $replace="<a href=\"\" onClick=\"\">
    Show Quoted Text</a>
    <div id="" style=\"display:none\">$$1</div>"

    But, I don't know how to number each matched pattern so that if there are more than 1 BlockQuotes, I would know which to show and which to hide.

    Can anyone help me here?

    Thanks in advance,
    Celia

  2. #2
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This should probably be handled client side with javascript toggling the visibility of whatever block element you wrap around the quoted text. Why would you want to make another trip back to the server for this functionality?
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    India
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah. You didn't get me. The show/hide is not the problem for me. The problem is how to determine the 'quoted text'. Once I determine what the quoted text is, I can easily put it in a div and do javascript toggling.

  4. #4
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, are you in control of the system generating the quoted text, or are you just trying to parse some elses data?
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  5. #5
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    India
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As I said, I am in control of the original text and am involved in a mailclient application. When I display the message, the 'original message' of the sender also gets displayed. This is quite ok as long as the message is small. Sometimes the thread becomes too long and hence I would want to do 'quoted text'.

    I would like to know how to implement this quoted text.

    1) Should I do a character by character matching since I have the original message stored in the database?

    2) Or should I use pattern matching since I find that some mail clients automatically wrap the 'original mail' text using BLOCKQUOTES.

    I am not sure whether I am understood.

  6. #6
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would suggest putting some kind of markers around the original text when you are creating the reply. Consider what happens here on this forum when you hit the "quote" button, the bb code [ quote ] tag is wrapped around the original content. You could also do this with an HTML <blockquote> tag, depending on what you are using to edit the content. This allows the user the benefit of you hide quoted text feature, but also allows them to edit down some of the quote for a shorter message to begin with. An exact text match would prevent the latter, and it would probably be very complex to "guess" using some kind of pattern matching.

    Hope that helps.
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •