phpTypography Action Methods

This draft of the doc­u­men­ta­tion remains imma­ture. While we have made attempt to be thor­ough and accu­rate, you may encounter errors. If you dis­cover any defi­cien­cies, please let us know at info@​kingdesk.​com

This page is a sub­set of the doc­u­men­ta­tion of the func­tion­al­ity pro­vided by the PHP Typog­ra­phy project.

php­Ty­pog­ra­phy Action Methods

return to top

process()

Descrip­tion

string process ( string $html [ , bool $isTitle = FALSE ] )

A method of class php­Ty­pog­ra­phy. This method typo­graph­i­cally processes the pro­vided html accord­ing to the attrib­utes set in the set­tings meth­ods and returns the results.

Para­me­ters

html
REQUIRED. A string of HTML code which should be sub­ject to typo­graphic processing.
isTi­tle
OPTIONAL. When work­ing with Con­tent Man­age­ment Sys­tem out­put, one com­monly acquires page (or arti­cle) titles that lack HTML tags that would com­mu­ni­cate to php­Ty­pog­ra­phy its con­text. This option allows the func­tion to know it is deal­ing with a head­ing, even though it lacks the ordi­nary HTML head­ing ele­ments. Defaults to FALSE.

Return Val­ues

Returns the typo­graph­i­cally processed html.

Exam­ples


<?php
$html = "raw HTML here... ";

include('path/to/php-typography.php');
$typo = new phpTypography();
$html = $typo->process($html);

echo $html;
?>

return to top

process_​feed()

Descrip­tion

string process_feed ( string $html [ , bool $isTitle = FALSE ] )

A method of class php­Ty­pog­ra­phy. Feed read­ers are often less than sophis­ti­cated in their han­dling of non-​​ASCII char­ac­ters. To avoid com­pli­ca­tions, this method does the bare min­i­mum in pro­cess­ing html accord­ing to the attrib­utes set in the set­tings meth­ods and returns the results. The only mod­i­fi­ca­tion of html that occurs is: intel­li­gent char­ac­ter replace­ment of quotemarks, dashes, ellipses and trademarks.

Para­me­ters

html
REQUIRED. A string of HTML code which should be sub­ject to typo­graphic processing.
isTi­tle
OPTIONAL. When work­ing with Con­tent Man­age­ment Sys­tem out­put, one com­monly acquires page (or arti­cle) titles that lack HTML tags that would com­mu­ni­cate to php­Ty­pog­ra­phy its con­text. This option allows the func­tion to know it is deal­ing with a head­ing, even though it lacks the ordi­nary HTML head­ing ele­ments. Defaults to FALSE.

Return Val­ues

Returns the typo­graph­i­cally processed html.

Exam­ples


<?php
$html = "raw HTML here... ";

include('path/to/php-typography.php');
$typo = new phpTypography();
$html = $typo->process_feed($html);

echo $html;
?>

return to top

get_​languages()

Descrip­tion

array get_languages ( )

A method of class php­Ty­pog­ra­phy. This method returns a com­plete list of lan­guage hyphen­ation pat­terns that are avail­able for use.

Return Val­ues

Returns an array of lan­guage codes and lan­guage names in the form of array( language code => language name ) for lan­guage files saved to the ‘/​php-​​typography/​lang/​’ directory.

Exam­ples


<?php
include('path/to/php-typography.php');
$typo = new phpTypography();
$langCodes = $typo->get_languages();
?>

<form action="/" method="get">	
<label for="languageCode">Hyphenation Language Pattern:</label>
<select name="languageCode" id="languageCode">
	<?php foreach($langCodes as $langCode => $langName): ?>
	<option value='<?php echo $langCode ?>'><?php echo $langName ?></option>
	<?php endforeach; ?>
</select>
<input type="submit" name="langSubmit" value="Submit" id="langSubmit">
</form>

return to top

get_​diacritic_​languages()

Descrip­tion

array get_diacritic_languages ( )

A method of class php­Ty­pog­ra­phy. This method returns a com­plete list of lan­guage spe­cific dia­critic replace­ment pat­terns that are avail­able for use.

Return Val­ues

Returns an array of all lan­guage codes and lan­guage names in the form of array( language code => language name ) for lan­guage files saved to the ‘/​php-​​typography/​diacritics/​’ directory.

Exam­ples


<?php
include('path/to/php-typography.php');
$typo = new phpTypography();
$langCodes = $typo->get_diacritic_languages();
?>

<form action="/" method="get">	
<label for="languageCode">Language specific diacritic replacement pattern:</label>
<select name="languageCode" id="languageCode">
	<?php foreach($langCodes as $langCode => $langName): ?>
	<option value='<?php echo $langCode ?>'><?php echo $langName ?></option>
	<?php endforeach; ?>
</select>
<input type="submit" name="langSubmit" value="Submit" id="langSubmit">
</form>

return to top