diff options
Diffstat (limited to 'class/class.art.php')
-rw-r--r-- | class/class.art.php | 93 |
1 files changed, 72 insertions, 21 deletions
diff --git a/class/class.art.php b/class/class.art.php index f945767..0e87b6c 100644 --- a/class/class.art.php +++ b/class/class.art.php @@ -1,7 +1,6 @@ <?php use Michelf\Markdown; -use Michelf\MarkdownExtra; class Art @@ -19,12 +18,15 @@ class Art private $couleurtext; private $couleurbkg; private $couleurlien; + private $couleurlienblank; + private $lien; - private static $len = 255; - private static $lenhtml = 65535; - private static $securemax = 2; - private static $lencouleur = 7; - + const LEN = 255; + const LENHTML = 20000; + const SECUREMAX = 2; + const LENCOULEUR = 7; + const DEBUT = '(?id='; + const FIN = ')'; // _____________________________________________________ F U N ____________________________________________________ @@ -53,13 +55,39 @@ class Art $this->setintro('resumé'); $this->settag('sans tag,'); $this->setdatecreation($now); - $this->setcss('article {} + $this->setcss('section {} a:hover {}'); $this->sethtml('contenu'); $this->setsecure(2); $this->setcouleurtext('#000000'); $this->setcouleurbkg('#FFFFFF'); $this->setcouleurlien('#000000'); + $this->setcouleurlienblank('#000000'); + $this->setlien(''); + } + + public function updatelien() + { + function search($haystack, $debut, $fin) + { + $list = []; + + $indexdebut = strpos($haystack, $debut); + if ($indexdebut !== false) { + $indexdebut += strlen($debut); + $indexfin = strpos($haystack, $fin, $indexdebut); + if ($indexfin !== false) { + //$indexfin -= strlen($fin); + array_push($list, substr($haystack, $indexdebut, $indexfin - $indexdebut)); + $haystack = substr($haystack, $indexfin); + $list = array_merge($list, search($haystack, $debut, $fin)); + } + } + return $list; + + } + $this->lien = search($this->html('md'), self::DEBUT, self::FIN); + } // _____________________________________________________ G E T ____________________________________________________ @@ -123,8 +151,8 @@ a:hover {}'); if ($option == 'md') { return $this->html; } elseif ($option == 'html') { - $html = MarkdownExtra::defaultTransform($this->html); - $htmla = str_replace('href="http://', ' class="external" target="_blank" href="http://', $html); + $html = Markdown::defaultTransform($this->html); + $htmla = str_replace('href="http', ' class="external" target="_blank" href="http', $html); $htmla = str_replace('class="b"', ' target="_blank" ', $htmla); $htmlmedia = str_replace('src="/', 'src="../media/', $htmla); @@ -157,41 +185,53 @@ a:hover {}'); return $this->couleurlienblank; } + public function lien($option) + { + if ($option == 'string') { + $lien = implode(", ", $this->lien); + } elseif ($option == 'array') { + $lien = $this->lien; + } + return $lien; + + } + + // _____________________________________________________ S E T ____________________________________________________ public function setid($id) { - if (strlen($id) < self::$len and is_string($id)) { + if (strlen($id) < self::LEN and is_string($id)) { $this->id = strip_tags(strtolower(str_replace(" ", "", $id))); } } public function settitre($titre) { - if (strlen($titre) < self::$len and is_string($titre)) { + if (strlen($titre) < self::LEN and is_string($titre)) { $this->titre = strip_tags(trim($titre)); } } public function setsoustitre($soustitre) { - if (strlen($soustitre) < self::$len and is_string($soustitre)) { + if (strlen($soustitre) < self::LEN and is_string($soustitre)) { $this->soustitre = strip_tags(trim($soustitre)); } } public function setintro($intro) { - if (strlen($intro) < self::$len and is_string($intro)) { + if (strlen($intro) < self::LEN and is_string($intro)) { $this->intro = strip_tags(trim($intro)); } } public function settag($tag) { - if (strlen($tag) < self::$len and is_string($tag)) { + if (strlen($tag) < self::LEN and is_string($tag)) { $tag = strip_tags(trim(strtolower($tag))); $taglist = explode(", ", $tag); $this->tag = $taglist; @@ -218,21 +258,21 @@ a:hover {}'); public function setcss($css) { - if (strlen($css) < self::$len and is_string($css)) { + if (strlen($css) < self::LEN and is_string($css)) { $this->css = strip_tags(trim(strtolower($css))); } } public function sethtml($html) { - if (strlen($html) < self::$lenhtml and is_string($html)) { + if (strlen($html) < self::LENHTML and is_string($html)) { $this->html = $html; } } public function setsecure($secure) { - if ($secure >= 0 and $secure <= self::$securemax) { + if ($secure >= 0 and $secure <= self::SECUREMAX) { $this->secure = intval($secure); } } @@ -240,7 +280,7 @@ a:hover {}'); public function setcouleurtext($couleurtext) { $couleurtext = strval($couleurtext); - if (strlen($couleurtext) <= self::$lencouleur) { + if (strlen($couleurtext) <= self::LENCOULEUR) { $this->couleurtext = strip_tags(trim($couleurtext)); } } @@ -248,7 +288,7 @@ a:hover {}'); public function setcouleurbkg($couleurbkg) { $couleurbkg = strval($couleurbkg); - if (strlen($couleurbkg) <= self::$lencouleur) { + if (strlen($couleurbkg) <= self::LENCOULEUR) { $this->couleurbkg = strip_tags(trim($couleurbkg)); } } @@ -256,7 +296,7 @@ a:hover {}'); public function setcouleurlien($couleurlien) { $couleurlien = strval($couleurlien); - if (strlen($couleurlien) <= self::$lencouleur) { + if (strlen($couleurlien) <= self::LENCOULEUR) { $this->couleurlien = strip_tags(trim($couleurlien)); } } @@ -264,11 +304,22 @@ a:hover {}'); public function setcouleurlienblank($couleurlienblank) { $couleurlienblank = strval($couleurlienblank); - if (strlen($couleurlienblank) <= self::$lencouleur) { + if (strlen($couleurlienblank) <= self::LENCOULEUR) { $this->couleurlienblank = strip_tags(trim($couleurlienblank)); } } + public function setlien($lien) + { + if (!empty($lien) && strlen($lien) < self::LEN && is_string($lien)) { + $lien = strip_tags(trim(strtolower($lien))); + $lienlist = explode(", ", $lien); + $this->lien = $lienlist; + } else { + $this->lien = []; + } + } + } |