diff --git image_captcha/css/image_captcha.css image_captcha/css/image_captcha.css new file mode 100644 index 0000000..e7ff5b9 --- /dev/null +++ image_captcha/css/image_captcha.css @@ -0,0 +1,31 @@ +/* $Id: image_captcha.css,v 1.2 2009/12/15 23:55:23 soxofaan Exp $ */ + +/** + * Styling of the font selection list (with previews) + * on the Image CAPTCHA settings page. + */ + +/** + * Float the fonts with preview (with a fixed width) + * to create a multi-column layout. + */ +.image_captcha_admin_font_preview { + float: left; + width: 160px; +} + +/** + * Fonts without a preview should not follow the column layout. + */ +.image_captcha_admin_fonts_selection .form-item { + clear: both; +} + +/** + * Center the font previews vertically to the text. + */ +.image_captcha_admin_fonts_selection img { + vertical-align: middle; +} + + diff --git image_captcha/css/image_captcha_rtl.css image_captcha/css/image_captcha_rtl.css new file mode 100644 index 0000000..6eca9e4 --- /dev/null +++ image_captcha/css/image_captcha_rtl.css @@ -0,0 +1,18 @@ +/* $Id$ */ + +/** + * RTL css + */ + +/** + * Styling of the font selection list (with previews) + * on the Image CAPTCHA settings page. + */ + +/** + * Float the fonts with preview (with a fixed width) + * to create a multi-column layout. + */ +.image_captcha_admin_font_preview { + float: right; +} diff --git image_captcha/image_captcha.admin.inc image_captcha/image_captcha.admin.inc index d15714e..ed44c86 100644 --- image_captcha/image_captcha.admin.inc +++ image_captcha/image_captcha.admin.inc @@ -14,7 +14,11 @@ function image_captcha_settings_form() { // Add CSS for theming of admin form. - drupal_add_css(drupal_get_path('module', 'image_captcha') .'/image_captcha.css'); + drupal_add_css(drupal_get_path('module', 'image_captcha') .'/css/image_captcha.css'); + global $language; + if ($language->direction) { + drupal_add_css(drupal_get_path('module', 'image_captcha') .'/css/image_captcha_rtl.css'); + } // Use javascript for some added usability on admin form. drupal_add_js(drupal_get_path('module', 'image_captcha') .'/image_captcha.js'); @@ -59,6 +63,12 @@ function image_captcha_settings_form() { '#default_value' => (int) variable_get('image_captcha_code_length', 5), '#description' => t('The code length influences the size of the image. Note that larger values make the image generation more CPU intensive.'), ); + $form['image_captcha_code_settings']['image_captcha_direction'] = array( + '#type' => 'checkbox', + '#title' => t('RTL direction for RTL languages'), + '#default_value' => variable_get('image_captcha_direction', 0), + '#description' => t('This option will cause characters in captcha image to start from the right if the current language is RTL.'), + ); // Font related stuff. $form['image_captcha_font_settings'] = _image_captcha_settings_form_font_section(); diff --git image_captcha/image_captcha.css image_captcha/image_captcha.css deleted file mode 100644 index e7ff5b9..0000000 --- image_captcha/image_captcha.css +++ /dev/null @@ -1,31 +0,0 @@ -/* $Id: image_captcha.css,v 1.2 2009/12/15 23:55:23 soxofaan Exp $ */ - -/** - * Styling of the font selection list (with previews) - * on the Image CAPTCHA settings page. - */ - -/** - * Float the fonts with preview (with a fixed width) - * to create a multi-column layout. - */ -.image_captcha_admin_font_preview { - float: left; - width: 160px; -} - -/** - * Fonts without a preview should not follow the column layout. - */ -.image_captcha_admin_fonts_selection .form-item { - clear: both; -} - -/** - * Center the font previews vertically to the text. - */ -.image_captcha_admin_fonts_selection img { - vertical-align: middle; -} - - diff --git image_captcha/image_captcha.user.inc image_captcha/image_captcha.user.inc index 2a9a8e5..815c365 100644 --- image_captcha/image_captcha.user.inc +++ image_captcha/image_captcha.user.inc @@ -254,6 +254,10 @@ function _image_captcha_image_generator_print_string(&$image, $width, $height, $ $ccage_width = $width / $character_quantity; $ccage_height = $height; + global $language; + if ($language->direction && ((bool) variable_get('image_captcha_direction', FALSE))) { + $characters = array_reverse($characters); + } foreach ($characters as $c => $character) { // initial position of character: in the center of its cage $center_x = ($c + 0.5) * $ccage_width;