[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package s9e\TextFormatter 5 * @copyright Copyright (c) 2010-2022 The s9e authors 6 * @license http://www.opensource.org/licenses/mit-license.php The MIT License 7 */ 8 namespace s9e\TextFormatter\Configurator\Traits; 9 10 trait TemplateSafeness 11 { 12 /** 13 * @var array Contexts in which this object is considered safe to be used 14 */ 15 protected $markedSafe = []; 16 17 /** 18 * Return whether this object is safe to be used in given context 19 * 20 * @param string $context Either 'AsURL', 'InCSS' or 'InJS' 21 * @return bool 22 */ 23 protected function isSafe($context) 24 { 25 // Test whether this attribute was marked as safe in given context 26 return !empty($this->markedSafe[$context]); 27 } 28 29 /** 30 * Return whether this object is safe to be used as a URL 31 * 32 * @return bool 33 */ 34 public function isSafeAsURL() 35 { 36 return $this->isSafe('AsURL'); 37 } 38 39 /** 40 * Return whether this object is safe to be used in CSS 41 * 42 * @return bool 43 */ 44 public function isSafeInCSS() 45 { 46 return $this->isSafe('InCSS'); 47 } 48 49 /** 50 * Return whether this object is safe to be used in JavaScript 51 * 52 * @return bool 53 */ 54 public function isSafeInJS() 55 { 56 return $this->isSafe('InJS'); 57 } 58 59 /** 60 * Return whether this object is safe to be used as a URL 61 * 62 * @return self 63 */ 64 public function markAsSafeAsURL() 65 { 66 $this->markedSafe['AsURL'] = true; 67 68 return $this; 69 } 70 71 /** 72 * Return whether this object is safe to be used in CSS 73 * 74 * @return self 75 */ 76 public function markAsSafeInCSS() 77 { 78 $this->markedSafe['InCSS'] = true; 79 80 return $this; 81 } 82 83 /** 84 * Return whether this object is safe to be used in JavaScript 85 * 86 * @return self 87 */ 88 public function markAsSafeInJS() 89 { 90 $this->markedSafe['InJS'] = true; 91 92 return $this; 93 } 94 95 /** 96 * Reset the "marked safe" statuses 97 * 98 * @return self 99 */ 100 public function resetSafeness() 101 { 102 $this->markedSafe = []; 103 104 return $this; 105 } 106 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |