19 include_once(
'TranslationProject.php');
54 public function __construct($parentID, $localeID, $brief =
false)
58 $this->Brief = $brief;
63 $this->LocaleID = $localeID;
64 $this->ParentID = $parentID;
67 if($CONFIG[
'disk_cache'])
70 $cacheFile = $CONFIG[
'disk_cache'].
"/ProjectList_".$this->LocaleID.
".cache";
71 $cacheFile2 = $CONFIG[
'disk_cache'].
"/ProjectChildren_".$this->LocaleID.
".cache";
74 $cacheFile .=
".brief";
75 $cacheFile2 .=
".brief";
80 if(empty(self::$ProjectList[$this->LocaleID]))
83 if($CONFIG[
'disk_cache'] && file_exists($cacheFile) && file_exists($cacheFile2))
85 self::$ProjectList[
$this->LocaleID] = unserialize(file_get_contents($cacheFile));
86 self::$ProjectChildren[
$this->LocaleID] = unserialize(file_get_contents($cacheFile2));
90 if(empty(self::$ProjectList[$this->LocaleID]))
94 $sql =
"SELECT ID, RootID, ParentID, Name, IsFolder, LocaleID,".
95 "TIMESTAMP(LastSeen) as LastSeen ".
96 "FROM ".$Tables[
"Projects"].
" WHERE LocaleID = ? ORDER BY Name";
100 $sql =
"SELECT ID, RootID, ParentID, Name, IsFolder, LocaleID,".
101 "Skeleton, OrigDoc, TIMESTAMP(LastSeen) as LastSeen ".
102 "FROM ".$Tables[
"Projects"].
" WHERE LocaleID = ? ORDER BY Name";
104 $rs =
$DB->Execute($sql, $this->LocaleID);
111 if(($haveMore = $proj->LoadFromRecordSet($rs, $this->Brief)))
114 self::$ProjectChildren[
$this->LocaleID][$proj->GetParentID()][] = $proj->GetID();
120 if($CONFIG[
'disk_cache'])
122 file_put_contents($cacheFile, serialize(self::$ProjectList[$this->LocaleID]));
123 file_put_contents($cacheFile2, serialize(self::$ProjectChildren[$this->LocaleID]));
128 if(empty(self::$ProjectList[$this->LocaleID]))
130 throw new Exception(
"There are no projects for Language ID: ".$this->LocaleID.
". Please import before using.");
148 if($CONFIG[
'disk_cache'])
150 $cacheFile = $CONFIG[
'disk_cache'].
"/ProjectList_".$localeID.
".cache";
151 $cacheFile2 = $CONFIG[
'disk_cache'].
"/ProjectChildren_".$localeID.
".cache";
153 if(file_exists($cacheFile))
157 if(file_exists($cacheFile2))
161 if(file_exists($cacheFile.
".brief"))
163 unlink($cacheFile.
".brief");
165 if(file_exists($cacheFile2.
".brief"))
167 unlink($cacheFile2.
".brief");
179 if(!empty(self::$ProjectChildren[$this->LocaleID][$this->ParentID][0]))
185 $this->CurrentID = 0;
201 foreach($siblings as $pid)
211 if($pid == $this->CurrentID)
223 return $this->CurrentID;
243 $lastID = $this->CurrentID;
244 $this->CurrentID = 0;
248 foreach($siblings as $pid)
253 $this->CurrentID = $pid;
269 return $this->CurrentID != 0;
280 return !empty(self::$ProjectChildren[$this->LocaleID][$this->CurrentID]);
289 return new ProjectIterator($this->CurrentID, $this->LocaleID, $this->Brief);
static ClearCache($localeID)
__construct($parentID, $localeID, $brief=false)