<?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>[&#039;brein-jæk] &#187; PHP</title>
	<atom:link href="http://www.brain-jek.de/topics/coding/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brain-jek.de</link>
	<description>randomized bits and well-structured thoughts</description>
	<lastBuildDate>Fri, 24 Jul 2009 07:56:19 +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>Using dynamic javascript in Symfony</title>
		<link>http://www.brain-jek.de/2009/using-dynamic-javascript-in-symfony/</link>
		<comments>http://www.brain-jek.de/2009/using-dynamic-javascript-in-symfony/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 07:41:48 +0000</pubDate>
		<dc:creator>j.org</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.brain-jek.de/?p=183</guid>
		<description><![CDATA[This is definitly nothing average users or even average programmers have to know, but if you&#8217;re a Symfony developer this might come very handy and could save you hours of searching and evenings of frustration :) You are qualified if : You are developing an application within the Symfony framework You make heavy use of [...]]]></description>
			<content:encoded><![CDATA[<p>This is definitly nothing average users or even average programmers have to know, but if you&#8217;re a <a  title="The Symfony Project" href="http://www.symfony-project.org/">Symfony</a> developer this might come very handy and could save you hours of searching and evenings of frustration :)</p>
<p><span id="more-183"></span>You are qualified if :</p>
<ul>
<li>You are developing an application within the Symfony framework</li>
<li>You make heavy use of your own javascript files because you don&#8217;t want to produce that much inline javascript code</li>
<li>You really need to use <em>dynamic javascript</em>, maybe you want to integrate with the built-in i18n framework</li>
<li>You&#8217;ve never ever heard of dynamic_javacript_include_tag() and use_dynamic_javascript() or weren&#8217;t able to make them work</li>
</ul>
<p>So here is my solution:</p>
<p>The helper function &#8220;use_dynamic_javascript&#8221; just doesn&#8217;t work (or at least I wasn&#8217;t able get it to work). Lump it and dump it. We&#8217;ll use the other function, which does its job. Here&#8217;s how:</p>
<p>As we have to place our dynamic JS within an module you should decide which module you want to use, say we just need i18n in JS so let&#8217;s call it &#8220;modI18n&#8221;. Later we probably include more stuff in this module, so we won&#8217;t use the index action. Instead let&#8217;s create an empty action called &#8220;JsI18n&#8221;. You can obviously decide on your own whether you want to use a single file (JsI18nAction.class.php) or the gathering actions.class.php (function executeJsI18n) variant.</p>
<p>Next, create a template called &#8220;jsI18nSuccess.js.php&#8221;. You already know the rest, don&#8217;t you? This is the place where you can mix up Javascript and PHP, great! In my case this file looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">var i18n = {
  'Hello World': '<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Hello World'</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>'
}
function __(key) {
  return (i18n[key] ? i18n[key] : key );
}</pre></div></div>

<p>Almost finished, only  one point is left: How to actually include this? If you stick with the default routing, there&#8217;s nothing easier than that, just type</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> dynamic_javascipt_include_tag<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'modI18n/JsI18n'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>in the head section of your layout or anywhere in your template (the earlier the better) and you&#8217;re done. If you use custom routing rules, you may have to add a corresponding route for the action and use this route in the helper. Now you can easily access translated strings within Javascript with the well known __() function. Of course you have to maintain the template, however it seems this is worth the work.</p>
<p>Summing it up this is a bit more convenient than <a  title="Timo Haberkerns solution" href="http://www.symfony-zone.com/wordpress/2008/12/13/use-routing-to-server-localized-and-dynamic-javascript/">other methods</a>, but nevertheless you&#8217;ll end up writing many additional lines of code.</p>
<p>~~~Cheers</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brain-jek.de/2009/using-dynamic-javascript-in-symfony/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>[Release] Last.fm for Artists 0.7</title>
		<link>http://www.brain-jek.de/2009/release-lastfm-for-artists-07/</link>
		<comments>http://www.brain-jek.de/2009/release-lastfm-for-artists-07/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 08:21:45 +0000</pubDate>
		<dc:creator>j.org</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[last.fm]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[release]]></category>
		<category><![CDATA[widget]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.brain-jek.de/?p=163</guid>
		<description><![CDATA[Many of you might have been waiting for this release and right you are, because it&#8217;s fully packed with improvements: [fix] uninstall method changed [fix] another try to avoid doubled entries [fix] hide-if-empty was broken [add] now the plugin carries some cool ready-to-use layout variants (fully customizable, of course) [change] the built-in layouts now feature [...]]]></description>
			<content:encoded><![CDATA[<p>Many of you might have been waiting for <a  title="Download page, latest version" href="http://wordpress.org/extend/plugins/lastfm-for-artists/">this release</a> and right you are, because it&#8217;s fully packed with improvements:</p>
<ul>
<li>[fix] uninstall method changed</li>
<li>[fix] another try to avoid doubled entries</li>
<li>[fix] hide-if-empty was broken</li>
<li>[add] now the plugin carries some cool ready-to-use layout variants (fully customizable, of course)</li>
<li>[change] the built-in layouts now feature robust, CSS-driven tooltips</li>
<li>[add] there is a new special tag for variables %VARIABLE:&lt;name-of-variable&gt;:&lt;value-of-variable&gt;% which is only useful in built-in configurations and needed for things like API keys.
<ul>
<li>upon widget layout selection, this special tag is recognized and a javascript window pops out asking for the value. Up to now, only one variable per configuration is possible.</li>
<li>this gets used in the GoogleMaps event layouts to ask you for your domain-specific API-Key, which you can sign-up for <a  title="Google Maps API Signup" href="http://www.google.com/apis/maps/signup.html">here</a>.</li>
</ul>
</li>
</ul>
<p>It is important that you select a layout (or write you custom one) after changing type or adding a new widget, otherwise the formatting would be uninitialized and the widget will be empty.<br />
<span id="more-163"></span><br />
I hope I did not introduce new bugs and everybody is satisfied with this release. As of this version I am able to include arbitrarily many example configurations with the plugin, so here is another way to contribute: Submit your custom configuration or demand something specific I really should include in the next release.</p>
<p>Upgraders beware: I don&#8217;t think your customized widget configuration will get lost during the upgrade, but for increased safety you should make a backup.</p>
<p>Recently I was asked a support question considering the format of date (and time). As the industrious reader of readme files should know, this is currently handled by the translation files, what means tinkering around with it is not as easy as it should be, I guess. So in fact there are at least 5 affected tags (starttime, endtime, startdate, enddate, date) for which an elegant idea would be highly appreciated.</p>
<p>Last but not least I want to thank <a  title="..go to his homepage" href="http://knertz.de">#benniy</a> and ongonkov for making helpful bug reports.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brain-jek.de/2009/release-lastfm-for-artists-07/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>[release] Last.fm for Artists 0.6.1</title>
		<link>http://www.brain-jek.de/2009/release-lastfm-for-artists-061/</link>
		<comments>http://www.brain-jek.de/2009/release-lastfm-for-artists-061/#comments</comments>
		<pubDate>Sun, 11 Jan 2009 15:33:20 +0000</pubDate>
		<dc:creator>j.org</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[last.fm]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[release]]></category>
		<category><![CDATA[widget]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.brain-jek.de/?p=101</guid>
		<description><![CDATA[Finally I am proud to announce a new bright and shiny version of my Last.fm for Artists WordPress plug-in. The highlights of this release include: improved wordpress 2.7 compatibility (css, un-installation) further clarified options layout: Users reported to be overwhelmed by the number of options, so I split it up in normal and advanced options, [...]]]></description>
			<content:encoded><![CDATA[<p>Finally I am proud to announce a new bright and shiny version of my <a  title="The Plugin Page" href="http://www.brain-jek.de/wordpress/lastfm-for-artists/">Last.fm for Artists</a> WordPress plug-in. The highlights of this release include:</p>
<ul>
<li>improved wordpress 2.7 compatibility (css, un-installation)</li>
<li>further clarified options layout: Users reported to be overwhelmed by the number of options, so I split it up in normal and advanced options, utilizing the built-in thickbox script.</li>
</ul>
<p>So please download the new version via the<a  title="Wordpress plugin repository" href="http://wordpress.org/extend/plugins/lastfm-for-artists/"> wordpress plugin repository</a> (or the cool auto-update function) and report bugs in the <a  title="The official wordpress support forums" href="http://wordpress.org/tags/lastfm-for-artists">forums</a> or directly here.</p>
<p><strong>Upgraders pay attention:</strong> It&#8217;s most likely that your options get reset to default, so I recommend a backup. From version 0.6.1. on this should not happen anymore.</p>
<p>I&#8217;m planning to further de-complicate the usage of the plugin by including a few more sample configurations per widget type which might be selected via an additional option. Also I think there is a need for another widget type: &#8220;Top Tags&#8221; and/or &#8220;Related Artists&#8221; whose implementation won&#8217;t be very complicated.</p>
<p>~~~ Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brain-jek.de/2009/release-lastfm-for-artists-061/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing EGroupware</title>
		<link>http://www.brain-jek.de/2009/fixing-egroupware/</link>
		<comments>http://www.brain-jek.de/2009/fixing-egroupware/#comments</comments>
		<pubDate>Tue, 06 Jan 2009 17:33:04 +0000</pubDate>
		<dc:creator>j.org</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[bugfix]]></category>
		<category><![CDATA[egroupware]]></category>
		<category><![CDATA[groupware]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://www.brain-jek.de/?p=9</guid>
		<description><![CDATA[Recently I wanted to migrate an old and rather hacked installation of EGroupware 1.4.002 running on a home server to the bright and shiny version 1.6.001 on a webhosting server. If you are familiar with such stuff you possibly would have wished me good luck&#8230; Anyhow, I ran into quite a few problems, for some [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I wanted to migrate an old and rather hacked installation of <a  title="EGroupware homepage" href="http://egroupware.org/">EGroupware</a> 1.4.002 running on a home server to the bright and shiny version 1.6.001 on a webhosting server. If you are familiar with such stuff you possibly would have wished me good luck&#8230;</p>
<p>Anyhow, I ran into quite a few problems, for some of which I had to edit the source &#8211; and in case you&#8217;re also facing one or another of these, here are the solutions.<span id="more-9"></span></p>
<h3>Mass category assignments in the calendar</h3>
<p>One of the new features I really like &#8211; but which doesn&#8217;t work out-of-the-box. It came out that its a small typo bug, in egroupware/addressbook/inc/class.addressbook_ui.inc.php, rewrite line 1976 to:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>selbox<span style="color: #339933;">.</span>value <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;cat_add&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></pre></div></div>

<p>I don&#8217;t know why this made it in the release version, but as it was the bug which was easiest to fix, I don&#8217;t care.</p>
<h3>Email notifications</h3>
<p>I think you got this one only under following circumstances:</p>
<ol>
<li>You don&#8217;t use felamimail, but maybe you&#8217;ve tried &#8211; in my case it didn&#8217;t work because of some missing php-pear stuff.</li>
<li>Saving a item (an infolog entry in my case) which should trigger a notification works, but there is an unexpected halt while saving. That means you won&#8217;t get a confirmation, the window won&#8217;t close and will show an completely empty page.</li>
<li>No e-mail is sent ;)</li>
</ol>
<p>The solution is not so obvious and it took me about 5 hours of echo-debugging of quite some source files. The failure is, EGroupware checks for preferences of felamimail, and if it got them there is no fallback to your smpt configuration in your headers. But unfortunately EGroupware can obtain a preference-object of felamimail, but cannot obtain preferences out of it&#8230; That&#8217;s weird, uhm? So here is a solution.</p>
<p>Rewrite line 58  of file egroupware/phpgwapi/inc/class.send.inc.php to:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">//  if ($bopreferences) {</span></pre></div></div>

<p>This makes the fallback default and is a modification which will still use the fallback with <em>enabled</em> felamimail. Now you should be sure, that your SMTP settings in header.inc.php are correct and it should work. At least in my case it did. In case you get felamimail working don&#8217;t forget to undo this modification, since sending mail via one user&#8217;s smtp account feels a lot better.</p>
<h3>MyDMS enhancement</h3>
<p>This is not a bug, but an enhancement I already did to the old installation &#8211; so I had to re-enhance the new version (I worry that this won&#8217;t be the last feature I have to re-introduce). So MyDMS was used in favor of the file manager because of usability and revision management. Very handy came the possibility to link MyDMS documents from the wiki &#8211; but you had to decide for a specific version number. With this tiny enhancement, this is past. Just omit the version number within the download link and you will get the latest version. To get things going expand line 35 of file egroupware/mydms/op/op.Download.php to look like:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$version</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$document</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getLatestContent</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: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$document</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getContentByVersion</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$version</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And that&#8217;s it.</p>
<p>I hope you gained some insights, do not hesitate to ask questions but keep in mind that I do not offer general EGroupware support, which <a  title="Homepage of Stylite" href="http://www.stylite.de/?&#038;lang=en" target="_blank">Stylite</a> would be happy to be paid for.</p>
<p>~~~ Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brain-jek.de/2009/fixing-egroupware/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
