+// Prepares the filter array for usage
+function prepareFilterArray () {
+ // Abort here if array is absend (e.g. not cached)
+ if (!isset($GLOBALS['cache_array']['filter']['filter_name'])) {
+ // Abort silently
+ return false;
+ } // END - if
+
+ // Init dummy array
+ $filterArray = array(
+ 'chains' => array(),
+ 'loaded' => array(),
+ 'counter' => array()
+ );
+
+ // Found in cache so rewrite the array
+ foreach ($GLOBALS['cache_array']['filter']['filter_name'] as $idx => $filterName) {
+ // Get filter function
+ $filterFunction = $GLOBALS['cache_array']['filter']['filter_function'][$idx];
+
+ // Add the element with mapped index
+ $filterArray['counter'][$filterName][$filterFunction] = $GLOBALS['cache_array']['filter']['filter_counter'][$idx];
+ $filterArray['loaded'][$filterName][$filterFunction] = true;
+ $filterArray['chains'][$filterName][$filterFunction] = $GLOBALS['cache_array']['filter']['filter_active'][$idx];
+ } // END - foreach
+
+ // Remove the cache
+ $GLOBALS['cache_array']['filter'] = $filterArray;
+}
+
+// Loads filter for given extension if present. This function will silently
+// ignore absent filter files.
+function loadExtensionFilters ($ext_name) {
+ // Do we have cache entry?
+ if (!isset($GLOBALS[__FUNCTION__][$ext_name])) {
+ // Default is not found
+ $GLOBALS[__FUNCTION__][$ext_name] = false;
+
+ // Construct include file name
+ $incFileName = sprintf("inc/filter/%s_filter.php", $ext_name);
+
+ // Is the include file readable?
+ if (isIncludeReadable($incFileName)) {
+ // Load the include file
+ loadIncludeOnce($incFileName);
+
+ // Mark the file as loaded
+ $GLOBALS[__FUNCTION__][$ext_name] = true;
+ } elseif (isDebugModeEnabled()) {
+ // Log missing file
+ logDebugMessage(__FUNCTION__, __LINE__, 'Filter include file ' . $incFileName . ' for extension ' . $ext_name . ' is missing.');
+ }
+ } // END - if
+}
+