Tweaks to DownloadView.php, a=chris
Tweaks to DownloadView.php, a=chris
<?php
/**
* SeekQuarry/Yioop --
* Open Source Pure PHP Search Engine, Crawler, and Indexer
*
* Copyright (C) 2009 - 2014 Chris Pollett chris@pollett.org
*
* LICENSE:
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* END LICENSE
*
* @author Chris Pollett chris@pollett.org
* @package seek_quarry
* @subpackage view
* @license http://www.gnu.org/licenses/ GPL3
* @link http://www.seekquarry.com/
* @copyright 2009 - 2014
* @filesource
*/
namespace seekquarry\yioop\views;
use seekquarry\yioop as B;
use seekquarry\yioop\configs as C;
/**
* This View is responsible for drawing the download
* information request form for the Seek Quarry app
*
* @author Chris Pollett
* @package seek_quarry
* @subpackage view
*/
class DownloadView extends View
{
/** This view is drawn on a web layout
* @var string
*/
var $layout = "web";
/**
* Draws the download yioop web page.
*
* @param array $data contains the anti CSRF token YIOOP_TOKEN
* the view
*/
function renderView($data)
{
$logo = C\BASE_URL . C\LOGO;
?>
<div class="download">
<h1 class="logo"><a href="<?=C\BASE_URL ?>"><img
src="<?= $logo ?>"
alt="SeekQuarry" /></a><span> - <?= tl('download_view_form')
?></span></h1>
<form method="post" action="<?=C\BASE_URL
?>" onsubmit="return checkFields();">
<input type="hidden" name="YIOOP_TOKEN" value="<?=
$data['YIOOP_TOKEN'] ?>" />
<input type="hidden" name="a" value="download" />
<input type="hidden" name="arg" value="step1" />
<input type="hidden" name="version" value="<?= $data['version']?>" />
<table>
<tr><td colspan="2"><?= tl('download_view_thank_you') ?></td></tr>
<tr>
<th class="table-label" ><label for="full-name"><?=
tl('download_view_full_name') ?></label>:</th>
<td class="table-input"><input id="full-name" type="text"
class="narrowfield" maxlength="80" name="full_name"/>
</td></tr>
<tr>
<th class="table-label" ><label for="e-mail"><?=
tl('download_view_email') ?></label>:</th>
<td class="table-input"><input id="e-mail" type="text"
class="narrowfield" maxlength="80" name="e_mail" /></td>
<tr>
<th class="table-label" ><label for="business-id"><?=
tl('download_view_business') ?></label>:</th>
<td class="table-input"><input id="business-id" type="text"
class="narrowfield" maxlength="80" name="business" /></td>
</tr>
<tr>
<th class="table-label" style="text-align:left;"
colspan="2"><label for="yioop-use"><?=
tl('download_view_interest') ?></label></th>
</tr>
<tr><td colspan="2">
<textarea class="shorttextarea" name="interest" ></textarea></td>
</tr>
<tr><td colspan="2" class="center">
<button type="submit" name="c" value="main"><?=
tl('download_view_get_email') ?></button>
</td></tr>
</table>
</form>
<div class="center"><a href="<?=
B\wikiUrl('Downloads', false, 'static') ?>"><?=
tl('download_view_return_main') ?></a></div>
</div>
<script type="text/javascript" />
function checkFields()
{
var full_name = elt('full-name');
var email = elt('e-mail');
var email_regex =
/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
var email_good = email_regex.test(email.value);
if(full_name.value == "" && !email_good) {
full_name.style.backgroundColor = 'red';
email.style.backgroundColor = 'red';
doMessage('<h1 class="red"><?=
tl("download_view_required_fields") ?></h1>');
return false;
} else if(full_name.value == "") {
full_name.style.backgroundColor = 'red';
doMessage('<h1 class="red"><?=
tl("download_view_name_required") ?></h1>');
return false;
} else if(!email_good) {
email.style.backgroundColor = 'red';
doMessage('<h1 class="red"><?=
tl("download_view_valid_email") ?></h1>');
return false;
}
return true;
}
</script>
<?php
}
}