00001 <?php
00002
00015
00016
00017
00018 import('plugins.BlockPlugin');
00019
00020 class LanguageToggleBlockPlugin extends BlockPlugin {
00021 function register($category, $path) {
00022 $success = parent::register($category, $path);
00023 if ($success) {
00024 $this->addLocaleData();
00025 }
00026 return $success;
00027 }
00028
00033 function getSupportedContexts() {
00034 return array(BLOCK_CONTEXT_LEFT_SIDEBAR, BLOCK_CONTEXT_RIGHT_SIDEBAR);
00035 }
00036
00041 function getEnabled() {
00042 if (!Config::getVar('general', 'installed')) return true;
00043 return parent::getEnabled();
00044 }
00045
00050 function getInstallSitePluginSettingsFile() {
00051 return $this->getPluginPath() . '/settings.xml';
00052 }
00053
00058 function getNewJournalPluginSettingsFile() {
00059 return $this->getPluginPath() . '/settings.xml';
00060 }
00061
00067 function getBlockContext() {
00068 if (!Config::getVar('general', 'installed')) return BLOCK_CONTEXT_RIGHT_SIDEBAR;
00069 return parent::getBlockContext();
00070 }
00071
00076 function getSeq() {
00077 if (!Config::getVar('general', 'installed')) return 2;
00078 return parent::getSeq();
00079 }
00080
00086 function getName() {
00087 return 'LanguageToggleBlockPlugin';
00088 }
00089
00094 function getDisplayName() {
00095 return Locale::translate('plugins.block.languageToggle.displayName');
00096 }
00097
00101 function getDescription() {
00102 return Locale::translate('plugins.block.languageToggle.description');
00103 }
00104
00108 function getContents(&$templateMgr) {
00109 if (!defined('SESSION_DISABLE_INIT')) {
00110 $journal =& Request::getJournal();
00111 if (isset($journal)) {
00112 $locales =& $journal->getSupportedLocaleNames();
00113
00114 } else {
00115 $site =& Request::getSite();
00116 $locales =& $site->getSupportedLocaleNames();
00117 }
00118 } else {
00119 $locales =& Locale::getAllLocales();
00120 $templateMgr->assign('languageToggleNoUser', true);
00121 }
00122
00123 if (isset($locales) && count($locales) > 1) {
00124 $templateMgr->assign('enableLanguageToggle', true);
00125 $templateMgr->assign('languageToggleLocales', $locales);
00126 }
00127
00128 return parent::getContents($templateMgr);
00129 }
00130 }
00131
00132 ?>