OPiQuotations
v.03.00.00 — April 5, 2019
|
Class quotation (text, author…) or maxim (text, nation…). More...
Public Member Functions | |
__construct ($id, $text, $is_maxim=false, $is_marked=false, $translation=null, $subject=null, $nation_author=null, $work=null, $text_lang=null, $selections=null, $is_misattributed=false) | |
Construct a quotation/maxim. More... | |
author () | |
Return null or the author of the quotation. More... | |
id () | |
Return the id of the quotation/maxim. More... | |
is_maxim () | |
Return true if is a maxim (of a possibly nation), false if is a quotation (of a possibly author). More... | |
is_marked () | |
Return true if is a marked quotation/maxim, else false. More... | |
is_misattributed () | |
Return true if is the quotation/maxim is misattributed to its author, else false. More... | |
nation () | |
Return null or the nation of the maxim. More... | |
selections () | |
Return the list of Selection. More... | |
selections_add ($selection) | |
Add a Selection to the list. More... | |
subject () | |
Return null or the subject of the quotation/maxim. More... | |
text () | |
Return the text of the quotation/maxim. More... | |
text_lang () | |
Return null or the language of the text quotation/maxim. More... | |
to_html ($search=null, $add_link=true, $link_target=null, $subject_tag='h2', $one_OPiQuotation_link='une-OPiCitation.php', $language='en') | |
Return the complete quotation/maxim in a HTML format. More... | |
to_text ($add_hashtags=false, $language='en', $url='', $add_subject=false, $add_selections=null) | |
Return the quotation/maxim with its author/nation and work in text format (strip HTML tags <b>, <c>, <i>, <sub>, <sup> and special character ¨ (diaeresis, U+00A8)). More... | |
to_text_facebook ($url='', $language='en', $add_selections=null) | |
Return the quotation/maxim with its author/nation and work in text format to post to Facebook. More... | |
to_text_twitter ($url=null, $short_url_length=null, $max_length=279, $language='en') | |
Return the quotation/maxim with its author/nation and work in short text format to post to Twitter. More... | |
translation () | |
Return null or the translation of the quotation/maxim. More... | |
work () | |
Return null or the work of the quotation. More... | |
Protected Attributes | |
$author | |
null or the author of the quotation if is a quotation, else null. More... | |
$id | |
The id of the quotation/maxim (must be > 0). More... | |
$is_marked | |
true if marked quotation/maxim, else false. More... | |
$is_maxim | |
true if maxim (of a possibly nation), false if quotation (of an possibly author). More... | |
$is_misattributed | |
true if the quotation/maxim is misattributed to its author, else false. More... | |
$nation | |
null or the nation of the maxim if is a maxim, else null. More... | |
$selections | |
$subject | |
null or the subject of the quotation/maxim. More... | |
$text | |
Text of the quotation/maxim. More... | |
$text_lang | |
Language of text, in ISO 639-1 code: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes. More... | |
$translation | |
null or the translation of the quotation/maxim. More... | |
$work | |
null or the work of the quotation if is a quotation, else null. More... | |
Static Private Member Functions | |
static | _add_comme_fix ($s) |
Return $s with each '-' replaced by '<span class"Comme-fix">-</span>' to workaround bug with this character in the Comme-Light.ttf font. More... | |
static | _add_hashtag ($s) |
Return $s with an adding '#' character before the last word. More... | |
static | _format_correct_html ($s) |
Return $s formatted in HTML to be displayed. More... | |
static | _highlight_html ($s, $search=null) |
If $search !== null then each occurence of $search is surrounded by '<mark>' and '</mark>'. More... | |
static | _translate_message ($message, $language) |
Return a translation of the message in the language. More... | |
Class quotation (text, author…) or maxim (text, nation…).
Definition at line 24 of file OPiQuotation.inc.
OPiQuotations\OPiQuotation::__construct | ( | $id, | |
$text, | |||
$is_maxim = false , |
|||
$is_marked = false , |
|||
$translation = null , |
|||
$subject = null , |
|||
$nation_author = null , |
|||
$work = null , |
|||
$text_lang = null , |
|||
$selections = null , |
|||
$is_misattributed = false |
|||
) |
Construct a quotation/maxim.
See to_html().
int | $id | Id of the quotation (must be > 0) |
string | $text | Text of the quotation (should not contain '@@@#' and '#@@@') |
bool | $is_maxim | true if maxim (of a possibly nation), false if quotation (of an possibly author) |
bool | $is_marked | true if marked quotation/maxim, else false |
null | string | $translation | Possibly translation of the text (should not contain '@@@#' and '#@@@') |
null | string | $subject | Possibly subject |
null | string | $nation_author | Possibly nation if maxim, else possibly author |
null | string | $work | Possibly work if quotation (must be null if $is_maxim) |
null | string | $text_lang | Language of text |
null|Selection[] | $selections List of Selection | |
bool | $is_misattributed | true if the quotation/maxim is misattributed to its author, else false |
Definition at line 43 of file OPiQuotation.inc.
|
staticprivate |
Return $s with each '-' replaced by '<span class"Comme-fix">-</span>' to workaround bug with this character in the Comme-Light.ttf font.
See "Bug in dash character Comme-Light.ttf (Vernon Adams) font with recent browsers" http://www.opimedia.be/DS/webdev/bugs-list/Bug-in-dash-character-of-Comme-Light-ttf-Vernon-Adams-font-with-recent-browsers/
string | $s |
Definition at line 108 of file OPiQuotation.inc.
|
staticprivate |
Return $s with an adding '#' character before the last word.
string | $s |
Definition at line 137 of file OPiQuotation.inc.
|
staticprivate |
Return $s formatted in HTML to be displayed.
string | $s | (should not contain '@@@#' and '#@@@') |
Definition at line 166 of file OPiQuotation.inc.
|
staticprivate |
If $search !== null then each occurence of $search is surrounded by '<mark>' and '</mark>'.
string | $s | |
null | string | $search |
Definition at line 219 of file OPiQuotation.inc.
References $search.
|
staticprivate |
Return a translation of the message in the language.
If don't exist in the dictionary, then return $message.
string | $message | |
string | $language |
Definition at line 255 of file OPiQuotation.inc.
OPiQuotations\OPiQuotation::author | ( | ) |
Return null or the author of the quotation.
Definition at line 304 of file OPiQuotation.inc.
OPiQuotations\OPiQuotation::id | ( | ) |
Return the id of the quotation/maxim.
Definition at line 317 of file OPiQuotation.inc.
References $id.
OPiQuotations\OPiQuotation::is_marked | ( | ) |
Return true if is a marked quotation/maxim, else false.
Definition at line 341 of file OPiQuotation.inc.
OPiQuotations\OPiQuotation::is_maxim | ( | ) |
Return true if is a maxim (of a possibly nation), false if is a quotation (of a possibly author).
Definition at line 329 of file OPiQuotation.inc.
OPiQuotations\OPiQuotation::is_misattributed | ( | ) |
Return true if is the quotation/maxim is misattributed to its author, else false.
Definition at line 353 of file OPiQuotation.inc.
OPiQuotations\OPiQuotation::nation | ( | ) |
Return null or the nation of the maxim.
Definition at line 364 of file OPiQuotation.inc.
OPiQuotations\OPiQuotation::selections | ( | ) |
OPiQuotations\OPiQuotation::selections_add | ( | $selection | ) |
Add a Selection to the list.
Selection | $selection |
Definition at line 388 of file OPiQuotation.inc.
References $selection.
OPiQuotations\OPiQuotation::subject | ( | ) |
Return null or the subject of the quotation/maxim.
Definition at line 403 of file OPiQuotation.inc.
OPiQuotations\OPiQuotation::text | ( | ) |
Return the text of the quotation/maxim.
Definition at line 414 of file OPiQuotation.inc.
References $text.
OPiQuotations\OPiQuotation::text_lang | ( | ) |
Return null or the language of the text quotation/maxim.
Definition at line 425 of file OPiQuotation.inc.
OPiQuotations\OPiQuotation::to_html | ( | $search = null , |
|
$add_link = true , |
|||
$link_target = null , |
|||
$subject_tag = 'h2' , |
|||
$one_OPiQuotation_link = 'une-OPiCitation.php' , |
|||
$language = 'en' |
|||
) |
Return the complete quotation/maxim in a HTML format.
Layout
In text and translation:
If $search !== null then each occurence of $search founded is surrounded by '<mark>' and '</mark>'.
If $add_link then add links to id, subject, nation, author and work.
If $link_target then add a target attribut to each link.
The subject is surrounded by $subject_tag.
null | string | $search | |
bool | $add_link | |
null | string | $link_target | |
string | $subject_tag | |
string | $one_OPiQuotation_link | |
string | $language |
Definition at line 477 of file OPiQuotation.inc.
OPiQuotations\OPiQuotation::to_text | ( | $add_hashtags = false , |
|
$language = 'en' , |
|||
$url = '' , |
|||
$add_subject = false , |
|||
$add_selections = null |
|||
) |
Return the quotation/maxim with its author/nation and work in text format (strip HTML tags <b>, <c>, <i>, <sub>, <sup> and special character ¨ (diaeresis, U+00A8)).
If $add_hashtags then add '#' character before the last word of author/nation and work.
If $url !== '' then add this URL.
If $add_selections is not empty then each add selection URL for each label.
bool | $add_hashtags | |
string | $language | |
string | $url | |
bool | $add_subject | |
null|string[] | $add_selections |
Definition at line 643 of file OPiQuotation.inc.
References $quot, $selection, and $url.
OPiQuotations\OPiQuotation::to_text_facebook | ( | $url = '' , |
|
$language = 'en' , |
|||
$add_selections = null |
|||
) |
Return the quotation/maxim with its author/nation and work in text format to post to Facebook.
If url !== '' then add this URL.
If $add_selections is not empty then each add selection URL for each label.
string | $url | |
string | $language | |
null|string[] | $add_selections |
Definition at line 764 of file OPiQuotation.inc.
References $url.
OPiQuotations\OPiQuotation::to_text_twitter | ( | $url = null , |
|
$short_url_length = null , |
|||
$max_length = 279 , |
|||
$language = 'en' |
|||
) |
Return the quotation/maxim with its author/nation and work in short text format to post to Twitter.
If a cutting is required then reduce contiguous whitespaces.
Cut the result to not be longer than $max_length characters.
If url !== null then add url to the end on a newline.
If $short_url_length === null then use the real length of the url, else assume that the url will be replaced by a short url not be longer than $short_url_length.
null | string | $url | |
null | int | $short_url_length | |
int | $max_length | (must be > 0) |
string | $language |
Definition at line 797 of file OPiQuotation.inc.
References $max_length, $quot, $short_url_length, $text, $url, and OPiQuotations\text_cut().
OPiQuotations\OPiQuotation::translation | ( | ) |
Return null or the translation of the quotation/maxim.
Definition at line 838 of file OPiQuotation.inc.
OPiQuotations\OPiQuotation::work | ( | ) |
Return null or the work of the quotation.
Definition at line 849 of file OPiQuotation.inc.
|
protected |
null or the author of the quotation if is a quotation, else null.
Definition at line 862 of file OPiQuotation.inc.
|
protected |
The id of the quotation/maxim (must be > 0).
Definition at line 868 of file OPiQuotation.inc.
|
protected |
true if marked quotation/maxim, else false.
Definition at line 875 of file OPiQuotation.inc.
|
protected |
true if maxim (of a possibly nation), false if quotation (of an possibly author).
Definition at line 882 of file OPiQuotation.inc.
|
protected |
true if the quotation/maxim is misattributed to its author, else false.
Definition at line 889 of file OPiQuotation.inc.
|
protected |
null or the nation of the maxim if is a maxim, else null.
Definition at line 896 of file OPiQuotation.inc.
|
protected |
Definition at line 902 of file OPiQuotation.inc.
|
protected |
null or the subject of the quotation/maxim.
Definition at line 908 of file OPiQuotation.inc.
|
protected |
Text of the quotation/maxim.
Maybe contains some HTML tags (see __construct()).
Definition at line 917 of file OPiQuotation.inc.
|
protected |
Language of text, in ISO 639-1 code: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes.
Mainly used to specify language when there is a translation.
Definition at line 926 of file OPiQuotation.inc.
|
protected |
null or the translation of the quotation/maxim.
Maybe contains some HTML tags (see __construct()).
Definition at line 935 of file OPiQuotation.inc.
|
protected |
null or the work of the quotation if is a quotation, else null.
Definition at line 942 of file OPiQuotation.inc.