コード例 #1
0
ファイル: menu.php プロジェクト: ppnieto/moriarti
<?php

Moriarti::register(9, '/view/adminlte/private/*', function ($code, $data) {
    $view = explode('/', $code)[4];
    $doc = Moriarti::get('view');
    $list = DOMUtil::findElementsByClassName('sidebar-menu')->item(0);
    $item = $list->firstChild;
    foreach (Moriarti::get('userMenu') as $menu) {
        $menuref = str_replace(' ', '', strtolower($menu));
        $newItem = $item->cloneNode(true);
        $list->appendChild($newItem);
        DOMUtil::xpathQuery('.//span', $newItem)->item(0)->nodeValue = $menu;
        DOMUtil::xpathQuery('.//a/@href', $newItem)->item(0)->nodeValue = $menuref;
        if ($view === $menuref) {
            $newItem->setAttribute('class', 'active');
        }
    }
    $item->parentNode->removeChild($item);
});
コード例 #2
0
ファイル: messages.php プロジェクト: ppnieto/moriarti
<?php

Moriarti::register(3, '/view/adminlte/private/*', function ($code, $data) {
    $doc = Moriarti::get('view');
    DOMUtil::findElementsByClassName('messages-text')->item(0)->nodeValue = 'Tienes 100 mensajes';
    DOMUtil::findElementsByClassName('messages-count')->item(0)->nodeValue = 100;
});
コード例 #3
0
ファイル: notifications.php プロジェクト: ppnieto/moriarti
<?php

Moriarti::register(9, '/view/adminlte/*', function ($code, $data) {
    // show warnings
    $doc = Moriarti::get('view');
    $notifications = $doc->getElementByID('notifications');
    if ($notifications != null) {
        $content = file_get_contents(__DIR__ . '/view/notifications/warning.html');
        $warningDoc = DOMUtil::parseHTML($content);
        foreach (Moriarti::getArr('warning') as $warningTxt) {
            DOMUtil::findElementsByClassName('warning-message', $warningDoc)->item(0)->nodeValue = $warningTxt;
            DOMUtil::importDOM($notifications, $warningDoc);
        }
        $content = file_get_contents(__DIR__ . '/view/notifications/error.html');
        $errorDoc = DOMUtil::parseHTML($content);
        foreach (Moriarti::getArr('error') as $errorTxt) {
            DOMUtil::findElementsByClassName('error-message', $errorDoc)->item(0)->nodeValue = $errorTxt;
            DOMUtil::importDOM($notifications, $errorDoc);
        }
        $content = file_get_contents(__DIR__ . '/view/notifications/info.html');
        $infoDoc = DOMUtil::parseHTML($content);
        foreach (Moriarti::getArr('info') as $infoTxt) {
            DOMUtil::findElementsByClassName('info-message', $infoDoc)->item(0)->nodeValue = $infoTxt;
            DOMUtil::importDOM($notifications, $infoDoc);
        }
    }
});