qsos-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qsos-commits] qsos/apps/o3s set_weighting.php


From: Raphaël Semeteys
Subject: [Qsos-commits] qsos/apps/o3s set_weighting.php
Date: Sun, 17 May 2009 22:20:48 +0000

CVSROOT:        /sources/qsos
Module name:    qsos
Changes by:     Raphaël Semeteys <rsemeteys>    09/05/17 22:20:48

Modified files:
        apps/o3s       : set_weighting.php 

Log message:
        Database integration

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qsos/apps/o3s/set_weighting.php?cvsroot=qsos&r1=1.2&r2=1.3

Patches:
Index: set_weighting.php
===================================================================
RCS file: /sources/qsos/qsos/apps/o3s/set_weighting.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- set_weighting.php   8 Jul 2007 23:21:09 -0000       1.2
+++ set_weighting.php   17 May 2009 22:20:45 -0000      1.3
@@ -1,6 +1,6 @@
 <?php
 /*
-**  Copyright (C) 2007 Atos Origin 
+**  Copyright (C) 2007-2009 Atos Origin 
 **
 **  Author: Raphael Semeteys <address@hidden>
 **
@@ -23,15 +23,36 @@
 ** set_weighting.php: displays form to enter weigthings
 **
 */
-
 session_start();
-session_unset();
-session_destroy();
-$_SESSION = array();
+
+$params = array('lang', 'svg', 'family', 'qsosspecificformat', 'new');
+
+foreach($params as $param) {
+  $$param = $_REQUEST[$param];
+}
+
+$weights = array();
+
+if (isset($new) && ($new == "true")) {
+  $_SESSION = array();
+  while (list($name, $value) = each($_REQUEST)) { 
+    if (!(in_array($name,$params))) {
+      $_SESSION[$name] = $value;
+    }
+  }
+}
+
+while (list($name, $value) = each($_SESSION)) { 
+  if (!(in_array($name,$params))) {
+    $weights[$name] = $_SESSION[$name];
+  }
+}
+
+
+$_SESSION["nbWeights"] = count($weights);
 
 include("config.php");
-include("fs.functions.php");
-include("locales/$lang.php");
+include("lang.php");
 
 echo "<html>\n";
 echo "<head>\n";
@@ -44,25 +65,30 @@
        if (isNaN(field.value)) {
                var oldValue = field.value;
                field.value = "1";
-               alert(oldValue + " is not an applicable weight value,\n it has 
been set to 1.");
+    alert(oldValue + "<? echo $msg['s2_err_weight']; ?>");
                field.focus();
        }
 }
 
-function save() {
+function saveFile() {
        myForm.action = "save_weighting.php";
        myForm.submit();
 }
 
-function next() {
-       myForm.action = "software.php";
+function save() {
+  myForm.action = "set_weighting.php";
+  myForm.submit();
+}
+
+function back() {
+  myForm.action = "list.php";
        myForm.submit();
 }
 
 function upload() {
        var file = document.getElementById("weighting");
        if (file.value == "") {
-               alert("No weight file is provided!");
+    alert("<? echo $msg['s2_err_no_file']; ?>");
                return;
        }
        myForm.action = "set_weighting.php";
@@ -79,14 +105,25 @@
 
 include("libs/QSOSDocument.php");
 
-$family = $_REQUEST['family'];
-$svg = $_REQUEST['svg'];
-
-$upload = false;
-$weights = array();
+//Check if family and template version exist
+$IdDB = mysql_connect($db_host ,$db_user, $db_pwd);
+mysql_select_db($db_db);
+$query = "SELECT DISTINCT CONCAT(qsosappfamily,qsosspecificformat) FROM 
evaluations WHERE appname <> '' AND language = '$lang'";
+$IdReq = mysql_query($query, $IdDB);
+$familiesFQDN = array();
+while($row = mysql_fetch_row($IdReq)) {
+  array_push($familiesFQDN, $row[0]);
+}
+if (!in_array($family.$qsosspecificformat,$familiesFQDN)) 
+  die ("$family $qsosspecificformat".$msg['s3_err_no_family']);
+
+$query = "SELECT file FROM evaluations WHERE qsosappfamily = '$family' AND 
qsosspecificformat = '$qsosspecificformat' LIMIT 0,1";
+$IdReq = mysql_query($query, $IdDB);
+$result = mysql_fetch_row($IdReq);
+$file = $result[0];
 
 //Upload of weighting file
-if (isset($_FILES['weighting'])) {
+if (isset($_FILES['weighting']) && $_FILES['weighting']['tmp_name'] <> "") {
        $weighting = $_FILES['weighting'];
        $dir = $temp.uniqid();
        move_uploaded_file($weighting['tmp_name'], $dir);
@@ -110,7 +147,6 @@
                        .$weighting['name']
                        .$msg['s2_loaded']
                        ."</div><br/>";
-               $upload = true;
        } else {
                $text = "<div style='texte-align: center; color: red'>"
                        .$family.$msg['s2_error1']
@@ -119,29 +155,19 @@
        }
 }
 
-$tree= retrieveLocalizedTree($sheet.$delim.$family, $locale);
-$keys = array_keys($tree);
-
-$file = $tree[$keys[0]][0];
-$file = $sheet.$delim.$family.$delim.$keys[0].$delim.$file;
-
 $myDoc = new QSOSDocument($file);
 $tree = $myDoc->getTree();
 $familyname = $myDoc->getkey("qsosappfamily");
 
-echo "<div style='font-weight: bold'>"
-       .$msg['s2_title']
-       ."<br/><br/></div>\n";
+echo "<div style='font-weight: bold'>".$msg['s2_title']."<br/><br/></div>\n";
 echo $text;
-echo "<form id='myForm' 
-       enctype='multipart/form-data' 
-       method='POST' 
-       action='software.php'>\n";
-echo "<input type='hidden' 
-       name='family' 
-       value='$family'/>\n";
-echo "<table id='table' 
-       style='border-collapse: collapse; font-size: 12pt; table-layout: 
fixed'>\n";
+echo "<form id='myForm' enctype='multipart/form-data' method='POST' 
action='set_weighting.php'>\n";
+echo "<input type='hidden' name='lang' value='$lang'/>\n";
+echo "<input type='hidden' name='svg' value='$svg'/>\n";
+echo "<input type='hidden' name='family' value='$family'/>\n";
+echo "<input type='hidden' name='new' value='true'/>\n";
+echo "<input type='hidden' name='qsosspecificformat' 
value='$qsosspecificformat'/>\n";
+echo "<table id='table' style='border-collapse: collapse; font-size: 12pt; 
table-layout: fixed'>\n";
 echo "<tr class='title' style='width: 400px'><td>$familyname</td>\n";
 echo "<td><div style='width: 60px; text-align: center'>"
        .$msg['s2_weight']
@@ -150,19 +176,14 @@
 
 showtree($myDoc, $tree, 0, '');
 
-echo "<input type='button' 
-       value='".$msg['s2_button_back']."' 
-       onclick='location.href=\"index.php\"'> ";
-echo " <input type='button' 
-       value='".$msg['s2_button_save']."' 
+echo "<input type='button' value='".$msg['s2_button_back']."' 
+  onclick='back()'> ";
+echo " <input type='button' value='".$msg['s2_button_save']."' 
        onclick='save()'> ";
-echo " <input type='button' 
-       value='".$msg['s2_button_next']."' 
-       onclick='next()'><br/><br/>\n";
-echo "<input type='file' 
-       id='weighting' name='weighting'> 
-      <input type='button' 
-       value='".$msg['s2_button_upload']."' 
+echo " <input type='button' value='".$msg['s2_button_saveFile']."' 
+  onclick='saveFile()'><br/><br/>\n";
+echo "<input type='file' id='weighting' name='weighting'/> ";
+echo "<input type='button' value='".$msg['s2_button_upload']."' 
        onclick='upload()'><br/><br/>\n";
 echo "</table>\n";
 echo "</form>\n";
@@ -203,7 +224,7 @@
                //If a weighting file has been uploaded use $weights array, if 
not use default value 1
                echo "<input type='text' 
                        name='$name' size='3' style='text-align: center' 
onblur='checkWeight(this)' 
-                       value='".(($upload)?$weights[$name]:1)."'/>\n";
+      value='".((isset($weights[$name]))?$weights[$name]:1)."'/>\n";
 
                echo "</div></td>\n";
        




reply via email to

[Prev in Thread] Current Thread [Next in Thread]