Jump to content

jpratt

Members
  • Posts

    144
  • Joined

  • Last visited

    Never

Everything posted by jpratt

  1. This throws an error: Warning: preg_replace() [function.preg-replace]: Unknown modifier 'j' in C:\Program Files\reporting\Program\www\localhost\trans\import.php on line 20
  2. Now I tried this to replace the content with a placeholder but removes the script tags all together without making placeholders: $content = preg_replace('#<script type="text/javascript">(.*?)</script>#s',"$1[*SCRIPT*]$2",$content); Any ideas?
  3. Thanks, got it working. Here is the code for getting the script content into a simple array: if(preg_match_all('#<script type="text/javascript">(.*?)</script>#s', $content, $matches)) { $scriptarr = array(); for ($row = 1; $row < 2; $row++) { foreach($matches[$row] as $field) { $scriptarr[] = $field; } } }
  4. Looking at it, I am going to do a replace on all the content between the script tags to create a second set of placeholders. But first I need to store the content from between the tags in an array. How do you get everything from between two tags and store in a variable? I looked over everything on php.net but most are replace or match. Is there a way of giving it and expression and have it return the content that matched it? I think this is my expression: '/<\script>(.*?)<\/script>/'
  5. OK. I have this in another thread, but this is so specific and off the topic of the other thread I need to concentrate on this. I am placing content into an html structure. I have values in my database that have html stored. I am removing the content from the html string and placing placeholders to be filled with new content in another language. The only problem I have is in the content there is a script tag that is getting removed. This in turn creates an extra placeholder so the text ends up being placed in the wrong areas. The question is how do I exclude this one placeholder from being created? Here is the code for both creating the placeholder and placing content back into the string. // $content represents original content html string $content = $row['content']; // remove content and put in placeholders where the translated text is to go $content = preg_replace('~(>)(?!\s*<).*?(<|$)~s',"$1[*CONTENT*]$2",$content); //open file from translator and place numbered lines in array $file = "translated.rtf"; $fh = fopen($file, 'r'); $data = fread($fh, filesize($file)); fclose($fh); $array = explode("\n", $data); //title is in separate field, place first translated line in projects in the title field $x = 1; foreach($array as $a) { if($x == 1) { $title = substr($a, 4); } else { $a = substr($a, 4); $content = preg_replace('~\[\*CONTENT\*\]~',$a,$content,1); } $x++; } echo $content
  6. Any idea how I would handle the content in the script tags?
  7. That is awesome thanks. I am still learning about reg expressions, but you have helped out tons. Also last problem is the content between the script tags. No idea on how to ignore this when creating the content 'fields'.
  8. This works out great. There is only a few problems I am having. It is placing content area between 2 tags with no data. So if I have this: <img src='blah' align='right'><p>some text</p> It places a content area between the img tag and the opening p tag as well as where the true content is. Also Exporting was not a problem, because I could look at each chunk of text coming in, but I have <script> tags with content between them as well. Other than this I think we might have it about there.
  9. yep, thats what I want. The middle of the process is outputting a file for the translator, then getting it back and importing to get the result you described.
  10. OK here goes. The first step you helped with was getting the text out of the html. This I wrote to a file orginized like this: 1.1 First chunk of text from first page. blah blah blah 1.2 second chunk of text. blah blah blah 1.3 third chunk of text 2.1 First chunk of text from second page. blah blah blah 2.2 second chunk of text. blah blah blah 2.3 third chunk of text 2.4 could have additional text ... This file is given to the translator, and given back in the same format just another language. Now I have to stick the new language back into the html tags in the right place. I am not over writing text, just creating a new entry in the database with a different language key. So I was thinking of reading the english html string again and walking through the string placing the html and text in an array. if the element of the array is html it ignores it, but if it is text it replaces the english version in the array. Then when it is done, it writes the array to the database in a new row with the new language id.
  11. Sorry, after looking through things, your idea works great. Now I have to reverse engineer the thing. So the text has been taken out and changed to a different language. Now I have to stick it back in based on the english html. I was thinking of looping through the field sticking it into a 2 dimentional array. The first element would contain tags or text, the second would contain a 1 or 0 depending on if it was html or text. If it is text it is replaced with the new language for that section. We got the text to be separate from the html, but how do I get them all into an array together without just removing the html? Thanks.
  12. I dont want to go off new lines because some tags my be in the middle of the line such as b tags. I just need an expression to strip out all html tags and place the chunks of text between the tags in an array in the order they were encountered.
  13. I have tried various reg expressions trying to remove the html using preg_match_all with little or no success. Anyone know of a regular expression that will remove this?
  14. So my question is. How would I implement something like preg_match_all or fgetss to get me desired results. The first tag it hits might be an img tag an a tag a p tag or something else. How would I loop through the string to place the chunks of text in an array?
  15. I looked into the DOMDocument model and its isn't very dynamic. Some of my text will be in p tags, some in span tags and so forth. I just need something like the striptags function but instead of just removing all the tags and return all the text together, it needs to return an array of the chunks of text found between the tags in order they were encountered.
  16. Ive looked into them, but all my pages I want to loop thru have a different format. So <p> tags will be in different places and <img> tags will also be in different places. There may also be div, b, em, etc tags mixed it. I wouldnt think reg expressions would be able to accommodate that. I thought about using something like strip tags but it just lops everything off and returns the entire thing as a string.
  17. I have html like this: <h3>title here</h3> <div style='width:515px;'> <img src='images/images1.jpg' id='imgr'> <p>first paragraph of text here</p> <p>another one here</p> <img src='images/image2.jpg' id='imgl'>... Alot of my pages are formated differently. So what I want to be able to do is remove all html tags, but I want to but the blocks of text in an array and save the different chunks in different fields in the database. the this array would be filed with these different blocks: first element: title here 2nd element: first paragraph of text here 3rd element: another one here Any ideas how I could do this?
  18. $newdir = str_replace (" ", "", $_POST['business']);
  19. if you want to run the code without a page refresh you will probably have to use javascript to update the elements. Or are you fin with a refresh of the page?
  20. Thats cause you have two buttons created to submit the form. What is the other buttons purpose?
  21. Both these are easy to implement. One easier than the other: http://www.tonymarston.net/php-mysql/pagination.html
  22. Also the other problem is that you have to use the name of the element: <input type="file" name="image_file" id="image_file" /> so you reference it as: $_FILES["image_file"]["name"] it does matter otherwise its looking for a temp uploaded file with a name of file not image_file.
  23. The .load() way of ajax request in jquery is the very simple way of ajax requests, as such does not come with very many options. The most flexible out of the jquery ajax requests is the .ajax method of doing this. This gives you more options to work with such as beforeSend option and a complete option. This helps control when the request is fired, what to do before and after its complete. Go here to see how it works and check out the options to see if you might want to go this route. http://docs.jquery.com/Ajax/jQuery.ajax
  24. If the php setting will not work then you might have to change the .htaccess time limit for you script to run. I am not sure about your python script, you would probably have to go to a different board for that.
  25. This is a server setting. This overrides anything the htaccess file sets it to. If you do not set your script limit time higher your script that takes ~3minutes will never finish because the default is set to something like 30 seconds. try putting this before your call to the python script: ini_set('set_time_limit', 300); Place this at the top of the php file and it will temporarily set the limit for this file only for 5 minutes.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.