diff --git a/header.inc.php.template b/header.inc.php.template index f3bdb41528..36ceeb440b 100644 --- a/header.inc.php.template +++ b/header.inc.php.template @@ -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}; diff --git a/login.php b/login.php index d9768edb1b..e1934232e4 100755 --- a/login.php +++ b/login.php @@ -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; diff --git a/phpgwapi/inc/class.egw.inc.php b/phpgwapi/inc/class.egw.inc.php index 756325e27c..5b8763c5af 100644 --- a/phpgwapi/inc/class.egw.inc.php +++ b/phpgwapi/inc/class.egw.inc.php @@ -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))) { diff --git a/phpgwapi/inc/class.egw_framework.inc.php b/phpgwapi/inc/class.egw_framework.inc.php index ee7f245865..1bab8d5b60 100644 --- a/phpgwapi/inc/class.egw_framework.inc.php +++ b/phpgwapi/inc/class.egw_framework.inc.php @@ -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' diff --git a/pixelegg/templates/pixelegg/head.tpl b/pixelegg/head.tpl similarity index 100% rename from pixelegg/templates/pixelegg/head.tpl rename to pixelegg/head.tpl diff --git a/pixelegg/templates/pixelegg/head_mobile.tpl b/pixelegg/head_mobile.tpl similarity index 100% rename from pixelegg/templates/pixelegg/head_mobile.tpl rename to pixelegg/head_mobile.tpl diff --git a/pixelegg/templates/pixelegg/login.tpl b/pixelegg/login.tpl similarity index 100% rename from pixelegg/templates/pixelegg/login.tpl rename to pixelegg/login.tpl