<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>Christoph Hautzinger's Blog - Javascript</title>
    <link>http://blog.hautzinger.info/</link>
    <description>Freakshow 2.0</description>
    <dc:language>de</dc:language>
    <generator>Serendipity 1.3.1 - http://www.s9y.org/</generator>
    <pubDate>Sat, 06 Oct 2007 15:28:55 GMT</pubDate>

    <image>
        <url>http://blog.hautzinger.info/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: Christoph Hautzinger's Blog - Javascript - Freakshow 2.0</title>
        <link>http://blog.hautzinger.info/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Webseitenüberschriften mittels Filter &quot;verschönern&quot;</title>
    <link>http://blog.hautzinger.info/archives/30-Webseitenueberschriften-mittels-Filter-verschoenern.html</link>
            <category>Javascript</category>
            <category>PHP</category>
            <category>Symfony</category>
    
    <comments>http://blog.hautzinger.info/archives/30-Webseitenueberschriften-mittels-Filter-verschoenern.html#comments</comments>
    <wfw:comment>http://blog.hautzinger.info/wfwcomment.php?cid=30</wfw:comment>

    <slash:comments>6</slash:comments>
    <wfw:commentRss>http://blog.hautzinger.info/rss.php?version=2.0&amp;type=comments&amp;cid=30</wfw:commentRss>
    

    <author>nospam@example.com (Christoph Hautzinger)</author>
    <content:encoded>
    Heute will ich etwas über Symfony Filter zum Besten geben. Vorab eine kleine Einführung zum &lt;a href=&quot;http://trac.symfony-project.com/wiki/sfTextReplacementPlugin&quot; target=&quot;_blank&quot;&gt;sfTextReplacementPlugin&lt;/a&gt;, welches es ermöglicht Text auf einer Website in einer beliebigen TTF-Schriftart als (cachbare) Grafik auszugeben um so beispielsweise h1/h2-Überschriften zu ersetzen. Die Einbindung erfolgt über einen simplen Funktionsaufruf, der an jeder gewünschten Stelle gemacht werden muss, hier ein Beispiel:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;php&quot; style=&quot;text-align: left&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; use_helper&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;TextReplacement&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;a href=&quot;http://www.php.net/echo&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt;&lt;/a&gt; graphical_text&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;Dies ist meine Überschrift&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;lt;p&amp;gt;hier fängt dann der Content der Seite an...&amp;lt;/p&amp;gt; &lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
Das Plugin bietet von Haus aus die Möglichkeit, die Seite nach dem Laden mit Hilfe des der &lt;em&gt;js_replace_text()&lt;/em&gt;Helper-Methode per Javascript zu durchsuchen um gewisse Tags durch die entsprechenden Bilder ersetzen zu lassen - doch was, wenn der Browser Javascript deaktiviert hat? Zudem wird hierbei ein zusätzliches Javascript File includiert was auch nicht unbedingt sein muss.&lt;br /&gt;
Für einen naiven Programmierer ist es natürlich ärgerlich, diese Replacements in ein großes Projekt zu integrieren weil er jede einzelne Überschrift durch den entsprechenden Funktionsaufruf ersetzt - viel eleganter geschieht dies mittels Filter. Da ich die Ersetzungen nur im Content Bereich der Webseite (also in dem Bereich, der auf jeder Seite anders ist) vorgenommen werden sollen, liegt es auf der Hand, eine abstrakte Klasse zu definieren, die eben diesen Bereich isoliert um ihn dann von einer Subklasse ersetzen zu lassen (eine zusätzliche Anforderung in diesem Projekt war nämlich das Ersetzen einzelner Wörter duch Wikipedia Links). Die (Super-)Klasse sieht in meinem Fall so aus:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;php&quot; style=&quot;text-align: left&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt; * abstract class to extract contents of template&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt; * &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt; * @author Christoph Hautzinger &amp;lt;mail at hautzinger.info&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt; */&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;abstract &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; ContentFilter extends sfFilter&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; protected &lt;span style=&quot;color: #0000ff;&quot;&gt;$content&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;#160; &amp;#160;* extracts pages main content and passes it to self::replace()&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;#160; &amp;#160;*&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;#160; &amp;#160;* @param sfFilter $filterChain&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;#160; &amp;#160;*/&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; public &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; execute&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$filterChain&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Execute next filter&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$filterChain&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;execute&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$timer&lt;/span&gt; = sfTimerManager::&lt;span style=&quot;color: #006600;&quot;&gt;getTimer&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/get_class&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;get_class&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039; Filter&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$response&lt;/span&gt; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;getContext&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;getResponse&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$content&lt;/span&gt; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$response&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;getContent&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$startMark&lt;/span&gt; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;&amp;lt;!-- ContentFilter:START --&amp;gt;&#039;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$stopMark&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;&amp;lt;!-- ContentFilter:STOP --&amp;gt;&#039;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// determine section where replacementes are done&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$startPos&lt;/span&gt; = &lt;a href=&quot;http://www.php.net/strpos&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;strpos&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$content&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$startMark&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$stopPos&lt;/span&gt;&amp;#160; = &lt;a href=&quot;http://www.php.net/strpos&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;strpos&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$content&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$stopMark&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$startPos&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; + &lt;a href=&quot;http://www.php.net/strlen&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;strlen&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$stopMark&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;content&lt;/span&gt; = &lt;a href=&quot;http://www.php.net/substr&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;substr&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$content&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$startPos&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$stopPos&lt;/span&gt; - &lt;span style=&quot;color: #0000ff;&quot;&gt;$startPos&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// do replacements&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;replace&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$response&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;setContent&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &lt;a href=&quot;http://www.php.net/substr&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;substr&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$content&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$startPos&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; . &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;content&lt;/span&gt; . &lt;a href=&quot;http://www.php.net/substr&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;substr&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$content&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$stopPos&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$timer&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;addTime&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;#160; &amp;#160;* should be overwritten in subclass&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;#160; &amp;#160;*/&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; abstract protected &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; replace&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt; Zu beachten ist hierbei, dass der Content im dem die Ersetzungen vorgenommen werden sollen im Template durch die beiden Kommentare &lt;em&gt;&amp;lt;!-- ContentFilter:START --&amp;gt;&lt;/em&gt; und &lt;em&gt;&amp;lt;!-- ContentFilter:STOP --&amp;gt;&lt;/em&gt; eingeschlossen werden muss. Der Code enthält keinerlei Magic und sollte auch ohne PHP-Kenntnisse leicht verständlich sein.&lt;br /&gt;
&lt;br /&gt;
Nun aber wieder zurück zum eigentlichen Problem: Wir haben nach einer Lösung gesucht, diese Ersetzungen global vorzunehmen und die sieht wie folgt aus:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;php&quot; style=&quot;text-align: left&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt; * replaces all h1, h2 tags with its adequate graphical_text()-call replacements&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt; * &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt; * @author Christoph Hautzinger &amp;lt;mail at hautzinger.info&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt; */&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; TextReplacementFilter extends ContentFilter &lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;#160; &amp;#160;* searches for all h1 and h2 tags and passes result to self::callbackHeadline()&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;#160; &amp;#160;*/&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; protected &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; replace&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; sfLoader::&lt;span style=&quot;color: #006600;&quot;&gt;loadHelpers&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;TextReplacement&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;content&lt;/span&gt; = &lt;a href=&quot;http://www.php.net/preg_replace_callback&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;preg_replace_callback&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;@&amp;lt;(h[12])&amp;gt;([^&amp;lt;]+)&amp;lt;/&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\\&lt;/span&gt;1&amp;gt;@i&#039;&lt;/span&gt;, &lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;callbackHeadline&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;content&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;#160; &amp;#160;* replace all matches with a specific h1 tag and our textreplacement-call&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;#160; &amp;#160;* @return string&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;#160; &amp;#160;*/&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; protected &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; callbackHeadline&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$matches&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;&amp;lt;h1&amp;gt;Google Searchword1, Google Searchword2: &#039;&lt;/span&gt;.&lt;span style=&quot;color: #0000ff;&quot;&gt;$matches&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;&amp;lt;/h1&amp;gt;&#039;&lt;/span&gt; . PHP_EOL .&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;graphical_text&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$matches&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;headline&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; .&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;&amp;lt;br/&amp;gt;&#039;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
Zusätzlich wird noch eine h1-Überschrift in das Dokument eingefügt, um eine bessere Indizierung durch Suchmaschinen zu gewährleisten - man darf natürlich nicht vergessen, sämtliche dieser &quot;speziellen&quot; h1 Tags per CSS auf &lt;em&gt;display: none&lt;/em&gt; zu setzen und den Filter in der filters.yml zu aktivieren.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Und wir sehen: Mit relativ wenig Code haben wir wieder sehr viel erreicht, wenn man die Vorzüge eines hervorragenden Frameworks nutzt. Sicherlich sind reguläre Ausdrücke langsam und preg_replace_callback noch langsamer - dennoch finde ich den Einsatz hier angebracht, zumal die Ausführung des Filters auf eine mittelgroße Seite angewandt nur ca. 6ms in Anspruch nimmt - und sollte sich später die gesamte Anwendung einmal wegen diesen 6ms aufhängen, so kann man immer noch ein Refactoring in Betracht ziehen und auf triviale Stringmanipulation umsteigen &lt;img src=&quot;http://blog.hautzinger.info/templates/default/img/emoticons/wink.png&quot; alt=&quot;;-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;.  
    </content:encoded>

    <pubDate>Sat, 06 Oct 2007 17:25:00 +0200</pubDate>
    <guid isPermaLink="false">http://blog.hautzinger.info/archives/30-guid.html</guid>
    
</item>
<item>
    <title>Javascript? Das ist doch Kindergeburtstag! Oder doch nicht!?</title>
    <link>http://blog.hautzinger.info/archives/28-Javascript-Das-ist-doch-Kindergeburtstag!-Oder-doch-nicht!.html</link>
            <category>Javascript</category>
    
    <comments>http://blog.hautzinger.info/archives/28-Javascript-Das-ist-doch-Kindergeburtstag!-Oder-doch-nicht!.html#comments</comments>
    <wfw:comment>http://blog.hautzinger.info/wfwcomment.php?cid=28</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://blog.hautzinger.info/rss.php?version=2.0&amp;type=comments&amp;cid=28</wfw:commentRss>
    

    <author>nospam@example.com (Christoph Hautzinger)</author>
    <content:encoded>
    Mir fällt immer wieder auf, dass es viele Web Developer gibt, die den Funktionsumfang von Javascript nicht kennen/nutzen, bzw. diese Sprache komplett unterschätzen - &quot;Ist ja nur eine kleine eingebettete Skriptsprache&quot;. Soeben bin ich auf den Blog von &lt;a href=&quot;http://ola-bini.blogspot.com/&quot; target=&quot;_blank&quot;&gt;Ola Bini&lt;/a&gt; gestossen, &lt;a href=&quot;http://ola-bini.blogspot.com/2007/09/javascript-ignorance.html&quot;&gt;in dem er sich wundert&lt;/a&gt;, dass man in Javascript beispielsweise über den Array-Operator auf die Methoden eines Objektes zugreifen kann.&lt;br /&gt;
&lt;br /&gt;
Bei Javascript handelt es sich (wie auch beispielsweise bei &lt;a href=&quot;http://de.wikipedia.org/wiki/Lisp&quot; target=&quot;_blank&quot;&gt;Lisp&lt;/a&gt;) um eine &lt;a href=&quot;http://de.wikipedia.org/wiki/Funktionale_Programmierung&quot; target=&quot;_blank&quot;&gt;Funktionale Sprache&lt;/a&gt;, was u.a. impliziert, dass Funktionsreferenzen als Parameter übergeben werden können, oder eine Funktion eine andere Funktion als Rückgabewert haben kann, wozu ich ein cooles Codebeispiel habe:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;javascript&quot; style=&quot;text-align: left&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; Configuration = &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;Class&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;create&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;Configuration.&lt;span style=&quot;color: #006600;&quot;&gt;prototype&lt;/span&gt; = &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; _config : &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;null&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; initialize: &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;config&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;._config = config;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; get: &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;key&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;vars&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;new&lt;/span&gt; Template&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;._config&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;key&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;evaluate&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;vars&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;bind&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;; &lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
Hierbei handelt es sich um ein der Anschaulichkeit vereinfaches Beispiel einer kleinen Template Engine in Javascript, da ich nach einer Möglichkeit gesucht habe, serverseitige Daten initial elegant an ein includiertes Javascriptfile zu übergeben. Aber ich will nicht vom Thema abschweifen... &lt;img src=&quot;http://blog.hautzinger.info/templates/default/img/emoticons/wink.png&quot; alt=&quot;;-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Schauen wir uns die &lt;em&gt;Configuration::get()&lt;/em&gt; Methode an - sie nimmt einen Parameter, der das Template mit einem sog. Hash (oder einem Schlüssel) identifiziert und sofort eine anonyme Funktion zurückgibt, die als Parameter ein JSON Objekt nimmt, welches der &lt;em&gt;evaluate()&lt;/em&gt; Methode aus Prototypes &lt;a href=&quot;http://prototypejs.org/api/template&quot; target=&quot;_blank&quot;&gt;Template-Klasse&lt;/a&gt; übergeben wird.&lt;br /&gt;
&lt;br /&gt;
Die anonyme Funktion tritt also erst in Aktion, nachdem sie explizit ausgeführt wird, wozu sie sich den Wert von &lt;em&gt;key&lt;/em&gt; in einem internen Funktionsenvironment speichern muss.&lt;br /&gt;
&lt;br /&gt;
Angenommen, wir hätten die Configuration bereits mit einem trivialen Template initialisiert, so können wir die anonyme Funktion über den entsprechenden Key abrufen und diese dann mit den Ersetzungswerten aufrufen:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;javascript&quot; style=&quot;text-align: left&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; cfg = &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;new&lt;/span&gt; Configuration&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;say_hallo: &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;Hallo #{firstname} #{lastname}, wie gehts?&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// fetch anonymous function&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; fn = cfg.&lt;span style=&quot;color: #006600;&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;say_hallo&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// call anonymous function&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; text = fn&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;firstname: &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;Marc&#039;&lt;/span&gt;, lastname: &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;Kreibich&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
Tja... und da Javascript wirklich so eine schöne Sprache ist, geht das natürlich auch noch einfacher, indem wir die anonyme Funktion direkt aufrufen, ohne sie in einer temporären Variablen zwischenzuspeichern:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;javascript&quot; style=&quot;text-align: left&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; text = cfg.&lt;span style=&quot;color: #006600;&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;say_hallo&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;firstname: &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;Marc&#039;&lt;/span&gt;, lastname: &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;Kreibich&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
Einer der vielen Gründe, wieso es sich lohnt sich mit Javascript einmal richtig auseinanderzusetzen!  
    </content:encoded>

    <pubDate>Fri, 21 Sep 2007 13:42:00 +0200</pubDate>
    <guid isPermaLink="false">http://blog.hautzinger.info/archives/28-guid.html</guid>
    
</item>
<item>
    <title>Google Maps Coordinate Picker</title>
    <link>http://blog.hautzinger.info/archives/23-Google-Maps-Coordinate-Picker.html</link>
            <category>diginights.com</category>
            <category>Javascript</category>
            <category>PHP</category>
            <category>Symfony</category>
    
    <comments>http://blog.hautzinger.info/archives/23-Google-Maps-Coordinate-Picker.html#comments</comments>
    <wfw:comment>http://blog.hautzinger.info/wfwcomment.php?cid=23</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://blog.hautzinger.info/rss.php?version=2.0&amp;type=comments&amp;cid=23</wfw:commentRss>
    

    <author>nospam@example.com (Christoph Hautzinger)</author>
    <content:encoded>
    Lets have a look at one &lt;a href=&quot;http://diginights.com/location/creme21.html&quot; target=&quot;_blank&quot;&gt;diginights location-detail page&lt;/a&gt;: There is a Google Map on the bottom of the page which displays the locations&#039; accurate position. The database-table therfore holds three columns: The two coordinate values for lattitude an longitude and the zoom factor.&lt;br /&gt;
&lt;br /&gt;
Our problem was the missing userfriendly admin interface, so i wrote a little class for this purpose which uses the Google Maps API to select a coordinate by double clicking the map. Additionaly an adress can be looked up which uses Google&#039;s Geocoder class internally.&lt;br /&gt;
&lt;br /&gt;
&lt;fieldset&gt;&lt;legend&gt;&lt;strong&gt;See the code in action&lt;/strong&gt;&lt;/legend&gt;&lt;script src=&quot;http://maps.google.com/maps?file=api&amp;amp;v=2&amp;amp;key=ABQIAAAA4qg3RjPmw94FWwwSfPHZjBTJ4WgYfy1epERbhjESjVKkK-giZBQ_peTKWrLb7P0z7pfACQnmqltvXg&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&lt;script src=&quot;http://diginights.com/sf/prototype/js/prototype.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&lt;script src=&quot;http://diginights.com/js/GMapsCoordPicker.class.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;lattitude: &lt;input type=&quot;text&quot; id=&quot;coordinate_x&quot; value=&quot;0&quot; /&gt; &lt;br /&gt;
longitude: &lt;input type=&quot;text&quot; id=&quot;coordinate_y&quot; value=&quot;0&quot; /&gt;&lt;br /&gt;
zoom: &lt;input type=&quot;text&quot; id=&quot;default_zoom&quot; value=&quot;0&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;width:100%;height:400px&quot;&gt;Zoom in first and then double click map to set coordinate!&lt;br /&gt;
&lt;div id=&quot;map&quot; style=&quot;width: 100%; height: 95%&quot;&gt;&lt;/div&gt;&lt;input type=&quot;text&quot; id=&quot;GMapCoordPickerQuery&quot; style=&quot;width:300px&quot; /&gt;&lt;input type=&quot;button&quot; onclick=&quot;gmcp.query($(&#039;GMapCoordPickerQuery&#039;).value)&quot; value=&quot;Lookup&quot; /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;script language=&quot;JavaScript&quot; &gt;gmcp = new GMapsCoordPicker(&#039;coordinate_x&#039;,&#039;coordinate_y&#039;,&#039;default_zoom&#039;,&#039;map&#039;); &lt;/script&gt;&lt;/fieldset&gt;&lt;br /&gt;
&lt;br /&gt;
Feel free to download all necessary files here: &lt;a href=&quot;http://blog.hautzinger.info/uploads/GMapsCoordPicker.zip&quot; title=&quot;GMapsCoordPicker.zip&quot; target=&quot;_blank&quot;&gt;GMapsCoordPicker.zip&lt;/a&gt;. The zip-archive contains 4 files:&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;GMapsCoordPicker.class.js&lt;/strong&gt;&lt;br /&gt;
Put this file in your project&#039;s javascript directory (/web/js), it handls client side logic.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;GoogleMapsHelper.php&lt;/strong&gt;&lt;br /&gt;
Put this file in your project&#039;s helper dir (/lib/helper). It supplies a helper function &lt;em&gt;google_maps_coord_picker()&lt;/em&gt;. The following example shows the usage in a symfony template:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;php&quot; style=&quot;text-align: left&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; use_helper&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;GoogleMaps&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;longitunde: &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;a href=&quot;http://www.php.net/echo&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt;&lt;/a&gt; input_tag&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;lon&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; ?&amp;gt;&amp;lt;br /&amp;gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;lattitude: &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;a href=&quot;http://www.php.net/echo&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt;&lt;/a&gt; input_tag&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;lat&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; ?&amp;gt;&amp;lt;br /&amp;gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;zoom: &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;a href=&quot;http://www.php.net/echo&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt;&lt;/a&gt; input_tag&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;zoom&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; ?&amp;gt;&amp;lt;br /&amp;gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;a href=&quot;http://www.php.net/echo&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt;&lt;/a&gt; google_maps_coord_picker&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;lon&#039;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;lat&#039;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;zoom&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt; &lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
This helper includes the Google Maps API, thus &lt;a href=&quot;http://www.google.com/apis/maps/signup.html&quot; target=&quot;_blank&quot;&gt;an API key has to be generated&lt;/a&gt; and set up in the application configuration (/apps/[appname]/config/app.yml):&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left&quot;&gt;&lt;ol&gt;# default values&lt;br /&gt;all:&lt;br /&gt;&amp;#160; google:&lt;br /&gt;&amp;#160; &amp;#160; api_key:&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;[your-api-key-here]&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;_google_maps_coordinate_picker.php&lt;/strong&gt;&lt;br /&gt;
To simply integrate in the admin generator, we need a tremplate that includes the helper showed above and displays the map. You have to replace the parameters passed to &lt;em&gt;google_maps_coord_picker()&lt;/em&gt; with the input field ids of your form. Note that symfony uses &lt;em&gt;object_input_tag()&lt;/em&gt; for its form elements which builds unconvenional form-field-ids.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;generator.yml&lt;/strong&gt;&lt;br /&gt;
This file displays the integration of _google_maps_coordinate_picker.php in the admin generator.  
    </content:encoded>

    <pubDate>Sun, 13 May 2007 17:38:16 +0200</pubDate>
    <guid isPermaLink="false">http://blog.hautzinger.info/archives/23-guid.html</guid>
    
</item>
<item>
    <title>Schnelle Webanwendungen mit Prototype und JSON</title>
    <link>http://blog.hautzinger.info/archives/11-Schnelle-Webanwendungen-mit-Prototype-und-JSON.html</link>
            <category>Javascript</category>
            <category>PHP</category>
            <category>Symfony</category>
    
    <comments>http://blog.hautzinger.info/archives/11-Schnelle-Webanwendungen-mit-Prototype-und-JSON.html#comments</comments>
    <wfw:comment>http://blog.hautzinger.info/wfwcomment.php?cid=11</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://blog.hautzinger.info/rss.php?version=2.0&amp;type=comments&amp;cid=11</wfw:commentRss>
    

    <author>nospam@example.com (Christoph Hautzinger)</author>
    <content:encoded>
    Da es ja heutzutage keine Webanwendung mehr ohne &lt;a href=&quot;http://de.wikipedia.org/wiki/Ajax_(Programmierung)&quot; target=&quot;_blank&quot;&gt;AJAX&lt;/a&gt; auskommt, will ich auch hierzu einen kleinen Blog-Eintrag verfassen. Das Prinzip, das hinter AJAX steht sollte ja allgemein geläufig sein: Man kann mittels Javascript eine Anfrage an den Server stellen ohne die komplette Seite neu laden zu müssen. Diese Art des Requests macht eine Webseite viel dynamischer - die Antwortzeiten werden kürzer da auch die übertragene Datenmenge abnimmt. Das &quot;A&quot; im Namen steht hierbei für &quot;asynchron&quot;, was soviel heißt, dass die JS-Anwendung nach Absetzen eines AJAX-Requests normal weiterarbeit und nicht direkt auf die Antwort des Servers wartet.&lt;br /&gt;
&lt;br /&gt;
Als fertiges Javascript Framework bietet sich &lt;a href=&quot;http://prototype.conio.net/&quot; target=&quot;_blank&quot;&gt;Prototype&lt;/a&gt; an, welches auch Ajax Funktionalität kapselt - hierzu seien die Klassen Ajax.Request und Ajax.Updater erwähnt - genauere Infos hierzu und zum gesamten Framework findet sich in der &lt;a href=&quot;http://www.sergiopereira.com/articles/prototype.js.html&quot; target=&quot;_blank&quot;&gt;inoffiziellen Dokumentation&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Hm... im Titel stand doch was von JSON?&lt;br /&gt;
&lt;br /&gt;
Angenommen wir haben eine komplexe Datenstruktur auf der Serverseite, die wir clientseitig verfügbar machen wollen, so kann dies sehr einfach mit Hilfe von JSON geschehen. Doch was ist JSON eigentlich? In der Wikipedia findet sich &lt;a href=&quot;http://de.wikipedia.org/wiki/JSON&quot; target=&quot;_blank&quot;&gt;dieser Artikel&lt;/a&gt; darüber. Es ist also eine Art Objektbeschreibung, mit der in Javascript (und auch in jeder anderen Sprache, die JSON unterstützen) direkt gearbeitet werden kann - viel einfacher und kleiner als ein XML-File mit selbem Inhalt.&lt;br /&gt;
&lt;br /&gt;
Am besten verständlich wird das an einem kleinen Beispiel:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;javascript&quot; style=&quot;text-align: left&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; lottery = &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; selectEvent: &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;eventid&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;new&lt;/span&gt; Ajax.&lt;span style=&quot;color: #006600;&quot;&gt;Request&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;/lottery/selectEvent.html&#039;&lt;/span&gt;, &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; method:&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;post&#039;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; parameters: &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;eventid=&#039;&lt;/span&gt;+eventid,&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; onSuccess: &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;res, json&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; $&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;title&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;value&lt;/span&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160;= json.&lt;span style=&quot;color: #006600;&quot;&gt;title&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; $&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;description&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;value&lt;/span&gt; = json.&lt;span style=&quot;color: #006600;&quot;&gt;description&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
Wir sehen einen Ajax-Request an /lottery/selectEvent.html, der nach Aufruf von lottery.selectEvent() ausgeführt wird. &lt;br /&gt;
Der Server antwortet nun mit einer Response, die von der Funktion, die unter &quot;onSuccess&quot; definiert ist asynchron verarbeitet wird. Als zweiten Parameter nimmt diese Funktion das Json Objekt, das vom Server gesendet wird.&lt;br /&gt;
&lt;br /&gt;
Um die Einfachheit des Ganzen begreifen zu können fehlt allerdings noch der Codeschnipsel, auf den der Frontcontroller den Request delegiert...&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;php&quot; style=&quot;text-align: left&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;public &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; executeSelectEvent&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$event&lt;/span&gt; = EventPeer::&lt;span style=&quot;color: #006600;&quot;&gt;retrieveByPk&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;getRequestParameter&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;eventid&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$forJSON&lt;/span&gt; = &lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;title&#039;&lt;/span&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160;=&amp;gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$event&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;getEventname&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;description&#039;&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$event&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;getInformation&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;parseJson&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$forJSON&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
Hier wird ein assoziatives Array zusammengekleistert, das die Daten enthält mit denen clientseitig gearbeitet werden soll und dieses der Funktion parseJson() übergeben, die in der Superklasse unsrer Action definiert ist:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;php&quot; style=&quot;text-align: left&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; myAction extends sfActions&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; protected &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; parseJson&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$forJson&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$json&lt;/span&gt; = json_encode&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$forJson&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;getResponse&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;setHttpHeader&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;X-JSON&#039;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;(&#039;&lt;/span&gt;.&lt;span style=&quot;color: #0000ff;&quot;&gt;$json&lt;/span&gt;.&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;)&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; sfView::&lt;span style=&quot;color: #006600;&quot;&gt;HEADER_ONLY&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: &#039;Courier New&#039;, Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
Unfairerweise kommt mein Blog mit &lt;a href=&quot;http://phpdoc.org/&quot;&gt;PHP-Doc Kommentaren&lt;/a&gt; in php-bb-Tags nicht klar, weshalb ich die In-Line Dokumentation zu beiden PHP Codestücken entfernt habe.&lt;br /&gt;
&lt;br /&gt;
Deutlich erkennbar allerdings, dass die parseJSON() Funktion intern json_encode() aufruft, welche man sich für sein PHP selber compilieren kann. Wie das genau geht und weitere Infos finden sich auf der Homepage von &lt;a href=&quot;http://www.aurore.net/projects/php-json/&quot; target=&quot;_blank&quot;&gt;Omar Kilani&lt;/a&gt;.&lt;br /&gt;
Gibts da nicht auch was von &lt;a href=&quot;http://pear.php.net&quot; target=&quot;_blank&quot;&gt;PEAR&lt;/a&gt;? Sicher gibt es das - allerdings kommt diese Version leider nicht mit ISO-8859-1 (besser gesagt mit &quot;nicht-UTF-8&quot;) klar, sodass man dazu noch über utf8_decode() einen Wrapper schreiben müsste.&lt;br /&gt;
&lt;br /&gt;
Unser Encodetes JSON-Objekt wird im Header der Response geliefert, vom Prototype korrekt ausgelesen und weiterverarbeitet wie man im ersten Codefetzen sieht.&lt;br /&gt;
&lt;br /&gt;
Schön nicht? &lt;img src=&quot;http://blog.hautzinger.info/templates/default/img/emoticons/wink.png&quot; alt=&quot;;-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;  
    </content:encoded>

    <pubDate>Mon, 08 Jan 2007 01:38:33 +0100</pubDate>
    <guid isPermaLink="false">http://blog.hautzinger.info/archives/11-guid.html</guid>
    
</item>
<item>
    <title>Javascript Fehlermeldung!?!?</title>
    <link>http://blog.hautzinger.info/archives/4-Javascript-Fehlermeldung!!.html</link>
            <category>Javascript</category>
    
    <comments>http://blog.hautzinger.info/archives/4-Javascript-Fehlermeldung!!.html#comments</comments>
    <wfw:comment>http://blog.hautzinger.info/wfwcomment.php?cid=4</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://blog.hautzinger.info/rss.php?version=2.0&amp;type=comments&amp;cid=4</wfw:commentRss>
    

    <author>nospam@example.com (Christoph Hautzinger)</author>
    <content:encoded>
    Beim Testen eines Scripts im Internet Explorer bekam ich gerade diese Fehlermeldung:&lt;br /&gt;
&lt;br /&gt;
&lt;!--s9ymdb:1--&gt;&lt;img width=&#039;436&#039; height=&#039;289&#039; style=&quot;float: left; border: 0px; padding-left: 5px; padding-right: 5px;&quot; src=&quot;http://blog.hautzinger.info/uploads/img/null_ist_null_oder_kein_objekt.jpg&quot; alt=&quot;&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
&#039;null&#039; scheint also NULL oder kein Objekt zu sein...&lt;br /&gt;
&lt;br /&gt;
...ahja &lt;img src=&quot;http://blog.hautzinger.info/templates/default/img/emoticons/wink.png&quot; alt=&quot;;-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;  
    </content:encoded>

    <pubDate>Thu, 14 Sep 2006 12:53:20 +0200</pubDate>
    <guid isPermaLink="false">http://blog.hautzinger.info/archives/4-guid.html</guid>
    
</item>
<item>
    <title>Software Engineering Professor nun auch unter den Bloggern</title>
    <link>http://blog.hautzinger.info/archives/3-Software-Engineering-Professor-nun-auch-unter-den-Bloggern.html</link>
            <category>Javascript</category>
            <category>Studium</category>
    
    <comments>http://blog.hautzinger.info/archives/3-Software-Engineering-Professor-nun-auch-unter-den-Bloggern.html#comments</comments>
    <wfw:comment>http://blog.hautzinger.info/wfwcomment.php?cid=3</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://blog.hautzinger.info/rss.php?version=2.0&amp;type=comments&amp;cid=3</wfw:commentRss>
    

    <author>nospam@example.com (Christoph Hautzinger)</author>
    <content:encoded>
    Heute will ich auf den Blog unseres coolsten Software Engineering-Profs verweisen - nämlich dem von Herrn Prof. Herzberg.&lt;br /&gt;
&lt;br /&gt;
Neben großer fachlicher Kompetenz hat er auch immer einen lockeren Spruch auf der Lippe, wie im vierten Semester in SEKS (Software Engineering komplexer Systeme):&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;Use Cases sind wie Selbstbefiedigung: Sie sind zwar schön und gut, bringen aber nichts.&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
Thematisch geht es in seinem Blog um interessante Geschichten aus der Informatik, worunter sich auch Themen befinden, die in seinen Vorlesungen abgehandelt werden, wie z.B. der Artikel über &lt;a href=&quot;http://denkspuren.blogspot.com/2006/08/netze-spannen-mit-design-by-contract.html&quot;&gt;Design by Contrast&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Hier der Link: &lt;a href=&quot;http://denkspuren.blogspot.com/index.html&quot;&gt;denkspuren&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Letzte Woche hab ich ein cooles Stückchen Javascript Code geschrieben, den ich hier auch noch bloggen möchte - das folgt diese Woche noch, wenn ich herausgefunden habe, wie man das geschickt machen kann &lt;img src=&quot;http://blog.hautzinger.info/templates/default/img/emoticons/wink.png&quot; alt=&quot;;-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;  
    </content:encoded>

    <pubDate>Tue, 12 Sep 2006 22:02:36 +0200</pubDate>
    <guid isPermaLink="false">http://blog.hautzinger.info/archives/3-guid.html</guid>
    
</item>

</channel>
</rss>