Extension:Metadata/pl
![]() Status wydania: stabilne |
|
---|---|
Realizacja | Bazy danych |
Opis | Provides a parser function and two PHP methods to set and get metadata about any wiki page |
Autor(zy) | Sophivorusdyskusja |
Ostatnia wersja | 2.0 (2022-02-14) |
MediaWiki | 1.35+ |
PHP | 7.0+ |
Zmiany w bazie danych | Tak |
Licencja | GNU General Public License 3.0 lub późniejsza |
Pobieranie | |
Quarterly downloads | 12 (Ranked 157th) |
Przetłumacz rozszerzenie Metadata jeżeli jest dostępne na translatewiki.net | |
The Metadata extension provides a simple parser function and two PHP methods to save and retrieve metadata about any wiki page.
This is a general purpose extension and does nothing useful by itself. It's meant to be used by other extensions and pieces of code to save and retrieve their own metadata.
The metadata is stored in a new database table.
Installation
- Pobierz i umieść plik(i) w katalogu o nazwie
Metadata
w folderzeextensions/
. - Dodaj poniższy kod na dole twojego pliku
LocalSettings.php
:wfLoadExtension( 'Metadata' );
- Uruchom skrypt aktualizujący, który automatycznie stworzy potrzebne tabele dla tego rozszerzenia.
Zrobione – Przejdź do Special:Version na twojej wiki, aby sprawdzić czy rozszerzenie zostało pomyślnie zainstalowane.
Usage
PHP
To save a simple key-value pair for a given page ID from PHP:
Metadata::set( $pageID, 'key', 'value' );
You can also set several key-value pairs at once, like so:
Metadata::set( $pageID, [
'key1' => 'value1',
'key2' => 'value2',
'key3' => 'etc',
]);
If a value for any of the keys already exists, it will be overwritten. Once set, you can retrieve the saved data for a given key with the following code:
$value = Metadata::get( $pageID, 'key' );
You can also retrieve all the key-value pairs for a given page at once, like so:
$data = Metadata::get( $pageID );
foreach ( $data as $key => $value ) {
// Do something
}
Wikitext
To store a simple key-value pair for the current page:
{{#metadata:key|value}}
To retrieve this value, simply do:
{{#metadata:key}}
Note that once a value has been assigned, it currently cannot be deleted from the database via wikitext (it can via PHP methods).