* 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:
Hadi Nategh 2015-06-02 09:15:57 +00:00
commit b17616348a
9 changed files with 44 additions and 59 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

@ -263,16 +263,9 @@ div .egw_fw_ui_sidemenu_entry_content > div {
// the instanciation of the template has to be here and not in the constructor,
// as the old Template class has problems if restored from the session (php-restore)
// todo: check if this is still true
$this->tpl = new Template(common::get_tpl_dir(static::APP));
$this->tpl = new Template(EGW_SERVER_ROOT.$this->template_dir);
if (html::$ua_mobile || $GLOBALS['egw_info']['user']['preferences']['common']['theme'] == 'mobile')
{
// if we are not on pixelegg template, switch to it for this session
// otherwise we get an error: template head_mobile.tpl not found!
if (static::APP != 'pixelegg')
{
$GLOBALS['egw']->preferences->add('common', 'template_set', 'pixelegg', 'session');
egw::redirect_link('/index.php');
}
$this->tpl->set_file(array('_head' => 'head_mobile.tpl'));
}
else
@ -375,7 +368,7 @@ div .egw_fw_ui_sidemenu_entry_content > div {
//Print button title
$this->tpl->set_var('title_print', lang("Print current view"));
}
// add framework div's
$this->tpl->set_var($this->_get_footer());
$content .= $this->tpl->fp('out','framework');
@ -447,7 +440,7 @@ div .egw_fw_ui_sidemenu_entry_content > div {
case 'logout':
if (html::$ua_mobile || $GLOBALS['egw_info']['user']['preferences']['common']['theme'] == 'mobile')
{
}
else
{

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'