openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

TextElement.class.php (1110B)


      1 <?php
      2 
      3 namespace wikiparser\model;
      4 
      5 use wikiparser\model\AbstractElement;
      6 
      7 /**
      8  * @author $Author$
      9  * @version $Revision$
     10  * @package openrat.text
     11  */
     12 class TextElement extends AbstractElement
     13 {
     14 	var $text = '';
     15 
     16 	function __construct($t = '')
     17 	{
     18 		$this->text = $t;
     19 
     20 		$this->parseStyleClass();
     21 		$this->parseTitleText();
     22 	}
     23 
     24 
     25 	function parseStyleClass()
     26 	{
     27 		$char1 = substr($this->text, 0, 1);
     28 		if ($char1 == "(") {
     29 			$pos2 = strpos($this->text, ")", 2);
     30 			if ($pos2 !== false) {
     31 				$this->style = substr($this->text, 1, $pos2 - 1);
     32 				$this->text = substr($this->text, $pos2 + 1);
     33 
     34 				// Wenn kein Doppelpunkt in den Styleangaben vorkommt, dann
     35 				// handelt es sich um einen Klassennamen.				
     36 				if (strpos($this->style, ':') === false) {
     37 					$this->class = $this->style;
     38 					$this->style = '';
     39 				}
     40 			}
     41 		}
     42 	}
     43 
     44 
     45 	function parseTitleText()
     46 	{
     47 		$char1 = substr($this->text, 0, 1);
     48 		if ($char1 == "'") {
     49 			$pos2 = strpos($this->text, "'", 2);
     50 			if ($pos2 !== false) {
     51 				$this->title = substr($this->text, 1, $pos2 - 1);
     52 				$this->text = substr($this->text, $pos2 + 1);
     53 			}
     54 		}
     55 	}
     56 
     57 
     58 }
     59 
     60 ?>