cvs: phpdoc /scripts/online_editor base.php cvslist.php login.php
| From: | Salah Faya | Date: | Tue, 06 May 2008 15:53:26 +0000 |
| Subject: | cvs: phpdoc /scripts/online_editor base.php cvslist.php login.php | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-1606@lists.php.net to get a copy of this message | ||
visualmind Tue May 6 15:53:26 2008 UTC
Modified files:
/phpdoc/scripts/online_editor base.php login.php cvslist.php
Log:
Few changes: added languages, legend and some title changing
http://cvs.php.net/viewvc.cgi/phpdoc/scripts/online_editor/base.php?r1=1.1&r2=1.2&diff_format=u Index: phpdoc/scripts/online_editor/base.php diff -u phpdoc/scripts/online_editor/base.php:1.1 phpdoc/scripts/online_editor/base.php:1.2 --- phpdoc/scripts/online_editor/base.php:1.1 Tue May 6 11:43:48 2008 +++ phpdoc/scripts/online_editor/base.php Tue May 6 15:53:26 2008 @@ -1,144 +1,167 @@ -<?php -//*-- The PHPDOC Online XML Editing Tool -//*-- Developed by Salah Faya visualmind(@)php.net -//*-- Version 1.0 - essentially developed for Arabic Translation of PHP Manual -//*-- Now updated to work with all phpdoc translations - -//--- base file (all other files require this to start) - -//------- Configuration -// Root path of cvs -$cvsRootPath = '/path/to/cvs/'; - -// Path to english xml sources from cvs -$enDocCVSPath = $cvsRootPath.'phpdoc/en/'; - -// Require User Login by email (needed for user file saving) -$requireLogin = false; - -if ($requireLogin) { - // Users folder where their cached files are saved - must be writable - $usersCachePath = '/path/to/editor/users/'; - // Files Permissions Mod - $filesChMod = 0777; -} - - -// Languages and paths: - -addLanguage('Arabic', $cvsRootPath.'phpdoc-ar/ar/', 'ar', 'utf-8', 'RTL', 'doc-ar@lists.php.net', 'doc-ar-subscribe@lists.php.net', 'Salah Faya visualmind(@)php.net'); - -addLanguage('Chinese-Simplified', $cvsRootPath.'phpdoc-zh/zh/', 'zh', 'gb2312', 'LTR', 'doc-zh@lists.php.net', 'doc-zh-subscribe@lists.php.net', ''); -addLanguage('Chinese-Traditional', $cvsRootPath.'phpdoc-tw/tw/', 'tw', 'big5', 'LTR', 'doc-tw@lists.php.net', 'doc-tw-subscribe@lists.php.net', ''); -addLanguage('Czech', $cvsRootPath.'phpdoc-cs/cs/', 'cs', 'iso-8859-2', 'LTR', 'doc-cs@lists.php.net', 'doc-cs-subscribe@lists.php.net', ''); -addLanguage('French', $cvsRootPath.'phpdoc-fr/fr/', 'fr', 'iso-8859-1', 'LTR', 'doc-fr@lists.php.net', 'doc-fr-subscribe@lists.php.net', ''); -addLanguage('Germany', $cvsRootPath.'phpdoc-de/de/', 'de', 'utf-8', 'LTR', 'doc-de@lists.php.net', 'doc-de-subscribe@lists.php.net', ''); -//.. - - -// Hide files (ignore) -$ignoreListingFolders = array('.', '..', 'CVS'); -$ignoreListingFiles = array('contributors.xml', 'contributors.ent', 'livedocs.ent'); - -//------- Base functions - -function addLanguage($lang, $cvspath, $id, $charset='utf-8', $direction='LTR', $mailing='', $mailsubscribe='', $coodinator='', $font='Fixedsys') { - global $phpdocLangs; - $phpdocLangs[$lang]['DocCVSPath'] = $cvspath; - $phpdocLangs[$lang]['charset'] = $charset; - $phpdocLangs[$lang]['direction'] = $direction; - $phpdocLangs[$lang]['id'] = $id; - $phpdocLangs[$lang]['mailing'] = $mailing; - $phpdocLangs[$lang]['mailingSubscribe'] = $mailsubscribe; - $phpdocLangs[$lang]['coordinator'] = $coordinator; - $phpdocLangs[$lang]['font'] = $font; -} - -function sessionCheck($arguments='') { - session_start(); - if (!isset($_SESSION['user'])) { - if ($_SERVER['REQUEST_METHOD']=='GET') { - $_SESSION['redo'] = $_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING']; - } - header('location: login.php'.$arguments); - exit('<a href="login.php">Login first</a>'); - } - return $_SESSION['user']; -} - -function getDateTimeToLog() { - return date('d/m H:i [').time().']'; -} - -function getUserIP() { - return $_SERVER['REMOTE_ADDR']; -} - -function getCacheName($filename) { - // change reference/ext/file.xml to reference~ext~file.xml - $filename = str_replace(array('/', '\\'), '~', $filename); - return $filename; -} - -function stripslashes2($text) { - if (get_magic_quotes_gpc()) { - $text = stripslashes($text); - } - return $text; -} - -function getRevision($file, $en=false) { - $f = fopen($file, "rb"); - $data = fread($f, 200); - fclose($f); - - // Use en-revision - if ($en) { - preg_match("#<!-- *EN-Revision: +([0-9\.]+)#i", $data, $result); - $rev = $result[1]; - } else { - preg_match("#<!-- *\\$"."Revision: +([0-9\.]+)#i", $data, $result); - $rev = $result[1]; - } - return $rev; -} - -function getTranslationStatus($file) { - global $user, $phpdocLangs, $enDocCVSPath; - - $lang = $user['phpdocLang']; - $translationPath = $phpdocLangs[$lang]['DocCVSPath']; - $trFile = $translationPath.$file; - $enFile = $enDocCVSPath.$file; - - $status['lastEnRevision'] = getRevision($enFile); - if (file_exists($trFile)) { - $status['translated'] = true; - $status['fileRevision'] = getRevision($trFile); - $status['fileEnRevision'] = getRevision($trFile, true); - if ($status['fileEnRevision'] && $status['lastEnRevision']) { - $distance = round((float) $status['lastEnRevision'], 3) - round((float) $status['fileEnRevision'], 3) ; - $backward = 0; - if ($distance<0) { - $backward = -1; - } elseif ($distance && $distance<.03) { - $backward = 1; - } elseif ($distance && $distance<.2) { - $backward = 2; - } elseif ($distance && $distance<.4) { - $backward = 3; - } elseif ($distance && $distance<.6) { - $backward = 4; - } elseif ($distance && $distance>=.6) { - $backward = 5; - } - $status['backward'] = $backward; - $status['distance'] = $distance; - } - } else { - $status['translated'] = false; - } - return $status; -} - -?> +<?php +//*-- The PHPDOC Online XML Editing Tool +//*-- Developed by Salah Faya visualmind(@)php.net +//*-- Version 1.0 - essentially developed for Arabic Translation of PHP Manual +//*-- Now updated to work with all phpdoc translations + +//--- base file (all other files require this to start) + +//------- Configuration +// Root path of cvs +$cvsRootPath = '/path/to/cvs/'; + +// Path to english xml sources from cvs +$enDocCVSPath = $cvsRootPath.'phpdoc/en/'; + +// Require User Login by email (needed for user file saving) +$requireLogin = false; + +if ($requireLogin) { + // Users folder where their cached files are saved - must be writable + $usersCachePath = '/path/to/editor/users/'; + // Files Permissions Mod + $filesChMod = 0777; +} + + +// Languages and paths: (ToDo Font should be defined for better display) + +addLanguage('Arabic', $cvsRootPath.'phpdoc-ar/ar/', 'ar', 'utf-8', 'RTL', 'doc-ar@lists.php.net', 'doc-ar-subscribe@lists.php.net', 'Salah Faya visualmind(@)php.net'); +addLanguage('Brazilian-PT', $cvsRootPath.'phpdoc-pt_BR/pt_BR/', 'pt_BR', 'iso-8859-1', 'LTR', 'doc-br@lists.php.net', 'doc-br-subscribe@lists.php.net', ''); +addLanguage('Bulgarian', $cvsRootPath.'phpdoc-bg/bg/', 'bg', 'utf-8', 'LTR', 'doc-bg@lists.php.net', 'doc-bg-subscribe@lists.php.net', ''); +addLanguage('Catalan', $cvsRootPath.'phpdoc-ca/ca/', 'ca', 'iso-8859-1', 'LTR', 'doc-ca@lists.php.net', 'doc-ca-subscribe@lists.php.net', ''); +addLanguage('Chinese-HK', $cvsRootPath.'phpdoc-hk/hk/', 'hk', 'big5', 'LTR', 'doc-hk@lists.php.net', 'doc-hk-subscribe@lists.php.net', ''); +addLanguage('Chinese-Simplified', $cvsRootPath.'phpdoc-zh/zh/', 'zh', 'gb2312', 'LTR', 'doc-zh@lists.php.net', 'doc-zh-subscribe@lists.php.net', ''); +addLanguage('Chinese-Traditional', $cvsRootPath.'phpdoc-tw/tw/', 'tw', 'big5', 'LTR', 'doc-tw@lists.php.net', 'doc-tw-subscribe@lists.php.net', ''); +addLanguage('Czech', $cvsRootPath.'phpdoc-cs/cs/', 'cs', 'iso-8859-2', 'LTR', 'doc-cs@lists.php.net', 'doc-cs-subscribe@lists.php.net', ''); +addLanguage('Danish', $cvsRootPath.'phpdoc-da/da/', 'da', 'iso-8859-1', 'LTR', 'doc-da@lists.php.net', 'doc-da-subscribe@lists.php.net', ''); +addLanguage('Dutch', $cvsRootPath.'phpdoc-nl/nl/', 'nl', 'iso-8859-1', 'LTR', 'doc-nl@lists.php.net', 'doc-nl-subscribe@lists.php.net', ''); +addLanguage('Finnish', $cvsRootPath.'phpdoc-fi/fi/', 'fi', 'iso-8859-1', 'LTR', 'doc-fi@lists.php.net', 'doc-fi-subscribe@lists.php.net', ''); +addLanguage('French', $cvsRootPath.'phpdoc-fr/fr/', 'fr', 'iso-8859-1', 'LTR', 'doc-fr@lists.php.net', 'doc-fr-subscribe@lists.php.net', ''); +addLanguage('German', $cvsRootPath.'phpdoc-de/de/', 'de', 'iso-8859-1', 'LTR', 'doc-de@lists.php.net', 'doc-de-subscribe@lists.php.net', ''); +addLanguage('Greek', $cvsRootPath.'phpdoc-el/el/', 'el', 'iso-8859-7', 'LTR', 'doc-el@lists.php.net', 'doc-el-subscribe@lists.php.net', ''); +addLanguage('Hebrew', $cvsRootPath.'phpdoc-he/he/', 'he', 'windows-1255', 'RTL', 'doc-he@lists.php.net', 'doc-he-subscribe@lists.php.net', ''); +addLanguage('Hungarian', $cvsRootPath.'phpdoc-hu/hu/', 'hu', 'iso-8859-2', 'LTR', 'doc-hu@lists.php.net', 'doc-hu-subscribe@lists.php.net', ''); +addLanguage('Indonesian', $cvsRootPath.'phpdoc-id/id/', 'id', 'iso-8859-1', 'LTR', 'doc-id@lists.php.net', 'doc-id-subscribe@lists.php.net', ''); +addLanguage('Italian', $cvsRootPath.'phpdoc-it/it/', 'it', 'iso-8859-1', 'LTR', 'doc-it@lists.php.net', 'doc-it-subscribe@lists.php.net', ''); +addLanguage('Japanese', $cvsRootPath.'phpdoc-ja/ja/', 'ja', 'utf-8', 'LTR', 'doc-ja@lists.php.net', 'doc-ja-subscribe@lists.php.net', ''); +addLanguage('Korean', $cvsRootPath.'phpdoc-kr/kr/', 'kr', 'utf-8', 'LTR', 'doc-kr@lists.php.net', 'doc-kr-subscribe@lists.php.net', ''); +addLanguage('Lithuanian', $cvsRootPath.'phpdoc-lt/lt/', 'lt', 'iso-8859-1', 'LTR', 'doc-lt@lists.php.net', 'doc-lt-subscribe@lists.php.net', ''); +addLanguage('Norwegian', $cvsRootPath.'phpdoc-no/no/', 'no', 'utf-8', 'LTR', 'doc-no@lists.php.net', 'doc-no-subscribe@lists.php.net', ''); +addLanguage('Polish', $cvsRootPath.'phpdoc-pl/pl/', 'pl', 'iso-8859-2', 'LTR', 'doc-pl@lists.php.net', 'doc-pl-subscribe@lists.php.net', ''); +addLanguage('Romanian', $cvsRootPath.'phpdoc-ro/ro/', 'ro', 'utf-8', 'LTR', 'doc-ro@lists.php.net', 'doc-ro-subscribe@lists.php.net', ''); +addLanguage('Russian', $cvsRootPath.'phpdoc-ru/ru/', 'ru', 'utf-8', 'LTR', 'doc-ru@lists.php.net', 'doc-ru-subscribe@lists.php.net', ''); +addLanguage('Slovak', $cvsRootPath.'phpdoc-sk/sk/', 'sk', 'iso-8859-2', 'LTR', 'doc-sk@lists.php.net', 'doc-sk-subscribe@lists.php.net', ''); +addLanguage('Slovenian', $cvsRootPath.'phpdoc-sl/sl/', 'sl', 'iso-8859-1', 'LTR', 'doc-sl@lists.php.net', 'doc-sl-subscribe@lists.php.net', ''); +addLanguage('Spanish', $cvsRootPath.'phpdoc-es/es/', 'es', 'iso-8859-1', 'LTR', 'doc-es@lists.php.net', 'doc-es-subscribe@lists.php.net', ''); +addLanguage('Swedish', $cvsRootPath.'phpdoc-sv/sv/', 'sv', 'iso-8859-1', 'LTR', 'doc-sv@lists.php.net', 'doc-sv-subscribe@lists.php.net', ''); +addLanguage('Turkish', $cvsRootPath.'phpdoc-tr/tr/', 'tr', 'utf-8', 'LTR', 'doc-tr@lists.php.net', 'doc-tr-subscribe@lists.php.net', ''); +//.. + + +// Hide files (ignore) +$ignoreListingFolders = array('.', '..', 'CVS'); +$ignoreListingFiles = array('contributors.xml', 'contributors.ent', 'livedocs.ent'); + +//------- Base functions + +function addLanguage($lang, $cvspath, $id, $charset='utf-8', $direction='LTR', $mailing='', $mailsubscribe='', $coodinator='', $font='Fixedsys') { + global $phpdocLangs; + $phpdocLangs[$lang]['DocCVSPath'] = $cvspath; + $phpdocLangs[$lang]['charset'] = $charset; + $phpdocLangs[$lang]['direction'] = $direction; + $phpdocLangs[$lang]['id'] = $id; + $phpdocLangs[$lang]['mailing'] = $mailing; + $phpdocLangs[$lang]['mailingSubscribe'] = $mailsubscribe; + $phpdocLangs[$lang]['coordinator'] = $coordinator; + $phpdocLangs[$lang]['font'] = $font; +} + +function sessionCheck($arguments='') { + session_start(); + if (!isset($_SESSION['user'])) { + if ($_SERVER['REQUEST_METHOD']=='GET') { + $_SESSION['redo'] = $_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING']; + } + header('location: login.php'.$arguments); + exit('<a href="login.php">Login first</a>'); + } + return $_SESSION['user']; +} + +function getDateTimeToLog() { + return date('d/m H:i [').time().']'; +} + +function getUserIP() { + return $_SERVER['REMOTE_ADDR']; +} + +function getCacheName($filename) { + // change reference/ext/file.xml to reference~ext~file.xml + $filename = str_replace(array('/', '\\'), '~', $filename); + return $filename; +} + +function stripslashes2($text) { + if (get_magic_quotes_gpc()) { + $text = stripslashes($text); + } + return $text; +} + +function getRevision($file, $en=false) { + $f = fopen($file, "rb"); + $data = fread($f, 200); + fclose($f); + + // Use en-revision + if ($en) { + preg_match("#<!-- *EN-Revision: +([0-9\.]+)#i", $data, $result); + $rev = $result[1]; + } else { + preg_match("#<!-- *\\$"."Revision: +([0-9\.]+)#i", $data, $result); + $rev = $result[1]; + } + return $rev; +} + +function getTranslationStatus($file) { + global $user, $phpdocLangs, $enDocCVSPath; + + $lang = $user['phpdocLang']; + $translationPath = $phpdocLangs[$lang]['DocCVSPath']; + $trFile = $translationPath.$file; + $enFile = $enDocCVSPath.$file; + + $status['lastEnRevision'] = getRevision($enFile); + if (file_exists($trFile)) { + $status['translated'] = true; + $status['fileRevision'] = getRevision($trFile); + $status['fileEnRevision'] = getRevision($trFile, true); + if ($status['fileEnRevision'] && $status['lastEnRevision']) { + $distance = round((float) $status['lastEnRevision'], 3) - round((float) $status['fileEnRevision'], 3) ; + $backward = 0; + if ($distance<0) { + $backward = -1; + } elseif ($distance && $distance<.03) { + $backward = 1; + } elseif ($distance && $distance<.2) { + $backward = 2; + } elseif ($distance && $distance<.4) { + $backward = 3; + } elseif ($distance && $distance<.6) { + $backward = 4; + } elseif ($distance && $distance>=.6) { + $backward = 5; + } + $status['backward'] = $backward; + $status['distance'] = $distance; + } + } else { + $status['translated'] = false; + } + return $status; +} + +?> http://cvs.php.net/viewvc.cgi/phpdoc/scripts/online_editor/login.php?r1=1.1&r2=1.2&diff_format=u Index: phpdoc/scripts/online_editor/login.php diff -u phpdoc/scripts/online_editor/login.php:1.1 phpdoc/scripts/online_editor/login.php:1.2 --- phpdoc/scripts/online_editor/login.php:1.1 Tue May 6 11:43:48 2008 +++ phpdoc/scripts/online_editor/login.php Tue May 6 15:53:26 2008 @@ -1,117 +1,117 @@ -<?php -//*-- The PHPDOC Online XML Editing Tool -//*-- Developed by Salah Faya visualmind(@)php.net -//*-- Version 1.0 - essentially developed for Arabic Translation of PHP Manual -//*-- Now updated to work with all phpdoc translations - -//--- This file allows users to login using an email address (TODO we may use CVS or other way in future) - -//------- Initialization -require 'base.php'; - -session_start(); - -// Logout &and=logout -if (isset($_GET['and'])) { - session_unregister('user'); - unset($_SESSION['user']); -} - - -//------- Login request -if (isset($_POST['lang'])) { - - if (isset($_POST['email'])) { - $email = $_POST['email']; - } - - $lang = $_POST['lang']; - - // Check selected language - if (!isset($phpdocLangs[$lang])) { - exit('Sorry, you have choosen an incorrect language'); - } - - if ($requireLogin) { - // Simple email validation -- ToDo some enhancements - $email = trim(strtolower($email)); - $p1 = preg_match("#^([a-z0-9][a-z0-9_\.]*)@[a-z0-9][a-z0-9\-]+\.[a-z]{2,6}$#", $email); - $p2 = preg_match("#^([a-z0-9][a-z0-9_\.]*)@[a-z0-9][a-z0-9\-]+\.[a-z]{2,3}\.[a-z]{2}$#", $email); - - if (!$p1 && !$p2) { - exit('That was not a valid email address'); - } - // This validation is required because emails are used as user folder name -- ToDO use another way - if (strlen($email)>50) { - exit('That was not a valid email address'); - } - - // Do Login (create user folder) - if (!file_exists($usersCachePath.$email)) { - @mkdir($usersCachePath.$email, $filesChMod); - } - - } - - - - if (is_dir($usersCachePath.$email) || !$requireLogin) { - - // Session setup - session_register('user'); - $_SESSION['user'] = array('email'=>$email, 'cache'=>$usersCachePath.$email.'/', 'phpdocLang'=>$lang); - - // If expired session, redo last request - if ($_SESSION['redo']) { - $link = $_SESSION['redo']; - $_SESSION['redo'] = false; - header("location: $link"); - exit; - } - - // If accidently lost session while editing - if ($_REQUEST['from']=='editxml') { - exit('Ok, Login is <b>successful</b>. Now retry your previous request'); - } - - // Redirect to frameset - header('location: workbench.php'); - exit('<a href="workbench.php">Moved to workbench.php</a>'); - } else { - // If folder has not been created - exit('Sorry, there was an internal error. Please contact administration'); - } -} - -//------- Login form -?> -<html> -<body style="font-family: Tahoma; font-size: 12px;"> - -<h3> The PHPDOC Online XML Editing Tool :: Login first</h3> -<form action=login.php method=post> -<input type=hidden name=from value="<?php print $_REQUEST['from']; ?>"> -<?php -if ($requireLogin) { ?> -Your email address (must be valid) <input type=text name=email><br> -<?php } ?> -Translating PHPDOC to -<select name=lang><?php -foreach($phpdocLangs as $lang=>$langInfo) { - print "<option value='$lang'>$lang</option>"; -} -?> -</select>* <input type=submit value=Login> -</form> - - Developed by Salah Faya visualmind(@)php.net<br> - Version 1.0 - essentially developed for Arabic Translation of PHP Manual<br> - Now updated to work with all phpdoc translations. -<br> - This is a special tool to be used only by PHPDOC translators.<br> - -Javascript and cookies must be enabled in your browser settings.<br> -<br> -<b>Last CVS Update: <?php print implode('', file('cvsupdate.txt')); ?></b> -</body> -</html> +<?php +//*-- The PHPDOC Online XML Editing Tool +//*-- Developed by Salah Faya visualmind(@)php.net +//*-- Version 1.0 - essentially developed for Arabic Translation of PHP Manual +//*-- Now updated to work with all phpdoc translations + +//--- This file allows users to login using an email address (TODO we may use CVS or other way in future) + +//------- Initialization +require 'base.php'; + +session_start(); + +// Logout &and=logout +if (isset($_GET['and'])) { + session_unregister('user'); + unset($_SESSION['user']); +} + + +//------- Login request +if (isset($_POST['lang'])) { + + if (isset($_POST['email'])) { + $email = $_POST['email']; + } + + $lang = $_POST['lang']; + + // Check selected language + if (!isset($phpdocLangs[$lang])) { + exit('Sorry, you have choosen an incorrect language'); + } + + if ($requireLogin) { + // Simple email validation -- ToDo some enhancements + $email = trim(strtolower($email)); + $p1 = preg_match("#^([a-z0-9][a-z0-9_\.]*)@[a-z0-9][a-z0-9\-]+\.[a-z]{2,6}$#", $email); + $p2 = preg_match("#^([a-z0-9][a-z0-9_\.]*)@[a-z0-9][a-z0-9\-]+\.[a-z]{2,3}\.[a-z]{2}$#", $email); + + if (!$p1 && !$p2) { + exit('That was not a valid email address'); + } + // This validation is required because emails are used as user folder name -- ToDO use another way + if (strlen($email)>50) { + exit('That was not a valid email address'); + } + + // Do Login (create user folder) + if (!file_exists($usersCachePath.$email)) { + @mkdir($usersCachePath.$email, $filesChMod); + } + + } + + + + if (is_dir($usersCachePath.$email) || !$requireLogin) { + + // Session setup + session_register('user'); + $_SESSION['user'] = array('email'=>$email, 'cache'=>$usersCachePath.$email.'/', 'phpdocLang'=>$lang); + + // If expired session, redo last request + if ($_SESSION['redo']) { + $link = $_SESSION['redo']; + $_SESSION['redo'] = false; + header("location: $link"); + exit; + } + + // If accidently lost session while editing + if ($_REQUEST['from']=='editxml') { + exit('Ok, Login is <b>successful</b>. Now retry your previous request'); + } + + // Redirect to frameset + header('location: workbench.php'); + exit('<a href="workbench.php">Moved to workbench.php</a>'); + } else { + // If folder has not been created + exit('Sorry, there was an internal error. Please contact administration'); + } +} + +//------- Login form +?> +<html> +<body style="font-family: Tahoma; font-size: 12px;"> + +<h3> The PHPDOC Online XML Editing Tool :: Choose your language</h3> +<form action=login.php method=post> +<input type=hidden name=from value="<?php print $_REQUEST['from']; ?>"> +<?php +if ($requireLogin) { ?> +Your email address (must be valid) <input type=text name=email><br> +<?php } ?> +Translating PHPDOC to +<select name=lang><?php +foreach($phpdocLangs as $lang=>$langInfo) { + print "<option value='$lang'>$lang</option>"; +} +?> +</select>* <input type=submit value="Start editing"> +</form> + + Developed by Salah Faya visualmind(@)php.net<br> + Version 1.0 - essentially developed for Arabic Translation of PHP Manual<br> + Now updated to work with all phpdoc translations. +<br> + This is a special tool to be used only by PHPDOC translators.<br> + +Javascript and cookies must be enabled in your browser settings.<br> +<br> +<b>Last CVS Update: <?php print implode('', file('cvsupdate.txt')); ?></b> +</body> +</html> http://cvs.php.net/viewvc.cgi/phpdoc/scripts/online_editor/cvslist.php?r1=1.1&r2=1.2&diff_format=u Index: phpdoc/scripts/online_editor/cvslist.php diff -u phpdoc/scripts/online_editor/cvslist.php:1.1 phpdoc/scripts/online_editor/cvslist.php:1.2 --- phpdoc/scripts/online_editor/cvslist.php:1.1 Tue May 6 11:43:48 2008 +++ phpdoc/scripts/online_editor/cvslist.php Tue May 6 15:53:26 2008 @@ -1,209 +1,216 @@ -<?php -//*-- The PHPDOC Online XML Editing Tool -//*-- Developed by Salah Faya visualmind(@)php.net -//*-- Version 1.0 - essentially developed for Arabic Translation of PHP Manual -//*-- Now updated to work with all phpdoc translations - -//--- This file lists the folders and files in the left frame - -//------- Initialization -require 'base.php'; -$user = sessionCheck(); - -$lang = $user['phpdocLang']; -$translationPath = $phpdocLangs[$lang]['DocCVSPath']; - -//------- Folder navigation vars -$path = ''; -$file = ''; -if (isset($_REQUEST['path'])) { - $path = $_REQUEST['path']; - if (isset($_REQUEST['file'])) { - $file = $_REQUEST['file']; - } -} - -// Prevent wrong paths -if (strstr($path, '.') || $file=='..' || $file=='.') { - exit; -} - - -// Path Slashes -if (!$path) $path = '/'; -if (substr($path, -1)!='/') $path .= '/'; - - -// Usually, the path are based on english cvs -$target = "$enDocCVSPath$path$file"; - - -//------- Decide what to do - -// If file is selected, redirect to the editor.. - -if ($file) { - // Find in user path first (editing cached file by default) - $ffile = $user['cache'].getCacheName($path.$file); - if (file_exists($ffile)) { - header("location: editxml.php?file=$path$file&source=upath"); - exit; - } - - // Find in translated path (edit the translated file) - $ffile = "$translationPath$path$file"; - if (file_exists($ffile)) { - header("location: editxml.php?file=$path$file&source=apath"); - exit; - } - - // So it's a new file? Use the english source - if (file_exists($target)) { - header("location: editxml.php?file=$path$file&source=epath"); - exit; - } -} else { - - // No file selected, Listing (from english cvs) - $d = opendir($target); - while($f = readdir($d)) { - if (is_dir($target.$f)) { - if (in_array($f, $ignoreListingFolders)) continue; - $dirs[] = $f; - } elseif ((substr($f, -4)=='.xml' || substr($f, -4)=='.ent') && !in_array($f, $ignoreListingFiles)) { - $files[] = $f; - } - } - -} - - -//------- Functions -function printPathAsLinks($path) { - global $lang; - - $px = explode('/', $path); - foreach($px as $i=>$p) { - $pp .= $p.'/'; - if (!$p && !$i) $p = $lang; - print "<a href='?path=$pp'>$p</a>"; - if ($p || !$i) print '/'; - } - print '<br>'; -} - - -function printDirectories($dirs, $path) { - sort($dirs); - foreach($dirs as $dir) { - print "<a href='?path=$path$dir'><img src='images/dir.png' width=16 height=16 border=0 align=absmiddle> $dir</a> <br>"; - } -} - -function printFiles($files, $path) { - global $translationPath, $user; - - sort($files); - foreach($files as $fl) { - $status = getTranslationStatus($path.$fl); - if ($status['translated']) { - if ($status['fileEnRevision'] && $status['lastEnRevision'] && $status['distance']>=0) { - if (!$status['backward']) { - $title = 'Up to date'; - $img = 'images/up2date.png'; - } else { - $title = 'Outdated '.$status['fileEnRevision'].' / '.$status['lastEnRevision']; - $img = 'images/r'.($status['backward']+1).'.png'; - } - } else { - $title = 'EN-Revision is incorrect or missing'; - $img = 'images/unknown.png'; - } - } else { - $title = 'Not translated yet'; - $img = 'images/notyet.png'; - } - - print "<a href='?path=$path&file=$fl' target=fileframe><img src='images/text.png' width=16 height=16 border=0 align=absmiddle> $fl</a> <img src='$img' border=0 align=absmiddle alt='$title'><br>"; - } - - // Lists the user's cached files - if (file_exists($user['cache']."files.txt")) { - print '<hr>'; - print 'Cached files:<br>'; - $ff = file($user['cache']."files.txt"); - foreach($ff as $f) { - $fx = explode('|', $f); - if (!isset($cf[$fx[2]])) { - print "<a href='editxml.php?file=$fx[2]&source=upath' target=fileframe>$fx[2]</a><br>"; - $cf[$fx[2]] = true; - } - } - } - -} - - -//------- Output -?> -<html> -<body bgcolor="#FFFFFF"> -<style type="text/css"> -body { - font-family: Tahoma; - font-size: 12px; -} -a:link { - text-decoration: none; - color: #000066; -} - -a:hover { - text-decoration: none; - color: #ff0000; -} - -a:active { - text-decoration: none; - color: #ff0000; -} - -a:visited { - text-decoration: none; - color: #000066; -} - - </style> -<div style="width: 400px;"> -Listing: -<?php - -printPathAsLinks($path); - -printDirectories($dirs, $path); - -printFiles($files, $path); - -?> -<hr> - -<form action=login.php method=post target=_top> -<?php -if ($requireLogin) { ?> - <input type=hidden name=email value="<?php print $user['email']; ?>"><br> -<?php } ?> -Switch language:<br> -<select name=lang onchange="if (this.value) this.form.submit();"> -<option value=''></option> -<?php -foreach($phpdocLangs as $lng=>$langInfo) { - if ($lng==$lang) $sel = " selected"; else $sel = ''; - print "<option value='$lng'$sel>$lng</option>"; -} -?> -</select> -</form> - -</div> -</body> -</html> +<?php +//*-- The PHPDOC Online XML Editing Tool +//*-- Developed by Salah Faya visualmind(@)php.net +//*-- Version 1.0 - essentially developed for Arabic Translation of PHP Manual +//*-- Now updated to work with all phpdoc translations + +//--- This file lists the folders and files in the left frame + +//------- Initialization +require 'base.php'; +$user = sessionCheck(); + +$lang = $user['phpdocLang']; +$translationPath = $phpdocLangs[$lang]['DocCVSPath']; + +//------- Folder navigation vars +$path = ''; +$file = ''; +if (isset($_REQUEST['path'])) { + $path = $_REQUEST['path']; + if (isset($_REQUEST['file'])) { + $file = $_REQUEST['file']; + } +} + +// Prevent wrong paths +if (strstr($path, '.') || $file=='..' || $file=='.') { + exit; +} + + +// Path Slashes +if (!$path) $path = '/'; +if (substr($path, -1)!='/') $path .= '/'; + + +// Usually, the path are based on english cvs +$target = "$enDocCVSPath$path$file"; + + +//------- Decide what to do + +// If file is selected, redirect to the editor.. + +if ($file) { + // Find in user path first (editing cached file by default) + $ffile = $user['cache'].getCacheName($path.$file); + if (file_exists($ffile)) { + header("location: editxml.php?file=$path$file&source=upath"); + exit; + } + + // Find in translated path (edit the translated file) + $ffile = "$translationPath$path$file"; + if (file_exists($ffile)) { + header("location: editxml.php?file=$path$file&source=apath"); + exit; + } + + // So it's a new file? Use the english source + if (file_exists($target)) { + header("location: editxml.php?file=$path$file&source=epath"); + exit; + } +} else { + + // No file selected, Listing (from english cvs) + $d = opendir($target); + while($f = readdir($d)) { + if (is_dir($target.$f)) { + if (in_array($f, $ignoreListingFolders)) continue; + $dirs[] = $f; + } elseif ((substr($f, -4)=='.xml' || substr($f, -4)=='.ent') && !in_array($f, $ignoreListingFiles)) { + $files[] = $f; + } + } + +} + + +//------- Functions +function printPathAsLinks($path) { + global $lang; + + $px = explode('/', $path); + foreach($px as $i=>$p) { + $pp .= $p.'/'; + if (!$p && !$i) $p = $lang; + print "<a href='?path=$pp'>$p</a>"; + if ($p || !$i) print '/'; + } + print '<br>'; +} + + +function printDirectories($dirs, $path) { + sort($dirs); + foreach($dirs as $dir) { + print "<a href='?path=$path$dir'><img src='images/dir.png' width=16 height=16 border=0 align=absmiddle> $dir</a> <br>"; + } +} + +function printFiles($files, $path) { + global $translationPath, $user; + + sort($files); + foreach($files as $fl) { + $status = getTranslationStatus($path.$fl); + if ($status['translated']) { + if ($status['fileEnRevision'] && $status['lastEnRevision'] && $status['distance']>=0) { + if (!$status['backward']) { + $title = 'Up to date'; + $img = 'images/up2date.png'; + } else { + $title = 'Outdated '.$status['fileEnRevision'].' / '.$status['lastEnRevision']; + $img = 'images/r'.($status['backward']+1).'.png'; + } + } else { + $title = 'EN-Revision is incorrect or missing'; + $img = 'images/unknown.png'; + } + } else { + $title = 'Not translated yet'; + $img = 'images/notyet.png'; + } + + print "<a href='?path=$path&file=$fl' target=fileframe><img src='images/text.png' width=16 height=16 border=0 align=absmiddle> $fl</a> <img src='$img' border=0 align=absmiddle alt='$title'><br>"; + } + + // Lists the user's cached files + if (file_exists($user['cache']."files.txt")) { + print '<hr>'; + print 'Cached files:<br>'; + $ff = file($user['cache']."files.txt"); + foreach($ff as $f) { + $fx = explode('|', $f); + if (!isset($cf[$fx[2]])) { + print "<a href='editxml.php?file=$fx[2]&source=upath' target=fileframe>$fx[2]</a><br>"; + $cf[$fx[2]] = true; + } + } + } + +} + + +//------- Output +?> +<html> +<body bgcolor="#FFFFFF"> +<style type="text/css"> +body { + font-family: Tahoma; + font-size: 12px; +} +a:link { + text-decoration: none; + color: #000066; +} + +a:hover { + text-decoration: none; + color: #ff0000; +} + +a:active { + text-decoration: none; + color: #ff0000; +} + +a:visited { + text-decoration: none; + color: #000066; +} + + </style> +<div style="width: 400px;"> +Listing: +<?php + +printPathAsLinks($path); + +printDirectories($dirs, $path); + +printFiles($files, $path); + +?> +<hr> + +<form action=login.php method=post target=_top> +<?php +if ($requireLogin) { ?> + <input type=hidden name=email value="<?php print $user['email']; ?>"><br> +<?php } ?> +Switch language:<br> +<select name=lang onchange="if (this.value) this.form.submit();"> +<option value=''></option> +<?php +foreach($phpdocLangs as $lng=>$langInfo) { + if ($lng==$lang) $sel = " selected"; else $sel = ''; + print "<option value='$lng'$sel>$lng</option>"; +} +?> +</select> +</form> + +<hr> +Legend:<br> +<img src=images/notyet.png> Not yet translated<br> +<img src=images/up2date.png> File is translated and up to date<br> +<img src=images/unknown.png> EN-Revision is incorrect or missing<br> +<img src=images/r6.png> How much is outdated-<br> gauge (hover it for revision). + +</div> +</body> +</html>
http://cvs.php.net/viewvc.cgi/phpdoc/scripts/online_editor/base.php?r1=1.1&r2=1.2&diff_format=u Index: phpdoc/scripts/online_editor/base.php diff -u phpdoc/scripts/online_editor/base.php:1.1 phpdoc/scripts/online_editor/base.php:1.2 --- phpdoc/scripts/online_editor/base.php:1.1 Tue May 6 11:43:48 2008 +++ phpdoc/scripts/online_editor/base.php Tue May 6 15:53:26 2008 @@ -1,144 +1,167 @@ -<?php -//*-- The PHPDOC Online XML Editing Tool -//*-- Developed by Salah Faya visualmind(@)php.net -//*-- Version 1.0 - essentially developed for Arabic Translation of PHP Manual -//*-- Now updated to work with all phpdoc translations - -//--- base file (all other files require this to start) - -//------- Configuration -// Root path of cvs -$cvsRootPath = '/path/to/cvs/'; - -// Path to english xml sources from cvs -$enDocCVSPath = $cvsRootPath.'phpdoc/en/'; - -// Require User Login by email (needed for user file saving) -$requireLogin = false; - -if ($requireLogin) { - // Users folder where their cached files are saved - must be writable - $usersCachePath = '/path/to/editor/users/'; - // Files Permissions Mod - $filesChMod = 0777; -} - - -// Languages and paths: - -addLanguage('Arabic', $cvsRootPath.'phpdoc-ar/ar/', 'ar', 'utf-8', 'RTL', 'doc-ar@lists.php.net', 'doc-ar-subscribe@lists.php.net', 'Salah Faya visualmind(@)php.net'); - -addLanguage('Chinese-Simplified', $cvsRootPath.'phpdoc-zh/zh/', 'zh', 'gb2312', 'LTR', 'doc-zh@lists.php.net', 'doc-zh-subscribe@lists.php.net', ''); -addLanguage('Chinese-Traditional', $cvsRootPath.'phpdoc-tw/tw/', 'tw', 'big5', 'LTR', 'doc-tw@lists.php.net', 'doc-tw-subscribe@lists.php.net', ''); -addLanguage('Czech', $cvsRootPath.'phpdoc-cs/cs/', 'cs', 'iso-8859-2', 'LTR', 'doc-cs@lists.php.net', 'doc-cs-subscribe@lists.php.net', ''); -addLanguage('French', $cvsRootPath.'phpdoc-fr/fr/', 'fr', 'iso-8859-1', 'LTR', 'doc-fr@lists.php.net', 'doc-fr-subscribe@lists.php.net', ''); -addLanguage('Germany', $cvsRootPath.'phpdoc-de/de/', 'de', 'utf-8', 'LTR', 'doc-de@lists.php.net', 'doc-de-subscribe@lists.php.net', ''); -//.. - - -// Hide files (ignore) -$ignoreListingFolders = array('.', '..', 'CVS'); -$ignoreListingFiles = array('contributors.xml', 'contributors.ent', 'livedocs.ent'); - -//------- Base functions - -function addLanguage($lang, $cvspath, $id, $charset='utf-8', $direction='LTR', $mailing='', $mailsubscribe='', $coodinator='', $font='Fixedsys') { - global $phpdocLangs; - $phpdocLangs[$lang]['DocCVSPath'] = $cvspath; - $phpdocLangs[$lang]['charset'] = $charset; - $phpdocLangs[$lang]['direction'] = $direction; - $phpdocLangs[$lang]['id'] = $id; - $phpdocLangs[$lang]['mailing'] = $mailing; - $phpdocLangs[$lang]['mailingSubscribe'] = $mailsubscribe; - $phpdocLangs[$lang]['coordinator'] = $coordinator; - $phpdocLangs[$lang]['font'] = $font; -} - -function sessionCheck($arguments='') { - session_start(); - if (!isset($_SESSION['user'])) { - if ($_SERVER['REQUEST_METHOD']=='GET') { - $_SESSION['redo'] = $_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING']; - } - header('location: login.php'.$arguments); - exit('<a href="login.php">Login first</a>'); - } - return $_SESSION['user']; -} - -function getDateTimeToLog() { - return date('d/m H:i [').time().']'; -} - -function getUserIP() { - return $_SERVER['REMOTE_ADDR']; -} - -function getCacheName($filename) { - // change reference/ext/file.xml to reference~ext~file.xml - $filename = str_replace(array('/', '\\'), '~', $filename); - return $filename; -} - -function stripslashes2($text) { - if (get_magic_quotes_gpc()) { - $text = stripslashes($text); - } - return $text; -} - -function getRevision($file, $en=false) { - $f = fopen($file, "rb"); - $data = fread($f, 200); - fclose($f); - - // Use en-revision - if ($en) { - preg_match("#<!-- *EN-Revision: +([0-9\.]+)#i", $data, $result); - $rev = $result[1]; - } else { - preg_match("#<!-- *\\$"."Revision: +([0-9\.]+)#i", $data, $result); - $rev = $result[1]; - } - return $rev; -} - -function getTranslationStatus($file) { - global $user, $phpdocLangs, $enDocCVSPath; - - $lang = $user['phpdocLang']; - $translationPath = $phpdocLangs[$lang]['DocCVSPath']; - $trFile = $translationPath.$file; - $enFile = $enDocCVSPath.$file; - - $status['lastEnRevision'] = getRevision($enFile); - if (file_exists($trFile)) { - $status['translated'] = true; - $status['fileRevision'] = getRevision($trFile); - $status['fileEnRevision'] = getRevision($trFile, true); - if ($status['fileEnRevision'] && $status['lastEnRevision']) { - $distance = round((float) $status['lastEnRevision'], 3) - round((float) $status['fileEnRevision'], 3) ; - $backward = 0; - if ($distance<0) { - $backward = -1; - } elseif ($distance && $distance<.03) { - $backward = 1; - } elseif ($distance && $distance<.2) { - $backward = 2; - } elseif ($distance && $distance<.4) { - $backward = 3; - } elseif ($distance && $distance<.6) { - $backward = 4; - } elseif ($distance && $distance>=.6) { - $backward = 5; - } - $status['backward'] = $backward; - $status['distance'] = $distance; - } - } else { - $status['translated'] = false; - } - return $status; -} - -?> +<?php +//*-- The PHPDOC Online XML Editing Tool +//*-- Developed by Salah Faya visualmind(@)php.net +//*-- Version 1.0 - essentially developed for Arabic Translation of PHP Manual +//*-- Now updated to work with all phpdoc translations + +//--- base file (all other files require this to start) + +//------- Configuration +// Root path of cvs +$cvsRootPath = '/path/to/cvs/'; + +// Path to english xml sources from cvs +$enDocCVSPath = $cvsRootPath.'phpdoc/en/'; + +// Require User Login by email (needed for user file saving) +$requireLogin = false; + +if ($requireLogin) { + // Users folder where their cached files are saved - must be writable + $usersCachePath = '/path/to/editor/users/'; + // Files Permissions Mod + $filesChMod = 0777; +} + + +// Languages and paths: (ToDo Font should be defined for better display) + +addLanguage('Arabic', $cvsRootPath.'phpdoc-ar/ar/', 'ar', 'utf-8', 'RTL', 'doc-ar@lists.php.net', 'doc-ar-subscribe@lists.php.net', 'Salah Faya visualmind(@)php.net'); +addLanguage('Brazilian-PT', $cvsRootPath.'phpdoc-pt_BR/pt_BR/', 'pt_BR', 'iso-8859-1', 'LTR', 'doc-br@lists.php.net', 'doc-br-subscribe@lists.php.net', ''); +addLanguage('Bulgarian', $cvsRootPath.'phpdoc-bg/bg/', 'bg', 'utf-8', 'LTR', 'doc-bg@lists.php.net', 'doc-bg-subscribe@lists.php.net', ''); +addLanguage('Catalan', $cvsRootPath.'phpdoc-ca/ca/', 'ca', 'iso-8859-1', 'LTR', 'doc-ca@lists.php.net', 'doc-ca-subscribe@lists.php.net', ''); +addLanguage('Chinese-HK', $cvsRootPath.'phpdoc-hk/hk/', 'hk', 'big5', 'LTR', 'doc-hk@lists.php.net', 'doc-hk-subscribe@lists.php.net', ''); +addLanguage('Chinese-Simplified', $cvsRootPath.'phpdoc-zh/zh/', 'zh', 'gb2312', 'LTR', 'doc-zh@lists.php.net', 'doc-zh-subscribe@lists.php.net', ''); +addLanguage('Chinese-Traditional', $cvsRootPath.'phpdoc-tw/tw/', 'tw', 'big5', 'LTR', 'doc-tw@lists.php.net', 'doc-tw-subscribe@lists.php.net', ''); +addLanguage('Czech', $cvsRootPath.'phpdoc-cs/cs/', 'cs', 'iso-8859-2', 'LTR', 'doc-cs@lists.php.net', 'doc-cs-subscribe@lists.php.net', ''); +addLanguage('Danish', $cvsRootPath.'phpdoc-da/da/', 'da', 'iso-8859-1', 'LTR', 'doc-da@lists.php.net', 'doc-da-subscribe@lists.php.net', ''); +addLanguage('Dutch', $cvsRootPath.'phpdoc-nl/nl/', 'nl', 'iso-8859-1', 'LTR', 'doc-nl@lists.php.net', 'doc-nl-subscribe@lists.php.net', ''); +addLanguage('Finnish', $cvsRootPath.'phpdoc-fi/fi/', 'fi', 'iso-8859-1', 'LTR', 'doc-fi@lists.php.net', 'doc-fi-subscribe@lists.php.net', ''); +addLanguage('French', $cvsRootPath.'phpdoc-fr/fr/', 'fr', 'iso-8859-1', 'LTR', 'doc-fr@lists.php.net', 'doc-fr-subscribe@lists.php.net', ''); +addLanguage('German', $cvsRootPath.'phpdoc-de/de/', 'de', 'iso-8859-1', 'LTR', 'doc-de@lists.php.net', 'doc-de-subscribe@lists.php.net', ''); +addLanguage('Greek', $cvsRootPath.'phpdoc-el/el/', 'el', 'iso-8859-7', 'LTR', 'doc-el@lists.php.net', 'doc-el-subscribe@lists.php.net', ''); +addLanguage('Hebrew', $cvsRootPath.'phpdoc-he/he/', 'he', 'windows-1255', 'RTL', 'doc-he@lists.php.net', 'doc-he-subscribe@lists.php.net', ''); +addLanguage('Hungarian', $cvsRootPath.'phpdoc-hu/hu/', 'hu', 'iso-8859-2', 'LTR', 'doc-hu@lists.php.net', 'doc-hu-subscribe@lists.php.net', ''); +addLanguage('Indonesian', $cvsRootPath.'phpdoc-id/id/', 'id', 'iso-8859-1', 'LTR', 'doc-id@lists.php.net', 'doc-id-subscribe@lists.php.net', ''); +addLanguage('Italian', $cvsRootPath.'phpdoc-it/it/', 'it', 'iso-8859-1', 'LTR', 'doc-it@lists.php.net', 'doc-it-subscribe@lists.php.net', ''); +addLanguage('Japanese', $cvsRootPath.'phpdoc-ja/ja/', 'ja', 'utf-8', 'LTR', 'doc-ja@lists.php.net', 'doc-ja-subscribe@lists.php.net', ''); +addLanguage('Korean', $cvsRootPath.'phpdoc-kr/kr/', 'kr', 'utf-8', 'LTR', 'doc-kr@lists.php.net', 'doc-kr-subscribe@lists.php.net', ''); +addLanguage('Lithuanian', $cvsRootPath.'phpdoc-lt/lt/', 'lt', 'iso-8859-1', 'LTR', 'doc-lt@lists.php.net', 'doc-lt-subscribe@lists.php.net', ''); +addLanguage('Norwegian', $cvsRootPath.'phpdoc-no/no/', 'no', 'utf-8', 'LTR', 'doc-no@lists.php.net', 'doc-no-subscribe@lists.php.net', ''); +addLanguage('Polish', $cvsRootPath.'phpdoc-pl/pl/', 'pl', 'iso-8859-2', 'LTR', 'doc-pl@lists.php.net', 'doc-pl-subscribe@lists.php.net', ''); +addLanguage('Romanian', $cvsRootPath.'phpdoc-ro/ro/', 'ro', 'utf-8', 'LTR', 'doc-ro@lists.php.net', 'doc-ro-subscribe@lists.php.net', ''); +addLanguage('Russian', $cvsRootPath.'phpdoc-ru/ru/', 'ru', 'utf-8', 'LTR', 'doc-ru@lists.php.net', 'doc-ru-subscribe@lists.php.net', ''); +addLanguage('Slovak', $cvsRootPath.'phpdoc-sk/sk/', 'sk', 'iso-8859-2', 'LTR', 'doc-sk@lists.php.net', 'doc-sk-subscribe@lists.php.net', ''); +addLanguage('Slovenian', $cvsRootPath.'phpdoc-sl/sl/', 'sl', 'iso-8859-1', 'LTR', 'doc-sl@lists.php.net', 'doc-sl-subscribe@lists.php.net', ''); +addLanguage('Spanish', $cvsRootPath.'phpdoc-es/es/', 'es', 'iso-8859-1', 'LTR', 'doc-es@lists.php.net', 'doc-es-subscribe@lists.php.net', ''); +addLanguage('Swedish', $cvsRootPath.'phpdoc-sv/sv/', 'sv', 'iso-8859-1', 'LTR', 'doc-sv@lists.php.net', 'doc-sv-subscribe@lists.php.net', ''); +addLanguage('Turkish', $cvsRootPath.'phpdoc-tr/tr/', 'tr', 'utf-8', 'LTR', 'doc-tr@lists.php.net', 'doc-tr-subscribe@lists.php.net', ''); +//.. + + +// Hide files (ignore) +$ignoreListingFolders = array('.', '..', 'CVS'); +$ignoreListingFiles = array('contributors.xml', 'contributors.ent', 'livedocs.ent'); + +//------- Base functions + +function addLanguage($lang, $cvspath, $id, $charset='utf-8', $direction='LTR', $mailing='', $mailsubscribe='', $coodinator='', $font='Fixedsys') { + global $phpdocLangs; + $phpdocLangs[$lang]['DocCVSPath'] = $cvspath; + $phpdocLangs[$lang]['charset'] = $charset; + $phpdocLangs[$lang]['direction'] = $direction; + $phpdocLangs[$lang]['id'] = $id; + $phpdocLangs[$lang]['mailing'] = $mailing; + $phpdocLangs[$lang]['mailingSubscribe'] = $mailsubscribe; + $phpdocLangs[$lang]['coordinator'] = $coordinator; + $phpdocLangs[$lang]['font'] = $font; +} + +function sessionCheck($arguments='') { + session_start(); + if (!isset($_SESSION['user'])) { + if ($_SERVER['REQUEST_METHOD']=='GET') { + $_SESSION['redo'] = $_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING']; + } + header('location: login.php'.$arguments); + exit('<a href="login.php">Login first</a>'); + } + return $_SESSION['user']; +} + +function getDateTimeToLog() { + return date('d/m H:i [').time().']'; +} + +function getUserIP() { + return $_SERVER['REMOTE_ADDR']; +} + +function getCacheName($filename) { + // change reference/ext/file.xml to reference~ext~file.xml + $filename = str_replace(array('/', '\\'), '~', $filename); + return $filename; +} + +function stripslashes2($text) { + if (get_magic_quotes_gpc()) { + $text = stripslashes($text); + } + return $text; +} + +function getRevision($file, $en=false) { + $f = fopen($file, "rb"); + $data = fread($f, 200); + fclose($f); + + // Use en-revision + if ($en) { + preg_match("#<!-- *EN-Revision: +([0-9\.]+)#i", $data, $result); + $rev = $result[1]; + } else { + preg_match("#<!-- *\\$"."Revision: +([0-9\.]+)#i", $data, $result); + $rev = $result[1]; + } + return $rev; +} + +function getTranslationStatus($file) { + global $user, $phpdocLangs, $enDocCVSPath; + + $lang = $user['phpdocLang']; + $translationPath = $phpdocLangs[$lang]['DocCVSPath']; + $trFile = $translationPath.$file; + $enFile = $enDocCVSPath.$file; + + $status['lastEnRevision'] = getRevision($enFile); + if (file_exists($trFile)) { + $status['translated'] = true; + $status['fileRevision'] = getRevision($trFile); + $status['fileEnRevision'] = getRevision($trFile, true); + if ($status['fileEnRevision'] && $status['lastEnRevision']) { + $distance = round((float) $status['lastEnRevision'], 3) - round((float) $status['fileEnRevision'], 3) ; + $backward = 0; + if ($distance<0) { + $backward = -1; + } elseif ($distance && $distance<.03) { + $backward = 1; + } elseif ($distance && $distance<.2) { + $backward = 2; + } elseif ($distance && $distance<.4) { + $backward = 3; + } elseif ($distance && $distance<.6) { + $backward = 4; + } elseif ($distance && $distance>=.6) { + $backward = 5; + } + $status['backward'] = $backward; + $status['distance'] = $distance; + } + } else { + $status['translated'] = false; + } + return $status; +} + +?> http://cvs.php.net/viewvc.cgi/phpdoc/scripts/online_editor/login.php?r1=1.1&r2=1.2&diff_format=u Index: phpdoc/scripts/online_editor/login.php diff -u phpdoc/scripts/online_editor/login.php:1.1 phpdoc/scripts/online_editor/login.php:1.2 --- phpdoc/scripts/online_editor/login.php:1.1 Tue May 6 11:43:48 2008 +++ phpdoc/scripts/online_editor/login.php Tue May 6 15:53:26 2008 @@ -1,117 +1,117 @@ -<?php -//*-- The PHPDOC Online XML Editing Tool -//*-- Developed by Salah Faya visualmind(@)php.net -//*-- Version 1.0 - essentially developed for Arabic Translation of PHP Manual -//*-- Now updated to work with all phpdoc translations - -//--- This file allows users to login using an email address (TODO we may use CVS or other way in future) - -//------- Initialization -require 'base.php'; - -session_start(); - -// Logout &and=logout -if (isset($_GET['and'])) { - session_unregister('user'); - unset($_SESSION['user']); -} - - -//------- Login request -if (isset($_POST['lang'])) { - - if (isset($_POST['email'])) { - $email = $_POST['email']; - } - - $lang = $_POST['lang']; - - // Check selected language - if (!isset($phpdocLangs[$lang])) { - exit('Sorry, you have choosen an incorrect language'); - } - - if ($requireLogin) { - // Simple email validation -- ToDo some enhancements - $email = trim(strtolower($email)); - $p1 = preg_match("#^([a-z0-9][a-z0-9_\.]*)@[a-z0-9][a-z0-9\-]+\.[a-z]{2,6}$#", $email); - $p2 = preg_match("#^([a-z0-9][a-z0-9_\.]*)@[a-z0-9][a-z0-9\-]+\.[a-z]{2,3}\.[a-z]{2}$#", $email); - - if (!$p1 && !$p2) { - exit('That was not a valid email address'); - } - // This validation is required because emails are used as user folder name -- ToDO use another way - if (strlen($email)>50) { - exit('That was not a valid email address'); - } - - // Do Login (create user folder) - if (!file_exists($usersCachePath.$email)) { - @mkdir($usersCachePath.$email, $filesChMod); - } - - } - - - - if (is_dir($usersCachePath.$email) || !$requireLogin) { - - // Session setup - session_register('user'); - $_SESSION['user'] = array('email'=>$email, 'cache'=>$usersCachePath.$email.'/', 'phpdocLang'=>$lang); - - // If expired session, redo last request - if ($_SESSION['redo']) { - $link = $_SESSION['redo']; - $_SESSION['redo'] = false; - header("location: $link"); - exit; - } - - // If accidently lost session while editing - if ($_REQUEST['from']=='editxml') { - exit('Ok, Login is <b>successful</b>. Now retry your previous request'); - } - - // Redirect to frameset - header('location: workbench.php'); - exit('<a href="workbench.php">Moved to workbench.php</a>'); - } else { - // If folder has not been created - exit('Sorry, there was an internal error. Please contact administration'); - } -} - -//------- Login form -?> -<html> -<body style="font-family: Tahoma; font-size: 12px;"> - -<h3> The PHPDOC Online XML Editing Tool :: Login first</h3> -<form action=login.php method=post> -<input type=hidden name=from value="<?php print $_REQUEST['from']; ?>"> -<?php -if ($requireLogin) { ?> -Your email address (must be valid) <input type=text name=email><br> -<?php } ?> -Translating PHPDOC to -<select name=lang><?php -foreach($phpdocLangs as $lang=>$langInfo) { - print "<option value='$lang'>$lang</option>"; -} -?> -</select>* <input type=submit value=Login> -</form> - - Developed by Salah Faya visualmind(@)php.net<br> - Version 1.0 - essentially developed for Arabic Translation of PHP Manual<br> - Now updated to work with all phpdoc translations. -<br> - This is a special tool to be used only by PHPDOC translators.<br> - -Javascript and cookies must be enabled in your browser settings.<br> -<br> -<b>Last CVS Update: <?php print implode('', file('cvsupdate.txt')); ?></b> -</body> -</html> +<?php +//*-- The PHPDOC Online XML Editing Tool +//*-- Developed by Salah Faya visualmind(@)php.net +//*-- Version 1.0 - essentially developed for Arabic Translation of PHP Manual +//*-- Now updated to work with all phpdoc translations + +//--- This file allows users to login using an email address (TODO we may use CVS or other way in future) + +//------- Initialization +require 'base.php'; + +session_start(); + +// Logout &and=logout +if (isset($_GET['and'])) { + session_unregister('user'); + unset($_SESSION['user']); +} + + +//------- Login request +if (isset($_POST['lang'])) { + + if (isset($_POST['email'])) { + $email = $_POST['email']; + } + + $lang = $_POST['lang']; + + // Check selected language + if (!isset($phpdocLangs[$lang])) { + exit('Sorry, you have choosen an incorrect language'); + } + + if ($requireLogin) { + // Simple email validation -- ToDo some enhancements + $email = trim(strtolower($email)); + $p1 = preg_match("#^([a-z0-9][a-z0-9_\.]*)@[a-z0-9][a-z0-9\-]+\.[a-z]{2,6}$#", $email); + $p2 = preg_match("#^([a-z0-9][a-z0-9_\.]*)@[a-z0-9][a-z0-9\-]+\.[a-z]{2,3}\.[a-z]{2}$#", $email); + + if (!$p1 && !$p2) { + exit('That was not a valid email address'); + } + // This validation is required because emails are used as user folder name -- ToDO use another way + if (strlen($email)>50) { + exit('That was not a valid email address'); + } + + // Do Login (create user folder) + if (!file_exists($usersCachePath.$email)) { + @mkdir($usersCachePath.$email, $filesChMod); + } + + } + + + + if (is_dir($usersCachePath.$email) || !$requireLogin) { + + // Session setup + session_register('user'); + $_SESSION['user'] = array('email'=>$email, 'cache'=>$usersCachePath.$email.'/', 'phpdocLang'=>$lang); + + // If expired session, redo last request + if ($_SESSION['redo']) { + $link = $_SESSION['redo']; + $_SESSION['redo'] = false; + header("location: $link"); + exit; + } + + // If accidently lost session while editing + if ($_REQUEST['from']=='editxml') { + exit('Ok, Login is <b>successful</b>. Now retry your previous request'); + } + + // Redirect to frameset + header('location: workbench.php'); + exit('<a href="workbench.php">Moved to workbench.php</a>'); + } else { + // If folder has not been created + exit('Sorry, there was an internal error. Please contact administration'); + } +} + +//------- Login form +?> +<html> +<body style="font-family: Tahoma; font-size: 12px;"> + +<h3> The PHPDOC Online XML Editing Tool :: Choose your language</h3> +<form action=login.php method=post> +<input type=hidden name=from value="<?php print $_REQUEST['from']; ?>"> +<?php +if ($requireLogin) { ?> +Your email address (must be valid) <input type=text name=email><br> +<?php } ?> +Translating PHPDOC to +<select name=lang><?php +foreach($phpdocLangs as $lang=>$langInfo) { + print "<option value='$lang'>$lang</option>"; +} +?> +</select>* <input type=submit value="Start editing"> +</form> + + Developed by Salah Faya visualmind(@)php.net<br> + Version 1.0 - essentially developed for Arabic Translation of PHP Manual<br> + Now updated to work with all phpdoc translations. +<br> + This is a special tool to be used only by PHPDOC translators.<br> + +Javascript and cookies must be enabled in your browser settings.<br> +<br> +<b>Last CVS Update: <?php print implode('', file('cvsupdate.txt')); ?></b> +</body> +</html> http://cvs.php.net/viewvc.cgi/phpdoc/scripts/online_editor/cvslist.php?r1=1.1&r2=1.2&diff_format=u Index: phpdoc/scripts/online_editor/cvslist.php diff -u phpdoc/scripts/online_editor/cvslist.php:1.1 phpdoc/scripts/online_editor/cvslist.php:1.2 --- phpdoc/scripts/online_editor/cvslist.php:1.1 Tue May 6 11:43:48 2008 +++ phpdoc/scripts/online_editor/cvslist.php Tue May 6 15:53:26 2008 @@ -1,209 +1,216 @@ -<?php -//*-- The PHPDOC Online XML Editing Tool -//*-- Developed by Salah Faya visualmind(@)php.net -//*-- Version 1.0 - essentially developed for Arabic Translation of PHP Manual -//*-- Now updated to work with all phpdoc translations - -//--- This file lists the folders and files in the left frame - -//------- Initialization -require 'base.php'; -$user = sessionCheck(); - -$lang = $user['phpdocLang']; -$translationPath = $phpdocLangs[$lang]['DocCVSPath']; - -//------- Folder navigation vars -$path = ''; -$file = ''; -if (isset($_REQUEST['path'])) { - $path = $_REQUEST['path']; - if (isset($_REQUEST['file'])) { - $file = $_REQUEST['file']; - } -} - -// Prevent wrong paths -if (strstr($path, '.') || $file=='..' || $file=='.') { - exit; -} - - -// Path Slashes -if (!$path) $path = '/'; -if (substr($path, -1)!='/') $path .= '/'; - - -// Usually, the path are based on english cvs -$target = "$enDocCVSPath$path$file"; - - -//------- Decide what to do - -// If file is selected, redirect to the editor.. - -if ($file) { - // Find in user path first (editing cached file by default) - $ffile = $user['cache'].getCacheName($path.$file); - if (file_exists($ffile)) { - header("location: editxml.php?file=$path$file&source=upath"); - exit; - } - - // Find in translated path (edit the translated file) - $ffile = "$translationPath$path$file"; - if (file_exists($ffile)) { - header("location: editxml.php?file=$path$file&source=apath"); - exit; - } - - // So it's a new file? Use the english source - if (file_exists($target)) { - header("location: editxml.php?file=$path$file&source=epath"); - exit; - } -} else { - - // No file selected, Listing (from english cvs) - $d = opendir($target); - while($f = readdir($d)) { - if (is_dir($target.$f)) { - if (in_array($f, $ignoreListingFolders)) continue; - $dirs[] = $f; - } elseif ((substr($f, -4)=='.xml' || substr($f, -4)=='.ent') && !in_array($f, $ignoreListingFiles)) { - $files[] = $f; - } - } - -} - - -//------- Functions -function printPathAsLinks($path) { - global $lang; - - $px = explode('/', $path); - foreach($px as $i=>$p) { - $pp .= $p.'/'; - if (!$p && !$i) $p = $lang; - print "<a href='?path=$pp'>$p</a>"; - if ($p || !$i) print '/'; - } - print '<br>'; -} - - -function printDirectories($dirs, $path) { - sort($dirs); - foreach($dirs as $dir) { - print "<a href='?path=$path$dir'><img src='images/dir.png' width=16 height=16 border=0 align=absmiddle> $dir</a> <br>"; - } -} - -function printFiles($files, $path) { - global $translationPath, $user; - - sort($files); - foreach($files as $fl) { - $status = getTranslationStatus($path.$fl); - if ($status['translated']) { - if ($status['fileEnRevision'] && $status['lastEnRevision'] && $status['distance']>=0) { - if (!$status['backward']) { - $title = 'Up to date'; - $img = 'images/up2date.png'; - } else { - $title = 'Outdated '.$status['fileEnRevision'].' / '.$status['lastEnRevision']; - $img = 'images/r'.($status['backward']+1).'.png'; - } - } else { - $title = 'EN-Revision is incorrect or missing'; - $img = 'images/unknown.png'; - } - } else { - $title = 'Not translated yet'; - $img = 'images/notyet.png'; - } - - print "<a href='?path=$path&file=$fl' target=fileframe><img src='images/text.png' width=16 height=16 border=0 align=absmiddle> $fl</a> <img src='$img' border=0 align=absmiddle alt='$title'><br>"; - } - - // Lists the user's cached files - if (file_exists($user['cache']."files.txt")) { - print '<hr>'; - print 'Cached files:<br>'; - $ff = file($user['cache']."files.txt"); - foreach($ff as $f) { - $fx = explode('|', $f); - if (!isset($cf[$fx[2]])) { - print "<a href='editxml.php?file=$fx[2]&source=upath' target=fileframe>$fx[2]</a><br>"; - $cf[$fx[2]] = true; - } - } - } - -} - - -//------- Output -?> -<html> -<body bgcolor="#FFFFFF"> -<style type="text/css"> -body { - font-family: Tahoma; - font-size: 12px; -} -a:link { - text-decoration: none; - color: #000066; -} - -a:hover { - text-decoration: none; - color: #ff0000; -} - -a:active { - text-decoration: none; - color: #ff0000; -} - -a:visited { - text-decoration: none; - color: #000066; -} - - </style> -<div style="width: 400px;"> -Listing: -<?php - -printPathAsLinks($path); - -printDirectories($dirs, $path); - -printFiles($files, $path); - -?> -<hr> - -<form action=login.php method=post target=_top> -<?php -if ($requireLogin) { ?> - <input type=hidden name=email value="<?php print $user['email']; ?>"><br> -<?php } ?> -Switch language:<br> -<select name=lang onchange="if (this.value) this.form.submit();"> -<option value=''></option> -<?php -foreach($phpdocLangs as $lng=>$langInfo) { - if ($lng==$lang) $sel = " selected"; else $sel = ''; - print "<option value='$lng'$sel>$lng</option>"; -} -?> -</select> -</form> - -</div> -</body> -</html> +<?php +//*-- The PHPDOC Online XML Editing Tool +//*-- Developed by Salah Faya visualmind(@)php.net +//*-- Version 1.0 - essentially developed for Arabic Translation of PHP Manual +//*-- Now updated to work with all phpdoc translations + +//--- This file lists the folders and files in the left frame + +//------- Initialization +require 'base.php'; +$user = sessionCheck(); + +$lang = $user['phpdocLang']; +$translationPath = $phpdocLangs[$lang]['DocCVSPath']; + +//------- Folder navigation vars +$path = ''; +$file = ''; +if (isset($_REQUEST['path'])) { + $path = $_REQUEST['path']; + if (isset($_REQUEST['file'])) { + $file = $_REQUEST['file']; + } +} + +// Prevent wrong paths +if (strstr($path, '.') || $file=='..' || $file=='.') { + exit; +} + + +// Path Slashes +if (!$path) $path = '/'; +if (substr($path, -1)!='/') $path .= '/'; + + +// Usually, the path are based on english cvs +$target = "$enDocCVSPath$path$file"; + + +//------- Decide what to do + +// If file is selected, redirect to the editor.. + +if ($file) { + // Find in user path first (editing cached file by default) + $ffile = $user['cache'].getCacheName($path.$file); + if (file_exists($ffile)) { + header("location: editxml.php?file=$path$file&source=upath"); + exit; + } + + // Find in translated path (edit the translated file) + $ffile = "$translationPath$path$file"; + if (file_exists($ffile)) { + header("location: editxml.php?file=$path$file&source=apath"); + exit; + } + + // So it's a new file? Use the english source + if (file_exists($target)) { + header("location: editxml.php?file=$path$file&source=epath"); + exit; + } +} else { + + // No file selected, Listing (from english cvs) + $d = opendir($target); + while($f = readdir($d)) { + if (is_dir($target.$f)) { + if (in_array($f, $ignoreListingFolders)) continue; + $dirs[] = $f; + } elseif ((substr($f, -4)=='.xml' || substr($f, -4)=='.ent') && !in_array($f, $ignoreListingFiles)) { + $files[] = $f; + } + } + +} + + +//------- Functions +function printPathAsLinks($path) { + global $lang; + + $px = explode('/', $path); + foreach($px as $i=>$p) { + $pp .= $p.'/'; + if (!$p && !$i) $p = $lang; + print "<a href='?path=$pp'>$p</a>"; + if ($p || !$i) print '/'; + } + print '<br>'; +} + + +function printDirectories($dirs, $path) { + sort($dirs); + foreach($dirs as $dir) { + print "<a href='?path=$path$dir'><img src='images/dir.png' width=16 height=16 border=0 align=absmiddle> $dir</a> <br>"; + } +} + +function printFiles($files, $path) { + global $translationPath, $user; + + sort($files); + foreach($files as $fl) { + $status = getTranslationStatus($path.$fl); + if ($status['translated']) { + if ($status['fileEnRevision'] && $status['lastEnRevision'] && $status['distance']>=0) { + if (!$status['backward']) { + $title = 'Up to date'; + $img = 'images/up2date.png'; + } else { + $title = 'Outdated '.$status['fileEnRevision'].' / '.$status['lastEnRevision']; + $img = 'images/r'.($status['backward']+1).'.png'; + } + } else { + $title = 'EN-Revision is incorrect or missing'; + $img = 'images/unknown.png'; + } + } else { + $title = 'Not translated yet'; + $img = 'images/notyet.png'; + } + + print "<a href='?path=$path&file=$fl' target=fileframe><img src='images/text.png' width=16 height=16 border=0 align=absmiddle> $fl</a> <img src='$img' border=0 align=absmiddle alt='$title'><br>"; + } + + // Lists the user's cached files + if (file_exists($user['cache']."files.txt")) { + print '<hr>'; + print 'Cached files:<br>'; + $ff = file($user['cache']."files.txt"); + foreach($ff as $f) { + $fx = explode('|', $f); + if (!isset($cf[$fx[2]])) { + print "<a href='editxml.php?file=$fx[2]&source=upath' target=fileframe>$fx[2]</a><br>"; + $cf[$fx[2]] = true; + } + } + } + +} + + +//------- Output +?> +<html> +<body bgcolor="#FFFFFF"> +<style type="text/css"> +body { + font-family: Tahoma; + font-size: 12px; +} +a:link { + text-decoration: none; + color: #000066; +} + +a:hover { + text-decoration: none; + color: #ff0000; +} + +a:active { + text-decoration: none; + color: #ff0000; +} + +a:visited { + text-decoration: none; + color: #000066; +} + + </style> +<div style="width: 400px;"> +Listing: +<?php + +printPathAsLinks($path); + +printDirectories($dirs, $path); + +printFiles($files, $path); + +?> +<hr> + +<form action=login.php method=post target=_top> +<?php +if ($requireLogin) { ?> + <input type=hidden name=email value="<?php print $user['email']; ?>"><br> +<?php } ?> +Switch language:<br> +<select name=lang onchange="if (this.value) this.form.submit();"> +<option value=''></option> +<?php +foreach($phpdocLangs as $lng=>$langInfo) { + if ($lng==$lang) $sel = " selected"; else $sel = ''; + print "<option value='$lng'$sel>$lng</option>"; +} +?> +</select> +</form> + +<hr> +Legend:<br> +<img src=images/notyet.png> Not yet translated<br> +<img src=images/up2date.png> File is translated and up to date<br> +<img src=images/unknown.png> EN-Revision is incorrect or missing<br> +<img src=images/r6.png> How much is outdated-<br> gauge (hover it for revision). + +</div> +</body> +</html>