2006-12-02 04:36:16 +00:00
< ? php
/*
2008-12-15 17:03:25 +00:00
* e107 website system
*
2017-01-15 10:59:58 +00:00
* Copyright ( C ) 2008 - 2017 e107 Inc ( e107 . org )
2008-12-15 17:03:25 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
* Administration Area - Languages
2013-11-05 22:22:47 -08:00
2009-09-05 18:58:56 +00:00
*/
2021-01-16 13:32:35 -08:00
require_once ( __DIR__ . " /../class2.php " );
2013-11-02 02:21:37 -07:00
if ( ! getperms ( 'L' ))
2006-12-02 04:36:16 +00:00
{
2016-01-13 19:17:37 -08:00
e107 :: redirect ( 'admin' );
2006-12-02 04:36:16 +00:00
exit ;
}
2017-01-17 01:33:03 +01:00
2013-01-27 20:49:39 +02:00
e107 :: coreLan ( 'language' , true );
2006-12-02 04:36:16 +00:00
$e_sub_cat = 'language' ;
2015-07-07 12:03:45 -07:00
2015-07-10 15:41:07 -07:00
if ( ! empty ( $_GET [ 'iframe' ]))
{
define ( 'e_IFRAME' , true );
}
2015-07-09 19:24:59 -07:00
class language_admin extends e_admin_dispatcher
{
protected $modes = array (
'main' => array (
'controller' => 'language_ui' ,
'path' => null ,
'ui' => 'language_form_ui' ,
'uipath' => null
),
'db' => array (
'controller' => 'language_ui' ,
'path' => null ,
'ui' => 'language_form_ui' ,
'uipath' => null
),
);
protected $adminMenu = array (
2016-06-17 18:21:40 -07:00
'main/prefs' => array ( 'caption' => LAN_PREFS , 'perm' => '0' ),
2021-02-03 11:46:32 -08:00
'main/tools' => array ( 'caption' => LANG_LAN_21 , 'perm' => 'L' , 'icon' => 'fas-tools' )
2015-07-09 19:24:59 -07:00
);
protected $adminMenuAliases = array (
2017-04-23 12:38:05 -07:00
'main/edit' => 'main/list' ,
// 'main/download' => 'main/tools'
2015-07-09 19:24:59 -07:00
);
2017-02-01 18:25:32 -08:00
protected $adminMenuIcon = 'e-language-24' ;
2015-07-09 19:24:59 -07:00
protected $menuTitle = ADLAN_132 ;
function init ()
{
$pref = e107 :: getPref ();
2016-10-25 11:33:51 -07:00
if ( ! empty ( $pref [ 'multilanguage' ]))
2015-07-09 19:24:59 -07:00
{
2016-10-25 11:33:51 -07:00
$this -> adminMenu = array (
'main/prefs' => $this -> adminMenu [ 'main/prefs' ],
2021-02-03 11:46:32 -08:00
'main/db' => array ( 'caption' => LANG_LAN_03 , 'perm' => 'P' , 'icon' => 'fas-database' ),
2016-10-25 11:33:51 -07:00
'main/tools' => $this -> adminMenu [ 'main/tools' ],
);
2015-07-09 19:24:59 -07:00
}
if ( e_DEVELOPER == true )
{
2016-10-10 20:06:43 +01:00
$this -> adminMenu [ 'main/deprecated' ] = array ( 'caption' => LANG_LAN_04 , 'perm' => '0' );
2015-07-09 19:24:59 -07:00
}
}
}
class language_ui extends e_admin_ui
{
protected $pluginTitle = ADLAN_132 ;
protected $pluginName = 'core' ;
protected $eventName = 'language' ;
// protected $table = 'language';
// protected $pid = 'gen_id';
// protected $perPage = 10;
// protected $batchDelete = true;
// protected $batchCopy = true;
// protected $sortField = 'somefield_order';
// protected $orderStep = 10;
// protected $tabs = array('Tabl 1','Tab 2'); // Use 'tab'=>0 OR 'tab'=>1 in the $fields below to enable.
// protected $listQry = "SELECT * FROM `#language` WHERE gen_type='language' "; // Example Custom Query. LEFT JOINS allowed. Should be without any Order or Limit.
// protected $listOrder = 'gen_id DESC';
// protected $fields = array ();
// protected $fieldpref = array('gen_ip', 'gen_intdata');
protected $prefs = array (
'sitelanguage' => array ( 'title' => LANG_LAN_14 , 'type' => 'dropdown' , 'data' => 'str' , 'help' => '' , 'writeParms' => array ( 'useValues' => 1 )),
'adminlanguage' => array ( 'title' => LANG_LAN_50 , 'type' => 'dropdown' , 'data' => 'str' , 'help' => '' , 'writeParms' => array ( 'useValues' => 1 , " default " => LANG_LAN_14 )),
'multilanguage' => array ( 'title' => LANG_LAN_12 , 'type' => 'boolean' , 'data' => 'int' , 'help' => '' ),
'noLanguageSubs' => array ( 'title' => LANG_LAN_26 , 'type' => 'boolean' , 'data' => 'int' , 'help' => LANG_LAN_27 ),
2017-05-03 12:30:26 -07:00
'multilanguage_subdomain' => array ( 'title' => LANG_LAN_18 , 'type' => 'textarea' , 'data' => 'str' , 'help' => LANG_LAN_19 , 'writeParms' => array ( 'rows' => 3 , 'placeholder' => 'mydomain.com' )),
'multilanguage_domain' => array ( 'title' => LANG_LAN_106 , 'type' => 'method' , 'data' => 'str' , 'help' => LANG_LAN_107 ),
2015-07-10 14:25:16 -07:00
'multilanguage_verify_errorsonly' => array ( 'title' => LANG_LAN_33 , 'type' => 'boolean' , 'data' => 'int' , 'help' => '' ),
2015-07-09 19:24:59 -07:00
);
protected $installedLanguages = array ();
2017-04-23 12:38:05 -07:00
protected $localPacks = array ();
protected $onlinePacks = array ();
2015-07-09 19:24:59 -07:00
public function init ()
{
$this -> installedLanguages = e107 :: getLanguage () -> installed ();
$this -> prefs [ 'sitelanguage' ][ 'writeParms' ][ 'optArray' ] = $this -> installedLanguages ;
$this -> prefs [ 'adminlanguage' ][ 'writeParms' ][ 'optArray' ] = $this -> installedLanguages ;
2017-04-23 12:38:05 -07:00
e107 :: css ( 'inline' , "
. language - name { padding - left : 15 px }
" );
}
private function loadPackInfo ()
{
2018-08-04 15:08:32 -07:00
/** @var lancheck $lck */
2017-04-23 12:38:05 -07:00
$lck = e107 :: getSingleton ( 'lancheck' , e_ADMIN . " lancheck.php " );
$this -> onlinePacks = $lck -> getOnlineLanguagePacks ();
$this -> localPacks = $lck -> getLocalLanguagePacks ();
2015-07-09 19:24:59 -07:00
}
function deprecatedPage ()
{
if ( e_DEVELOPER !== true )
{
return false ;
}
$lnd = new lanDeveloper ;
$text = lanDeveloper :: form ();
if ( $result = $lnd -> run ())
{
$text .= $result [ 'text' ];
}
return $text ;
}
2017-04-23 12:38:05 -07:00
function ToolsPage ()
2015-07-09 19:24:59 -07:00
{
2017-04-23 12:38:05 -07:00
$this -> loadPackInfo ();
2021-01-25 17:57:34 -08:00
$pref = e107 :: getPref ( 'multilanguage_verify_errorsonly' , false );
2020-12-30 10:11:04 -08:00
/** @var lancheck $lck */
2015-07-09 19:24:59 -07:00
$lck = e107 :: getSingleton ( 'lancheck' , e_ADMIN . " lancheck.php " );
2021-01-25 17:57:34 -08:00
$lck -> errorsOnly ( $pref );
2015-07-09 19:24:59 -07:00
// show_packs();
if ( $return = $lck -> init ())
{
2021-02-12 14:27:21 -08:00
if ( isset ( $return [ 'caption' ]))
2015-07-09 19:24:59 -07:00
{
$this -> addTitle ( $return [ 'caption' ]);
}
2021-02-12 14:27:21 -08:00
if ( isset ( $return [ 'text' ]))
{
return $return [ 'text' ];
}
return null ;
2015-07-09 19:24:59 -07:00
}
2017-04-23 12:38:05 -07:00
return $this -> renderLanguagePacks ();
2015-07-09 19:24:59 -07:00
2017-04-23 12:38:05 -07:00
}
2015-07-09 19:24:59 -07:00
2017-04-23 12:38:05 -07:00
function DownloadPage ()
{
2022-01-01 13:05:17 -08:00
if ( empty ( $_GET [ 'e-token' ]))
{
e107 :: getMessage () -> addError ( " Invalid Token " ); // Debug - no need for translation.
return LAN_ERROR ;
}
2017-04-23 12:38:05 -07:00
$this -> loadPackInfo ();
2015-07-09 19:24:59 -07:00
2017-04-23 12:38:05 -07:00
$lan = $this -> getId ();
2015-07-09 19:24:59 -07:00
2017-04-23 12:38:05 -07:00
if ( empty ( $lan ))
{
return LAN_ERROR ;
}
if ( empty ( $this -> onlinePacks [ $lan ][ 'url' ]))
{
return LAN_ERROR ;
}
$result = e107 :: getFile () -> unzipGithubArchive ( $this -> onlinePacks [ $lan ][ 'url' ]);
if ( ! empty ( $result [ 'success' ]))
{
e107 :: getMessage () -> addSuccess ( print_a ( $result [ 'success' ], true ));
$_SESSION [ 'lancheck' ][ $lan ][ 'total' ] = 0 ; // reset errors to zero.
}
2015-07-09 19:24:59 -07:00
2017-04-23 12:38:05 -07:00
if ( ! empty ( $result [ 'error' ]))
{
e107 :: getMessage () -> addError ( print_a ( $result [ 'error' ], true ));
}
$this -> addTitle ( LANG_LAN_114 );
$this -> addTitle ( $lan );
return e107 :: getMessage () -> render ();
}
/**
* List the installed language packs .
* @ return string
*/
private function renderLanguagePacks ()
{
$frm = e107 :: getForm ();
$ns = e107 :: getRender ();
$tp = e107 :: getParser ();
2017-04-27 15:21:20 -07:00
// if(is_readable(e_ADMIN."ver.php"))
2017-04-23 12:38:05 -07:00
{
2017-04-27 15:21:20 -07:00
// include(e_ADMIN."ver.php");
list ( $ver , $tmp ) = explode ( " " , e_VERSION );
2017-04-23 12:38:05 -07:00
}
$lck = e107 :: getSingleton ( 'lancheck' , e_ADMIN . " lancheck.php " );
$release_diz = defset ( " LANG_LAN_30 " , " Release Date " );
$compat_diz = defset ( " LANG_LAN_31 " , " Compatibility " );
2021-08-31 00:11:14 +02:00
$lan_pleasewait = ( deftrue ( 'LAN_PLEASEWAIT' )) ? LAN_PLEASEWAIT : " Please Wait " ;
2017-04-23 12:38:05 -07:00
$text = " <form id='lancheck' method='post' action=' " . e_REQUEST_URI . " '>
< table class = 'table adminlist table-striped' >
< colgroup >
< col style = 'width:20%' />
< col style = 'width:20%' />
2018-08-04 15:08:32 -07:00
< col style = 'width:auto' />
< col style = 'width:10%' />
2017-04-23 12:38:05 -07:00
< col style = 'width:25%' />
</ colgroup > " ;
$text .= " <thead>
< tr >
< th > " .ADLAN_132. " </ th >
2018-08-04 15:08:32 -07:00
< th class = 'text-left' > " . $release_diz . " </ th >
< th class = 'text-left' > " . $compat_diz . " </ th >
2017-04-23 12:38:05 -07:00
< th class = 'text-center' > " .LAN_STATUS. " </ td >
< th class = 'text-right' style = 'white-space:nowrap' > " .LAN_OPTIONS. " </ td >
</ tr >
</ thead >
" ;
$text .= " <tr><th colspan='5'> " . LAN_INSTALLED . " </th></tr> " ;
// $onlinePacks = $lck->getOnlineLanguagePacks();
// $localPacks = $lck->getLocalLanguagePacks();
foreach ( $this -> localPacks as $language => $value )
{
$errFound = ( isset ( $_SESSION [ 'lancheck' ][ $language ][ 'total' ]) && $_SESSION [ 'lancheck' ][ $language ][ 'total' ] > 0 ) ? TRUE : FALSE ;
$text .= " <tr>
< td >< span class = 'language-name' > " . $language . " </ a ></ td >
2018-08-04 15:08:32 -07:00
< td class = 'text-left' > " . $value['date'] . " </ td >
< td class = 'text-left' > " . $value['compatibility'] . " </ td >
2017-04-23 12:38:05 -07:00
< td class = 'text-center' > " .( $errFound ? ADMIN_FALSE_ICON : ADMIN_TRUE_ICON ). " </ td >
< td class = 'text-right' > " ;
// $text .= "<input type='submit' name='language_sel[{$language}]' value=\"".LAN_CHECK_2."\" class='btn btn-primary' />";
$text .= " <a href=' " . e_REQUEST_URI . " &sub=verify&lan= " . $language . " ' class='btn btn-default' > " . $tp -> toGlyph ( 'fa-search' ) . LAN_CHECK_2 . " </a> " ;
/* $text .= "
< input type = 'submit' name = 'ziplang[{$language}]' value = \ " " . LANG_LAN_23 . " \" class='btn btn-default' onclick= \" this.value = ' " . $lan_pleasewait . " ' \" /> " ;
*/
$text .= " </td>
</ tr > " ;
}
$text .= " <tr><th colspan='5'> " . defset ( 'LANG_LAN_151' , 'Available' ) . " </th></tr> " ; // don't translate this.
$text .= $this -> renderOnlineLanguagePacks ();
$text .= "
</ tr ></ table > " ;
$creditLan = defset ( 'LANG_LAN_152' , " Courtesy of the [e107 translation team] " ); // don't translate this.
$srch = array ( " [ " , " ] " );
$repl = array ( " <a rel='external' href='https://github.com/orgs/e107translations/teams'> " , " </a> " );
$text .= " <div class='nav navbar'><small class='navbar-text'> " . str_replace ( $srch , $repl , $creditLan ) . " </small></div> " ;
/*
$text .= " <table class='table table-striped'> " ;
$text .= " <thead><tr><th> " . LAN_OPTIONS . " </th></tr></thead><tbody> " ;
$srch = array ( " [ " , " ] " );
$repl = array ( " <a rel='external' href='https://github.com/orgs/e107translations/teams'> " , " </a> " );
$diz = ( deftrue ( " LANG_LAN_28 " )) ? LANG_LAN_28 : " Check this box if you are a member of the [e107 translation team]. " ;
$checked = varset ( $_COOKIE [ 'e107_certified' ]) == 1 ? true : false ;
$text .= " <tr><td> " ;
$text .= $frm -> checkbox ( 'contribute_pack' , 1 , $checked , array ( 'label' => str_replace ( $srch , $repl , $diz )));
;
$text .= " </td>
</ tr >
< tr >
< td > " ;
$text .= " </td>
</ tr > " ;
$text .= " </tbody></table> " ;
*/
$text .= " </form> " ;
// $text .= "<div class='text-right text-muted' style='padding-top:50px'><small>".LANG_LAN_AGR."</small></div>";
return $text ;
}
private function renderOnlineLanguagePacks ()
{
$text = '' ;
$tp = e107 :: getParser ();
2020-08-19 10:02:14 -07:00
if ( empty ( $this -> onlinePacks ))
{
return null ;
}
2018-08-04 15:08:32 -07:00
2017-04-23 12:38:05 -07:00
foreach ( $this -> onlinePacks as $lan => $value )
{
if ( ! empty ( $this -> localPacks [ $lan ]))
{
if ( $this -> localPacks [ $lan ][ 'compatibility' ] == $value [ 'compatibility' ] && ! deftrue ( 'e_DEBUG' ))
{
continue ;
}
// $status = $tp->toGlyph('fa-star');
$class = 'btn-primary' ;
}
else
{
$status = " " ;
$class = 'btn-default' ;
}
$text .= " <tr>
2017-11-07 14:21:06 -08:00
< td >< span class = 'language-name' >< a rel = 'external' href = '".$value[' infoURL ']."' title = \ " " . LAN_MOREINFO . " \" > " . $value [ 'name' ] . " </a></span> " ;
2018-08-04 15:08:32 -07:00
2017-11-07 14:21:06 -08:00
$text .= " </td> " ;
2017-04-23 12:38:05 -07:00
/* $text .= "
< td > " . $value['version'] . " </ td >
< td >< a href = '".$value[' authorURL ']."' > " . $value['author'] . " </ a ></ td > " ;*/
2022-09-05 19:49:31 +02:00
$url = 'language.php?mode=main&action=download&e-token=' . e_TOKEN . '&id=' . $value [ 'name' ]; // $value['url']
2017-04-23 12:38:05 -07:00
$text .= "
2018-08-04 15:08:32 -07:00
< td class = 'text-left' > " . $value['date'] . " </ td >
< td class = 'text-left' > " . $value['version'] ;
if ( strpos ( $value [ 'tag' ], '-' ) !== false )
{
$text .= " <span class='label label-warning'> " . LANG_LAN_153 . " </span> " ;
}
$text .= " </td>
2017-04-23 12:38:05 -07:00
< td class = 'text-center' > " . $status . " </ td >
< td class = 'text-right' >< a class = 'btn ".$class."' href = '".$url."' >< i class = 'fa fa-arrow-down' ></ i > " .ADLAN_121. " </ a ></ td >
</ tr > " ;
}
2015-07-09 19:24:59 -07:00
return $text ;
}
2017-04-23 12:38:05 -07:00
2015-07-09 19:24:59 -07:00
private function getTables ()
{
// grab default language lists.
$exclude = array ();
$exclude [] = " banlist " ;
$exclude [] = " banner " ;
$exclude [] = " cache " ;
$exclude [] = " core " ;
$exclude [] = " online " ;
$exclude [] = " parser " ;
$exclude [] = " plugin " ;
$exclude [] = " user " ;
$exclude [] = " upload " ;
$exclude [] = " userclass_classes " ;
$exclude [] = " rbinary " ;
$exclude [] = " session " ;
$exclude [] = " tmp " ;
$exclude [] = " flood " ;
$exclude [] = " stat_info " ;
$exclude [] = " stat_last " ;
$exclude [] = " submit_news " ;
$exclude [] = " rate " ;
$exclude [] = " stat_counter " ;
$exclude [] = " user_extended " ;
$exclude [] = " user_extended_struct " ;
$exclude [] = " pm_messages " ;
$exclude [] = " pm_blocks " ;
$tables = e107 :: getDb () -> tables ( 'nolan' ); // db table list without language tables.
return array_diff ( $tables , $exclude );
}
private function dbPageEditProcess ()
{
$tabs = $this -> getTables ();
$sql = e107 :: getDb ();
$tp = e107 :: getParser ();
$mes = e107 :: getMessage ();
$message = '' ;
2016-11-28 16:27:17 -08:00
if ( ! empty ( $_POST [ 'language' ]))
{
2018-01-13 13:00:44 -08:00
$_POST [ 'language' ] = e107 :: getParser () -> filter ( $_POST [ 'language' ], 'w' );
2016-11-28 16:27:17 -08:00
}
2015-07-09 19:24:59 -07:00
// ----------------- delete tables ---------------------------------------------
if ( isset ( $_POST [ 'del_existing' ]) && $_POST [ 'lang_choices' ] && getperms ( '0' ))
{
$lang = strtolower ( $_POST [ 'lang_choices' ]);
2018-01-13 13:00:44 -08:00
$_POST [ 'lang_choices' ] = e107 :: getParser () -> filter ( $_POST [ 'lang_choices' ], 'w' );
2015-07-09 19:24:59 -07:00
foreach ( $tabs as $del_table )
{
if ( $sql -> isTable ( $del_table , $lang ))
{
// echo $del_table." exists<br />";
$qry = " DROP TABLE " . MPREFIX . " lan_ " . $lang . " _ " . $del_table ;
2016-11-28 16:27:17 -08:00
if ( $sql -> gen ( $qry ))
2015-07-09 19:24:59 -07:00
{
$msg = $tp -> lanVars ( LANG_LAN_100 , $_POST [ 'lang_choices' ] . ' ' . $del_table );
$message .= $msg . '[!br!]' ;
$mes -> addSuccess ( $msg );
}
else
{
$msg = $tp -> lanVars ( LANG_LAN_101 , $_POST [ 'lang_choices' ] . ' ' . $del_table );
$message .= $msg . '[!br!]' ;
$mes -> addWarning ( $msg );
}
}
}
e107 :: getLog () -> add ( 'LANG_02' , $message . '[!br!]' , E_LOG_INFORMATIVE , '' );
$sql -> db_ResetTableList ();
}
// ----------create tables -----------------------------------------------------
if ( isset ( $_POST [ 'create_tables' ]) && $_POST [ 'language' ])
{
$table_to_copy = array ();
$lang_to_create = array ();
2018-01-13 14:11:46 -08:00
2015-07-09 19:24:59 -07:00
foreach ( $tabs as $value )
{
$lang = strtolower ( $_POST [ 'language' ]);
if ( isset ( $_POST [ $value ]))
{
$copdata = ( $_POST [ 'copydata_' . $value ]) ? 1 : 0 ;
if ( $sql -> db_CopyTable ( $value , " lan_ " . $lang . " _ " . $value , $_POST [ 'drop' ], $copdata ))
{
$msg = $tp -> lanVars ( LANG_LAN_103 , $_POST [ 'language' ] . ' ' . $value );
$message .= $msg . '[!br!]' ; // Used in admin log.
$mes -> addSuccess ( $msg );
}
else
{
2018-01-13 13:00:44 -08:00
if ( empty ( $_POST [ 'drop' ]))
2015-07-09 19:24:59 -07:00
{
$msg = $tp -> lanVars ( LANG_LAN_00 , $_POST [ 'language' ] . ' ' . $value );
$message .= $msg . '[!br!]' ;
$mes -> addWarning ( $msg );
}
else
{
$msg = $tp -> lanVars ( LANG_LAN_01 , $_POST [ 'language' ] . ' ' . $value );
$message .= $msg . '[!br!]' ;
$mes -> addWarning ( $msg );
}
}
}
elseif ( $sql -> isTable ( $value , $_POST [ 'language' ]))
{
if ( $_POST [ 'remove' ])
{
// Remove table.
2016-11-28 16:27:17 -08:00
if ( $sql -> gen ( " DROP TABLE " . MPREFIX . " lan_ " . $lang . " _ " . $value ))
2015-07-09 19:24:59 -07:00
{
$message .= $_POST [ 'language' ] . ' ' . $value . ' ' . LAN_DELETED . '[!br!]' ; // can be removed?
$mes -> addSuccess ( $_POST [ 'language' ] . ' ' . $value . ' ' . LAN_DELETED );
}
else
{
$msg = $tp -> lanVars ( LANG_LAN_02 , $_POST [ 'language' ] . ' ' . $value );
$message .= $msg . '[!br!]' ;
$mes -> addWarning ( $msg );
}
}
else
{
// leave table. LANG_LAN_104
$msg = $tp -> lanVars ( LANG_LAN_104 , $_POST [ 'language' ] . ' ' . $value );
$message .= $msg . '[!br!]' ;
$mes -> addInfo ( $msg );
}
}
}
e107 :: getLog () -> add ( 'LANG_03' , $message , E_LOG_INFORMATIVE , '' );
$sql -> db_ResetTableList ();
}
}
private function dbPageEdit ()
{
$frm = e107 :: getForm ();
$tp = e107 :: getParser ();
$tabs = $this -> getTables ();
$sql = e107 :: getDb ();
$languageSelected = $tp -> filter ( $_GET [ 'lan' ], 'w' );
$text = "
< form method = 'post' action = '".e_SELF."?mode=main&action=db' >
< fieldset id = 'core-language-edit' >
< legend class = 'e-hideme' > " . $languageSelected . " </ legend >
< table class = 'table adminlist table-striped' >
< colgroup >
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tbody >
" ;
foreach ( $tabs as $table_name )
{
$installed = 'lan_' . strtolower ( $languageSelected ) . " _ " . $table_name ;
2020-12-20 11:50:10 -08:00
if ( stripos ( $languageSelected , $installed ) === false )
2015-07-09 19:24:59 -07:00
{
$selected = ( $sql -> isTable ( $table_name , $languageSelected )) ? " checked='checked' " : " " ;
$tableName = ucfirst ( str_replace ( " _ " , " " , $table_name ));
$tableLabel = ( $selected ) ? " <span class='label label-success'> " . $tableName . " </span> " : $tableName ;
$text .= "
< tr >
< td > " . $tableLabel . " </ td >
< td >
< div >
< div class = 'auto-toggle-area e-pointer' >
" ;
$text .= "
2021-01-16 13:32:35 -08:00
< input type = 'checkbox' class = 'checkbox e-expandit' data - return = 'true' data - target = 'language-datacopy-{$table_name}' id = 'language-action-{$table_name}' name = '{$table_name}' value = '1' { $selected } />
2015-07-09 19:24:59 -07:00
</ div >
< div id = 'language-datacopy-{$table_name}' class = 'offset1 e-hideme e-pointer' > " .
$frm -> checkbox ( " copydata_ " . $table_name , 1 , false , LANG_LAN_15 ) . "
</ div >
</ div >
</ td >
</ tr >
" ;
}
}
// ===========================================================================
// Drop tables ? isset()
if ( varset ( $_GET [ 'sub' ]) == 'create' )
{
$baction = 'create' ;
$bcaption = LANG_LAN_06 ;
}
else
{
$baction = 'update' ;
$bcaption = LAN_UPDATE ;
}
$text .= "
2015-07-22 19:49:02 -07:00
< tr class = 'warning' >
2015-07-09 19:24:59 -07:00
< td >< strong > " .LANG_LAN_07. " </ strong ></ td >
< td >
" . $frm->checkbox ('drop', 1). "
< div class = 'smalltext field-help' > " . $frm->label (LANG_LAN_08, 'drop', 1). " </ div >
</ td >
</ tr >
2015-07-22 19:49:02 -07:00
< tr class = 'warning' >
2015-07-09 19:24:59 -07:00
< td >< strong > " .LAN_CONFDELETE. " </ strong ></ td >
< td >
" . $frm->checkbox ('remove', 1). "
< div class = 'smalltext field-help' > " . $frm->label (LANG_LAN_11, 'remove', 1). " </ div >
</ td >
</ tr >
</ tbody >
</ table >
< div class = 'buttons-bar center' >
< input type = 'hidden' name = 'language' value = '{$languageSelected}' />
" . $frm->admin_button ('create_tables','no-value', $baction , $bcaption ). "
</ div >
</ fieldset >
</ form >
" ;
$this -> addTitle ( $languageSelected );
return $text ;
//$ns->tablerender(ADLAN_132.SEP.LANG_LAN_03.SEP.$languageSelected, $mes->render().$text);
//return true;
}
public function dbPage ()
{
if ( ! getperms ( '0' ))
{
return " Access Denied " ;
}
$this -> dbPageEditProcess ();
if ( $_GET [ 'sub' ] == 'edit' || $_GET [ 'sub' ] == 'create' )
{
return $this -> dbPageEdit ();
}
// $lanlist = e107::getLanguage()->installed();
$lanlist = $this -> installedLanguages ;
$tabs = $this -> getTables ();
$sql = e107 :: getDb ();
$frm = e107 :: getForm ();
$tp = e107 :: getParser ();
$mes = e107 :: getMessage ();
$pref = e107 :: getPref ();
if ( empty ( $pref [ 'multilanguage' ]))
{
return false ;
}
$lck = e107 :: getSingleton ( 'lancheck' , e_ADMIN . " lancheck.php " );
// Choose Language to Edit:
$text = "
< fieldset id = 'core-language-list' >
< legend class = 'e-hideme' > " .LANG_LAN_16. " </ legend >
< table class = 'table table-striped adminlist' >
< colgroup >
< col style = 'width:20%' />
< col style = 'width:60%' />
< col style = 'width:20%' />
</ colgroup >
< thead >
< tr >
< th > " .ADLAN_132. " </ th >
< th > " .LANG_LAN_03. " </ th >
< th class = 'last' > " .LAN_OPTIONS. " </ th >
</ tr >
</ thead >
< tbody >
< tr class = 'active' >
< td > " . $pref['sitelanguage'] . " </ td >
< td >< i > " .LANG_LAN_17. " </ i ></ td >
< td ></ td >
</ tr >
" ;
sort ( $lanlist );
foreach ( $lanlist as $e_language )
{
if ( $e_language == $pref [ 'sitelanguage' ])
{
continue ;
}
$installed = array ();
$text .= " <tr><td> { $e_language } </td><td> " ;
foreach ( $tabs as $tab_name )
{
if ( $e_language != $pref [ 'sitelanguage' ] && $sql -> isTable ( $tab_name , $e_language ))
{
$installed [] = $tab_name ;
$text .= " <span class='label label-success'> " . $tab_name . " </span> " ;
}
}
$text .= ( ! count ( $installed )) ? " <span class='label label-danger label-important'> " . LANG_LAN_05 . " </span> " : " " ;
$text .= " </td> \n " ;
$text .= " <td>
< form style = 'margin:0px' id = 'core-language-form-".str_replace(" ", "-", $e_language)."' action = '".e_SELF."?mode=main&action=db' method = 'post' > \n " ;
$text .= " <div> " ;
if ( count ( $installed ))
{
$text .= " <a class='btn btn-primary edit' href=' " . e_SELF . " ?mode=main&action=db&sub=edit&lan= " . $e_language . " '> " . LAN_EDIT . " </a> " ;
// $text .= "<button class='btn btn-primary edit' type='submit' name='edit_existing' value='no-value'><span>".LAN_EDIT."</span></button>";
$text .= $frm -> admin_button ( 'del_existing' , LAN_DELETE , 'delete' );
// $text .= "<button class='btn btn-danger delete' type='submit' name='del_existing' value='no-value' title='".$tp->lanVars(LANG_LAN_105, $e_language).' '.LAN_JSCONFIRM."'><span>".LAN_DELETE."</span></button>";
}
elseif ( $e_language != $pref [ 'sitelanguage' ])
{
// $text .= "<button class='create' type='submit' name='create_edit_existing' value='no-value'><span>".LAN_CREATE."</span></button>";
// $text .= $frm->admin_button('create_edit_existing','no-value','create',LAN_CREATE);
$text .= " <a class='btn btn-primary create' href=' " . e_SELF . " ?mode=main&action=db&sub=create&lan= " . $e_language . " '> " . LAN_CREATE . " </a> " ;
}
$text .= " <input type='hidden' name='lang_choices' value=' " . $e_language . " ' />
</ div >
</ form >
</ td >
</ tr >
" ;
}
$text .= "
</ tbody >
</ table >
</ fieldset >
" ;
return $text ;
// e107::getRender()->tablerender(ADLAN_132.SEP.LANG_LAN_16, $mes->render().$text); // Languages -> Tables
}
}
class language_form_ui extends e_admin_form_ui
{
function multilanguage_domain ( $curVal , $mode )
{
$pref = e107 :: getPref ();
$opt = " " ;
$langs = explode ( " , " , e_LANLIST );
foreach ( $langs as $val )
{
if ( $val != $pref [ 'sitelanguage' ])
{
2021-02-13 07:58:24 -08:00
$opt .= " <tr><td class='middle' style='width:5%'> " . $val . " </td><td class='left inline-text'><input type='text' class='form-control' name='multilanguage_domain[ " . $val . " ]' value= \" " . varset ( $pref [ 'multilanguage_domain' ][ $val ]) . " \" /></td></tr> " ;
2015-07-09 19:24:59 -07:00
}
}
if ( $opt )
{
2021-02-12 14:27:21 -08:00
$text = " <table class='table table-striped table-bordered' style='margin-left:0px;width:600px'> " . $opt . " </table> " ;
2015-07-09 19:24:59 -07:00
}
2021-02-12 14:27:21 -08:00
else
{
$text = " <span class='label label-default'> " . LANG_LAN_155 . " </span> " ;
}
return $text ;
2015-07-09 19:24:59 -07:00
}
}
new language_admin ();
require_once ( e_ADMIN . " auth.php " );
e107 :: getAdminUI () -> runPage ();
require_once ( e_ADMIN . " footer.php " );
2009-11-07 11:20:34 +00:00
2015-07-03 19:39:02 -07:00
class lanDeveloper
2009-11-07 11:20:34 +00:00
{
2013-02-22 21:35:00 -08:00
2015-07-03 19:39:02 -07:00
private $lanFile = null ;
private $scriptFile = null ;
private $adminFile = false ;
private $commonPhrases = array ();
private $errors = 0 ;
2013-02-23 16:19:28 -08:00
2015-07-03 19:39:02 -07:00
function __construct ()
2009-11-07 11:20:34 +00:00
{
2015-07-03 19:39:02 -07:00
$ns = e107 :: getRender ();
$mes = e107 :: getMessage ();
2016-12-15 15:08:49 +01:00
$tp = e107 :: getParser ();
2015-07-03 19:39:02 -07:00
2015-07-09 19:24:59 -07:00
// ------------------------------ TODO -------------------------------
2018-01-13 13:00:44 -08:00
if ( ! empty ( $_POST [ 'disabled-unused' ]) && ! empty ( $_POST [ 'disable-unused-lanfile' ]))
2013-02-23 16:19:28 -08:00
{
2016-12-15 15:08:49 +01:00
$disUnusedLanFile = $tp -> filter ( $_POST [ 'disable-unused-lanfile' ], 'file' );
2015-07-09 19:24:59 -07:00
$mes = e107 :: getMessage ();
2016-12-15 15:08:49 +01:00
$data = file_get_contents ( $disUnusedLanFile );
2015-07-09 19:24:59 -07:00
$new = $this -> disableUnused ( $data );
2016-12-15 15:08:49 +01:00
if ( file_put_contents ( $disUnusedLanFile , $new ))
2015-07-09 19:24:59 -07:00
{
2016-12-15 15:08:49 +01:00
$mes -> addSuccess ( LANG_LAN_135 . $disUnusedLanFile ); //Overwriting
2015-07-09 19:24:59 -07:00
}
else
{
2016-12-15 15:08:49 +01:00
$mes -> addError ( LANG_LAN_136 . $disUnusedLanFile ); //Couldn't overwrite
2015-07-09 19:24:59 -07:00
}
2016-12-15 15:08:49 +01:00
$ns -> tablerender ( LANG_LAN_137 . SEP . $disUnusedLanFile , $mes -> render () . " <pre> " . htmlentities ( $new ) . " </pre> " ); //Processed
2015-07-09 19:24:59 -07:00
}
2013-02-23 16:19:28 -08:00
2015-07-09 19:24:59 -07:00
}
function run ()
{
2016-12-15 15:08:49 +01:00
$tp = e107 :: getParser ();
2015-07-09 19:24:59 -07:00
$mes = e107 :: getMessage ();
if ( varset ( $_POST [ 'searchDeprecated' ]) && varset ( $_POST [ 'deprecatedLans' ]))
{
// print_a($_POST);
2015-07-03 19:39:02 -07:00
// $lanfile = $_POST['deprecatedLans'];
2016-12-15 15:08:49 +01:00
$script = $tp -> filter ( $_POST [ 'deprecatedLans' ]);
2015-07-03 19:39:02 -07:00
2015-07-10 15:04:14 -07:00
foreach ( $script as $k => $scr )
2013-02-23 16:19:28 -08:00
{
2015-07-09 19:24:59 -07:00
if ( strpos ( $scr , e_ADMIN ) !== false ) // CORE
{
2016-10-11 14:48:13 +01:00
$mes -> addDebug ( " Mode: Core Admin Calculated " );
2015-07-09 19:24:59 -07:00
//$scriptname = str_replace("lan_","",basename($lanfile));
$lanfile [ $k ] = e_LANGUAGEDIR . e_LANGUAGE . " /admin/lan_ " . basename ( $scr );
$this -> adminFile = true ;
}
else // Root
{
2016-10-11 14:48:13 +01:00
$mes -> addDebug ( " Mode: Search Core Root lan calculated " );
2015-07-09 19:24:59 -07:00
$lanfile [ $k ] = e_LANGUAGEDIR . e_LANGUAGE . " /lan_ " . basename ( $scr );
$lanfile [ $k ] = str_replace ( " lan_install " , " lan_installer " , $lanfile [ $k ]); //quick fix.,
2015-07-03 19:39:02 -07:00
2015-07-09 19:24:59 -07:00
//$lanfile = $this->findIncludedFiles($script,vartrue($_POST['deprecatedLansReverse']));
}
2013-02-23 16:19:28 -08:00
2015-07-10 14:25:16 -07:00
if ( ! is_readable ( $scr ))
{
2016-10-10 20:06:43 +01:00
$mes -> addError ( LAN_NOTREADABLE . $scr );
2015-07-10 14:25:16 -07:00
// $script = $scriptname; // matching files. lan_xxxx.php and xxxx.php
}
2015-07-03 19:39:02 -07:00
}
2009-11-07 11:20:34 +00:00
2015-07-10 14:25:16 -07:00
2015-07-09 19:24:59 -07:00
// $found = $this->findIncludedFiles($script,vartrue($_POST['deprecatedLansReverse']));
2009-11-07 11:20:34 +00:00
2015-07-03 19:39:02 -07:00
// print_a($found);
// Exceptions - same language loaded by several scripts.
2015-07-10 15:04:14 -07:00
// if($lanfile == e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_e107_update.php")
// {
// $script = e_ADMIN."update_routines.php,".e_ADMIN."e107_update.php";
// }
2015-07-03 19:39:02 -07:00
2015-07-10 15:04:14 -07:00
if ( $_POST [ 'deprecatedLanFile' ][ 0 ] != 'auto' ) //override.
2013-05-18 14:54:57 -07:00
{
2021-02-11 12:29:16 -08:00
$lanfile = $tp -> filter ( $_POST [ 'deprecatedLanFile' ]);
2013-05-18 14:54:57 -07:00
}
2015-07-03 19:39:02 -07:00
2015-07-10 15:04:14 -07:00
2015-07-03 19:39:02 -07:00
$this -> lanFile = $lanfile ;
$this -> scriptFile = $script ;
$this -> commonPhrases = $this -> getCommon ();
2015-07-09 19:24:59 -07:00
// print_a($this->commonPhrases);
2016-12-15 15:08:49 +01:00
$reverse = vartrue ( $_POST [ 'deprecatedLansReverse' ]);
$reverse = $tp -> filter ( $reverse );
2015-07-03 19:39:02 -07:00
2016-12-15 15:08:49 +01:00
if ( $res = $this -> unused ( $lanfile , $script , $reverse ))
2015-07-03 19:39:02 -07:00
{
2015-07-09 19:24:59 -07:00
return $res ;
// $ns->tablerender($res['caption'],$mes->render(). $res['text']);
2009-11-07 11:20:34 +00:00
}
2013-05-18 14:54:57 -07:00
}
2009-11-07 11:20:34 +00:00
2015-07-09 19:24:59 -07:00
return false ;
}
function disableUnused ( $data )
{
2017-01-15 10:59:58 +00:00
$data = str_replace ( " 2008-2010 " , " 2008-2017 " , $data );
2015-07-09 19:24:59 -07:00
$data = str_replace ( ' * $URL $
* $Revision $
* $Id $
* $Author $ ' , " " , $data ); // TODO FIXME ?
$tmp = explode ( " \n " , $data );
foreach ( $tmp as $line )
{
$ret = $this -> getDefined ( $line );
$newline [] = ( in_array ( $ret [ 'define' ], $_SESSION [ 'language-tools-unused' ]) && substr ( $line , 0 , 2 ) != '//' ) ? " // " . $line : $line ;
}
return implode ( " \n " , $newline );
}
function getDefined ( $line , $script = false )
{
if ( $script == true )
{
2015-07-10 14:25:16 -07:00
return array ( 'define' => $line , 'value' => '-' );
2015-07-09 19:24:59 -07:00
}
if ( preg_match ( " # \" (.*?) \" .*? \" (.*) \" # " , $line , $match ) ||
preg_match ( " # \ '(.*?) \ '.*? \" (.*) \" # " , $line , $match ) ||
preg_match ( " # \" (.*?) \" .*? \ '(.*) \ '# " , $line , $match ) ||
preg_match ( " # \ '(.*?) \ '.*? \ '(.*) \ '# " , $line , $match ) ||
preg_match ( " # \ ((.*?) \ ,.*? \" (.*) \" # " , $line , $match ) ||
preg_match ( " # \ ((.*?) \ ,.*? \ '(.*) \ '# " , $line , $match ))
{
return array ( 'define' => $match [ 1 ], 'value' => $match [ 2 ]);
}
2015-07-03 19:39:02 -07:00
2009-11-07 11:20:34 +00:00
}
2015-07-03 19:39:02 -07:00
static function form ()
2009-11-07 11:20:34 +00:00
{
2021-02-11 12:29:16 -08:00
2015-07-03 19:39:02 -07:00
$frm = e107 :: getForm ();
$mes = e107 :: getMessage ();
$text = " " ;
2009-11-07 11:20:34 +00:00
2015-07-03 19:39:02 -07:00
$text .= "
2021-02-11 12:29:16 -08:00
< form id = 'lanDev' method = 'post' action = '" . e_REQUEST_URI . "' >
2015-07-03 19:39:02 -07:00
< fieldset id = 'core-language-package' >
2015-07-11 14:11:56 -07:00
2021-02-11 12:29:16 -08:00
" ;
2009-11-07 11:20:34 +00:00
2015-07-03 19:39:02 -07:00
$fl = e107 :: getFile ();
$fl -> mode = 'full' ;
2009-11-07 11:20:34 +00:00
2015-07-03 19:39:02 -07:00
// $_SESSION['languageTools_lanFileList'] = null;
if ( ! $_SESSION [ 'languageTools_lanFileList' ])
2009-11-07 11:20:34 +00:00
{
2015-07-03 19:39:02 -07:00
2021-02-11 12:29:16 -08:00
$_SESSION [ 'languageTools_lanFileList' ] = $fl -> get_files ( e_LANGUAGEDIR . " English " , '.*?(English|lan_).*?\.php$' , 'standard' , 3 );
2009-11-07 11:20:34 +00:00
}
2015-07-03 19:39:02 -07:00
// print_a($_SESSION['languageTools_lanFileList']);
2021-02-11 12:29:16 -08:00
$text .= " <div class='alert-info alert alert-block'> " . e107 :: getParser () -> toHTML ( LANG_LAN_140 , true ) . " </div>
< div class = 'row' >
< div class = 'col-md-4' >
< select name = 'deprecatedLans[]' class = 'form-control' multiple style = 'height:200px' >
< option value = '' > " . LANG_LAN_141 . " </ option > " ;
2015-07-03 19:39:02 -07:00
2021-02-11 12:29:16 -08:00
$omit = array ( 'languages' , '\.png' , '\.gif' , 'handlers' );
$lans = $fl -> get_files ( e_ADMIN , '.php' , 'standard' , 0 );
2017-01-15 10:59:58 +00:00
asort ( $lans );
2015-07-03 19:39:02 -07:00
$fl -> setFileFilter ( array ( " ^e_ " ));
2021-02-11 12:29:16 -08:00
$root = $fl -> get_files ( e_BASE , '.*?/?.*?\.php' , $omit , 0 );
2017-01-15 10:59:58 +00:00
asort ( $root );
2015-07-03 19:39:02 -07:00
2021-02-11 12:29:16 -08:00
$templates = $fl -> get_files ( e_CORE . " templates " , '.*?/?.*?\.php' , $omit , 0 );
2017-01-15 10:59:58 +00:00
asort ( $templates );
2021-02-11 12:29:16 -08:00
$shortcodes = $fl -> get_files ( e_CORE . " shortcodes " , '.*?/?.*?\.php' , $omit , 1 );
2017-01-15 10:59:58 +00:00
asort ( $shortcodes );
2015-07-03 19:39:02 -07:00
$exclude = array ( 'lan_admin.php' );
2021-02-11 12:29:16 -08:00
$srch = array ( e_ADMIN , e_PLUGIN , e_CORE , e_BASE );
2015-07-03 19:39:02 -07:00
2021-02-11 12:29:16 -08:00
$text .= " <optgroup label=' " . LAN_ADMIN . " '> " ;
2015-07-03 19:39:02 -07:00
2021-02-11 12:29:16 -08:00
foreach ( $lans as $script => $lan )
2015-07-03 19:39:02 -07:00
{
2021-02-11 12:29:16 -08:00
if ( in_array ( basename ( $lan ), $exclude ))
2015-07-03 19:39:02 -07:00
{
continue ;
}
2021-02-11 12:29:16 -08:00
2015-07-10 14:25:16 -07:00
$selected = ( ! empty ( $_POST [ 'deprecatedLans' ]) && in_array ( $lan , $_POST [ 'deprecatedLans' ])) ? " selected='selected' " : " " ;
2021-02-11 12:29:16 -08:00
$text .= " <option value=' " . $lan . " ' { $selected } > " . str_replace ( '../e107_' , " " , $lan ) . " </option> \n " ;
2015-07-03 19:39:02 -07:00
}
$text .= " </optgroup> " ;
2021-02-11 12:29:16 -08:00
$text .= " <optgroup label=' " . LAN_ROOT . " '> " ;
foreach ( $root as $script => $lan )
2015-07-03 19:39:02 -07:00
{
2021-02-11 12:29:16 -08:00
if ( in_array ( basename ( $lan ), $exclude ))
2015-07-03 19:39:02 -07:00
{
continue ;
}
2015-07-10 14:25:16 -07:00
$selected = ( ! empty ( $_POST [ 'deprecatedLans' ]) && in_array ( $lan , $_POST [ 'deprecatedLans' ])) ? " selected='selected' " : " " ;
2021-02-11 12:29:16 -08:00
$text .= " <option value=' " . $lan . " ' { $selected } > " . str_replace ( $srch , " " , $lan ) . " </option> \n " ;
2015-07-03 19:39:02 -07:00
}
$text .= " </optgroup> " ;
2021-02-11 12:29:16 -08:00
$text .= " <optgroup label=' " . LAN_TEMPLATES . " '> " ;
foreach ( $templates as $script => $lan )
2015-07-11 14:46:29 -07:00
{
2021-02-11 12:29:16 -08:00
if ( in_array ( basename ( $lan ), $exclude ))
2015-07-11 14:46:29 -07:00
{
continue ;
}
$selected = ( ! empty ( $_POST [ 'deprecatedLans' ]) && in_array ( $lan , $_POST [ 'deprecatedLans' ])) ? " selected='selected' " : " " ;
2021-02-11 12:29:16 -08:00
$text .= " <option value=' " . $lan . " ' { $selected } > " . str_replace ( $srch , " " , $lan ) . " </option> \n " ;
2015-07-11 14:46:29 -07:00
}
2015-07-10 14:25:16 -07:00
2015-07-11 14:46:29 -07:00
$text .= " </optgroup> " ;
2015-07-10 14:25:16 -07:00
2021-02-11 12:29:16 -08:00
$text .= " <optgroup label=' " . LAN_SHORTCODES . " '> " ;
foreach ( $shortcodes as $script => $lan )
2015-07-11 14:46:29 -07:00
{
2021-02-11 12:29:16 -08:00
if ( in_array ( basename ( $lan ), $exclude ))
2015-07-11 14:46:29 -07:00
{
continue ;
}
$selected = ( ! empty ( $_POST [ 'deprecatedLans' ]) && in_array ( $lan , $_POST [ 'deprecatedLans' ])) ? " selected='selected' " : " " ;
2021-02-11 12:29:16 -08:00
$text .= " <option value=' " . $lan . " ' { $selected } > " . str_replace ( $srch , " " , $lan ) . " </option> \n " ;
2015-07-11 14:46:29 -07:00
}
$text .= " </optgroup> " ;
2021-02-11 12:29:16 -08:00
2016-10-10 20:06:43 +01:00
//TODO LANs - not sure if this can be replaced with LANS?
2015-07-03 19:39:02 -07:00
$depOptions = array (
1 => " Script > Lan File " ,
0 => " Script < Lan File "
);
2021-02-11 12:29:16 -08:00
$text .= " </select></div><div class='col-md-4 text-center'> " ;
2015-07-03 19:39:02 -07:00
2021-02-11 12:29:16 -08:00
$text .= $frm -> select ( 'deprecatedLansReverse' , $depOptions , e107 :: getParser () -> filter ( $_POST [ 'deprecatedLansReverse' ]), 'class=select form-control' ) . " " ;
$text .= " <p> " . $frm -> admin_button ( 'searchDeprecated' , LAN_RUN , 'other' ) . " </p> " ;
2013-02-23 16:19:28 -08:00
2021-02-11 12:29:16 -08:00
$search = array ( e_PLUGIN , e_ADMIN , e_LANGUAGEDIR . " English/ " , e_THEME );
$replace = array ( " Plugins " , " Admin " , " Core " , " Themes " );
2015-07-03 19:39:02 -07:00
$prev = 'Core' ;
2021-02-11 12:29:16 -08:00
$text .= " </div><div class='col-md-4'><select name='deprecatedLanFile[]' class='form-control' multiple style='height:200px'>
2015-07-03 19:39:02 -07:00
" ;
2021-02-11 12:29:16 -08:00
$selected = ( $_POST [ 'deprecatedLanFile' ][ 0 ] == 'auto' ) ? " selected='selected' " : " " ;
$text .= " <option value='auto' { $selected } > " . LANG_LAN_142 . " </option><optgroup label=' " . LANG_LAN_143 . " '> \n " ; //Auto-Detect
2017-01-15 10:59:58 +00:00
asort ( $_SESSION [ 'languageTools_lanFileList' ]);
2015-07-03 19:39:02 -07:00
foreach ( $_SESSION [ 'languageTools_lanFileList' ] as $val )
{
2020-12-20 11:50:10 -08:00
if ( strpos ( $val , e_SYSTEM ) !== false )
2015-07-03 19:39:02 -07:00
{
continue ;
}
2015-07-10 14:25:16 -07:00
$selected = ( ! empty ( $_POST [ 'deprecatedLanFile' ]) && in_array ( $val , $_POST [ 'deprecatedLanFile' ])) ? " selected='selected' " : " " ;
2021-02-11 12:29:16 -08:00
$diz = str_replace ( $search , $replace , $val );
list ( $type , $label ) = explode ( " " , $diz );
2015-07-03 19:39:02 -07:00
if ( $type !== $prev )
{
2021-02-11 12:29:16 -08:00
$text .= " </optgroup><optgroup label=' " . $type . " '> \n " ;
2015-07-03 19:39:02 -07:00
}
2021-02-11 12:29:16 -08:00
$text .= " <option value=' " . $val . " ' " . $selected . " > " . $label . " </option> \n " ;
2015-07-03 19:39:02 -07:00
$prev = $type ;
}
$text .= " </optgroup> " ;
$text .= " </select> " ;
2021-02-11 12:29:16 -08:00
$text .= " </div>
</ div >
2015-07-03 19:39:02 -07:00
</ fieldset >
</ form >
2021-02-11 12:29:16 -08:00
" ;
2015-07-03 19:39:02 -07:00
2021-02-11 12:29:16 -08:00
return $mes -> render () . $text . " <hr /> " ;
2015-07-03 19:39:02 -07:00
}
2021-02-11 12:29:16 -08:00
2015-07-03 19:39:02 -07:00
function getCommon ()
2009-11-07 11:20:34 +00:00
{
2015-07-03 19:39:02 -07:00
$commonPhrases = file_get_contents ( e_LANGUAGEDIR . " English/English.php " );
if ( $this -> adminFile == true )
2009-11-07 11:20:34 +00:00
{
2015-07-03 19:39:02 -07:00
$commonPhrases .= file_get_contents ( e_LANGUAGEDIR . " English/admin/lan_admin.php " );
2009-11-07 11:20:34 +00:00
}
2015-07-03 19:39:02 -07:00
$commonLines = explode ( " \n " , $commonPhrases );
$ar = array ();
foreach ( $commonLines as $line )
2012-06-09 04:44:11 +00:00
{
2015-07-09 19:24:59 -07:00
if ( $match = $this -> getDefined ( $line ))
2015-07-03 19:39:02 -07:00
{
$id = $match [ 'define' ];
$ar [ $id ] = $match [ 'value' ];
}
}
return $ar ;
2009-11-07 11:20:34 +00:00
}
2015-07-03 19:39:02 -07:00
2015-07-10 14:25:16 -07:00
function isFound ( $needle , $haystack )
{
$found = array ();
foreach ( $haystack as $file => $content )
{
$count = 1 ;
$lines = explode ( " \n " , $content );
foreach ( $lines as $ln )
{
if ( preg_match ( " / \ b " . $needle . " \ b/i " , $ln , $mtch ))
{
$found [ $file ][ 'count' ][] = $count ;
$found [ $file ][ 'line' ][] = $ln ;
}
$count ++ ;
}
}
if ( ! empty ( $found ))
{
return $found ;
}
return false ;
// print_a($haystack);
}
2015-07-03 19:39:02 -07:00
function compareit ( $needle , $haystack , $value = '' , $disabled = false , $reverse = false )
2009-11-07 11:20:34 +00:00
{
2015-07-03 19:39:02 -07:00
2015-07-10 14:25:16 -07:00
$found = $this -> isFound ( $needle , $haystack );
2015-07-03 19:39:02 -07:00
// return "Need=".$needle."<br />hack=".$haystack."<br />val=".$val;
$foundSimilar = FALSE ;
$foundCommon = FALSE ;
$ar = $this -> commonPhrases ;
$commonArray = array_keys ( $ar );
// Check if a common phrases was used.
foreach ( $ar as $def => $common )
{
similar_text ( $value , $common , $p );
if ( strtoupper ( trim ( $value )) == strtoupper ( $common ))
2009-11-07 11:20:34 +00:00
{
2015-07-03 19:39:02 -07:00
//$text .= "<div style='color:yellow'><b>$common</b></div>";
$foundCommon = true ;
break ;
}
elseif ( $p > 75 )
{
$foundSimilar = true ;
break ;
}
$p = 0 ;
}
$text = '' ;
$text2 = '' ;
2015-07-10 14:25:16 -07:00
foreach ( $haystack as $file => $script )
2015-07-03 19:39:02 -07:00
{
2015-07-10 14:25:16 -07:00
// $lines = explode("\n",$script);
2015-07-03 19:39:02 -07:00
$text .= " <td> " ;
2015-07-10 14:25:16 -07:00
// $text2 .= ($reverse == true) ? "<td>" : "";
2015-07-03 19:39:02 -07:00
2015-07-10 14:25:16 -07:00
if ( ! empty ( $found [ $file ][ 'count' ]))
2015-07-03 19:39:02 -07:00
{
2015-07-10 14:25:16 -07:00
if ( $disabled )
2009-11-08 09:14:39 +00:00
{
2015-07-10 14:25:16 -07:00
$text .= ADMIN_WARNING_ICON ;
2016-10-10 20:06:43 +01:00
$label = " <span class='label label-important label-danger'> " . LANG_LAN_144 . " </span> " ; //Must be re-enabled
2015-07-10 14:25:16 -07:00
$this -> errors ++ ;
// $text .= "blabla";
2015-07-03 19:39:02 -07:00
// $class = 'alert alert-warning';
2015-07-10 14:25:16 -07:00
}
elseif ( $reverse == true )
{
$value = ADMIN_TRUE_ICON ;
2016-10-10 20:06:43 +01:00
$value .= " " . LAN_LINE . " <b> " . implode ( " , " , $found [ $file ][ 'count' ]) . " </b> " ; // "' Found";
2015-07-10 14:25:16 -07:00
foreach ( $found [ $file ][ 'line' ] as $defLine )
2015-07-03 19:39:02 -07:00
{
2015-07-10 14:25:16 -07:00
$text .= print_a ( $defLine , true );
2015-07-03 19:39:02 -07:00
}
2015-07-10 14:25:16 -07:00
}
else
{
2016-10-10 20:06:43 +01:00
$text .= " " . LAN_LINE . " :<b> " . implode ( " , " , $found [ $file ][ 'count' ]) . " </b> " ; // "' Found";
2013-02-23 16:19:28 -08:00
}
2015-07-03 19:39:02 -07:00
}
2015-07-10 14:25:16 -07:00
2015-07-03 19:39:02 -07:00
if ( $reverse == true && in_array ( $needle , $commonArray ))
{
$found = false ;
2015-07-10 14:25:16 -07:00
2015-07-03 19:39:02 -07:00
}
if ( empty ( $found ))
{
// echo "<br />Unused: ".$needle;
2013-05-18 14:54:57 -07:00
if ( $reverse == true )
{
2015-07-03 19:39:02 -07:00
if ( in_array ( $needle , $commonArray ))
{
// print_a($needle);
//$color = "background-color:#E9EAF2";
$class = '' ;
2015-07-10 14:25:16 -07:00
$value = ADMIN_TRUE_ICON ;
$label = " <span class='label label-success'> " . LANG_LAN_130 . " </span> " ; // Common Term.
2015-07-03 19:39:02 -07:00
}
else
{
// $color = "background-color:yellow";
2016-10-10 20:06:43 +01:00
$value = " <a href='#' title= " . LAN_MISSING . " > " . ADMIN_WARNING_ICON . " </a> " ;
2015-07-03 19:39:02 -07:00
$this -> errors ++ ;
2015-07-15 19:33:15 -07:00
$label = " <span class='label label-important label-danger'> " . LANG_LAN_131 . " </span> " ;
2015-07-10 14:25:16 -07:00
// $class = "alert alert-warning";
2015-07-03 19:39:02 -07:00
}
}
elseif ( empty ( $disabled ))
{
// $color = "background-color:pink";
$class = ' ' ;
2016-10-10 20:06:43 +01:00
$label = " <span class='label label-important label-danger'> " . LAN_UNUSED . " </span> " ;
2015-07-03 19:39:02 -07:00
$text .= " - " ;
$this -> errors ++ ;
}
if ( ! $disabled )
{
$_SESSION [ 'language-tools-unused' ][] = $needle ;
2013-05-18 14:54:57 -07:00
}
2009-11-07 11:20:34 +00:00
}
2015-07-03 19:39:02 -07:00
$text .= " </td> " ;
2015-07-10 14:25:16 -07:00
2015-07-03 19:39:02 -07:00
}
2009-11-08 09:14:39 +00:00
2015-07-03 19:39:02 -07:00
if ( $foundCommon && $found )
{
//$color = "background-color:yellow";
// $class = "alert alert-warning";
2015-07-15 19:33:15 -07:00
$label .= " <div class='label label-important label-danger'><i> " . $common . " </i> " . LANG_LAN_132 . " <br />( " . LANG_LAN_133 . " <b> " . $def . " </b> " . LANG_LAN_134 . " )</div> " ;
2015-07-03 19:39:02 -07:00
// return "<tr><td style='width:25%;'>".$needle .$disabled. "</td><td></td></tr>";
}
elseif ( $foundSimilar && $found && substr ( $def , 0 , 4 ) == " LAN_ " )
{
// $color = "background-color:#E9EAF2";
$label .= " <span class='label label-warning' style='cursor:help' title= \" " . $common . " \" > " . round ( $p ) . " % like " . $def . " </span> " ;
// $disabled .= " <a class='e-tip' href='#' title=\"".$common."\">" . $def."</a>"; // $common;
}
if ( $disabled !== false )
{
$color = " font-style:italic " ;
$class = 'muted text-important ' ;
2016-10-10 20:06:43 +01:00
$label .= " <span class='label label-inverse'> " . LAN_DISABLED . " </span> " ;
2015-07-03 19:39:02 -07:00
}
2020-12-18 19:55:12 -08:00
// if(empty($found) && $disabled === true)
// {
2015-07-03 19:39:02 -07:00
// $needle = "<span class='e-tip' style='cursor:help' title=\"".$value."\">".$needle."</span>";
2020-12-18 19:55:12 -08:00
// }
2009-11-07 11:20:34 +00:00
2015-07-10 14:25:16 -07:00
return " <tr><td class=' " . $class . " ' style='width:15%; $color '> " . $needle . " </td><td> " . $label . " </td>
2015-07-03 19:39:02 -07:00
< td class = '".$class."' > " .print_r( $value ,true). " </ td >
" . $text . $text2 . " </ tr > " ;
}
/**
* Compare Language File against script and find unused LANs
2020-12-18 19:55:12 -08:00
* @ param array | string $lanfile
* @ param array | string $script
* @ return array | bool | string
2015-07-03 19:39:02 -07:00
*/
2020-12-18 19:55:12 -08:00
function unused ( $lanfile , $script , $reverse = false )
2015-07-03 19:39:02 -07:00
{
$mes = e107 :: getMessage ();
$frm = e107 :: getForm ();
unset ( $_SESSION [ 'language-tools-unused' ]);
// $mes->addInfo("LAN=".$lanfile."<br />Script = ".$script);
if ( $reverse == true )
2009-11-07 11:20:34 +00:00
{
2016-10-11 14:48:13 +01:00
$mes -> addDebug ( " REVERSE MODE " );
2015-07-10 14:25:16 -07:00
$exclude = array ( " e_LANGUAGE " , " e_LANGUAGEDIR " , " e_LAN " , " e_LANLIST " , " e_LANCODE " , " LANGUAGES_DIRECTORY " , " e_LANGUAGEDIR_ABS " , " LAN " );
$data = '' ;
foreach ( $script as $d )
{
$data .= file_get_contents ( $d ) . " \n " ;
}
2015-07-03 19:39:02 -07:00
if ( preg_match_all ( " /([ \ w_]*LAN[ \ w_]*)/ " , $data , $match ))
2013-02-23 16:19:28 -08:00
{
2015-07-03 19:39:02 -07:00
// print_a($match);
$foundLans = array ();
foreach ( $match [ 1 ] as $val )
2013-02-23 16:19:28 -08:00
{
2015-07-03 19:39:02 -07:00
if ( ! in_array ( $val , $exclude ))
{
$foundLans [] = $val ;
}
}
sort ( $foundLans );
$foundLans = array_unique ( $foundLans );
$lanDefines = implode ( " \n " , $foundLans );
}
2015-07-09 19:24:59 -07:00
$tmp = is_array ( $lanfile ) ? $lanfile : explode ( " , " , $lanfile );
2015-07-03 19:39:02 -07:00
foreach ( $tmp as $scr )
{
2016-10-11 14:48:13 +01:00
$mes -> addDebug ( " Script : " . $scr );
2015-07-09 19:24:59 -07:00
2015-07-03 19:39:02 -07:00
if ( ! file_exists ( $scr ))
2013-02-23 16:19:28 -08:00
{
2016-10-11 14:48:13 +01:00
$mes -> addError ( " Reverse Mode: " . LANG_LAN_121 . " " . $scr );
2015-07-03 19:39:02 -07:00
continue ;
2013-02-23 16:19:28 -08:00
}
2015-07-03 19:39:02 -07:00
$compare [ $scr ] = file_get_contents ( $scr );
2016-10-11 14:48:13 +01:00
$mes -> addDebug ( " LanFile: " . $scr );
2015-07-03 19:39:02 -07:00
2013-02-23 16:19:28 -08:00
}
2015-07-03 19:39:02 -07:00
$lanfile = $script ;
}
else
{
2016-10-11 14:48:13 +01:00
$mes -> addDebug ( " NORMAL MODE " );
2015-07-09 19:24:59 -07:00
$lanDefines = '' ;
foreach ( $lanfile as $arr )
{
$lanDefines .= file_get_contents ( $arr );
2016-10-11 14:48:13 +01:00
$mes -> addDebug ( " LanFile: " . $arr );
2015-07-09 19:24:59 -07:00
}
2015-07-03 19:39:02 -07:00
2015-07-09 19:24:59 -07:00
$tmp = is_array ( $script ) ? $script : explode ( " , " , $script );
2015-07-03 19:39:02 -07:00
foreach ( $tmp as $scr )
2013-02-23 16:19:28 -08:00
{
2015-07-03 19:39:02 -07:00
if ( ! file_exists ( $scr ))
{
2016-10-10 20:06:43 +01:00
$mes -> addError ( LANG_LAN_148 . " : " . LANG_LAN_121 . " " . $scr );
2015-07-03 19:39:02 -07:00
continue ;
}
$compare [ $scr ] = file_get_contents ( $scr );
2016-10-11 14:48:13 +01:00
$mes -> addDebug ( " Script: " . $scr );
2013-02-23 16:19:28 -08:00
}
2015-07-03 19:39:02 -07:00
}
// print_a($compare);
// print_a($lanDefines);
if ( ! $compare )
{
2016-10-10 20:06:43 +01:00
$mes -> addError ( LAN_LINE . " " . __LINE__ . " : " . LANG_LAN_121 . " " . $script );
2015-07-03 19:39:02 -07:00
}
if ( ! $lanDefines )
{
2016-10-10 20:06:43 +01:00
$mes -> addError ( LAN_LINE . " " . __LINE__ . " : " . LANG_LAN_121 . " " . $lanfile );
2015-07-03 19:39:02 -07:00
}
$srch = array ( " <?php " , " <? " , " ?> " );
$lanDefines = str_replace ( $srch , " " , $lanDefines );
$lanDefines = explode ( " \n " , $lanDefines );
if ( $lanDefines )
{
$text = $frm -> open ( 'language-unused' );
$text .= " <table class='table adminlist table-striped table-bordered'>
< colgroup >
2015-07-10 14:25:16 -07:00
< col style = 'width:10%' />
< col style = 'width:5%' />
< col style = 'width:auto' /> " ;
foreach ( $lanfile as $l )
{
$text .= " <col style='width:auto' /> \n " ;
}
$text .= "
2015-07-03 19:39:02 -07:00
</ colgroup >
< thead >
< tr >
2015-07-10 14:25:16 -07:00
< th > " .str_replace(e_LANGUAGEDIR, " " ,implode( " < br /> " , $lanfile )). " </ th >
< th > " .LAN_STATUS. " </ th > " ;
if ( $reverse == false )
{
2016-10-10 20:06:43 +01:00
$text .= " <th> " . LANG_LAN_149 . " </th> " ;
2015-07-10 14:25:16 -07:00
}
2015-07-03 19:39:02 -07:00
foreach ( $compare as $k => $val )
{
$text .= " <th> " . str_replace ( " ../ " , " " , $k ) . " </th> " ;
}
2015-07-10 14:25:16 -07:00
2015-07-03 19:39:02 -07:00
if ( $reverse == true )
{
$text .= " <th> " . LANG_LAN_124 . " </th> " ;
}
$text .= "
</ tr >
</ thead >
< tbody > " ;
// for ($i=0; $i<count($lanDefines); $i++)
// {
foreach ( $lanDefines as $line )
{
if ( trim ( $line ) != " " )
{
2015-07-10 14:25:16 -07:00
$disabled = ( preg_match ( " #^//#i " , $line )) ? " ( " . LAN_DISABLED . " ) " : false ;
2015-07-09 19:24:59 -07:00
if ( $match = $this -> getDefined ( $line , $reverse ))
2015-07-03 19:39:02 -07:00
{
$text .= $this -> compareit ( $match [ 'define' ], $compare , $match [ 'value' ], $disabled , $reverse );
2015-07-10 14:25:16 -07:00
2015-07-03 19:39:02 -07:00
}
}
}
$text .= " </tbody></table> " ;
/*
if ( count ( $_SESSION [ 'language-tools-unused' ]) > 0 && $reverse == false )
{
$text .= " <div class='buttons-bar center'> " . $frm -> admin_button ( 'disabled-unused' , LANG_LAN_126 , 'delete' ) .
$frm -> hidden ( 'disable-unused-lanfile' , $lanfile ) .
$frm -> hidden ( 'deprecatedLans' , $script ) .
" </div> " ;
}
*/
$text .= $frm -> close ();
if ( $reverse != true )
2013-02-22 21:35:00 -08:00
{
2016-10-25 08:02:58 +02:00
$mes -> addInfo ( e107 :: getParser () -> toHTML ( LANG_LAN_150 , true )); //Search Everywhere before commenting out
2015-07-03 19:39:02 -07:00
}
$ret [ 'text' ] = $mes -> render () . $text ;
2016-10-10 20:06:43 +01:00
$ret [ 'caption' ] = LAN_ERRORS . " : " . intval ( $this -> errors );
2015-07-03 19:39:02 -07:00
return $ret ;
}
else
{
2020-12-18 19:55:12 -08:00
return false ;
2009-11-07 11:20:34 +00:00
}
2015-07-03 19:39:02 -07:00
2009-11-07 11:20:34 +00:00
}
2013-02-23 16:19:28 -08:00
2009-11-07 11:20:34 +00:00
2015-07-03 19:39:02 -07:00
function findIncludedFiles ( $script , $reverse = false )
{
$mes = e107 :: getMessage ();
$data = file_get_contents ( $script );
if ( strpos ( $data , 'e_admin_dispatcher' ) !== false )
{
$reverse = false ;
}
$dir = dirname ( $script );
$dir = str_replace ( " /includes " , " " , $dir );
$plugin = basename ( $dir );
if ( strpos ( $script , 'admin' ) !== false || strpos ( $script , 'includes' ) !== false ) // Admin Language files.
{
$newLangs = array (
0 => $dir . " /languages/English/English_admin_ " . $plugin . " .php " ,
1 => $dir . " /languages/English_admin_ " . $plugin . " .php " ,
2 => $dir . " /languages/English_admin.php " ,
3 => $dir . " /languages/English/English_admin.php "
);
}
else
{
$newLangs = array (
0 => $dir . " /languages/English/English_ " . $plugin . " .php " ,
1 => $dir . " /languages/English_admin_ " . $plugin . " .php " ,
2 => $dir . " /languages/English_front.php " ,
3 => $dir . " /languages/English/English_front.php " ,
4 => $dir . " /languages/English_front.php " ,
5 => $dir . " /languages/English/English_front.php "
);
}
// if(strpos($data, 'e_admin_dispatcher')!==false)
{
foreach ( $newLangs as $path )
{
if ( file_exists ( $path ) && $reverse == false )
{
return $path ;
}
}
}
preg_match_all ( " /.*(include_lan|require_once|include|include_once) ? \ ((.*e_LANGUAGE.*? \ .php)/i " , $data , $match );
$srch = array ( " " , 'e_PLUGIN.' , 'e_LANGUAGEDIR' , '.e_LANGUAGE.' , " ' " , '"' , " '. " );
$repl = array ( " " , e_PLUGIN , e_LANGUAGEDIR , " English " , " " , " " , " " );
foreach ( $match [ 2 ] as $lanFile )
{
$arrt = str_replace ( $srch , $repl , $lanFile );
// if(strpos($arrt,'admin'))
{
//return $arrt;
$arr [] = $arrt ;
}
}
return implode ( " , " , $arr );
// return $arr[0];
2009-11-07 11:20:34 +00:00
}
2015-07-03 19:39:02 -07:00
}
2009-11-07 11:20:34 +00:00