svn: /web/doc-editor/trunk/php/ ExtJsController.php File.php RepositoryManager.php
[email protected] (Yannick Torres)
| Newsgroups | php.doc.web |
|---|---|
| Message-ID | <[email protected]> |
yannick Mon, 04 Jan 2010 21:34:16 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=293113
Log:
Fix the process when we try to commit a file witch don't exist in EN, and only in LANG, like translation.xml file
Changed paths:
U web/doc-editor/trunk/php/ExtJsController.php
U web/doc-editor/trunk/php/File.php
U web/doc-editor/trunk/php/RepositoryManager.php
Modified: web/doc-editor/trunk/php/ExtJsController.php
===================================================================
--- web/doc-editor/trunk/php/ExtJsController.php 2010-01-04 21:32:01 UTC (rev 293112)
+++ web/doc-editor/trunk/php/ExtJsController.php 2010-01-04 21:34:16 UTC (rev 293113)
@@ -1003,11 +1003,20 @@
// Only for lang files.
if( $existFiles[$i]->lang != 'en' ) {
+ $info = $existFiles[$i]->getInfo();
+
$en = new File('en', $existFiles[$i]->path, $existFiles[$i]->name);
- $info = $existFiles[$i]->getInfo();
+ // If the EN file don't exist, it's because we have a file witch only exist into LANG, for example, translator.xml
+ // We fake the EN with the LANG content to fake the errorTools ;)
- $langFiles[$j]['en_content'] = $en->read(true);
+ if( ! $en->fileExist() ) {
+ $en_content = $existFiles[$i]->read(true);
+ } else {
+ $en_content = $en->read(true);
+ }
+
+ $langFiles[$j]['en_content'] = $en_content;
$langFiles[$j]['lang_content'] = $existFiles[$i]->read(true);
$langFiles[$j]['lang'] = $existFiles[$i]->lang;
$langFiles[$j]['path'] = $existFiles[$i]->path;
Modified: web/doc-editor/trunk/php/File.php
===================================================================
--- web/doc-editor/trunk/php/File.php 2010-01-04 21:32:01 UTC (rev 293112)
+++ web/doc-editor/trunk/php/File.php 2010-01-04 21:34:16 UTC (rev 293113)
@@ -36,6 +36,12 @@
$this->full_path = $GLOBALS['DOC_EDITOR_VCS_PATH'].$lang.$path.$name;
}
+ public function fileExist()
+ {
+ return is_file($this->full_path);
+ }
+
+
/**
* Read the content of a file.
*
Modified: web/doc-editor/trunk/php/RepositoryManager.php
===================================================================
--- web/doc-editor/trunk/php/RepositoryManager.php 2010-01-04 21:32:01 UTC (rev 293112)
+++ web/doc-editor/trunk/php/RepositoryManager.php 2010-01-04 21:34:16 UTC (rev 293113)
@@ -608,40 +608,74 @@
} else { // lang file
- $en = new File('en', $file->path, $file->name);
- $enInfo = $en->getInfo();
+ // If this file don't exist in EN, we should skip all this proces
+ $en = new File('en', $file->path, $file->name);
- $sizeEN = intval(filesize($en->full_path) / 1024);
- $dateEN = filemtime($en->full_path);
+ if( $en->fileExist() ) {
- $size_diff = $sizeEN - $size;
- $date_diff = (intval((time() - $dateEN) / 86400))
- - (intval((time() - $date) / 86400));
+ $enInfo = $en->getInfo();
- // update LANG file info
- $s = sprintf(
- 'UPDATE `files`
- SET
- `xmlid` = "%s",
- `revision` = "%s",
- `en_revision`= "%s",
- `reviewed` = "%s",
- `size` = "%s",
- `mdate` = "%s",
- `maintainer` = "%s",
- `status` = "%s",
- `size_diff` = "%s",
- `mdate_diff` = "%s"
- WHERE
- `project` = "%s" AND
- `lang` = "%s" AND
- `path` = "%s" AND
- `name` = "%s"',
- $info['xmlid'], $info['en-rev'], $enInfo['rev'], trim($info['reviewed']), $size, $date,
- trim($info['maintainer']), trim($info['status']), $size_diff,
- $date_diff, $am->project, $file->lang, $file->path, $file->name
- );
- DBConnection::getInstance()->query($s);
+ $sizeEN = intval(filesize($en->full_path) / 1024);
+ $dateEN = filemtime($en->full_path);
+
+ $size_diff = $sizeEN - $size;
+ $date_diff = (intval((time() - $dateEN) / 86400))
+ - (intval((time() - $date) / 86400));
+
+ // update LANG file info
+ $s = sprintf(
+ 'UPDATE `files`
+ SET
+ `xmlid` = "%s",
+ `revision` = "%s",
+ `en_revision`= "%s",
+ `reviewed` = "%s",
+ `size` = "%s",
+ `mdate` = "%s",
+ `maintainer` = "%s",
+ `status` = "%s",
+ `size_diff` = "%s",
+ `mdate_diff` = "%s"
+ WHERE
+ `project` = "%s" AND
+ `lang` = "%s" AND
+ `path` = "%s" AND
+ `name` = "%s"',
+ $info['xmlid'], $info['en-rev'], $enInfo['rev'], trim($info['reviewed']), $size, $date,
+ trim($info['maintainer']), trim($info['status']), $size_diff,
+ $date_diff, $am->project, $file->lang, $file->path, $file->name
+ );
+ DBConnection::getInstance()->query($s);
+
+ } else // This file exist only in LANG version, like translation.xml, for example
+ {
+
+ // update LANG file info
+ $s = sprintf(
+ 'UPDATE `files`
+ SET
+ `xmlid` = "%s",
+ `revision` = "%s",
+ `en_revision`= "%s",
+ `reviewed` = "%s",
+ `size` = "%s",
+ `mdate` = "%s",
+ `maintainer` = "%s",
+ `status` = "%s",
+ `size_diff` = "%s",
+ `mdate_diff` = "%s"
+ WHERE
+ `project` = "%s" AND
+ `lang` = "%s" AND
+ `path` = "%s" AND
+ `name` = "%s"',
+ $info['xmlid'], $info['en-rev'], 0, trim($info['reviewed']), $size, $date,
+ trim($info['maintainer']), trim($info['status']), 0,
+ 0, $am->project, $file->lang, $file->path, $file->name
+ );
+ DBConnection::getInstance()->query($s);
+
+ }
}
}
}