Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 14... Línea 14...
14
// You should have received a copy of the GNU General Public License
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
Línea 16... Línea 16...
16
 
16
 
Línea 17... Línea -...
17
namespace core_cache\output;
-
 
18
 
-
 
19
use cache_factory;
17
namespace core_cache\output;
-
 
18
 
-
 
19
use context;
20
use cache_store;
20
use core_cache\factory as cache_factory;
21
use context;
21
use core_cache\store as cache_store;
22
use core_collator;
22
use core_collator;
23
use html_table;
23
use html_table;
24
use html_table_cell;
24
use html_table_cell;
Línea 34... Línea 34...
34
 * @package    core_cache
34
 * @package    core_cache
35
 * @copyright  2012 Sam Hemelryk
35
 * @copyright  2012 Sam Hemelryk
36
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37
 */
37
 */
38
class renderer extends \plugin_renderer_base {
38
class renderer extends \plugin_renderer_base {
39
 
-
 
40
    /**
39
    /**
41
     * Displays store summaries.
40
     * Displays store summaries.
42
     *
41
     *
43
     * @param array $storeinstancesummaries information about each store instance,
42
     * @param array $storeinstancesummaries information about each store instance,
44
     *      as returned by core_cache\administration_helper::get_store_instance_summaries().
43
     *      as returned by core_cache\administration_helper::get_store_instance_summaries().
Línea 46... Línea 45...
46
     *      returned by core_cache\administration_helper::get_store_plugin_summaries().
45
     *      returned by core_cache\administration_helper::get_store_plugin_summaries().
47
     * @return string HTML
46
     * @return string HTML
48
     */
47
     */
49
    public function store_instance_summariers(array $storeinstancesummaries, array $storepluginsummaries) {
48
    public function store_instance_summariers(array $storeinstancesummaries, array $storepluginsummaries) {
50
        $table = new html_table();
49
        $table = new html_table();
51
        $table->head = array(
50
        $table->head = [
52
            get_string('storename', 'cache'),
51
            get_string('storename', 'cache'),
53
            get_string('plugin', 'cache'),
52
            get_string('plugin', 'cache'),
54
            get_string('storeready', 'cache'),
53
            get_string('storeready', 'cache'),
55
            get_string('mappings', 'cache'),
54
            get_string('mappings', 'cache'),
56
            get_string('modes', 'cache'),
55
            get_string('modes', 'cache'),
57
            get_string('supports', 'cache'),
56
            get_string('supports', 'cache'),
58
            get_string('locking', 'cache') . ' ' . $this->output->help_icon('locking', 'cache'),
57
            get_string('locking', 'cache') . ' ' . $this->output->help_icon('locking', 'cache'),
59
            get_string('actions', 'cache'),
58
            get_string('actions', 'cache'),
60
        );
59
        ];
61
        $table->colclasses = array(
60
        $table->colclasses = [
62
            'storename',
61
            'storename',
63
            'plugin',
62
            'plugin',
64
            'storeready',
63
            'storeready',
65
            'mappings',
64
            'mappings',
66
            'modes',
65
            'modes',
67
            'supports',
66
            'supports',
68
            'locking',
67
            'locking',
69
            'actions'
68
            'actions',
70
        );
69
        ];
71
        $table->data = array();
70
        $table->data = [];
Línea 72... Línea 71...
72
 
71
 
Línea 73... Línea 72...
73
        $defaultstoreactions = get_string('defaultstoreactions', 'cache');
72
        $defaultstoreactions = get_string('defaultstoreactions', 'cache');
74
 
73
 
75
        foreach ($storeinstancesummaries as $name => $storesummary) {
74
        foreach ($storeinstancesummaries as $name => $storesummary) {
76
            $htmlactions = cache_factory::get_administration_display_helper()->get_store_instance_actions($name, $storesummary);
75
            $htmlactions = cache_factory::get_administration_display_helper()->get_store_instance_actions($name, $storesummary);
77
            $modes = array();
76
            $modes = [];
78
            foreach ($storesummary['modes'] as $mode => $enabled) {
77
            foreach ($storesummary['modes'] as $mode => $enabled) {
79
                if ($enabled) {
78
                if ($enabled) {
80
                    $modes[] = get_string('mode_'.$mode, 'cache');
79
                    $modes[] = get_string('mode_' . $mode, 'cache');
Línea 81... Línea 80...
81
                }
80
                }
82
            }
81
            }
83
 
82
 
84
            $supports = array();
83
            $supports = [];
85
            foreach ($storesummary['supports'] as $support => $enabled) {
84
            foreach ($storesummary['supports'] as $support => $enabled) {
86
                if ($enabled) {
85
                if ($enabled) {
Línea 87... Línea 86...
87
                    $supports[] = get_string('supports_'.$support, 'cache');
86
                    $supports[] = get_string('supports_' . $support, 'cache');
88
                }
87
                }
89
            }
88
            }
90
 
89
 
Línea 91... Línea 90...
91
            $info = '';
90
            $info = '';
92
            if (!empty($storesummary['default'])) {
91
            if (!empty($storesummary['default'])) {
93
                $info = $this->output->pix_icon('i/info', $defaultstoreactions, '', array('class' => 'icon'));
92
                $info = $this->output->pix_icon('i/info', $defaultstoreactions, '', ['class' => 'icon']);
94
            }
93
            }
95
 
94
 
Línea 96... Línea 95...
96
            $isready = $storesummary['isready'] && $storesummary['requirementsmet'];
95
            $isready = $storesummary['isready'] && $storesummary['requirementsmet'];
97
            $readycell = new html_table_cell;
96
            $readycell = new html_table_cell();
98
            if ($isready) {
97
            if ($isready) {
99
                $readycell->text = $this->output->pix_icon('i/valid', '1');
98
                $readycell->text = $this->output->pix_icon('i/valid', '1');
100
            }
99
            }
101
 
100
 
102
            $storename = $storesummary['name'];
101
            $storename = $storesummary['name'];
103
            if (!empty($storesummary['default'])) {
102
            if (!empty($storesummary['default'])) {
Línea 111... Línea 110...
111
            $lock = $storesummary['lock']['name'];
110
            $lock = $storesummary['lock']['name'];
112
            if (!empty($storesummary['lock']['default'])) {
111
            if (!empty($storesummary['lock']['default'])) {
113
                $lock = get_string($storesummary['lock']['name'], 'cache');
112
                $lock = get_string($storesummary['lock']['name'], 'cache');
114
            }
113
            }
Línea 115... Línea 114...
115
 
114
 
116
            $row = new html_table_row(array(
115
            $row = new html_table_row([
117
                $storename,
116
                $storename,
118
                get_string('pluginname', 'cachestore_'.$storesummary['plugin']),
117
                get_string('pluginname', 'cachestore_' . $storesummary['plugin']),
119
                $readycell,
118
                $readycell,
120
                $storesummary['mappings'],
119
                $storesummary['mappings'],
121
                join(', ', $modes),
120
                join(', ', $modes),
122
                join(', ', $supports),
121
                join(', ', $supports),
123
                $lock,
122
                $lock,
124
                $info.join(', ', $htmlactions)
123
                $info . join(', ', $htmlactions),
125
            ));
124
            ]);
126
            $row->attributes['class'] = 'store-'.$name;
125
            $row->attributes['class'] = 'store-' . $name;
127
            if ($storesummary['default']) {
126
            if ($storesummary['default']) {
128
                $row->attributes['class'] .= ' default-store';
127
                $row->attributes['class'] .= ' default-store';
129
            }
128
            }
130
            $table->data[] = $row;
129
            $table->data[] = $row;
Línea 131... Línea 130...
131
        }
130
        }
132
 
131
 
133
        $html  = html_writer::start_tag('div', array('id' => 'core-cache-store-summaries'));
132
        $html  = html_writer::start_tag('div', ['id' => 'core-cache-store-summaries']);
134
        $html .= $this->output->heading(get_string('storesummaries', 'cache'), 3);
133
        $html .= $this->output->heading(get_string('storesummaries', 'cache'), 3);
135
        $html .= html_writer::table($table);
134
        $html .= html_writer::table($table);
136
        $html .= html_writer::end_tag('div');
135
        $html .= html_writer::end_tag('div');
Línea 144... Línea 143...
144
     *      returned by core_cache\administration_helper::get_store_plugin_summaries().
143
     *      returned by core_cache\administration_helper::get_store_plugin_summaries().
145
     * @return string HTML
144
     * @return string HTML
146
     */
145
     */
147
    public function store_plugin_summaries(array $storepluginsummaries) {
146
    public function store_plugin_summaries(array $storepluginsummaries) {
148
        $table = new html_table();
147
        $table = new html_table();
149
        $table->head = array(
148
        $table->head = [
150
            get_string('plugin', 'cache'),
149
            get_string('plugin', 'cache'),
151
            get_string('storeready', 'cache'),
150
            get_string('storeready', 'cache'),
152
            get_string('stores', 'cache'),
151
            get_string('stores', 'cache'),
153
            get_string('modes', 'cache'),
152
            get_string('modes', 'cache'),
154
            get_string('supports', 'cache'),
153
            get_string('supports', 'cache'),
155
            get_string('actions', 'cache'),
154
            get_string('actions', 'cache'),
156
        );
155
        ];
157
        $table->colclasses = array(
156
        $table->colclasses = [
158
            'plugin',
157
            'plugin',
159
            'storeready',
158
            'storeready',
160
            'stores',
159
            'stores',
161
            'modes',
160
            'modes',
162
            'supports',
161
            'supports',
163
            'actions'
162
            'actions',
164
        );
163
        ];
165
        $table->data = array();
164
        $table->data = [];
Línea 166... Línea 165...
166
 
165
 
167
        foreach ($storepluginsummaries as $name => $plugin) {
166
        foreach ($storepluginsummaries as $name => $plugin) {
Línea 168... Línea 167...
168
            $htmlactions = cache_factory::get_administration_display_helper()->get_store_plugin_actions($name, $plugin);
167
            $htmlactions = cache_factory::get_administration_display_helper()->get_store_plugin_actions($name, $plugin);
169
 
168
 
170
            $modes = array();
169
            $modes = [];
171
            foreach ($plugin['modes'] as $mode => $enabled) {
170
            foreach ($plugin['modes'] as $mode => $enabled) {
172
                if ($enabled) {
171
                if ($enabled) {
173
                    $modes[] = get_string('mode_'.$mode, 'cache');
172
                    $modes[] = get_string('mode_' . $mode, 'cache');
Línea 174... Línea 173...
174
                }
173
                }
175
            }
174
            }
176
 
175
 
177
            $supports = array();
176
            $supports = [];
178
            foreach ($plugin['supports'] as $support => $enabled) {
177
            foreach ($plugin['supports'] as $support => $enabled) {
179
                if ($enabled) {
178
                if ($enabled) {
Línea 180... Línea 179...
180
                    $supports[] = get_string('supports_'.$support, 'cache');
179
                    $supports[] = get_string('supports_' . $support, 'cache');
181
                }
180
                }
182
            }
181
            }
183
 
182
 
184
            $row = new html_table_row(array(
183
            $row = new html_table_row([
185
                $plugin['name'],
184
                $plugin['name'],
186
                ($plugin['requirementsmet']) ? $this->output->pix_icon('i/valid', '1') : '',
185
                ($plugin['requirementsmet']) ? $this->output->pix_icon('i/valid', '1') : '',
187
                $plugin['instances'],
186
                $plugin['instances'],
Línea 188... Línea 187...
188
                join(', ', $modes),
187
                join(', ', $modes),
189
                join(', ', $supports),
188
                join(', ', $supports),
190
                join(', ', $htmlactions)
189
                join(', ', $htmlactions),
Línea 191... Línea 190...
191
            ));
190
            ]);
192
 
191
 
193
            $row->attributes['class'] = 'plugin-'.$name;
192
            $row->attributes['class'] = 'plugin-' . $name;
194
            $table->data[] = $row;
193
            $table->data[] = $row;
195
        }
194
        }
196
 
195
 
Línea 210... Línea 209...
210
     *
209
     *
211
     * @return string HTML.
210
     * @return string HTML.
212
     */
211
     */
213
    public function definition_summaries(array $definitionsummaries, context $context) {
212
    public function definition_summaries(array $definitionsummaries, context $context) {
214
        $table = new html_table();
213
        $table = new html_table();
215
        $table->head = array(
214
        $table->head = [
216
            get_string('definition', 'cache'),
215
            get_string('definition', 'cache'),
217
            get_string('mode', 'cache'),
216
            get_string('mode', 'cache'),
218
            get_string('component', 'cache'),
217
            get_string('component', 'cache'),
219
            get_string('area', 'cache'),
218
            get_string('area', 'cache'),
220
            get_string('mappings', 'cache'),
219
            get_string('mappings', 'cache'),
221
            get_string('sharing', 'cache'),
220
            get_string('sharing', 'cache'),
222
            get_string('canuselocalstore', 'cache'),
221
            get_string('canuselocalstore', 'cache'),
223
            get_string('actions', 'cache')
222
            get_string('actions', 'cache'),
224
        );
223
        ];
225
        $table->colclasses = array(
224
        $table->colclasses = [
226
            'definition',
225
            'definition',
227
            'mode',
226
            'mode',
228
            'component',
227
            'component',
229
            'area',
228
            'area',
230
            'mappings',
229
            'mappings',
231
            'sharing',
230
            'sharing',
232
            'canuselocalstore',
231
            'canuselocalstore',
233
            'actions'
232
            'actions',
234
        );
233
        ];
235
        $table->data = array();
234
        $table->data = [];
Línea 236... Línea 235...
236
 
235
 
Línea 237... Línea 236...
237
        core_collator::asort_array_of_arrays_by_key($definitionsummaries, 'name');
236
        core_collator::asort_array_of_arrays_by_key($definitionsummaries, 'name');
238
 
237
 
239
        $none = new lang_string('none', 'cache');
238
        $none = new lang_string('none', 'cache');
240
        foreach ($definitionsummaries as $id => $definition) {
239
        foreach ($definitionsummaries as $id => $definition) {
241
            $htmlactions = cache_factory::get_administration_display_helper()->get_definition_actions($context, $definition);
240
            $htmlactions = cache_factory::get_administration_display_helper()->get_definition_actions($context, $definition);
242
            if (!empty($definition['mappings'])) {
241
            if (!empty($definition['mappings'])) {
243
                $mapping = join(', ', $definition['mappings']);
242
                $mapping = join(', ', $definition['mappings']);
244
            } else {
243
            } else {
Línea 245... Línea 244...
245
                $mapping = '<em>'.$none.'</em>';
244
                $mapping = '<em>' . $none . '</em>';
246
            }
245
            }
247
 
246
 
248
            $uselocalcachecol = get_string('no');
247
            $uselocalcachecol = get_string('no');
249
            if ($definition['mode'] != cache_store::MODE_REQUEST) {
248
            if ($definition['mode'] != cache_store::MODE_REQUEST) {
250
                if (isset($definition['canuselocalstore']) && $definition['canuselocalstore']) {
249
                if (isset($definition['canuselocalstore']) && $definition['canuselocalstore']) {
Línea 251... Línea 250...
251
                    $uselocalcachecol = get_string('yes');
250
                    $uselocalcachecol = get_string('yes');
252
                }
251
                }
253
            }
252
            }
254
 
253
 
255
            $row = new html_table_row(array(
254
            $row = new html_table_row([
256
                $definition['name'],
255
                $definition['name'],
257
                get_string('mode_'.$definition['mode'], 'cache'),
256
                get_string('mode_' . $definition['mode'], 'cache'),
258
                $definition['component'],
257
                $definition['component'],
259
                $definition['area'],
258
                $definition['area'],
260
                $mapping,
259
                $mapping,
261
                join(', ', $definition['selectedsharingoption']),
260
                join(', ', $definition['selectedsharingoption']),
262
                $uselocalcachecol,
261
                $uselocalcachecol,
263
                join(', ', $htmlactions)
262
                join(', ', $htmlactions),
Línea 264... Línea 263...
264
            ));
263
            ]);
265
            $row->attributes['class'] = 'definition-'.$definition['component'].'-'.$definition['area'];
264
            $row->attributes['class'] = 'definition-' . $definition['component'] . '-' . $definition['area'];
266
            $table->data[] = $row;
265
            $table->data[] = $row;
Línea 267... Línea 266...
267
        }
266
        }
268
 
267
 
269
        $html  = html_writer::start_tag('div', array('id' => 'core-cache-definition-summaries'));
268
        $html  = html_writer::start_tag('div', ['id' => 'core-cache-definition-summaries']);
Línea 270... Línea 269...
270
        $html .= $this->output->heading(get_string('definitionsummaries', 'cache'), 3);
269
        $html .= $this->output->heading(get_string('definitionsummaries', 'cache'), 3);
271
        $html .= html_writer::table($table);
270
        $html .= html_writer::table($table);
272
 
271
 
Línea 287... Línea 286...
287
     * @param moodle_url $editurl
286
     * @param moodle_url $editurl
288
     * @return string HTML
287
     * @return string HTML
289
     */
288
     */
290
    public function mode_mappings($applicationstore, $sessionstore, $requeststore, moodle_url $editurl) {
289
    public function mode_mappings($applicationstore, $sessionstore, $requeststore, moodle_url $editurl) {
291
        $table = new html_table();
290
        $table = new html_table();
292
        $table->colclasses = array(
291
        $table->colclasses = [
293
            'mode',
292
            'mode',
294
            'mapping',
293
            'mapping',
295
        );
294
        ];
296
        $table->rowclasses = array(
295
        $table->rowclasses = [
297
            'mode_application',
296
            'mode_application',
298
            'mode_session',
297
            'mode_session',
299
            'mode_request'
298
            'mode_request',
300
        );
299
        ];
301
        $table->head = array(
300
        $table->head = [
302
            get_string('mode', 'cache'),
301
            get_string('mode', 'cache'),
303
            get_string('mappings', 'cache'),
302
            get_string('mappings', 'cache'),
304
        );
303
        ];
305
        $table->data = array(
304
        $table->data = [
306
            array(get_string('mode_'.cache_store::MODE_APPLICATION, 'cache'), $applicationstore),
305
            [get_string('mode_' . cache_store::MODE_APPLICATION, 'cache'), $applicationstore],
307
            array(get_string('mode_'.cache_store::MODE_SESSION, 'cache'), $sessionstore),
306
            [get_string('mode_' . cache_store::MODE_SESSION, 'cache'), $sessionstore],
308
            array(get_string('mode_'.cache_store::MODE_REQUEST, 'cache'), $requeststore)
307
            [get_string('mode_' . cache_store::MODE_REQUEST, 'cache'), $requeststore],
309
        );
308
        ];
Línea 310... Línea 309...
310
 
309
 
311
        $html = html_writer::start_tag('div', array('id' => 'core-cache-mode-mappings'));
310
        $html = html_writer::start_tag('div', ['id' => 'core-cache-mode-mappings']);
312
        $html .= $this->output->heading(get_string('defaultmappings', 'cache'), 3);
311
        $html .= $this->output->heading(get_string('defaultmappings', 'cache'), 3);
313
        $html .= html_writer::table($table);
312
        $html .= html_writer::table($table);
314
        $link = html_writer::link($editurl, get_string('editmappings', 'cache'));
313
        $link = html_writer::link($editurl, get_string('editmappings', 'cache'));
315
        $html .= html_writer::tag('div', $link, array('class' => 'edit-link'));
314
        $html .= html_writer::tag('div', $link, ['class' => 'edit-link']);
316
        $html .= html_writer::end_tag('div');
315
        $html .= html_writer::end_tag('div');
317
        return $html;
316
        return $html;
Línea 318... Línea 317...
318
    }
317
    }
Línea 325... Línea 324...
325
     * @param array $locks
324
     * @param array $locks
326
     * @return string
325
     * @return string
327
     */
326
     */
328
    public function lock_summaries(array $locks) {
327
    public function lock_summaries(array $locks) {
329
        $table = new html_table();
328
        $table = new html_table();
330
        $table->colclasses = array(
329
        $table->colclasses = [
331
            'name',
330
            'name',
332
            'type',
331
            'type',
333
            'default',
332
            'default',
334
            'uses',
333
            'uses',
335
            'actions'
334
            'actions',
336
        );
335
        ];
337
        $table->rowclasses = array(
336
        $table->rowclasses = [
338
            'lock_name',
337
            'lock_name',
339
            'lock_type',
338
            'lock_type',
340
            'lock_default',
339
            'lock_default',
341
            'lock_uses',
340
            'lock_uses',
342
            'lock_actions',
341
            'lock_actions',
343
        );
342
        ];
344
        $table->head = array(
343
        $table->head = [
345
            get_string('lockname', 'cache'),
344
            get_string('lockname', 'cache'),
346
            get_string('locktype', 'cache'),
345
            get_string('locktype', 'cache'),
347
            get_string('lockdefault', 'cache'),
346
            get_string('lockdefault', 'cache'),
348
            get_string('lockuses', 'cache'),
347
            get_string('lockuses', 'cache'),
349
            get_string('actions', 'cache')
348
            get_string('actions', 'cache'),
350
        );
349
        ];
351
        $table->data = array();
350
        $table->data = [];
352
        $tick = $this->output->pix_icon('i/valid', '');
351
        $tick = $this->output->pix_icon('i/valid', '');
353
        foreach ($locks as $lock) {
352
        foreach ($locks as $lock) {
354
            $actions = array();
353
            $actions = [];
355
            if ($lock['uses'] === 0 && !$lock['default']) {
354
            if ($lock['uses'] === 0 && !$lock['default']) {
356
                $url = new moodle_url('/cache/admin.php', array('lock' => $lock['name'], 'action' => 'deletelock'));
355
                $url = new moodle_url('/cache/admin.php', ['lock' => $lock['name'], 'action' => 'deletelock']);
357
                $actions[] = html_writer::link($url, get_string('delete', 'cache'));
356
                $actions[] = html_writer::link($url, get_string('delete', 'cache'));
358
            }
357
            }
359
            $table->data[] = new html_table_row(array(
358
            $table->data[] = new html_table_row([
360
                new html_table_cell($lock['name']),
359
                new html_table_cell($lock['name']),
361
                new html_table_cell($lock['type']),
360
                new html_table_cell($lock['type']),
362
                new html_table_cell($lock['default'] ? $tick : ''),
361
                new html_table_cell($lock['default'] ? $tick : ''),
363
                new html_table_cell($lock['uses']),
362
                new html_table_cell($lock['uses']),
364
                new html_table_cell(join(' ', $actions))
363
                new html_table_cell(join(' ', $actions)),
365
            ));
364
            ]);
366
        }
365
        }
Línea 367... Línea 366...
367
 
366
 
368
        $html = html_writer::start_tag('div', array('id' => 'core-cache-lock-summary'));
367
        $html = html_writer::start_tag('div', ['id' => 'core-cache-lock-summary']);
369
        $html .= $this->output->heading(get_string('locksummary', 'cache'), 3);
368
        $html .= $this->output->heading(get_string('locksummary', 'cache'), 3);
370
        $html .= html_writer::table($table);
369
        $html .= html_writer::table($table);
371
        $html .= html_writer::end_tag('div');
370
        $html .= html_writer::end_tag('div');
372
        return $html;
371
        return $html;
Línea 376... Línea 375...
376
     * Renders additional actions for locks, such as Add.
375
     * Renders additional actions for locks, such as Add.
377
     *
376
     *
378
     * @return string
377
     * @return string
379
     */
378
     */
380
    public function additional_lock_actions(): string {
379
    public function additional_lock_actions(): string {
381
        $url = new moodle_url('/cache/admin.php', array('action' => 'newlockinstance'));
380
        $url = new moodle_url('/cache/admin.php', ['action' => 'newlockinstance']);
382
        $select = new single_select($url, 'lock', cache_factory::get_administration_display_helper()->get_addable_lock_options());
381
        $select = new single_select($url, 'lock', cache_factory::get_administration_display_helper()->get_addable_lock_options());
383
        $select->label = get_string('addnewlockinstance', 'cache');
382
        $select->label = get_string('addnewlockinstance', 'cache');
Línea 384... Línea 383...
384
 
383
 
385
        $html = html_writer::start_tag('div', array('id' => 'core-cache-lock-additional-actions'));
384
        $html = html_writer::start_tag('div', ['id' => 'core-cache-lock-additional-actions']);
386
        $html .= html_writer::tag('div', $this->output->render($select), array('class' => 'new-instance'));
385
        $html .= html_writer::tag('div', $this->output->render($select), ['class' => 'new-instance']);
387
        $html .= html_writer::end_tag('div');
386
        $html .= html_writer::end_tag('div');
388
        return $html;
387
        return $html;
Línea 389... Línea 388...
389
    }
388
    }
Línea 398... Línea 397...
398
     * );
397
     * );
399
     *
398
     *
400
     * @param array $notifications
399
     * @param array $notifications
401
     * @return string
400
     * @return string
402
     */
401
     */
403
    public function notifications(array $notifications = array()) {
402
    public function notifications(array $notifications = []) {
404
        if (count($notifications) === 0) {
403
        if (count($notifications) === 0) {
405
            // There are no notifications to render.
404
            // There are no notifications to render.
406
            return '';
405
            return '';
407
        }
406
        }
408
        $html = html_writer::start_div('notifications');
407
        $html = html_writer::start_div('notifications');
409
        foreach ($notifications as $notification) {
408
        foreach ($notifications as $notification) {
410
            list($message, $notifysuccess) = $notification;
409
            [$message, $notifysuccess] = $notification;
411
            $html .= $this->notification($message, ($notifysuccess) ? 'notifysuccess' : 'notifyproblem');
410
            $html .= $this->notification($message, ($notifysuccess) ? 'notifysuccess' : 'notifyproblem');
412
        }
411
        }
413
        $html .= html_writer::end_div();
412
        $html .= html_writer::end_div();
414
        return $html;
413
        return $html;
415
    }
414
    }
Línea 416... Línea 415...
416
 
415
 
417
    /**
416
    /**
418
     * Creates the two tables which display on the usage page.
417
     * Creates the two tables which display on the usage page.
419
     *
418
     *
420
     * @param array $usage Usage information (from cache_helper::usage)
419
     * @param array $usage Usage information (from \core_cache\helper::usage)
421
     * @return array Array of 2 tables (main and summary table)
420
     * @return array Array of 2 tables (main and summary table)
422
     * @throws \coding_exception
421
     * @throws \coding_exception
423
     */
422
     */
424
    public function usage_tables(array $usage): array {
423
    public function usage_tables(array $usage): array {
Línea 430... Línea 429...
430
            get_string('plugin', 'cache'),
429
            get_string('plugin', 'cache'),
431
            get_string('usage_items', 'cache'),
430
            get_string('usage_items', 'cache'),
432
            get_string('usage_mean', 'cache'),
431
            get_string('usage_mean', 'cache'),
433
            get_string('usage_sd', 'cache'),
432
            get_string('usage_sd', 'cache'),
434
            get_string('usage_total', 'cache'),
433
            get_string('usage_total', 'cache'),
435
            get_string('usage_totalmargin', 'cache')];
434
            get_string('usage_totalmargin', 'cache'), ];
436
        $table->align = [
435
        $table->align = [
437
            'left', 'left', 'left',
436
            'left', 'left', 'left',
438
            'right', 'right', 'right', 'right', 'right'
437
            'right', 'right', 'right', 'right', 'right',
439
        ];
438
        ];
440
        $table->data = [];
439
        $table->data = [];
Línea 441... Línea 440...
441
 
440
 
442
        $summarytable = new \html_table();
441
        $summarytable = new \html_table();
443
        $summarytable->id = 'usage_summary';
442
        $summarytable->id = 'usage_summary';
444
        $summarytable->head = [
443
        $summarytable->head = [
445
            get_string('storename', 'cache'),
444
            get_string('storename', 'cache'),
446
            get_string('plugin', 'cache'),
445
            get_string('plugin', 'cache'),
447
            get_string('usage_total', 'cache'),
446
            get_string('usage_total', 'cache'),
448
            get_string('usage_realtotal', 'cache')
447
            get_string('usage_realtotal', 'cache'),
449
        ];
448
        ];
450
        $summarytable->align = [
449
        $summarytable->align = [
451
            'left', 'left',
450
            'left', 'left',
452
            'right', 'right',
451
            'right', 'right',
Línea 540... Línea 539...
540
     */
539
     */
541
    public function usage_page(\html_table $maintable, \html_table $summarytable, \moodleform $samplesform): string {
540
    public function usage_page(\html_table $maintable, \html_table $summarytable, \moodleform $samplesform): string {
542
        $data = [
541
        $data = [
543
            'maintable' => \html_writer::table($maintable),
542
            'maintable' => \html_writer::table($maintable),
544
            'summarytable' => \html_writer::table($summarytable),
543
            'summarytable' => \html_writer::table($summarytable),
545
            'samplesform' => $samplesform->render()
544
            'samplesform' => $samplesform->render(),
546
        ];
545
        ];
Línea 547... Línea 546...
547
 
546
 
548
        return $this->render_from_template('core_cache/usage', $data);
547
        return $this->render_from_template('core_cache/usage', $data);
549
    }
548
    }