BehaviourTag.php
| 1 | <?php |
| 2 | if (!defined('ABSPATH')) exit; |
| 3 | |
| 4 | class IRP_BehaviourTag extends IRP_HTMLTag { |
| 5 | |
| 6 | var $allowBoxBefore=FALSE; |
| 7 | var $allowBoxAfter=FALSE; |
| 8 | var $skipWordsCount=FALSE; |
| 9 | var $ensureUncuttable=FALSE; |
| 10 | var $ensureWithoutPreviousBox=FALSE; |
| 11 | var $ensureWithoutNextBox=FALSE; |
| 12 | |
| 13 | public function write(IRP_HTMLContext $context) { |
| 14 | $w=$context->skipWordsCount; |
| 15 | $context->skipWordsCount=$this->skipWordsCount; |
| 16 | |
| 17 | if($this->ensureWithoutPreviousBox) { |
| 18 | //if present remove the last related box |
| 19 | $args=array('last'=>TRUE); |
| 20 | $context->popRelatedBox($args); |
| 21 | } |
| 22 | if($this->allowBoxBefore) { |
| 23 | $context->writeRelatedBoxIfNeeded(); |
| 24 | } |
| 25 | |
| 26 | if($this->ensureUncuttable) { |
| 27 | $previous=$context->isUncuttable(); |
| 28 | $context->setUncuttable(TRUE); |
| 29 | } |
| 30 | parent::write($context); |
| 31 | if($this->ensureUncuttable) { |
| 32 | $context->setUncuttable($previous); |
| 33 | } |
| 34 | |
| 35 | if($this->allowBoxAfter) { |
| 36 | $context->writeRelatedBoxIfNeeded(); |
| 37 | } |
| 38 | if($this->ensureWithoutNextBox) { |
| 39 | $context->setWithoutNextBox(); |
| 40 | } |
| 41 | |
| 42 | $context->skipWordsCount=$w; |
| 43 | } |
| 44 | public function analyseText(IRP_HTMLContext $context) { |
| 45 | if($this->skipWordsCount) { |
| 46 | return; |
| 47 | } |
| 48 | |
| 49 | parent::analyseText($context); |
| 50 | } |
| 51 | } |
| 52 |