Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

StringIterator.php

Go to the documentation of this file.
00001 <?
00002 /***************************************************************************
00003  *   Copyright (C) 2005 by Ferenc Veres   *
00004  *   lion@netngine.hu   *
00005  *                                                                         *
00006  *   This program is free software; you can redistribute it and/or modify  *
00007  *   it under the terms of the GNU General Public License as published by  *
00008  *   the Free Software Foundation; either version 2 of the License, or     *
00009  *   (at your option) any later version.                                   *
00010  *                                                                         *
00011  *   This program is distributed in the hope that it will be useful,       *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU General Public License for more details.                          *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU General Public License     *
00017  *   along with this program; if not, write to the                         *
00018  *   Free Software Foundation, Inc.,                                       *
00019  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00020  ***************************************************************************/
00021  include_once('TranslationString.php');
00022 
00030 class StringIterator implements Iterator
00031 {
00032         private $ProjectID;             
00033         private $ProjectStrings;        
00035         private $Current;               
00036         private $IsValid;               
00043         public function __construct($projectID)
00044         {
00045                 $DB =& GetDbConn();
00046                 $Tables =& GetTables();
00047 
00048                 $this->ProjectID = $projectID;
00049 
00050                 // Fetch all strings of the project from the DB.
00051                 $rs = $DB->Execute("SELECT ID, Original, LocaleID, Translation, SentenceID, LastSeen, RowOrder FROM ".$Tables["Strings"]." WHERE ProjectID=? ORDER BY RowOrder", array($this->ProjectID));
00052 
00053                 while($row = $rs->FetchRow())
00054                 {
00055                         // Add fully initializes strings to the array.
00056                         $this->ProjectStrings[] = new TranslationString(
00057                                 $row["ID"],
00058                                 $this->ProjectID,
00059                                 $row["Original"],
00060                                 $row["LocaleID"],
00061                                 $row["Translation"],
00062                                 $row["SentenceID"],
00063                                 $row["LastSeen"],
00064                                 $row["RowOrder"]);
00065                 }
00066                 $this->rewind();
00067         }
00068 
00069         /* Iterator interface */
00070 
00074         public function rewind()
00075         {
00076                 $this->Current = 0;
00077         }
00078         
00082         public function hasMore()
00083         {
00084                 return (count($this->ProjectStrings) > $this->Current);
00085         }
00086         
00090         public function key()
00091         {
00092                 return $this->Current;
00093         }
00094         
00098         public function current()
00099         {
00100                 return $this->ProjectStrings[$this->Current];
00101         }
00102         
00106         public function next()
00107         {
00108                 $this->Current++;
00109         }
00110         
00114         public function valid()
00115         {
00116                 return (count($this->ProjectStrings) > $this->Current);
00117         }
00118 }

Generated on Sat Apr 22 16:49:53 2006 for XarayaTranslationMemory by  doxygen 1.4.4