コード例 #1
0
@if(get_class($errors) == 'Illuminate\Support\ViewErrorBag' && $errors->any())

@section('scripts')
@parent
<script>
$(function(){
<?php 
foreach ($errors->getMessages() as $field => $messages) {
    echo 'Validaty.error("' . jse($field) . '", "' . jse(implode(' ', $messages)) . '");';
}
?>
});
</script>
@stop

@endif
コード例 #2
0
ファイル: html.php プロジェクト: rtconner/conner
/**
 * $result = html\to_dom("<html><head><title>teste</title></head><body style='background:red;'>ola <span id='testando'>teste</span> do mundo</body></html>"); // gets a array with id of the first Child and the code of the rest..
 * echo $result["code"]; // to show the code
 * echo "document.body.appendChild(".$result["id"].")"; // To show the result in document.body
 */
function to_dom($html)
{
    if (is_string($html)) {
        $type = "string";
    } else {
        $type = get_class($html);
    }
    switch ($type) {
        case "DOMDocument":
        case "DOMElement":
            $id = $html->nodeName . "_" . md5(uniqid()) . "_element";
            if ($html->nodeName != "#document") {
                $code = "var " . $id . " = document.createElement('" . $html->nodeName . "');\n";
            } else {
                $code = "";
            }
            if (!!$html->attributes) {
                foreach ($html->attributes as $attr) {
                    $code .= $id . ".setAttribute('" . $attr->name . "', '" . jse($attr->value) . "');\n";
                }
            }
            if (!!$html->childNodes) {
                foreach ($html->childNodes as $child) {
                    if ($child->nodeType == XML_TEXT_NODE) {
                        $code .= $id . ".appendChild(document.createTextNode('" . htmlentities(strip_nl($child->nodeValue)) . "'));\n";
                    } else {
                        $element = to_dom($child);
                        $code .= $element["code"];
                        if ($html->nodeName != "#document") {
                            $code .= $id . ".appendChild(" . $element["id"] . ");\n";
                        } else {
                            $id = $element["id"];
                        }
                    }
                }
            }
            return array("code" => $code, "id" => $id);
            break;
        case "DOMDocumentType":
            return array("code" => "", "id" => "");
            break;
        default:
        case "string":
            $dom = new DOMDocument();
            $dom->strictErrorChecking = false;
            $dom->loadHTML($html);
            $result = to_dom($dom);
            return $result;
            break;
    }
    return NULL;
}