qsos-commits
[Top][All Lists]
Advanced

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

[Qsos-commits] qsos/apps/o3s config.php index.php search.php s...


From: Raphaël Semeteys
Subject: [Qsos-commits] qsos/apps/o3s config.php index.php search.php s...
Date: Sun, 08 Jul 2007 23:21:09 +0000

CVSROOT:        /sources/qsos
Module name:    qsos
Changes by:     Raphaël Semeteys <rsemeteys>   07/07/08 23:21:09

Modified files:
        apps/o3s       : config.php index.php search.php 
                         set_weighting.php software.php 
        apps/o3s/locales: en-US.php fr-FR.php 
Added files:
        apps/o3s       : fs.functions.php 

Log message:
        Software families and evaluations are now filtered based on locale 
setting

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qsos/apps/o3s/config.php?cvsroot=qsos&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/qsos/apps/o3s/index.php?cvsroot=qsos&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/qsos/apps/o3s/search.php?cvsroot=qsos&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/qsos/apps/o3s/set_weighting.php?cvsroot=qsos&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/qsos/apps/o3s/software.php?cvsroot=qsos&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/qsos/apps/o3s/fs.functions.php?cvsroot=qsos&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/qsos/apps/o3s/locales/en-US.php?cvsroot=qsos&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/qsos/apps/o3s/locales/fr-FR.php?cvsroot=qsos&r1=1.1&r2=1.2

Patches:
Index: config.php
===================================================================
RCS file: /sources/qsos/qsos/apps/o3s/config.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- config.php  2 Feb 2007 07:14:33 -0000       1.1
+++ config.php  8 Jul 2007 23:21:09 -0000       1.2
@@ -25,14 +25,14 @@
 */
 
 //Local and web paths to QSOS sheets and templates
-$sheet = "sheets";
-$sheet_web = "http://localhost:88/o3s/sheets";;
-$template = "template";
-$template_web = "http://localhost:88/o3s/template";;
+$sheet = "../sheets";
+$sheet_web = "http://qsos/sheets";;
+$template = "../templates";
+$template_web = "http://qsos/templates";;
 $delim = "/";
 
 //Path to jpgraph library (for PNG graphs)
-$jpgraph_path = "libs/jpgraph-2.1.3/src/";
+$jpgraph_path = "/home/raph/qsos/web/o3s/libs/jpgraph-2.2/src/";
 
 //Temp directory, with trailing slash
 $temp = "/tmp/";
@@ -45,4 +45,5 @@
 
 //Locale to use (locale files are stored i, locales/ subdirectory)
 $lang = "fr-FR";
+$locale = "fr";
 ?>
\ No newline at end of file

Index: index.php
===================================================================
RCS file: /sources/qsos/qsos/apps/o3s/index.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- index.php   2 Feb 2007 07:14:33 -0000       1.1
+++ index.php   8 Jul 2007 23:21:09 -0000       1.2
@@ -25,6 +25,7 @@
 */
 
 include("config.php");
+include("fs.functions.php");
 include("locales/$lang.php");
 
 echo "<html>\n";
@@ -37,45 +38,28 @@
 echo "<img src='skins/$skin/o3s.png'/>\n";
 echo "<br/><br/>\n";
 
-//Returns array of software families
-function getFamilies($dir) {
-       global $delim;
-       $families = array();
-       if (is_dir($dir)) {
-               if ($dh = opendir($dir)) {
-                       while (($file = readdir($dh)) !== false) {
-                               if (is_dir($dir.$delim.$file) 
-                               && ($file != 'CVS') 
-                               && ($file != '.') 
-                               && ($file != '..') 
-                               && ($file != 'include') 
-                               && ($file != 'template') 
-                               && ($file != 'templates') 
-                               && ($file != '.svn')) {
-                                       array_push($families, $file);
-                               }
-                       }
-                       closedir($dh);
-               }
-       }
-       return (isset($families) ? $families : false);
-}
-
-$families = getFamilies($sheet);
-
 echo "<div style='font-weight: bold'>".$msg['s1_title']."<br/><br/>\n";
 
 echo "<table style='border-collapse: collapse'>\n";
-echo "<tr class='title'>\n";
-echo "<td>".$msg['s1_table_title']."</td>\n";
-echo "</tr>\n";
 
-for ($i=0; $i<count($families); $i++) {
+$tree = retrieveLocalizedTree($sheet, $locale);
+if (count($tree)) {
+       echo "<tr class='title'>\n";
+       echo "<td>".$msg['s1_table_title']."</td>\n";
+       echo "</tr>\n";
+       
+       $families = array_keys(retrieveLocalizedTree($sheet, $locale));
+       for ($i=0; $i<count($families); $i++) {
        echo "<tr class='level1' 
                onmouseover=\"this.setAttribute('class','highlight')\" 
                onmouseout=\"this.setAttribute('class','level1')\">\n";
        echo "<td><a 
href='set_weighting.php?family=$families[$i]'>$families[$i]</a></td>\n";
        echo "</tr>\n";
+       }
+} else {
+       echo "<tr class='title'>\n";
+       echo "<td>".$msg['s1_no_evaluations']."</td>\n";
+       echo "</tr>\n";
 }
 
 echo "</table>\n";

Index: search.php
===================================================================
RCS file: /sources/qsos/qsos/apps/o3s/search.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- search.php  2 Feb 2007 07:14:33 -0000       1.1
+++ search.php  8 Jul 2007 23:21:09 -0000       1.2
@@ -9,6 +9,7 @@
 $searchstr = $_REQUEST['s'];
 
 include("config.php");
+include("fs.functions.php");
 include("locales/$lang.php");
 
 echo "<html>\n";
@@ -42,11 +43,13 @@
           // filename: line
           // So, we use split() to split the data
           list($fname, $fline) = split(':', $buffer, 2);
-          // we take only the first hit per file
-          if (! defined($myresult[$fname])) {
+                       $fname = trim($fname);
+                       // we take only the first hit per file matching the 
locale filter
+                       if (isLocalizedName($fname, $locale) && ! 
defined($myresult[$fname])) {
               $myresult[$fname] = $fline;
           }
       }
+
       // we have results in a hash. lets walk through it and print it
       if (count($myresult)) {
            echo '<ul><br/>';
@@ -60,7 +63,7 @@
             echo 
$msg['s1_search_msg1']."<strong>$searchstr</strong>".$msg['s1_search_msg2']."<br/>\n";
        }
        pclose($fp);
-   }
+}
 
 echo "</body>\n";
 echo "</html>\n";

Index: set_weighting.php
===================================================================
RCS file: /sources/qsos/qsos/apps/o3s/set_weighting.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- set_weighting.php   2 Feb 2007 07:14:33 -0000       1.1
+++ set_weighting.php   8 Jul 2007 23:21:09 -0000       1.2
@@ -30,6 +30,7 @@
 $_SESSION = array();
 
 include("config.php");
+include("fs.functions.php");
 include("locales/$lang.php");
 
 echo "<html>\n";
@@ -118,34 +119,12 @@
        }
 }
 
-$tree= retrieveTree($sheet.$delim.$family);
+$tree= retrieveLocalizedTree($sheet.$delim.$family, $locale);
 $keys = array_keys($tree);
-function retrieveTree($path)  {
-       global $delim;
-       
-       if (address@hidden($path)) {
-       while (($element=readdir($dir))!== false) {
-               if (is_dir($path.$delim.$element) 
-               && $element != "." 
-               && $element != ".." 
-               && $element != "CVS" 
-               && $element != "template" 
-               && $element != "templates" 
-               && $element != ".svn") {
-                       $array[$element] = retrieveTree($path.$delim.$element);
-               } elseif (substr($element, -5) == ".qsos") {
-                       $array[] = $element;
-               }
-       }
-       closedir($dir);
-       }
-       return (isset($array) ? $array : false);
-}
 
 $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");

Index: software.php
===================================================================
RCS file: /sources/qsos/qsos/apps/o3s/software.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- software.php        2 Feb 2007 07:14:33 -0000       1.1
+++ software.php        8 Jul 2007 23:21:09 -0000       1.2
@@ -26,6 +26,7 @@
 
 session_start();
 include("config.php");
+include("fs.functions.php");
 include("locales/$lang.php");
 
 echo "<html>\n";
@@ -85,31 +86,9 @@
        }
 }
 
-$tree= retrieveTree($sheet.$delim.$family); 
+$tree = retrieveLocalizedTree($sheet.$delim.$family, $locale);
 $keys = array_keys($tree);
 
-function retrieveTree($path)  {
-       global $delim;
-       
-       if (address@hidden($path)) {
-       while (($element=readdir($dir))!== false) {
-               if (is_dir($path.$delim.$element) 
-               && $element != "." 
-               && $element != ".." 
-               && $element != "CVS" 
-               && $element != "template" 
-               && $element != "templates" 
-               && $element != ".svn") {
-                       $array[$element] = retrieveTree($path.$delim.$element);
-               } elseif (substr($element, -5) == ".qsos") {
-                       $array[] = $element;
-               }
-       }
-       closedir($dir);
-       }
-       return (isset($array) ? $array : false);
-}
-
 echo "<div style='font-weight: bold'>".
        $msg['s3_title'].
        "<br/><br/>\n";

Index: locales/en-US.php
===================================================================
RCS file: /sources/qsos/qsos/apps/o3s/locales/en-US.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- locales/en-US.php   2 Feb 2007 07:16:44 -0000       1.1
+++ locales/en-US.php   8 Jul 2007 23:21:09 -0000       1.2
@@ -30,6 +30,7 @@
 //Step 1 (index.php)
 $msg['s1_title'] = "Step 1 - Select a software family";
 $msg['s1_table_title'] = "Software families";
+$msg['s1_no_evaluations'] = "No evaluation match your locale";
 $msg['s1_search'] = "or search by keywords";
 $msg['s1_button'] = "Search!";
 //Step 1 (search.php)

Index: locales/fr-FR.php
===================================================================
RCS file: /sources/qsos/qsos/apps/o3s/locales/fr-FR.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- locales/fr-FR.php   2 Feb 2007 07:17:04 -0000       1.1
+++ locales/fr-FR.php   8 Jul 2007 23:21:09 -0000       1.2
@@ -30,6 +30,7 @@
 //Step 1 (index.php)
 $msg['s1_title'] = "Etape 1 - Sélectionner un domaine logiciel";
 $msg['s1_table_title'] = "Domaines logiciels";
+$msg['s1_no_evaluations'] = "Aucune évaluation disponible dans votre langue";
 $msg['s1_search'] = "ou effectuer une recherche par mots-clés";
 $msg['s1_button'] = "Chercher";
 //Step 1 (search.php)

Index: fs.functions.php
===================================================================
RCS file: fs.functions.php
diff -N fs.functions.php
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ fs.functions.php    8 Jul 2007 23:21:09 -0000       1.1
@@ -0,0 +1,68 @@
+<?php
+/*
+**  Copyright (C) 2007 Atos Origin 
+**
+**  Author: Raphael Semeteys <address@hidden>
+**
+**  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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  
USA
+**
+**
+** O3S
+** fs.functions.php: common FileSystem functions
+**
+*/
+
+//Returns multidimentional array of software families and software 
evaluations, filtered by locale
+//if $locale == "" then english evaluation are returned
+function retrieveLocalizedTree($path, $locale) {
+       global $delim;
+       
+       if (address@hidden($path)) {
+       while (($element=readdir($dir))!== false) {
+               if (is_dir($path.$delim.$element) 
+               && $element != "." 
+               && $element != ".." 
+               && $element != "CVS" 
+               && $element != "template" 
+               && $element != "templates" 
+               && $element != ".svn") {
+                       $subarray = 
retrieveLocalizedTree($path.$delim.$element, $locale);
+                       if (count($subarray) > 0) $array[$element] = $subarray;
+               } elseif (isLocalizedName($element, $locale)) {
+                       $array[] = $element;
+               }
+       }
+       closedir($dir);
+       }
+       return $array;
+}
+
+function isLocalizedName($name, $locale) {
+       if (
+               (substr($name, -5) == ".qsos")
+               && 
+               (
+                       ($locale != "" && substr($name, -8, -5) == "_$locale") 
+                       || 
+                       ($locale == "" && !strpos($name, '_'))
+               )
+       ) {
+               return true;
+       } else {
+               return false;
+       }
+}
+
+?>
\ No newline at end of file




reply via email to

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