Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
FilterProcessing.js
001 /**
002 * Execute all the attribute preprocessors of given tag
003 *
004 * @private
005 *
006 * @param {!Tag} tag Source tag
007 * @param {!Object} tagConfig Tag's config
008 */
009 function executeAttributePreprocessors(tag, tagConfig)
010 {
011 if (typeof tagConfig.attributePreprocessors === 'undefined')
012 {
013 return;
014 }
015
016 tagConfig.attributePreprocessors.forEach(function(ap)
017 {
018 var attrName = ap[0], regexp = ap[1], map = ap[2];
019 if (tag.hasAttribute(attrName))
020 {
021 executeAttributePreprocessor(tag, attrName, regexp, map);
022 }
023 });
024 }
025
026 /**
027 * Filter the attributes of given tag
028 *
029 * @private
030 *
031 * @param {!Tag} tag Tag being checked
032 * @param {!Object} tagConfig Tag's config
033 * @param {!Object} registeredVars Unused
034 * @param {!Logger} logger This parser's Logger instance
035 */
036 function filterAttributes(tag, tagConfig, registeredVars, logger)
037 {
038 var attributes = {}, attrName;
039 for (attrName in tagConfig.attributes)
040 {
041 var attrConfig = tagConfig.attributes[attrName],
042 attrValue = false;
043 if (tag.hasAttribute(attrName))
044 {
045 attrValue = executeAttributeFilterChain(attrConfig.filterChain, attrName, tag.getAttribute(attrName));
046 }
047
048 if (attrValue !== false)
049 {
050 attributes[attrName] = attrValue;
051 }
052 else if (HINT.attributeDefaultValue && typeof attrConfig.defaultValue !== 'undefined')
053 {
054 attributes[attrName] = attrConfig.defaultValue;
055 }
056 else if (attrConfig.required)
057 {
058 tag.invalidate();
059 }
060 }
061 tag.setAttributes(attributes);
062 }
063
064 /**
065 * Execute a tag's filterChain
066 *
067 * @private
068 *
069 * @param {!Tag} tag Tag to filter
070 */
071 function filterTag(tag)
072 {
073 var tagName = tag.getName(),
074 tagConfig = tagsConfig[tagName];
075
076 // Record the tag being processed into the logger it can be added to the context of
077 // messages logged during the execution
078 logger.setTag(tag);
079
080 for (var i = 0; i < tagConfig.filterChain.length; ++i)
081 {
082 if (tag.isInvalid())
083 {
084 break;
085 }
086 tagConfig.filterChain[i](tag, tagConfig);
087 }
088
089 // Remove the tag from the logger
090 logger.unsetTag();
091 }
092
093 /**
094 * Execute an attribute's filterChain
095 *
096 * @param {!Array} filterChain Attribute's filterChain
097 * @param {string} attrName Attribute's name
098 * @param {*} attrValue Original value
099 * @return {*} Filtered value
100 */
101 function executeAttributeFilterChain(filterChain, attrName, attrValue)
102 {
103 logger.setAttribute(attrName);
104 for (var i = 0; i < filterChain.length; ++i)
105 {
106 // NOTE: attrValue is intentionally set as the first argument to facilitate inlining
107 attrValue = filterChain[i](attrValue, attrName);
108 if (attrValue === false)
109 {
110 break;
111 }
112 }
113 logger.unsetAttribute();
114
115 return attrValue;
116 }
117
118 /**
119 * Execute an attribute preprocessor
120 *
121 * @param {!Tag} tag
122 * @param {string} attrName
123 * @param {!RegExp} regexp
124 * @param {!Array<string>} map
125 */
126 function executeAttributePreprocessor(tag, attrName, regexp, map)
127 {
128 var attrValue = tag.getAttribute(attrName),
129 captures = getNamedCaptures(attrValue, regexp, map),
130 k;
131 for (k in captures)
132 {
133 // Attribute preprocessors cannot overwrite other attributes but they can
134 // overwrite themselves
135 if (k === attrName || !tag.hasAttribute(k))
136 {
137 tag.setAttribute(k, captures[k]);
138 }
139 }
140 }
141
142 /**
143 * Execute a regexp and return the values of the mapped captures
144 *
145 * @param {string} attrValue
146 * @param {!RegExp} regexp
147 * @param {!Array<string>} map
148 * @return {!Object<string,string>}
149 */
150 function getNamedCaptures(attrValue, regexp, map)
151 {
152 var m = regexp.exec(attrValue);
153 if (!m)
154 {
155 return [];
156 }
157
158 var values = {};
159 map.forEach(function(k, i)
160 {
161 if (typeof m[i] === 'string' && m[i] !== '')
162 {
163 values[k] = m[i];
164 }
165 });
166
167 return values;
168 }