2004-12-12 03:51:51 +00:00
< ? php
2004-12-11 03:59:45 +00:00
/************************************/
2004-03-15 16:22:00 +00:00
/* code to Submit a new application */
2004-12-11 03:59:45 +00:00
/************************************/
include ( " path.php " );
2005-02-02 00:18:59 +00:00
require ( BASE . " include/incl.php " );
require ( BASE . " include/tableve.php " );
2005-02-07 23:21:33 +00:00
require ( BASE . " include/mail.php " );
require ( BASE . " include/application.php " );
2005-06-29 03:01:08 +00:00
/*
* Templates
* FIXME : put templates in config file or somewhere else .
*/
//$sAppDescription = "<p>Enter description here</p>";
$sVersionDescription = " <p>This is a template; enter version-specific description here</p>
< p >
< span class = \ " title \" >Wine compatibility</span><br />
< span class = \ " subtitle \" >What works:</span><br />
- settings < br />
- help < br />
< br />< span class = \ " subtitle \" >What doesn't work:</span><br />
- erasing < br />
< br />< span class = \ " subtitle \" >What was not tested:</span><br />
- burning < br />
</ p >
< p >< span class = \ " title \" >Tested versions</span><br /><table class= \" historyTable \" width= \" 90% \" border= \" 1 \" >
< thead class = \ " historyHeader \" ><tr>
< td > App . version </ td >< td > Wine version </ td >< td > Installs ? </ td >< td > Runs ? </ td >< td > Rating </ td >
</ tr ></ thead >
< tbody >< tr >
< td class = \ " gold \" >3.23</td><td class= \" gold \" >20050111</td><td class= \" gold \" >yes</td><td class= \" gold \" >yes</td><td class= \" gold \" >Gold</td>
</ tr >< tr >
< td class = \ " silver \" >3.23</td><td class= \" silver \" >20041201</td><td class= \" silver \" >yes</td><td class= \" silver \" >yes</td><td class= \" silver \" >Silver</td>
</ tr >< tr >
< td class = \ " bronze \" >3.21</td><td class= \" bronze \" >20040615</td><td class= \" bronze \" >yes</td><td class= \" bronze \" >yes</td><td class= \" bronze \" >Bronze</td>
</ tr ></ tbody ></ table ></ p >< p >< br /></ p > " ;
2004-12-11 03:59:45 +00:00
2005-01-30 23:12:48 +00:00
if ( ! $_SESSION [ 'current' ] -> isLoggedIn ())
2004-12-11 03:59:45 +00:00
{
2005-02-07 23:21:33 +00:00
// you must be logged in to submit app
apidb_header ( " Please login " );
echo " To submit an application to the database you must be logged in. Please <a href= \" account.php?cmd=login \" >login now</a> or create a <a href= \" account.php?cmd=new \" >new account</a>. " , " \n " ;
exit ;
2004-12-11 03:59:45 +00:00
}
2004-03-15 16:22:00 +00:00
2004-03-18 19:26:33 +00:00
// Check the input of a submitted form. And output with a list
// of errors. (<ul></ul>)
2004-12-11 03:59:45 +00:00
function checkInput ( $fields )
2004-03-18 19:26:33 +00:00
{
2004-12-11 03:59:45 +00:00
$errors = " " ;
2004-03-15 16:22:00 +00:00
2005-02-07 23:21:33 +00:00
if ( strlen ( $fields [ 'appName' ]) > 200 )
2004-12-11 03:59:45 +00:00
$errors .= " <li>Your application name is too long.</li> \n " ;
2004-03-15 16:22:00 +00:00
2005-02-07 23:21:33 +00:00
if ( empty ( $fields [ 'appName' ]) && ! $fields [ 'appId' ])
2004-12-11 03:59:45 +00:00
$errors .= " <li>Please enter an application name.</li> \n " ;
2004-03-15 16:22:00 +00:00
2005-02-07 23:21:33 +00:00
if ( empty ( $fields [ 'versionName' ]))
2004-12-11 03:59:45 +00:00
$errors .= " <li>Please enter an application version.</li> \n " ;
2004-03-15 16:22:00 +00:00
2004-12-11 03:59:45 +00:00
// No vendor entered, and nothing in the list is selected
2005-02-09 02:19:24 +00:00
if ( empty ( $fields [ 'vendorName' ]) && ! $fields [ 'vendorId' ] && ! $fields [ 'appId' ])
2004-12-11 03:59:45 +00:00
$errors .= " <li>Please enter a vendor.</li> \n " ;
2004-03-18 19:26:33 +00:00
2005-02-09 02:19:24 +00:00
if ( empty ( $fields [ 'appDescription' ]) && ! $fields [ 'appId' ])
2004-12-11 03:59:45 +00:00
$errors .= " <li>Please enter a description of your application.</li> \n " ;
2004-03-18 19:26:33 +00:00
2004-12-11 03:59:45 +00:00
if ( empty ( $errors ))
return " " ;
else
return $errors ;
2004-03-18 19:26:33 +00:00
}
2005-02-07 23:21:33 +00:00
/*
* User submitted an application
*/
if ( isset ( $_REQUEST [ 'appName' ]))
2004-03-15 16:22:00 +00:00
{
2004-03-18 19:26:33 +00:00
// Check input and exit if we found errors
2005-06-29 03:01:08 +00:00
2004-03-18 19:26:33 +00:00
$errors = checkInput ( $_REQUEST );
2005-06-29 03:01:08 +00:00
if ( empty ( $errors ))
2004-03-18 19:26:33 +00:00
{
2005-06-29 03:01:08 +00:00
if ( $vendorName ) $_REQUEST [ 'vendorId' ] = " " ;
$oApplication = new Application ();
// FIXME When two htmlarea will be able to live on the same page
// without problems under gecko, remove the <p></p> around appDescrion
2005-08-05 22:07:41 +00:00
$oApplication -> create ( $_REQUEST [ 'appName' ], " <p> " . $_REQUEST [ 'appDescription' ] . " </p> " , $_REQUEST [ 'keywords' ] . " *** " . $_REQUEST [ 'vendorName' ], $_REQUEST [ 'webpage' ], $_REQUEST [ 'vendorId' ], $_REQUEST [ 'catId' ]);
2005-06-29 03:01:08 +00:00
$oVersion = new Version ();
$oVersion -> create ( $_REQUEST [ 'versionName' ], $_REQUEST [ 'versionDescription' ], null , null , $oApplication -> iAppId );
redirect ( apidb_fullurl ( " index.php " ));
2004-03-18 19:26:33 +00:00
}
2005-06-29 03:01:08 +00:00
2005-02-07 23:21:33 +00:00
}
2005-06-29 03:01:08 +00:00
2005-02-07 23:21:33 +00:00
/*
* User submitted a version
*/
elseif ( isset ( $_REQUEST [ 'versionName' ]) && is_numeric ( $_REQUEST [ 'appId' ]))
{
// Check input and exit if we found errors
$errors = checkInput ( $_REQUEST );
2005-06-29 03:01:08 +00:00
if ( empty ( $errors ))
2004-03-18 19:26:33 +00:00
{
2005-02-07 23:21:33 +00:00
2005-06-29 03:01:08 +00:00
$oVersion = new Version ();
$oVersion -> create ( $_REQUEST [ 'versionName' ], $_REQUEST [ 'versionDescription' ], null , null , $_REQUEST [ 'appId' ]);
redirect ( apidb_fullurl ( " index.php " ));
}
2004-03-15 16:22:00 +00:00
}
2005-06-29 03:01:08 +00:00
2005-02-07 23:21:33 +00:00
/*
* User wants to submit an application or version
*/
2005-06-29 03:01:08 +00:00
if ( isset ( $_REQUEST [ 'apptype' ]))
2004-12-11 03:59:45 +00:00
{
2005-02-23 00:15:30 +00:00
// header
apidb_header ( " Submit Application " );
2005-02-02 04:11:41 +00:00
//FIXME: use absolute path in htmlarea_loader.js to avoid code duplication here
?>
<!-- load HTMLArea -->
< script type = " text/javascript " >
_editor_url = " ./htmlarea/ " ;
_editor_lang = " en " ;
function initDocument () {
config = new HTMLArea . Config ();
config . toolbar = [
[ " bold " , " italic " , " underline " , " strikethrough " , " separator " ,
" copy " , " cut " , " paste " , " space " , " undo " , " redo " , " separator " ,
" justifyleft " , " justifycenter " , " justifyright " , " justifyfull " , " separator " ,
" orderedlist " , " unorderedlist " , " outdent " , " indent " , " separator " ,
" forecolor " , " hilitecolor " , " separator " ,
" inserthorizontalrule " , " createlink " , " inserttable " ]
];
config . width = 700 ;
2005-02-24 04:48:04 +00:00
config . pageStyle = " @import url(./application.css); " ;
// FIXME: when both editors and stylesheets are used, sometimes one of the editor is readonly under gecko
// var editor = new HTMLArea("editor",config);
// editor.registerPlugin(DynamicCSS);
2005-02-07 23:21:33 +00:00
< ? php
2005-03-16 03:39:34 +00:00
// if($_REQUEST['apptype'] == 1) // we have two editors, one for application and one for version.
//{
?>
2005-02-07 23:21:33 +00:00
var editor2 = new HTMLArea ( " editor2 " , config );
editor2 . generate ();
2005-02-24 04:48:04 +00:00
editor2 . registerPlugin ( DynamicCSS );
2005-02-07 23:21:33 +00:00
< ? php
2005-03-16 03:39:34 +00:00
//}
?>
2005-02-24 04:48:04 +00:00
// FIXME: when both editors and stylesheets are used, sometimes one of the editor is readonly under gecko
// editor.generate();
2005-02-02 04:11:41 +00:00
}
onload = function () {
HTMLArea . loadPlugin ( " DynamicCSS " );
HTMLArea . init ();
HTMLArea . onload = initDocument ;
}
</ script >
< script type = " text/javascript " src = " ./htmlarea/htmlarea.js " ></ script >
< ? php
2004-11-09 22:34:49 +00:00
2005-02-07 23:21:33 +00:00
// show add to queue form
echo '<form name="newApp" action="appsubmit.php" method="post">' . " \n " ;
echo " <p>This page is for submitting new applications to be added to this \n " ;
echo " database. The application will be reviewed by the AppDB Administrator \n " ;
echo " and you will be notified via email if this application will be added to \n " ;
echo " the database.</p> \n " ;
2005-05-14 00:43:33 +00:00
echo " <p>Before continuing please check that you have: \n " ;
echo " <ul> \n " ;
if ( $_REQUEST [ 'apptype' ] == 1 )
{
echo " <li>Searched for this application in the database. Duplicate submissions will be rejected.</li> \n " ;
echo " <li>Really want to submit an application instead of a new version of an application \n " ;
echo " that is already in the database. If this is the case browse to the application \n " ;
echo " and click on 'Submit new version'</li> \n " ;
}
echo " <li>Entered a valid version for this application. This is the application \n " ;
echo " version, NOT the wine version(which goes in the testing results section of the template</li> \n " ;
echo " <li>Tested this application under Wine. There are tens of thousands of applications \n " ;
echo " for windows, we don't need placeholder entries in the database. Please enter as complete \n " ;
echo " as possible testing results in the version template provided below</li> \n " ;
echo " </ul></p> " ;
2005-02-07 23:21:33 +00:00
echo " <p>Please don't forget to mention which Wine version you used, how well it worked \n " ;
echo " and if any workaround were needed. Having app descriptions just sponsoring the app \n " ;
echo " (Yes, some vendor want to use the appdb for this) or saying \" I haven't tried this app with Wine \" " ;
echo " won't help Wine development or Wine users.</p> \n " ;
2005-05-14 00:43:33 +00:00
echo " <p>After your application has been added you'll be able to submit screenshots for it, post " ;
echo " messages in its forums or become a maintainer to help others trying to run the application.</p> " ;
2005-06-29 03:01:08 +00:00
if ( ! empty ( $errors ))
{
echo '<font color="red">' , " \n " ;
echo '<p class="red"> We found the following errors:</p><ul>' . $errors . '</ul>Please correct them.' ;
echo '</font><br />' , " \n " ;
echo '<p></p>' , " \n " ;
}
2005-02-07 23:21:33 +00:00
// new application and version
if ( $_REQUEST [ 'apptype' ] == 1 )
{
echo html_frame_start ( " New Application Form " , 400 , " " , 0 );
echo " <table width='100%' border=0 cellpadding=2 cellspacing=0> \n " ;
echo '<tr valign=top><td class="color0"><b>Application name</b></td>' , " \n " ;
2005-06-29 03:01:08 +00:00
echo '<td><input type="text" name="appName" value="' . $_REQUEST [ 'appName' ] . '" size="20"></td></tr>' , " \n " ;
2005-02-07 23:21:33 +00:00
// app Category
$w = new TableVE ( " view " );
echo '<tr valign=top><td class="color0"><b>Category</b></td><td>' , " \n " ;
2005-06-29 03:01:08 +00:00
$w -> make_option_list ( " catId " , $_REQUEST [ 'catId' ], " appCategory " , " catId " , " catName " );
2005-02-07 23:21:33 +00:00
echo '</td></tr>' , " \n " ;
echo '<tr valign=top><td class="color0"><b>Vendor</b></td>' , " \n " ;
2005-06-29 03:01:08 +00:00
echo '<td><input type=text name="vendorName" value="' . $_REQUEST [ 'vendorName' ] . '" size="20"></td></tr>' , " \n " ;
2005-02-07 23:21:33 +00:00
// alt vendor
$x = new TableVE ( " view " );
echo '<tr valign=top><td class="color0"> </td><td>' , " \n " ;
2005-06-29 03:01:08 +00:00
$x -> make_option_list ( " vendorId " , $_REQUEST [ 'vendorId' ], " vendor " , " vendorId " , " vendorName " );
2005-02-07 23:21:33 +00:00
echo '</td></tr>' , " \n " ;
echo '<tr valign=top><td class="color0"><b>URL</b></td>' , " \n " ;
2005-06-29 03:01:08 +00:00
echo '<td><input type=text name="webpage" value="' . $_REQUEST [ 'webpage' ] . '" size=20></td></tr>' , " \n " ;
2004-04-06 21:26:10 +00:00
2005-02-07 23:21:33 +00:00
echo '<tr valign=top><td class="color0"><b>Keywords</b></td>' , " \n " ;
2005-06-29 03:01:08 +00:00
echo '<td><input size="80%" type="text" name="keywords" value="' . $_REQUEST [ 'keywords' ] . '"></td></tr>' , " \n " ;
2004-11-09 22:34:49 +00:00
2005-02-07 23:21:33 +00:00
echo '<tr valign=top><td class="color0"><b>Application Description</b></td>' , " \n " ;
2005-06-29 03:01:08 +00:00
echo '<td><p><textarea cols="80" rows="20" name="appDescription">' ;
echo $_REQUEST [ 'appDescription' ] . '</textarea></p></td></tr>' , " \n " ;
2004-03-15 16:22:00 +00:00
2005-02-07 23:21:33 +00:00
}
// new version
else
{
echo html_frame_start ( " New Version Form " , 400 , " " , 0 );
echo " <table width='100%' border=0 cellpadding=2 cellspacing=0> \n " ;
// app parent
$x = new TableVE ( " view " );
echo '<tr valign=top><td class=color0><b>Application</b></td><td>' , " \n " ;
$x -> make_option_list ( " appId " , $_REQUEST [ 'appId' ], " appFamily " , " appId " , " appName " );
echo '</td></tr>' , " \n " ;
2005-06-29 03:01:08 +00:00
}
echo '<tr valign=top><td class="color0"><b>Version name</b></td>' , " \n " ;
echo '<td><input type="text" name="versionName" value="' . $_REQUEST [ 'versionName' ] . '" size="20"></td></tr>' , " \n " ;
if ( trim ( strip_tags ( $_REQUEST [ 'versionDescription' ])) == " " )
{
$_REQUEST [ 'versionDescription' ] = $sVersionDescription ;
}
echo '<tr valign=top><td class=color0><b>Version description</b></td>' , " \n " ;
echo '<td><p style="width:700px">' , " \n " ;
echo '<textarea cols="80" rows="20" id="editor2" name="versionDescription">' , " \n " ;
/* if magic quotes are enabled we need to strip them before we output the 'versionDescription' */
/* again. Otherwise we will stack up magic quotes each time the user resubmits after having */
/* an error */
if ( get_magic_quotes_gpc ())
echo stripslashes ( $_REQUEST [ 'versionDescription' ]) . '</textarea></p></td></tr>' , " \n " ;
else
echo $_REQUEST [ 'versionDescription' ] . '</textarea></p></td></tr>' , " \n " ;
2004-11-09 22:34:49 +00:00
2005-06-29 03:01:08 +00:00
echo '<input type="hidden" name="apptype" value="' . $_REQUEST [ 'apptype' ] . '">' , " \n " ;
2005-02-07 23:21:33 +00:00
2005-06-29 03:01:08 +00:00
// new application and version
if ( $_REQUEST [ 'apptype' ] == 1 )
{
echo '<tr valign=top><td class=color3 align=center colspan=2>' , " \n " ;
echo '<input type=submit value="Submit New Application" class="button"> </td></tr>' , " \n " ;
}
// new version
else
{
2005-02-07 23:21:33 +00:00
echo '<tr valign=top><td class="color3" align="center" colspan="2">' , " \n " ;
echo '<input type=submit value="Submit New Version" class="button"> </td></tr>' , " \n " ;
}
2005-06-29 03:01:08 +00:00
echo '</table>' , " \n " ;
echo html_frame_end ();
echo " </form> " ;
2005-02-07 23:21:33 +00:00
}
2004-03-15 16:22:00 +00:00
apidb_footer ();
?>