Last commit for views/download_view.php: d9872d5d4c31e8d00c3a0c6a35da059a7176bb99

Changes for Version 3.0, a=chris

Chris Pollett [2015-08-27 19:Aug:th]
Changes for Version 3.0, 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
 */

if(!defined('BASE_DIR')) {echo "BAD REQUEST"; exit();}

/**
 * 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) {
?>
   <div  class="download">
  <h1 class="logo"><a href="."><img src="./?c=resource&amp;a=get&amp;f=resources&amp;g=2&amp;p=11&amp;n=SeekQuarry.png"
    alt="SeekQuarry" /></a><span> - <?php e(tl('download_view_form'));
    ?></span></h1>
<form  method="post" onsubmit="return checkFields();">
<input type="hidden" name="YIOOP_TOKEN" value="<?php
        e($data['YIOOP_TOKEN']); ?>" />
<input type="hidden" name="a" value="download" />
<input type="hidden" name="arg" value="step1" />
<input type="hidden" name="version" value="<?php e($data['version'])?>" />

    <table>
    <tr><td colspan="2"><?php
    e(tl('download_view_thank_you')); ?></td></tr>
    <tr>
    <th class="table-label" ><label for="full-name"><?php
        e(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"><?php
        e(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"><?php
        e(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" colspan="2"><label for="yioop-use"><?php
        e(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"><?php
        e(tl('download_view_get_email')); ?></button>
    </td></tr>
    </table>
</form>

<div class="center"><a href="?c=static&p=Downloads"><?php
    e(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"><?php
            e(tl("download_view_required_fields"))?></h1>');
        return false;
    } else if(full_name.value == "") {
        full_name.style.backgroundColor = 'red';
        doMessage('<h1 class="red"><?php
            e(tl("download_view_name_required"))?></h1>');
        return false;
    } else if(!email_good) {
        email.style.backgroundColor = 'red';
        doMessage('<h1 class="red"><?php
            e(tl("download_view_valid_email"))?></h1>');
        return false;
    }
    return true;
}
</script>
<?php
    }
}
?>
ViewGit