00001 <?php
00002
00014
00015
00016 import('plugins.BlockPlugin');
00017
00018 class LanguageToggleBlockPlugin extends BlockPlugin {
00019 function register($category, $path) {
00020 $success = parent::register($category, $path);
00021 if ($success) {
00022 $this->addLocaleData();
00023 }
00024 return $success;
00025 }
00026
00031 function getSupportedContexts() {
00032 return array(BLOCK_CONTEXT_LEFT_SIDEBAR, BLOCK_CONTEXT_RIGHT_SIDEBAR);
00033 }
00034
00039 function getEnabled() {
00040 if (!Config::getVar('general', 'installed')) return true;
00041 return parent::getEnabled();
00042 }
00043
00048 function getInstallSitePluginSettingsFile() {
00049 return $this->getPluginPath() . '/settings.xml';
00050 }
00051
00056 function getNewConferencePluginSettingsFile() {
00057 return $this->getPluginPath() . '/settings.xml';
00058 }
00059
00065 function getBlockContext() {
00066 if (!Config::getVar('general', 'installed')) return BLOCK_CONTEXT_RIGHT_SIDEBAR;
00067 return parent::getBlockContext();
00068 }
00069
00074 function getSeq() {
00075 if (!Config::getVar('general', 'installed')) return 2;
00076 return parent::getSeq();
00077 }
00078
00084 function getName() {
00085 return 'LanguageToggleBlockPlugin';
00086 }
00087
00092 function getDisplayName() {
00093 return __('plugins.block.languageToggle.displayName');
00094 }
00095
00099 function getDescription() {
00100 return __('plugins.block.languageToggle.description');
00101 }
00102
00106 function getContents(&$templateMgr) {
00107 $templateMgr->assign('isPostRequest', Request::isPost());
00108 if (!defined('SESSION_DISABLE_INIT')) {
00109 $conference =& Request::getConference();
00110 if (isset($conference)) {
00111 $locales =& $conference->getSupportedLocaleNames();
00112
00113 } else {
00114 $site =& Request::getSite();
00115 $locales =& $site->getSupportedLocaleNames();
00116 }
00117 } else {
00118 $locales =& AppLocale::getAllLocales();
00119 $templateMgr->assign('languageToggleNoUser', true);
00120 }
00121
00122 if (isset($locales) && count($locales) > 1) {
00123 $templateMgr->assign('enableLanguageToggle', true);
00124 $templateMgr->assign('languageToggleLocales', $locales);
00125 }
00126
00127 return parent::getContents($templateMgr);
00128 }
00129 }
00130
00131 ?>