initial commit from rev. 632

This commit is contained in:
Erik Amaru Ortiz
2010-12-02 23:34:41 +00:00
commit 0525681d79
5410 changed files with 864427 additions and 0 deletions

View File

@@ -0,0 +1,83 @@
<?php
/**
* dvServices.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
/*
* Created on 11-02-2008
*
* @author David Callizaya <davidsantos@colosa.com>
*/
G::LoadSystem("webResource");
class dvServices extends WebResource
{
function get_session_vars()
{
$cur=array_keys($_SESSION);
$res='';
foreach($cur as $key)
{
$res.='* '.$key.'<br/>';
}
return $res;
}
function get_session_xmlforms()
{
$cur=array_keys($_SESSION);
$res='';
$colors=array('white','#EEFFFF');
$colori=0;$count=0;
//Get xmlforms in session
foreach($cur as $key)
{
$res.='<div style="background-color:'.$colors[$colori].';">';
$xml=G::getUIDName($key,'');
if (strpos($xml,'.xml')!==false)
{
$res.='<i>FORM:</i> '.$xml;
$colori=$colori ^ 1;
$count++;
}
$res.='</div>';
}
//Get pagedTable in session
foreach($cur as $key)
{
$res.='<div style="background-color:'.$colors[$colori].';">';
if (substr($key,0,11)==="pagedTable[")
{
$xml=G::getUIDName(substr($key,11,-1),'');
$res.='<i>TABLE:</i> '.$xml;
$colori=$colori ^ 1;
$count++;
}
$res.='</div>';
}
return array("count"=>$count,"html"=>$res);
}
}
$o=new dvServices($_SERVER['REQUEST_URI'],$_POST);
//av.buenos aires maxparedes
//tienda viva.
//122
?>

View File

@@ -0,0 +1,29 @@
<?php
/**
* index.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
unset($_SESSION['TOOLS_VIEWTYPE']);
$newFile = str_replace ( 'index.php', 'translations.php' , __FILE__ ) ;
return $newFile;

View File

@@ -0,0 +1,31 @@
<?php
/**
* methodsPermissions.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('view', 'tools/methodsPermissions' );
G::RenderPage( 'publish' );
?>

View File

@@ -0,0 +1,287 @@
<?php
/**
* methodsPermissions_Ajax.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
G::LoadClass("webResource");
define('GET_PERMISSION_REG_EXP','/(G::\\s*genericForceLogin\\s*\\(\\s*[\'"])(\\w+)([\'"]\\s*,\\s*[\'"].+[\'"],.+\\)\\s*)|(\\$RBAC->userCanAccess\\s*\\(\\s*[\'"])(\\w+)([\'"]\\s*\\))/i');
define('GET_PERMISSION_REG_EXP2','/\\s*if\\s*\\(\\s*\\(\\s*\\$RBAC_Response\\s*=\\s*\\$RBAC->userCanAccess\\s*\\(\\s*[\'"]\\w+[\'"]\\s*\\)\\s*\\)\\s*!=1\\s*\\)\\s*return(?:.*)?;\\s*/i');
class phpFile extends webResource
{
function _get_permissions($filename)
{
$aSource = file( $filename);
$aOutSource = array();
$source = implode( '', $aSource );
$regExp=GET_PERMISSION_REG_EXP;
$permissions=array();
$lines=array();
$len=preg_match_all($regExp,$source,$matches,PREG_OFFSET_CAPTURE);
for($r=0; $r < $len; $r++)
{
$match=$matches[0][$r][0];
$permission=($matches[2][$r][0]!='') ? $matches[2][$r][0]:$matches[5][$r][0];
$toPrint=($matches[2][$r][0]!='') ?
(
htmlentities($matches[1][$r][0],ENT_QUOTES,'utf-8').
'<b>'.htmlentities($matches[2][$r][0],ENT_QUOTES,'utf-8').'</b>'.
htmlentities($matches[3][$r][0],ENT_QUOTES,'utf-8')
)
:
(
htmlentities($matches[4][$r][0],ENT_QUOTES,'utf-8').
'<b>'.htmlentities($matches[5][$r][0],ENT_QUOTES,'utf-8').'</b>'.
htmlentities($matches[6][$r][0],ENT_QUOTES,'utf-8')
);
$row = $this->_getLine($aSource,$matches[0][$r][1]);
if (array_search($permission,$permissions)===FALSE)
{
$permissions[]=$permission;
$lines[]=$row;
}
//TODO: Need to htmlencode the rest of the line that is not in match. Ex. < ? php
if ($row>0) $aOutSource[$row-1]=str_replace($match,$toPrint,isset($aOutSource[$row-1])?$aOutSource[$row-1]:$aSource[$row-1]);
$aOutSource[$row]=str_replace($match,$toPrint,isset($aOutSource[$row])?$aOutSource[$row]:$aSource[$row]);
if ($row<(sizeof($aSource)-1)) $aOutSource[$row+1]=str_replace($match,$toPrint,isset($aOutSource[$row+1])?$aOutSource[$row+1]:$aSource[$row+1]);
}
ksort($aOutSource);
$row0=0;$html='';
foreach($aOutSource as $row => $line)
{
if (($row-1) > $row0) $html.=$this->_printLine($row,'...');
$html.=$this->_printLine($row+1,$line,true,$aSource[$row],$filename.'?'.$row);
$row0=$row;
}
return array (
($html==='')?'Dont have RBAC validation!':('<table>'.$html.'</table>'),
$permissions,
$lines
);
}
function get_permissions($filename)
{
$res=$this->_get_permissions($filename);
return $res[0];
}
function modify_line($filename,$row,$value)
{
$aSource = file( $filename);
$line=$aSource[$row];
$nl=(strlen($line)>=2)&&(substr($line,-2,2)=="\r\n")?
"\r\n":
((strlen($line)>=1)&&(substr($line,-1,1)=="\n")?"\n":"");
$aSource[$row]=$value.$nl;
/*Save change*/
$fp=fopen($filename,'w');
fwrite($fp,implode('',$aSource));
fclose($fp);
/*Format line*/
$regExp=GET_PERMISSION_REG_EXP;
$line=$aSource[$row];
$len=preg_match_all($regExp,$line,$matches,PREG_OFFSET_CAPTURE);
for($r=0; $r < $len; $r++)
{
$match=$matches[0][$r][0];
$toPrint=($matches[2][$r][0]!='') ?
(
htmlentities($matches[1][$r][0],ENT_QUOTES,'utf-8').
'<b>'.htmlentities($matches[2][$r][0],ENT_QUOTES,'utf-8').'</b>'.
htmlentities($matches[3][$r][0],ENT_QUOTES,'utf-8')
)
:
(
htmlentities($matches[4][$r][0],ENT_QUOTES,'utf-8').
'<b>'.htmlentities($matches[5][$r][0],ENT_QUOTES,'utf-8').'</b>'.
htmlentities($matches[6][$r][0],ENT_QUOTES,'utf-8')
);
$line=str_replace($match,$toPrint,$line);
}
return array($line,$aSource[$row]);
}
function set_header($filename,$value)
{
$aFields=array("_FILENAME_"=>basename( $filename ) );
$value = G::replaceDataField( $value , $aFields );
$aOrigin = file( $filename);
//It suposse that allway start with <? or <?php
$line=$aOrigin[0];
$nl=(strlen($line)>=2)&&(substr($line,-2,2)=="\r\n")?
"\r\n":
((strlen($line)>=1)&&(substr($line,-1,1)=="\n")?"\n":"");
$codigo = implode('',$aOrigin);
$pattern='/\/\*[\w\W]+\* '.'ProcessMaker Open Source'.'[\w\W]+?\*\//i';
if (preg_match($pattern,$codigo))
{
$codigo=preg_replace( $pattern, $value , $codigo );
}
else
{
$aSource=array();
$aSource[0]=$aOrigin[0];
$aSource[1]=$value.$nl;
for($r=1;$r<sizeof($aOrigin);$r++)
{
$aSource[]=$aOrigin[$r];
}
$codigo=implode('',$aSource);
}
/*Save change*/
$fp=fopen($filename,'w');
fwrite($fp,$codigo);
fclose($fp);
return $this->get_permissions($filename);
}
function add_permission($filename,$value)
{
$aOrigin = file( $filename);
//It suposse that allway start with <? or <?php
$aSource[0]=$aOrigin[0];
$line=$aOrigin[0];
$nl=(strlen($line)>=2)&&(substr($line,-2,2)=="\r\n")?
"\r\n":
((strlen($line)>=1)&&(substr($line,-1,1)=="\n")?"\n":"");
$aSource[1]=$value.$nl;
for($r=1;$r<sizeof($aOrigin);$r++)
{
$aSource[]=$aOrigin[$r];
}
/*Save change*/
$fp=fopen($filename,'w');
fwrite($fp,implode('',$aSource));
fclose($fp);
return $this->get_permissions($filename);
}
function _getLine(&$aSource,$pos)
{
$i=1;
while ($pos>sizeof($aSource[$i]))
{
$pos-=strlen($aSource[$i]);
$i++;
}
return $i-1;
}
function _printLine($row,$txt,$editable=false,$editValue='',$name='')
{
if ($editable)
{
return '<tr><td><input value="X" type="button" style="width:100%;" '.
' name="'.htmlentities($name,ENT_QUOTES,'utf-8').'"'.
' onclick="removeLine(this);"/></td>'.
'<td class="treeContent" align="right">'.$row.'</td>
<td class="treeNode"><span onclick="switchViewEdit(this,this.nextSibling);">'.
$txt.'</span>'.
'<input class="treeNode"'.
' name="'.htmlentities($name,ENT_QUOTES,'utf-8').'"'.
' style="border:none;width:100%;display:none;"'.
' onblur="switchEditView(this.previousSibling,this);"'.
' value="'.htmlentities($editValue,ENT_QUOTES,'utf-8').'"/></td></tr>';
}
else
{
return '<tr><td></td>'.
'<td class="treeContent" align="right">'.$row.'</td>'.
'<td class="treeNode">'.$txt.'</td></tr>';
}
}
function set_permission($filename,$permission)
{
list($html,$permissions)=$this->_get_permissions($filename);
if (array_search($permission,$permissions)===FALSE)
{
$this->add_permission
(
$filename,
'if (($RBAC_Response=$RBAC->userCanAccess("'.$permission.'"))!=1) return $RBAC_Response;'
);
}
return $this->get_permissions($filename);
}
function set_path_permission($path,$permission)
{
$files=glob($path.'*.php');
foreach($files as $file)
{
$this->set_permission($file,$permission);
}
}
function set_path_header($path,$header)
{
$files=glob($path.'*.php');
$filesMod=array();
foreach($files as $file)
{
$filesMod[]=$file;
$this->set_header($file,$header);
}
$dirs=glob($path.'*', GLOB_MARK );
foreach($dirs as $dir)
{
if (substr( $dir , -1 , 1 )=='/') $this->set_path_header($dir,$header);
}
return $filesMod;
}
function remove_path_permission($path,$permission)
{
$files=glob($path.'*.php');
foreach($files as $file)
{
$this->remove_permission($file,$permission);
}
}
function remove_line($filename,$line)
{
$aSource = file($filename);
unset($aSource[$line]);
/*Save change*/
$fp=fopen($filename,'w');
fwrite($fp,implode('',$aSource));
fclose($fp);
return $this->get_permissions($filename);
}
function remove_permission($filename,$permission)
{
$aSource = file( $filename);
list($html,$permissions,$lines) = $this->_get_permissions($filename);
if (($row=array_search($permission,$permissions))!==FALSE)
{
$line=$lines[$row];
if (preg_match(GET_PERMISSION_REG_EXP2,$aSource[$line]))
{
unset($aSource[$line]);
$msg="Removed.";
}
else
{
$msg="Can not be removed!";
}
}
/*Save change*/
$fp=fopen($filename,'w');
fwrite($fp,implode('',$aSource));
fclose($fp);
return $this->get_permissions($filename);
}
}
$phpFile=new phpFile('methodsPermissions_Ajax',$_POST);
?>

View File

@@ -0,0 +1,45 @@
<style>
.tableOption {
color:#005791 !important;
}
</style>
<?php
/**
* translations.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
$G_MAIN_MENU = 'tools';
$G_SUB_MENU = 'toolsTranslations';
$G_ID_MENU_SELECTED = 'TRANSLATION';
$G_ID_SUB_MENU_SELECTED = 'TRANSLATION_LIST';
$table="TRANSLATION";
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('pagedtable', 'paged-table', 'tools/translationsList', '', array() , '');
if( isset($_SESSION['TOOLS_VIEWTYPE']) ) {
G::RenderPage('publishBlank', 'green-submenu');
} else {
G::RenderPage('publish');
}

View File

@@ -0,0 +1,38 @@
<?php
/**
* translationsAdd.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
$G_MAIN_MENU = 'tools';
$G_SUB_MENU = 'toolsTranslations';
$G_ID_MENU_SELECTED = 'TRANSLATION';
$G_ID_SUB_MENU_SELECTED = 'TRANSLATION_ADD';
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'tools/translationAdd', '', null, 'translationsSave' );
if( isset($_SESSION['TOOLS_VIEWTYPE']) && $_SESSION['TOOLS_VIEWTYPE'] == 'blank') {
G::RenderPage('publishBlank', 'green-submenu');
} else {
G::RenderPage('publish');
}
?>

View File

@@ -0,0 +1,217 @@
<?php
/**
* translationsAjax.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
ini_set('display_errors','off');
G::LoadInclude('ajax');
$function = get_ajax_value('function');
$cat = get_ajax_value('cat');
$node = get_ajax_value('node');
$lang = get_ajax_value('lang');
$langLabel = get_ajax_value('langLabel');
$text = get_ajax_value('text');
$table="TRANSLATION";
$dbc = new DBConnection;
$ses = new DBSession($dbc);
switch($function)
{
case "editLabel":
case "changeLabel":
$query=$ses->execute("select * from $table where TRN_CATEGORY='$cat' and TRN_ID='$node' and TRN_LANG='$lang'",false);
if ($query->count()===0) {echo("Not found $cat:$node:$lang in table '$table'");return;}
if ($query->count()>1) {echo("The $cat:$node:$lang in table '$table' is not unique");return;}
$res=$query->read();
switch($function)
{
case "editLabel":
$myID="input_".$cat."_".$node."_".$lang;
$myID='aux';
echo("<input id='$myID' type='text' value='".htmlspecialchars($res['TRN_VALUE'])."' ".
ajax_event("onblur","translationsAjax.php",
'lang_'.$cat.'_'.$node.'_'.$lang,
"'function=changeLabel&cat=".urlencode($cat).
"&node=".urlencode($node).
"&lang=".urlencode($lang).
"&langLabel='+encodeURI(getElementById('$myID').value)",'')
."/>");
break;
case "changeLabel":
$update=$ses->execute("update $table set TRN_VALUE='$langLabel' where TRN_CATEGORY='$cat' and TRN_ID='$node' and TRN_LANG='$lang'",false);
$query=$ses->execute("select * from $table where TRN_CATEGORY='$cat' and TRN_ID='$node' and TRN_LANG='$lang'",false);
if ($query->count()===0) {echo("Not found $cat:$node:$lang in table '$table'");return;}
if ($query->count()>1) {echo("The $cat:$node:$lang in table '$table' is not unique");return;}
$res=$query->read();
echo(htmlspecialchars($res['TRN_VALUE']));
break;
break;
}
G::LoadClass( "translation" );
$dbc = new DBConnection;
$obj = new Translation;
$obj->SetTo($dbc );
$translation2 = $obj->generateFileTranslation();
break;
case "listLanguage":
$query=$ses->execute("select distinct TRN_LANG from $table",false);
$template = new TemplatePower(PATH_CORE . 'templates/tools/translationsTP.html');
$template->prepare();
$template->newBlock("languageList");
$template->assign("ajaxDelLang",ajax_event("onclick","translationsAjax","showSpace",
"'function=delLanguage&lang='+encodeURI(getElementById('language').value)",'hideLangBar'));
for($r=1;$r<=$query->count();$r++)
{
$res=$query->read();
$template->newBlock("languageItem");
$template->assign("langIdRadio",$res['TRN_LANG']);
}
$template->printToScreen();
break;
case "show":
case "search":
case "addField":
case "addLanguage":
case "delLanguage":
case "delField":
switch($function)
{
case "show":
$query=$ses->execute("select * from $table ORDER BY TRN_CATEGORY ASC , TRN_ID ASC , TRN_LANG ASC ",false);
break;
case "search":
$query=$ses->execute("select * from $table where (TRN_CATEGORY like '%$text%') or (TRN_ID like '%$text%') or (TRN_LANG like '%$text%') or (TRN_VALUE like '%$text%') ORDER BY TRN_CATEGORY ASC , TRN_ID ASC , TRN_LANG ASC ",false);
break;
case "addField":
if (!defined('LANGUAGES')) define('LANGUAGES',SYS_LANG);
$languages=explode(",",LANGUAGES);
foreach($languages as $lang)
{
//$langLabel=$cat;
/* $update=$ses->execute("insert into $table(TRN_CATEGORY , TRN_ID , TRN_LANG , TRN_VALUE )
values ('$cat','$node','$lang','$langLabel')",false);*/
$update=$ses->execute("insert into $table(TRN_CATEGORY , TRN_ID , TRN_LANG , TRN_VALUE )
values ('LABEL','$node','$lang','$langLabel')",false);
}
$query=$ses->execute("select * from $table ORDER BY TRN_CATEGORY ASC , TRN_ID ASC , TRN_LANG ASC ",false);
break;
case "addLanguage":
//SELECT distinct TRN_CATEGORY, TRN_ID, 'ne', 'new value' FROM TRANSLATION WHERE TRN_LANG<>'ne'
//INSERT INTO TRANSLATION(TRN_CATEGORY, TRN_ID, TRN_LANG , TRN_VALUE ) SELECT distinct TRN_CATEGORY, TRN_ID, 'ne', TRN_VALUE FROM TRANSLATION WHERE TRN_LANG<>'ne'
$query1=$ses->execute("select * from $table where TRN_LANG='$lang'",false);
$query2=$ses->execute("select distinct TRN_CATEGORY, TRN_ID from $table",false);
$existe=array();
for($r=1;$r<=$query1->count();$r++)
{
$res=$query1->read();
$existe[$res['TRN_CATEGORY']."_".$res['TRN_ID']]=$res;
}
for($r=1;$r<=$query2->count();$r++)
{
$res=$query2->read();
$cat=$res['TRN_CATEGORY'];
$node=$res['TRN_ID'];
$langLabel=$res['TRN_CATEGORY'];
if (!array_key_exists($cat."_".$node,$existe))
/* $update=$ses->execute("insert into $table(TRN_CATEGORY , TRN_ID , TRN_LANG , TRN_VALUE )
values ('$cat','$node','$lang','$langLabel')",false);*/
$update=$ses->execute("insert into $table(TRN_CATEGORY , TRN_ID , TRN_LANG , TRN_VALUE )
values ('LABELS','$node','en','$langLabel')",false);
unset($update);
}
unset($existe);
unset($query1);unset($query2);
$query=$ses->execute("select * from $table ORDER BY TRN_CATEGORY ASC , TRN_ID ASC , TRN_LANG ASC ",false);
break;
case "delLanguage":
$update=$ses->execute("delete from $table where TRN_LANG='$lang'",false);
$query=$ses->execute("select * from $table ORDER BY TRN_CATEGORY ASC , TRN_ID ASC , TRN_LANG ASC ",false);
break;
case "delField":
$update=$ses->execute("delete from $table where TRN_CATEGORY='$cat' and TRN_ID='$node' and TRN_LANG='$lang'",false);
//echo("delete from $table where TRN_CATEGORY='$cat' and TRN_ID='$node' and TRN_LANG='$lang'");
$query=$ses->execute("select * from $table ORDER BY TRN_CATEGORY ASC , TRN_ID ASC , TRN_LANG ASC ",false);
break;
}
$template = new TemplatePower(PATH_CORE . 'templates/tools/translationsTP.html');
$template->prepare();
$template->newBlock("CONTENT");
$template->newBlock("table");
$aCat="";$aNode="";
for($i=1;$i<=$query->count();$i++)
{
$template->newBlock("row");
$res=$query->read();
$cat=$res['TRN_CATEGORY'];
$node=$res['TRN_ID'];
$lang=$res['TRN_LANG'];
$langLabel=$res['TRN_VALUE'];
if ($cat!=$aCat)
{
$template->newBlock("TDcat");
$template->assign("catId",$res['TRN_CATEGORY']);
$template->assign("ajaxDelField",
ajax_event('onclick','translationsAjax','showSpace',
"'function=delField".
"&cat=".urlencode($cat).
"&node=".urlencode($node).
"&lang=".urlencode($lang)."'",''));
}
if (($cat!=$aCat) ||
($node!=$aNode))
{
$template->newBlock("TDnode");
$template->assign("nodeId",$res['TRN_ID']);
}
//$aCat=$cat;
//$aNode=$node;
$template->goToBlock("row");
$template->assign("catId",$res['TRN_CATEGORY']);
$template->assign("nodeId",$res['TRN_ID']);
$template->assign("langId",$lang);
$template->assign("langLabel",$langLabel);
$template->assign("ajaxLabel","onclick=\"if (!document.getElementById('aux'))".
ajax_init('translationsAjax.php',
'lang_'.$cat.'_'.$node.'_'.$lang,
"'function=editLabel".
"&cat=".urlencode($cat).
"&node=".urlencode($node).
"&lang=".urlencode($lang)."'",'focusInputLabel')
.'"');
}
$template->printToScreen();
break;
}
?>
<?php
function ajax_event($event="onclick",$page,$div,$param,$freturn="")
{
if ($freturn==='') $freturn="''";
return "$event=\"ajax_init('$page','$div',$param,$freturn)\"";
}
function ajax_init($page,$div,$param,$freturn="")
{
if ($freturn=='') $freturn="''";
return "ajax_init('$page','$div',$param,$freturn);";
}
?>

View File

@@ -0,0 +1,43 @@
<?php
/**
* translationsDelete.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
//to do: improve the way to pass two or more parameters in the paged-table ( link )
$aux = explode ( '|', $_GET['id'] );
$category = str_replace ( '"', '', $aux[0] );
$id = str_replace ( '"', '', $aux[1] );
require_once ( "classes/model/Translation.php" );
//if exists the row in the database propel will update it, otherwise will insert.
$tr = TranslationPeer::retrieveByPK( $category, $id, 'en' );
if ( ( is_object ( $tr ) && get_class ($tr) == 'Translation' ) ) {
$tr->delete();
}
// else
G::Header('location: translations');
?>

View File

@@ -0,0 +1,60 @@
<?php
/**
* translationsEdit.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
//to do: improve the way to pass two or more parameters in the paged-table ( link )
$aux = explode ( '|', $_GET['id'] );
$category = str_replace ( '"', '', $aux[0] );
$id = str_replace ( '"', '', $aux[1] );
require_once ( "classes/model/Translation.php" );
//if exists the row in the database propel will update it, otherwise will insert.
$tr = TranslationPeer::retrieveByPK( $category, $id, 'en' );
if ( ( is_object ( $tr ) && get_class ($tr) == 'Translation' ) ) {
$fields['trn_category'] = $tr->getTrnCategory();
$fields['trn_id'] = $tr->getTrnId();
$fields['trn_value'] = $tr->getTrnValue();
}
else
$fields = array();
$G_MAIN_MENU = 'tools';
$G_SUB_MENU = 'toolsTranslations';
$G_ID_MENU_SELECTED = 'TOOLS';
$G_ID_SUB_MENU_SELECTED = 'ADD_TRANSLATION';
$G_PUBLISH = new Publisher;
$dbc = new DBConnection;
$ses = new DBSession($dbc);
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'tools/translationAdd', '', $fields, 'translationsSave' );
if( isset($_SESSION['TOOLS_VIEWTYPE']) && $_SESSION['TOOLS_VIEWTYPE'] == 'blank') {
G::RenderPage('publishBlank', 'green-submenu');
} else {
G::RenderPage('publish');
}
?>

View File

@@ -0,0 +1,36 @@
<?php
/**
* translationsSave.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
$form = $_POST['form'];
require_once ( "classes/model/Translation.php" );
$form['trn_value'] = preg_replace("[\n|\r|\n\r]", ' ', $form['trn_value']);
//$t = new Translation;
$res = Translation::addTranslation( $form['trn_category'], $form['trn_id'], 'en' , $form['trn_value'] );
if ( $res['codError'] < 0 ) {
G::SendMessageText ( $res['message'] , 'error' );
}
G::Header('location: translations');
?>

View File

@@ -0,0 +1,43 @@
<?php
/**
* updateTranslation.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
require_once ( "classes/model/Translation.php" );
$t = new Translation;
$fields = Translation::generateFileTranslation('en');
$G_MAIN_MENU = 'tools';
$G_SUB_MENU = 'toolsTranslations';
$G_ID_MENU_SELECTED = 'TRANSLATION';
$G_ID_SUB_MENU_SELECTED = 'TRANSLATION_REBUILD';
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'tools/updateTranslation', '', $fields);
if( isset($_SESSION['TOOLS_VIEWTYPE']) && $_SESSION['TOOLS_VIEWTYPE'] == 'blank') {
G::RenderPage('publishBlank', 'green-submenu');
} else {
G::RenderPage('publish');
}
?>