X-Git-Url: https://git-public.kairo.at/?p=php-utility-classes.git;a=blobdiff_plain;f=tests%2Fua_list.php;h=5c2e5ceede0db15c1007e7f03961142242694645;hp=3b417afd30053ccb5a604cd721e05b179fddb10e;hb=432328ee91316c002fd50137184970893ee3850b;hpb=7b9ebce7d25e4eaa557e8a64f8b1ed15aad1a9bb diff --git a/tests/ua_list.php b/tests/ua_list.php index 3b417af..5c2e5ce 100644 --- a/tests/ua_list.php +++ b/tests/ua_list.php @@ -1,65 +1,79 @@ pgtop('User Agents', $mycss); +// Start HTML document as a DOM object. +extract(ExtendedDocument::initHTML5()); // sets $document, $html, $head, $title, $body +$document->formatOutput = true; // we want a nice output -print('

User Agents

'."\n"); +$style = $head->appendElement('link'); +$style->setAttribute('rel', 'stylesheet'); +$style->setAttribute('href', 'test.css'); +$title->appendText('User Agents'); +$h1 = $body->appendElement('h1', 'User Agents'); $ualist = is_readable($uafile)?file($uafile):array(); if (count($ualist)) { - print(''."\n"); - print(' '."\n"); - print(' '."\n"); - print(' '."\n"); - print(' '."\n"); - print(' '."\n"); - print(' '."\n"); - print(' '."\n"); - print(' '."\n"); - print(' '."\n"); - print(' '."\n"); - print(' '."\n"); - print(' '."\n"); + $tbl = $body->appendElement('table'); + $tbl->setAttribute('class', 'border'); + $tbl->setAttribute('id', 'ualist'); + $thead = $tbl->appendElement('thead'); + $trow = $thead->appendElement('tr'); + $trow->appendElement('th', 'User Agent string'); + $trow->appendElement('th', 'Brand'); + $trow->appendElement('th', 'Version'); + $trow->appendElement('th', 'Bot'); + $trow->appendElement('th', 'Mob'); + $trow->appendElement('th', 'Engine'); + $trow->appendElement('th', 'eVer'); + $trow->appendElement('th', 'OS'); + $trow->appendElement('th', 'Platform'); + $trow->appendElement('th', 'Lang'); + $tbody = $tbl->appendElement('tbody'); foreach ($ualist as $uastring) { $uastring = trim($uastring); if (substr($uastring, 0, 1) == '#') { // comment - print(' '."\n"); - print(' '."\n"); - print(' '."\n"); + $trow = $tbody->appendElement('tr'); + $cell = $trow->appendElement('td', substr($uastring, 1)); + $cell->setAttribute('colspan', 10); + $cell->setAttribute('class', 'comment'); } else { $ua = new userAgent($uastring); - print(' '."\n"); - print(' '."\n"); - print(' '."\n"); - print(' '."\n"); - print(' '."\n"); - print(' '."\n"); - print(' '."\n"); - print(' '."\n"); - print(' '."\n"); - print(' '."\n"); - print(' '."\n"); - print(' '."\n"); + $trow = $tbody->appendElement('tr'); + $cell = $trow->appendElement('td', $ua->getUAString()); + $cell->setAttribute('class', 'ua'); + $trow->appendElement('td', $ua->getBrand()); + $trow->appendElement('td', $ua->getVersion()); + $trow->appendElement('td', ($ua->isBot()?'x':'-')); + $trow->appendElement('td', ($ua->isMobile()?'x':'-')); + $trow->appendElement('td', $ua->getEngine()); + $trow->appendElement('td', $ua->getEngineVersion()); + $trow->appendElement('td', $ua->getOS()); + $trow->appendElement('td', $ua->getPlatform()); + $trow->appendElement('td', $ua->getLanguage()); } } - print('
User Agent stringBrandVersionBotMobEngineeVerOSPlatformLang
'.substr($uastring, 1).'
'.$ua->getUAString().''.$ua->getBrand().''.$ua->getVersion().''.($ua->isBot()?'x':'-').''.($ua->isMobile()?'x':'-').''.$ua->getEngine().''.$ua->getEngineVersion().''.$ua->getOS().''.$ua->getPlatform().''.$ua->getLanguage().'
'."\n"); } else { - print('No User Agent strings found in file "'.$uafile.'".'."\n"); + $body->appendElement('p', 'No User Agent strings found in file "'.$uafile.'".'); } -$wrapper->pgbottom(); +$footer = $body->appendElement('footer', 'Page code under Mozilla Public License, code available at '); +$footer->setAttribute('id', 'copyright'); +$footer->appendLink('https://github.com/KaiRo-at/php-utility-classes', 'GitHub'); +$footer->appendText('.'); + +// Send HTML to client. +print($document->saveHTML()); ?>