Author: dgoette Date: Sun Apr 26 03:09:46 2009 New Revision: 391
URL: http://svn.reactos.org/svn/reactos?rev=391&view=rev Log: initial version of the new submit interface
Added: branches/danny-web/www/www.reactos.org/compat/js/submit.js branches/danny-web/www/www.reactos.org/compat/lib/get/List_Suggestions.class.php branches/danny-web/www/www.reactos.org/compat/lib/om/Entry.class.php branches/danny-web/www/www.reactos.org/compat/lib/view/HTML_Submit.class.php Modified: branches/danny-web/www/www.reactos.org/compat/config.php branches/danny-web/www/www.reactos.org/compat/convert1to2.sql branches/danny-web/www/www.reactos.org/compat/index.php branches/danny-web/www/www.reactos.org/compat/lib/HTML.class.php branches/danny-web/www/www.reactos.org/compat/lib/om/Category.class.php
Modified: branches/danny-web/www/www.reactos.org/compat/config.php URL: http://svn.reactos.org/svn/reactos/branches/danny-web/www/www.reactos.org/co... ============================================================================== --- branches/danny-web/www/www.reactos.org/compat/config.php [iso-8859-1] (original) +++ branches/danny-web/www/www.reactos.org/compat/config.php [iso-8859-1] Sun Apr 26 03:09:46 2009 @@ -8,5 +8,6 @@ define('CDBT_LANGUAGES' , 'cdb_languages'); define('CDBT_LOGS' , 'cdb_logs'); define('CDBT_TAGS' , 'cdb_tags'); +define('CDBT_VERSIONS' , 'cdb_entries_tags');
?>
Modified: branches/danny-web/www/www.reactos.org/compat/convert1to2.sql URL: http://svn.reactos.org/svn/reactos/branches/danny-web/www/www.reactos.org/co... ============================================================================== --- branches/danny-web/www/www.reactos.org/compat/convert1to2.sql [iso-8859-1] (original) +++ branches/danny-web/www/www.reactos.org/compat/convert1to2.sql [iso-8859-1] Sun Apr 26 03:09:46 2009 @@ -37,17 +37,7 @@ cat_icon, TRUE FROM rsdb_categories - WHERE cat_visible = '1' -UNION - SELECT - cat_id, - cat_path, - cat_name, - cat_description, - cat_icon, - FALSE - FROM rsdb_categories - WHERE cat_visible = '0'; + WHERE cat_visible = '1' AND cat_comp = '1';
ALTER TABLE cdb_categories ORDER BY id; DROP TABLE rsdb_categories; @@ -63,7 +53,7 @@ user_id BIGINT UNSIGNED NOT NULL COMMENT '->roscms.accounts(id)', title VARCHAR( 100 ) NOT NULL , content TEXT NOT NULL , - creation DATETIME NOT NULL , + created DATETIME NOT NULL , visible BOOL NOT NULL DEFAULT FALSE ) ENGINE = MYISAM COMMENT = 'parent xor entry_id has to be NULL';
@@ -265,6 +255,7 @@ id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR( 100 ) NOT NULL, version VARCHAR( 100 ) NOT NULL, + category_id BIGINT NOT NULL, description TEXT NOT NULL, created DATETIME NOT NULL, modified DATETIME NOT NULL, @@ -279,6 +270,7 @@ NULL, old_name, old_version, + 0, old_description, created, modified, @@ -303,7 +295,8 @@ ALTER TABLE cdb_entries_reports DROP old_name, DROP old_description, - DROP old_groupid; + DROP old_groupid, + DROP old_version;
DROP TABLE rsdb_item_comp;
@@ -314,7 +307,6 @@ -- ----------------------------------------------------------------- CREATE TABLE cdb_tags ( id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , - category_id BIGINT COMMENT '->categories(id)', name VARCHAR( 100 ) NOT NULL , description TEXT NOT NULL , user_id BIGINT UNSIGNED NOT NULL COMMENT '->roscms.users(id)', @@ -325,22 +317,6 @@ old_groupid BIGINT ) ENGINE = MYISAM;
--- groups -INSERT INTO cdb_tags -SELECT DISTINCT - NULL, - (SELECT grpentr_category FROM rsdb_groups WHERE grpentr_name=g.grpentr_name ORDER BY grpentr_date DESC LIMIT 1), - grpentr_name, - grpentr_description, - grpentr_usrid, - (SELECT grpentr_date FROM rsdb_groups WHERE grpentr_name=g.grpentr_name ORDER BY grpentr_date DESC LIMIT 1), - TRUE, - FALSE, - (SELECT grpentr_vendor FROM rsdb_groups WHERE grpentr_name=g.grpentr_name ORDER BY grpentr_date DESC LIMIT 1), - grpentr_id -FROM rsdb_groups g -WHERE grpentr_comp = '1' AND grpentr_visible = '1'; - -- vendors INSERT INTO cdb_tags SELECT DISTINCT @@ -370,7 +346,7 @@ id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , user_id BIGINT UNSIGNED NOT NULL COMMENT '->roscms.users(id)', content TEXT NOT NULL , - creation DATETIME NOT NULL + created DATETIME NOT NULL ) ENGINE = MYISAM;
INSERT INTO cdb_logs @@ -401,7 +377,7 @@ e.id, t.id FROM cdb_entries e -JOIN cdb_tags t ON (t.old_groupid = e.old_groupid OR t.old_vendor =e.old_vendorid); +JOIN cdb_tags t ON (t.old_vendor = e.old_vendorid);
ALTER TABLE cdb_entries DROP old_groupid; ALTER TABLE cdb_entries DROP old_vendorid; @@ -459,7 +435,7 @@ (NULL, 35137, 'ReactOS 0.3.6', TRUE, '000360'), (NULL, 37181, 'ReactOS 0.3.7', TRUE, '000370'), (NULL, 39330, 'ReactOS 0.3.8', TRUE, '000380'), -(NULL, 66666, 'ReactOS 0.3.9', TRUE, '000390'); +(NULL, 40702, 'ReactOS 0.3.9', TRUE, '000390');
Modified: branches/danny-web/www/www.reactos.org/compat/index.php URL: http://svn.reactos.org/svn/reactos/branches/danny-web/www/www.reactos.org/co... ============================================================================== --- branches/danny-web/www/www.reactos.org/compat/index.php [iso-8859-1] (original) +++ branches/danny-web/www/www.reactos.org/compat/index.php [iso-8859-1] Sun Apr 26 03:09:46 2009 @@ -131,7 +131,6 @@ switch (@$_GET['page']) {
// Frontpage - case '': case 'home': new Home(); break; @@ -240,9 +239,9 @@ new HTML_Search(); break;
- // Category + // Submit case 'submit': - new Submit_Item(); + new HTML_Submit(); break;
// Help @@ -251,7 +250,10 @@ break;
default: - echo '404'; + // just show 404, if no request for 'get=' is given + if (!isset($_GET['get'])) { + echo '404'; + } break;
// export data @@ -280,4 +282,13 @@ } // end switch export break; } // end switch page + +switch (@$_GET['get']) { + + // Suggestions + case 'suggestions': + new List_Suggestions(); + break; + +} // end switch get ?>
Added: branches/danny-web/www/www.reactos.org/compat/js/submit.js URL: http://svn.reactos.org/svn/reactos/branches/danny-web/www/www.reactos.org/co... ============================================================================== --- branches/danny-web/www/www.reactos.org/compat/js/submit.js (added) +++ branches/danny-web/www/www.reactos.org/compat/js/submit.js [iso-8859-1] Sun Apr 26 03:09:46 2009 @@ -1,0 +1,165 @@ +var namesuggestion = false; +var xmldoc; + + +function suggestName( name ) +{ + if (name.length>1) { + makeRequest('?get=suggestions&for=names&search='+encodeURIComponent(name), 'name'); + } +} + + + +/** + * starts a new AJAX request + * + * @param string url + * @param string action + * @param string objid + * @param string format + * @param string kind + * @param string parameters + */ +function makeRequest( url, action ) +{ + var http_request = false; + + if (window.XMLHttpRequest) { // Mozilla, Safari,... + http_request = new XMLHttpRequest(); + } + else if (window.ActiveXObject) { // IE + try { + http_request = new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + try { + http_request = new ActiveXObject("Microsoft.XMLHTTP"); + } catch (e2) { + } + } + } + http_request.overrideMimeType('text/xml'); + + http_request.onreadystatechange = function() + { + try { + if (http_request.readyState === 4) { + if (http_request.status === 200) { + switch (action) { + + case 'name': + showSuggestions(http_request, 'suggestedNames'); + break; + + case 'version': + showSuggestions(http_request, 'suggestedVersions'); + break; + } + } + } + } + catch (e) { + } + + }; + + // internal function end + http_request.open('GET', url, true); + http_request.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); // Bypass the IE Cache + http_request.send(null); + + return true; +} // end of function makeRequest + + + +function showSuggestions( http_request, id ) +{ + var show=''; + + xmldoc = http_request.responseXML; + var entries = xmldoc.getElementsByTagName('entry'); + + if (entries.length > 0) { + document.getElementById(id).style.display = 'block'; + namesuggestion = true; + + for (var i=0; i < entries.length; i++) { + show += '<li> <a onclick="useSuggestion(this, \'name\', '+i+');">'+entries[i].getAttribute('name')+'</a></li>'; + } + + document.getElementById(id).innerHTML='<ul>'+show+'</ul>'; + } + else { + namesuggestion = false; + hideSuggestions(id); + } +} + + + +function hideSuggestions( id ) +{ + document.getElementById(id).style.display = 'none'; +} + + + +function useSuggestion( from, type, index ) +{ + var id; + var show=''; + + if (type == 'name') { + id = 'title'; + hideSuggestions('suggestedNames'); + disableDetails(); + + var entries = xmldoc.getElementsByTagName('entry'); + var versions = entries[index].getElementsByTagName('version'); + + for (var i=0; i < versions.length; i++) { + show += '<li> <a onclick="useSuggestion(this, \'version\');">'+versions[i].firstChild.nodeValue+'</a></li>'; + } + + document.getElementById('suggestedVersions').style.display='block'; + document.getElementById('suggestedVersions').innerHTML='<ul>'+show+'</ul>'; + } + else if (type == 'version') { + id = 'version'; + hideSuggestions('suggestedVersions'); + } + document.getElementById(id).value=from.innerHTML; +} + + + +function toggleDetails( ) +{ + if (!document.getElementById('iCheck').checked) { + enableDetails() + } + else { + disableDetails() + } +} + + + +function disableDetails( ) +{ + document.getElementById('iCheck').checked = true; + document.getElementById('cat').disabled = true; + document.getElementById('description').disabled = true; + document.getElementById('tags').disabled = true; +} + + + +function enableDetails( ) +{ + document.getElementById('iCheck').checked = false; + document.getElementById('cat').disabled = false; + document.getElementById('description').disabled = false; + document.getElementById('tags').disabled = false; +}
Modified: branches/danny-web/www/www.reactos.org/compat/lib/HTML.class.php URL: http://svn.reactos.org/svn/reactos/branches/danny-web/www/www.reactos.org/co... ============================================================================== --- branches/danny-web/www/www.reactos.org/compat/lib/HTML.class.php [iso-8859-1] (original) +++ branches/danny-web/www/www.reactos.org/compat/lib/HTML.class.php [iso-8859-1] Sun Apr 26 03:09:46 2009 @@ -44,7 +44,7 @@ $this->title = $page_title; $this->register_css('style.css'); $this->register_js('smoothscroll.js'); - $this->register_js('search.js'); + //$this->register_js('search.js');
// get output $this->build(); @@ -57,7 +57,7 @@ * * @access private */ - private function build( ) + protected function build( ) { $this->header(); $this->navigation();
Added: branches/danny-web/www/www.reactos.org/compat/lib/get/List_Suggestions.class.php URL: http://svn.reactos.org/svn/reactos/branches/danny-web/www/www.reactos.org/co... ============================================================================== --- branches/danny-web/www/www.reactos.org/compat/lib/get/List_Suggestions.class.php (added) +++ branches/danny-web/www/www.reactos.org/compat/lib/get/List_Suggestions.class.php [iso-8859-1] Sun Apr 26 03:09:46 2009 @@ -1,0 +1,69 @@ +<?php + /* + RSDB - ReactOS Support Database + Copyright (C) 2009 Danny Götte <dangerground@web.de> + + 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +class List_Suggestions +{ + + + + public function __construct( ) + { + header("Content-Type: Text/XML"); + echo '<root>'; + switch (@$_GET['for']) { + case 'name': + default: + $stmt=CDBConnection::getInstance()->prepare("SELECT name, version FROM ".CDBT_ENTRIES." WHERE name LIKE :search ORDER BY name ASC, version DESC"); + + } + $stmt->bindValue('search',@$_GET['search'].'%',PDO::PARAM_STR); + $stmt->execute(); + $oldname = null; + + // build list of entries and their versions + while ($entry=$stmt->fetch(PDO::FETCH_ASSOC)) { + + // open / close entry + if ($oldname === null || $oldname != $entry['name']) { + if ($oldname !== null) { + echo '</entry>'; + } + echo '<entry name="'.htmlspecialchars($entry['name']).'">'; + } + + // version + echo '<version>'.htmlspecialchars($entry['version']).'</version>'; + + // update last entry name + $oldname = $entry['name']; + } // end while entry + + // close entry + if ($oldname !== null) { + echo '</entry>'; + } + + echo '</root>'; + } // end of constructor + + + +} // end of List_Suggestions +?>
Modified: branches/danny-web/www/www.reactos.org/compat/lib/om/Category.class.php URL: http://svn.reactos.org/svn/reactos/branches/danny-web/www/www.reactos.org/co... ============================================================================== --- branches/danny-web/www/www.reactos.org/compat/lib/om/Category.class.php [iso-8859-1] (original) +++ branches/danny-web/www/www.reactos.org/compat/lib/om/Category.class.php [iso-8859-1] Sun Apr 26 03:09:46 2009 @@ -2,6 +2,7 @@ /* CompatDB - ReactOS Compatability Database Copyright (C) 2005-2006 Klemens Friedl frik85@reactos.org + 2009 Danny Götte dangerground@web.de
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 @@ -33,24 +34,36 @@ * * @access public */ - public static function showTree($RSDB_TEMP_cat_path, $RSDB_TEMP_cat_id, $RSDB_TEMP_cat_level, $RSDB_TEMP_cat_level_newmain, $option) { - global $RSDB_intern_link_category_cat; + public static function showTreeAsOption($category_id = 0, $level = 0) + { + $output = '';
- $stmt=CDBConnection::getInstance()->prepare("SELECT * FROM ".CDBT_CATEGORIES." WHERE parent = :cat_path AND visible IS TRUE ORDER BY name ASC"); - $stmt->bindParam('cat_path',$RSDB_TEMP_cat_id,PDO::PARAM_STR); + $categories=self::getChilds($category_id); + if (count($categories) > 0) { + foreach($categories as $category) { + $output .= ' + <option value="'.$category['id'].'">'.str_repeat(' ',$level).htmlspecialchars($category['name']).'</option>'; + $output .= self::showTreeAsOption($category['id'],$level+1); + } + } + + return $output; + } // end of member function showTree + + + + /** + * @FILLME + * + * @access private + */ + private static function getChilds($category_id) + { + $stmt=CDBConnection::getInstance()->prepare("SELECT id, name FROM ".CDBT_CATEGORIES." WHERE parent = :cat_path AND visible IS TRUE ORDER BY name ASC"); + $stmt->bindParam('cat_path',$category_id,PDO::PARAM_INT); $stmt->execute(); - - while($result_create_historybar=$stmt->fetch(PDO::FETCH_ASSOC)) { - if ($option) { - self::showLeafAsOption($result_create_historybar['id'], $RSDB_TEMP_cat_level_newmain); - } - else { - self::showLeafAsRow($result_create_historybar['id'], $RSDB_TEMP_cat_level_newmain); - } - self::showTree($result_create_historybar['parent'], $result_create_historybar['id'], $RSDB_TEMP_cat_level, $RSDB_TEMP_cat_level_newmain,$option); - } - } // end of member function showTree - + return $stmt->fetchAll(PDO::FETCH_ASSOC); + }
/** @@ -58,10 +71,10 @@ * * @access public */ - public static function showLeafAsOption($RSDB_TEMP_entry_id, $RSDB_TEMP_cat_level_newmain) { + public static function showLeafAsOption($RSDB_TEMP_entry_id, $RSDB_TEMP_cat_level_newmain) + { global $RSDB_intern_selected; - global $RSDB_intern_link_category_cat; global $cellcolor2; $cellcolor=$cellcolor2; @@ -115,7 +128,8 @@ * * @access public */ - public static function showLeafAsRow($RSDB_TEMP_entry_id, $RSDB_TEMP_cat_level_newmain) { + public static function showLeafAsRow($RSDB_TEMP_entry_id, $RSDB_TEMP_cat_level_newmain) + { global $RSDB_intern_link_category_cat; global $cellcolor2; @@ -176,7 +190,7 @@ echo "</font></div></td><td width='10%' valign='top' bgcolor='".$cellcolor."'><font size='2'>".Count::entriesInGroup($result_create_tree_entry['id'])."</font></td></tr>"; - } // end of member function showLeafAsOption + } // end of member function showLeafAsRow
Added: branches/danny-web/www/www.reactos.org/compat/lib/om/Entry.class.php URL: http://svn.reactos.org/svn/reactos/branches/danny-web/www/www.reactos.org/co... ============================================================================== --- branches/danny-web/www/www.reactos.org/compat/lib/om/Entry.class.php (added) +++ branches/danny-web/www/www.reactos.org/compat/lib/om/Entry.class.php [iso-8859-1] Sun Apr 26 03:09:46 2009 @@ -1,0 +1,149 @@ +<?php + /* + RosCMS - ReactOS Content Management System + Copyright (C) 2009 Danny Götte <gvg@reactos.org> + + 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/** + * class Entry + * + */ +class Entry +{ + + + + /** + * @FILLME + * + * @access public + */ + public static function add( $title, $version, $category, $description, $tags, $update = false ) + { + // search for existing entry + $entry_id = self::getId($title, $version); + + // insert new entry + if ($entry_id === false) { + + // check category type + if (!ctype_digit((string)$category) || $category == 0) { + echo 'Error: Unknown Categorie'; + return false; + } + + // insert + $stmt=CDBConnection::getInstance()->prepare("INSERT INTO ".CDBT_ENTRIES." (name, version, category_id, description, created, modified, visible) VALUES (:name, :version, :category, :description, NOW(), NOW(), TRUE)"); + $stmt->bindParam('name',$title,PDO::PARAM_STR); + $stmt->bindParam('version',$version,PDO::PARAM_STR); + $stmt->bindParam('category',$category,PDO::PARAM_INT); + $stmt->bindParam('description',$description,PDO::PARAM_STR); + if(!$stmt->execute()) { + return false; + } + + $entry_id = self::getId($title, $version); + } + + // update entry + elseif ($update) { + $stmt=CDBConnection::getInstance()->prepare("UPDATE ".CDBT_ENTRIES." SET category=:category, description=:description, modified=NOW() WHERE id=:entry_id"); + $stmt->bindParam('entry_id',$entry_id,PDO::PARAM_STR); + $stmt->bindParam('category',$category,PDO::PARAM_INT); + $stmt->bindParam('description',$description,PDO::PARAM_STR); + if(!$stmt->execute()) { + return false; + } + } + + return $entry_id; + } // end of member function add + + + + /** + * @FILLME + * + * @access public + */ + public static function addReport( $entry_id, $revision, $status = false ) + { + global $RSDB_intern_user_id; + + // check if entry exists + if ($entry_id === false) { + echo 'Error: Unknown entry'; + return false; + } + + // insert + $stmt=CDBConnection::getInstance()->prepare("INSERT INTO ".CDBT_REPORTS." (entry_id, user_id, revision, works, created, visible, disabled) VALUES (:entry_id, :user_id, :revision, :status, NOW(), TRUE, FALSE)"); + $stmt->bindParam('entry_id',$entry_id,PDO::PARAM_INT); + $stmt->bindParam('user_id',$RSDB_intern_user_id,PDO::PARAM_INT); + $stmt->bindParam('revision',$revision,PDO::PARAM_INT); + $stmt->bindParam('status',$status,PDO::PARAM_BOOL); + return $stmt->execute(); + } // end of member function addReport + + + + /** + * @FILLME + * + * @access public + */ + public static function addComment( $entry_id, $title, $content ) + { + global $RSDB_intern_user_id; + + // check if entry exists + if ($entry_id === false) { + echo 'Error: Unknown entry'; + return false; + } + + // insert + $stmt=CDBConnection::getInstance()->prepare("INSERT INTO ".CDBT_COMMENTS." (entry_id, user_id, parent, title, content, created, visible) VALUES (:entry_id, :user_id, NULL, :title, :content, NOW(), TRUE)"); + $stmt->bindParam('entry_id',$entry_id,PDO::PARAM_INT); + $stmt->bindParam('user_id',$RSDB_intern_user_id,PDO::PARAM_INT); + $stmt->bindParam('title',$title,PDO::PARAM_STR); + $stmt->bindParam('status',$content,PDO::PARAM_STR); + return $stmt->execute(); + } // end of member function add + + + + /** + * @FILLME + * + * @access public + */ + public static function getId( $title, $version ) + { + // search for existing entry + $stmt=CDBConnection::getInstance()->prepare("SELECT id FROM ".CDBT_ENTRIES." WHERE name LIKE :name AND version LIKE :version LIMIT 1"); + $stmt->bindParam('name',$title,PDO::PARAM_STR); + $stmt->bindParam('version',$version,PDO::PARAM_STR); + $stmt->execute(); + return $stmt->fetchColumn(); + } // end of member function add + + + +} // end of Entry +?>
Added: branches/danny-web/www/www.reactos.org/compat/lib/view/HTML_Submit.class.php URL: http://svn.reactos.org/svn/reactos/branches/danny-web/www/www.reactos.org/co... ============================================================================== --- branches/danny-web/www/www.reactos.org/compat/lib/view/HTML_Submit.class.php (added) +++ branches/danny-web/www/www.reactos.org/compat/lib/view/HTML_Submit.class.php [iso-8859-1] Sun Apr 26 03:09:46 2009 @@ -1,0 +1,191 @@ +<?php + /* + RSDB - ReactOS Support Database + Copyright (C) 2009 Danny Götte <dangerground@web.de> + + 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +class HTML_Submit extends HTML +{ + + + public function __construct( ) + { + $this->register_js('submit.js'); + + parent::__construct(); + } + + + protected function build( ) + { + $this->header(); + $this->navigation(); + if (isset($_REQUEST['submit']) && $_REQUEST['submit'] == 'yes') { + $this->submit(); + } + $this->body(); + $this->footer(); + } + + + private function submit( ) + { + // get used revision number + if ($_POST['ver'] == 'R') { + $revision = $_POST['rev']; + } + else { + $revision = $_POST['ver']; + } + + // try to insert a new entry + if (isset($_POST['cat']) && isset($_POST['description'])) { + $entry_id = Entry::add($_POST['title'], $_POST['version'], $_POST['cat'], $_POST['description'], $_POST['tags'], (isset($_POST['iCheck']) && $_POST['iCheck'] == 'yes')); + } + + // search entry + else { + $entry_id = Entry::getId($_POST['title'], $_POST['version']); + } + + // insert new report/comment + if ($entry_id !== false) { + Entry::addReport($entry_id, $revision, ($_POST['status']=='yes')); + + // insert new comment + if (isset($_POST['comment']) && $_POST['comment'] != '') { + Entry::addComment($entry_id, 'test of r'.$revision, $_POST['comment']); + } + } + } // end of member function submit + + + + protected function body( ) + { + $used_again = (isset($_POST['next']) && $_POST['next']=='again'); + + echo ' + <form action="?page=submit&submit=yes" method="post"> + <fieldset> + <legend>App Details</legend> + <ul style="list-style-type: none;"> + <li style="float: left;"> + <label for="title">Application Name:</label><br /> + <input type="text" name="title" id="title" onkeyup="suggestName(this.value);" /> + <div id="suggestedNames" style="display:none;border: 1px solid red;"></div> + </li> + + <li style="float: right;"> + <label for="version">Version:</label><br /> + <input type="text" name="version" id="version" /> + <div id="suggestedVersions" style="display:none;border: 1px solid red;"></div> + </li> + + <li style="clear: both;"> + <fieldset> + <legend> + <input type="checkbox" name="iCheck" id="iCheck" value="yes" onclick="toggleDetails();" /> + <label for="iCheck">I don\'t want to modify the additional information</label> + </legend> + <ul style="list-style-type: none;"> + <li> + <label for="cat">Category:</label><br /> + <select name="cat" id="cat"> + <option value="0"> </option> + '.Category::showTreeAsOption().' + </select> + </li> + <li> + <label for="description">Short Description:</label><br /> + <input type="text" name="description" id="description" /> + </li> + + <li style="display:none;"> + <label for="tags">Tags: (seperate them by <em>,</em>)</label><br /> + <input type="text" name="tags" id="tags" /> + </li> + </ul> + </li> + + </ul> + </fieldset> + + <fieldset> + <legend>Test</legend> + <ul style="list-style-type: none;"> + <li> + Status:<br /> + <input type="radio" name="status" id="noworks" value="no" /> + <label for="noworks" style="color: red;">Doesn\'t Work</label> + <br /> + <input type="radio" name="status" id="doesn\'t work" value="yes" /> + <label for="works" style="color: green;">Works</label> + <br /> + <br /> + </li> + <li> + <label for="ver">Tested Version</label><br /> + <select name="ver" id="ver"> + <option value="R"'.(($used_again && $_POST['ver'] == 'R') ? ' selected="selected"' : '').'>Use Revision</option>'; + + $stmt=CDBConnection::getInstance()->prepare("SELECT revision, name FROM ".CDBT_VERSIONS." WHERE VISIBLE IS TRUE ORDER BY revision DESC"); + $stmt->execute(); + $x = 0; + while ($version = $stmt->fetch(PDO::FETCH_ASSOC) ) { + ++$x; + echo ' + <option value="'.$version['revision'].'"'.((($used_again && $_POST['ver'] == $version['revision']) || (!$used_again && $x===1)) ? ' selected="selected"' : '').'>'.$version['name'].'</option>'; + } + echo ' + </select> + </li> + + <li> + <label for="rev">Tested Revision (only trunk revisions are allowed, please don\'t enter revisions of tags or branches)</label><br /> + <input type="text" name="rev" id="rev"'.(($used_again && $_POST['ver'] == 'R') ? ' value="'.htmlspecialchars($_POST['revision']).'"' : '').' /> + </li> + </ul> + </fieldset> + + <fieldset> + <legend>Additional</legend> + <ul style="list-style-type: none;"> + <li> + <label for="comment">Comment</label><br /> + <textarea rows="6" cols="80" name="comment" id="comment"></textarea> + </li> + <li> + next action:<br /> + <input type="radio" name="next" id="again" value="again" '.($used_again ? 'checked="checked"' : '').' /> + <label for="again">Insert another entry/report</label> + <br /> + <input type="radio" name="next" id="entry" value="entry" '.(!$used_again ? 'checked="checked"' : '').' /> + <label for="entry">Jump to inserted entry/report</label> + </li> + </ul> + </fieldset> + <div> + <button type="submit">Submit new Compatibility Report</button> + </div> + </form>'; + } // end of member function body + + + +} // end of HTML_Submit +?>