Öffentliche Methoden | |
| maxLaenge ($laenge, $text) | |
| maxLength ($text, $laenge=20, $append='...', $where=STR_PAD_RIGHT) | |
| bbCode2Wiki ($inhalt) | |
| Html2Wiki ($inhalt) | |
| encodeHtml ($inhalt) | |
| replaceHtmlChars ($text) | |
| encodeHtmlSpecialChars ($inhalt) | |
| diff ($from_text, $to_text) | |
| entferneVonBis ($text, $von, $bis) | |
Definiert in Zeile 62 der Datei Text.class.php.
| Text::bbCode2Wiki | ( | $ | inhalt | ) |
Umwandeln von BB-Code in Wiki-Textauszeichnungen
| text | zu bearbeitender Text |
Definiert in Zeile 106 der Datei Text.class.php.
Wird benutzt von Value::generate().
00107 { 00108 $inhalt = eregi_replace('\[b\]([^\[]*)\[\/b\]' , '*\\1*' ,$inhalt); 00109 $inhalt = eregi_replace('\[i\]([^\[]*)\[\/i\]' , '_\\1_' ,$inhalt); 00110 $inhalt = eregi_replace('\[code\]([^\[]*)\[\/code\]' , '=\\1=' ,$inhalt); 00111 00112 $inhalt = eregi_replace('\[url\]([^\[]*)[\/url\]' ,'"\\1"->"\\1"' ,$inhalt); 00113 $inhalt = eregi_replace('\[url=([^\[]*)\]([^\[]*)\[\/url\]','"\\2"->"\\1"' ,$inhalt); 00114 00115 return $inhalt; 00116 }
| Text::diff | ( | $ | from_text, | |
| $ | to_text | |||
| ) |
Vergleicht 2 Text-Arrays und ermittelt eine Darstellung der Unterschiede
Definiert in Zeile 189 der Datei Text.class.php.
00190 { 00191 // Zaehler pro Textarray 00192 $pos_from = -1; 00193 $pos_to = -1; 00194 00195 // Ergebnis-Arrays 00196 $from_out = array(); 00197 $to_out = array(); 00198 00199 while( true ) 00200 { 00201 $pos_from++; 00202 $pos_to ++; 00203 00204 if ( !isset($from_text[$pos_from]) && 00205 !isset($to_text [$pos_to ]) ) 00206 { 00207 // Text in ist 'neu' und 'alt' zuende. Ende der Schleife. 00208 break; 00209 } 00210 elseif 00211 ( isset($from_text[$pos_from]) && 00212 !isset($to_text [$pos_to]) ) 00213 { 00214 // Text in 'neu' ist zuende, die Restzeilen von 'alt' werden ausgegeben 00215 while( isset($from_text[$pos_from]) ) 00216 { 00217 $from_out[] = array('text'=>$from_text[$pos_from],'line'=>$pos_from+1,'type'=>'old'); 00218 $to_out [] = array(); 00219 $pos_from++; 00220 } 00221 break; 00222 } 00223 elseif 00224 ( !isset($from_text[$pos_from]) && 00225 isset($to_text [$pos_to]) ) 00226 { 00227 // Umgekehrter Fall: Text in 'alt' ist zuende, Restzeilen aus 'neu' werden ausgegeben 00228 while( isset($to_text[$pos_to]) ) 00229 { 00230 $from_out[] = array(); 00231 $to_out [] = array('text'=>$to_text[$pos_to],'line'=>$pos_to+1,'type'=>'new'); 00232 $pos_to++; 00233 } 00234 break; 00235 } 00236 elseif 00237 ( rtrim($from_text[$pos_from]) != rtrim($to_text[$pos_to]) ) 00238 { 00239 // Zeilen sind vorhanden, aber ungleich 00240 // Wir suchen jetzt die naechsten beiden Zeilen, die gleich sind. 00241 $max_entf = min(count($from_text)-$pos_from-1,count($to_text)-$pos_to-1); 00242 00243 #echo "suche start, max_entf=$max_entf, pos_from=$pos_from, pos_to=$pos_to<br/>"; 00244 00245 for ( $a=0; $a<=$max_entf; $a++ ) 00246 { 00247 #echo "a ist $a<br/>"; 00248 for ( $b=0; $b<=$max_entf; $b++ ) 00249 { 00250 #echo "b ist $b<br/>"; 00251 if ( trim($from_text[$pos_from+$b]) != '' && 00252 $from_text[$pos_from+$b] == $to_text[$pos_to+$a] ) 00253 { 00254 $pos_gef_from = $pos_from+$b; 00255 $pos_gef_to = $pos_to +$a; 00256 break; 00257 } 00258 00259 if ( trim($from_text[$pos_from+$a]) != '' && 00260 $from_text[$pos_from+$a] == $to_text[$pos_to+$b] ) 00261 { 00262 $pos_gef_from = $pos_from+$a; 00263 $pos_gef_to = $pos_to +$b; 00264 break; 00265 } 00266 } 00267 00268 if ( $b <=$max_entf) 00269 { 00270 break; 00271 } 00272 } 00273 00274 if ( $a<=$max_entf ) 00275 { 00276 // Gleiche Zeile gefunden 00277 #echo "gefunden, pos_gef_from=$pos_gef_from, pos_gef_to=$pos_gef_to<br/>"; 00278 00279 if ( $pos_gef_from - $pos_from == 0 ) 00280 $type = 'new'; 00281 elseif 00282 ( $pos_gef_to - $pos_to == 0 ) 00283 $type = 'old'; 00284 else 00285 $type = 'notequal'; 00286 00287 while( $pos_gef_from - $pos_from > 0 && 00288 $pos_gef_to - $pos_to > 0 ) 00289 { 00290 $from_out[] = array('text'=>$from_text[$pos_from],'line'=>$pos_from+1,'type'=>$type); 00291 $to_out [] = array('text'=>$to_text [$pos_to ],'line'=>$pos_to+1 ,'type'=>$type); 00292 00293 $pos_from++; 00294 $pos_to++; 00295 } 00296 00297 while( $pos_gef_from - $pos_from > 0 ) 00298 { 00299 $from_out[] = array('text'=>$from_text[$pos_from],'line'=>$pos_from+1,'type'=>$type); 00300 $to_out [] = array(); 00301 $pos_from++; 00302 } 00303 00304 while( $pos_gef_to - $pos_to > 0 ) 00305 { 00306 $from_out[] = array(); 00307 $to_out [] = array('text'=>$to_text [$pos_to ],'line'=>$pos_to+1 ,'type'=>$type); 00308 $pos_to++; 00309 } 00310 $pos_from--; 00311 $pos_to--; 00312 } 00313 else 00314 { 00315 // Keine gleichen Zeilen gefunden 00316 #echo "nicht gefunden, i=$i, j=$j, pos_from war $pos_from, pos_to war $pos_to<br/>"; 00317 00318 while( true ) 00319 { 00320 if ( !isset($from_text[$pos_from]) && 00321 !isset($to_text [$pos_to ]) ) 00322 { 00323 break; 00324 } 00325 elseif 00326 ( isset($from_text[$pos_from]) && 00327 !isset($to_text [$pos_to ]) ) 00328 { 00329 $from_out[] = array('text'=>$from_text[$pos_from],'line'=>$pos_from+1,'type'=>'notequal'); 00330 $to_out [] = array(); 00331 } 00332 elseif 00333 ( !isset($from_text[$pos_from]) && 00334 isset($to_text [$pos_to ]) ) 00335 { 00336 $from_out[] = array(); 00337 $to_out [] = array('text'=>$to_text [$pos_to ],'line'=>$pos_to+1 ,'type'=>'notequal'); 00338 } 00339 else 00340 { 00341 $from_out[] = array('text'=>$from_text[$pos_from],'line'=>$pos_from+1,'type'=>'notequal'); 00342 $to_out [] = array('text'=>$to_text [$pos_to ],'line'=>$pos_to+1 ,'type'=>'notequal'); 00343 } 00344 $pos_from++; 00345 $pos_to++; 00346 } 00347 } 00348 } 00349 else 00350 { 00351 // Zeilen sind gleich 00352 $from_out[] = array('text'=>$from_text[$pos_from],'line'=>$pos_from+1,'type'=>'equal'); 00353 $to_out [] = array('text'=>$to_text [$pos_to ],'line'=>$pos_to+1 ,'type'=>'equal'); 00354 } 00355 } 00356 00357 return( array($from_out,$to_out) ); 00358 }
| Text::encodeHtml | ( | $ | inhalt | ) |
HTML-Entitaeten fuer HTML-Tags verwenden
| String | Text, in dem HTML-Tags umgewandelt werden sollen |
Definiert in Zeile 142 der Datei Text.class.php.
Wird benutzt von Value::generate().
00143 { 00144 $inhalt = str_replace('&','&',$inhalt); 00145 $inhalt = str_replace('<','<' ,$inhalt); 00146 $inhalt = str_replace('>','>' ,$inhalt); 00147 00148 return $inhalt; 00149 }
| Text::encodeHtmlSpecialChars | ( | $ | inhalt | ) |
HTML-Entitaeten fuer HTML-Tags verwenden
| String | Text, in dem HTML-Tags umgewandelt werden sollen |
Definiert in Zeile 178 der Datei Text.class.php.
Benutzt replaceHtmlChars().
Wird benutzt von Value::generate().
00179 { 00180 return Text::replaceHtmlChars( $inhalt ); 00181 }
| Text::entferneVonBis | ( | $ | text, | |
| $ | von, | |||
| $ | bis | |||
| ) |
Definiert in Zeile 361 der Datei Text.class.php.
Wird benutzt von Page::generate().
00362 { 00363 $beg = strpos($text,$von); 00364 $end = strpos($text,$bis); 00365 if ( $beg!==false && $end !==false ) 00366 $text = substr($src,0,$beg).substr($src,$end); 00367 return $text; 00368 }
| Text::Html2Wiki | ( | $ | inhalt | ) |
Umwandeln von einfachen HTML-Befehlen in Wiki-Textauszeichnungen
| text | zu bearbeitender Text |
Definiert in Zeile 126 der Datei Text.class.php.
00127 { 00128 $inhalt = eregi_replace('<b(.*)>(.*)</b>','*\\2*' ,$inhalt); 00129 $inhalt = eregi_replace('<i(.*)>(.*)</i>','_\\2_' ,$inhalt); 00130 $inhalt = eregi_replace('<a(.*)href="(.*)">(.*)</a>','"\\3"->"\\2"' ,$inhalt); 00131 00132 return $inhalt; 00133 }
| Text::maxLaenge | ( | $ | laenge, | |
| $ | text | |||
| ) |
Alias fuer Methode maxLength()
Definiert in Zeile 69 der Datei Text.class.php.
Benutzt maxLength().
Wird benutzt von PageelementAction::archive(), PageAction::el(), ProjectTree::folder(), ProjectTree::link(), FolderAction::order(), FolderAction::select(), FolderAction::show(), ProjectTree::template() und ProjectTree::templates().
00070 { 00071 return Text::maxLength($text,$laenge); 00072 }
| Text::maxLength | ( | $ | text, | |
| $ | laenge = 20, |
|||
| $ | append = '...', |
|||
| $ | where = STR_PAD_RIGHT | |||
| ) |
Einen Text auf eine bestimmte Laenge begrenzen.
Ist der Text zu lang, so wird abgeschnitten und eine Zeichenkette angehaengt.
| String | Text, der zu begrenzen ist | |
| Integer | maximale Laenge des Textes (optional) | |
| Text,der | an gekuerzten Text angehangen wird (optional) |
Definiert in Zeile 85 der Datei Text.class.php.
Wird benutzt von maxLaenge(), AdministrationTree::prefs_cms() und IndexAction::showlogin().
00086 { 00087 if ( strlen($text) > $laenge ) 00088 { 00089 if ( $where == STR_PAD_RIGHT ) 00090 $text = substr($text,0,$laenge).$append; 00091 elseif ( $where == STR_PAD_BOTH ) 00092 $text = substr($text,0,$laenge/2).$append.substr($text,strlen($text)-($laenge/2)); 00093 } 00094 00095 return $text; 00096 }
| Text::replaceHtmlChars | ( | $ | text | ) |
Ersetzt Sonderzeichen durch HTML-�quivalente.
Z.B. Ersetzt "(c)" durch "©".
Definiert in Zeile 157 der Datei Text.class.php.
Benutzt $conf.
Wird benutzt von encodeHtmlSpecialChars(), XhtmlRenderer::renderElement(), LatexRenderer::renderElement(), HtmlRenderer::renderElement() und DocBookRenderer::renderElement().
00158 { 00159 global $conf; 00160 00161 foreach( explode(' ',$conf['editor']['html']['replace']) as $repl ) 00162 { 00163 list( $ersetze, $mit ) = explode(':',$repl.':'); 00164 $text = str_replace($ersetze, $mit, $text); 00165 } 00166 00167 return $text; 00168 }
1.5.8