* Mobile: fix redirect loop, if template_set was forced to something else then "pixelegg"

- refactored generation of framework object to egw_framework::factory used now in login.php and egw object
- using now $framework->template_dir for *.tpl files of template-sets
This commit is contained in:
Ralf Becker 2015-05-27 14:01:32 +00:00
parent 82f9190c32
commit 01860bc469
7 changed files with 41 additions and 49 deletions

View File

@ -58,9 +58,6 @@ $GLOBALS['egw_info']['server']['db_persistent'] = {DB_PERSISTENT};
*/
$GLOBALS['egw_info']['server']['session_handler'] = '{SESSION_HANDLER}';
/* Select which login template set you want, most people will use idots */
$GLOBALS['egw_info']['login_template_set'] = 'idots';
/* This is used to control mcrypt's use */
$GLOBALS['egw_info']['server']['mcrypt_enabled'] = {ENABLE_MCRYPT};

View File

@ -110,29 +110,10 @@ else
{
$GLOBALS['egw_info']['server']['template_set'] =
$GLOBALS['egw_info']['login_template_set'] = $prefs->data['common']['template_set'];
$GLOBALS['egw_info']['server']['template_dir'] =
EGW_SERVER_ROOT . '/' . $GLOBALS['egw_info']['login_template_set'].'/templates/'.$GLOBALS['egw_info']['login_template_set'];
}
else
{
$GLOBALS['egw_info']['server']['template_dir'] = EGW_SERVER_ROOT . '/phpgwapi/templates/' . $GLOBALS['egw_info']['login_template_set'];
}
unset($prefs);
unset($prefs); unset($class);
// read the images from the login-template-set, not the (maybe not even set) users template-set
$GLOBALS['egw_info']['user']['preferences']['common']['template_set'] = $GLOBALS['egw_info']['login_template_set'];
$class = $GLOBALS['egw_info']['login_template_set'].'_framework';
if (!class_exists($class))
{
if(!file_exists($framework = $GLOBALS['egw_info']['server']['template_dir'].'/class.'.$class.'.inc.php'))
{
$framework = EGW_SERVER_ROOT . '/phpgwapi/templates/idots/class.'.($class='idots_framework').'.inc.php';
}
require_once($framework);
}
$GLOBALS['egw']->framework = new $class($GLOBALS['egw_info']['login_template_set']);
unset($framework); unset($class);
$GLOBALS['egw']->framework = egw_framework::factory();
// This is used for system downtime, to prevent new logins.
if($GLOBALS['egw_info']['server']['deny_all_logins'])
@ -266,9 +247,8 @@ else
//conference - for strings like vinicius@thyamad.com@default , allows
//that user have a login that is his e-mail. (viniciuscb)
$login_parts = explode('@',$login);
// remove blanks
$login_parts = array_map('trim',$login_parts);
$login_parts = array_map('trim',explode('@',$login));
$login = implode('@',$login_parts);
$got_login = false;

View File

@ -693,26 +693,7 @@ class egw_minimal
switch($name)
{
case 'framework':
// default to idots, if no template_set set, to eg. not stall installations if settings use egw::link
if (empty($GLOBALS['egw_info']['server']['template_set'])) $GLOBALS['egw_info']['server']['template_set'] = 'idots';
// setup the new eGW framework (template sets)
$class = $GLOBALS['egw_info']['server']['template_set'].'_framework';
if (!class_exists($class)) // first try to autoload the class
{
require_once($file=EGW_INCLUDE_ROOT.'/phpgwapi/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/class.'.$class.'.inc.php');
if (!in_array($file,(array)$_SESSION['egw_required_files']))
{
$_SESSION['egw_required_files'][] = $file; // automatic load the used framework class, when the object get's restored
}
}
// fall back to idots if a template does NOT support current user-agent
if ($class != 'idots_framework' && method_exists($class,'is_supported_user_agent') &&
!call_user_func(array($class,'is_supported_user_agent')))
{
$GLOBALS['egw_info']['server']['template_set'] = 'idots';
return $this->__get('framework');
}
break;
return $this->framework = egw_framework::factory();
case 'template': // need to be instancated for the current app
if (!($tpl_dir = common::get_tpl_dir($this->currentapp)))
{

View File

@ -83,6 +83,40 @@ abstract class egw_framework
$this->template_dir = '/phpgwapi/templates/'.$template;
}
/**
* Factory method to instanciate framework object
*
* @return egw_framwork
*/
public static function factory()
{
if ((html::$ua_mobile || $GLOBALS['egw_info']['user']['preferences']['common']['theme'] == 'mobile') &&
file_exists(EGW_SERVER_ROOT.'/pixelegg'))
{
$GLOBALS['egw_info']['server']['template_set'] = 'pixelegg';
}
// default to idots, if no template_set set, to eg. not stall installations if settings use egw::link
if (empty($GLOBALS['egw_info']['server']['template_set'])) $GLOBALS['egw_info']['server']['template_set'] = 'idots';
// setup the new eGW framework (template sets)
$class = $GLOBALS['egw_info']['server']['template_set'].'_framework';
if (!class_exists($class)) // first try to autoload the class
{
require_once($file=EGW_INCLUDE_ROOT.'/phpgwapi/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/class.'.$class.'.inc.php');
if (!in_array($file,(array)$_SESSION['egw_required_files']))
{
$_SESSION['egw_required_files'][] = $file; // automatic load the used framework class, when the object get's restored
}
}
// fall back to idots if a template does NOT support current user-agent
if ($class != 'idots_framework' && method_exists($class,'is_supported_user_agent') &&
!call_user_func(array($class,'is_supported_user_agent')))
{
$GLOBALS['egw_info']['server']['template_set'] = 'idots';
return self::factory();
}
return new $class($GLOBALS['egw_info']['server']['template_set']);
}
/**
* Additional attributes or urls for CSP script-src 'self'
*
@ -546,8 +580,8 @@ abstract class egw_framework
{
self::csp_frame_src_attrs(array()); // array() no external frame-sources
//error_log(__METHOD__."() server[template_dir]=".array2string($GLOBALS['egw_info']['server']['template_dir']).", this->template=$this->template, this->template_dir=$this->template_dir, get_class(this)=".get_class($this));
$tmpl = new Template($GLOBALS['egw_info']['server']['template_dir']);
//error_log(__METHOD__."() this->template=$this->template, this->template_dir=$this->template_dir, get_class(this)=".get_class($this));
$tmpl = new Template(EGW_SERVER_ROOT.$this->template_dir);
$tmpl->set_file(array('login_form' => 'login.tpl'));
@ -700,7 +734,7 @@ abstract class egw_framework
*/
function denylogin_screen()
{
$tmpl = new Template($GLOBALS['egw_info']['server']['template_dir']);
$tmpl = new Template(EGW_SERVER_ROOT.$this->template_dir);
$tmpl->set_file(array(
'login_form' => 'login_denylogin.tpl'