public function applyOnlyTools() { $am = AccountManager::getInstance(); // We start by cleaning up the database $this->conn->query("DELETE FROM `errorfiles` WHERE `project`='%s'", array($am->project)); // We start by all translation // We select files how have revision=en_revision for this lang $query = 'SELECT * FROM files WHERE `project`="%s" AND `lang`!="%s" AND `revision`=`en_revision`'; $params = array($am->project, 'en'); $r = $this->conn->query($query, $params); while ($a = $r->fetch_object()) { $error = new ToolsError(); $fileEN = new File('en', $a->path . $a->name); $ENContent = $fileEN->read(true); $fileLANG = new File($a->lang, $a->path . $a->name); $LANGContent = $fileLANG->read(true); $error->setParams($ENContent, $LANGContent, $a->lang, $a->path, $a->name, ''); $error->run(); $error->saveError(); } //.... and now, EN files $query = 'SELECT * FROM files WHERE `project`="%s" AND `lang`="%s"'; $params = array($am->project, 'en'); $r = $this->conn->query($query, $params); while ($a = $r->fetch_object()) { $error = new ToolsError(); $fileEN = new File('en', $a->path . $a->name); $ENContent = $fileEN->read(true); $error->setParams($ENContent, '', $a->lang, $a->path, $a->name, ''); $error->run(); $error->saveError(); } }
<?php session_start(); error_reporting(E_ALL); require_once "./php/AccountManager.php"; require_once "./php/ToolsError.php"; $am = AccountManager::getInstance(); $am->isLogged(); if (isset($_GET['dir']) && isset($_GET['file'])) { // We retrieve all this error from DB to display the value. $errorTools = new ToolsError(); $errorTools->setParams('', '', $am->vcsLang, $_GET['dir'], $_GET['file'], ''); $error_to_display = $errorTools->getInfo(); if (empty($error_to_display)) { // We fake an empty error $error_to_display['-No error-']['error'][0]['value_en'] = '-'; $error_to_display['-No error-']['error'][0]['value_lang'] = '-'; } $fileLibel = $_GET['dir'] . $_GET['file']; } else { $error_to_display = array(); $fileLibel = NULL; } ?> <style type="text/css"> .member-table { font-size: 13px; color: #222222; font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif; margin: 10px;
/** * Check if a file have an error according to ToolsError's class. */ public function checkFileError() { if (!AccountManager::getInstance()->isLogged()) { return JsonResponseBuilder::failure(); } $FilePath = $this->getRequestVariable('FilePath'); $FileName = $this->getRequestVariable('FileName'); $FileLang = $this->getRequestVariable('FileLang'); // Remove \ $FileContent = stripslashes($this->getRequestVariable('FileContent')); // Replace by space $FileContent = str_replace(" ", "", $FileContent); $file = new File($FileLang, $FilePath . $FileName); // Detect encoding $charset = $file->getEncoding($FileContent); // If the new charset is set to utf-8, we don't need to decode it if ($charset != 'utf-8') { // Utf8_decode $FileContent = utf8_decode($FileContent); } // Get EN content to check error with $en_file = new File('en', $FilePath . $FileName); $readOriginal = true; $en_content = $en_file->read($readOriginal); // Update DB with this new Error (if any) $info = $file->getInfo($FileContent); $anode[0] = array('lang' => $FileLang, 'path' => $FilePath, 'name' => $FileName, 'en_content' => $en_content, 'lang_content' => $FileContent, 'maintainer' => $info['maintainer']); $errorTools = new ToolsError(); $r = $errorTools->updateFilesError($anode, 'nocommit'); return JsonResponseBuilder::success(array('error' => $r['state'], 'error_first' => $r['first'])); }