Moving to Attic, possible future use in TestFests but we will stick with hacky scripts this year

This commit is contained in:
Zoe Slattery
2009-05-09 15:32:04 +00:00
parent befa6725a4
commit cb85f38438
32 changed files with 11 additions and 803 deletions

11
.project Normal file
View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>php-testfest-web</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>

View File

@@ -1,52 +0,0 @@
<?php
Solar::autoload('Solar_Controller_Page');
/**
* That really is just a base so we
* can have the same templates shared
* accross modules
*/
class PHP_App_Base extends Solar_Controller_Page
{
/**
* Type of layout to use.
*
* @var String The layout to use.
*/
protected $_layout = 'main';
/**
* The default action
*
* This is the default action called when this
* controller is invoked.
*
* @var string The default action to invoke.
*/
protected $_action_default = 'index';
/**
* Name of the partial to use for navigation
*
* @var string The name of the partial.
*/
public $nav_partial = false;
/**
* Read-once notice to display
*
* @var string The notice string.
*/
public $flash_notice = null;
/**
* Setup method called after instantiation
*
* We use this to register a sql shared object needed to work with models.
*/
protected function _setup()
{
Solar_Registry::set('sql', Solar::factory('Solar_Sql'));
$this->flash_notice = $this->_session->getFlash('notice');
}
}

View File

@@ -1,51 +0,0 @@
<?php
/**
* Helper for navigation links.
*
* It sets a 'class' attribute with 'current' as a value if the $href provided
* corresponds to the request URI.
*
*/
class PHP_App_Base_Helper_NavAction extends Solar_View_Helper_Action
{
/**
* Internal request object.
*
* @var Solar_Request
*/
protected $_request = null;
/**
* Constructor
*
* @param array $config User-specified configuration.
*/
public function __construct($config = null)
{
parent::__construct($config);
$this->_request = Solar::factory('Solar_Request');
}
/**
* Returns an action link.
*
* The $text link text will be put in a span tag.
*
* @param string $href The action href.
*
* @param string $text A locale translation key.
*
* @return string
*/
public function navAction($text, $href)
{
if ($this->_request->server('REQUEST_URI') == $href) {
return "<a class=\"current\" href=\"$href\"><span>$text</span></a>";
}
return "<a href=\"$href\"><span>$text</span></a>";
}
}
?>

View File

@@ -1,5 +0,0 @@
<ul id="nav-links">
<li><?php echo $this->navAction('My Account', '/contributors'); ?></li>
<li><?php echo $this->navAction('Upload test(s)', '/contributors/upload'); ?></li>
<li><?php echo $this->navAction('My Files', '/contributors/myfiles'); ?></li>
</ul>

View File

@@ -1,6 +0,0 @@
<ul id="nav-links">
<li><?php echo $this->navAction('My Account', '/mentors/my'); ?></li>
<li><?php echo $this->navAction('Test Review', '/mentors/review'); ?></li>
<li><?php echo $this->navAction('Live Testing Area', '/mentors/livetest'); ?></li>
<li><?php echo $this->navAction('Announcements', '/mentors/announce'); ?></li>
</ul>

View File

@@ -1,57 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title><?php echo $this->getText('BASE_TITLE'); ?></title>
<link rel="stylesheet" type="text/css" href="/public/css/style.css" media="screen" />
<script src="/public/js/jquery-1.2.3.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#notice').show('slow');
window.setTimeout("$('#notice').hide('slow')", 4000);
});
</script>
</head>
<body>
<div id="container">
<div id="header">
<h1 class="header-logo">PHP Testfest 2008</h1>
<!-- Links to ... -->
<ul id="header-links">
<li><a href="http://php.net">PHP</a></li>
<li><a href="http://qa.php.net">PHP QA</a></li>
<li><a href="http://wiki.php.net">PHP Wiki</a></li>
<li><a href="http://docs.php.net">PHP Docs</a></li>
<li><a href="http://bugs.php.net">PHP Bugs</a></li>
</ul>
<?php if ($this->nav_partial) echo $this->partial($this->nav_partial); ?>
<div id="notice" style="display:hidden;">
<?php if ($this->flash_notice !== null) : ?>
<p><?php echo $this->getText($this->flash_notice); ?></p>
<?php endif; ?>
</div>
</div>
<div id="wrapper">
<div id="content">
<?php echo $this->layout_content; ?>
</div>
</div>
<div id="sidebar">
<!-- News (RSS) -->
<div class="box">
<h2>News :</h2>
<p>News about the Test Fest</p>
</div>
</div>
<div id="footer">
<a href="http://php.net/copyright.php">Copyright &copy; 2001-2008 The PHP Group</a><br />
All rights reserved.
</div>
</div>
</body>
</html>

View File

@@ -1,5 +0,0 @@
<?php
return array(
'BASE_TITLE' => 'PHP Test Fest ' . date('Y'),
);

View File

@@ -1,57 +0,0 @@
<?php
/**
* Any actions done by a contributor is going to be
* done here.
*
* @todo Develop actionUpload
* @todo Develop actionLogin
* @todo Develop actionFiles
*/
class PHP_App_Contributors extends PHP_App_Base
{
/**
* Name of the partial to use for navigation
*
* @var string The name of the partial.
*/
public $nav_partial = '_contributors_nav';
/**
* Eventual upload error to be displayed
*
* @var string The error.
*/
public $upload_error = false;
/**
* Action index.
*
* This action index when the /contributors root is invoked.
*
* @return void
*/
public function actionIndex()
{
}
/**
* Action upload.
*
* @return void
*/
public function actionUpload()
{
if ($this->_request->isPost()) {
try {
$handler = new PHP_Lib_UploadHandler($this->_request->files('testfile'));
$handler->process();
} catch (Exception $e) {
$this->upload_error = $e->getMessage();
return;
}
$this->_session->setFlash('notice', 'UPLOAD_SUCCESS');
$this->_redirectNoCache('contributors');
}
}
}

View File

@@ -1,13 +0,0 @@
<?php
return array(
'CONTRIBUTORS_WELCOME' => 'Welcome contributors!',
'CONTRIBUTORS_AREA' => 'Contributors Area!',
'UPLOAD_FORM_HEADER' => 'Upload your tests',
'UPLOAD_FORM_ERROR' => 'An error occured while processing your file. Please retry.',
'UPLOAD_FORM_LABEL' => 'Test file (.phpt) or zip of test files (.zip, .tar.gz)',
'UPLOAD_FORM_BUTTON' => 'Upload',
'UPLOAD_UNZIP_ERROR' => 'An error occured while unziping your file. Please retry.',
'UPLOAD_UNKNOWN_FILE_TYPE' => 'Unknown file type. Please retry.',
'UPLOAD_SUCCESS' => 'Upload successful !',
);

View File

@@ -1,2 +0,0 @@
<h2><?php echo $this->getText('CONTRIBUTORS_AREA'); ?></h2>
<p><?php echo $this->getText('CONTRIBUTORS_WELCOME'); ?></p>

View File

@@ -1,11 +0,0 @@
<h2><?php echo $this->getText('UPLOAD_FORM_HEADER'); ?></h2>
<form method="post" enctype="multipart/form-data" action="/contributors/upload">
<?php if ($this->upload_error) : ?>
<p id="form-error">
<?php echo $this->getText($this->upload_error); ?>
</p>
<?php endif; ?>
<label for="testfile"><?php echo $this->getText('UPLOAD_FORM_LABEL'); ?></label>
<input type="file" name="testfile" />
<input type="submit" name="commit" value="<?php echo $this->getText('UPLOAD_FORM_BUTTON'); ?>" />
</form>

View File

@@ -1,33 +0,0 @@
<?php
/**
* Index mockup
*
* This class behaves as if the /index was called
* It is not currently 100% working, but most of it
* is actually in place.
*
* @todo Add content to layout.
*/
class PHP_App_Index extends PHP_App_Base
{
/**
* The output to display. This is mostly an
* example of anything running with variables.
*
* @var string The output variable
*/
public $output = '';
/**
* Action index.
*
* This action index when the /index root is invoked.
*
* @see $this->output
* @return void
*/
public function actionIndex()
{
$this->output = 'Welcome to the 2008 Test Fest';
}
}

View File

@@ -1,5 +0,0 @@
<?php
return array(
'INDEX_PUBLIC_AREA' => 'Public hangout place',
);

View File

@@ -1,16 +0,0 @@
<div>
<h2><?php echo $this->getText('INDEX_PUBLIC_AREA'); ?></h2>
<p><?php echo $this->output; ?></p>
</div>
<div>
<h3>Signup</h3>
<form method="post" action="">
<p><label>Username</label><br />
<input type="text" name="login" id="login" size="30" /></p>
<p><label>Password</label><br />
<input type="password" name="password" id="password" size="30" /></p>
<p><input type="checkbox" />&nbsp;mentor ?</p>
<p style="text-align: right;"><input type="submit" name="commit" value="Signup" class="login-submit" /> or <a href="/register">register</a></p>
</form>
</div>

View File

@@ -1,73 +0,0 @@
<?php
/**
* Any actions done by a mentor is going to be
* done here.
*
* @todo Develop actionReview
* @todo Develop actionComment
* @todo Develop actionLivetesting
*/
class PHP_App_Mentors extends PHP_App_Base
{
/**
* Name of the partial to use for navigation
*
* @var string The name of the partial.
*/
public $nav_partial = '_mentors_nav';
/**
* The output to display. This is mostly an
* example of anything running with variables.
*
* @var string The output variable
*/
public $output = '';
/**
* Action index.
*
* This action index when the /contributors root is invoked.
*
* The string passed to this output is the string that you can
* get through $this->getText() which will then be i18ned to whichever
* language it is set in your locale and in your locale folder.
*
* @see $this->output
* @return void
*/
public function actionIndex()
{
$this->output = 'MENTORS_WELCOME';
}
public function actionLogin()
{
}
/**
* Announce action
*
* This is where we are supose to handle
* the action of adding new announcement
* somewhere...
*
* @see $this->_request
* @return void
*/
public function actionAnnounce()
{
$title = $this->_request->post('title');
$text = $this->_request->post('announcement');
if (!is_null($title) && !is_null($text)) {
/**
* @TODO:
* Get the username that did this,
* Invoke the model and save the text
* and title.
*/
}
}
}

View File

@@ -1,5 +0,0 @@
<?php
return array(
'MENTORS_WELCOME' => 'Welcome to all mentors!',
'MENTORS_AREA' => 'Mentors Area!',
);

View File

@@ -1,21 +0,0 @@
<h2>Mentors area</h2>
<?php
echo $this->form()
->text(array(
'name' => 'title',
'label' => 'Title',
))
->textarea(array(
'name' => 'announcement',
'label' => 'Text of announcement',
'attribs' => array(
'rows' => '10',
'cols' => '80',
),
))
->submit(array(
'name' => 'process',
'value' => $this->getTextRaw('PROCESS_SAVE'),
))
->fetch();
?>

View File

@@ -1,3 +0,0 @@
<h2>Mentors area</h2>
<p><?php echo $this->getText('MENTORS_WELCOME');?></p>

View File

@@ -1,17 +0,0 @@
<h2>Mentors area</h2>
<?php
echo $this->form()
->text(array(
'name' => 'handle',
'label' => 'Username',
))
->password(array(
'name' => 'passwd',
'label' => 'Password',
))
->submit(array(
'name' => 'process',
'value' => $this->getTextRaw('PROCESS_LOGIN'),
))
->fetch();
?>

View File

@@ -1,69 +0,0 @@
<?php
class PHP_Lib_UploadHandler
{
private $upload;
public function __construct($upload)
{
if ($upload['error'] !== 0) {
throw new Exception('UPLOAD_FORM_ERROR');
}
$this->upload = $upload;
}
public function process()
{
$path_parts = pathinfo($this->upload['name']);
switch ($path_parts['extension'])
{
case 'zip':
$this->handle_zip($this->upload);
break;
case 'phpt':
$this->db_insert($this->upload['name'], fopen($this->upload['tmp_name'], 'r'));
break;
default:
throw new Exception('UPLOAD_UNKNOWN_FILE_TYPE');
}
}
private function handle_zip($upload)
{
$zip = new ZipArchive;
if (!$zip->open($upload['tmp_name'])) {
throw new Exception('UPLOAD_UNZIP_ERROR');
} else {
for ($i=0; $i<$zip->numFiles;$i++) {
$filename = $zip->getNameIndex($i);
$handle = $zip->getStream($filename);
$this->db_insert($filename, $handle);
}
$zip->close();
}
}
private function db_insert($test_file_name, $test_file_handle)
{
$contents = '';
$description = '';
while (!feof($test_file_handle)) {
$buffer = fgets($test_file_handle, 4096);
$contents.= $buffer;
if (trim($buffer) == '--TEST--') {
$description = fgets($test_file_handle, 4096);
$contents.= $buffer;
}
}
$model = new PHP_Model_Tests();
$model->insert(array(
'filename' => $test_file_name,
'description' => $description,
'status' => 'Uploaded'
));
}
}
?>

View File

@@ -1,8 +0,0 @@
<?php
class PHP_Model_Tests extends Solar_Model
{
protected $_table_name = 'tests';
}
?>

34
README
View File

@@ -1,34 +0,0 @@
Install:
========
In order to be able to install this and develop on it, you'll have to install
the Solar Framework.
See http://solarphp.com/project/download
Vhost & Apache Configuration:
=============================
# http://local.testfest.com
<VirtualHost *:80>
ServerName local.testfest.com
DocumentRoot /path/to/testfest
<Directory />
AllowOverride All
Order deny,allow
Allow from all
</Directory>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /index.php [QSA,L]
</VirtualHost>
or in a .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /index.php [QSA,L]

View File

@@ -1,36 +0,0 @@
<?php
$URIBASE = '/';
$config = array();
$safedir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'jail';
// Base action href
$config['Solar_Uri_Action']['path'] = "$URIBASE";
// Base public directory href
$config['Solar_Uri_Public']['path'] = "$URIBASE/public";
// DB config
$config['Solar_Sql'] = array(
'adapter' => 'Solar_Sql_Adapter_Mysql',
'host' => '127.0.0.1',
'user' => 'testfest',
'pass' => 'php',
'name' => 'testfest',
);
// Auth config
$config['Solar_Auth']['adapter'] = 'Solar_Auth_Adapter_Sql';
$config['Solar_Auth_Adapter_Sql']['table'] = 'contributors';
$config['Solar_Auth_Adapter_Sql']['uid_col'] = 'id';
$config['Solar_Auth_Adapter_Sql']['handle_col'] = 'username';
$config['Solar_Auth_Adapter_Sql']['passwd_col'] = 'password';
$config['Solar_Auth_Adapter_Sql']['salt'] = 'testtt';
// Front controller config
$config['Solar_Controller_Front']['classes'] = array('PHP_App');
$config['Solar_Controller_Front']['default'] = 'index';
// Done!
return $config;
?>

View File

@@ -1,20 +0,0 @@
CREATE TABLE `contributors` (
`id` int(10) unsigned NOT NULL auto_increment,
`username` varchar(15) NOT NULL,
`password` varchar(32) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `testfiles` (
`id` int(10) unsigned NOT NULL auto_increment,
`filename` varchar(100) NOT NULL,
`description` tinytext NOT NULL,
`status` enum('Uploaded','Confirmed','In Review','Accepted','Refused') NOT NULL,
`uploaded_on` timestamp NOT NULL default CURRENT_TIMESTAMP,
`refusal_reason` tinytext,
PRIMARY KEY (`id`),
KEY `filename` (`filename`),
KEY `status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@@ -1,18 +0,0 @@
<?php
// $INCPATH is the the path to where Solar is installed,
// typically the PEAR PHP directory.
set_include_path(ini_get('include_path') . PATH_SEPARATOR . dirname(__FILE__));
// Load and start Solar. Be sure to point to the proper
// location of your Solar.config.php file.
require_once 'Solar.php';
Solar::start(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Solar.config.php');
// Instantiate and run the front controller.
$front = Solar::factory('Solar_Controller_Front');
$front->display();
// Done!
Solar::stop();
?>

View File

@@ -1,154 +0,0 @@
/* ----- CSS Reset ----- */
* {
margin: 0;
padding: 0;
}
/* ----- Basics ----- */
body {
font: 85%/1.3 TrebuchetMS,Arial,sans-serif;
text-align: left;
background: #fff;
}
a {
color: #6972a8;
}
h1 {
font: bold 2.1em Arial, Arial, Sans-Serif;
color: #036DA7;
}
h2 {
font: bold 1.1em Arial, Arial, Sans-Serif;
}
/* ----- Layout ----- */
div#container {
background-color: #fff;
}
div#header {
background-color: #282c2f; /*background: #202326;*/
}
div#wrapper {
float:left;
width:100%;
margin-left:-200px;
}
div#content {
margin-left:200px;
padding: 1em;
border-right: 1px solid gray;
min-height: 400px;
}
div#sidebar {
float:right;
width:160px;
padding: 1em;
/*background-color: #009200;*/
}
div#footer {
clear:both;
/*background-color: #ddd;*/
border-top: 1px solid gray;
padding: .5em;
}
h1.header-logo {
width: 330px; height: 100px;
background: url("/public/images/testfest_composite.png");
text-indent: -9999px;
}
/* ----- Navs ----- */
ul#header-links {
position: absolute;
top: 0;
right: 0;
list-style: none;
}
ul#header-links li {
float: left;
margin: 0 10px;
}
ul#nav-links {
border-bottom: solid 1px #DEDEDE;
height: 2em;
padding-left: 450px;
list-style: none;
}
ul#nav-links li {
float:left;
margin-right:2px;
}
ul#nav-links a {
background: transparent url("/public/images/tab-round.png");
color: #008;
display: block;
float: left;
height: 2em;
padding-left: 10px;
text-decoration: none;
}
ul#nav-links span {
background: #282c2f url("/public/images/tab-round.png") 100% 0;
display: block;
line-height: 2em;
padding-right: 10px;
}
ul#nav-links a:hover {
background-position: 0 -120px;
}
ul#nav-links a:hover span {
background-position: 100% -120px;
}
ul#nav-links a.current {
background-position: 0 -60px;
color: #fff;
font-weight: bold;
}
ul#nav-links a.current span {
background-position: 100% -60px;
}
div#notice {
position: absolute;
top: 25px;
width: 30%;
margin-left:35%;
margin-right:35%;
}
div#notice p {
font-size: 13px;
font-weight: bold;
padding: 0.5em 0.5em 0.5em 2.5em;
background: #06ba06 url("/public/images/information.png") no-repeat 0.5em 50%;
border:2px solid #fff;
color: #fff;
}
/* ----- Forms ----- */
p#form-error {
background-color: #cc0000;
color: #fff;
padding: 0.8em;
margin: 1em 0;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 778 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

File diff suppressed because one or more lines are too long