Newer
Older
<?php
/**
* Copyright Maarch since 2008 under licence GPLv3.
* See LICENCE.txt file at the root folder for more details.
* This file is part of Maarch software.
*
*/
/**
* @brief Text Format Model Abstract
* @author dev@maarch.org
* @ingroup core
*/
namespace Core\Models;
class TextFormatModelAbstract
{
public static function normalize(array $aArgs)
{
ValidatorModel::notEmpty($aArgs, ['string']);
ValidatorModel::stringType($aArgs, ['string']);
$a = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ';
$b = 'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr';
$string = utf8_decode($aArgs['string']);
$string = strtr($string, utf8_decode($a), $b);
$string = strtolower($string);
return utf8_encode($string);
}

Alex ORLUC
committed

Alex ORLUC
committed
{
$last_date = '';
if(!empty($date)) {
if(strpos($date, " ")) {
$date_ex = explode(" ", $date);
$the_date = explode("-", $date_ex[0]);
$last_date = $the_date[2]."-".$the_date[1]."-".$the_date[0];
} else {
$the_date = explode("-", $date);
$last_date = $the_date[2]."-".$the_date[1]."-".$the_date[0];

Alex ORLUC
committed
}
}

Alex ORLUC
committed
return $last_date;
}
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
ValidatorModel::notEmpty($aArgs, ['string']);
ValidatorModel::stringType($aArgs, ['string', 'charset']);
if(empty($aArgs['charset'])){
$aArgs['charset'] = 'utf-8';
}
$string = htmlentities($aArgs['string'], ENT_NOQUOTES, $aArgs['charset']);
$string = preg_replace('#\&([A-za-z])(?:uml|circ|tilde|acute|grave|cedil|ring)\;#', '\1', $string);
$string = preg_replace('#\&([A-za-z]{2})(?:lig)\;#', '\1', $string);
$string = preg_replace('#\&[^;]+\;#', '', $string);
return $string;
}
public static function htmlWasher($html, $mode = 'unicode')
{
if ($mode == 'unicode') {
$html = str_replace("<br/>", "\\n", $html);
$html = str_replace("<br />", "\\n", $html);
$html = str_replace("<br/>", "\\n", $html);
$html = str_replace(" ", " ", $html);
$html = str_replace("é", "\u00e9", $html);
$html = str_replace("è", "\u00e8", $html);
$html = str_replace("ê", "\00ea", $html);
$html = str_replace("à", "\u00e0", $html);
$html = str_replace("â", "\u00e2", $html);
$html = str_replace("î", "\u00ee", $html);
$html = str_replace("ô", "\u00f4", $html);
$html = str_replace("û", "\u00fb", $html);
$html = str_replace("´", "\u0027", $html);
$html = str_replace("°", "\u00b0", $html);
$html = str_replace("’", "\u2019", $html);
} else {
$html = str_replace("<br/>", "\\n", $html);
$html = str_replace("<br />", "\\n", $html);
$html = str_replace("<br/>", "\\n", $html);
$html = str_replace(" ", " ", $html);
$html = str_replace("é", "é", $html);
$html = str_replace("è", "è", $html);
$html = str_replace("ê", "ê", $html);
$html = str_replace("à", "à", $html);
$html = str_replace("â", "â", $html);
$html = str_replace("î", "î", $html);
$html = str_replace("ô", "ô", $html);
$html = str_replace("û", "û", $html);
$html = str_replace("´", "", $html);
$html = str_replace("°", "°", $html);
$html = str_replace("’", "'", $html);
}