2008-12-02 00:32:30 +00:00
< ? php
/*
* e107 website system
*
2011-12-10 00:00:15 +00:00
* Copyright ( C ) e107 Inc ( e107 . org )
2008-12-02 00:32:30 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
2011-11-25 17:48:24 +00:00
* URL and front controller Management
2008-12-02 00:32:30 +00:00
*
*/
2021-09-14 13:28:03 -07:00
if ( ! empty ( $_POST ) && ! isset ( $_POST [ 'e-token' ]))
{
$_POST [ 'e-token' ] = '' ;
}
2021-01-16 13:32:35 -08:00
require_once ( __DIR__ . '/../class2.php' );
2016-03-27 11:34:14 -07:00
if ( ! getperms ( 'K' ))
2008-12-02 11:03:02 +00:00
{
2016-01-13 19:17:37 -08:00
e107 :: redirect ( 'admin' );
2008-12-02 00:32:30 +00:00
exit ;
2008-12-02 00:40:28 +00:00
}
2008-12-02 00:32:30 +00:00
2011-11-25 17:48:24 +00:00
e107 :: coreLan ( 'eurl' , true );
// TODO - admin interface support, remove it from globals
2008-12-02 00:32:30 +00:00
$e_sub_cat = 'eurl' ;
2015-09-14 12:36:44 -07:00
e107 :: css ( 'inline' , " span.e-help { cursor: help } " );
2015-06-18 18:23:25 -07:00
2011-11-25 17:48:24 +00:00
class eurl_admin extends e_admin_dispatcher
2008-12-02 00:32:30 +00:00
{
2011-11-25 17:48:24 +00:00
protected $modes = array (
'main' => array (
'controller' => 'eurl_admin_ui' ,
'path' => null ,
'ui' => 'eurl_admin_form_ui' ,
'uipath' => null
)
);
protected $adminMenu = array (
2021-02-03 11:46:32 -08:00
'main/config' => array ( 'caption' => LAN_EURL_MENU_PROFILES , 'perm' => 'L' , 'icon' => 'fas-list' ),
'main/alias' => array ( 'caption' => LAN_EURL_MENU_ALIASES , 'perm' => 'L' , 'icon' => 'fas-edit' ),
'main/simple' => array ( 'caption' => LAN_EURL_MENU_CONFIG , 'perm' => 'L' , 'icon' => 'fas-sliders-h' ),
2011-11-25 17:48:24 +00:00
'main/settings' => array ( 'caption' => LAN_EURL_MENU_SETTINGS , 'perm' => 'L' ),
2016-02-28 09:26:21 -08:00
2013-04-15 14:06:53 -07:00
// 'main/help' => array('caption'=> LAN_EURL_MENU_HELP, 'perm' => 'L'),
2011-11-25 17:48:24 +00:00
);
protected $adminMenuAliases = array ();
protected $defaultAction = 'config' ;
2008-12-02 00:32:30 +00:00
2011-11-25 17:48:24 +00:00
protected $menuTitle = LAN_EURL_MENU ;
2017-02-01 18:25:32 -08:00
protected $adminMenuIcon = 'e-eurl-24' ;
2011-11-25 17:48:24 +00:00
}
2008-12-02 00:32:30 +00:00
2011-11-25 17:48:24 +00:00
class eurl_admin_ui extends e_admin_controller_ui
{
public $api ;
protected $prefs = array (
'url_disable_pathinfo' => array ( 'title' => LAN_EURL_SETTINGS_PATHINFO , 'type' => 'boolean' , 'help' => LAN_EURL_MODREWR_DESCR ),
2011-12-10 00:00:15 +00:00
'url_main_module' => array ( 'title' => LAN_EURL_SETTINGS_MAINMODULE , 'type' => 'dropdown' , 'data' => 'string' , 'help' => LAN_EURL_SETTINGS_MAINMODULE_HELP ),
2011-11-25 17:48:24 +00:00
'url_error_redirect' => array ( 'title' => LAN_EURL_SETTINGS_REDIRECT , 'type' => 'boolean' , 'help' => LAN_EURL_SETTINGS_REDIRECT_HELP ),
2011-12-10 00:00:15 +00:00
'url_sef_translate' => array ( 'title' => LAN_EURL_SETTINGS_SEFTRANSLATE , 'type' => 'dropdown' , 'data' => 'string' , 'help' => LAN_EURL_SETTINGS_SEFTRANSLATE_HELP ),
2011-11-25 17:48:24 +00:00
);
public function init ()
{
2015-06-18 18:23:25 -07:00
if ( e_AJAX_REQUEST )
{
$tp = e107 :: getParser ();
if ( ! empty ( $_POST [ 'pk' ]) && ! empty ( $_POST [ 'value' ]))
{
$cfg = e107 :: getConfig ();
list ( $plug , $key ) = explode ( " | " , $_POST [ 'pk' ]);
if ( is_string ( $cfg -> get ( 'e_url_alias' )))
{
$cfg -> setPostedData ( 'e_url_alias' , array ( e_LAN => array ( $plug => array ( $key => $tp -> filter ( $_POST [ 'value' ]))) ), false );
}
else
{
$cfg -> setPref ( 'e_url_alias/' . e_LAN . '/' . $plug . " / " . $key , $tp -> filter ( $_POST [ 'value' ]));
}
$cfg -> save ( true , true , true );
}
2015-03-31 07:25:39 -07:00
2015-06-18 18:23:25 -07:00
// file_put_contents(e_LOG."e_url.log", print_r($cfg->get('e_url_alias'),true));
exit ;
}
2015-04-01 02:09:25 -07:00
$htaccess = file_exists ( e_BASE . " .htaccess " );
2015-03-31 07:25:39 -07:00
2015-04-01 02:09:25 -07:00
if ( function_exists ( 'apache_get_modules' ))
2015-03-31 07:25:39 -07:00
{
2015-04-01 02:09:25 -07:00
$modules = apache_get_modules ();
$modRewrite = in_array ( 'mod_rewrite' , $modules );
}
else
{
2015-04-10 18:58:13 -07:00
$modRewrite = true ; //we don't really know.
2015-04-01 02:09:25 -07:00
}
if ( $modRewrite === false )
{
e107 :: getMessage () -> addInfo ( " Apache mod_rewrite was not found on this server and is required to use this feature. " );
2015-04-10 18:58:13 -07:00
e107 :: getMessage () -> addDebug ( print_a ( $modules , true ));
2015-04-01 02:09:25 -07:00
}
if ( $htaccess && $modRewrite && ! deftrue ( 'e_MOD_REWRITE' ))
{
e107 :: getMessage () -> addInfo ( " Mod-rewrite is disabled. To enable, please add the following line to your <b>e107_config.php</b> file:<br /><pre>define('e_MOD_REWRITE',true);</pre> " );
2015-03-31 07:25:39 -07:00
}
2013-11-22 20:46:45 -08:00
2020-01-27 12:17:34 -08:00
if ( isset ( $_POST [ 'rebuild' ]) && is_array ( $_POST [ 'rebuild' ]))
2013-11-22 20:46:45 -08:00
{
$table = key ( $_POST [ 'rebuild' ]);
list ( $primary , $input , $output ) = explode ( " :: " , $_POST [ 'rebuild' ][ $table ]);
$this -> rebuild ( $table , $primary , $input , $output );
}
2017-04-14 11:55:41 -07:00
2013-11-22 20:46:45 -08:00
2011-11-25 17:48:24 +00:00
$this -> api = e107 :: getInstance ();
$this -> addTitle ( LAN_EURL_NAME );
if ( $this -> getAction () != 'settings' ) return ;
2013-11-22 20:46:45 -08:00
}
/**
* Rebuild SEF Urls for a particular table
* @ param $table
* @ param primary field id .
* @ param input field ( title )
* @ param output field ( sef )
*/
2017-04-14 11:55:41 -07:00
private function rebuild ( $table , $primary = '' , $input = '' , $output = '' )
2013-11-22 20:46:45 -08:00
{
if ( empty ( $table ) || empty ( $input ) || empty ( $output ) || empty ( $primary ))
{
e107 :: getMessage () -> addError ( " Missing Generator data " );
return ;
}
$sql = e107 :: getDb ();
$data = $sql -> retrieve ( $table , $primary . " , " . $input , $input . " != '' " , true );
$success = 0 ;
$failed = 0 ;
foreach ( $data as $row )
{
$sef = eHelper :: title2sef ( $row [ $input ]);
if ( $sql -> update ( $table , $output . " = ' " . $sef . " ' WHERE " . $primary . " = " . intval ( $row [ $primary ]) . " LIMIT 1 " ) !== false )
{
$success ++ ;
}
else
{
$failed ++ ;
}
// echo $row[$input]." => ".$output ." = '".$sef."' WHERE ".$primary. " = ".intval($row[$primary]). " LIMIT 1 <br />";
2009-09-25 20:20:23 +00:00
2013-11-22 20:46:45 -08:00
}
if ( $success )
{
2017-04-14 11:55:41 -07:00
e107 :: getMessage () -> addSuccess ( LAN_EURL_TABLE . " : <b> " . $table . " </b><br /> " . $success . LAN_EURL_SURL_UPD );
2013-11-22 20:46:45 -08:00
}
if ( $failed )
{
2017-04-14 11:55:41 -07:00
e107 :: getMessage () -> addError ( LAN_EURL_TABLE . " : <b> " . $table . " </b><br /> " . $failed . LAN_EURL_SURL_NUPD );
2013-11-22 20:46:45 -08:00
}
2011-11-25 17:48:24 +00:00
}
2009-09-25 20:20:23 +00:00
2013-11-22 20:46:45 -08:00
2011-11-25 17:48:24 +00:00
public function HelpObserver ()
{
}
2009-09-25 20:20:23 +00:00
2011-11-25 17:48:24 +00:00
public function HelpPage ()
{
$this -> addTitle ( LAN_EURL_NAME_HELP );
return LAN_EURL_UC ;
}
2015-04-01 02:09:25 -07:00
//TODO Checkbox for each plugin to enable/disable
2016-04-22 16:10:18 -07:00
protected function simplePage ()
2015-02-03 12:23:03 -08:00
{
// $this->addTitle("Simple Redirects");
2017-03-27 10:38:51 -07:00
$eUrl = e107 :: getUrlConfig ();
2015-06-16 15:14:39 -07:00
$frm = e107 :: getForm ();
$tp = e107 :: getParser ();
$cfg = e107 :: getConfig ();
2016-12-06 06:55:47 -08:00
2016-12-05 21:30:54 -08:00
2015-06-16 15:14:39 -07:00
if ( ! empty ( $_POST [ 'saveSimpleSef' ]))
{
2016-12-06 06:55:47 -08:00
/* if ( is_string ( $this -> getConfig () -> get ( 'e_url_alias' )))
2015-06-16 15:14:39 -07:00
{
$cfg -> setPostedData ( 'e_url_alias' , array ( e_LAN => $_POST [ 'e_url_alias' ]), false );
}
else
{
$cfg -> setPref ( 'e_url_alias/' . e_LAN , $_POST [ 'e_url_alias' ]);
2016-12-06 06:55:47 -08:00
} */
foreach ( $_POST [ 'urlstatus' ] as $k => $v )
{
$val = ( ! empty ( $v )) ? $tp -> filter ( $k , 'w' ) : 0 ;
$cfg -> setPref ( 'e_url_list/' . $k , $val );
2015-06-16 15:14:39 -07:00
}
$cfg -> save ( true , true , true );
}
$pref = e107 :: getPref ( 'e_url_alias' );
2016-12-06 06:55:47 -08:00
$sefActive = e107 :: getPref ( 'e_url_list' );
2015-06-16 15:14:39 -07:00
2020-01-27 12:13:02 -08:00
2015-02-03 12:23:03 -08:00
if ( empty ( $eUrl ))
{
2020-01-27 12:13:02 -08:00
e107 :: getMessage () -> addDebug ( " Unable to load e_url configurations. " );
2016-12-06 06:55:47 -08:00
return false ;
2015-02-03 12:23:03 -08:00
}
2015-03-31 07:25:39 -07:00
2015-06-18 18:23:25 -07:00
$text = " <div class='e-container'> " ;
$text .= $frm -> open ( 'simpleSef' );
2015-06-16 15:14:39 -07:00
$multilan = " <small class='e-tip admin-multilanguage-field' style='cursor:help; padding-left:10px' title='Multi-language field'> " . $tp -> toGlyph ( 'fa-language' ) . " </small> " ;
$home = " <small> " . SITEURL . '</small>' ;
2016-12-06 06:55:47 -08:00
// e107::getDebug()->log($sefActive);
2017-02-10 12:39:14 -08:00
$plg = e107 :: getPlug ();
2015-02-03 12:23:03 -08:00
foreach ( $eUrl as $plug => $val )
{
2017-02-10 12:39:14 -08:00
2020-01-27 12:13:02 -08:00
2017-02-10 12:39:14 -08:00
$plg -> load ( $plug );
2016-12-06 06:55:47 -08:00
$active = ! empty ( $sefActive [ $plug ]) ? true : false ;
2016-12-05 21:30:54 -08:00
$text .= " <table class='table table-striped table-bordered' style='margin-bottom:40px'>
< colgroup >
2017-02-10 12:39:14 -08:00
< col style = 'min-width:220px' />
2016-12-05 21:30:54 -08:00
< col style = 'width:45%' />
< col style = 'width:45%' />
</ colgroup > " ;
2016-12-06 06:55:47 -08:00
$name = 'urlstatus[' . $plug . ']' ;
2017-01-28 10:23:53 +01:00
$switch = $frm -> radio_switch ( $name , $active , LAN_ON , LAN_OFF , array (
'switch' => 'mini' ,
));
2017-02-10 12:39:14 -08:00
$text .= " <tr class='active'><td><h4> " . $plg -> getName () . " </h4></td><td colspan='2'> " . $switch . " </td></tr> " ;
2017-02-13 07:47:03 +01:00
$text .= " <tr><th> " . LAN_EURL_KEY . " </th><th> " . LAN_EURL_REGULAR_EXPRESSION . " </th>
2015-06-18 18:23:25 -07:00
2015-06-16 15:14:39 -07:00
2015-02-03 12:23:03 -08:00
< th > " .LAN_URL. " </ th >
</ tr > " ;
foreach ( $val as $k => $v )
{
2015-06-16 15:14:39 -07:00
2020-01-27 12:17:34 -08:00
if ( ! isset ( $v [ 'alias' ]))
{
$v [ 'alias' ] = '' ;
}
if ( ! isset ( $v [ 'regex' ]))
{
$v [ 'regex' ] = '' ;
}
if ( ! isset ( $v [ 'redirect' ]))
{
$v [ 'redirect' ] = '' ;
}
2015-06-18 18:23:25 -07:00
$alias = vartrue ( $pref [ e_LAN ][ $plug ][ $k ], $v [ 'alias' ]);
// $sefurl = (!empty($alias)) ? str_replace('{alias}', $alias, $v['sef']) : $v['sef'];
$pid = $plug . " | " . $k ;
2016-06-25 10:38:05 -07:00
$v [ 'regex' ] = preg_replace ( " /^ \ ^/ " , $home , $v [ 'regex' ]);
$aliasForm = $frm -> renderInline ( 'e_url_alias[' . $plug . '][' . $k . ']' , $pid , 'e_url_alias[' . $plug . '][' . $k . ']' , $alias , $alias , 'text' , null , array ( 'title' => LAN_EDIT . " (Language-specific) " , 'url' => e_REQUEST_SELF ));
2015-06-18 18:23:25 -07:00
$aliasRender = str_replace ( '{alias}' , $aliasForm , $v [ 'regex' ]);
2015-06-16 15:14:39 -07:00
$text .= " <tr>
2016-12-05 21:30:54 -08:00
< td > " . $k . " </ td >
< td > " . $aliasRender . " </ td >
2015-06-18 18:23:25 -07:00
2016-12-05 21:30:54 -08:00
< td > " . $v['redirect'] . " </ td >
2015-06-16 15:14:39 -07:00
</ tr > " ;
2015-02-03 12:23:03 -08:00
}
$text .= " </table> " ;
}
2015-06-16 15:14:39 -07:00
2016-12-06 06:55:47 -08:00
$text .= " <div class='buttons-bar center'> " . $frm -> button ( 'saveSimpleSef' , LAN_SAVE , 'submit' ) . " </div> " ;
2021-09-14 13:28:03 -07:00
$text .= $frm -> token ();
2015-06-16 15:14:39 -07:00
$text .= $frm -> close ();
2021-09-14 13:28:03 -07:00
2015-06-18 18:23:25 -07:00
$text .= " </div> " ;
2015-02-03 12:23:03 -08:00
return $text ;
}
2011-11-25 17:48:24 +00:00
public function SettingsObserver ()
2008-12-02 00:32:30 +00:00
{
2011-12-10 00:00:15 +00:00
// main module pref dropdown
2011-11-25 17:48:24 +00:00
$this -> prefs [ 'url_main_module' ][ 'writeParms' ][ '' ] = 'None' ;
2017-03-27 10:38:51 -07:00
// e_url.php aliases
$tmp = e107 :: getUrlConfig ( 'alias' );
foreach ( $tmp as $plugin => $alias )
{
$this -> prefs [ 'url_main_module' ][ 'writeParms' ][ $alias ] = eHelper :: labelize ( $plugin );
}
// legacy URL (news, pages )
2011-11-25 17:48:24 +00:00
$modules = e107 :: getPref ( 'url_config' , array ());
2017-03-27 10:38:51 -07:00
2011-11-25 17:48:24 +00:00
foreach ( $modules as $module => $location )
{
$labels = array ();
$obj = eDispatcher :: getConfigObject ( $module , $location );
2011-11-30 15:14:02 +00:00
if ( ! $obj ) continue ;
$config = $obj -> config ();
if ( ! $config || ! vartrue ( $config [ 'config' ][ 'allowMain' ])) continue ;
$admin = $obj -> admin ();
$labels = vartrue ( $admin [ 'labels' ], array ());
2017-03-27 10:38:51 -07:00
2020-12-29 08:04:52 -08:00
$this -> prefs [ 'url_main_module' ][ 'writeParms' ][ $module ] = eHelper :: labelize ( $module ); // vartrue($section['name'], eHelper::labelize($module));
2011-11-25 17:48:24 +00:00
}
2017-03-27 10:38:51 -07:00
ksort ( $this -> prefs [ 'url_main_module' ][ 'writeParms' ]);
2011-11-25 17:48:24 +00:00
2011-12-10 00:00:15 +00:00
// title2sef transform type pref
$types = explode ( '|' , 'none|dashl|dashc|dash|underscorel|underscorec|underscore|plusl|plusc|plus' );
$this -> prefs [ 'url_sef_translate' ][ 'writeParms' ] = array ();
foreach ( $types as $type )
{
$this -> prefs [ 'url_sef_translate' ][ 'writeParms' ][ $type ] = deftrue ( 'LAN_EURL_SETTINGS_SEFTRTYPE_' . strtoupper ( $type ), ucfirst ( $type ));
}
2011-11-25 17:48:24 +00:00
if ( isset ( $_POST [ 'etrigger_save' ]))
{
$this -> getConfig ()
2016-12-03 09:24:41 +01:00
-> setPostedData ( $this -> getPosted (), null , false )
2011-11-25 17:48:24 +00:00
//->setPosted('not_existing_pref_test', 1)
-> save ( true );
$this -> getConfig () -> setMessages ();
}
2008-12-02 00:32:30 +00:00
}
2011-11-25 17:48:24 +00:00
2016-04-22 16:10:18 -07:00
protected function SettingsPage ()
2008-12-02 00:40:28 +00:00
{
2015-06-26 20:24:53 -07:00
//$this->addTitle(LAN_EURL_NAME_SETTINGS);
2011-11-25 17:48:24 +00:00
return $this -> getUI () -> urlSettings ();
}
public function AliasObserver ()
{
if ( isset ( $_POST [ 'update' ]))
{
$posted = is_array ( $_POST [ 'eurl_aliases' ]) ? e107 :: getParser () -> post_toForm ( $_POST [ 'eurl_aliases' ]) : '' ;
2011-12-10 00:00:15 +00:00
$locations = array_keys ( e107 :: getPref ( 'url_locations' , array ()));
2011-11-25 17:48:24 +00:00
$aliases = array ();
2011-12-10 00:00:15 +00:00
$message = e107 :: getMessage ();
2011-11-25 17:48:24 +00:00
foreach ( $posted as $lan => $als )
{
foreach ( $als as $module => $alias )
{
$alias = trim ( $alias );
$module = trim ( $module );
if ( $module !== $alias )
{
2011-12-10 00:00:15 +00:00
$cindex = array_search ( $module , $locations );
$sarray = $locations ;
unset ( $sarray [ $cindex ]);
if ( ! in_array ( strtolower ( $alias ), $sarray )) $aliases [ $lan ][ $alias ] = $module ;
else $message -> addError ( sprintf ( LAN_EURL_ERR_ALIAS_MODULE , $alias , $module ));
2011-11-25 17:48:24 +00:00
}
}
}
e107 :: getConfig () -> set ( 'url_aliases' , e107 :: getParser () -> post_toForm ( $aliases )) -> save ( false );
}
}
2016-04-22 16:10:18 -07:00
protected function AliasPage ()
2011-11-25 17:48:24 +00:00
{
2015-06-26 20:24:53 -07:00
// $this->addTitle(LAN_EURL_NAME_ALIASES);
2011-06-08 03:18:50 +00:00
2011-11-25 17:48:24 +00:00
$aliases = e107 :: getPref ( 'url_aliases' , array ());
$form = $this -> getUI ();
2008-12-20 12:30:18 +00:00
$text = "
2011-11-25 17:48:24 +00:00
< form action = '".e_SELF."?mode=main&action=alias' method = 'post' id = 'urlconfig-form' >
2008-12-20 12:30:18 +00:00
< fieldset id = 'core-eurl-core' >
2011-11-25 17:48:24 +00:00
< legend > " .LAN_EURL_LEGEND_ALIASES. " </ legend >
2012-11-26 14:41:32 -08:00
< table class = 'table adminlist' >
2012-05-13 05:50:32 +00:00
< colgroup >
2008-12-20 12:30:18 +00:00
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tbody >
2008-12-02 11:03:02 +00:00
" ;
2011-11-25 17:48:24 +00:00
$text .= $this -> renderAliases ( $aliases );
2008-12-02 00:32:30 +00:00
$text .= "
2008-12-20 12:30:18 +00:00
</ tbody >
</ table >
2011-11-25 17:48:24 +00:00
< div class = 'buttons-bar center' >
2021-09-14 13:28:03 -07:00
" . $form->admin_button ('update', LAN_UPDATE, 'update').
$form -> token () . "
2011-11-25 17:48:24 +00:00
</ div >
2008-12-20 12:30:18 +00:00
</ fieldset >
2011-11-25 17:48:24 +00:00
</ form >
" ;
return $text ;
}
public function ConfigObserver ()
{
2017-04-14 11:55:41 -07:00
if ( ! empty ( $_POST [ 'generate' ]))
{
$gen = e107 :: getUrlConfig ( 'generate' );
$id = key ( $_POST [ 'generate' ]);
if ( empty ( $gen [ $id ]))
{
e107 :: getMessage () -> addDebug ( " Empty " );
return null ;
}
foreach ( $gen [ $id ] as $conf )
{
$this -> rebuild ( $conf [ 'table' ], $conf [ 'primary' ], $conf [ 'input' ], $conf [ 'output' ]);
}
}
2017-09-25 16:23:28 -07:00
2017-04-14 11:55:41 -07:00
2011-11-25 17:48:24 +00:00
if ( isset ( $_POST [ 'update' ]))
{
$config = is_array ( $_POST [ 'eurl_config' ]) ? e107 :: getParser () -> post_toForm ( $_POST [ 'eurl_config' ]) : '' ;
$modules = eRouter :: adminReadModules ();
$locations = eRouter :: adminBuildLocations ( $modules );
$aliases = eRouter :: adminSyncAliases ( e107 :: getPref ( 'url_aliases' ), $config );
2017-04-10 13:28:06 -07:00
if ( ! empty ( $_POST [ 'eurl_profile' ]))
{
e107 :: getConfig () -> set ( 'url_profiles' , $_POST [ 'eurl_profile' ]);
2017-04-27 15:21:20 -07:00
// unset($locations['download']);
// unset($config['download']);
2017-04-10 13:28:06 -07:00
}
2011-11-25 17:48:24 +00:00
e107 :: getConfig ()
-> set ( 'url_aliases' , $aliases )
-> set ( 'url_config' , $config )
-> set ( 'url_modules' , $modules )
-> set ( 'url_locations' , $locations )
-> save ();
2017-04-10 13:28:06 -07:00
2017-10-10 16:14:56 -07:00
if ( ! empty ( $_POST [ 'eurl_config' ][ 'gallery' ])) // disabled, so disable e_url on index also.
{
$val = ( $_POST [ 'eurl_config' ][ 'gallery' ] === 'plugin' ) ? 0 : 'gallery' ;
e107 :: getConfig () -> setPref ( 'e_url_list/gallery' , $val ) -> save ( false , true , false );
}
if ( ! empty ( $_POST [ 'eurl_config' ][ 'news' ])) // disabled, so disable e_url on index also.
{
$val = ( $_POST [ 'eurl_config' ][ 'news' ] === 'core' ) ? 0 : 'news' ;
e107 :: getConfig () -> setPref ( 'e_url_list/news' , $val ) -> save ( false , true , false );
}
// var_dump($_POST['eurl_config']);
2011-11-25 17:48:24 +00:00
eRouter :: clearCache ();
2017-09-25 16:08:40 -07:00
e107 :: getCache () -> clearAll ( 'content' ); // clear content - it may be using old url scheme.
2011-11-25 17:48:24 +00:00
}
}
2016-04-22 16:10:18 -07:00
protected function ConfigPage ()
2011-11-25 17:48:24 +00:00
{
2015-06-26 20:24:53 -07:00
// $this->addTitle(LAN_EURL_NAME_CONFIG);
2011-11-25 17:48:24 +00:00
$active = e107 :: getPref ( 'url_config' );
2011-12-10 00:00:15 +00:00
2011-11-25 17:48:24 +00:00
$set = array ();
// all available URL modules
$set [ 'url_modules' ] = eRouter :: adminReadModules ();
// set by user URL config locations
$set [ 'url_config' ] = eRouter :: adminBuildConfig ( $active , $set [ 'url_modules' ]);
// all available URL config locations
$set [ 'url_locations' ] = eRouter :: adminBuildLocations ( $set [ 'url_modules' ]);
$form = $this -> getUI ();
$text = "
< form action = '".e_SELF."?mode=main&action=config' method = 'post' id = 'urlconfig-form' >
< fieldset id = 'core-eurl-core' >
< legend > " .LAN_EURL_LEGEND_CONFIG. " </ legend >
2012-11-26 14:41:32 -08:00
< table class = 'table adminlist' >
2012-05-13 05:50:32 +00:00
< colgroup >
2013-11-22 20:46:45 -08:00
< col class = 'col-label' style = 'width:20%' />
< col class = 'col-control' style = 'width:60%' />
< col style = 'width:20%' />
2008-12-20 12:30:18 +00:00
</ colgroup >
2013-02-26 01:30:13 -08:00
< thead >
< tr >
< th > " .LAN_TYPE. " </ th >
< th > " .LAN_URL. " </ th >
2013-11-22 20:46:45 -08:00
< th > " .LAN_OPTIONS. " </ th >
2013-02-26 01:30:13 -08:00
</ tr >
</ thead >
2008-12-20 12:30:18 +00:00
< tbody >
" ;
2017-04-10 13:28:06 -07:00
$text .= $this -> renderProfiles ();
2011-11-25 17:48:24 +00:00
$text .= $this -> renderConfig ( $set [ 'url_config' ], $set [ 'url_locations' ]);
2008-12-02 00:32:30 +00:00
$text .= "
2008-12-20 12:30:18 +00:00
</ tbody >
</ table >
< div class = 'buttons-bar center' >
2021-09-14 13:28:03 -07:00
" . $form->admin_button ('update', LAN_UPDATE, 'update').
$form -> token () . "
2008-12-20 12:30:18 +00:00
</ div >
</ fieldset >
</ form >
" ;
2011-11-25 17:48:24 +00:00
return $text ;
}
2008-12-02 11:03:02 +00:00
2017-04-10 13:28:06 -07:00
/**
* New in v2 . 1.6
*/
private function renderProfiles ()
{
$PLUGINS_DIRECTORY = e107 :: getFolder ( " PLUGINS " );
$srch = array ( " { SITEURL} " , " { e_PLUGIN_ABS} " );
$repl = array ( SITEURL , SITEURL . $PLUGINS_DIRECTORY );
$profiles = e107 :: getUrlConfig ( 'profiles' );
2017-04-14 11:55:41 -07:00
$generate = e107 :: getUrlConfig ( 'generate' );
2017-04-10 13:28:06 -07:00
$form = $this -> getUI ();
$text = '' ;
$active = e107 :: getPref ( 'url_profiles' );
foreach ( $profiles as $plug => $prof )
{
$arr = array ();
foreach ( $prof as $id => $val )
{
$arr [ $id ] = $val [ 'label' ] . " : " . str_replace ( $srch , $repl , $val [ 'examples' ][ 0 ]);
}
$sel = $active [ $plug ];
$selector = $form -> select ( 'eurl_profile[' . $plug . ']' , $arr , $sel , array ( 'size' => 'block-level' ));
2017-04-12 15:52:43 -07:00
$label = e107 :: getPlugLan ( $plug , 'name' );
2017-04-14 11:55:41 -07:00
$text .= " <tr><td> " . $label . " </td><td> " . $selector . " </td><td> " ;
$text .= ( ! empty ( $generate [ $plug ])) ? $form -> admin_button ( 'generate[' . $plug . ']' , $plug , 'delete' , LAN_EURL_REBUILD ) : " " ;
$text .= " </td></tr> " ;
2017-04-10 13:28:06 -07:00
}
return $text ;
}
2011-11-25 17:48:24 +00:00
public function renderConfig ( $current , $locations )
{
$ret = array ();
$url = e107 :: getUrl ();
2016-02-05 19:05:55 -08:00
2011-11-25 17:48:24 +00:00
ksort ( $locations );
2016-02-05 19:05:55 -08:00
unset ( $locations [ 'forum' ], $locations [ 'faqs' ], $locations [ 'pm' ]); // using new system so hide from here.
2011-11-25 17:48:24 +00:00
foreach ( $locations as $module => $l )
{
$data = new e_vars ( array (
'current' => $current ,
));
$obj = eDispatcher :: getConfigObject ( $module , $l [ 0 ]);
if ( null === $obj ) $obj = new eurlAdminEmptyConfig ;
$data -> module = $module ;
$data -> locations = $l ;
$data -> defaultLocation = $l [ 0 ];
$data -> config = $obj ;
2016-02-05 19:05:55 -08:00
2011-11-25 17:48:24 +00:00
$ret [] = $data ;
}
2016-02-05 19:05:55 -08:00
2011-11-25 17:48:24 +00:00
return $this -> getUI () -> moduleRows ( $ret );
2008-12-02 00:32:30 +00:00
}
2011-11-25 17:48:24 +00:00
2008-12-02 00:32:30 +00:00
2011-11-25 17:48:24 +00:00
public function renderAliases ( $aliases )
2008-12-02 00:40:28 +00:00
{
2008-12-02 11:03:02 +00:00
2011-11-25 17:48:24 +00:00
$ret = array ();
$lans = array ();
$lng = e107 :: getLanguage ();
$lanList = $lng -> installed ();
sort ( $lanList );
$lanDef = e107 :: getPref ( 'sitelanguage' ) ? e107 :: getPref ( 'sitelanguage' ) : e_LANGUAGE ;
$lanDef = array ( $lng -> convert ( $lanDef ), $lanDef );
foreach ( $lanList as $index => $lan )
2008-12-02 00:40:28 +00:00
{
2011-11-25 17:48:24 +00:00
$lanCode = $lng -> convert ( $lan );
if ( $lanDef [ 0 ] == $lanCode ) continue ;
$lans [ $lanCode ] = $lan ;
}
$modules = e107 :: getPref ( 'url_config' );
if ( ! $modules )
2008-12-02 00:40:28 +00:00
{
2011-11-25 17:48:24 +00:00
$modules = array ();
e107 :: getConfig () -> set ( 'url_aliases' , array ()) -> save ( false );
// do not output message
e107 :: getMessage () -> reset ( false , 'default' );
2008-12-02 00:32:30 +00:00
}
2011-11-25 17:48:24 +00:00
foreach ( $modules as $module => $location )
2008-12-02 00:40:28 +00:00
{
2011-11-25 17:48:24 +00:00
$data = new e_vars ();
$obj = eDispatcher :: getConfigObject ( $module , $location );
if ( null === $obj ) $obj = new eurlAdminEmptyConfig ;
$data -> module = $module ;
$data -> location = $location ;
$data -> config = $obj ;
$modules [ $module ] = $data ;
2008-12-02 00:32:30 +00:00
}
2011-11-25 17:48:24 +00:00
return $this -> getUI () -> aliasesRows ( $aliases , $modules , $lanDef , $lans );
2008-12-02 00:32:30 +00:00
}
2011-11-25 17:48:24 +00:00
/**
* Set extended ( UI ) Form instance
2020-12-18 19:55:12 -08:00
* @ return eurl_admin_ui
2011-11-25 17:48:24 +00:00
*/
public function _setUI ()
2008-12-02 00:32:30 +00:00
{
2011-11-25 17:48:24 +00:00
$this -> _ui = $this -> getParam ( 'ui' );
$this -> setParam ( 'ui' , null );
return $this ;
2008-12-02 00:32:30 +00:00
}
2011-11-25 17:48:24 +00:00
/**
* Set Config object
2020-12-18 19:55:12 -08:00
* @ return eurl_admin_ui
2011-11-25 17:48:24 +00:00
*/
protected function _setConfig ()
2008-12-02 00:32:30 +00:00
{
2011-11-25 17:48:24 +00:00
$this -> _pref = e107 :: getConfig ();
2008-12-02 11:03:02 +00:00
2011-11-25 17:48:24 +00:00
$dataFields = $validateRules = array ();
foreach ( $this -> prefs as $key => $att )
2008-12-02 00:32:30 +00:00
{
2011-11-25 17:48:24 +00:00
// create dataFields array
$dataFields [ $key ] = vartrue ( $att [ 'data' ], 'string' );
// create validation array
if ( vartrue ( $att [ 'validate' ]))
2008-12-02 00:32:30 +00:00
{
2011-11-25 17:48:24 +00:00
$validateRules [ $key ] = array (( true === $att [ 'validate' ] ? 'required' : $att [ 'validate' ]), varset ( $att [ 'rule' ]), $att [ 'title' ], varset ( $att [ 'error' ], $att [ 'help' ]));
2008-12-02 00:32:30 +00:00
}
2011-11-25 17:48:24 +00:00
/* Not implemented in e_model yet
elseif ( vartrue ( $att [ 'check' ]))
{
$validateRules [ $key ] = array ( $att [ 'check' ], varset ( $att [ 'rule' ]), $att [ 'title' ], varset ( $att [ 'error' ], $att [ 'help' ]));
} */
2008-12-02 00:32:30 +00:00
}
2011-11-25 17:48:24 +00:00
$this -> _pref -> setDataFields ( $dataFields ) -> setValidationRules ( $validateRules );
2008-12-02 00:32:30 +00:00
2011-11-25 17:48:24 +00:00
return $this ;
}
}
2008-12-02 11:03:02 +00:00
2011-11-25 17:48:24 +00:00
class eurl_admin_form_ui extends e_admin_form_ui
{
public function urlSettings ()
{
return $this -> getSettings ();
}
2013-02-26 01:30:13 -08:00
public function moreInfo ( $title , $info )
{
$tp = e107 :: getParser ();
$id = 'eurl_' . $this -> name2id ( $title );
2021-01-26 15:08:58 -08:00
$text = " <a data-toggle='modal' data-bs-toggle='modal' href='# " . $id . " ' data-cache='false' data-target='# " . $id . " ' class='e-tip' title=' " . LAN_MOREINFO . " '> " ;
2013-02-26 01:30:13 -08:00
$text .= $title ;
$text .= '</a>' ;
$text .= '
2017-04-10 13:28:06 -07:00
< div id = " '. $id .' " class = " modal fade " tabindex = " -1 " role = " dialog " aria - hidden = " true " >
< div class = " modal-dialog modal-lg " >
< div class = " modal-content " >
< div class = " modal-header " >
< button type = " button " class = " close " data - dismiss = " modal " aria - hidden = " true " >& times ; </ button >
2019-02-26 12:22:36 -08:00
< h4 > '.$tp->toHTML($title,false,' TITLE ').' </ h4 >
2017-04-10 13:28:06 -07:00
</ div >
< div class = " modal-body " >
< p > ' ;
2013-02-26 01:30:13 -08:00
$text .= $info ;
$text .= ' </ p >
</ div >
< div class = " modal-footer " >
2017-02-13 07:47:03 +01:00
< a href = " # " data - dismiss = " modal " class = " btn btn-primary " > '.LAN_CLOSE.' </ a >
2013-02-26 01:30:13 -08:00
</ div >
2017-04-10 13:28:06 -07:00
</ div >
</ div ></ div > ' ;
2013-02-26 01:30:13 -08:00
return $text ;
}
2011-11-25 17:48:24 +00:00
public function moduleRows ( $data )
{
$text = '' ;
$tp = e107 :: getParser ();
2013-11-22 20:46:45 -08:00
$frm = e107 :: getForm ();
2016-02-05 19:05:55 -08:00
2011-11-25 17:48:24 +00:00
if ( empty ( $data ))
{
return "
< tr >
< td colspan = '2' > " .LAN_EURL_EMPTY. " </ td >
</ tr >
" ;
}
2013-02-26 01:30:13 -08:00
$PLUGINS_DIRECTORY = e107 :: getFolder ( " PLUGINS " );
$srch = array ( " { SITEURL} " , " { e_PLUGIN_ABS} " );
$repl = array ( SITEURL , SITEURL . $PLUGINS_DIRECTORY );
2017-04-10 13:28:06 -07:00
2013-02-26 01:30:13 -08:00
2011-11-25 17:48:24 +00:00
foreach ( $data as $obj )
2008-12-02 00:32:30 +00:00
{
2013-11-22 20:46:45 -08:00
$admin = $obj -> config -> admin ();
$section = vartrue ( $admin [ 'labels' ], array ());
$rowspan = count ( $obj -> locations ) + 1 ;
$module = $obj -> module ;
$generate = vartrue ( $admin [ 'generate' ], array ());
2013-02-26 01:30:13 -08:00
/*
$info .= "
< tr >
< td rowspan = '$rowspan' >< a class = 'e-tip' style = 'display:block' title = '".LAN_EURL_LOCATION.$path."' >
" .vartrue( $section['name'] , eHelper::labelize( $obj->module )). "
</ a ></ td >
</ tr >
" ;
*/
$opt = " " ;
$info = " <table class='table table-striped'> " ;
2017-04-10 13:28:06 -07:00
2013-02-26 01:30:13 -08:00
2011-11-25 17:48:24 +00:00
foreach ( $obj -> locations as $index => $location )
{
$objSub = $obj -> defaultLocation != $location ? eDispatcher :: getConfigObject ( $obj -> module , $location ) : false ;
if ( $objSub )
{
$admin = $objSub -> admin ();
$section = vartrue ( $admin [ 'labels' ], array ());
}
elseif ( $obj -> defaultLocation != $location ) $section = array ();
$id = 'eurl-' . str_replace ( '_' , '-' , $obj -> module ) . '-' . $index ;
2013-02-26 01:30:13 -08:00
2021-01-16 13:32:35 -08:00
$checked = ( isset ( $obj -> current [ $module ]) && $obj -> current [ $module ] == $location ) ? ' checked="checked"' : '' ;
2011-11-25 17:48:24 +00:00
$path = eDispatcher :: getConfigPath ( $module , $location , false );
2013-02-26 01:30:13 -08:00
if ( ! is_readable ( $path ))
{
$path = str_replace ( '/url.php' , '/' , $tp -> replaceConstants ( eDispatcher :: getConfigPath ( $module , $location , true ), true )) . ' <em>(' . LAN_EURL_LOCATION_NONE . ')</em>' ;
$diz = LAN_EURL_DEFAULT ;
}
else
{
$path = $tp -> replaceConstants ( eDispatcher :: getConfigPath ( $module , $location , true ), true );
$diz = ( basename ( $path ) != 'url.php' ) ? LAN_EURL_FRIENDLY : LAN_EURL_DEFAULT ;
}
2011-11-25 17:48:24 +00:00
$label = vartrue ( $section [ 'label' ], $index == 0 ? LAN_EURL_DEFAULT : eHelper :: labelize ( ltrim ( strstr ( $location , '/' ), '/' )));
2020-12-20 19:42:09 -08:00
// $cssClass = $checked ? 'e-showme' : 'e-hideme';
2011-12-05 15:44:16 +00:00
$cssClass = 'e-hideme' ; // always hidden for now, some interface changes could come after pre-alpha
2013-02-26 01:30:13 -08:00
$exampleUrl = array ();
2015-04-10 18:58:13 -07:00
if ( ! empty ( $section [ 'examples' ]))
{
foreach ( $section [ 'examples' ] as $ex )
{
$exampleUrl [] = str_replace ( $srch , $repl , $ex );
}
}
2020-12-18 19:55:12 -08:00
/*
2013-02-26 01:30:13 -08:00
if ( strpos ( $path , 'noid' ) !== false )
{
2020-12-18 19:55:12 -08:00
$exampleUrl .= " ‡ " ; //XXX Add footer - denotes more CPU required. ?
2013-02-26 01:30:13 -08:00
}
2020-12-18 19:55:12 -08:00
*/
2021-01-16 13:32:35 -08:00
$selected = ( isset ( $obj -> current [ $module ]) && ( $obj -> current [ $module ] == $location )) ? " selected='selected' " : '' ;
2020-12-29 08:04:52 -08:00
$opt .= " <option value=' { $location } ' { $selected } > " . $diz . " : " . varset ( $exampleUrl [ 0 ]) . " </option> " ;
2013-11-22 20:46:45 -08:00
2013-02-26 01:30:13 -08:00
$info .= " <tr><td> " . $label . "
</ td >
2013-03-21 13:39:11 +01:00
< td >< strong > " .LAN_EURL_LOCATION. " </ strong >: " . $path . "
2013-11-22 20:46:45 -08:00
< p > " .vartrue( $section['description'] , LAN_EURL_PROFILE_INFO). " </ p >< small > " .implode( " < br /> " , $exampleUrl ). " </ small ></ td >
</ tr >
2008-12-02 00:32:30 +00:00
" ;
2013-02-26 01:30:13 -08:00
2008-12-02 00:32:30 +00:00
}
2013-11-22 20:46:45 -08:00
2013-02-26 01:30:13 -08:00
$info .= " </table> " ;
2013-11-22 20:46:45 -08:00
$title = vartrue ( $section [ 'name' ], eHelper :: labelize ( $obj -> module ));
2017-04-10 13:28:06 -07:00
2013-02-26 01:30:13 -08:00
2013-11-22 20:46:45 -08:00
$text .= "
2013-02-26 01:30:13 -08:00
< tr >
< td > " . $this->moreInfo ( $title , $info ). " </ td >
2017-01-31 16:39:00 -08:00
< td >< select name = 'eurl_config[$module]' class = 'form-control input-block-level' > " . $opt . " </ select ></ td >
2013-11-22 20:46:45 -08:00
< td > " ;
2020-12-29 08:04:52 -08:00
$bTable = varset ( $admin [ 'generate' ][ 'table' ]);
$bInput = varset ( $admin [ 'generate' ][ 'input' ]);
$bOutput = varset ( $admin [ 'generate' ][ 'output' ]);
$bPrimary = varset ( $admin [ 'generate' ][ 'primary' ]);
2013-11-22 20:46:45 -08:00
2016-01-30 16:58:58 +01:00
$text .= ( is_array ( $admin [ 'generate' ])) ? $frm -> admin_button ( 'rebuild[' . $bTable . ']' , $bPrimary . " :: " . $bInput . " :: " . $bOutput , 'delete' , LAN_EURL_REBUILD ) : " " ;
2013-11-22 20:46:45 -08:00
$text .= " </td>
2013-02-26 01:30:13 -08:00
</ tr > " ;
2008-12-02 12:27:10 +00:00
}
2011-12-02 21:34:36 +00:00
2013-02-26 01:30:13 -08:00
2011-12-02 21:34:36 +00:00
/*
For Miro - intuitive interface example . All configs are contained within one e_url . php file .
Root namespacing automatically calculated based on selection .
ie . choosing option 1 below will set root namespacing for news .
Known bug ( example ) :
News title : Nothing ' s Gonna Change my World !
Currently becomes : / Nothing % 26 % 23039 % 3 Bs % 20 Gonna % 20 Change % 20 my % 20 World % 21
Should become : / nothings - gonna - change - my - world
Good SEF reference : http :// davidwalsh . name / generate - search - engine - friendly - urls - php - function
2011-12-05 15:44:16 +00:00
[ Miro ] Solution comes from the module itself , not related with URL assembling in anyway ( as per latest Skype discussion )
2011-12-02 21:34:36 +00:00
*/
2015-02-16 02:22:47 -08:00
2011-12-02 21:34:36 +00:00
// Global On/Off Switch Example
2011-12-05 15:44:16 +00:00
// [Miro] there is no reason of switch, everything could go through single entry point at any time, without a need of .htaccess (path info)
// Control is coming per configuration file.
2011-12-02 21:34:36 +00:00
$example = "
< tr >< td > Enable Search - Engine - Friendly URLs </ td >
< td >< input type = 'checkbox' name = 'SEF-active' value = '1' />
</ td ></ tr > " ;
//Entry Example (Hidden unless the above global switch is active)
$example .= "
< tr >< td > News </ td >
2011-12-03 22:05:46 +00:00
< td style = 'padding:0px' >
< table style = 'width:600px;margin-left:0px' >
< tr >
< td >< input type = 'radio' class = 'radio' name = 'example' /> Default </ td >< td >/ news . php ? item . 1 </ td >
</ tr >
< tr >
< td >< input type = 'radio' class = 'radio' name = 'example' /> News Namespace and News Title </ td >< td >/ news / news - item - title </ td >
</ tr >
< tr >
< td >< input type = 'radio' class = 'radio' name = 'example' /> Year and News Title </ td >< td >/ 2011 / news - item - title </ td >
</ tr >
< tr >
< td >< input type = 'radio' class = 'radio' name = 'example' /> Year / Month and News Title </ td >< td >/ 2011 / 08 / news - item - title </ td >
</ tr >
< tr >
< td >< input type = 'radio' class = 'radio' name = 'example' /> Year / Month / Day and News Title </ td >< td >/ 2011 / 08 / 27 / news - item - title </ td >
</ tr >
< tr >
< td >< input type = 'radio' class = 'radio' name = 'example' /> News Category and News Title </ td >< td >/ news - category / news - item - title </ td >
</ tr >
" ;
// For 0.8 Beta
$example .= "
< tr >
< td >< input type = 'radio' class = 'radio' name = 'example' /> Custom </ td >< td >< input class = 'tbox' type = 'text' name = 'custom-news' value = '' /></ td >
</ tr > " ;
$example .= " </table> " ;
2011-12-02 21:34:36 +00:00
$example .= " </td>
</ tr > " ;
2011-12-05 15:44:16 +00:00
2011-12-02 21:34:36 +00:00
2011-12-05 15:44:16 +00:00
return $text ;
2011-12-02 21:34:36 +00:00
2008-12-02 00:32:30 +00:00
}
2008-12-02 11:03:02 +00:00
2011-11-25 17:48:24 +00:00
public function aliasesRows ( $currentAliases , $modules , $lanDef , $lans )
2008-12-02 12:27:10 +00:00
{
2011-11-25 17:48:24 +00:00
if ( empty ( $modules ))
{
return "
< tr >
< td colspan = '3' > " .LAN_EURL_EMPTY. " </ td >
</ tr >
" ;
2008-12-02 12:27:10 +00:00
}
2011-11-25 17:48:24 +00:00
$text = '' ;
$tp = e107 :: getParser ();
2015-09-14 12:36:44 -07:00
$text .= " <tr>
< th > Module </ th >
< th ></ th >
< th ></ th >
</ tr > " ;
$lng = e107 :: getLanguage ();
2011-11-25 17:48:24 +00:00
foreach ( $modules as $module => $obj )
2008-12-02 00:32:30 +00:00
{
2011-12-01 22:08:23 +00:00
$cfg = $obj -> config -> config ();
if ( isset ( $cfg [ 'config' ][ 'noSingleEntry' ]) && $cfg [ 'config' ][ 'noSingleEntry' ]) continue ;
if ( $module == 'index' )
{
2015-09-14 12:36:44 -07:00
$text .= "
2011-12-01 22:08:23 +00:00
< tr >
2012-11-26 14:41:32 -08:00
< td >
2011-12-01 22:08:23 +00:00
" .LAN_EURL_CORE_INDEX. "
</ td >
2012-11-26 14:41:32 -08:00
< td >
2015-09-14 12:36:44 -07:00
< table class = 'table table-striped table-bordered' style = 'margin-bottom:0' >
< colgroup >
< col style = 'width:20%' />
< col style = 'width:40%' />
< col style = 'width:40%' />
</ colgroup >
< tr >
< td colspan = '2' >
" .LAN_EURL_CORE_INDEX_INFO. "
</ td >
< td >
" .e107::getUrl()->create('/', '', array('full' => 1)). "
</ tr >
</ table >
2011-12-01 22:08:23 +00:00
</ td >
</ tr >
" ;
continue ;
}
2015-09-14 12:36:44 -07:00
2011-11-25 17:48:24 +00:00
$help = array ();
$admin = $obj -> config -> admin ();
$lan = $lanDef [ 0 ];
2011-12-06 16:01:34 +00:00
$url = e107 :: getUrl () -> create ( $module , '' , array ( 'full' => 1 , 'encode' => 0 ));
2011-11-25 17:48:24 +00:00
$defVal = isset ( $currentAliases [ $lan ]) && in_array ( $module , $currentAliases [ $lan ]) ? array_search ( $module , $currentAliases [ $lan ]) : $module ;
$section = vartrue ( $admin [ 'labels' ], array ());
2011-12-01 22:08:23 +00:00
2011-11-25 17:48:24 +00:00
$text .= "
< tr >
2012-11-26 14:41:32 -08:00
< td >
2011-11-25 17:48:24 +00:00
" .vartrue( $section['name'] , ucfirst(str_replace('_', ' ', $obj->module ))). "
< div class = 'label-note' >
" .LAN_EURL_FORM_HELP_ALIAS_0. " < strong > { $module } </ strong >< br />
</ div >
</ td >
2012-11-26 14:41:32 -08:00
< td >
2011-11-25 17:48:24 +00:00
" ;
2015-09-14 12:36:44 -07:00
2011-11-25 17:48:24 +00:00
2015-09-14 12:36:44 -07:00
// default language
$text .= " <table class='table table-striped table-bordered' style='margin-bottom:0'>
< colgroup >
< col style = 'width:20%' />
< col style = 'width:40%' />
< col style = 'width:40%' />
</ colgroup > " ;
$text .= " <tr>
< th > " .ADLAN_132. " </ th >
< th > " .LAN_EURL_NAME_ALIASES. " </ th >
< th > " .LAN_EURL_FORM_HELP_EXAMPLE. " </ th >
</ tr > " ;
$text .= " <tr> " ;
2021-02-12 12:19:58 -08:00
$text .= " <td> " . $lanDef [ 1 ] . $this -> help ( LAN_EURL_FORM_HELP_DEFAULT ) . " </td> " ;
2015-09-14 12:36:44 -07:00
$text .= " <td class='form-inline'> " ;
$text .= $this -> text ( 'eurl_aliases[' . $lanDef [ 0 ] . '][' . $module . ']' , $defVal , 255 , 'size=xlarge' );
// $text .= ' ['.$lanDef[1].']';
$text .= " </td><td> " ;
$text .= " </td> " ;
// $help[] = '['.$lanDef[1].'] '.LAN_EURL_FORM_HELP_EXAMPLE.':<br /><strong>'.$url.'</strong>';
$text .= " </tr> " ;
if ( e107 :: getUrl () -> router () -> isMainModule ( $module ))
{
$help = " <span class='e-tip e-help' title= \" " . LAN_EURL_CORE_MAIN . " \" > " . $tp -> toGlyph ( 'fa-home' ) . " </span> " ;
//$readonly = 1; // may be used later.
$readonly = 0 ;
}
else
{
$help = '' ;
$readonly = 0 ;
}
2011-11-25 17:48:24 +00:00
if ( $lans )
2008-12-20 12:30:18 +00:00
{
2015-09-14 12:36:44 -07:00
2011-11-25 17:48:24 +00:00
foreach ( $lans as $code => $lan )
{
2011-12-01 22:08:23 +00:00
2011-12-06 16:01:34 +00:00
$url = e107 :: getUrl () -> create ( $module , '' , array ( 'lan' => $code , 'full' => 1 , 'encode' => 0 ));
2015-09-14 12:36:44 -07:00
$defVal = isset ( $currentAliases [ $code ]) && in_array ( $module , $currentAliases [ $code ]) ? array_search ( $module , $currentAliases [ $code ]) : $module ;
// $help .= '['.$lan.'] '.LAN_EURL_FORM_HELP_EXAMPLE.':<br /><strong>'.$url.'</strong>';
$text .= " <tr> " ;
$text .= " <td> " . $lan . " </td> " ;
$text .= " <td class='form-inline'> " . $this -> text ( 'eurl_aliases[' . $code . '][' . $module . ']' , $defVal , 255 , array ( 'size' => 'xlarge' , 'readonly' => $readonly ));
$text .= $help ;
$text .= " </td> " ;
$text .= " <td> " ;
// $text .= $this->help(LAN_EURL_FORM_HELP_ALIAS_1.' <strong>'.$lan.'</strong>');
// $text .= $this->help(LAN_EURL_FORM_HELP_ALIAS_1.' <strong>'.$lan.'</strong>');
$url = $lng -> subdomainUrl ( $lan , $url );
$text .= $url ;
$text .= " </td> " ;
// $text .= "<td>".
// $text .= '['.$lan.'] '.LAN_EURL_FORM_HELP_EXAMPLE.':<br /><strong>'.$url.'</strong>';
// $text .= "</td>";
$text .= " </tr> " ;
2011-11-25 17:48:24 +00:00
}
2015-09-14 12:36:44 -07:00
2008-12-20 12:30:18 +00:00
}
2015-09-14 12:36:44 -07:00
$text .= " </table>
</ td ></ tr > " ;
2011-11-25 17:48:24 +00:00
2015-09-14 12:36:44 -07:00
/* $text .= "
2011-11-25 17:48:24 +00:00
</ td >
2012-11-26 14:41:32 -08:00
< td >
2011-11-25 17:48:24 +00:00
" .implode( " < div class = 'spacer' ><!-- --></ div > " , $help ). "
</ td >
</ tr >
2015-09-14 12:36:44 -07:00
" ;*/
// $text .= "</tr>";
2008-12-02 00:32:30 +00:00
}
2008-12-02 11:03:02 +00:00
2011-11-25 17:48:24 +00:00
return $text ;
2008-12-02 00:32:30 +00:00
}
2011-11-25 17:48:24 +00:00
}
2008-12-02 11:03:02 +00:00
2011-11-25 17:48:24 +00:00
class eurlAdminEmptyConfig extends eUrlConfig
{
public function config ()
2008-12-02 00:32:30 +00:00
{
2011-11-25 17:48:24 +00:00
return array ();
2008-12-02 00:32:30 +00:00
}
}
2011-11-25 17:48:24 +00:00
new eurl_admin ();
2008-12-02 11:03:02 +00:00
2011-11-25 17:48:24 +00:00
require_once ( e_ADMIN . 'auth.php' );
2008-12-02 00:32:30 +00:00
2011-11-25 17:48:24 +00:00
e107 :: getAdminUI () -> runPage ();
require_once ( e_ADMIN . 'footer.php' );
2008-12-02 00:32:30 +00:00
2008-12-02 11:03:02 +00:00