cvs: docweb /include lib_phpt_generator.inc.php /www phpt_generator.php

From: Date: Sun, 03 Dec 2006 09:09:46 +0000
Subject: cvs: docweb /include lib_phpt_generator.inc.php /www phpt_generator.php
Groups: php.doc.web 
Request: Send a blank email to doc-web+get-901@lists.php.net to get a copy of this message
colder Sun Dec 3 09:09:46 2006 UTC Modified files: /docweb/include lib_phpt_generator.inc.php /docweb/www phpt_generator.php Log: Optimizes the way big packages are generated http://cvs.php.net/viewvc.cgi/docweb/include/lib_phpt_generator.inc.php?r1=1.4&r2=1.5&diff_format=u Index: docweb/include/lib_phpt_generator.inc.php diff -u docweb/include/lib_phpt_generator.inc.php:1.4 docweb/include/lib_phpt_generator.inc.php:1.5 --- docweb/include/lib_phpt_generator.inc.php:1.4 Thu Nov 30 16:42:09 2006 +++ docweb/include/lib_phpt_generator.inc.php Sun Dec 3 09:09:45 2006 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Authors: Etienne Kneuss <colder@php.net> | +----------------------------------------------------------------------+ -$Id: lib_phpt_generator.inc.php,v 1.4 2006/11/30 16:42:09 colder Exp $ +$Id: lib_phpt_generator.inc.php,v 1.5 2006/12/03 09:09:45 colder Exp $ */ /** * Parameters @@ -323,12 +323,76 @@ $myArchive->addString('test'.$row['id'].'.phpt', phpt_generate($row)); } + // Destructor, to correctly close the file + $myArchive->_Archive_Tar(); + readfile($archivePath); unlink($archivePath); } } +/** + * Generate a list of examples selected by flag + * + * @return null + */ +function phpt_generate_all($sqlite, $flags) +{ + + // select data + + $sql_query = 'SELECT id, + title, + location, + test, + skipif, + expected, + edit_date, + import_date, + flags + FROM tests + WHERE flags & '.$flags.' = '.$flags; + + $results = sqlite_query($sqlite, $sql_query); + + if (count($ids) === 1) { + phpt_download(sqlite_fetch_array($results, SQLITE_ASSOC)); + } else { + $flags_verbose = array(); + if ($flags & PHPT_FLAG_FILLED) { + $flags_verbose[] = 'filled'; + } + + if ($flags & PHPT_FLAG_APPROVED) { + $flags_verbose[] = 'approved'; + } + + if ($flags & PHPT_FLAG_IMPLEMENTED) { + $flags_verbose[] = 'implemented'; + } + + + $archivePath = '/tmp/phpt_'.implode('_', $flags_verbose).'.tgz'; + + header('Content-Type: application/gzip'); + header('Content-Disposition: attachment; filename='.basename($archivePath)); + + + + $myArchive = new Archive_Tar($archivePath, 'gz'); + + while ($row = sqlite_fetch_array($results, SQLITE_ASSOC)) { + $myArchive->addString('test'.$row['id'].'.phpt', phpt_generate($row)); + } + // Destructor, to correctly close the file + $myArchive->_Archive_Tar(); + + readfile($archivePath); + unlink($archivePath); + + } +} /** * Delete a list of tests * http://cvs.php.net/viewvc.cgi/docweb/www/phpt_generator.php?r1=1.2&r2=1.3&diff_format=u Index: docweb/www/phpt_generator.php diff -u docweb/www/phpt_generator.php:1.2 docweb/www/phpt_generator.php:1.3 --- docweb/www/phpt_generator.php:1.2 Mon Nov 27 18:50:21 2006 +++ docweb/www/phpt_generator.php Sun Dec 3 09:09:45 2006 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Authors: Etienne Kneuss <colder@php.net> | +----------------------------------------------------------------------+ -$Id: phpt_generator.php,v 1.2 2006/11/27 18:50:21 colder Exp $ +$Id: phpt_generator.php,v 1.3 2006/12/03 09:09:45 colder Exp $ */ require_once '../include/init.inc.php'; @@ -50,23 +50,11 @@ } /** - * Generate every tests + * Generate every filled tests */ if (isset($_REQUEST['generateAll'])) { - $sql_query = 'SELECT id - FROM tests - WHERE flags & '.PHPT_FLAG_FILLED; - - $results = sqlite_query($sqlite, $sql_query); - - $ids = array(); - - while($row = sqlite_fetch_array($results, SQLITE_ASSOC)) { - $ids[] = $row['id']; - } - - phpt_generate_list($sqlite, $ids); + phpt_generate_all($sqlite, PHPT_FLAG_FILLED); exit; }

« previous php.doc.web (#901) next »