From 1937db6065a756d46951e5099eaad8ff97d1bcc0 Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Thu, 26 May 2011 10:40:00 +0000 Subject: [PATCH] Initial RTL support. Thanks to Brook Schofield for implementing this! git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2850 44740490-163a-0410-bde0-09ae8108e29a --- config-templates/config.php | 3 +- lib/SimpleSAML/XHTML/Template.php | 12 ++++ .../InfoCard/templates/temp-getcardform.php | 2 +- modules/InfoCard/templates/temp-login.php | 2 +- modules/authX509/templates/X509error.php | 2 +- .../authYubiKey/templates/yubikeylogin.php | 2 +- modules/core/templates/frontpage_auth.tpl.php | 4 +- .../core/templates/frontpage_config.tpl.php | 4 +- .../templates/frontpage_federation.tpl.php | 4 +- .../core/templates/frontpage_welcome.tpl.php | 4 +- modules/core/templates/loginuserpass.php | 2 +- modules/sanitycheck/templates/check-tpl.php | 4 +- templates/includes/header.php | 9 +++ templates/login-ldapmulti.php | 2 +- templates/login.php | 2 +- templates/selectidp-links.php | 6 +- www/resources/default-rtl.css | 70 +++++++++++++++++++ www/resources/default.css | 9 +++ 18 files changed, 122 insertions(+), 21 deletions(-) create mode 100644 www/resources/default-rtl.css diff --git a/config-templates/config.php b/config-templates/config.php index 87963d66b..3e8809c56 100644 --- a/config-templates/config.php +++ b/config-templates/config.php @@ -217,9 +217,10 @@ $config = array ( 'session.phpsession.httponly' => FALSE, /* - * Languages available and what language is default + * Languages available, RTL languages, and what language is default */ 'language.available' => array('en', 'no', 'nn', 'se', 'da', 'de', 'sv', 'fi', 'es', 'fr', 'it', 'nl', 'lb', 'cs', 'sl', 'lt', 'hr', 'hu', 'pl', 'pt', 'pt-BR', 'tr', 'ja', 'zh-tw', 'ru'), + 'language.rtl' => array('ar','dv','fa','ur','he'), 'language.default' => 'en', /* diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php index 03fe5e286..6a01396f5 100644 --- a/lib/SimpleSAML/XHTML/Template.php +++ b/lib/SimpleSAML/XHTML/Template.php @@ -176,6 +176,18 @@ class SimpleSAML_XHTML_Template { return $lang; } + /** + * Return TRUE if language is Right-to-Left. + */ + private function isLanguageRTL() { + $rtlLanguages = $this->configuration->getArray('language.rtl', array()); + $thisLang = $this->getLanguage(); + if (in_array($thisLang, $rtlLanguages)) { + return TRUE; + } + return FALSE; + } + /** * Includs a file relative to the template base directory. * This function can be used to include headers and footers etc. diff --git a/modules/InfoCard/templates/temp-getcardform.php b/modules/InfoCard/templates/temp-getcardform.php index fecc40ff3..f2bcf4031 100644 --- a/modules/InfoCard/templates/temp-getcardform.php +++ b/modules/InfoCard/templates/temp-getcardform.php @@ -8,7 +8,7 @@ $this->includeAtTemplateBase('includes/header.php'); if (isset($this->data['error'])) { ?> <div style="border-left: 1px solid #e8e8e8; border-bottom: 1px solid #e8e8e8; background: #f5f5f5"> - <img src="/<?php echo $this->data['baseurlpath']; ?>resources/icons/experience/gtk-dialog-error.48x48.png" style="float: left; margin: 15px " /> + <img src="/<?php echo $this->data['baseurlpath']; ?>resources/icons/experience/gtk-dialog-error.48x48.png" class="float-l" style="margin: 15px " /> <h2><?php echo $this->t('error_header'); ?></h2> <p><?php echo $this->t($this->data['error']); ?> </p> diff --git a/modules/InfoCard/templates/temp-login.php b/modules/InfoCard/templates/temp-login.php index 346986331..099e61a94 100644 --- a/modules/InfoCard/templates/temp-login.php +++ b/modules/InfoCard/templates/temp-login.php @@ -8,7 +8,7 @@ $this->includeAtTemplateBase('includes/header.php'); if (isset($this->data['error'])) { ?> <div style="border-left: 1px solid #e8e8e8; border-bottom: 1px solid #e8e8e8; background: #f5f5f5"> - <img src="/<?php echo $this->data['baseurlpath']; ?>resources/icons/experience/gtk-dialog-error.48x48.png" style="float: left; margin: 15px " /> + <img src="/<?php echo $this->data['baseurlpath']; ?>resources/icons/experience/gtk-dialog-error.48x48.png" class="float-l" style="margin: 15px " /> <h2><?php echo $this->t('error_header'); ?></h2> <p><?php echo $this->t($this->data['error']); ?> </p> diff --git a/modules/authX509/templates/X509error.php b/modules/authX509/templates/X509error.php index 00168ba01..96b93046c 100644 --- a/modules/authX509/templates/X509error.php +++ b/modules/authX509/templates/X509error.php @@ -9,7 +9,7 @@ $this->includeAtTemplateBase('includes/header.php'); if ($this->data['errorcode'] !== NULL) { ?> <div style="border-left: 1px solid #e8e8e8; border-bottom: 1px solid #e8e8e8; background: #f5f5f5"> - <img src="/<?php echo $this->data['baseurlpath']; ?>resources/icons/experience/gtk-dialog-error.48x48.png" style="float: left; margin: 15px " /> + <img src="/<?php echo $this->data['baseurlpath']; ?>resources/icons/experience/gtk-dialog-error.48x48.png" class="float-l" style="margin: 15px " /> <h2><?php echo $this->t('{login:error_header}'); ?></h2> <p><b><?php echo $this->t('{errors:title_' . $this->data['errorcode'] . '}'); ?></b></p> <p><?php echo $this->t('{errors:descr_' . $this->data['errorcode'] . '}'); ?></p> diff --git a/modules/authYubiKey/templates/yubikeylogin.php b/modules/authYubiKey/templates/yubikeylogin.php index 4158d2753..eb3dce691 100644 --- a/modules/authYubiKey/templates/yubikeylogin.php +++ b/modules/authYubiKey/templates/yubikeylogin.php @@ -10,7 +10,7 @@ $this->includeAtTemplateBase('includes/header.php'); if ($this->data['errorcode'] !== NULL) { ?> <div style="border-left: 1px solid #e8e8e8; border-bottom: 1px solid #e8e8e8; background: #f5f5f5"> - <img src="/<?php echo $this->data['baseurlpath']; ?>resources/icons/experience/gtk-dialog-error.48x48.png" style="float: left; margin: 15px " /> + <img src="/<?php echo $this->data['baseurlpath']; ?>resources/icons/experience/gtk-dialog-error.48x48.png" class="float-l" style="margin: 15px " /> <h2><?php echo $this->t('{login:error_header}'); ?></h2> <p><b><?php echo $this->t('{errors:title_' . $this->data['errorcode'] . '}'); ?></b></p> <p><?php echo $this->t('{errors:descr_' . $this->data['errorcode'] . '}'); ?></p> diff --git a/modules/core/templates/frontpage_auth.tpl.php b/modules/core/templates/frontpage_auth.tpl.php index 3b9aae74b..b5976246b 100644 --- a/modules/core/templates/frontpage_auth.tpl.php +++ b/modules/core/templates/frontpage_auth.tpl.php @@ -7,9 +7,9 @@ $this->includeAtTemplateBase('includes/header.php'); <?php if ($this->data['isadmin']) { - echo '<p style="float: right">' . $this->t('{core:frontpage:loggedin_as_admin}') . '</p>'; + echo '<p class="float-r">' . $this->t('{core:frontpage:loggedin_as_admin}') . '</p>'; } else { - echo '<p style="float: right"><a href="' . $this->data['loginurl'] . '">' . $this->t('{core:frontpage:login_as_admin}') . '</a></p>'; + echo '<p class="float-r"><a href="' . $this->data['loginurl'] . '">' . $this->t('{core:frontpage:login_as_admin}') . '</a></p>'; } ?> diff --git a/modules/core/templates/frontpage_config.tpl.php b/modules/core/templates/frontpage_config.tpl.php index 9e7d1fdc6..9fb3bf976 100644 --- a/modules/core/templates/frontpage_config.tpl.php +++ b/modules/core/templates/frontpage_config.tpl.php @@ -15,9 +15,9 @@ $this->includeAtTemplateBase('includes/header.php'); </ul> --> <?php if ($this->data['isadmin']) { - echo '<p style="float: right">' . $this->t('{core:frontpage:loggedin_as_admin}') . '</p>'; + echo '<p class="float-r">' . $this->t('{core:frontpage:loggedin_as_admin}') . '</p>'; } else { - echo '<p style="float: right"><a href="' . $this->data['loginurl'] . '">' . $this->t('{core:frontpage:login_as_admin}') . '</a></p>'; + echo '<p class="float-r"><a href="' . $this->data['loginurl'] . '">' . $this->t('{core:frontpage:login_as_admin}') . '</a></p>'; } ?> diff --git a/modules/core/templates/frontpage_federation.tpl.php b/modules/core/templates/frontpage_federation.tpl.php index 08af6b584..3fe0b9eb3 100644 --- a/modules/core/templates/frontpage_federation.tpl.php +++ b/modules/core/templates/frontpage_federation.tpl.php @@ -15,9 +15,9 @@ $this->includeAtTemplateBase('includes/header.php'); </ul> --> <?php if ($this->data['isadmin']) { - echo '<p style="float: right">' . $this->t('{core:frontpage:loggedin_as_admin}') . '</p>'; + echo '<p class="float-r">' . $this->t('{core:frontpage:loggedin_as_admin}') . '</p>'; } else { - echo '<p style="float: right"><a href="' . $this->data['loginurl'] . '">' . $this->t('{core:frontpage:login_as_admin}') . '</a></p>'; + echo '<p class="float-r"><a href="' . $this->data['loginurl'] . '">' . $this->t('{core:frontpage:login_as_admin}') . '</a></p>'; } ?> diff --git a/modules/core/templates/frontpage_welcome.tpl.php b/modules/core/templates/frontpage_welcome.tpl.php index 1809a676d..dcde4f21b 100644 --- a/modules/core/templates/frontpage_welcome.tpl.php +++ b/modules/core/templates/frontpage_welcome.tpl.php @@ -8,9 +8,9 @@ $this->includeAtTemplateBase('includes/header.php'); <?php if ($this->data['isadmin']) { - echo '<p style="float: right">' . $this->t('{core:frontpage:loggedin_as_admin}') . '</p>'; + echo '<p class="float-r">' . $this->t('{core:frontpage:loggedin_as_admin}') . '</p>'; } else { - echo '<p style="float: right"><a href="' . $this->data['loginurl'] . '">' . $this->t('{core:frontpage:login_as_admin}') . '</a></p>'; + echo '<p class="float-r"><a href="' . $this->data['loginurl'] . '">' . $this->t('{core:frontpage:login_as_admin}') . '</a></p>'; } ?> diff --git a/modules/core/templates/loginuserpass.php b/modules/core/templates/loginuserpass.php index cff340c99..e2657cd67 100644 --- a/modules/core/templates/loginuserpass.php +++ b/modules/core/templates/loginuserpass.php @@ -14,7 +14,7 @@ $this->includeAtTemplateBase('includes/header.php'); if ($this->data['errorcode'] !== NULL) { ?> <div style="border-left: 1px solid #e8e8e8; border-bottom: 1px solid #e8e8e8; background: #f5f5f5"> - <img src="/<?php echo $this->data['baseurlpath']; ?>resources/icons/experience/gtk-dialog-error.48x48.png" style="float: left; margin: 15px " /> + <img src="/<?php echo $this->data['baseurlpath']; ?>resources/icons/experience/gtk-dialog-error.48x48.png" class="float-l" style="margin: 15px " /> <h2><?php echo $this->t('{login:error_header}'); ?></h2> <p><b><?php echo $this->t('{errors:title_' . $this->data['errorcode'] . '}'); ?></b></p> <p><?php echo $this->t('{errors:descr_' . $this->data['errorcode'] . '}'); ?></p> diff --git a/modules/sanitycheck/templates/check-tpl.php b/modules/sanitycheck/templates/check-tpl.php index afb84a69d..4d6200115 100644 --- a/modules/sanitycheck/templates/check-tpl.php +++ b/modules/sanitycheck/templates/check-tpl.php @@ -10,7 +10,7 @@ $this->includeAtTemplateBase('includes/header.php'); if (count($this->data['errors']) > 0) { ?> <div style="border: 1px solid #800; background: #caa; margin: 1em; padding: .5em"> -<p><?php echo '<img style="float: right" src="/' . $this->data['baseurlpath'] . 'resources/icons/silk/delete.png" alt="Failed" />'; ?> +<p><?php echo '<img class="float-r" src="/' . $this->data['baseurlpath'] . 'resources/icons/silk/delete.png" alt="Failed" />'; ?> These checks failed:</p> <?php @@ -28,7 +28,7 @@ echo '</div>'; if (count($this->data['info']) > 0) { ?> <div style="border: 1px solid #ccc; background: #eee; margin: 1em; padding: .5em"> -<p><?php echo '<img style="float: right" src="/' . $this->data['baseurlpath'] . 'resources/icons/silk/accept.png" alt="OK" />'; ?> +<p><?php echo '<img class="float-r" src="/' . $this->data['baseurlpath'] . 'resources/icons/silk/accept.png" alt="OK" />'; ?> These checks succeeded:</p> <?php echo '<ul>'; diff --git a/templates/includes/header.php b/templates/includes/header.php index 2a802919d..dcf0dd548 100644 --- a/templates/includes/header.php +++ b/templates/includes/header.php @@ -88,6 +88,11 @@ if(!empty($this->data['htmlinject']['htmlContentHead'])) { +if ($this->isLanguageRTL()) { +?> + <link rel="stylesheet" type="text/css" href="/<?php echo $this->data['baseurlpath']; ?>resources/default-rtl.css" /> +<?php +} ?> @@ -165,6 +170,10 @@ if($onLoad !== '') { 'el' => 'ελληνικά', 'ja' => '日本語', 'zh-tw' => 'ä¸ć–‡', + 'ar' => 'العربية', // Arabic + 'fa' => 'پارسی', // Persian + 'ur' => 'اردŮ', // Urdu + 'he' => 'עִבְרִית', // Hebrew ); $textarray = array(); diff --git a/templates/login-ldapmulti.php b/templates/login-ldapmulti.php index f8c045a2d..61a01ab86 100644 --- a/templates/login-ldapmulti.php +++ b/templates/login-ldapmulti.php @@ -5,7 +5,7 @@ <?php if (isset($this->data['error'])) { ?> <div style="border-left: 1px solid #e8e8e8; border-bottom: 1px solid #e8e8e8; background: #f5f5f5"> - <img src="/<?php echo $this->data['baseurlpath']; ?>resources/icons/experience/gtk-dialog-error.48x48.png" style="float: left; margin: 15px " /> + <img src="/<?php echo $this->data['baseurlpath']; ?>resources/icons/experience/gtk-dialog-error.48x48.png" class="float-l" style="margin: 15px " /> <h2><?php echo $this->t('error_header'); ?></h2> <p><?php echo htmlspecialchars($this->data['error']); ?> </p> diff --git a/templates/login.php b/templates/login.php index 9f2982ca8..5cdab55c1 100644 --- a/templates/login.php +++ b/templates/login.php @@ -7,7 +7,7 @@ <?php if (isset($this->data['error'])) { ?> <div style="border-left: 1px solid #e8e8e8; border-bottom: 1px solid #e8e8e8; background: #f5f5f5"> - <img src="/<?php echo $this->data['baseurlpath']; ?>resources/icons/experience/gtk-dialog-error.48x48.png" style="float: left; margin: 15px " /> + <img src="/<?php echo $this->data['baseurlpath']; ?>resources/icons/experience/gtk-dialog-error.48x48.png" class="float-l" style="margin: 15px " /> <h2><?php echo $this->t('error_header'); ?></h2> <p><?php echo $this->t($this->data['error']); ?> </p> diff --git a/templates/selectidp-links.php b/templates/selectidp-links.php index 1153a84c1..85aa3ca8b 100644 --- a/templates/selectidp-links.php +++ b/templates/selectidp-links.php @@ -43,11 +43,11 @@ foreach ($this->data['idplist'] AS $idpentry) { if (!empty($this->data['preferredidp']) && array_key_exists($this->data['preferredidp'], $this->data['idplist'])) { $idpentry = $this->data['idplist'][$this->data['preferredidp']]; echo '<div class="preferredidp">'; - echo ' <img src="/' . $this->data['baseurlpath'] .'resources/icons/experience/gtk-about.64x64.png" style="float: right" alt="'.$this->t('icon_prefered_idp').'" />'; + echo ' <img src="/' . $this->data['baseurlpath'] .'resources/icons/experience/gtk-about.64x64.png" class="float-r" alt="'.$this->t('icon_prefered_idp').'" />'; if(array_key_exists('icon', $idpentry) && $idpentry['icon'] !== NULL) { $iconUrl = SimpleSAML_Utilities::resolveURL($idpentry['icon']); - echo '<img style="float: left; margin: 1em; padding: 3px; border: 1px solid #999" src="' . htmlspecialchars($iconUrl) . '" />'; + echo '<img class="float-l" style="margin: 1em; padding: 3px; border: 1px solid #999" src="' . htmlspecialchars($iconUrl) . '" />'; } echo "\n" . ' <h3 style="margin-top: 8px">' . htmlspecialchars($this->t('idpname_' . $idpentry['entityid'])) . '</h3>'; @@ -66,7 +66,7 @@ foreach ($this->data['idplist'] AS $idpentry) { if(array_key_exists('icon', $idpentry) && $idpentry['icon'] !== NULL) { $iconUrl = SimpleSAML_Utilities::resolveURL($idpentry['icon']); - echo '<img style="clear: both; float: left; margin: 1em; padding: 3px; border: 1px solid #999" src="' . htmlspecialchars($iconUrl) . '" />'; + echo '<img class="float-l" style="clear: both; margin: 1em; padding: 3px; border: 1px solid #999" src="' . htmlspecialchars($iconUrl) . '" />'; } echo "\n" . ' <h3 style="margin-top: 8px">' . htmlspecialchars($this->t('idpname_' . $idpentry['entityid'])) . '</h3>'; diff --git a/www/resources/default-rtl.css b/www/resources/default-rtl.css new file mode 100644 index 000000000..0113f82f1 --- /dev/null +++ b/www/resources/default-rtl.css @@ -0,0 +1,70 @@ +/* these styles are in the head of this page because this is a unique page */ + +/* THE BIG GUYS */ +html { + direction: rtl; +} + +/* LISTS */ +ul { + margin: .3em 2em 1.5em 0; +} + +li { + margin-right: 2em; +} + +#wrap { + text-align: right; +} + +/* TYPOGRAPHY */ +dl dd { + margin-right: 3em; +} + +.efieldlist { + border-right: 1px solid #e6e6e6; +} + +div.caution { + padding: .2em 60px .2em .2em; + background-position: right; +} + +th.rowtitle { + text-align: right; +} +.enablebox table { + margin-right: 1em; +} +.enablebox.mini table { + float: left; +} +.enablebox tr td { + padding: .5px .5em 1px 1em; +} + +/* Attribute presentation in example page */ +table.attributes td.attrname { + text-align: left; +} + +fieldset.fancyfieldset { + margin: 2em 0px 1em 1em; +} +fieldset.fancyfieldset legend { + margin-right: 2em; +} + +.ui-tabs .ui-tabs-nav li { + float: right; +} + +/* Reverse Float Left <-> Right */ +.float-r { + float: left; +} +.float-l { + float: right; +} diff --git a/www/resources/default.css b/www/resources/default.css index 984304fed..958a86f70 100644 --- a/www/resources/default.css +++ b/www/resources/default.css @@ -340,3 +340,12 @@ div#confirmation { caption { display: none; } + +/* Left-to-Right CSS for RTL (Right to Left Support) */ +.float-r { + float: right; +} +.float-l { + float: left; +} + -- GitLab