cvs: presentations / oscon_tut07.xml /slides/intro db_layer1.xml db_layer2.xml db_layer3.xml db_layer4.xml db_layer5.xml db_layer6.xml php_yui1.xml
php_yui2.xml php_yui3.xml php_yui4.xml php_yui5.xml pres2 display.php objects.php

From: Date: Sat, 21 Jul 2007 14:02:54 +0000
Subject: cvs: presentations / oscon_tut07.xml /slides/intro db_layer1.xml db_layer2.xml db_layer3.xml db_layer4.xml db_layer5.xml db_layer6.xml php_yui1.xml
php_yui2.xml php_yui3.xml php_yui4.xml php_yui5.xml pres2 display.php objects.php
Groups: php.pres 
Request: Send a blank email to pres+get-1414@lists.php.net to get a copy of this message
rasmus Sat Jul 21 14:02:54 2007 UTC Added files: /presentations oscon_tut07.xml /presentations/slides/intro db_layer1.xml db_layer2.xml db_layer3.xml db_layer4.xml db_layer5.xml db_layer6.xml php_yui1.xml php_yui2.xml php_yui3.xml php_yui4.xml php_yui5.xml Modified files: /pres2 objects.php display.php Log: Start of OSCON tut

http://cvs.php.net/viewvc.cgi/pres2/objects.php?r1=1.159&r2=1.160&diff_format=u Index: pres2/objects.php diff -u pres2/objects.php:1.159 pres2/objects.php:1.160 --- pres2/objects.php:1.159 Mon Oct 23 06:25:28 2006 +++ pres2/objects.php Sat Jul 21 14:02:53 2007 @@ -361,6 +361,12 @@ } } else { switch($this->type) { + case 'marked': + echo "<pre>"; + echo preg_replace('/^\|(.*)$/m','<font color="#802000">\1</font>',htmlspecialchars($this->text)); + echo "</pre>"; + break; + case 'php': if ($this->linenumbers) { $text = add_line_numbers($this->text); @@ -369,6 +375,7 @@ highlight_string($this->text); } break; + case 'shell': echo '<pre>'.markup_text(htmlspecialchars($this->text))."</pre>\n"; break; http://cvs.php.net/viewvc.cgi/pres2/display.php?r1=1.40&r2=1.41&diff_format=u Index: pres2/display.php diff -u pres2/display.php:1.40 pres2/display.php:1.41 --- pres2/display.php:1.40 Thu May 3 11:28:39 2007 +++ pres2/display.php Sat Jul 21 14:02:53 2007 @@ -512,21 +512,25 @@ break; } } else { - switch($example->type) { - default: - if (isset($example->encoding)) { - $example->text = iconv('utf8', $example->encoding, $example->text); - ob_start(); - eval('?>'.$example->text); - $result = ob_get_contents(); - ob_end_clean(); - echo iconv($example->encoding, 'utf8', $result); - } - else - { - eval('?>'.$example->text); - } - break; + if (isset($example->encoding)) { + $example->text = iconv('utf8', $example->encoding, $example->text); + ob_start(); + if($example->type=='marked') { + $text = preg_replace("/^\|/m","",$example->text); + eval('?>'.$text); + } else { + eval('?>'.$example->text); + } + $result = ob_get_contents(); + ob_end_clean(); + echo iconv($example->encoding, 'utf8', $result); + } else { + if($example->type=='marked') { + $text = preg_replace("/^\|/m","",$example->text); + eval('?>'.$text); + } else { + eval('?>'.$example->text); + } } } if ($this->pres->template == 'css' and (isset($example->class))) { http://cvs.php.net/viewvc.cgi/presentations/oscon_tut07.xml?view=markup&rev=1.1 Index: presentations/oscon_tut07.xml +++ presentations/oscon_tut07.xml <presentation template="php2" navmode="html" titlecolor="#1111aa" navbarbackground="url(images/trans-ffffff.png)" logo1="images/php-med-trans-light.gif" titlesize="2em" navbarheight="4.1em" > <topic>PHP</topic> <title>PHP/YUI</title> <subtitle>You got Javascript in my PHP! And...</subtitle> <event>OSCON 2007</event> <location>Portland</location> <date>July 23, 2007</date> <speaker>Thomas Sha, Rasmus Lerdorf</speaker> <url>http://talks.php.net/show/oscon_tut07</url> <slide>slides/intro/titlepage.xml</slide> <slide>slides/intro/php_yui1.xml</slide> <slide>slides/intro/php_yui2.xml</slide> <slide>slides/intro/php_yui3.xml</slide> <slide>slides/intro/php_yui4.xml</slide> <slide>slides/intro/php_yui5.xml</slide> <slide>slides/intro/security_title.xml</slide> <slide>slides/intro/xss_basic.xml</slide> <slide>slides/intro/xss_yrisk.xml</slide> <slide>slides/intro/input_filter2.xml</slide> <slide>slides/intro/xss_type1.xml</slide> <slide>slides/intro/xss_type2.xml</slide> <slide>slides/intro/xss_type3.xml</slide> <slide>slides/intro/xss_type4.xml</slide> <slide>slides/intro/xss_type5.xml</slide> <slide>slides/intro/xss_type6.xml</slide> <slide>slides/intro/xss_type7.xml</slide> <slide>slides/intro/xss_type8.xml</slide> <slide>slides/intro/the_web_is_broken.xml</slide> <slide>slides/intro/xsrf.xml</slide> <slide>slides/intro/db_layer1.xml</slide> <slide>slides/intro/db_layer2.xml</slide> <slide>slides/intro/db_layer3.xml</slide> <slide>slides/intro/db_layer4.xml</slide> <slide>slides/intro/db_layer5.xml</slide> <slide>slides/intro/db_layer6.xml</slide> <slide>slides/intro/web2_ref.xml</slide> </presentation> http://cvs.php.net/viewvc.cgi/presentations/slides/intro/db_layer1.xml?view=markup&rev=1.1 Index: presentations/slides/intro/db_layer1.xml +++ presentations/slides/intro/db_layer1.xml <slide title="DB Layer"> <break lines="1" /> <blurb fontsize="7em"> A simple abstract base class is the start of our Database layer </blurb> <example result="0" marginright="1em" fontsize="1.5"><![CDATA[<?php abstract class db { protected static $dbh = false; function connect() { self::$dbh = new PDO('sqlite:./people.db'); self::$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } ?>]]></example> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/intro/db_layer2.xml?view=markup&rev=1.1 Index: presentations/slides/intro/db_layer2.xml +++ presentations/slides/intro/db_layer2.xml <slide title="DB Layer"> <break lines="1" /> <blurb fontsize="7em"> This will help us track down problems during development </blurb> <example result="0" marginright="1em" fontsize="1.5"><![CDATA[<?php abstract class db { protected static $dbh = false; function connect() { self::$dbh = new PDO('sqlite:./people.db'); self::$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } protected function fatal_error($msg) { echo "<pre>Error!: $msg\n"; $bt = debug_backtrace(); foreach($bt as $line) { $args = var_export($line['args'], true); echo "{$line['function']}($args) at {$line['file']}:{$line['line']}\n"; } echo "</pre>"; die(); } ?>]]></example> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/intro/db_layer3.xml?view=markup&rev=1.1 Index: presentations/slides/intro/db_layer3.xml +++ presentations/slides/intro/db_layer3.xml <slide title="DB Layer"> <break lines="1" /> <blurb fontsize="7em"> For each table I usually do something like this </blurb> <example result="0" marginright="1em" fontsize="1.5"><![CDATA[<?php class people extends db { function load($id=-1) { $where = ''; if($id!=-1) $where = "where id=".(int)$id; try { if(!self::$dbh) $this->connect(); $result = self::$dbh->query("SELECT * FROM people $where"); $rows = $result->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { $this->fatal_error($e->getMessage()); } return $rows; } ?>]]></example> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/intro/db_layer4.xml?view=markup&rev=1.1 Index: presentations/slides/intro/db_layer4.xml +++ presentations/slides/intro/db_layer4.xml <slide title="DB Layer"> <break lines="1" /> <blurb fontsize="7em"> Prepare/execute example </blurb> <example result="0" marginright="1em" fontsize="1.5"><![CDATA[<?php class people extends db { function load($id=-1) { $where = ''; if($id!=-1) $where = "where id=".(int)$id; try { if(!self::$dbh) $this->connect(); $result = self::$dbh->query("SELECT * FROM people $where"); $rows = $result->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { $this->fatal_error($e->getMessage()); } return $rows; } function insert($p) { try { if(!self::$dbh) $this->connect(); $stmt = self::$dbh->prepare("INSERT INTO people (name,cvs_id,email,groups,language,lon,lat) VALUES (:name,:cvs_id,:email,:groups,:lang,:lon,:lat)"); $params = array(':name'=>$p['name'], ':cvs_id'=>$p['cvs_id'], ':email'=>$p['email'], ':groups'=>$p['groups'], ':lang'=>$p['langSearch'], ':lon'=>$p['longitude'], ':lat'=>$p['latitude']); $stmt->execute($params); $ret = self::$dbh->lastInsertId(); } catch (PDOException $e) { $this->fatal_error($e->getMessage()); } return $ret; } ?>]]></example> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/intro/db_layer5.xml?view=markup&rev=1.1 Index: presentations/slides/intro/db_layer5.xml +++ presentations/slides/intro/db_layer5.xml <slide title="DB Layer"> <break lines="1" /> <blurb fontsize="7em"> Using the DB layer </blurb> <example result="0" marginright="1em"><![CDATA[<?php include './db.inc'; include './db_people.inc'; $pep = new people; $all = $pep->load(); $lid = $pep->insert($_REQUEST); ?>]]></example> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/intro/db_layer6.xml?view=markup&rev=1.1 Index: presentations/slides/intro/db_layer6.xml +++ presentations/slides/intro/db_layer6.xml <slide title="DB Layer"> <break lines="1" /> <blurb fontsize="7em"> A complete DB/JSON backend </blurb> <example result="0" marginright="1em"><![CDATA[<?php include './db.inc'; include './db_people.inc'; $pep = new people; header("Content-type: application/json"); switch($_REQUEST['action']) { case 'markers': $all = $pep->load(); echo json_encode(array('people'=>$all)); break; } ?>]]></example> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/intro/php_yui1.xml?view=markup&rev=1.1 Index: presentations/slides/intro/php_yui1.xml +++ presentations/slides/intro/php_yui1.xml <slide title="Javascript invades"> <break lines="1" /> <blurb fontsize="7em"> You got Javascript in my PHP! And I am not happy about it. </blurb> <list> <bullet fontsize="3em">Javascript confuses me</bullet> <bullet fontsize="3em">It doesn't run on my server</bullet> <bullet fontsize="3em">I like my server</bullet> <bullet fontsize="3em">My server has my database</bullet> <bullet fontsize="3em">My application needs to run on my server</bullet> <bullet fontsize="3em">But my UI sucks</bullet> <bullet fontsize="3em">Javascript can fix my UI</bullet> <bullet fontsize="3em">The UI needs to manipulate the data</bullet> <bullet fontsize="3em">Half my application doesn't run on my server anymore</bullet> <bullet fontsize="3em">Javascript confuses me</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/intro/php_yui2.xml?view=markup&rev=1.1 Index: presentations/slides/intro/php_yui2.xml +++ presentations/slides/intro/php_yui2.xml <slide title="Taming the beast"> <break lines="1" /> <blurb fontsize="7em"> Javascript libraries to the rescue </blurb> <example result="1" fontsize="1.4em" rfontsize="1em" marginright="1em"><![CDATA[<script type="text/javascript" src="http://api.maps.yahoo.com/ajaxymap?v=3.7&appid=YahooDemo"></script> <div id="jsmapContainer" style="height: 500px; width: 930px;"></div> <script type="text/javascript"> var jsmap = new YMap('jsmapContainer'); jsmap.addZoomLong(); jsmap.drawZoomAndCenter("Portland, OR", 7); </script>]]></example> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/intro/php_yui3.xml?view=markup&rev=1.1 Index: presentations/slides/intro/php_yui3.xml +++ presentations/slides/intro/php_yui3.xml <slide title="Taming the beast"> <break lines="1" /> <blurb fontsize="7em"> Small changes, big rewards </blurb> <example result="1" fontsize="1.4em" rfontsize="1em" marginright="1em" type="marked"><![CDATA[<script type="text/javascript" src="http://api.maps.yahoo.com/ajaxymap?v=3.7&appid=YahooDemo"></script> <div id="jsmapContainer" style="height: 500px; width: 930px;"></div> <script type="text/javascript"> var jsmap = new YMap('jsmapContainer'); jsmap.addZoomLong(); |jsmap.addTypeControl(); jsmap.drawZoomAndCenter("Portland, OR", 7); </script>]]></example> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/intro/php_yui4.xml?view=markup&rev=1.1 Index: presentations/slides/intro/php_yui4.xml +++ presentations/slides/intro/php_yui4.xml <slide title="Building up"> <break lines="1" /> <example result="1" fontsize="1.4em" rfontsize="1em" marginright="1em" type="marked"><![CDATA[<script type="text/javascript" src="http://api.maps.yahoo.com/ajaxymap?v=3.7&appid=YahooDemo"></script> <div id="jsmapContainer" style="height: 500px; width: 930px;"></div> |<form id="locF" onSubmit="return updateMap();"> | <label for="loc">Location:<label> | <input type="text" name="loc" id="loc" size="80"/> |</form> <script type="text/javascript"> |var updateMap = function() { | var loc = document.getElementById('loc').value; | jsmap.drawZoomAndCenter(loc,7); | return false; |}; var jsmap = new YMap('jsmapContainer'); jsmap.addZoomLong(); jsmap.addTypeControl(); jsmap.drawZoomAndCenter("Portland, OR", 7); </script>]]></example> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/intro/php_yui5.xml?view=markup&rev=1.1 Index: presentations/slides/intro/php_yui5.xml +++ presentations/slides/intro/php_yui5.xml <slide title="Earthquakes!"> <break lines="1" /> <example result="1" fontsize="1.4em" rfontsize="1em" marginright="1em" type="marked"><![CDATA[<script type="text/javascript" src="http://api.maps.yahoo.com/ajaxymap?v=3.7&appid=YahooDemo"></script> <div id="jsmapContainer" style="height: 500px; width: 930px;"></div> <form id="locF" onSubmit="return updateMap();"> <label for="loc">Location:<label> <input type="text" name="loc" id="loc" size="80"/> </form> <script type="text/javascript"> var updateMap = function() { var loc = document.getElementById('loc').value; jsmap.drawZoomAndCenter(loc,7); return false; }; var jsmap = new YMap('jsmapContainer'); jsmap.addZoomLong(); jsmap.addTypeControl(); jsmap.drawZoomAndCenter("Portland, OR", 7); |jsmap.addOverlay(new YGeoRSS('http://earthquake.usgs.gov/eqcenter/catalogs/eqs7day-M2.5.xml')); </script>]]></example> </slide>
« previous php.pres (#1414) next »