diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index f4e1177..3d237e6 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -757,12 +757,19 @@ function hasPart($areaName) /** * get parts of area * @param $areaName + * @param null $custom custom theme * @return Part[]|\Illuminate\Database\Eloquent\Collection|\LaravelIdea\Helper\App\Models\_IH_Part_C */ -function getParts($areaName) +function getParts($areaName, $custom = null) { - $a = Area::where('name', $areaName)->first(); - return $a->parts()->orderBy('sort')->get(); + if ($custom != null) { + + $customs = Part::where('custom', $custom)->orderBy('sort'); + if ($customs->count() > 0) { + return $customs->get(); + } + } + return Area::where('name', $areaName)->first()->parts()->orderBy('sort')->get(); } @@ -1278,7 +1285,8 @@ function sendingSMS($text, $number, $args) * @param $html * @return array */ -function generateTOC($html) { +function generateTOC($html) +{ // Load HTML into a DOMDocument for parsing $doc = new DOMDocument(); @$doc->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8')); @@ -1333,7 +1341,8 @@ function generateTOC($html) { * @param $counter * @return string */ -function generateHeadingID($text, $counter) { +function generateHeadingID($text, $counter) +{ // Convert to lowercase and replace non-alphanumeric characters with dashes $id = strtolower(preg_replace('/[^a-zA-Z0-9]+/', '-', $text)); @@ -1352,7 +1361,8 @@ function generateHeadingID($text, $counter) { } // The buildTOC function remains unchanged -function buildTOC($items) { +function buildTOC($items) +{ $html = '