<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>OXT blog</title>
	<atom:link href="http://blog.o-x-t.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.o-x-t.com</link>
	<description>"People say nothing is impossible, but I do nothing every day." - Whinnie The Pooh</description>
	<lastBuildDate>Wed, 25 Aug 2010 19:18:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Symfony Doctrine Sluggable &#8211; rebuilding empty slugs</title>
		<link>http://blog.o-x-t.com/2010/08/25/symfony-doctrine-sluggable-rebuilding-empty-slugs/</link>
		<comments>http://blog.o-x-t.com/2010/08/25/symfony-doctrine-sluggable-rebuilding-empty-slugs/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 19:18:05 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[doctrine]]></category>
		<category><![CDATA[sluggable]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://blog.o-x-t.com/?p=244</guid>
		<description><![CDATA[If you add slugs with Sluggable behaviour in the middle of your project you&#8217;ll have empty slugs for all old records. To fix it you need to save your models via symfony, slugs will be built automatically. You can automate it with help of this simple task: class buildSlugTask extends sfBaseTask &#123; protected function configure&#40;&#41; [...]]]></description>
			<content:encoded><![CDATA[<p>If you add slugs with Sluggable behaviour in the middle of your project you&#8217;ll have empty slugs for all old records. To fix it you need to save your models via symfony, slugs will be built automatically.</p>
<p>You can automate it with help of this simple task:<br />
<span id="more-244"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> buildSlugTask <span style="color: #000000; font-weight: bold;">extends</span> sfBaseTask
<span style="color: #009900;">&#123;</span>
  protected <span style="color: #000000; font-weight: bold;">function</span> configure<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addArguments</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
      <span style="color: #000000; font-weight: bold;">new</span> sfCommandArgument<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'model'</span><span style="color: #339933;">,</span> sfCommandArgument<span style="color: #339933;">::</span><span style="color: #004000;">REQUIRED</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Model'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
      <span style="color: #000000; font-weight: bold;">new</span> sfCommandArgument<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'field'</span><span style="color: #339933;">,</span> sfCommandArgument<span style="color: #339933;">::</span><span style="color: #004000;">REQUIRED</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Slug source field'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addOptions</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
      <span style="color: #000000; font-weight: bold;">new</span> sfCommandOption<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'application'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> sfCommandOption<span style="color: #339933;">::</span><span style="color: #004000;">PARAMETER_REQUIRED</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'The application name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
      <span style="color: #000000; font-weight: bold;">new</span> sfCommandOption<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'env'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> sfCommandOption<span style="color: #339933;">::</span><span style="color: #004000;">PARAMETER_REQUIRED</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'The environment'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'dev'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
      <span style="color: #000000; font-weight: bold;">new</span> sfCommandOption<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'connection'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> sfCommandOption<span style="color: #339933;">::</span><span style="color: #004000;">PARAMETER_REQUIRED</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'The connection name'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'doctrine'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">namespace</span>        <span style="color: #339933;">=</span> <span style="color: #0000ff;">'oxt'</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span>             <span style="color: #339933;">=</span> <span style="color: #0000ff;">'buildSlug'</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">briefDescription</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Rebuild empty slug'</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">detailedDescription</span> <span style="color: #339933;">=</span> <span style="color: #0000cc; font-style: italic;">&lt;&lt;&lt;EOF
The [buildSlug|INFO] task rebuilds empty slugs.
Call it with:
&nbsp;
  [php symfony buildSlug|INFO]
EOF</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  protected <span style="color: #000000; font-weight: bold;">function</span> execute<span style="color: #009900;">&#40;</span><span style="color: #000088;">$arguments</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// initialize the database connection</span>
    <span style="color: #000088;">$databaseManager</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> sfDatabaseManager<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">configuration</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$connection</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$databaseManager</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getDatabase</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'connection'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getConnection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$items</span> <span style="color: #339933;">=</span> Doctrine<span style="color: #339933;">::</span><span style="color: #004000;">getTable</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arguments</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'model'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
      <span style="color: #339933;">-&gt;</span><span style="color: #004000;">createQuery</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'m'</span><span style="color: #009900;">&#41;</span>
      <span style="color: #339933;">-&gt;</span><span style="color: #004000;">where</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'m.slug IS NULL'</span><span style="color: #009900;">&#41;</span>
      <span style="color: #339933;">-&gt;</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$items</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
      <span style="color: #666666; font-style: italic;">//cheat doctrine to re-save our model</span>
      <span style="color: #000088;">$field_value</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arguments</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'field'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arguments</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'field'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arguments</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'field'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$field_value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Call it with model name and slug field name. If you have slug built from several fields you can pass any of them.<br />
E.g.:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>symfony oxt:buildSlug Record title</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.o-x-t.com/2010/08/25/symfony-doctrine-sluggable-rebuilding-empty-slugs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Background spell check in TinyMCE</title>
		<link>http://blog.o-x-t.com/2010/04/11/background-spell-check-in-tinymce/</link>
		<comments>http://blog.o-x-t.com/2010/04/11/background-spell-check-in-tinymce/#comments</comments>
		<pubDate>Sun, 11 Apr 2010 09:10:49 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[spell check]]></category>
		<category><![CDATA[TinyMCE]]></category>

		<guid isPermaLink="false">http://blog.o-x-t.com/?p=239</guid>
		<description><![CDATA[TinyMCE has spellchecker plugin which checks your text when you click button. You can read how to setup it here. However what we want is to have background spell checking when we type text. Just like in regular word processor. The idea is simple &#8211; trigger spell check each time we type something. There&#8217;s a [...]]]></description>
			<content:encoded><![CDATA[<p>TinyMCE has spellchecker plugin which checks your text when you click button. You can read how to setup it <a href="http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker">here</a>.</p>
<p>However what we want is to have background spell checking when we type text. Just like in regular word processor. The idea is simple &#8211; trigger spell check each time we type something. There&#8217;s a problem if we&#8217;ll trigger it after each letter &#8211; spell check uses Ajax request to server script, it may be very slow. We&#8217;ll solve it by triggering spell checking within 3-seconds delay after user has stopped typing.</p>
<p>Here&#8217;s the code:<br />
<span id="more-239"></span></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">tinyMCE.<span style="color: #660066;">init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">//...</span>
	<span style="color: #006600; font-style: italic;">//regular initialization here</span>
	<span style="color: #006600; font-style: italic;">//...</span>
	plugins <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;spellchecker&quot;</span><span style="color: #339933;">,</span> 
	theme_advanced_buttons1 <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;spellchecker&quot;</span><span style="color: #339933;">,</span>
	spellchecker_languages <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;English=en&quot;</span><span style="color: #339933;">,</span> 
	setup<span style="color: #339933;">:</span> mceSpellCheckRuntimeHandler
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>And setup function:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">mceSpellCheckRuntimeHandler <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>ed<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  ed.<span style="color: #660066;">addCommand</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mceSpellCheckRuntime'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    t <span style="color: #339933;">=</span> ed.<span style="color: #660066;">plugins</span>.<span style="color: #660066;">spellchecker</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>t.<span style="color: #660066;">mceSpellCheckRuntimeTimer</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      window.<span style="color: #660066;">clearTimeout</span><span style="color: #009900;">&#40;</span>t.<span style="color: #660066;">mceSpellCheckRuntimeTimer</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    t.<span style="color: #660066;">mceSpellCheckRuntimeTimer</span> <span style="color: #339933;">=</span> window.<span style="color: #660066;">setTimeout</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      t._done<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      t._sendRPC<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'checkWords'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span>t.<span style="color: #660066;">selectedLang</span><span style="color: #339933;">,</span> t._getWords<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>r<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>r.<span style="color: #660066;">length</span> <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          t.<span style="color: #660066;">active</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
          t._markWords<span style="color: #009900;">&#40;</span>r<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          ed.<span style="color: #660066;">nodeChanged</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//3 seconds</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  ed.<span style="color: #660066;">onKeyUp</span>.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>ed<span style="color: #339933;">,</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    ed.<span style="color: #660066;">execCommand</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mceSpellCheckRuntime'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The code is not ideal, but it works. Feel free to improve it for your needs.<br />
<strong>Update.</strong> There may be an issue with focus. For example when cursor leaves tinymce it may return back to the editor. Ask me if you have this problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.o-x-t.com/2010/04/11/background-spell-check-in-tinymce/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Extra spacing in TinyMCE after pasting from Word</title>
		<link>http://blog.o-x-t.com/2010/03/06/extra-spacing-in-tinymce-after-pasting-from-word/</link>
		<comments>http://blog.o-x-t.com/2010/03/06/extra-spacing-in-tinymce-after-pasting-from-word/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 13:26:02 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[TinyMCE]]></category>
		<category><![CDATA[Word]]></category>

		<guid isPermaLink="false">http://blog.o-x-t.com/?p=235</guid>
		<description><![CDATA[TinyMCE can add extra empty paragraphs when you insert text from Word. TinyMCE simply wraps each newline into paragraph. To solve it you need to follow these steps: Enable paste plugin. Add handler for parsing inserted text So your TinyMCE code will look like: tinyMCE.init&#40;&#123; ... plugins: &#34;paste&#34;, paste_auto_cleanup_on_paste : true, paste_postprocess : function&#40;pl, o&#41; [...]]]></description>
			<content:encoded><![CDATA[<p>TinyMCE can add extra empty paragraphs when you insert text from Word. TinyMCE simply wraps each newline into paragraph.<br />
To solve it you need to follow these steps:</p>
<ol>
<li>Enable <code>paste</code> plugin.</li>
<li>Add handler for parsing inserted text</li>
</ol>
<p>So your TinyMCE code will look like:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">  tinyMCE.<span style="color: #660066;">init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
        ...
      	<span style="color: #660066;">plugins</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;paste&quot;</span><span style="color: #339933;">,</span>
      	paste_auto_cleanup_on_paste <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
      	paste_postprocess <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>pl<span style="color: #339933;">,</span> o<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #006600; font-style: italic;">// remove extra line breaks</span>
            o.<span style="color: #660066;">node</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> o.<span style="color: #660066;">node</span>.<span style="color: #660066;">innerHTML</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/&lt;p.*&gt;\s*(&lt;br&gt;|&amp;nbsp;)\s*&lt;\/p&gt;/ig</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>See more info on the <a href="http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/paste">official wiki</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.o-x-t.com/2010/03/06/extra-spacing-in-tinymce-after-pasting-from-word/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Doctrine Sluggable and translit</title>
		<link>http://blog.o-x-t.com/2010/02/01/doctrine-sluggable-and-translit/</link>
		<comments>http://blog.o-x-t.com/2010/02/01/doctrine-sluggable-and-translit/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 00:45:02 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[doctrine]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[translit]]></category>

		<guid isPermaLink="false">http://blog.o-x-t.com/?p=230</guid>
		<description><![CDATA[Doctrine Sluggable behaviour doesn&#8217;t work with non-ASCII characters &#8211; it just removes them from the slug. For some languages, e.g. Russian with Cyrillic alphabet, it becomes unusable. The obvious way is to use transliteration. Luckily Doctrine has easy way to do that, you can pass method for building slug: Artist: actAs: Sluggable: fields: &#91;name&#93; builder: [...]]]></description>
			<content:encoded><![CDATA[<p>Doctrine Sluggable behaviour doesn&#8217;t work with non-ASCII characters &#8211; it just removes them from the slug. For some languages, e.g. Russian with Cyrillic alphabet, it becomes unusable. The obvious way is to use transliteration.<br />
Luckily Doctrine has easy way to do that, you can pass method for building slug:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">Artist:
  actAs:
    Sluggable:
      fields: <span style="color:#006600; font-weight:bold;">&#91;</span>name<span style="color:#006600; font-weight:bold;">&#93;</span>
      builder: <span style="color:#006600; font-weight:bold;">&#91;</span>oxtSluggableTranslit, urlize<span style="color:#006600; font-weight:bold;">&#93;</span></pre></div></div>

<p>The easiest way I found to transliterate non-ASCII text is to use <a href="http://pecl.php.net/package/translit">PECL translit package</a>. For Debian-based systems you can install it with <code>dh-make-php</code>.<br />
Here&#8217;s the code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> oxtSluggableTranslit
<span style="color: #009900;">&#123;</span>
  <span style="color: #009933; font-style: italic;">/**
   * Convert any passed string to a url friendly string. Converts 'My first blog post' to 'my-first-blog-post'
   *
   * @param  string $text  Text to urlize
   * @return string $text  Urlized text
   */</span>
  static <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> urlize<span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> Doctrine_Inflector<span style="color: #339933;">::</span><span style="color: #004000;">urlize</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">transliterate</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cyrillic_transliterate'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'remove_punctuation'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'utf-8'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'utf-8'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>You can view all available transliterate filters by running</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">php <span style="color: #660033;">-r</span> <span style="color: #ff0000;">'print_r(transliterate_filters_get());'</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.o-x-t.com/2010/02/01/doctrine-sluggable-and-translit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Symfony, propel and long running scripts</title>
		<link>http://blog.o-x-t.com/2009/11/28/symfony-propel-and-long-running-scripts/</link>
		<comments>http://blog.o-x-t.com/2009/11/28/symfony-propel-and-long-running-scripts/#comments</comments>
		<pubDate>Sat, 28 Nov 2009 15:25:18 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[propel]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://blog.o-x-t.com/?p=228</guid>
		<description><![CDATA[For long running scripts in symfony with propel ORM you may experience problems with memory usage. To avoid them make sure to disable propel instance caching by calling this code at the beginning of the script: Propel::disableInstancePooling&#40;&#41;; Propel by default caches in memory all fetched database objects. That means that for scripts with extensive db [...]]]></description>
			<content:encoded><![CDATA[<p>For long running scripts in symfony with propel ORM you may experience problems with memory usage. To avoid them make sure to disable propel instance caching by calling this code at the beginning of the script:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">Propel<span style="color: #339933;">::</span><span style="color: #004000;">disableInstancePooling</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Propel by default caches in memory all fetched database objects. That means that for scripts with extensive db usage or long running time you may hit php <code>memory_limit</code> sooner or later.<br />
Starting with propel 1.3 shipped with symfony 1.3 and 1.4 which are about to be released you&#8217;ll be able to disable instance pooling in database yaml config.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.o-x-t.com/2009/11/28/symfony-propel-and-long-running-scripts/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Disable menu bar in gnome-terminal</title>
		<link>http://blog.o-x-t.com/2009/10/18/disable-menu-bar-in-gnome-terminal/</link>
		<comments>http://blog.o-x-t.com/2009/10/18/disable-menu-bar-in-gnome-terminal/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 18:54:36 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[Operating systems]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://blog.o-x-t.com/?p=222</guid>
		<description><![CDATA[You can easily hide menu bar for gnome-terminal at a runtime. Obviously it&#8217;s rarely used and you can save some screen space by hiding it. To hide it for newly opened terminal windows by default change this flag in gnome config: /apps/gnome-terminal/profiles/Default/default_show_menubar to false. gconftool --type boolean --set /apps/gnome-terminal/profiles/Default/default_show_menubar false]]></description>
			<content:encoded><![CDATA[<p>You can easily hide menu bar for gnome-terminal at a runtime. Obviously it&#8217;s rarely used and you can save some screen space by hiding it.</p>
<p>To hide it for newly opened terminal windows by default change this flag in gnome config:<br />
<code>/apps/gnome-terminal/profiles/Default/default_show_menubar</code> to false.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gconftool <span style="color: #660033;">--type</span> boolean <span style="color: #660033;">--set</span> <span style="color: #000000; font-weight: bold;">/</span>apps<span style="color: #000000; font-weight: bold;">/</span>gnome-terminal<span style="color: #000000; font-weight: bold;">/</span>profiles<span style="color: #000000; font-weight: bold;">/</span>Default<span style="color: #000000; font-weight: bold;">/</span>default_show_menubar <span style="color: #c20cb9; font-weight: bold;">false</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.o-x-t.com/2009/10/18/disable-menu-bar-in-gnome-terminal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>symfony: sfValidatorFile &#8211; invalid mime type (text/plain) for PNG images</title>
		<link>http://blog.o-x-t.com/2009/07/27/symfony-sfvalidatorfile-invalid-mime-type-textplain-for-png-images/</link>
		<comments>http://blog.o-x-t.com/2009/07/27/symfony-sfvalidatorfile-invalid-mime-type-textplain-for-png-images/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 13:47:02 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://blog.o-x-t.com/?p=217</guid>
		<description><![CDATA[On some systems sfValidatorFile may give you an error when trying to upoad PNG images. It says that it has invalid mime type &#8211; text/plain, though you have 'mime_types' = 'web_images' and other image formats work well. It may be caused by wrong result from mime_content_type() function. To check if it&#8217;s your case create simple [...]]]></description>
			<content:encoded><![CDATA[<p>On some systems <code>sfValidatorFile</code> may give you an error when trying to upoad PNG images. It says that it has invalid mime type &#8211; text/plain, though you have <code>'mime_types' = 'web_images'</code> and other image formats work well.</p>
<p>It may be caused by wrong result from <code>mime_content_type()</code> function. To check if it&#8217;s your case create simple php script with just one line:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <span style="color: #990000;">mime_content_type</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'path_to_your_png_image'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>If it will give you <code>text/plain</code> then you have three options:</p>
<ol>
<li>Upgrade your PHP to 5.3.0, though I doubt it&#8217;s available for most *nix distributions at this time.</li>
<li>Install PECL package <a href="http://pecl.php.net/package/Fileinfo">Fileinfo</a>.</li>
<li>The easiest, modify form class.</li>
</ol>
<p>In first two options <code>sfValidatorFile</code> will use <code>finfo_open</code> function prior to <code>mime_content_type</code> and it should give correct results for PNG image. However, upgrading PHP or installing PECL package isn&#8217;t always possible.</p>
<p>The simplest way to fix this bug is to apply small modifications to your form class, just reorder mime type guessers:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> configure<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">validatorSchema</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'image'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> sfValidatorFile<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
      <span style="color: #0000ff;">'required'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">'path'</span>       <span style="color: #339933;">=&gt;</span> sfConfig<span style="color: #339933;">::</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sf_upload_dir'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/directory'</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">'mime_types'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'web_images'</span>
    <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">validatorSchema</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'image'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mime_type_guessers'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">validatorSchema</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'image'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'guessFromFileinfo'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">validatorSchema</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'image'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'guessFromFileBinary'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">validatorSchema</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'image'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'guessFromMimeContentType'</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>In this case validator will first try <code>fileinfo</code> (which should be available since PHP 5.3.0), then <code>'file -bi'</code> which should work correctly on *nix platform and only if both failed it will use <code>mime_content_type</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.o-x-t.com/2009/07/27/symfony-sfvalidatorfile-invalid-mime-type-textplain-for-png-images/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Calling phing tasks from Eclipse</title>
		<link>http://blog.o-x-t.com/2009/06/11/calling-phing-tasks-from-eclipse/</link>
		<comments>http://blog.o-x-t.com/2009/06/11/calling-phing-tasks-from-eclipse/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 12:16:27 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[phing]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.o-x-t.com/?p=211</guid>
		<description><![CDATA[Here you can read how to run phing tasks using built-in Ant tool in Eclipse. In this post I&#8217;ll describe what to do if your phing task requires user input. The solution is simple &#8211; ask for user property in ant and pass it back to phing: &#60;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&#62; &#60;project name=&#34;project_name&#34;&#62; &#60;property name=&#34;phing.command&#34; value=&#34;phing&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>Here you can read <a href="http://www.insidewebdev.com/2008/08/16/using-eclipse-ant-with-phing/">how to run phing tasks using built-in Ant tool in Eclipse</a>.</p>
<p>In this post I&#8217;ll describe what to do if your phing task requires user input. The solution is simple &#8211; ask for user property in ant and pass it back to phing:<br />
<span id="more-211"></span></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;project_name&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;phing.command&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;phing&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;task_name&quot;</span> <span style="color: #000066;">description</span>=<span style="color: #ff0000;">&quot;Task description&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">message</span>=<span style="color: #ff0000;">&quot;Input property&quot;</span></span>
<span style="color: #009900;">			<span style="color: #000066;">addproperty</span>=<span style="color: #ff0000;">&quot;property_name&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">executable</span>=<span style="color: #ff0000;">&quot;${phing.command}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">line</span>=<span style="color: #ff0000;">&quot;-Dphing_task_property=${property_name}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">line</span>=<span style="color: #ff0000;">&quot;phing_task_name&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>You also need to tell phing not to wait for user input if we&#8217;ve passed property via command line. For phing task <code>propertyPrompt</code> use attribute <code>useExistingValue="true"</code>.</p>
<p>If your phing property has default value you need to specify this default value in ant input task also.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.o-x-t.com/2009/06/11/calling-phing-tasks-from-eclipse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add absolute link menu item to user menu in Drupal</title>
		<link>http://blog.o-x-t.com/2009/05/21/add-absolute-link-menu-item-to-user-menu-in-drupal/</link>
		<comments>http://blog.o-x-t.com/2009/05/21/add-absolute-link-menu-item-to-user-menu-in-drupal/#comments</comments>
		<pubDate>Wed, 20 May 2009 22:58:26 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.o-x-t.com/?p=207</guid>
		<description><![CDATA[First of all, user menu (local tasks) in Drupal cannot be edited via admin. To add items to the menu you need to create new module and implement hook_menu() in it. The following example shows how to do it in Drupal 6: function yourmodule_menu&#40;&#41; &#123; $items&#91;'http://some.url'&#93; = array&#40; 'tab_root' =&#62; 'user', 'tab_parent' =&#62; 'user', 'title' [...]]]></description>
			<content:encoded><![CDATA[<p>First of all, user menu (local tasks) in Drupal cannot be edited via admin. To add items to the menu you need to create new module and implement hook_menu() in it.<br />
The following example shows how to do it in Drupal 6:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> yourmodule_menu<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$items</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'http://some.url'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'tab_root'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'user'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'tab_parent'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'user'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'title'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'External URL'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'page callback'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'user_page'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'access callback'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'user_is_anonymous'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'type'</span> <span style="color: #339933;">=&gt;</span> MENU_LOCAL_TASK<span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'weight'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">5</span>
  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$items</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Change &#8216;access callback&#8217; to whatever function (or constant) you want, but don&#8217;t forget to set &#8216;page callback&#8217;. It is being checked when building menu structure even if we don&#8217;t have any page callback actually.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.o-x-t.com/2009/05/21/add-absolute-link-menu-item-to-user-menu-in-drupal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>symfony l10n &#8211; going further</title>
		<link>http://blog.o-x-t.com/2009/04/19/symfony-l10n-going-further/</link>
		<comments>http://blog.o-x-t.com/2009/04/19/symfony-l10n-going-further/#comments</comments>
		<pubDate>Sun, 19 Apr 2009 20:39:16 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[l10n]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://blog.o-x-t.com/?p=180</guid>
		<description><![CDATA[As you may know symfony offers localized objects out of the box. It gives you an easy way to have different data for different cultures. Sometimes it is not enough. I needed two localized version of website but with completely different content &#8211; everything including users, admin and super admin. Both version were supposed to [...]]]></description>
			<content:encoded><![CDATA[<p>As you may know symfony offers localized objects out of the box. It gives you an easy way to have different data for different cultures.</p>
<p>Sometimes it is not enough. I needed two localized version of website but with completely different content &#8211; everything including users, admin and super admin. Both version were supposed to run under the same domain and to be distinguished just by locale part in the url. I was too lazy and didn&#8217;t want to copy applications or projects (moreover, it is a problem in the future, you&#8217;ll have to modify each copy). So, I decided to use different databases with exact schema for different cultures.</p>
<p>Here&#8217;s guide how to implement this.<br />
<span id="more-180"></span></p>
<p>First of all, I need to extract locale parameter from the url. That is easy, you&#8217;ll find it in the symfony docs.<br />
Routes config (routing.yml):</p>
<pre>
action:
  url:   /:locale/:module/:action/*
  requirements: {locale: nl|be}
</pre>
<p>I needed only NL and BE locales.</p>
<p>Then, you need to setup two databases. I was using symfony 1.1 with doctrine, but it should be possible for 1.2 also and propel or whatever ORM you are convenient with. Doctrine is able to work with multiple connections. However, I don&#8217;t need multiple connections. I need them both defined but I need only one current connection for every request. So I&#8217;m defining two connections but not specifying any binding to connection in model schema.<br />
Databases config (databases.yml):</p>
<pre>
all:
  belgium:
    class:          sfDoctrineDatabase
    param:
      dsn:          mysql://user_be:pass_be@host_be/db_be
  primary:
    class:          sfDoctrineDatabase
    param:
      dsn:          mysql://user_nl:pass_nl@host_nl/db_nl
</pre>
<p>If you check your application at this moment it will use connection last defined.</p>
<p>So, now I only need to switch between these connections. I can do it with filters.<br />
filters.yml:</p>
<pre>
rendering: ~
security:  ~
l10n:
  class: l10nFilter
cache:     ~
common:    ~
execution: ~
</pre>
<p>And the filter itself:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> l10nFilter <span style="color: #000000; font-weight: bold;">extends</span> sfFilter 
<span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> execute<span style="color: #009900;">&#40;</span><span style="color: #000088;">$filterChain</span><span style="color: #009900;">&#41;</span> 
  <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isFirstCall</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$locale</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getParameter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'locale'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #666666; font-style: italic;">//sanitize locale</span>
      <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUser</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'locale'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$locale</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$connection</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$locale</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'be'</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">'belgium'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'primary'</span><span style="color: #339933;">;</span>
      Doctrine_Manager<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setCurrentConnection</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$connection</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000088;">$filterChain</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>That&#8217;s it.</p>
<p>The small issue is that if you are going to use symfony db tasks (e.g. migrations or data population) you&#8217;ll need to set additional environments:<br />
databases.yml:</p>
<pre>
prod_be:
  primary:
    class:          sfDoctrineDatabase
    param:
      dsn:          mysql://user_be:pass_be@host_be/db_be
prod_nl:
  primary:
    class:          sfDoctrineDatabase
    param:
      dsn:          mysql://user_nl:pass_nl@host_nl/db_nl
</pre>
<p>And call your tasks twice for each pseudo-environment by adding &#8211;env=prod_be or &#8211;env=prod_nl.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.o-x-t.com/2009/04/19/symfony-l10n-going-further/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
