Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 16... Línea 16...
16
 
16
 
Línea 17... Línea 17...
17
declare(strict_types=1);
17
declare(strict_types=1);
Línea 18... Línea -...
18
 
-
 
19
namespace core_tag\reportbuilder\local\entities;
-
 
20
 
18
 
21
use context;
19
namespace core_tag\reportbuilder\local\entities;
22
use context_helper;
-
 
23
use core_collator;
20
 
24
use core_tag_area;
21
use core_collator;
25
use html_writer;
22
use core_tag_area;
26
use lang_string;
23
use lang_string;
27
use stdClass;
24
use stdClass;
Línea 45... Línea 42...
45
     * @return string[]
42
     * @return string[]
46
     */
43
     */
47
    protected function get_default_tables(): array {
44
    protected function get_default_tables(): array {
48
        return [
45
        return [
49
            'tag_instance',
46
            'tag_instance',
-
 
47
        ];
-
 
48
    }
-
 
49
 
-
 
50
    /**
-
 
51
     * Database tables that this entity no longer uses
-
 
52
     *
-
 
53
     * @return string[]
-
 
54
     */
-
 
55
    protected function get_deprecated_tables(): array {
-
 
56
        return [
50
            'context',
57
            'context',
51
        ];
58
        ];
52
    }
59
    }
Línea 53... Línea 60...
53
 
60
 
Línea 87... Línea 94...
87
     *
94
     *
88
     * @return column[]
95
     * @return column[]
89
     */
96
     */
90
    protected function get_all_columns(): array {
97
    protected function get_all_columns(): array {
91
        $instancealias = $this->get_table_alias('tag_instance');
98
        $instancealias = $this->get_table_alias('tag_instance');
92
        $contextalias = $this->get_table_alias('context');
-
 
Línea 93... Línea 99...
93
 
99
 
94
        // Area.
100
        // Area.
95
        $columns[] = (new column(
101
        $columns[] = (new column(
96
            'area',
102
            'area',
Línea 107... Línea 113...
107
                    return '';
113
                    return '';
108
                }
114
                }
109
                return (string) core_tag_area::display_name($area->component, $area->itemtype);
115
                return (string) core_tag_area::display_name($area->component, $area->itemtype);
110
            });
116
            });
Línea 111... Línea -...
111
 
-
 
112
        // Context.
-
 
113
        $columns[] = (new column(
-
 
114
            'context',
-
 
115
            new lang_string('context'),
-
 
116
            $this->get_entity_name()
-
 
117
        ))
-
 
118
            ->add_joins($this->get_joins())
-
 
119
            ->set_type(column::TYPE_TEXT)
-
 
120
            ->add_join("LEFT JOIN {context} {$contextalias} ON {$contextalias}.id = {$instancealias}.contextid")
-
 
121
            ->add_fields("{$instancealias}.contextid, " . context_helper::get_preload_record_columns_sql($contextalias))
-
 
122
            // Sorting may not order alphabetically, but will at least group contexts together.
-
 
123
            ->set_is_sortable(true)
-
 
124
            ->set_is_deprecated('See \'context:name\' for replacement')
-
 
125
            ->add_callback(static function($contextid, stdClass $context): string {
-
 
126
                if ($contextid === null) {
-
 
127
                    return '';
-
 
128
                }
-
 
129
 
-
 
130
                context_helper::preload_from_record($context);
-
 
131
                return context::instance_by_id($contextid)->get_context_name();
-
 
132
            });
-
 
133
 
-
 
134
        // Context URL.
-
 
135
        $columns[] = (new column(
-
 
136
            'contexturl',
-
 
137
            new lang_string('contexturl'),
-
 
138
            $this->get_entity_name()
-
 
139
        ))
-
 
140
            ->add_joins($this->get_joins())
-
 
141
            ->set_type(column::TYPE_TEXT)
-
 
142
            ->add_join("LEFT JOIN {context} {$contextalias} ON {$contextalias}.id = {$instancealias}.contextid")
-
 
143
            ->add_fields("{$instancealias}.contextid, " . context_helper::get_preload_record_columns_sql($contextalias))
-
 
144
            // Sorting may not order alphabetically, but will at least group contexts together.
-
 
145
            ->set_is_sortable(true)
-
 
146
            ->set_is_deprecated('See \'context:link\' for replacement')
-
 
147
            ->add_callback(static function($contextid, stdClass $context): string {
-
 
148
                if ($contextid === null) {
-
 
149
                    return '';
-
 
150
                }
-
 
151
 
-
 
152
                context_helper::preload_from_record($context);
-
 
153
                $context = context::instance_by_id($contextid);
-
 
154
 
-
 
155
                return html_writer::link($context->get_url(), $context->get_context_name());
-
 
156
            });
-
 
157
 
117
 
158
        // Component.
118
        // Component.
159
        $columns[] = (new column(
119
        $columns[] = (new column(
160
            'component',
120
            'component',
161
            new lang_string('component', 'core_tag'),
121
            new lang_string('component', 'core_tag'),
Línea 182... Línea 142...
182
            'itemid',
142
            'itemid',
183
            new lang_string('itemid', 'core_tag'),
143
            new lang_string('itemid', 'core_tag'),
184
            $this->get_entity_name()
144
            $this->get_entity_name()
185
        ))
145
        ))
186
            ->add_joins($this->get_joins())
146
            ->add_joins($this->get_joins())
187
            ->set_type(column::TYPE_INTEGER)
-
 
188
            ->add_fields("{$instancealias}.itemid")
147
            ->add_fields("{$instancealias}.itemid")
189
            ->set_is_sortable(true)
148
            ->set_is_sortable(true);
190
            ->set_disabled_aggregation_all();
-
 
Línea 191... Línea 149...
191
 
149
 
192
        // Time created.
150
        // Time created.
193
        $columns[] = (new column(
151
        $columns[] = (new column(
194
            'timecreated',
152
            'timecreated',