/** * Returns an array about the definitions. All the information a renderer needs. * @return array */ public static function get_definition_summaries() { $instance = cache_config::instance(); $definitions = $instance->get_definitions(); $storenames = array(); foreach ($instance->get_all_stores() as $key => $store) { if (!empty($store['default'])) { $storenames[$key] = new lang_string('store_' . $key, 'cache'); } } $modemappings = array(); foreach ($instance->get_mode_mappings() as $mapping) { $mode = $mapping['mode']; if (!array_key_exists($mode, $modemappings)) { $modemappings[$mode] = array(); } if (array_key_exists($mapping['store'], $storenames)) { $modemappings[$mode][] = $storenames[$mapping['store']]; } else { $modemappings[$mode][] = $mapping['store']; } } $definitionmappings = array(); foreach ($instance->get_definition_mappings() as $mapping) { $definition = $mapping['definition']; if (!array_key_exists($definition, $definitionmappings)) { $definitionmappings[$definition] = array(); } if (array_key_exists($mapping['store'], $storenames)) { $definitionmappings[$definition][] = $storenames[$mapping['store']]; } else { $definitionmappings[$definition][] = $mapping['store']; } } $return = array(); foreach ($definitions as $id => $definition) { $mappings = array(); if (array_key_exists($id, $definitionmappings)) { $mappings = $definitionmappings[$id]; } else { if (empty($definition['mappingsonly'])) { $mappings = $modemappings[$definition['mode']]; } } $return[$id] = array('id' => $id, 'name' => cache_helper::get_definition_name($definition), 'mode' => $definition['mode'], 'component' => $definition['component'], 'area' => $definition['area'], 'mappings' => $mappings, 'sharingoptions' => self::get_definition_sharing_options($definition['sharingoptions'], false), 'selectedsharingoption' => self::get_definition_sharing_options($definition['selectedsharingoption'], true), 'userinputsharingkey' => $definition['userinputsharingkey']); } return $return; }