Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
tool_customlang\local\mlang\langstring Class Reference

Class containing a lang string cleaned. More...

Public Member Functions

 __construct (string $id, string $text='', int $timemodified=null, int $deleted=0, stdclass $extra=null)
 Class constructor.
 

Static Public Member Functions

static fix_syntax (string $text, int $format=2, ?int $from=null)
 Given a string text, returns it being formatted properly for storing in AMOS repository.
 

Public Attributes

bool $deleted = false
 is deleted
 
stdclass $extra = null
 extra information about the string
 
string $id = null
 identifier
 
string $text = ''
 
int $timemodified = null
 the time stamp when this string was saved
 

Detailed Description

Class containing a lang string cleaned.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later Represents a single string

Constructor & Destructor Documentation

◆ __construct()

tool_customlang\local\mlang\langstring::__construct ( string $id,
string $text = '',
int $timemodified = null,
int $deleted = 0,
stdclass $extra = null )

Class constructor.

Parameters
string$idstring identifier
string$textstring text
int$timemodified
int$deleted
stdclass$extra

Member Function Documentation

◆ fix_syntax()

static tool_customlang\local\mlang\langstring::fix_syntax ( string $text,
int $format = 2,
?int $from = null )
static

Given a string text, returns it being formatted properly for storing in AMOS repository.

Note: This method is taken directly from local_amos as it is highly tested and robust. The Moodle 1.x part is keep on puspose to make it easier the copy paste from both codes. This could change in the future when AMOS stop suporting the 1.x langstrings.

We need to know for what branch the string should be prepared due to internal changes in format required by get_string()

  • for get_string() in Moodle 1.6 - 1.9 use $format == 1
  • for get_string() in Moodle 2.0 and higher use $format == 2

Typical usages of this methods: $t = langstring\fix_syntax($t); // sanity new translations of 2.x strings $t = langstring\fix_syntax($t, 1); // sanity legacy 1.x strings $t = langstring\fix_syntax($t, 2, 1); // convert format of 1.x strings into 2.x

Backward converting 2.x format into 1.x is not supported

Parameters
string$textstring text to be fixed
int$formattarget get_string() format version
int$fromwhich format version does the text come from, defaults to the same as $format
Return values
string

The documentation for this class was generated from the following file: