コード例 #1
0
ファイル: OcSmarty.class.php プロジェクト: 4Vs/oc-server3
 function display($dummy1 = null, $dummy2 = null, $dummy3 = null)
 {
     global $opt, $db, $cookie, $login, $menu, $sqldebugger, $translate;
     global $useragent_msie;
     $cookie->close();
     // if the user is an admin, dont cache the content
     if (isset($login)) {
         if ($login->admin) {
             $this->caching = false;
         }
     }
     //Give Smarty access to the whole options array.
     $this->assign('siteSettings', $opt);
     //Should we remove this whole block since we now have
     //access using the siteSettings above?
     // assign main template vars
     // ... and some of the $opt
     $locale = $opt['template']['locale'];
     $optn['debug'] = $opt['debug'];
     $optn['template']['locales'] = $opt['template']['locales'];
     $optn['template']['locale'] = $opt['template']['locale'];
     $optn['template']['style'] = $opt['template']['style'];
     $optn['template']['country'] = $login->getUserCountry();
     $optn['page']['subtitle1'] = isset($opt['locale'][$locale]['page']['subtitle1']) ? $opt['locale'][$locale]['page']['subtitle1'] : $opt['page']['subtitle1'];
     $optn['page']['subtitle2'] = isset($opt['locale'][$locale]['page']['subtitle2']) ? $opt['locale'][$locale]['page']['subtitle2'] : $opt['page']['subtitle2'];
     $optn['page']['headimagepath'] = $opt['page']['headimagepath'];
     $optn['page']['headoverlay'] = $opt['page']['headoverlay'];
     $optn['page']['max_logins_per_hour'] = $opt['page']['max_logins_per_hour'];
     $optn['page']['absolute_url'] = $opt['page']['absolute_url'];
     $optn['page']['absolute_urlpath'] = parse_url($opt['page']['absolute_url'], PHP_URL_PATH);
     $optn['page']['target'] = $this->target;
     $optn['page']['showdonations'] = $opt['page']['showdonations'];
     $optn['page']['title'] = $opt['page']['title'];
     $optn['page']['nowpsearch'] = $this->nowpsearch;
     $optn['page']['header_javascript'] = $this->header_javascript;
     $optn['page']['body_load'] = $this->body_load;
     $optn['page']['body_unload'] = $this->body_unload;
     $optn['page']['sponsor'] = $opt['page']['sponsor'];
     $optn['page']['showsocialmedia'] = $opt['page']['showsocialmedia'];
     $optn['template']['title'] = $this->title;
     $optn['template']['caching'] = $this->caching;
     $optn['template']['popup'] = $this->popup;
     $optn['template']['popupmargin'] = $this->popupmargin;
     $optn['format'] = $opt['locale'][$opt['template']['locale']]['format'];
     $optn['mail'] = $opt['mail'];
     $optn['lib'] = $opt['lib'];
     $optn['cms'] = $opt['cms'];
     $optn['geokrety'] = $opt['geokrety'];
     $optn['template']['usercountrieslist'] = labels::getLabels('usercountrieslist');
     $optn['help']['oconly'] = helppagelink('oconly', 'OConly');
     $optn['msie'] = $useragent_msie;
     // url-sessions? (for session timout display)
     $optn['session']['url'] = false;
     if ($opt['session']['mode'] == SAVE_SESSION && $login->userid != 0) {
         if (isset($_GET['SESSION']) || isset($_POST['SESSION'])) {
             $optn['session']['url'] = true;
         }
         $optn['session']['id'] = session_id();
     }
     if (isset($login)) {
         $loginn['username'] = $login->username;
         $loginn['userid'] = $login->userid;
         $loginn['admin'] = $login->admin;
     } else {
         $loginn['username'] = '';
         $loginn['userid'] = '';
         $loginn['admin'] = '';
     }
     // build menu
     if ($this->menuitem == null) {
         $menu->SetSelectItem(MNU_ROOT);
     } else {
         $menu->SetSelectItem($this->menuitem);
     }
     $this->assign('topmenu', $menu->getTopMenu());
     $this->assign('submenu', $menu->getSubMenu());
     $this->assign('breadcrumb', $menu->getBreadcrumb());
     $this->assign('menucolor', $menu->getMenuColor());
     $this->assign('helplink', helppagelink($this->name));
     $this->assign('greybg', !$this->caching && $loginn['username'] == 'HWR-Info');
     if ($this->title == '') {
         $optn['template']['title'] = $menu->GetMenuTitle();
     }
     // build address for switching locales
     $locale_pageadr = $_SERVER['REQUEST_URI'];
     // workaround for http://redmine.opencaching.de/issues/703
     $strange_things_pos = strpos($locale_pageadr, ".php/");
     if ($strange_things_pos) {
         $locale_pageadr = substr($locale_pageadr, 0, $strange_things_pos + 4);
     }
     $lpos = strpos($locale_pageadr, "locale=");
     if ($lpos) {
         $locale_pageadr = substr($locale_pageadr, 0, $lpos);
     } else {
         $urx = explode('#', $locale_pageadr);
         $locale_pageadr = $urx[0];
         if (strpos($locale_pageadr, '?') == 0) {
             $locale_pageadr .= '?';
         } else {
             $locale_pageadr .= '&';
         }
     }
     $this->assign('locale_pageadr', $locale_pageadr);
     if ($opt['logic']['license']['disclaimer']) {
         if (isset($opt['locale'][$locale]['page']['license_url'])) {
             $lurl = $opt['locale'][$locale]['page']['license_url'];
         } else {
             $lurl = $opt['locale']['EN']['page']['license_url'];
         }
         if (isset($opt['locale'][$locale]['page']['license'])) {
             $ltext = $opt['locale'][$locale]['page']['license'];
         } else {
             $ltext = $opt['locale']['EN']['page']['license'];
         }
         $this->assign('license_disclaimer', mb_ereg_replace('%1', $lurl, $ltext));
     } else {
         $this->assign('license_disclaimer', '');
     }
     $this->assign('opt', $optn);
     $this->assign('login', $loginn);
     if ($db['connected'] == true) {
         $this->assign('sys_dbconnected', true);
     } else {
         $this->assign('sys_dbconnected', false);
     }
     $this->assign('sys_dbslave', $db['slave_id'] != -1);
     if ($this->template_exists($this->name . '.tpl')) {
         $this->assign('template', $this->name);
     } else {
         if ($this->name != 'sys_error') {
             $this->error(ERROR_TEMPLATE_NOT_FOUND);
         }
     }
     $this->bench->stop();
     $this->assign('sys_runtime', $this->bench->diff());
     $this->assign('screen_css_time', filemtime($opt['rootpath'] . "resource2/" . $opt['template']['style'] . "/css/style_screen.css"));
     $this->assign('screen_msie_css_time', filemtime($opt['rootpath'] . "resource2/" . $opt['template']['style'] . "/css/style_screen_msie.css"));
     $this->assign('print_css_time', filemtime($opt['rootpath'] . "resource2/" . $opt['template']['style'] . "/css/style_print.css"));
     // check if the template is compiled
     // if not, check if translation works correct
     $_smarty_compile_path = $this->_get_compile_path($this->name);
     if (!$this->_is_compiled($this->name, $_smarty_compile_path) && $this->name != 'error') {
         $internal_lang = $translate->t('INTERNAL_LANG', 'all', 'OcSmarty.class.php', '');
         if ($internal_lang != $opt['template']['locale'] && $internal_lang != 'INTERNAL_LANG') {
             $this->error(ERROR_COMPILATION_FAILED);
         }
     }
     if ($this->is_cached() == true) {
         $this->assign('sys_cached', true);
     } else {
         $this->assign('sys_cached', false);
     }
     if (($opt['debug'] & DEBUG_SQLDEBUGGER) == DEBUG_SQLDEBUGGER) {
         require_once $opt['rootpath'] . 'lib2/sqldebugger.class.php';
         parent::fetch($this->main_template . '.tpl', $this->get_cache_id(), $this->get_compile_id());
         $this->clear_all_assign();
         $this->main_template = 'sys_sqldebugger';
         $this->assign('commands', $sqldebugger->getCommands());
         $this->assign('cancel', $sqldebugger->getCancel());
         unset($sqldebugger);
         $this->assign('opt', $optn);
         $this->assign('login', $loginn);
         $this->caching = false;
         // unset sqldebugger to allow proper translation of sqldebugger template
         $opt['debug'] = $opt['debug'] & ~DEBUG_SQLDEBUGGER;
         $this->header();
         parent::display($this->main_template . '.tpl');
     } else {
         $this->header();
         parent::display($this->main_template . '.tpl', $this->get_cache_id(), $this->get_compile_id());
     }
     exit;
 }
コード例 #2
0
 function display()
 {
     global $opt, $db, $cookie, $login, $menu, $sqldebugger, $translate;
     $cookie->close();
     //		// if the user is an admin, dont cache the content
     //		if (isset($login))
     //			if ($login->admin)
     //				$this->caching = false;
     //Give Smarty access to the whole options array.
     $this->assign('siteSettings', $opt);
     //Should we remove this whole block since we now have
     //access using the siteSettings above?
     // assign main template vars
     // ... and some of the $opt
     $optn['debug'] = $opt['debug'];
     $optn['template']['locales'] = $opt['template']['locales'];
     $optn['template']['locale'] = $opt['template']['locale'];
     $optn['template']['style'] = $opt['template']['style'];
     $optn['template']['country'] = $login->getUserCountry();
     $optn['page']['subtitle1'] = isset($opt['locale'][$opt['template']['locale']]['page']['subtitle1']) ? $opt['locale'][$opt['template']['locale']]['page']['subtitle1'] : $opt['page']['subtitle1'];
     $optn['page']['subtitle2'] = isset($opt['locale'][$opt['template']['locale']]['page']['subtitle2']) ? $opt['locale'][$opt['template']['locale']]['page']['subtitle2'] : $opt['page']['subtitle2'];
     $optn['page']['max_logins_per_hour'] = $opt['page']['max_logins_per_hour'];
     $optn['page']['absolute_url'] = $opt['page']['absolute_url'];
     $optn['page']['target'] = $this->target;
     $optn['page']['showdonations'] = $opt['page']['showdonations'];
     $optn['page']['title'] = $opt['page']['title'];
     $optn['page']['nowpsearch'] = $this->nowpsearch;
     $optn['page']['header_javascript'] = $this->header_javascript;
     $optn['page']['body_load'] = $this->body_load;
     $optn['page']['body_unload'] = $this->body_unload;
     $optn['page']['sponsor'] = $opt['page']['sponsor'];
     $optn['template']['title'] = $this->title;
     $optn['template']['caching'] = $this->caching;
     $optn['template']['popup'] = $this->popup;
     $optn['template']['popupmargin'] = $this->popupmargin;
     $optn['format'] = $opt['locale'][$opt['template']['locale']]['format'];
     $optn['mail'] = $opt['mail'];
     $optn['lib'] = $opt['lib'];
     $optn['geokrety'] = $opt['geokrety'];
     $optn['template']['usercountrieslist'] = labels::getLabels('usercountrieslist');
     // url-sessions? (for session timout display)
     $optn['session']['url'] = false;
     if ($opt['session']['mode'] == SAVE_SESSION && $login->userid != 0) {
         if (isset($_GET['SESSION']) || isset($_POST['SESSION'])) {
             $optn['session']['url'] = true;
         }
         $optn['session']['id'] = session_id();
     }
     if (isset($login)) {
         $loginn['username'] = $login->username;
         $loginn['userid'] = $login->userid;
         $loginn['admin'] = $login->admin;
     } else {
         $loginn['username'] = '';
         $loginn['userid'] = '';
         $loginn['admin'] = '';
     }
     // build menu
     if ($this->menuitem == null) {
         $menu->SetSelectItem(MNU_ROOT);
     } else {
         $menu->SetSelectItem($this->menuitem);
     }
     $this->assign('topmenu', $menu->getTopMenu());
     $this->assign('mainmenu', $menu->getSubMenuItems(MNU_START));
     $this->assign('my_menu', $menu->getSubMenuItems(MNU_MYPROFILE));
     $this->assign('breadcrumb', $menu->getBreadcrumb());
     $this->assign('menucolor', $menu->getMenuColor());
     if ($this->title == '') {
         $optn['template']['title'] = $menu->GetMenuTitle();
     }
     $this->assign('opt', $optn);
     $this->assign('login', $loginn);
     if ($db['connected'] == true) {
         $this->assign('sys_dbconnected', true);
     } else {
         $this->assign('sys_dbconnected', false);
     }
     $this->assign('sys_dbslave', $db['slave_id'] != -1);
     if ($this->template_exists($this->name . '.tpl')) {
         $this->assign('template', $this->name);
     } else {
         if ($this->name != 'sys_error') {
             $this->error(ERROR_TEMPLATE_NOT_FOUND);
         }
     }
     $this->bench->stop();
     $this->assign('sys_runtime', $this->bench->diff());
     // check if the template is compiled
     // if not, check if translation works correct
     $_smarty_compile_path = $this->_get_compile_path($this->name);
     if (!$this->_is_compiled($this->name, $_smarty_compile_path) && $this->name != 'error') {
         $internal_lang = $translate->t('INTERNAL_LANG', 'all', 'OcSmarty.class.php', '');
         if ($internal_lang != $opt['template']['locale'] && $internal_lang != 'INTERNAL_LANG') {
             $this->error(ERROR_COMPILATION_FAILED);
         }
     }
     if ($this->is_cached() == true) {
         $this->assign('sys_cached', true);
     } else {
         $this->assign('sys_cached', false);
     }
     $this->assignFeeds();
     if (($opt['debug'] & DEBUG_SQLDEBUGGER) == DEBUG_SQLDEBUGGER) {
         parent::fetch($this->main_template . '.tpl', $this->get_cache_id(), $this->get_compile_id());
         $this->clear_all_assign();
         $this->main_template = 'sys_sqldebugger';
         $this->assign('commands', $sqldebugger->getCommands());
         $this->assign('cancel', $sqldebugger->getCancel());
         unset($sqldebugger);
         $this->assign('opt', $optn);
         $this->assign('login', $loginn);
         $this->caching = false;
         // unset sqldebugger to allow proper translation of sqldebugger template
         $opt['debug'] = $opt['debug'] & ~DEBUG_SQLDEBUGGER;
         $this->header();
         parent::display($this->main_template . '.tpl');
     } else {
         $this->header();
         parent::display($this->main_template . '.tpl', $this->get_cache_id(), $this->get_compile_id());
     }
     exit;
 }