OPiQuotations  v.02.00.00 — October 26, 2015
 All Classes Namespaces Files Functions Variables Pages
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)
 Construct a quotation/maxim.
 author ()
 Return null or the author of the quotation.
 id ()
 Return the id of the quotation/maxim.
 is_maxim ()
 Return true if is a maxim (of a possibly nation), false if is a quotation (of a possibly author).
 is_marked ()
 Return true if is a marked quotation/maxim, else false.
 nation ()
 Return null or the nation of the maxim.
 subject ()
 Return null or the subject of the quotation/maxim.
 text ()
 Return the text of the quotation/maxim.
 to_html ($search=null, $add_link=true, $link_target=null, $subject_tag='h2', $uneOPiCitation_link='uneOPiCitation.php')
 Return the complete quotation/maxim in a HTML format.
 to_text ()
 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)).
 to_text_facebook ($url='')
 Return the quotation/maxim with its author/nation and work in text format to post to Facebook.
 to_text_twitter ($url=null, $short_url_length=null, $max_length=140)
 Return the quotation/maxim with its author/nation and work in short text format to post to Twitter.
 translation ()
 Return null or the translation of the quotation/maxim.
 work ()
 Return null or the work of the quotation.

Protected Attributes

 $author
 null or the author of the quotation if is a quotation, else null.
 $id
 The id of the quotation/maxim (must be > 0).
 $is_marked
 true if marked quotation/maxim, else false.
 $is_maxim
 true if maxim (of a possibly nation), false if quotation (of an possibly author)
 $nation
 null or the nation of the maxim if is a maxim, else null.
 $subject
 null or the subject of the quotation/maxim.
 $text
 Text of the quotation/maxim.
 $translation
 null or the translation of the quotation/maxim.
 $work
 null or the work of the quotation if is a quotation, else null.

Static Private Member Functions

static _format_correct_html ($s)
 Return $s formatted in HTML to be displayed.
static _highlight_html ($s, $search=null)
 If $search !== null then each occurence of $search is surrounded by '<span class="highlight">' and '</span>'.

Detailed Description

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

Definition at line 24 of file OPiQuotation.inc.

Constructor & Destructor Documentation

OPiQuotations\OPiQuotation::__construct (   $id,
  $text,
  $is_maxim = false,
  $is_marked = false,
  $translation = null,
  $subject = null,
  $nation_author = null,
  $work = null 
)

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)

Definition at line 40 of file OPiQuotation.inc.

References $text.

Member Function Documentation

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 90 of file OPiQuotation.inc.

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

If $search !== null then each occurence of $search is surrounded by '<span class="highlight">' and '</span>'.

Parameters
string$s
null | string$search
Returns
string

Definition at line 143 of file OPiQuotation.inc.

References $search.

OPiQuotations\OPiQuotation::author ( )

Return null or the author of the quotation.

Returns
null|string

Definition at line 174 of file OPiQuotation.inc.

OPiQuotations\OPiQuotation::id ( )

Return the id of the quotation/maxim.

Returns
id > 0

Definition at line 187 of file OPiQuotation.inc.

OPiQuotations\OPiQuotation::is_marked ( )

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

Returns
bool

Definition at line 211 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).

Returns
bool

Definition at line 199 of file OPiQuotation.inc.

OPiQuotations\OPiQuotation::nation ( )

Return null or the nation of the maxim.

Returns
null|string

Definition at line 222 of file OPiQuotation.inc.

OPiQuotations\OPiQuotation::subject ( )

Return null or the subject of the quotation/maxim.

Returns
null|string

Definition at line 235 of file OPiQuotation.inc.

OPiQuotations\OPiQuotation::text ( )

Return the text of the quotation/maxim.

Returns
string

Definition at line 246 of file OPiQuotation.inc.

References $text.

OPiQuotations\OPiQuotation::to_html (   $search = null,
  $add_link = true,
  $link_target = null,
  $subject_tag = 'h2',
  $uneOPiCitation_link = 'uneOPiCitation.php' 
)

Return the complete quotation/maxim in a HTML format.

 Layout
 - for a quotation:
@code 

id subject (mark) text | translation author work *

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 '<span class="highlight">' and '</span>'.

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.

$uneOPiCitation_link is use to the external id link.

Parameters
null | string$search
bool$add_link
null | string$link_target
string$subject_tag
string$uneOPiCitation_link
Returns
string

Definition at line 299 of file OPiQuotation.inc.

References $search.

OPiQuotations\OPiQuotation::to_text ( )

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

Returns
string

Definition at line 410 of file OPiQuotation.inc.

OPiQuotations\OPiQuotation::to_text_facebook (   $url = '')

Return the quotation/maxim with its author/nation and work in text format to post to Facebook.

If url !== '' then add url to the end on a newline.

Parameters
string$url
Returns
string

Definition at line 458 of file OPiQuotation.inc.

References $url.

OPiQuotations\OPiQuotation::to_text_twitter (   $url = null,
  $short_url_length = null,
  $max_length = 140 
)

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. See https://dev.twitter.com/docs/tco-link-wrapper/faq#How_do_I_calculate_if_a_Tweet_with_a_link_is_going_to_be_over_140_characters_or_not

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)
Returns
string

Definition at line 498 of file OPiQuotation.inc.

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

OPiQuotations\OPiQuotation::translation ( )

Return null or the translation of the quotation/maxim.

Returns
null|string

Definition at line 529 of file OPiQuotation.inc.

OPiQuotations\OPiQuotation::work ( )

Return null or the work of the quotation.

Returns
null|string

Definition at line 540 of file OPiQuotation.inc.

Member Data Documentation

null string OPiQuotations\OPiQuotation::$author
protected

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

Definition at line 553 of file OPiQuotation.inc.

int OPiQuotations\OPiQuotation::$id
protected

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

Definition at line 559 of file OPiQuotation.inc.

bool OPiQuotations\OPiQuotation::$is_marked
protected

true if marked quotation/maxim, else false.

Definition at line 566 of file OPiQuotation.inc.

bool OPiQuotations\OPiQuotation::$is_maxim
protected

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

Definition at line 573 of file OPiQuotation.inc.

null string OPiQuotations\OPiQuotation::$nation
protected

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

Definition at line 580 of file OPiQuotation.inc.

null string OPiQuotations\OPiQuotation::$subject
protected

null or the subject of the quotation/maxim.

Definition at line 586 of file OPiQuotation.inc.

string OPiQuotations\OPiQuotation::$text
protected

Text of the quotation/maxim.

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

Definition at line 595 of file OPiQuotation.inc.

null string OPiQuotations\OPiQuotation::$translation
protected

null or the translation of the quotation/maxim.

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

Definition at line 604 of file OPiQuotation.inc.

string null OPiQuotations\OPiQuotation::$work
protected

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

Definition at line 611 of file OPiQuotation.inc.


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