TextContent.php
| 1 | <?php |
| 2 | if (!defined('ABSPATH')) exit; |
| 3 | |
| 4 | class IRP_TextContent extends IRP_HTMLTag { |
| 5 | var $body; |
| 6 | public function __construct() { |
| 7 | parent::__construct(); |
| 8 | $this->body=''; |
| 9 | } |
| 10 | |
| 11 | public function hasTagContent() { |
| 12 | return FALSE; |
| 13 | } |
| 14 | public function append($text) { |
| 15 | $this->body.=$text; |
| 16 | } |
| 17 | public function write(IRP_HTMLContext $context) { |
| 18 | global $irp; |
| 19 | if($context->isUncuttable() || trim($this->body)=='') { |
| 20 | //we dont want to insert nothing inside iframe or table |
| 21 | $context->write($this->body); |
| 22 | $context->incCounters($this->body); |
| 23 | if(defined('IRP_DEBUG_BLOCK') && IRP_DEBUG_BLOCK) { |
| 24 | $context->write(sprintf('<sup style="color:red;"> {%s/%s,%s}</sup>' |
| 25 | , $context->currentWords, $context->wordsThreshold, $context->lastBoxWords)); |
| 26 | } |
| 27 | } else { |
| 28 | //here is all text so we have to decide when cut it |
| 29 | $text=explode("\n", $this->body); |
| 30 | for($i=0; $i<count($text); $i++) { |
| 31 | $line=$text[$i]; |
| 32 | if(trim($line)=='') { |
| 33 | $context->writeRelatedBoxIfNeeded(); |
| 34 | } |
| 35 | |
| 36 | if($i<(count($text)-1)) { |
| 37 | $line.="\n"; |
| 38 | } |
| 39 | $context->write($line); |
| 40 | $context->incCounters($line); |
| 41 | if(trim($line)!='') { |
| 42 | if (defined('IRP_DEBUG_BLOCK') && IRP_DEBUG_BLOCK) { |
| 43 | $context->write(sprintf('<sup style="color:#008000"> {%s/%s,%s}</sup>' |
| 44 | , $context->currentWords, $context->wordsThreshold, $context->lastBoxWords)); |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | public function analyseText(IRP_HTMLContext $context) { |
| 51 | $context->incCounters($this->body); |
| 52 | } |
| 53 | } |
| 54 |