/** * Parsing a description, in order to replace shortcodes with their HTML codes. * * Internal and reusable method to do it. * @param string $description The description */ protected function updateDescription($description) { $shortcodeTags = array(); if (!preg_match_all(Diaporama::SHORTCODETAG_HTMLENTITIES_REGEX, $description, $shortcodeTags)) { return $description; } // Array with all the captured shortcodes once $shortcodeTags = array_unique($shortcodeTags[0]); $diaporamaHtmlCodes = array(); foreach ($shortcodeTags as $shortcodeTag) { $toParseshortcodeTag = str_replace(['£', ' '], ['£', ' '], $shortcodeTag); sscanf($toParseshortcodeTag, "[£ %s £]", $shortcode); if (Diaporama::existsByShortcode($shortcode)) { $diaporamaHtmlCodes[$shortcodeTag] = $this->getShortcodeHTML($shortcode, 200, 100); } } return str_replace(array_keys($diaporamaHtmlCodes), array_values($diaporamaHtmlCodes), $description); }