MDL-65492 cache admin: make the code easier to understand
This commit is contained in:
Vendored
+36
-30
@@ -40,11 +40,13 @@ class core_cache_renderer extends plugin_renderer_base {
|
||||
/**
|
||||
* Displays store summaries.
|
||||
*
|
||||
* @param array $stores
|
||||
* @param array $plugins
|
||||
* @param array $storeinstancesummaries information about each store instance,
|
||||
* as returned by cache_administration_helper::get_store_instance_summaries().
|
||||
* @param array $storepluginsummaries information about each store plugin as
|
||||
* returned by cache_administration_helper::get_store_plugin_summaries().
|
||||
* @return string HTML
|
||||
*/
|
||||
public function store_instance_summariers(array $stores, array $plugins) {
|
||||
public function store_instance_summariers(array $storeinstancesummaries, array $storepluginsummaries) {
|
||||
$table = new html_table();
|
||||
$table->head = array(
|
||||
get_string('storename', 'cache'),
|
||||
@@ -70,24 +72,24 @@ class core_cache_renderer extends plugin_renderer_base {
|
||||
|
||||
$defaultstoreactions = get_string('defaultstoreactions', 'cache');
|
||||
|
||||
foreach ($stores as $name => $store) {
|
||||
$actions = cache_administration_helper::get_store_instance_actions($name, $store);
|
||||
foreach ($storeinstancesummaries as $name => $storesummary) {
|
||||
$actions = cache_administration_helper::get_store_instance_actions($name, $storesummary);
|
||||
$modes = array();
|
||||
foreach ($store['modes'] as $mode => $enabled) {
|
||||
foreach ($storesummary['modes'] as $mode => $enabled) {
|
||||
if ($enabled) {
|
||||
$modes[] = get_string('mode_'.$mode, 'cache');
|
||||
}
|
||||
}
|
||||
|
||||
$supports = array();
|
||||
foreach ($store['supports'] as $support => $enabled) {
|
||||
foreach ($storesummary['supports'] as $support => $enabled) {
|
||||
if ($enabled) {
|
||||
$supports[] = get_string('supports_'.$support, 'cache');
|
||||
}
|
||||
}
|
||||
|
||||
$info = '';
|
||||
if (!empty($store['default'])) {
|
||||
if (!empty($storesummary['default'])) {
|
||||
$info = $this->output->pix_icon('i/info', $defaultstoreactions, '', array('class' => 'icon'));
|
||||
}
|
||||
$htmlactions = array();
|
||||
@@ -95,38 +97,38 @@ class core_cache_renderer extends plugin_renderer_base {
|
||||
$htmlactions[] = $this->output->action_link($action['url'], $action['text']);
|
||||
}
|
||||
|
||||
$isready = $store['isready'] && $store['requirementsmet'];
|
||||
$isready = $storesummary['isready'] && $storesummary['requirementsmet'];
|
||||
$readycell = new html_table_cell;
|
||||
if ($isready) {
|
||||
$readycell->text = $this->output->pix_icon('i/valid', '1');
|
||||
}
|
||||
|
||||
$storename = $store['name'];
|
||||
if (!empty($store['default'])) {
|
||||
$storename = get_string('store_'.$store['name'], 'cache');
|
||||
$storename = $storesummary['name'];
|
||||
if (!empty($storesummary['default'])) {
|
||||
$storename = get_string('store_'.$storesummary['name'], 'cache');
|
||||
}
|
||||
if (!$isready && (int)$store['mappings'] > 0) {
|
||||
if (!$isready && (int)$storesummary['mappings'] > 0) {
|
||||
$readycell->text = $this->output->help_icon('storerequiresattention', 'cache');
|
||||
$readycell->attributes['class'] = 'store-requires-attention';
|
||||
}
|
||||
|
||||
$lock = $store['lock']['name'];
|
||||
if (!empty($store['lock']['default'])) {
|
||||
$lock = get_string($store['lock']['name'], 'cache');
|
||||
$lock = $storesummary['lock']['name'];
|
||||
if (!empty($storesummary['lock']['default'])) {
|
||||
$lock = get_string($storesummary['lock']['name'], 'cache');
|
||||
}
|
||||
|
||||
$row = new html_table_row(array(
|
||||
$storename,
|
||||
get_string('pluginname', 'cachestore_'.$store['plugin']),
|
||||
get_string('pluginname', 'cachestore_'.$storesummary['plugin']),
|
||||
$readycell,
|
||||
$store['mappings'],
|
||||
$storesummary['mappings'],
|
||||
join(', ', $modes),
|
||||
join(', ', $supports),
|
||||
$lock,
|
||||
$info.join(', ', $htmlactions)
|
||||
));
|
||||
$row->attributes['class'] = 'store-'.$name;
|
||||
if ($store['default']) {
|
||||
if ($storesummary['default']) {
|
||||
$row->attributes['class'] .= ' default-store';
|
||||
}
|
||||
$table->data[] = $row;
|
||||
@@ -140,12 +142,13 @@ class core_cache_renderer extends plugin_renderer_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays plugin summaries
|
||||
* Displays plugin summaries.
|
||||
*
|
||||
* @param array $plugins
|
||||
* @param array $storepluginsummaries information about each store plugin as
|
||||
* returned by cache_administration_helper::get_store_plugin_summaries().
|
||||
* @return string HTML
|
||||
*/
|
||||
public function store_plugin_summaries(array $plugins) {
|
||||
public function store_plugin_summaries(array $storepluginsummaries) {
|
||||
$table = new html_table();
|
||||
$table->head = array(
|
||||
get_string('plugin', 'cache'),
|
||||
@@ -165,7 +168,7 @@ class core_cache_renderer extends plugin_renderer_base {
|
||||
);
|
||||
$table->data = array();
|
||||
|
||||
foreach ($plugins as $name => $plugin) {
|
||||
foreach ($storepluginsummaries as $name => $plugin) {
|
||||
$actions = cache_administration_helper::get_store_plugin_actions($name, $plugin);
|
||||
|
||||
$modes = array();
|
||||
@@ -208,12 +211,15 @@ class core_cache_renderer extends plugin_renderer_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays definition summaries
|
||||
* Displays definition summaries.
|
||||
*
|
||||
* @param array $definitions
|
||||
* @return string HTML
|
||||
* @param array $definitionsummaries information about each definition, as returned by
|
||||
* cache_administration_helper::get_definition_summaries().
|
||||
* @param context $context the system context.
|
||||
*
|
||||
* @return string HTML.
|
||||
*/
|
||||
public function definition_summaries(array $definitions, context $context) {
|
||||
public function definition_summaries(array $definitionsummaries, context $context) {
|
||||
$table = new html_table();
|
||||
$table->head = array(
|
||||
get_string('definition', 'cache'),
|
||||
@@ -235,10 +241,10 @@ class core_cache_renderer extends plugin_renderer_base {
|
||||
);
|
||||
$table->data = array();
|
||||
|
||||
core_collator::asort_array_of_arrays_by_key($definitions, 'name');
|
||||
core_collator::asort_array_of_arrays_by_key($definitionsummaries, 'name');
|
||||
|
||||
$none = new lang_string('none', 'cache');
|
||||
foreach ($definitions as $id => $definition) {
|
||||
foreach ($definitionsummaries as $id => $definition) {
|
||||
$actions = cache_administration_helper::get_definition_actions($context, $definition);
|
||||
$htmlactions = array();
|
||||
foreach ($actions as $action) {
|
||||
@@ -400,4 +406,4 @@ class core_cache_renderer extends plugin_renderer_base {
|
||||
$html .= html_writer::end_div();
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user