A very basic FFS module that implements some basic functionality and a simple binary based file format. More...
Public Member Functions | |
supportsFuzzy () | |
Query the capabilities of this FFS. | |
getFileExtensions () | |
Return the commonly used file extensions for these formats. | |
__construct (FileBasedMessageGroup $group) | |
setGroup (FileBasedMessageGroup $group) | |
getGroup () | |
setWritePath ($writePath) | |
getWritePath () | |
exists ($code=false) | |
Returns true if the file for this message group in a given language exists. | |
read ($code) | |
Reads messages from the file in a given language and returns an array of AUTHORS, MESSAGES and possibly other properties. | |
readFromVariable ($data) | |
Parse the message data given as a string in the SimpleFFS format and return it as an array of AUTHORS and MESSAGES. | |
write (MessageCollection $collection) | |
Write the collection to file. | |
writeIntoVariable (MessageCollection $collection) | |
Read a collection and return it as a SimpleFFS formatted string. | |
Static Public Member Functions | |
static | fixNewLines ($data) |
Replaces all Windows and Mac line endings with Unix line endings. | |
Public Attributes | |
const | RECORD_SEPARATOR = "\0" |
const | PART_SEPARATOR = "\0\0\0\0" |
Protected Member Functions | |
writeReal (MessageCollection $collection) | |
tryReadSource ($filename, MessageCollection $collection) | |
tryReadFile ($filename) | |
Read the contents of $filename and return it as a string. | |
filterAuthors (array $authors, $code) | |
Remove blacklisted authors. | |
Protected Attributes | |
$group | |
$writePath | |
$extra | |
Stores the FILES section of the YAML configuration, which can be accessed for extra FFS class specific options. |
A very basic FFS module that implements some basic functionality and a simple binary based file format.
Other FFS classes can extend SimpleFFS and override suitable methods.
Definition at line 93 of file FFS.php.
SimpleFFS::__construct | ( | FileBasedMessageGroup $ | group | ) |
SimpleFFS::exists | ( | $ | code = false |
) |
Returns true if the file for this message group in a given language exists.
If no $code is given, the groups source language is assumed. NB: Some formats store all languages in the same file, and then this function will return true even if there are no translations to that language.
$code | string|bool |
Definition at line 162 of file FFS.php.
Referenced by XliffFFS::read(), and read().
SimpleFFS::filterAuthors | ( | array $ | authors, | |
$ | code | |||
) | [protected] |
Remove blacklisted authors.
$authors | array | |
$code | string |
Definition at line 383 of file FFS.php.
Referenced by YamlFFS::doAuthors(), GettextFFS::doAuthors(), FlatPhpFFS::doAuthors(), DtdFFS::doAuthors(), PythonSingleFFS::writeReal(), MediaWikiExtensionFFS::writeReal(), and writeReal().
static SimpleFFS::fixNewLines | ( | $ | data | ) | [static] |
Replaces all Windows and Mac line endings with Unix line endings.
This is needed in some file types.
$data | string |
Definition at line 419 of file FFS.php.
Referenced by JavaFFS::readFromVariable(), PythonSingleFFS::splitSections(), and MediaWikiExtensionFFS::splitSections().
SimpleFFS::getFileExtensions | ( | ) |
Return the commonly used file extensions for these formats.
Include the dot.
Implements FFS.
Reimplemented in AndroidXmlFFS, DtdFFS, FlatPhpFFS, GettextFFS, IniFFS, JavaFFS, JavaScriptFFS, JsonFFS, MediaWikiExtensionFFS, PythonSingleFFS, RubyYamlFFS, XliffFFS, and YamlFFS.
SimpleFFS::getGroup | ( | ) |
SimpleFFS::read | ( | $ | code | ) |
Reads messages from the file in a given language and returns an array of AUTHORS, MESSAGES and possibly other properties.
$code | string |
MWException | if the file appears to exist, but cannot be read |
Implements FFS.
Reimplemented in MediaWikiExtensionFFS, PythonSingleFFS, and XliffFFS.
Definition at line 187 of file FFS.php.
Referenced by GettextFFS::writeReal().
SimpleFFS::readFromVariable | ( | $ | data | ) |
Parse the message data given as a string in the SimpleFFS format and return it as an array of AUTHORS and MESSAGES.
$data | string |
MWException |
Implements FFS.
Reimplemented in AndroidXmlFFS, DtdFFS, FlatPhpFFS, GettextFFS, IniFFS, JavaFFS, JavaScriptFFS, JsonFFS, MediaWikiExtensionFFS, PythonSingleFFS, and YamlFFS.
Definition at line 209 of file FFS.php.
Referenced by read(), and tryReadSource().
SimpleFFS::setGroup | ( | FileBasedMessageGroup $ | group | ) |
$group | FileBasedMessageGroup |
Definition at line 127 of file FFS.php.
Referenced by __construct().
SimpleFFS::setWritePath | ( | $ | writePath | ) |
SimpleFFS::supportsFuzzy | ( | ) |
Query the capabilities of this FFS.
Allowed values are:
Implements FFS.
Reimplemented in AndroidXmlFFS, GettextFFS, IniFFS, JavaFFS, MediaWikiExtensionFFS, and XliffFFS.
SimpleFFS::tryReadFile | ( | $ | filename | ) | [protected] |
Read the contents of $filename and return it as a string.
Return false if the file doesn't exist. Throw an exception if the file isn't readable or if the reading fails strangely.
$filename | string |
MWException |
Definition at line 355 of file FFS.php.
Referenced by tryReadSource().
SimpleFFS::tryReadSource | ( | $ | filename, | |
MessageCollection $ | collection | |||
) | [protected] |
$filename | string | |
$collection | MessageCollection |
Definition at line 323 of file FFS.php.
Referenced by write(), and writeIntoVariable().
SimpleFFS::write | ( | MessageCollection $ | collection | ) |
Write the collection to file.
$collection | MessageCollection |
MWException |
Implements FFS.
Definition at line 250 of file FFS.php.
SimpleFFS::writeIntoVariable | ( | MessageCollection $ | collection | ) |
Read a collection and return it as a SimpleFFS formatted string.
$collection | MessageCollection |
Implements FFS.
Definition at line 287 of file FFS.php.
SimpleFFS::writeReal | ( | MessageCollection $ | collection | ) | [protected] |
$collection | MessageCollection |
Reimplemented in GettextFFS, MediaWikiExtensionFFS, PythonSingleFFS, and XliffFFS.
Definition at line 298 of file FFS.php.
Referenced by write(), and writeIntoVariable().
SimpleFFS::$extra [protected] |
Stores the FILES section of the YAML configuration, which can be accessed for extra FFS class specific options.
Definition at line 113 of file FFS.php.
Referenced by GettextFFS::doGettextHeader(), and MediaWikiExtensionFFS::quote().
SimpleFFS::$writePath [protected] |
Definition at line 107 of file FFS.php.
Referenced by setWritePath(), and write().
const SimpleFFS::PART_SEPARATOR = "\0\0\0\0" |
const SimpleFFS::RECORD_SEPARATOR = "\0" |