Results 1 to 6 of 6

Thread: formatTextPar

  1. #1
    Join Date
    Jun 2007
    Location
    DeKalb, IL
    Posts
    45
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default formatTextPar

    I have some code that the Web Developer put in place before I was here. but I haven't been able to figure out what this one code is. It's formatTextPar. I've googled it but nothing comes up.

    Here's the code: $relBody = formatTextPar($_POST['relBody']);

    So I'm assuming that it formats the text differently. I'm having problems right now with the dashes not formatting correctly. I don't know how to fix that problem.

  2. #2
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    That'll be a custom function that the developer created. Try looking for it in one of the included files, if there are any - such as "functions.inc.php" or something similar.

    Without being able to see what's going on inside the function I can't tell what's causing the problem.

  3. #3
    Join Date
    Jun 2007
    Location
    DeKalb, IL
    Posts
    45
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    YES! I found it! Thank you!! So here's the code associatd in the file. So from what I can gather, it looks like the formatTextChars code is in the formatTextPar but yet, it's not working any longer. Just for the Option + - dash anyway. Everything else looks to be fine.

    PHP Code:
    <?php
    function formatTextPar($inputString) {
        
    $inputString "<p>" str_replace("</p><p></p><p>","</p><p>",str_replace("\r\n","</p><p>",$inputString)) . "</p>";
        
    $inputString formatTextChars($inputString);
        return 
    $inputString;
    }
    function 
    formatTextLst($inputString) {
        
    $inputString "<ul><li>" str_replace("\r\n","</li><li>",$inputString) . "</li></ul>";
        
    $inputString formatTextChars($inputString);
        return 
    $inputString;
    }
    function 
    formatTextChars($inputString) {
        
    $inputString str_replace("&","&amp;",$inputString);
        
    $inputString str_replace("--","&mdash;",$inputString);
        
    $inputString str_replace("“","&quot;",$inputString);
        
    $inputString str_replace("”","&quot;",$inputString);
        
    $inputString str_replace("—","&mdash;",$inputString);
        
    $inputString str_replace("–","-",$inputString);
        
    $inputString str_replace("’","&apos;",$inputString);
        
    $inputString trim($inputString);
        return 
    $inputString;
    }
    ?>
    Last edited by lindsaycb; 02-02-2010 at 04:36 PM.

  4. #4
    Join Date
    Feb 2009
    Posts
    156
    Thanks
    0
    Thanked 4 Times in 3 Posts

    Default

    use it

  5. #5
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    Ok, what are you passing into the function?

    What does $_POST['relBody'] contain?

  6. #6
    Join Date
    Jun 2007
    Location
    DeKalb, IL
    Posts
    45
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    It just contains text that usually someone copies from Microsoft Word into the form. I messed with the code and it only doesn't work when it's using the Option - dash. You know how when you write 9 - 5 and then Word changes the dash into the longer dash? That's the one I'm talking about. A regular dash works fine.

    Since I can't figure out why it's not working (it actually turns the longer dash into this funky image http://www.kishwaukeecollege.edu/pre...cle.php?id=577) I'll have to tell the person to always make sure that the dashes are regular sized. But I know she won't like that one bit. So if you have a solution, I'll try anything!

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
  •