function RenderButtonGroup($body) { // Get all inputs // format: <input ...> $inputs = array(); if (preg_match_all('/<input\\s+([^>]*)>/i', $body, $inputmatches, PREG_SET_ORDER)) { foreach ($inputmatches as $inputmatch) { $body = str_replace($inputmatch[0], '', $body); $inputs[] = $inputmatch[0]; } } // Get all buttons // format: <div class="btn-group">...</div> $btns = array(); if (preg_match_all('/<div\\s+class\\s*=\\s*[\'"]btn-group[\'"]([^>]*)>([\\s\\S]*?)<\\/div\\s*>/i', $body, $btnmatches, PREG_SET_ORDER)) { foreach ($btnmatches as $btnmatch) { $body = str_replace($btnmatch[0], '', $body); $btns[] = $btnmatch[0]; } } $links = ''; // Get all links // format: <a ...>...</a> if (preg_match_all('/<a([^>]*)>([\\s\\S]*?)<\\/a\\s*>/i', $body, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { if (preg_match('/\\s+class\\s*=\\s*[\'"]([\\s\\S]*?)[\'"]/i', $match[1], $submatches)) { // Match class='class' $class = $submatches[1]; $attrs = str_replace($submatches[0], '', $match[1]); } else { $class = ''; $attrs = $match[1]; } $caption = $match[2]; ew_PrependClass($class, 'btn'); // Prepend button classes if ($this->ButtonClass != "") { ew_AppendClass($class, $this->ButtonClass); } $attrs = ' class="' . $class . '" ' . $attrs; $link = '<a' . $attrs . '>' . $caption . '</a>'; $links .= $link; } } if ($links != "") { $btngroup = '<div class="btn-group ewButtonGroup">' . $links . '</div>'; } else { $btngroup = ""; } foreach ($btns as $btn) { $btngroup .= $btn; } foreach ($inputs as $input) { $btngroup .= $input; } return $btngroup; }
function RenderButtonGroup($body) { // Get all hidden inputs // format: <input type="hidden" ...> $inputs = array(); if (preg_match_all('/<input\\s+([^>]*)>/i', $body, $inputmatches, PREG_SET_ORDER)) { foreach ($inputmatches as $inputmatch) { $body = str_replace($inputmatch[0], '', $body); if (preg_match('/\\s+type\\s*=\\s*[\'"]hidden[\'"]/i', $inputmatch[0])) { // Match type='hidden' $inputs[] = $inputmatch[0]; } } } // Get all buttons // format: <div class="btn-group">...</div> $btns = array(); if (preg_match_all('/<div\\s+class\\s*=\\s*[\'"]btn-group[\'"]([^>]*)>([\\s\\S]*?)<\\/div\\s*>/i', $body, $btnmatches, PREG_SET_ORDER)) { foreach ($btnmatches as $btnmatch) { $body = str_replace($btnmatch[0], '', $body); $btns[] = $btnmatch[0]; } } $links = ''; // Get all links/buttons // format: <a ...>...</a> / <button ...>...</button> if (preg_match_all('/<(a|button)([^>]*)>([\\s\\S]*?)<\\/(a|button)\\s*>/i', $body, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { $tag = $match[1]; if (preg_match('/\\s+class\\s*=\\s*[\'"]([\\s\\S]*?)[\'"]/i', $match[2], $submatches)) { // Match class='class' $class = $submatches[1]; $attrs = str_replace($submatches[0], '', $match[2]); } else { $class = ''; $attrs = $match[2]; } $caption = $match[3]; if (strpos($class, 'btn btn-default') === FALSE) { // Prepend button classes ew_PrependClass($class, 'btn btn-default'); } if ($this->ButtonClass != "") { ew_AppendClass($class, $this->ButtonClass); } $attrs = ' class="' . $class . '" ' . $attrs; $link = '<' . $tag . $attrs . '>' . $caption . '</' . $tag . '>'; $links .= $link; } } if ($links != "") { $btngroup = '<div class="btn-group ewButtonGroup">' . $links . '</div>'; } else { $btngroup = ""; } foreach ($btns as $btn) { $btngroup .= $btn; } foreach ($inputs as $input) { $btngroup .= $input; } return $btngroup; }
function Render($aclass = "", $liclass = "", $mobile = FALSE) { // Create <A> $url = ew_GetUrl($this->Url); if (!is_null($this->SubMenu)) { $submenuhtml = $this->SubMenu->Render(TRUE); } else { $submenuhtml = ""; } if ($mobile) { $url = str_replace("#", "?chart=", $url); if ($url == "") { $url = "#"; } $attrs = array("class" => $aclass, "rel" => $url != "#" ? "external" : "", "href" => $url, "target" => $this->Target); } else { if ($url == "") { $url = "#"; } if (!is_null($this->SubMenu) && $this->SubMenu->MenuLinkDropdownClass != "" && $submenuhtml != "") { ew_PrependClass($aclass, $this->SubMenu->MenuLinkDropdownClass); } $attrs = array("class" => $aclass, "href" => $url, "target" => $this->Target); } $text = $this->Text; if (!is_null($this->SubMenu) && $submenuhtml != "") { if ($this->Parent->SubMenuDropdownIconClassName != "") { $text .= "<span class=\"" . $this->Parent->SubMenuDropdownIconClassName . "\"></span>"; } if ($this->Parent->SubMenuDropdownImage != "" && $this->ParentId == -1) { $text .= $this->Parent->SubMenuDropdownImage; } } $innerhtml = ew_HtmlElement("a", $attrs, $text); if (!is_null($this->SubMenu)) { if ($url != "#" && $this->SubMenu->MenuLinkClassName != "" && $submenuhtml != "") { // Add click link for mobile menu $attrs2 = array("class" => "ewMenuLink", "href" => $url); $text2 = "<span class=\"" . $this->SubMenu->MenuLinkClassName . "\"></span>"; $innerhtml = ew_HtmlElement("a", $attrs2, $text2) . $innerhtml; } if ($mobile && $this->Url != "#") { $innerhtml .= $innerhtml; } $innerhtml .= $submenuhtml; } // Create <LI> return ew_HtmlElement("li", array("id" => $this->Name, "class" => $liclass), $innerhtml); }