OPiQuotations  v.03.00.00 — April 5, 2019
Public Member Functions | Protected Attributes | Static Private Member Functions | List of all members
OPiQuotations\OPiQuotation Class Reference

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...
 

Detailed Description

Class quotation (text, author…) or maxim (text, nation…).

Definition at line 24 of file OPiQuotation.inc.

Constructor & Destructor Documentation

◆ __construct()

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().

Parameters
int$idId of the quotation (must be > 0)
string$textText of the quotation (should not contain '@@@#' and '#@@@')
bool$is_maximtrue if maxim (of a possibly nation), false if quotation (of an possibly author)
bool$is_markedtrue if marked quotation/maxim, else false
null | string$translationPossibly translation of the text (should not contain '@@@#' and '#@@@')
null | string$subjectPossibly subject
null | string$nation_authorPossibly nation if maxim, else possibly author
null | string$workPossibly work if quotation (must be null if $is_maxim)
null | string$text_langLanguage of text
null|Selection[]$selections List of Selection
bool$is_misattributedtrue if the quotation/maxim is misattributed to its author, else false

Definition at line 43 of file OPiQuotation.inc.

References $id, and $text.

Member Function Documentation

◆ _add_comme_fix()

static OPiQuotations\OPiQuotation::_add_comme_fix (   $s)
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/

Parameters
string$s
Returns
string

Definition at line 108 of file OPiQuotation.inc.

◆ _add_hashtag()

static OPiQuotations\OPiQuotation::_add_hashtag (   $s)
staticprivate

Return $s with an adding '#' character before the last word.

Parameters
string$s
Returns
string

Definition at line 137 of file OPiQuotation.inc.

◆ _format_correct_html()

static OPiQuotations\OPiQuotation::_format_correct_html (   $s)
staticprivate

Return $s formatted in HTML to be displayed.

  • HTML tags <b>, <c>, <i>, <sub>, <sup> are used (the other tags are displayed as it is).
  • The special character ¨ (diaeresis, U+00A8) is used to justify to the right.
  • Beginning (at the beginning of the line and after an end of line) double space is used to indentation.
Parameters
string$s(should not contain '@@@#' and '#@@@')
Returns
string

Definition at line 166 of file OPiQuotation.inc.

◆ _highlight_html()

static OPiQuotations\OPiQuotation::_highlight_html (   $s,
  $search = null 
)
staticprivate

If $search !== null then each occurence of $search is surrounded by '<mark>' and '</mark>'.

Parameters
string$s
null | string$search
Returns
string

Definition at line 219 of file OPiQuotation.inc.

References $search.

◆ _translate_message()

static OPiQuotations\OPiQuotation::_translate_message (   $message,
  $language 
)
staticprivate

Return a translation of the message in the language.

If don't exist in the dictionary, then return $message.

Parameters
string$message
string$language
Returns
string

Definition at line 255 of file OPiQuotation.inc.

◆ author()

OPiQuotations\OPiQuotation::author ( )

Return null or the author of the quotation.

Returns
null|string

Definition at line 304 of file OPiQuotation.inc.

◆ id()

OPiQuotations\OPiQuotation::id ( )

Return the id of the quotation/maxim.

Returns
id > 0

Definition at line 317 of file OPiQuotation.inc.

References $id.

◆ is_marked()

OPiQuotations\OPiQuotation::is_marked ( )

Return true if is a marked quotation/maxim, else false.

Returns
bool

Definition at line 341 of file OPiQuotation.inc.

◆ is_maxim()

OPiQuotations\OPiQuotation::is_maxim ( )

Return true if is a maxim (of a possibly nation), false if is a quotation (of a possibly author).

Returns
bool

Definition at line 329 of file OPiQuotation.inc.

◆ is_misattributed()

OPiQuotations\OPiQuotation::is_misattributed ( )

Return true if is the quotation/maxim is misattributed to its author, else false.

Returns
bool

Definition at line 353 of file OPiQuotation.inc.

◆ nation()

OPiQuotations\OPiQuotation::nation ( )

Return null or the nation of the maxim.

Returns
null|string

Definition at line 364 of file OPiQuotation.inc.

◆ selections()

OPiQuotations\OPiQuotation::selections ( )

Return the list of Selection.

Returns
Selection[]

Definition at line 377 of file OPiQuotation.inc.

◆ selections_add()

OPiQuotations\OPiQuotation::selections_add (   $selection)

Add a Selection to the list.

Parameters
Selection$selection

Definition at line 388 of file OPiQuotation.inc.

References $selection.

◆ subject()

OPiQuotations\OPiQuotation::subject ( )

Return null or the subject of the quotation/maxim.

Returns
null|string

Definition at line 403 of file OPiQuotation.inc.

◆ text()

OPiQuotations\OPiQuotation::text ( )

Return the text of the quotation/maxim.

Returns
string

Definition at line 414 of file OPiQuotation.inc.

References $text.

◆ text_lang()

OPiQuotations\OPiQuotation::text_lang ( )

Return null or the language of the text quotation/maxim.

Returns
null|string

Definition at line 425 of file OPiQuotation.inc.

◆ to_html()

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:

  • HTML tags <b>, <c>, <i>, <sub>, <sup> are used (the other tags are displayed as it is).
  • The special character ¨ (diaeresis, U+00A8) is used to justify to the right.
  • Beginning (at the beginning of the line and after an end of line) double space is used to indentation.

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.

Parameters
null | string$search
bool$add_link
null | string$link_target
string$subject_tag
string$one_OPiQuotation_link
string$language
Returns
string

Definition at line 477 of file OPiQuotation.inc.

References $search, and $url.

◆ to_text()

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.

Parameters
bool$add_hashtags
string$language
string$url
bool$add_subject
null|string[]$add_selections
Returns
string

Definition at line 643 of file OPiQuotation.inc.

References $quot, $selection, and $url.

◆ to_text_facebook()

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.

Parameters
string$url
string$language
null|string[]$add_selections
Returns
string

Definition at line 764 of file OPiQuotation.inc.

References $url.

◆ to_text_twitter()

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.

Parameters
null | string$url
null | int$short_url_length
int$max_length(must be > 0)
string$language
Returns
string

Definition at line 797 of file OPiQuotation.inc.

References $max_length, $quot, $short_url_length, $text, $url, and OPiQuotations\text_cut().

◆ translation()

OPiQuotations\OPiQuotation::translation ( )

Return null or the translation of the quotation/maxim.

Returns
null|string

Definition at line 838 of file OPiQuotation.inc.

◆ work()

OPiQuotations\OPiQuotation::work ( )

Return null or the work of the quotation.

Returns
null|string

Definition at line 849 of file OPiQuotation.inc.

Member Data Documentation

◆ $author

null string OPiQuotations\OPiQuotation::$author
protected

null or the author of the quotation if is a quotation, else null.

Definition at line 862 of file OPiQuotation.inc.

◆ $id

int OPiQuotations\OPiQuotation::$id
protected

The id of the quotation/maxim (must be > 0).

Definition at line 868 of file OPiQuotation.inc.

◆ $is_marked

bool OPiQuotations\OPiQuotation::$is_marked
protected

true if marked quotation/maxim, else false.

Definition at line 875 of file OPiQuotation.inc.

◆ $is_maxim

bool OPiQuotations\OPiQuotation::$is_maxim
protected

true if maxim (of a possibly nation), false if quotation (of an possibly author).

Definition at line 882 of file OPiQuotation.inc.

◆ $is_misattributed

bool OPiQuotations\OPiQuotation::$is_misattributed
protected

true if the quotation/maxim is misattributed to its author, else false.

Definition at line 889 of file OPiQuotation.inc.

◆ $nation

null string OPiQuotations\OPiQuotation::$nation
protected

null or the nation of the maxim if is a maxim, else null.

Definition at line 896 of file OPiQuotation.inc.

◆ $selections

OPiQuotations\OPiQuotation::$selections
protected

Definition at line 902 of file OPiQuotation.inc.

◆ $subject

null string OPiQuotations\OPiQuotation::$subject
protected

null or the subject of the quotation/maxim.

Definition at line 908 of file OPiQuotation.inc.

◆ $text

string OPiQuotations\OPiQuotation::$text
protected

Text of the quotation/maxim.

Maybe contains some HTML tags (see __construct()).

Definition at line 917 of file OPiQuotation.inc.

◆ $text_lang

string OPiQuotations\OPiQuotation::$text_lang
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.

◆ $translation

null string OPiQuotations\OPiQuotation::$translation
protected

null or the translation of the quotation/maxim.

Maybe contains some HTML tags (see __construct()).

Definition at line 935 of file OPiQuotation.inc.

◆ $work

null string OPiQuotations\OPiQuotation::$work
protected

null or the work of the quotation if is a quotation, else null.

Definition at line 942 of file OPiQuotation.inc.


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