Text direction flexibility - feature request.
Posted: 29 April 2008 10:47 PM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  194
Joined  01-06-2006

I would LOVE to have text direction flexibility in my forums and wiki.  It would make all the difference.  Can you add this as a feature?  It seems to require the activation of the html bdo tag throughout the site, forums, wiki.

The technical info: 

The html for “bi-directional” (bdo) technique for switching directions in the middle of a div has just come to my attention:

<bdo dir="rtl"> فارسی </bdo>

It works great in html.  So, I can use it in my templates.  It kind of works in the weblog entries.  The direction is in order.  Somehow it doesn’t line up on the right side of the page, though, even when I add in an align=“right” attribute, like so.

<bdo dir="rtl" align="right">      فکر نکنم.  اگر کار بکنه، خیلی خوشحال می‌شوم.  </bdo>

It doesn’t work in the wiki, which is one place I want it to work.  I tried using brackets[] instead of <>, but that didn’t work.
[bdo dir=“rtl”]    فکر نکنم.  اگر کار بکنه، خیلی خوشحال می‌شوم.  [/bdo]

And it doesn’t work in the forum.
<bdo dir=“rtl” align=“right”>    فکر نکنم.  اگر کار بکنه، خیلی خوشحال می‌شوم.  </bdo>

(You can tell, because the period is at the right of the sentence.  The punctuation is a giveaway.  your text is moving the way it does, but the punctuation is what is set to the rtl or ltr flow.

Hopefully this is an easy feature for you geniuses to add!  It would make expression engine great for arabic, persian and hebrew users! 

Thanks!

PS, this is my first formal feature request.  A personal historic moment.  I’m going to pause a moment before hitting “submit”.

Profile
 
 
Posted: 29 April 2008 10:49 PM   [ Ignore ]   [ # 1 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  194
Joined  01-06-2006

Ideally, in the forums, you would have a button up in the formatting bar. Perhaps after <a> but before Smileys.  a “rtl” button.  Click that, and it surrounds your text with the bdo/rtl tags so they flow in the right direction. 

Thanks!

Profile
 
 
Posted: 07 May 2008 12:43 AM   [ Ignore ]   [ # 2 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  194
Joined  01-06-2006

Actually, it turns out you can do this in the wiki already. 

In the preferences, I set “text formatting” to Xhtml, and “HTML formatting for articles” to “Allow ALL HTML”.

Works like a charm!

But strangely, these same settings don’t work in the forums.  Wonder why?  The html tags are all showing. 

So, this isn’t a feature request - I suppose I need to go back to that other post and put this information in there.

Profile
 
 
Posted: 07 May 2008 01:11 AM   [ Ignore ]   [ # 3 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  194
Joined  01-06-2006

I suppose this is still an official feature request because in the preferences pane, you warn us that the “Allow ALL HTML” setting is not recommended.  So probably just creating the possibility of the right to left and align functions within the context of safety (I have no idea how you do that) would be the way to go.

Maybe buttons for the forum post formatting panel.  A “rtl” button and an alignment dropdown box next to “size” and “color”

And for the wiki, too.  A formatting panel.

If you’re not too busy : )

You guys rock.

Profile
 
 
Posted: 07 May 2008 04:41 PM   [ Ignore ]   [ # 4 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15866
Joined  06-03-2002

In your forums did you change the preferences for your existing forums, or just your global prefs used when creating new ones?  And it’s a small hack, but if you prefer to not allow all HTML, you can add the <bdo> tag to be considered “safe”

 Signature 
Profile
MSG
 
 
Posted: 08 May 2008 04:48 AM   [ Ignore ]   [ # 5 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  194
Joined  01-06-2006

Hey Derek!  Congratulations on that “steps up” thing (from the news)!

Yes!  It turns out I only did global prefs instead of existing prefs, so the forums now work.

Derek Jones - 07 May 2008 04:41 PM

if you prefer to not allow all HTML, you can add the <bdo> tag to be considered “safe”

Thanks for the hack!  A few questions.  The link says only:

The list of which HTML tags are considered “safe” is located in the system/core.core.typography.php file.  There are $safe_encode and $safe_decode arrays specified around lines 60-70.  You may modify the “safe” tags by changing those two functions.


Note tiny typo, if you’re a stickler - should be core/core

So, anyway, looking into the core.typography.php file, I find:

var $safe_encode = array('b', 'i', 'u', 'em', 'strike', 'strong', 'pre', 'code', 'blockquote');
    
    var
$safe_decode = array(
                                
'b'             => 'b',
                                
'i'             => 'i',
                                
'u'             => 'u',
                                
'em'            => 'em',
                                
'strike'        => 'strike',
                                
'strong'        => 'strong',
                                
'pre'           => 'pre',
                                
'code'          => 'code',
                                
'blockquote'    => 'blockquote',
                                
'quote'         => 'blockquote',
                                
'QUOTE'         => 'blockquote'
                             
);

So I take it that all I need to do is add, exactly:
‘bdo’ in the $safe_encode = array set, and
‘bdo’  => ‘bdo’, in the $safe_decode = array ? 

Also, I need to have the align function working, too.  I’ve noticed that bdo only reverses the order, but things are still on the left side of the margin.  If I want them right, I have to add a <div align=“right”> tag. 

That’s a <div> tag.  Would it work the same?  e.g.,:

‘align’ in the $safe_encode = array set, and
‘align’  => ‘align’, in the $safe_decode = array ?

I guess I could just experiment and report back.  That won’t cause chaos, will it?

Just a bit squeamish going into those core files gulp

Profile
 
 
Posted: 08 May 2008 05:16 AM   [ Ignore ]   [ # 6 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  194
Joined  01-06-2006

Ok, that didn’t quite work.  The result was:

[align=“right”]
[bdo dir=“rtl”]
یک کمی تکست فارسی اینجا.

and english?

And back to english.

Interestingly, the close tags don’t appear in the box (e.g., [/bdo] didn’t show up.)  Also, in the core.typography.php file, I set “‘align’  => ‘div align’”

I think this has trouble with the dir=“rtl” additional info.

OK.  I’m beyond my depth.  I sadly don’t speak PHP.  Help!

And then, getting back on topic of feature request:  if you could direct me to info on how to set up a custom button in the formatting palette of the forums. 

The idea is that right up there after “Smileys” I could have a button that says:  “farsi” (in farsi, of course), and that, when you click it, two tags appear:  [farsi][/farsi].  What these tags do, is put everything inside within the following format:

<div align="right"><bdo dir="rtl"><size="2x bigger than english">   </size></bdo></div>

This is because these 3 things are necessary.  The Persian has to be on the right, going rtl, and it needs to be a few font points bigger to appear similarlly legible. 

I want to make it easy for my forum, and also wiki, users to just click a button and have a simple set of tags in which to type, and hey presto, it comes out uniform throughout the site.  I think it would be too much to have them learn all the html and put in all those tags one by one each time they write farsi.

Are there directions somewhere for me to do this myself?  Is this what they call a plugin?  Brave new world.

Thanks!

Profile
 
 
Posted: 08 May 2008 05:31 AM   [ Ignore ]   [ # 7 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  194
Joined  01-06-2006

Yes, I need to wrap my head around how exactly to communicate this to…the ghost in the machine.

I see that in the forums, by clicking the <img> button in Formatting bar, it simply produces an img tag like so:

[img]http://urlhere.com[/img]

So clearly, somewhere the processor has been told that

[img][/img]

is the same as

<img src="       "/>

So that’s what I need to get it to understand with the

<div align="right"></div>

and

<
bdo dir="rtl"></bdo>

tags, seperately and jointly.  E.g., jointly defining it would be the way to go to create some sort of custom [farsi][/farsi] tags.

(Or, alternatively, [english][/english] tags if I decide to make the site Farsi dominant with an english reversal option.)

Hmm.  Bet you have a post somewhere about how to make custom formatting buttons already.

I’m going to take a break now.

Profile
 
 
Posted: 08 May 2008 06:59 AM   [ Ignore ]   [ # 8 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15866
Joined  06-03-2002

You’ll need to just use the regular HTML tags; there are not any code handlers made to process attributes in pMcode for those tags.

 Signature 
Profile
MSG
 
 
Posted: 11 May 2008 12:02 AM   [ Ignore ]   [ # 9 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  194
Joined  01-06-2006
Derek Jones - 08 May 2008 06:59 AM

You’ll need to just use the regular HTML tags; there are not any code handlers made to process attributes in pMcode for those tags.

So, going back to what you said earlier about designating certain tags as “safe”, are you saying that I can’t effectively do that for these tags?

So does that bring me back to square one, holding out my hand for a feature request?

Thanks!

Profile
 
 
Posted: 11 May 2008 08:59 AM   [ Ignore ]   [ # 10 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15866
Joined  06-03-2002

Yes, sorry, my memory was incorrect, and only tags without parameters of any kind will be processed as “safe”.  But, all is not lost.  ‘farsi’ is not a valid tag, so you can’t choose to do that unless you write an extension to parse it, but if you add this to your stylesheet, you should be good to go:

span.farsi {
    direction
: rtl;
    
unicode-bidi: bidi-override;
    
text-align: right;
    
font-size: 2em;
    
display: block
}

Now you can create your ‘farsi’ button, and you will have it output:

[style=farsi][/style]

 Signature 
Profile
MSG
 
 
Posted: 28 August 2008 07:40 AM   [ Ignore ]   [ # 11 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  194
Joined  01-06-2006

Brilliant!  The code works great.  I stuck it in my Themes CSS folder and it outputs just fine. 

Now:

Derek Jones - 11 May 2008 08:59 AM

Now you can create your ‘farsi’ button, and you will have it output:

[style=farsi][/style]

OK, what are the steps for making the button and inserting it in the formatting strip of the post?  I looked into Post Submission Form Templates > Post Subission Form and see in there somewhere this thingie:  {include:html_formatting_buttons}

so, where do I mess around with the html_formatting_buttons? 

Thanks!

Profile
 
 
Posted: 28 August 2008 08:36 AM   [ Ignore ]   [ # 12 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  194
Joined  01-06-2006

Also, how do I get the farsi style to appear in the forum category descriptions?  So I can explain things to Persian readers for each forum.

I tried the [style=... code, but it just shows up as typed. 

Thanks!

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 65071 Total Logged-in Users: 36
Total Topics: 82203 Total Anonymous Users: 20
Total Replies: 441788 Total Guests: 202
Total Posts: 523991    
Members ( View Memberlist )