[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qsos-commits] qsos/apps/o3s metadata.php
From: |
Raphaël Semeteys |
Subject: |
[Qsos-commits] qsos/apps/o3s metadata.php |
Date: |
Sun, 17 May 2009 22:13:36 +0000 |
CVSROOT: /sources/qsos
Module name: qsos
Changes by: Raphaël Semeteys <rsemeteys> 09/05/17 22:13:36
Added files:
apps/o3s : metadata.php
Log message:
Extract metadata from QSOS files for database backend
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qsos/apps/o3s/metadata.php?cvsroot=qsos&rev=1.1
Patches:
Index: metadata.php
===================================================================
RCS file: metadata.php
diff -N metadata.php
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ metadata.php 17 May 2009 22:13:36 -0000 1.1
@@ -0,0 +1,137 @@
+<?php
+/*
+** Copyright (C) 2009 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
+** metadata.php: extract metadata from QSOS files
+**
+*/
+
+include("config.php");
+include("locales/$lang.php");
+
+echo "<html>\n";
+echo "<head>\n";
+echo "<LINK REL=StyleSheet HREF='skins/$skin/o3s.css' TYPE='text/css'/>\n";
+echo "</head>\n";
+
+include("libs/QSOSDocument.php");
+
+//$file: filename (or URI) of the QSOS document to load
+//Returns: array with metadata
+function getmetadata($file) {
+ $metadata = array();
+ $keys = array( "qsosappfamily", "qsosspecificformat", "appname",
"qsosappname", "release", "language", "licensedesc" ,"creation", "validation" );
+ $myDoc = new QSOSDocument($file);
+
+ foreach ($keys as $key) {
+ $metadata[$key] = $myDoc->getkey($key);
+ }
+
+ $metadata["authors"] = $myDoc->getauthors();
+
+ $metadata["sections"] = $myDoc->getcountkey("section");
+
+ $metadata["criteria"] = array(
+ "total" => $myDoc->getcountkey("element"),
+ "scorable" => $myDoc->getcountkey("element/score"),
+ "scored" => $myDoc->getcountkey("element[score >= 0]"),
+ "notscored" => $myDoc->getcountkey("element[score = '']")
+ );
+
+ $metadata["comments"] = array(
+ "total" => $myDoc->getcountkey("element/comment"),
+ "commented" => $myDoc->getcountkey("element[comment != '']"),
+ "notcommented" => $myDoc->getcountkey("element[comment = '']")
+ );
+
+ return $metadata;
+}
+
+$array = array();
+function retrieveTree($path, $parent) {
+ global $delim;
+ global $array;
+
+ 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") {
+ retrieveTree($path.$delim.$element,
$parent.$delim.$element);
+ } elseif (substr($element, -5) == ".qsos") {
+ array_push($array, $parent.$delim.$element);
+ }
+ }
+ closedir($dir);
+ }
+ return (isset($array) ? $array : false);
+}
+
+$evaluations = retrieveTree($sheet, $sheet);
+
+$IdDB = mysql_connect($db_host ,$db_user, $db_pwd);
+mysql_select_db($db_db);
+
+$query = "TRUNCATE TABLE evaluations";
+if ($IdReq = mysql_query($query, $IdDB)) {
+ echo "Meta données supprimées<br/>";
+} else {
+ echo "Erreur lors de la suppression des meta données...<br/>";
+}
+
+foreach ($evaluations as $evaluation) {
+ $id = end(explode($delim, $evaluation));
+
+ $m = getmetadata($evaluation);
+// echo "<pre>";
+// print_r($m);
+// echo "</pre>";
+ $query = "INSERT INTO evaluations VALUES (\"$id\",
+ \"".$m['qsosappfamily']."\",
+ \"".$m['qsosspecificformat']."\",
+ \"".$m['qsosappname']."\",
+ \"".$m['release']."\",
+ \"".$m['appname']."\",
+ \"".$m['language']."\",
+ \"$evaluation\",
+ \"".$m['licensedesc']."\",
+ \"".$m['creation']."\",
+ \"".$m['validation']."\",
+ ".$m['sections'].",
+ ".$m['criteria']['total'].",
+ ".$m['criteria']['scorable'].",
+ ".$m['criteria']['scored'].",
+ ".$m['criteria']['notscored'].",
+ ".$m['comments']['total'].",
+ ".$m['comments']['commented'].",
+ ".$m['comments']['notcommented'].")";
+
+ if ($IdReq = mysql_query($query, $IdDB)) {
+ echo $m['appname']." enregistré en base<br/>";
+ } else {
+ echo "Erreur d'écriture dans la base...<br/>";
+ }
+}
+?>
\ No newline at end of file
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qsos-commits] qsos/apps/o3s metadata.php,
Raphaël Semeteys <=