00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 class TextPlaceholderBase implements ITextPlaceholder {
00014 protected $cmd = '';
00015
00016 public function __constructor($cmd) {
00017 $this->cmd = $cmd;
00018 }
00019
00020
00021
00022
00023
00024
00025
00026 public function apply($text) {
00027 $ret = $text;
00028 $matches = array();
00029 String::preg_match_all($this->build_regex(), $ret, $matches, PREG_SET_ORDER);
00030 foreach($matches as $match) {
00031 $params = explode(':', $match[1]);
00032 $replace = $this->do_apply($params);
00033 if ($replace !== false) {
00034 $ret = str_replace($match[0], $replace, $ret);
00035 }
00036 }
00037 return $ret;
00038 }
00039
00040
00041
00042
00043
00044
00045 protected function build_regex() {
00046 $cmd = preg_quote($this->cmd);
00047 return "@{{$cmd}:(.*?)}@i";
00048 }
00049
00050
00051
00052
00053
00054
00055
00056 protected function do_apply($params) {
00057 return false;
00058 }
00059 }