qsos-commits
[Top][All Lists]
Advanced

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

[Qsos-commits] qsos/apps/phpviewer QSOSDocument.php


From: Raphaël Semeteys
Subject: [Qsos-commits] qsos/apps/phpviewer QSOSDocument.php
Date: Sun, 12 Nov 2006 11:03:05 +0000

CVSROOT:        /sources/qsos
Module name:    qsos
Changes by:     Raphaël Semeteys <rsemeteys>   06/11/12 11:03:05

Modified files:
        apps/phpviewer : QSOSDocument.php 

Log message:
        getauthors() function added

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

Patches:
Index: QSOSDocument.php
===================================================================
RCS file: /sources/qsos/qsos/apps/phpviewer/QSOSDocument.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- QSOSDocument.php    7 Nov 2006 23:18:27 -0000       1.2
+++ QSOSDocument.php    12 Nov 2006 11:03:04 -0000      1.3
@@ -31,6 +31,12 @@
        var $score;
 }
 
+//Class representing a QSOS author (<author/>)
+class Author {
+       var $name;
+       var $email;
+}
+
 //Class representing a QSOS document
 class QSOSDocument {
        var $doc;
@@ -100,6 +106,33 @@
                }
        }
 
+    //Returns: array of Author objects (cf. Author class above)
+       public function getauthors() {
+               $authors = array();     
+
+               $nodes = $this->xpath->query("//author");
+               for ($i=0; $i < $nodes->length; $i++) {
+                       $author = new Author();
+
+                       $names = $nodes->item($i)->getElementsByTagName("name");
+                       if ($names->length > 0) {
+                               $author->name = $names->item(0)->textContent;
+                       } else {
+                               $author->name = "";
+                       }
+
+                       $titles = 
$nodes->item($i)->getElementsByTagName("email");
+                       if ($titles->length > 0) {
+                               $author->email = $titles->item(0)->textContent;
+                       } else {
+                               $author->email = "";
+                       }
+                       array_push($authors, $author);
+               }
+
+               return $authors;
+       }
+
     //Returns: tree of QSOSCriterion objects representing the scored criteria 
of the QSOS document
        public function getTree() {
                $tree = array();




reply via email to

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