From: <txm...@us...> - 2012-05-21 19:31:33
|
Revision: 9571 http://xoops.svn.sourceforge.net/xoops/?rev=9571&view=rev Author: txmodxoops Date: 2012-05-21 19:31:22 +0000 (Mon, 21 May 2012) Log Message: ----------- Initial update to 2.6.0 Added Paths: ----------- XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/about.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/bbs.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/header.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/index.html XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/index.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/languages.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/menu.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/wizard.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/blocks/ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/blocks/index.html XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/class/ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/class/files.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/class/googleprovider.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/class/index.html XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/class/iobase.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/class/languages.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/class/provider.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/class/translator.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/css/ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/css/index.html XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/docs/ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/docs/changelog.txt XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/docs/credits.txt XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/docs/index.html XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/docs/install.txt XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/docs/lang_diff.txt XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/docs/licence.txt XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/docs/readme.txt XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/16/ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/16/analysis.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/16/edit.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/16/export.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/16/import.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/16/index.html XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/16/traslate.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/32/ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/32/dashboard.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/32/index.html XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/32/languages.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/32/translations.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/32/wizard.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/admin/ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/admin/about.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/admin/help.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/admin/home.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/admin/index.html XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/admin/permissions.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/admin/xoopsmicrobutton.gif XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/deco/ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/deco/about.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/deco/arrow.gif XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/deco/delete.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/deco/edit.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/deco/index.html XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/deco/index.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/deco/off.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/deco/on.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/deco/permissions.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/deco/pref.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/deco/update.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/icons/ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/icons/index.html XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/icons/off.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/icons/on.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/index.html XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/languages.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/left_both.gif XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/menu/ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/menu/bg.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/menu/index.html XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/menu/left_both.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/menu/right_both.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/right_both.gif XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/translations.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/wizard.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/images/xtransam_slogo.png XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/include/ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/include/JSON.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/include/charset_utf-8.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/include/forms.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/include/functions.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/include/index.html XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/include/install.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/include/update.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/language/ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/language/english/ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/language/english/admin.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/language/english/google.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/language/english/help/ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/language/english/help/help.html XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/language/english/help/index.html XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/language/english/index.html XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/language/english/modinfo.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/language/index.html XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/language/italian/ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/language/italian/admin.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/language/italian/google.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/language/italian/help/ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/language/italian/help/help.html XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/language/italian/help/index.html XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/language/italian/index.html XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/language/italian/modinfo.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/providers/ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/providers/bing.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/providers/google.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/providers/index.html XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/providers/mymemory.php XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/sql/ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/sql/index.html XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/sql/mysql.sql XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/templates/ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/templates/admin/ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/templates/admin/index.html XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/templates/admin/xtransam_about.html XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/templates/admin/xtransam_help.html XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/templates/blocks/ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/templates/blocks/index.html XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/templates/index.html XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/xoops_version.php Added: XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/about.php =================================================================== --- XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/about.php (rev 0) +++ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/about.php 2012-05-21 19:31:22 UTC (rev 9571) @@ -0,0 +1,34 @@ +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +/** + * Traslation Languages + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package xtransam + * @since 1.3.0 + * @author Mamba + * @author Simon Roberts <si...@ch...> + * @version $Id: about.php 8469 2011-12-12 14:13:34Z beckmi $ + * @version $Id: about.php 9400 2012-12-04 12:58:28Z timgno $ + */ + +include dirname(__FILE__) . '/header.php'; + +$xoops = Xoops::getInstance(); +$xoops->header(); + +$aboutAdmin = new XoopsModuleAdmin(); +$aboutAdmin->renderNavigation('about.php'); +$aboutAdmin->renderAbout('6KJ7RW5DR3VTJ', false); + +$xoops->footer(); \ No newline at end of file Added: XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/bbs.php =================================================================== --- XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/bbs.php (rev 0) +++ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/bbs.php 2012-05-21 19:31:22 UTC (rev 9571) @@ -0,0 +1,238 @@ +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +/** + * Traslation Languages + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package xtransam + * @since 1.3.0 + * @author Simon Roberts <si...@ch...> + * @author Timgno <in...@tx...> + * @version $Id: index.php 9400 2012-04-28 12:53:34Z timgno $ + */ +include dirname(__FILE__) . '/header.php'; + +$xoops = Xoops::getInstance(); +$xoops->header(); + +include_once '../include/forms.php'; +define ("_CHARSET","UTF-8"); +define ("_CHARSET_ISO","ISO-8859-1"); +error_reporting(E_ALL); +global $xoopsDB, $xoopsModuleConfig; + + if (isset($_GET)) { + foreach ($_GET as $k => $v) { + ${$k} = $v; + } + } + + if (isset($_POST)) { + foreach ($_POST as $k => $v) { + ${$k} = $v; + } + } + + +ini_set("max_execution_time", "300"); + +switch ($op){ +case "deletebuffer": + $sql[0] = "DELETE FROM ".$xoopsDB->prefix('xtransam_files')." WHERE ioid = $id"; + $sql[1] = "DELETE FROM ".$xoopsDB->prefix('xtransam_translator')." WHERE ioid = $id"; + $sql[2] = "DELETE FROM ".$xoopsDB->prefix('xtransam_iobase')." WHERE id = $id"; + + foreach($sql as $fquestion) + $xoopsDB->queryF($fquestion); + + redirect_header("index.php", 4, _XT_IODELETED); + break; +case "save-languages": + $lang_handler = xoops_getmodulehandler('languages', 'xtransam'); + foreach($id as $key => $value) + { + switch($value){ + case "new": + $lang = $lang_handler->create(); + break; + default: + $lang = $lang_handler->get($value); + } + + if (!empty($name[$key])&&!empty($code[$key])) { + $lang->setVar('name', $name[$key]); + $lang->setVar('code', $code[$key]); + $lang->setVar('foldername', $folder[$key]); + $lang->setVar('provider', $provider[$key]); + @$lang_handler->insert($lang); + } + } + redirect_header("index.php?op=languages",2,_XT_LANGSAVEOK); + break; +case "languages": + languagesForm_display(); + break; +case "export": + global $xoopsUser; + + $io_handler = xoops_getmodulehandler('iobase', 'xtransam'); + $io = $io_handler->get($id); + $trans_handler = xoops_getmodulehandler('translator', 'xtransam'); + $lang_handler = xoops_getmodulehandler('languages', 'xtransam'); + $files_handler = xoops_getmodulehandler('files', 'xtransam'); + $criteria = new CriteriaCompo(new Criteria('ioid', $io->getVar('id'))); + $files = $files_handler->getObjects($criteria); + + $from_folder = $lang_handler->folder($io->getvar('languagefrom')); + $to_folder = $lang_handler->folder($io->getvar('languageto')); + + foreach($files as $file) { + $path = explode('/', $file->getVar('path')); + + foreach($path as $key => $value) + if (strtolower($value) == strtolower($from_folder)) { + $path[$key] = $to_folder; + } + + //$wpath = implode('/', $path).'/'; + $wpath = implode(DIRECTORY_SEPARATOR, $path); + mkdir($wpath, 0777); + + if($wpath!=$file->getVar('path')){ + $bfile = file($file->getVar('path').$file->getVar('filename')); + $criteria = new CriteriaCompo(new Criteria('ioid', $io->getVar('id'))); + $criteria->add(new Criteria('fileid', $file->getVar('id'))); + $trans = $trans_handler->getObjects($criteria); + // Changed & Added by TXMod Xoops + $bfile[1] = "\n// Translation done by xtransam & ".$xoopsUser->uname()." TXMod Xoops - ".date('Y-m-d H:i')."\n\n"; + + foreach($trans as $tran) { + $search = xtransam_convert_decode($tran->getVar('replacestr'), $tran->getVar('sm')); + $name = xtransam_convert_decode($tran->getVar('name'), $tran->getVar('sm')); + $translation = xtransam_convert_decode($tran->getVar('translation'), $tran->getVar('sm')); + + // Changed & Added by TXMod Xoops + //include_once '../include/charset_utf-8.php'; + //$translation = preg_replace($search, $replace, $translation); + $translation = str_replace('"', '\"', $translation); + $translation = str_replace('\"', "'", $translation); + $translation = str_replace('="', "='", $translation); + $translation = str_replace('">', "'>", $translation); + $translation = str_replace('È', 'E'', $translation); + $translation = str_replace('ì', 'ì', $translation); + $translation = str_replace('ò', 'ò', $translation); + $translation = str_replace('è', 'è', $translation); + $translation = str_replace('ù', 'ù', $translation); + $translation = str_replace('à', 'à', $translation); + $translation = str_replace('% S', '%s', $translation); + $translation = str_replace('%s ', '%s ', $translation); + $translation = str_replace('%s "', '%s"', $translation); + $translation = str_replace(' / ', '/', $translation); + + $replace = 'define("'.$name.'", "'.$translation.'");'; + $bfile[$tran->getVar('line')] = str_replace($search, $replace, $bfile[$tran->getVar('line')]); + } + @makeWritable($wpath, true); + if (file_exists($wpath.$file->getVar('filename'))) + unlink($wpath.$file->getVar('filename')); + $file = @fopen($wpath.$file->getVar('filename'), 'w'); + $buffer = implode('', $bfile); + fwrite($file, $buffer, strlen($buffer)); + fclose($file); + } + } + // Added by TXMod Xoops + if (file_exists($indexFile = XOOPS_ROOT_PATH."/modules/xtransam/language/index.html")) + copy($indexFile, $wpath."index.html"); + + redirect_header("index.php?op=bbs",2,_XT_EXPORTCOMPLETE); + break; +case "save": + $trans_handler = xoops_getmodulehandler('translator', 'xtransam'); + foreach($trans as $key => $value) { + $tran = $trans_handler->get($key); + $tran->setVar('translation', xtransam_convert_encode($value, $tran->getVar('sm'))); + $trans_handler->insert($tran); + } + redirect_header("index.php?op=manage&id=$id&fileid=$fileid",2,_XT_SAVECOMPLETE); + break; +case "manage": + managerForm_display($id, $fileid); + break; + +case "analysis": + $io_handler = xoops_getmodulehandler('iobase', 'xtransam'); + $files_handler = xoops_getmodulehandler('files', 'xtransam'); + $io = $io_handler->get($id); + @$files_handler->analysepath($io); + redirect_header("index.php?op=bbs",2,_XT_ANLYSISCOMPLETE); + break; + +case "import": + $io_handler = xoops_getmodulehandler('iobase', 'xtransam'); + $files_handler = xoops_getmodulehandler('files', 'xtransam'); + $io = $io_handler->get($id); + @$files_handler->importfiles($io); + redirect_header("index.php?op=bbs",2,_XT_IMPORTCOMPLETE); + break; + +case "translate": + $io_handler = xoops_getmodulehandler('iobase', 'xtransam'); + $io = $io_handler->get($id); + $trans_handler = xoops_getmodulehandler('translator', 'xtransam'); + $lang_handler = xoops_getmodulehandler('languages', 'xtransam'); + $criteria = new CriteriaCompo(new Criteria('ioid', $io->getVar('id'))); + if ($trans_handler->getCount($criteria)>0) { + $trans = $trans_handler->getObjects($criteria); + $start = time(); + foreach($trans as $tran) { + if ($tran->isempty()){ + $from = $lang_handler->code($io->getVar('languagefrom')); + $to = $lang_handler->code($io->getVar('languageto')); + $provider = $lang_handler->provider($tran->getVar('toid')); + if (strlen($provider)>0) { + $provider_handler = xoops_getmodulehandler($provider.'provider', 'xtransam'); + $translation = $provider_handler->translate($from,$to, xtransam_convert_decode($tran->getVar('orginal'), $tran->getVar('sm'))); + $tran->setVar('translation', xtransam_convert_encode($translation, $tran->getVar('sm'))); + if (strlen($translation)>0) + $tran->setVar('auto', 1); + else + $tran->setVar('auto', 0); + + $trans_handler->insert($tran); + } + if ($start+28<time()) + { + $restart++; + redirect_header("index.php?op=translate&id=$id&restart=$restart",2,sprintf(_XT_30SECONDSCONTINUING, $restart)); + } + } + } + } + redirect_header("index.php?op=bbs",2,_XT_TRANSLATIONCOMPLETE); + break; + +case "languages": + + break; +case "bbs": + translationForm_display(false); + break; + +case "wizard": +default: + wizardForm_display($step); + translationForm_display(true); + break; +} +$xoops->footer(); \ No newline at end of file Added: XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/header.php =================================================================== --- XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/header.php (rev 0) +++ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/header.php 2012-05-21 19:31:22 UTC (rev 9571) @@ -0,0 +1,26 @@ +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +/** + * Traslation Languages + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package xtransam + * @since 1.3.0 + * @author Taiwen Jiang <ph...@us...> + * @author Simon Roberts <si...@ch...> + * @version $Id: header.php 9400 2012-04-28 10:25:22Z timgno $ + */ +require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/include/cp_header.php'; + +$xoops = Xoops::getInstance(); +XoopsLoad::load('xtransam', 'xtransam'); \ No newline at end of file Added: XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/index.html =================================================================== --- XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/index.html (rev 0) +++ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/index.html 2012-05-21 19:31:22 UTC (rev 9571) @@ -0,0 +1 @@ + <script>history.go(-1);</script> \ No newline at end of file Added: XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/index.php =================================================================== --- XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/index.php (rev 0) +++ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/index.php 2012-05-21 19:31:22 UTC (rev 9571) @@ -0,0 +1,263 @@ +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +/** + * Traslation Languages + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package xtransam + * @since 1.3.0 + * @author Simon Roberts <si...@ch...> + * @author Timgno <in...@tx...> + * @version $Id: index.php 9400 2012-04-28 12:53:34Z timgno $ + */ +include dirname(__FILE__) . '/header.php'; + +$xoops = Xoops::getInstance(); +$xoops->header(); + +$indexAdmin = new XoopsModuleAdmin(); +$indexAdmin->renderNavigation('index.php'); +$indexAdmin->renderIndex(); + +/*error_reporting(E_ALL); +global $xoopsDB, $xoopsModuleConfig; + +$op = isset($_REQUEST['op'])?$_REQUEST['op']:'dashboard'; + +switch ($op){ +case "deletebuffer": + $sql[0] = "DELETE FROM ".$xoopsDB->prefix('xtransam_files')." WHERE ioid = $id"; + $sql[1] = "DELETE FROM ".$xoopsDB->prefix('xtransam_translator')." WHERE ioid = $id"; + $sql[2] = "DELETE FROM ".$xoopsDB->prefix('xtransam_iobase')." WHERE id = $id"; + + foreach($sql as $fquestion) + $xoopsDB->queryF($fquestion); + + redirect_header("index.php", 4, _AM_XTRANSAM_IODELETED); + break; +case "save-languages": + $lang_handler = xoops_getmodulehandler('languages', 'xtransam'); + foreach($id as $key => $value) + { + switch($value){ + case "new": + $lang = $lang_handler->create(); + break; + default: + $lang = $lang_handler->get($value); + } + + if (!empty($name[$key])&&!empty($code[$key])) { + $lang->setVar('name', $name[$key]); + $lang->setVar('code', $code[$key]); + $lang->setVar('foldername', $folder[$key]); + $lang->setVar('providers', $providers[$key]); + @$lang_handler->insert($lang); + } + } + redirect_header("index.php?op=languages",2,_AM_XTRANSAM_LANGSAVEOK); + break; +case "languages": + + echo $indexAdmin->addNavigation('index.php?op=languages'); + languagesForm_display(); + include "admin_footer.php"; + + break; +case "export": + global $xoopsUser; + + $io_handler = xoops_getmodulehandler('iobase', 'xtransam'); + $io = $io_handler->get($id); + $trans_handler = xoops_getmodulehandler('translator', 'xtransam'); + $lang_handler = xoops_getmodulehandler('languages', 'xtransam'); + $files_handler = xoops_getmodulehandler('files', 'xtransam'); + $criteria = new CriteriaCompo(new Criteria('ioid', $io->getVar('id'))); + $files = $files_handler->getObjects($criteria); + + $from_folder = $lang_handler->folder($io->getvar('languagefrom')); + $to_folder = $lang_handler->folder($io->getvar('languageto')); + + // Changed by Chronolabs - Removed Code by Timgo - ansi conversion - 08/11/2011 + //include($GLOBALS['xoops']->path('modules'.DS.'xtransam'.DS.'include'.DS.'charset_utf-8.php')); + + foreach($files as $file) { + $path = array(); + foreach(explode('\\', $file->getVar('path')) as $nodea) + foreach(explode('/', $nodea) as $nodeb) + $path[] = $nodeb; + foreach($path as $key => $value) { + if (strtolower($value) == strtolower($from_folder)) { + $path[$key] = $to_folder; + } + $pdir = DS.$path[$key]; + mkdir($pdir, 0777); + } + $wpath = implode(DS, $path); + if($wpath!=$file->getVar('path')){ + $bfile = file($file->getVar('path').$file->getVar('filename')); + // Changed by TXMod Xoops back to Header + $bfile[] = "<?php\n\n// Translation done by XTransam & ".$GLOBALS['xoopsUser']->getVar('uname')." (".$GLOBALS['xoopsUser']->getVar('email').")\n// XTransam ".($GLOBALS['xtransamModule']->getVar('version')/100)." is written by Chronolabs Co-op & The XOOPS Project - File Dumped on ".date('Y-m-d H:i')."\n\n?>"; + $criteria = new CriteriaCompo(new Criteria('ioid', $io->getVar('id'))); + $criteria->add(new Criteria('fileid', $file->getVar('id'))); + $trans = $trans_handler->getObjects($criteria); + foreach($trans as $tran) { + $search = xtransam_convert_decode($tran->getVar('replacestr'), $tran->getVar('sm')); + $name = xtransam_convert_decode($tran->getVar('name'), $tran->getVar('sm')); + $translation = xtransam_convert_decode($tran->getVar('translation'), $tran->getVar('sm')); + *//*foreach($GLOBALS['charset_utf8'] as $search => $replace) + $translation = str_replace($search, $replace, $translation); + $translation = htmlspecialchars($translation, ENT_QUOTES); *//* + $trans = get_html_translation_table(HTML_ENTITIES); + $str = $translation; + $encoded = strtr($str, $trans); + //$translation = htmlentities($translation, ENT_COMPAT, "UTF-8"); + $replace = 'define("'.$name.'", "'.$encoded.'");'."\n"; + $bfile[$tran->getVar('line')] = $replace; + } + @makeWritable($wpath, true); + if (file_exists($wpath.$file->getVar('filename'))) + unlink($wpath.$file->getVar('filename')); + $file = @fopen($wpath.$file->getVar('filename'), 'w'); + $buffer = implode("", $bfile); + fwrite($file, $buffer, strlen($buffer)); + fclose($file); + } + // Changed by Chronolabs to be recursive + if (file_exists($indexFile = XOOPS_ROOT_PATH."modules/xtransam/language/index.html")) + copy($indexFile, $wpath."/index.html"); + } + redirect_header("index.php?op=bbs",2,_AM_XTRANSAM_EXPORTCOMPLETE); + break; +case "save": + $trans_handler = xoops_getmodulehandler('translator', 'xtransam'); + foreach($trans as $key => $value) { + $tran = $trans_handler->get($key); + $tran->setVar('translation', xtransam_convert_encode($value, $tran->getVar('sm'))); + $trans_handler->insert($tran); + } + redirect_header("index.php?op=manage&id=$id&fileid=$fileid",2,_AM_XTRANSAM_SAVECOMPLETE); + break; +case "manage": + + echo $indexAdmin->addNavigation('index.php?op=manage'); + //echo $indexAdmin->renderIndex(); + managerForm_display($id, $fileid); + + break; + +case "analysis": + $io_handler = xoops_getmodulehandler('iobase', 'xtransam'); + $files_handler = xoops_getmodulehandler('files', 'xtransam'); + $io = $io_handler->get($id); + @$files_handler->analysepath($io); + redirect_header("index.php?op=bbs",2,_AM_XTRANSAM_ANLYSISCOMPLETE); + break; + +case "import": + $io_handler = xoops_getmodulehandler('iobase', 'xtransam'); + $files_handler = xoops_getmodulehandler('files', 'xtransam'); + $io = $io_handler->get($id); + @$files_handler->importfiles($io); + redirect_header("index.php?op=bbs",2,_AM_XTRANSAM_IMPORTCOMPLETE); + break; + +case "translate": + + echo sprintf(_AM_XTRANSAM_TRANSLATION_IN_PROCESS, $GLOBALS['xtransamModuleConfig']['php_execute_for'], isset($restart)?$restart:1); + include "admin_footer.php"; + $io_handler = xoops_getmodulehandler('iobase', 'xtransam'); + $io = $io_handler->get($id); + $trans_handler = xoops_getmodulehandler('translator', 'xtransam'); + $lang_handler = xoops_getmodulehandler('languages', 'xtransam'); + $criteria = new CriteriaCompo(new Criteria('ioid', $io->getVar('id'))); + if ($trans_handler->getCount($criteria)>0) { + $trans = $trans_handler->getObjects($criteria); + $start = time(); + foreach($trans as $tran) { + if ($tran->isempty()){ + $from = $lang_handler->code($io->getVar('languagefrom')); + $to = $lang_handler->code($io->getVar('languageto')); + $GLOBALS['provider'] = $lang_handler->provider($tran->getVar('toid')); + if (strlen($GLOBALS['provider'])>0) { + $provider_handler = xoops_getmodulehandler('provider', 'xtransam'); + $translation = $provider_handler->provider->translate($from,$to, xtransam_convert_decode($tran->getVar('orginal'), $tran->getVar('sm'))); + $tran->setVar('translation', xtransam_convert_encode($translation, $tran->getVar('sm'))); + if (strlen($translation)>0) + $tran->setVar('auto', 1); + else + $tran->setVar('auto', 0); + + $trans_handler->insert($tran); + } + if ($start+$GLOBALS['xtransamModuleConfig']['php_execute_for']-3<time()) + { + $restart++; + redirect_header("index.php?op=translate&id=$id&restart=$restart"); + exit(0); + } + } + } + } + redirect_header("index.php?op=bbs",2,_AM_XTRANSAM_TRANSLATIONCOMPLETE); + break; + +case "bbs": + + echo $indexAdmin->addNavigation('index.php?op=bbs'); + //echo $indexAdmin->renderIndex(); + translationForm_display(false); + + break; + +case "wizard": + echo $indexAdmin->addNavigation('index.php?op=wizard'); + //echo $indexAdmin->renderIndex(); + wizardForm_display($step); + translationForm_display(true); + break; +case "dashboard": +default: + + $trans_handler = xoops_getmodulehandler('translator', 'xtransam'); + $lang_handler = xoops_getmodulehandler('languages', 'xtransam'); + $files_handler = xoops_getmodulehandler('files', 'xtransam'); + $iobase_handler = xoops_getmodulehandler('iobase', 'xtransam'); + + $indexAdmin->addInfoBox(_AM_XTRANSAM_ADMIN_NUMTRASL); + $indexAdmin->addInfoBoxLine(_AM_XTRANSAM_ADMIN_NUMTRASL, "<label>"._AM_XTRANSAM_THEREARE_NUMFILES."</label>", $files_handler->getCount(NULL), 'Green'); + $indexAdmin->addInfoBoxLine(_AM_XTRANSAM_ADMIN_NUMTRASL, "<label>"._AM_XTRANSAM_THEREARE_NUMLINES."</label>", $trans_handler->getCount(NULL), 'Green'); + $indexAdmin->addInfoBoxLine(_AM_XTRANSAM_ADMIN_NUMTRASL, "<label>"._AM_XTRANSAM_THEREARE_NUMPROJECTS."</label>", $iobase_handler->getCount(NULL), 'Green'); + $indexAdmin->addInfoBoxLine(_AM_XTRANSAM_ADMIN_NUMTRASL, "<label>"._AM_XTRANSAM_THEREARE_NUMLANG."</label>", $lang_handler->getCount(NULL), 'Green'); + xoops_load('xoopscache'); + if (!class_exists('XoopsCache')) { + // XOOPS 2.4 Compliance + xoops_load('cache'); + if (!class_exists('XoopsCache')) { + include_once XOOPS_ROOT_PATH.DS.'class'.DS.'cache'.DS.'xoopscache.php'; + } + } + + if ($googlecodes = XoopsCache::read('xtransam_google_pause')) { + $indexAdmin->addInfoBoxLine(_AM_XTRANSAM_ADMIN_NUMTRASL, "<label>"._AM_XTRANSAM_THEREARE_GOOGLEAVAILABLE."</label>", _YES, 'Green'); + $indexAdmin->addInfoBoxLine(_AM_XTRANSAM_ADMIN_NUMTRASL, "<label>".sprintf(_AM_XTRANSAM_THEREARE_GOOGLEERROR, $googlecodes['code'], $googlecodes['message'])."</label>", '', 'Green'); + } else { + $indexAdmin->addInfoBoxLine(_AM_XTRANSAM_ADMIN_NUMTRASL, "<label>"._AM_XTRANSAM_THEREARE_GOOGLEAVAILABLE."</label>", _NO, 'Green'); + } + + echo $indexAdmin->addNavigation("index.php") ; + echo $indexAdmin->renderIndex(); + + break; +}*/ +$xoops->footer(); Added: XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/languages.php =================================================================== --- XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/languages.php (rev 0) +++ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/languages.php 2012-05-21 19:31:22 UTC (rev 9571) @@ -0,0 +1,91 @@ +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +/** + * Traslation Languages + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package xtransam + * @since 1.3.0 + * @author Simon Roberts <si...@ch...> + * @author Timgno <in...@tx...> + * @version $Id: index.php 9400 2012-04-28 12:53:34Z timgno $ + */ +include dirname(__FILE__) . '/header.php'; + +$xoops = Xoops::getInstance(); +$xoops->header(); + +include_once '../include/forms.php'; +define ("_CHARSET","UTF-8"); +define ("_CHARSET_ISO","ISO-8859-1"); +error_reporting(E_ALL); +global $xoopsDB, $xoopsModuleConfig; + + if (isset($_GET)) { + foreach ($_GET as $k => $v) { + ${$k} = $v; + } + } + + if (isset($_POST)) { + foreach ($_POST as $k => $v) { + ${$k} = $v; + } + } + + +ini_set("max_execution_time", "300"); + +switch ($op){ +case "save-languages": + $lang_handler = xoops_getmodulehandler('languages', 'xtransam'); + foreach($id as $key => $value) + { + switch($value){ + case "new": + $lang = $lang_handler->create(); + break; + default: + $lang = $lang_handler->get($value); + } + + if (!empty($name[$key])&&!empty($code[$key])) { + $lang->setVar('name', $name[$key]); + $lang->setVar('code', $code[$key]); + $lang->setVar('foldername', $folder[$key]); + $lang->setVar('provider', $provider[$key]); + @$lang_handler->insert($lang); + } + } + redirect_header("index.php?op=languages",2,_XT_LANGSAVEOK); + break; + +case "save": + $trans_handler = xoops_getmodulehandler('translator', 'xtransam'); + foreach($trans as $key => $value) { + $tran = $trans_handler->get($key); + $tran->setVar('translation', xtransam_convert_encode($value, $tran->getVar('sm'))); + $trans_handler->insert($tran); + } + redirect_header("index.php?op=manage&id=$id&fileid=$fileid",2,_XT_SAVECOMPLETE); + break; +case "languages": +default: + xoops_cp_header(); + adminMenu(3); + languagesForm_display(); + footer_adminMenu(); + xoops_cp_footer(); + break; +} +$xoops->footer(); \ No newline at end of file Added: XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/menu.php =================================================================== --- XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/menu.php (rev 0) +++ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/menu.php 2012-05-21 19:31:22 UTC (rev 9571) @@ -0,0 +1,37 @@ +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ +/** + * Traslation Languages + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package xtransam + * @since 1.3.0 + * @author Taiwen Jiang <ph...@us...> + * @author Simon Roberts <si...@ch...> + * @version $Id: menu.php 9400 2012-04-28 10:40:24Z timgno $ + */ +$adminmenu = array(); $i = 1; +$adminmenu[$i]["title"] = _MI_XTRANSAM_ADMENU1; +$adminmenu[$i]["link"] = 'admin/index.php'; +$adminmenu[$i]["icon"] = 'home.png'; $i++; +$adminmenu[$i]["title"] = _MI_XTRANSAM_ADMENU2; +$adminmenu[$i]["link"] = 'admin/index.php?op=wizard'; +$adminmenu[$i]["icon"] = 'wizard.png'; $i++; +$adminmenu[$i]["title"] = _MI_XTRANSAM_ADMENU3; +$adminmenu[$i]["link"] = 'admin/index.php?op=bbs'; +$adminmenu[$i]["icon"] = 'translations.png'; $i++; +$adminmenu[$i]["title"] = _MI_XTRANSAM_ADMENU4; +$adminmenu[$i]["link"] = 'admin/index.php?op=languages'; +$adminmenu[$i]["icon"] = 'languages.png'; $i++; +$adminmenu[$i]["title"] = _MI_XTRANSAM_ADMENU5; +$adminmenu[$i]["link"] = 'admin/about.php'; +$adminmenu[$i]["icon"] = 'about.png'; unset($i); \ No newline at end of file Added: XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/wizard.php =================================================================== --- XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/wizard.php (rev 0) +++ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/admin/wizard.php 2012-05-21 19:31:22 UTC (rev 9571) @@ -0,0 +1,243 @@ +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +/** + * Traslation Languages + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package xtransam + * @since 1.3.0 + * @author Simon Roberts <si...@ch...> + * @author Timgno <in...@tx...> + * @version $Id: index.php 9400 2012-04-28 12:53:34Z timgno $ + */ +include dirname(__FILE__) . '/header.php'; + +$xoops = Xoops::getInstance(); +$xoops->header(); + +include_once '../include/forms.php'; +define ("_CHARSET","UTF-8"); +define ("_CHARSET_ISO","ISO-8859-1"); +error_reporting(E_ALL); +global $xoopsDB, $xoopsModuleConfig; + + if (isset($_GET)) { + foreach ($_GET as $k => $v) { + ${$k} = $v; + } + } + + if (isset($_POST)) { + foreach ($_POST as $k => $v) { + ${$k} = $v; + } + } + + +ini_set("max_execution_time", "300"); + +switch ($op){ +case "deletebuffer": + $sql[0] = "DELETE FROM ".$xoopsDB->prefix('xtransam_files')." WHERE ioid = $id"; + $sql[1] = "DELETE FROM ".$xoopsDB->prefix('xtransam_translator')." WHERE ioid = $id"; + $sql[2] = "DELETE FROM ".$xoopsDB->prefix('xtransam_iobase')." WHERE id = $id"; + + foreach($sql as $fquestion) + $xoopsDB->queryF($fquestion); + + redirect_header("index.php", 4, _XT_IODELETED); + break; +case "save-languages": + $lang_handler = xoops_getmodulehandler('languages', 'xtransam'); + foreach($id as $key => $value) + { + switch($value){ + case "new": + $lang = $lang_handler->create(); + break; + default: + $lang = $lang_handler->get($value); + } + + if (!empty($name[$key])&&!empty($code[$key])) { + $lang->setVar('name', $name[$key]); + $lang->setVar('code', $code[$key]); + $lang->setVar('foldername', $folder[$key]); + $lang->setVar('provider', $provider[$key]); + @$lang_handler->insert($lang); + } + } + redirect_header("index.php?op=languages",2,_XT_LANGSAVEOK); + break; +case "languages": + xoops_cp_header(); + adminMenu(3); + languagesForm_display(); + footer_adminMenu(); + xoops_cp_footer(); + + break; +case "export": + global $xoopsUser; + + $io_handler = xoops_getmodulehandler('iobase', 'xtransam'); + $io = $io_handler->get($id); + $trans_handler = xoops_getmodulehandler('translator', 'xtransam'); + $lang_handler = xoops_getmodulehandler('languages', 'xtransam'); + $files_handler = xoops_getmodulehandler('files', 'xtransam'); + $criteria = new CriteriaCompo(new Criteria('ioid', $io->getVar('id'))); + $files = $files_handler->getObjects($criteria); + + $from_folder = $lang_handler->folder($io->getvar('languagefrom')); + $to_folder = $lang_handler->folder($io->getvar('languageto')); + + foreach($files as $file) { + $path = explode('/', $file->getVar('path')); + + foreach($path as $key => $value) + if (strtolower($value) == strtolower($from_folder)) { + $path[$key] = $to_folder; + } + + //$wpath = implode('/', $path).'/'; + $wpath = implode(DIRECTORY_SEPARATOR, $path); + mkdir($wpath, 0777); + + if($wpath!=$file->getVar('path')){ + $bfile = file($file->getVar('path').$file->getVar('filename')); + $criteria = new CriteriaCompo(new Criteria('ioid', $io->getVar('id'))); + $criteria->add(new Criteria('fileid', $file->getVar('id'))); + $trans = $trans_handler->getObjects($criteria); + // Changed & Added by TXMod Xoops + $bfile[1] = "\n// Translation done by xtransam & ".$xoopsUser->uname()." TXMod Xoops - ".date('Y-m-d H:i')."\n\n"; + + foreach($trans as $tran) { + $search = xtransam_convert_decode($tran->getVar('replacestr'), $tran->getVar('sm')); + $name = xtransam_convert_decode($tran->getVar('name'), $tran->getVar('sm')); + $translation = xtransam_convert_decode($tran->getVar('translation'), $tran->getVar('sm')); + + // Changed & Added by TXMod Xoops + //include_once '../include/charset_utf-8.php'; + //$translation = preg_replace($search, $replace, $translation); + $translation = str_replace('"', '\"', $translation); + $translation = str_replace('\"', "'", $translation); + $translation = str_replace('="', "='", $translation); + $translation = str_replace('">', "'>", $translation); + $translation = str_replace('È', 'E'', $translation); + $translation = str_replace('ì', 'ì', $translation); + $translation = str_replace('ò', 'ò', $translation); + $translation = str_replace('è', 'è', $translation); + $translation = str_replace('ù', 'ù', $translation); + $translation = str_replace('à', 'à', $translation); + $translation = str_replace('% S', '%s', $translation); + $translation = str_replace('%s ', '%s ', $translation); + $translation = str_replace('%s "', '%s"', $translation); + $translation = str_replace(' / ', '/', $translation); + + $replace = 'define("'.$name.'", "'.$translation.'");'; + $bfile[$tran->getVar('line')] = str_replace($search, $replace, $bfile[$tran->getVar('line')]); + } + @makeWritable($wpath, true); + if (file_exists($wpath.$file->getVar('filename'))) + unlink($wpath.$file->getVar('filename')); + $file = @fopen($wpath.$file->getVar('filename'), 'w'); + $buffer = implode('', $bfile); + fwrite($file, $buffer, strlen($buffer)); + fclose($file); + } + } + // Added by TXMod Xoops + if (file_exists($indexFile = XOOPS_ROOT_PATH."/modules/xtransam/language/index.html")) + copy($indexFile, $wpath."index.html"); + + redirect_header("index.php?op=bbs",2,_XT_EXPORTCOMPLETE); + break; +case "save": + $trans_handler = xoops_getmodulehandler('translator', 'xtransam'); + foreach($trans as $key => $value) { + $tran = $trans_handler->get($key); + $tran->setVar('translation', xtransam_convert_encode($value, $tran->getVar('sm'))); + $trans_handler->insert($tran); + } + redirect_header("index.php?op=manage&id=$id&fileid=$fileid",2,_XT_SAVECOMPLETE); + break; +case "manage": + managerForm_display($id, $fileid); + break; + +case "analysis": + $io_handler = xoops_getmodulehandler('iobase', 'xtransam'); + $files_handler = xoops_getmodulehandler('files', 'xtransam'); + $io = $io_handler->get($id); + @$files_handler->analysepath($io); + redirect_header("index.php?op=bbs",2,_XT_ANLYSISCOMPLETE); + break; + +case "import": + $io_handler = xoops_getmodulehandler('iobase', 'xtransam'); + $files_handler = xoops_getmodulehandler('files', 'xtransam'); + $io = $io_handler->get($id); + @$files_handler->importfiles($io); + redirect_header("index.php?op=bbs",2,_XT_IMPORTCOMPLETE); + break; + +case "translate": + $io_handler = xoops_getmodulehandler('iobase', 'xtransam'); + $io = $io_handler->get($id); + $trans_handler = xoops_getmodulehandler('translator', 'xtransam'); + $lang_handler = xoops_getmodulehandler('languages', 'xtransam'); + $criteria = new CriteriaCompo(new Criteria('ioid', $io->getVar('id'))); + if ($trans_handler->getCount($criteria)>0) { + $trans = $trans_handler->getObjects($criteria); + $start = time(); + foreach($trans as $tran) { + if ($tran->isempty()){ + $from = $lang_handler->code($io->getVar('languagefrom')); + $to = $lang_handler->code($io->getVar('languageto')); + $provider = $lang_handler->provider($tran->getVar('toid')); + if (strlen($provider)>0) { + $provider_handler = xoops_getmodulehandler($provider.'provider', 'xtransam'); + $translation = $provider_handler->translate($from,$to, xtransam_convert_decode($tran->getVar('orginal'), $tran->getVar('sm'))); + $tran->setVar('translation', xtransam_convert_encode($translation, $tran->getVar('sm'))); + if (strlen($translation)>0) + $tran->setVar('auto', 1); + else + $tran->setVar('auto', 0); + + $trans_handler->insert($tran); + } + if ($start+28<time()) + { + $restart++; + redirect_header("index.php?op=translate&id=$id&restart=$restart",2,sprintf(_XT_30SECONDSCONTINUING, $restart)); + } + } + } + } + redirect_header("index.php?op=bbs",2,_XT_TRANSLATIONCOMPLETE); + break; + +case "languages": + + break; +case "bbs": + translationForm_display(false); + break; + +case "wizard": +default: + wizardForm_display($step); + translationForm_display(true); + break; +} +$xoops->footer(); \ No newline at end of file Added: XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/blocks/index.html =================================================================== --- XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/blocks/index.html (rev 0) +++ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/blocks/index.html 2012-05-21 19:31:22 UTC (rev 9571) @@ -0,0 +1 @@ + <script>history.go(-1);</script> \ No newline at end of file Added: XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/class/files.php =================================================================== --- XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/class/files.php (rev 0) +++ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/class/files.php 2012-05-21 19:31:22 UTC (rev 9571) @@ -0,0 +1,210 @@ +<?php +// $Autho: wishcraft $ +// ------------------------------------------------------------------------ // +// XOOPS - PHP Content Management System // +// Copyright (c) 2009 XOOPS.org // +// <http://www.xoops.org/> // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // +// -- Author: Simon Roberts (si...@ch...) -- // +// ------------------------------------------------------------------------ // + +if (!defined('XOOPS_ROOT_PATH')) { + exit(); +} +/** + * Class for policies + * @author Simon Roberts <on...@xo...> + * @copyright copyright (c) 2009-2003 XOOPS.org + * @package kernel + */ +class XtransamFiles extends XoopsObject +{ + + function XtransamFiles($id = null) + { + $this->initVar('id', XOBJ_DTYPE_INT, null, false); + $this->initVar('ioid', XOBJ_DTYPE_INT); + $this->initVar('filename', XOBJ_DTYPE_TXTBOX, null, true, 255); + $this->initVar('path', XOBJ_DTYPE_TXTBOX, null, true, 255); + $this->initVar('imported', XOBJ_DTYPE_INT, 0); + } + +} + + +/** +* XOOPS policies handler class. +* This class is responsible for providing data access mechanisms to the data source +* of XOOPS user class objects. +* +* @author Simon Roberts <si...@ch...> +* @package kernel +*/ +class XtransamFilesHandler extends XoopsPersistableObjectHandler +{ + + var $db; + var $regex = '/define\((.*) \);|define \((.*) \);|define \((.*) \);|define \( ([\"\', \ta-zA-Z0-9_]+)\);|define\( (.*) \);|define\((.*)\);|define \((.*)\);|define \((.*)\);|define \( ([\"\', \ta-zA-Z0-9_]+)\);|define\( (.*)\);|define\((.*) \);|define \((.*) \);|define \((.*) \);|define \( (.*) \);|define\( (.*) \);/'; + var $seperator = array('", "', '","', '" , "', '" , "', '", "', '" , "', + '", \'', '",\'', '" , \'', '" , \'', '", \'', '" , \'' , + '\', \'', '\',\'', '\' , \'', '\' , \'', '\', \'', '\' , \'', + '\', "', '\',"', '\' , "', '\' , "', '\', "', '\' , "'); + + function __construct(&$db) + { + $this->db = $db; + parent::__construct($db, "xtransam_files", 'XtransamFiles', "id", "path"); + } + + function importfiles($io) + { + if (!is_a($io, 'XtransamIobase')) + return false; + + global $xoopsModuleConfig; + + $trans_handler = xoops_getmodulehandler('translator', 'xtransam'); + + $criteria = new CriteriaCompo(new Criteria('`ioid`', $io->getVar('id')), 'AND'); + $criteria->add(new Criteria('`imported`', 0), 'AND'); + $files = $this->getObjects($criteria); + + foreach ($files as $file) { + $content = file_get_contents($file->getVar('path').DS.$file->getVar('filename')); + $lines = explode("\n", $content); + foreach($lines as $key => $line) { + if (strpos(' '.$line,'define')>0) { + @preg_match_all($this->regex, $line, $matches); + + $def = array(); + foreach($matches as $match) + foreach($match as $result) { + if (!empty($result)&&substr($result,0,6)!='define') { + foreach($this->seperator as $sep) + if (strpos($result, $sep)>0) + if (count(explode($sep, $result))==2) + $result = explode($sep, $result); + + $def[0] = substr(trim($result[0]),1); + $def[1] = substr(trim($result[1]),0, strlen(trim($result[1]))-1); + } elseif (substr($result,0,6)=='define') { + $def[3] = $result; + } + } + + + if (!empty($def[0])&&!empty($def[1])) { + $trans = $trans_handler->create(); + $trans->setVar('ioid',$io->getVar('id')); + $trans->setVar('fromid',$io->getVar('languagefrom')); + $trans->setVar('toid',$io->getVar('languageto')); + $trans->setVar('fileid',$file->getVar('id')); + $trans->setVar('linetype','define'); + $trans->setVar('line', $key); + $trans->setVar('name',xtransam_convert_encode($def[0], $xoopsModuleConfig['store_method'])); + $trans->setVar('orginal',xtransam_convert_encode($def[1], $xoopsModuleConfig['store_method'])); + $trans->setVar('replacestr',xtransam_convert_encode($def[3], $xoopsModuleConfig['store_method'])); + $trans->setVar('sm', $xoopsModuleConfig['store_method']); + if (!$trans_handler->exists($trans)) + $trans_handler->insert($trans); + } + } + } + + $file->setVar('imported', '1'); + $this->insert($file); + + } + } + + + function analysepath($io) + { + if (!is_a($io, 'XtransamIobase')) + return false; + + switch ($io->getVar('point')) + { + case "core": + $files = $this->dirToArray(XOOPS_ROOT_PATH.DS.'language'.DS.$io->getVar('path'), true); + $path = XOOPS_ROOT_PATH.DS.'language'.DS.$io->getVar('path'); + break; + case "module": + $files = $this->dirToArray(XOOPS_ROOT_PATH.DS.'modules'.DS.$io->getVar('path'), true); + $path = XOOPS_ROOT_PATH.DS.'modules'.DS.$io->getVar('path'); + break; + } + + foreach($files as $key => $file) + { + if (file_exists($file)) { + $tfile = $this->create(); + $tfile->setVar('filename', basename($file)); + $tfile->setVar('path', str_replace(basename($file),'',$file)); + $tfile->setVar('ioid', $io->getVar('id')); + if (!$this->exists($tfile)) + @$this->insert($tfile); + } + } + + } + + private function dirToArray($directory, $recursive, $fileext = 'php') { + $array_items = array(); + if ($handle = opendir($directory)) { + while (false !== ($file = readdir($handle))) { + $filecomp = explode('.', $file); + if ($file != "." && $file != "..") { + if (is_dir($directory. "/" . $file)) { + if($recursive) { + $array_items = array_merge($array_items, $this->dirToArray($directory. "/" . $file, $recursive)); + } + $file = $directory . "/" . $file; + if (in_array($fileext, $filecomp)) + $array_items[] = preg_replace("/\/\//si", "/", $file); + } else { + $file = $directory . "/" . $file; + if (in_array($fileext, $filecomp)) + $array_items[] = preg_replace("/\/\//si", "/", $file); + } + } + } + closedir($handle); + } + return $array_items; + } + + function exists($file) + { + if (!is_a($file, 'XtransamFiles')) + return true; + + $criteria = new CriteriaCompo(new Criteria('`ioid`', $file->getVar('ioid')), 'AND'); + $criteria->add(new Criteria('`path`', $file->getVar('path')), 'AND'); + $criteria->add(new Criteria('`filename`', $file->getVar('filename')), 'AND'); + if ($this->getCount($criteria)>0) + return true; + else + return false; + } +} +?> \ No newline at end of file Added: XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/class/googleprovider.php =================================================================== --- XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/class/googleprovider.php (rev 0) +++ XoopsCore/tags/2.6 timgno/htdocs/modules/xtransam/class/googleprovider.php 2012-05-21 19:31:22 UTC (rev 9571) @@ -0,0 +1,112 @@ +<?php +// $Autho: wishcraft $ +// ------------------------------------------------------------------------ // +// XOOPS - PHP Content Management System // +// Copyright (c) 2009 XOOPS.org // +// <http://www.xoops.org/> // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // +// -- Author: Simon Roberts (si...@ch...) -- // +// ------------------------------------------------------------------------ // + +if (!defined('XOOPS_ROOT_PATH')) { + exit(); +} +/** + * Class for policies + * @author Simon Roberts <on...@xo...> + * @copyright copyright (c) 2009-2003 XOOPS.org + * @package kernel + */ +class XtransamGoogleprovider extends XoopsObject +{ + + function XtransamGoogleprovider($id = null) + { + + } + +} + + +/** +* XOOPS policies handler class. +* This class is responsible for providing data access mechanisms to the data source +* of XOOPS user class objects. +* +* @author Simon Roberts <si...@ch...> +* @package kernel +*/ +class XtransamGoogleproviderHandler extends XoopsPersistableObjectHandler +{ + + var $url = "http://ajax.googleapis.com/ajax/services/language/translate"; + var $retrieve = array('start' => '<textarea name=utrans wrap=SOFT dir="ltr" rows=5 id=suggestion>', + 'end' => '</textarea>'); + + function __construct(&$db) + { } + + function translate($fromcode, $tocode, $value) + { + + $response = $this->send_post($this->url, $value, $fromcode, $tocode, XOOPS_URL); + if (preg_match("/{\"translatedText\":\"([^\"]+)\"/i", $response, $matches)) { + return self::_unescapeUTF8EscapeSeq($this->clean($matches[1])); + } + } + + private function _unescapeUTF8EscapeSeq($str) { + return preg_replace_callback("/\\\u([0-9a-f]{4})/i", create_function('$matches', 'return html_entity_decode(\'&#x\'.$matches[1].\';\', ENT_NOQUOTES, \'UTF-8\');'), $str); + } + + private function clean($var) + { + $var = htmlspecialchars_decode($var); + $var = str_replace('% s', ' %s ', $var); + $var = str_replace('% u', ' %u ', $var); + $var = str_replace('% d', ' %d ', $var); + if (strpos($var, 'text/css')) ... [truncated message content] |