1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10:
11:
12:
13:
14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24:
25: class TexyConfigurator
26: {
27: public static $safeTags = array(
28: 'a' => array('href', 'title'),
29: 'acronym' => array('title'),
30: 'b' => array(),
31: 'br' => array(),
32: 'cite' => array(),
33: 'code' => array(),
34: 'em' => array(),
35: 'i' => array(),
36: 'strong' => array(),
37: 'sub' => array(),
38: 'sup' => array(),
39: 'q' => array(),
40: 'small' => array(),
41: );
42:
43:
44:
45: 46: 47:
48: final public function __construct()
49: {
50: throw new LogicException("Cannot instantiate static class " . get_class($this));
51: }
52:
53:
54:
55: 56: 57: 58: 59: 60:
61: public static function safeMode(Texy $texy)
62: {
63: $texy->allowedClasses = Texy::NONE; 64: $texy->allowedStyles = Texy::NONE; 65: $texy->allowedTags = self::$safeTags; 66: $texy->urlSchemeFilters[Texy::FILTER_ANCHOR] = '#https?:|ftp:|mailto:#A';
67: $texy->urlSchemeFilters[Texy::FILTER_IMAGE] = '#https?:#A';
68: $texy->allowed['image'] = FALSE; 69: $texy->allowed['link/definition'] = FALSE; 70: $texy->allowed['html/comment'] = FALSE; 71: $texy->linkModule->forceNoFollow = TRUE; 72: }
73:
74:
75:
76: 77: 78: 79: 80: 81:
82: public static function disableLinks(Texy $texy)
83: {
84: $texy->allowed['link/reference'] = FALSE;
85: $texy->allowed['link/email'] = FALSE;
86: $texy->allowed['link/url'] = FALSE;
87: $texy->allowed['link/definition'] = FALSE;
88: $texy->phraseModule->linksAllowed = FALSE;
89:
90: if (is_array($texy->allowedTags)) {
91: unset($texy->allowedTags['a']);
92: } 93: }
94:
95:
96:
97: 98: 99: 100: 101: 102:
103: public static function disableImages(Texy $texy)
104: {
105: $texy->allowed['image'] = FALSE;
106: $texy->allowed['figure'] = FALSE;
107: $texy->allowed['image/definition'] = FALSE;
108:
109: if (is_array($texy->allowedTags)) {
110: unset($texy->allowedTags['img'], $texy->allowedTags['object'], $texy->allowedTags['embed'], $texy->allowedTags['applet']);
111: } 112: }
113:
114: }
115: