X-Git-Url: https://git-public.kairo.at/?p=php-utility-classes.git;a=blobdiff_plain;f=tests%2Fua_list.php;h=5c2e5ceede0db15c1007e7f03961142242694645;hp=3c9fa000f5c43257952d3aa1569de84ee9ced07e;hb=432328ee91316c002fd50137184970893ee3850b;hpb=9fdff807c738934b8f2a1428a597a81b7615df7e diff --git a/tests/ua_list.php b/tests/ua_list.php index 3c9fa00..5c2e5ce 100644 --- a/tests/ua_list.php +++ b/tests/ua_list.php @@ -4,68 +4,76 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ include('../classes/useragent.php-class'); +include('../classes/document.php-class'); // read string from this file $uafile = 'ua_list_raw.txt'; -print("\n"); -print("\n\n"); -print(" \n"); -print(" \n"); -print(" ".'User Agents'."\n"); -print("\n\n"); +// 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.'".'); } -print("
\n"); -print("Page code under Mozilla Public License, code available at GitHub.\n"); -print("
\n"); -print("\n"); +$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()); ?>