cvs: presentations / powerpear.xml /slides/powerpear agenda.xml break.xml cs1.xml devcom.xml distnet.xml errors1.xml errors2.xml errors3.xml
errors4.xml errors5.xml errors6.xml fast_logo.png fund.xml go-pear.xml intro1.xml intro2.xml intro3.xml intro4.xml licensing.xml obtaining.xml
packages1.xml packages2.xml titlepage.xml tools1.xml tools2.xml usinginstaller1.xml usinginstaller2.xml versioning.xml wiki-intro.xml
wiki-src-Wiki.php.xml wiki-src-edit.tpl.xml wiki-src-footer.tpl.xml wiki-src-header.tpl.xml wiki-src-index.php.xml wiki-src-node.tpl.xml
/slides/powerpear/examples/apache pearwiki.conf /slides/powerpear/examples/htdocs Wiki.php auth.php index.php pear-icon.png prepend.php
/slides/powerpear/examples/sql pearwiki.sql search.sql /slides/powerpear/examples/templates 404.tpl edit.tpl footer.tpl header.tpl home.tpl mail.tpl
node.tpl
| From: | Stig Bakken | Date: | Mon, 04 Nov 2002 07:05:14 +0000 |
| Subject: | cvs: presentations / powerpear.xml /slides/powerpear agenda.xml break.xml cs1.xml devcom.xml distnet.xml errors1.xml errors2.xml errors3.xml errors4.xml errors5.xml errors6.xml fast_logo.png fund.xml go-pear.xml intro1.xml intro2.xml intro3.xml intro4.xml licensing.xml obtaining.xml packages1.xml packages2.xml titlepage.xml tools1.xml tools2.xml usinginstaller1.xml usinginstaller2.xml versioning.xml wiki-intro.xml wiki-src-Wiki.php.xml wiki-src-edit.tpl.xml wiki-src-footer.tpl.xml wiki-src-header.tpl.xml wiki-src-index.php.xml wiki-src-node.tpl.xml /slides/powerpear/examples/apache pearwiki.conf /slides/powerpear/examples/htdocs Wiki.php auth.php index.php pear-icon.png prepend.php /slides/powerpear/examples/sql pearwiki.sql search.sql /slides/powerpear/examples/templates 404.tpl edit.tpl footer.tpl header.tpl home.tpl mail.tpl node.tpl |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-7284@lists.php.net to get a copy of this message | ||
ssb Mon Nov 4 02:05:14 2002 EDT
Added files:
/presentations powerpear.xml
/presentations/slides/powerpear agenda.xml break.xml cs1.xml
devcom.xml distnet.xml errors1.xml
errors2.xml errors3.xml errors4.xml
errors5.xml errors6.xml
fast_logo.png fund.xml go-pear.xml
intro1.xml intro2.xml intro3.xml
intro4.xml licensing.xml
obtaining.xml packages1.xml
packages2.xml titlepage.xml
tools1.xml tools2.xml
usinginstaller1.xml
usinginstaller2.xml versioning.xml
wiki-intro.xml
wiki-src-Wiki.php.xml
wiki-src-edit.tpl.xml
wiki-src-footer.tpl.xml
wiki-src-header.tpl.xml
wiki-src-index.php.xml
wiki-src-node.tpl.xml
/presentations/slides/powerpear/examples/apache pearwiki.conf
/presentations/slides/powerpear/examples/htdocs Wiki.php auth.php
index.php
pear-icon.png
prepend.php
/presentations/slides/powerpear/examples/sql pearwiki.sql
search.sql
/presentations/slides/powerpear/examples/templates 404.tpl edit.tpl
footer.tpl
header.tpl
home.tpl
mail.tpl
node.tpl
Log:
* PEAR Power Workshop slides
Index: presentations/powerpear.xml +++ presentations/powerpear.xml <presentation jskeyboard="1" template="php" logo1="/images/pear.png" logoimage1url="http://pear.php.net/" navbarbackground="#339900" backgroundcol="#f0f0f0" navsize="1.4em"> <title>Teach Yourself PEAR in 6 Hours</title> <topic>PEAR</topic> <event>International PHP Conference</event> <location>Frankfurt</location> <date>2002-11-03</date> <speaker>Stig Bakken</speaker> <company>Fast Search & Transfer</company> <email>ssb@fast.no</email> <url>http://conf.php.net/</url> <slide>slides/powerpear/titlepage.xml</slide> <slide>slides/powerpear/agenda.xml</slide> <slide>slides/powerpear/intro1.xml</slide> <slide>slides/powerpear/intro2.xml</slide> <slide>slides/powerpear/intro3.xml</slide> <slide>slides/powerpear/intro4.xml</slide> <slide>slides/powerpear/packages1.xml</slide> <slide>slides/powerpear/packages2.xml</slide> <slide>slides/powerpear/versioning.xml</slide> <slide>slides/powerpear/cs1.xml</slide> <slide>slides/powerpear/tools1.xml</slide> <slide>slides/powerpear/tools2.xml</slide> <slide>slides/powerpear/distnet.xml</slide> <slide>slides/powerpear/devcom.xml</slide> <slide>slides/powerpear/licensing.xml</slide> <slide>slides/powerpear/break.xml</slide> <slide>slides/powerpear/obtaining.xml</slide> <slide>slides/powerpear/go-pear.xml</slide> <slide>slides/powerpear/usinginstaller1.xml</slide> <slide>slides/powerpear/usinginstaller2.xml</slide> <slide>slides/powerpear/fund.xml</slide> <slide>slides/powerpear/errors1.xml</slide> <slide>slides/powerpear/errors2.xml</slide> <slide>slides/powerpear/errors3.xml</slide> <slide>slides/powerpear/errors4.xml</slide> <slide>slides/powerpear/errors5.xml</slide> <slide>slides/powerpear/errors6.xml</slide> <slide>slides/powerpear/wiki-intro.xml</slide> <slide>slides/powerpear/wiki-src-index.php.xml</slide> <slide>slides/powerpear/wiki-src-Wiki.php.xml</slide> <slide>slides/powerpear/wiki-src-node.tpl.xml</slide> <slide>slides/powerpear/wiki-src-header.tpl.xml</slide> <slide>slides/powerpear/wiki-src-footer.tpl.xml</slide> <slide>slides/powerpear/wiki-src-edit.tpl.xml</slide> </presentation> Index: presentations/slides/powerpear/agenda.xml +++ presentations/slides/powerpear/agenda.xml <slide title="(Power) Agenda"> <list fontsize="6em"> <bullet>(Power) Introduction to PEAR</bullet> <bullet>Obtaining PEAR</bullet> <bullet>Using the Installer</bullet> <bullet>PEAR Fundamentals</bullet> <bullet>Demo: PEAR Wiki</bullet> <bullet>Wiki Hacking</bullet> <bullet>Questions / Ideas</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/break.xml +++ presentations/slides/powerpear/break.xml <slide title="Break Time!"> <list fontsize="5em"> <title>Stretch Your Feet!</title> </list> </slide> Index: presentations/slides/powerpear/cs1.xml +++ presentations/slides/powerpear/cs1.xml <slide title="PEAR Coding Standard"> <list fontsize="5em" effect="hide"> <bullet>Indentation: 4 spaces</bullet> <bullet>Package Naming: Foo, Foo_Bar</bullet> <bullet>Symbol Naming:</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>Functions: Package_function()</bullet> <bullet>Classes: Package, Package_Anotherclass</bullet> <bullet>Methods: public(), publicMethod(), _privateMethod()</bullet> <bullet>Globals: $_Package_globalname</bullet> <bullet>Constants: PACKAGE_CONSTANT</bullet> </list> <list fontsize="5em" effect="hide"> <bullet>PhpDoc Comments</bullet> <bullet>Including PEAR Code</bullet> <bullet>Use of PHP Short Tags</bullet> <bullet>Handling php.ini Settings</bullet> <bullet>CVS Rules (for cvs.php.net)</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/devcom.xml +++ presentations/slides/powerpear/devcom.xml <slide title="PEAR Developer Community"> <list fontsize="6em" effect="hide"> <bullet>pear-general@lists.php.net</bullet> </list> <list marginleft="2em" fontsize="5em" effect="hide"> <bullet>For users of PEAR packages</bullet> <bullet>General questions</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>pear-dev@lists.php.net</bullet> </list> <list marginleft="2em" fontsize="5em" effect="hide"> <bullet>For developers of PEAR packages</bullet> <bullet>Package Naming Discussions</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/distnet.xml +++ presentations/slides/powerpear/distnet.xml <slide title="PEAR Package Registry"> <list fontsize="6em" effect="hide"> <bullet>pear.php.net</bullet> <bullet>HTML interface</bullet> </list> <list marginleft="2em" fontsize="5em" effect="hide"> <bullet>Documentation</bullet> <bullet>Release Uploads</bullet> <bullet>Package Browsing</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>XML-RPC interface</bullet> </list> <list marginleft="2em" fontsize="5em" effect="hide"> <bullet>browsing, retrieving info</bullet> <bullet>manage releases</bullet> <bullet>list upgrades</bullet> <bullet>misc. administration methods</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/errors1.xml +++ presentations/slides/powerpear/errors1.xml <slide title="PEAR Errors"> <list fontsize="5em"> <bullet>How to distinguish an error?</bullet> <bullet>Errors as types</bullet> <bullet>Classes are types</bullet> <bullet>Exceptions coming in PHP 5</bullet> <bullet>Forward compatibility</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/errors2.xml +++ presentations/slides/powerpear/errors2.xml <slide title="PEAR Errors (2)"> <list fontsize="5em"> <bullet>PEAR::raiseError()</bullet> </list> <example type="php"> <text><![CDATA[ if (!@fopen($file, "r")) { return PEAR::raiseError($php_errormsg); } ]]></text></example> <list fontsize="5em"> <bullet>PEAR::isError()</bullet> </list> <example type="php"> <text><![CDATA[ $res = open_file(); if (PEAR::isError($res)) { die("Couldn't open file: " . $res->getMessage()); } ]]></text></example> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/errors3.xml +++ presentations/slides/powerpear/errors3.xml <slide title="PEAR::isError"> <list fontsize="5em"> <bullet>PEAR::isError() Implementation</bullet> </list> <example type="php"> <text><![CDATA[ function isError($data) { return (bool)(is_object($data) && (get_class($data) == 'pear_error' || is_subclass_of($data, 'pear_error'))); } ]]></text></example> <list fontsize="5em"> <bullet>PEAR_Error may be subclassed</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/errors4.xml +++ presentations/slides/powerpear/errors4.xml <slide title="PEAR::raiseError"> <list fontsize="5em"> <bullet>Called statically</bullet> </list> <example type="php"> <text><![CDATA[ if (datacenter_is_burning()) { PEAR::raiseError("power failure imminent"); } ]]></text></example> <list fontsize="5em"> <bullet>Called as part of object</bullet> </list> <example type="php"> <text><![CDATA[ if ($this->datacenterIsBurning()) { return $this->raiseError("CPU on fire"); } ]]></text></example> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/errors5.xml +++ presentations/slides/powerpear/errors5.xml <slide title="PEAR::setErrorHandling"> <list fontsize="6em"> <bullet>Global default handling</bullet> </list> <example type="php"> <text><![CDATA[ PEAR::setErrorHandling(PEAR_ERROR_DIE); ]]></text></example> <list fontsize="6em"> <bullet>Per-object default handling</bullet> </list> <example type="php"> <text><![CDATA[ $object->setErrorHandling(PEAR_ERROR_DIE, "<blink>%s</blink>"); ]]></text></example> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/errors6.xml +++ presentations/slides/powerpear/errors6.xml <slide title="Error Modes"> <list fontsize="6em" effect="hide"> <bullet>PEAR_ERROR_RETURN</bullet> <bullet>PEAR_ERROR_PRINT</bullet> <bullet>PEAR_ERROR_DIE</bullet> <bullet>PEAR_ERROR_TRIGGER</bullet> <bullet>PEAR_ERROR_CALLBACK</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/fund.xml +++ presentations/slides/powerpear/fund.xml <slide title="Including Files"> <list fontsize="6em" effect="hide"> <bullet>Including Files</bullet> </list> <list fontsize="4em" marginleft="2em" effect="hide"> <bullet>Use include_path</bullet> <bullet>require_once / include_once</bullet> <bullet>always include what you use</bullet> <bullet>(do not include what you do not use)</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>Why dirname(__FILE__) is bad</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/go-pear.xml +++ presentations/slides/powerpear/go-pear.xml <slide title="go-pear"> <list fontsize="6em" effect="hide"> <bullet>Requires CLI/CGI version of PHP</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>PHP 4.2.x: configure ... --enable-cli</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>go-pear</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>%lynx -source go-pear.org | php%</bullet> <bullet>Up to date!</bullet> <bullet>Web version available</bullet> <bullet>Doesn't work too great on Windows/MacOS X yet</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>Demonstration</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/intro1.xml +++ presentations/slides/powerpear/intro1.xml <slide title="What is PEAR?"> <list fontsize="5em" effect="hide"> <bullet>PHP Extension and Application Repository</bullet> <bullet>PHP Extension Code Library (PECL)</bullet> <bullet>Coding Standards</bullet> <bullet>Versioning Standards</bullet> <bullet>Package Concept</bullet> <bullet>Package Format</bullet> <bullet>Installation Tools</bullet> <bullet>Package Registry</bullet> <bullet>Developer Community</bullet> <bullet>Licensing Options</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/intro2.xml +++ presentations/slides/powerpear/intro2.xml <slide title="PHP Ext. and App. Repository"> <list fontsize="5em" effect="hide"> <bullet>Code Follows PEAR Coding Standards</bullet> <bullet>Currently Only PHP Code</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>Nothing stopping PEAR C modules</bullet> <bullet>Naming Standards Still Apply</bullet> </list> <list fontsize="5em" effect="hide"> <bullet>Package Name Management</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>Discussion/voting on pear-dev</bullet> </list> <list fontsize="5em" effect="hide"> <bullet>Example packages</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>Auth, Cache, Date, DB, File_Find</bullet> <bullet>HTML_Table, HTML_Template_IT, HTTP_Request</bullet> <bullet>HTTP_WebDav_Server, I18N, Image_Transform</bullet> <bullet>Inline_C, Log, Mail_Mime, Math, MDB, Net_DNS</bullet> <bullet>Net_POP3, LiveUser, SOAP, SQL_Parser</bullet> <bullet>XML_Parser, XML_Transformer, XML_Tree, +++</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/intro3.xml +++ presentations/slides/powerpear/intro3.xml <slide title="PECL (PHP Extension Code Library)"> <list fontsize="5em" effect="hide"> <bullet>PHP Extensions Written in C/C++</bullet> <bullet>Code Follows PHP Coding Standards</bullet> <bullet>Many PHP Extensions Will Move to PECL</bullet> <bullet>Example packages</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>apc, apd, bcompiler</bullet> <bullet>iisfunc, printer, ixsfunc</bullet> <bullet>mailparse, phpdoc, python, satellite</bullet> <bullet>session_pgsql, soap, threads, xmms</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/intro4.xml +++ presentations/slides/powerpear/intro4.xml <slide title="PFC (PHP Foundation Classes)"> <list fontsize="6em" effect="hide"> <bullet>Not Yet Defined^tm^</bullet> <bullet>Core Subset of PEAR</bullet> <bullet>Additional QA on APIs and Design</bullet> <bullet>Interoperability</bullet> <bullet>Integration Testing</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/licensing.xml +++ presentations/slides/powerpear/licensing.xml <slide title="Licensing Options"> <list fontsize="5em" effect="hide"> <bullet>PHP License Recommended</bullet> <bullet>GPL problems</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>C code: PHP/GPL licenses incompatible</bullet> <bullet>PHP code: not really resolved</bullet> <bullet>Applies for _distribution_</bullet> </list> <list fontsize="5em" effect="hide"> <bullet>Compatible Licenses:</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>Lesser/Library GPL</bullet> <bullet>Apache / BSD</bullet> <bullet>MPL / QPL</bullet> </list> <list fontsize="5em" effect="hide"> <bullet>PEAR Tools are general</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>May be used to manage in-house packages</bullet> <bullet>Install from any URL</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/obtaining.xml +++ presentations/slides/powerpear/obtaining.xml <slide title="Obtaining PEAR"> <list fontsize="6em" effect="hide"> <bullet>Bundled with PHP</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>Lags behind (PHP RC takes too long)</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>go-pear</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>%lynx -source go-pear.org | php%</bullet> <bullet>Up to date!</bullet> <bullet>Web version available</bullet> <bullet>Doesn't work too great on Windows/MacOS X yet</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/packages1.xml +++ presentations/slides/powerpear/packages1.xml <slide title="Package Concept"> <list fontsize="6em" effect="hide"> <bullet>PEAR Packages</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>Small Independent Projects</bullet> <bullet>Registered on pear.php.net</bullet> <bullet>Distributed and Installed Separately</bullet> <bullet>State: alpha, beta, stable, snapshot, devel</bullet> <bullet>Leads, developers, helpers</bullet> <bullet>Code Organization</bullet> <bullet>Available through Releases</bullet> <bullet>Dependencies: pkg, ext, php, prog, os, sapi, zend, rtlib</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/packages2.xml +++ presentations/slides/powerpear/packages2.xml <slide title="Package Concept (2)"> <list fontsize="6em" effect="hide"> <bullet>Why not use .rpm/.deb/.jar/.xyz?</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>Portability</bullet> <bullet>Integration the wrong way</bullet> <bullet>Need specialized tools anyway</bullet> <bullet>Design for wrapping in other formats</bullet> <bullet>Proof of concept: "pear makerpm"</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/titlepage.xml +++ presentations/slides/powerpear/titlepage.xml <slide template="titlepage" fontsize="6em"> <title>Welcome!</title> </slide> Index: presentations/slides/powerpear/tools1.xml +++ presentations/slides/powerpear/tools1.xml <slide title="PEAR Tools"> <list fontsize="6em" effect="hide"> <bullet>The PEAR Installer</bullet> </list> <list marginleft="2em" fontsize="5em" effect="hide"> <bullet>Uses the PEAR Package Format</bullet> <bullet>Cross-Platform</bullet> <bullet>Multiple User Interfaces (CLI, Gtk, Web)</bullet> <bullet>Can be wrapped in for example RPM</bullet> <bullet>Queries central package registry</bullet> <bullet>Builds extensions from source</bullet> <bullet>MD5 checksums and GPG signatures</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/tools2.xml +++ presentations/slides/powerpear/tools2.xml <slide title="PEAR Tools (2)"> <list fontsize="6em" effect="hide"> <bullet>PEAR Installer Functions:</bullet> </list> <list marginleft="2em" fontsize="5em" effect="hide"> <bullet>install / upgrade / uninstall / download</bullet> <bullet>list upgrades</bullet> <bullet>upgrade-all</bullet> <bullet>package, sign and release packages</bullet> <bullet>generate RPM spec files</bullet> <bullet>browse locally installed packages</bullet> <bullet>browse remotely available packages</bullet> <bullet>search package registry</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/usinginstaller1.xml +++ presentations/slides/powerpear/usinginstaller1.xml <slide title="Using the Installer (1)"> <list fontsize="6em" effect="hide"> <bullet>Inventory</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>%pear list%</bullet> <bullet>%pear info //Package//%</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>New Packages</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>%pear install Package%</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>Catching Up</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>%pear upgrade-all%</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>Cleaning House</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>%pear uninstall Package%</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>Demonstration</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/usinginstaller2.xml +++ presentations/slides/powerpear/usinginstaller2.xml <slide title="Using the Gtk Installer"> <list fontsize="6em" effect="hide"> <bullet>Requires PHP-GTK</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>Not available though PECL, yet</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>Installing the Gtk Installer UI</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>%pear install PEAR_Frontend_Gtk%</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>Demonstration</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/versioning.xml +++ presentations/slides/powerpear/versioning.xml <slide title="Versioning Standard"> <list fontsize="6em" effect="hide"> <bullet>Why Standardize?</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>Common Perception of What X.Y Means</bullet> <bullet>Tools Need to Compare Versions</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>major [.minor [.patch]] [pre]</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>"major" version: numeric, 0 means "experimental"</bullet> <bullet>"minor" version: new features ok, BC maintained</bullet> <bullet>"patch" version: bug fixes, tiny changes</bullet> <bullet>"pre" element: {dev,a,b,RC,pl}//N//</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>Comparing:</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>version_compare() function (from PHP 4.1.0)</bullet> <bullet>0.x < 1.x < 2.x ...</bullet> <bullet>0.1 < 0.9 < 0.10 < 1.0 ...</bullet> <bullet>1.0dev1 < 1.0a1 < 1.0b1 < 1.0RC1 < 1.0 < 1.0pl1</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/wiki-intro.xml +++ presentations/slides/powerpear/wiki-intro.xml <slide title="Case Study: PEAR Wiki"> <list fontsize="6em" effect="hide"> <bullet>Starting Simple:</bullet> </list> <list marginleft="2em" fontsize="5em" effect="hide"> <bullet>One MySQL table</bullet> <bullet>View Page</bullet> <bullet>Edit Page</bullet> </list> <example effect="slide"> <title>mywiki.sql</title> <filename>examples/sql/mywiki.sql</filename> </example> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/wiki-src-Wiki.php.xml +++ presentations/slides/powerpear/wiki-src-Wiki.php.xml <slide title="PEAR Wiki: Wiki.php"> <example type="php"> <title>Wiki.php</title> <filename>examples/htdocs/Wiki.php</filename> </example> </slide> Index: presentations/slides/powerpear/wiki-src-edit.tpl.xml +++ presentations/slides/powerpear/wiki-src-edit.tpl.xml <slide title="PEAR Wiki: edit.tpl"> <example> <title>edit.tpl</title> <filename>examples/templates/edit.tpl</filename> </example> </slide> Index: presentations/slides/powerpear/wiki-src-footer.tpl.xml +++ presentations/slides/powerpear/wiki-src-footer.tpl.xml <slide title="PEAR Wiki: footer.tpl"> <example> <title>footer.tpl</title> <filename>examples/templates/footer.tpl</filename> </example> </slide> Index: presentations/slides/powerpear/wiki-src-header.tpl.xml +++ presentations/slides/powerpear/wiki-src-header.tpl.xml <slide title="PEAR Wiki: header.tpl"> <example> <title>header.tpl</title> <filename>examples/templates/header.tpl</filename> </example> </slide> Index: presentations/slides/powerpear/wiki-src-index.php.xml +++ presentations/slides/powerpear/wiki-src-index.php.xml <slide title="PEAR Wiki: index.php"> <example type="php"> <title>index.php</title> <filename>examples/htdocs/index.php</filename> </example> </slide> Index: presentations/slides/powerpear/wiki-src-node.tpl.xml +++ presentations/slides/powerpear/wiki-src-node.tpl.xml <slide title="PEAR Wiki: node.tpl"> <example> <title>node.tpl</title> <filename>examples/templates/node.tpl</filename> </example> </slide> Index: presentations/slides/powerpear/examples/apache/pearwiki.conf +++ presentations/slides/powerpear/examples/apache/pearwiki.conf <VirtualHost *> ServerName pearwiki.localdomain DirectoryIndex index.php DocumentRoot /home/ssb/cvs/php/pres2/presentations/slides/powerpear/examples/htdocs php_flag register_globals on php_value include_path .:/home/ssb/cvs/php/pres2/presentations/slides/powerpear/examples:/usr/share/pear php_value error_reporting 7 php_value auto_prepend_file prepend.php ErrorDocument 404 /error-404.php </VirtualHost> Index: presentations/slides/powerpear/examples/htdocs/Wiki.php +++ presentations/slides/powerpear/examples/htdocs/Wiki.php <?php class Wiki { function matchWord($word) { return preg_match('^[A-Z]+[a-z]+[A-Za-z0-9]*$', $word); } function formatWord($word) { $word = preg_replace('/([a-z])([A-Z])/', '\1 \2', $word); $word = preg_replace('/([a-zA-Z])(\d)/', '\1 \2', $word); return $word; } function process($contents) { if (preg_match_all('/{([a-z-]+)\s*([^}]*?)}/s', $contents, $matches)) { list($strings, $funcs, $args) = $matches; for ($i = 0; $i < sizeof($strings); $i++) { $replace = Wiki::runMacro($funcs[$i], $args[$i]); $contents = str_replace($strings[$i], $replace, $contents); } } if (preg_match_all('#\b([A-Z]+[a-z]+[A-Z\d][A-Za-z\d]*)\b#s', $contents, $matches)) { list($strings, $nodes) = $matches; $self = $_SERVER['SCRIPT_NAME']; for ($i = 0; $i < sizeof($strings); $i++) { // if (Wiki::nodeExists($nodes[$i])) { $spaced = Wiki::formatWord($nodes[$i]); $replace = "<a href=\"{$self}/{$nodes[$i]}\">$spaced</a>"; $contents = str_replace($strings[$i], $replace, $contents, 1); // } } } //$contents = str_replace('@@@', "{$self}/", $contents); return nl2br($contents); } function nodeExists($node) { static $cache = array(); if (isset($cache[$node])) { return $cache[$node]; } global $dbh; $id = $dbh->getOne('SELECT id FROM nodes WHERE name = ?', $node); if ($id !== null) { $cache[$node] = $id; } return (bool)$id; } function runMacro($func, $arg) { global $dbh; $ret = ''; switch ($func) { case 'list': $arg = str_replace('?', '_', $arg); $arg = str_replace('*', '%', $arg); $sql = "SELECT name FROM nodes WHERE name LIKE '$arg'"; // catch errors $dbh->pushErrorHandling(PEAR_ERROR_RETURN); $nodes = $dbh->getCol($sql, 0); $dbh->popErrorHandling(); if (is_array($nodes)) { $ret = implode("\n", $nodes); } break; case 'phpdoc': $url = "http://php.net/$arg"; $ret = "<a href=\"$url\">$arg (php.net)</a>"; break; case 'pear-listall': include_once "PEAR/Config.php"; include_once "PEAR/Remote.php"; $config = &PEAR_Config::singleton(); @$remote =& new PEAR_Remote($config); @$packages = $remote->call('package.listAll'); $ret = implode("\n", array_keys($packages)); break; case 'recent': include_once "Date.php"; $arg = (int)$arg; $res = $dbh->limitQuery("SELECT name, mtime FROM nodes ORDER BY mtime DESC", 0, $arg); $ret = ''; while ($res->fetchInto($tmp)) { $date = new Date($tmp['mtime']); $ret .= "$tmp[name] " . $date->getDate() . "\n"; } $res->free(); break; } return $ret; } function displayEditor(&$tpl, $node) { $tpl->loadTemplatefile('edit.tpl'); if ($node != '__new__') { $contents = Wiki::getNodeContents($node); } if ($contents === null) { // new node $tpl->setVariable("NewOrEdit", "New"); $nodename = "new node"; if ($node == '__new__') { $node = ""; } $new = true; } else { $tpl->setVariable("NewOrEdit", "Edit"); $nodename = Wiki::formatWord($node); $new = false; } $tpl->setVariable("NodeName", $nodename); $tpl->setVariable("PageTitle", "PEAR Wiki Editor: $nodename"); $form = &Wiki::buildEditForm($node, $new); $tpl->setVariable("EditForm", $form->toHtml()); $tpl->show(); } function displayNode(&$tpl, $node) { if ($node == 'RootNode') { // hack to display a default Root node $contents = Wiki::getNodeContents($node); if ($contents === null) { $contents = '(Empty Root Node)'; } } $nodename = Wiki::formatWord($node); if (empty($contents)) { $contents = Wiki::getNodeContents($node); } if ($contents === null) { $tpl->loadTemplatefile('404.tpl'); } else { $tpl->loadTemplatefile('node.tpl'); $tpl->setVariable('Contents', Wiki::process($contents)); } $tpl->setVariable('User', $GLOBALS['a']->getUsername()); $tpl->setVariable('Self', $_SERVER['SCRIPT_NAME']); $tpl->setVariable('Version', PEAR_WIKI_VERSION); $tpl->setVariable('Node', $node); $tpl->setVariable('NodeName', $nodename); $tpl->setVariable('PageTitle', "PEAR Wiki: $nodename"); $tpl->show(); } function getNodeContents($node) { global $dbh; if (empty($dbh)) { return null; } return $dbh->getOne('SELECT content FROM nodes WHERE name = ?', array($node)); } function &buildEditForm($node, $new) { include_once 'HTML/QuickForm.php'; $form =& new HTML_QuickForm('editForm', 'POST'); $form->clearAllTemplates(); $constants['node'] = $node; $defaults['contents'] = Wiki::getNodeContents($node); $form->setConstants($constants); $form->setDefaults($defaults); $form->addData('<table border="0" cellpadding="0" cellspacing="2" bgcolor="#eeeeee">'); $form->addData('<tr><td colspan="2" align="left">Node:'); if ($new) { $form->addElement('text', 'node', null, 'size="60"'); $form->addRule('node', 'Must have a node name', 'required', null, 'client'); } else { $form->addElement('hidden', 'node', $node); $form->addData("<tt>$node</tt>"); } $form->addData('</td></tr><tr><td align="center" colspan="2">'); $form->addElement('textarea', 'contents', null, 'cols="60" rows="20" wrap="virtual"'); $form->addData('</td></tr><tr><td align="center" colspan="2">'); $form->addElement('submit', 'mode', 'submit'); $form->addData('</td></tr></table>'); return $form; } function storeNode($node, $contents) { global $dbh, $logger, $a; $now = time(); $sql = 'UPDATE nodes SET content = ?, mtime = ? WHERE name = ?'; $dbh->query($sql, array($contents, $now, $node)); if ($dbh->affectedRows() == 0) { $sql = 'INSERT INTO nodes VALUES(?,?,?,?)'; $id = $dbh->nextId('nodes'); $ret = $dbh->query($sql, array($node, $id, $contents, $now)); $logger->log($a->getUsername() . " added $node"); } else { $logger->log($a->getUsername() . " modified $node"); } return $ret; } function deleteNode($node) { global $dbh, $logger, $a; $sql = 'DELETE FROM nodes WHERE name = ?'; $logger->log($a->getUsername() . " deleted $node"); return $dbh->query($sql, array($node)); } } ?> Index: presentations/slides/powerpear/examples/htdocs/auth.php +++ presentations/slides/powerpear/examples/htdocs/auth.php <?php require_once 'Auth/Auth.php'; require_once 'HTML/QuickForm.php'; function loginFunction() { $form =& new HTML_QuickForm('editForm', 'POST'); $form->addData('<h1>Please log in!</h1>'); //$form->addData('<br />User name: '); $form->addElement('text', 'username', null, 'size="10"'); $form->addRule('username', 'Please enter your user name', 'required', null, 'client'); //$form->addData('<br />Password: '); $form->addElement('password', 'password'); $form->addRule('password', 'Please enter your password', 'required', null, 'client'); $form->addElement('submit'); $form->display(); exit; } $auth_options = array( 'dsn' => $dsn, 'table' => 'users', 'usernamecol' => 'username', 'passwordcol' => 'password', ); $a = new Auth("DB", $auth_options, "loginFunction"); $a->start(); ?> Index: presentations/slides/powerpear/examples/htdocs/index.php +++ presentations/slides/powerpear/examples/htdocs/index.php <?php // PEAR includes require_once 'HTML/Template/IT.php'; // non-PEAR includes require 'Wiki.php'; ob_start(); $node = preg_replace(':^/:', '', $_SERVER['PATH_INFO']); $mode = $_REQUEST['mode']; $template_dir = dirname(dirname(__FILE__)) . '/templates'; if ($mode == 'submit') { if (Wiki::storeNode($_REQUEST['node'], $_REQUEST['contents'])) { header("Location: $_SERVER[SCRIPT_NAME]/$_REQUEST[node]"); } else { header("Location: $_SERVER[SCRIPT_NAME]"); } exit; } if ($mode == 'logout') { $a->logout(); $a->start(); } if ($mode == 'delete') { Wiki::deleteNode($node); header("Location: $_SERVER[SCRIPT_NAME]"); exit; } if ($mode == 'mail') { if (empty($_REQUEST['email'])) { include_once "HTML/QuickForm.php"; include_once "HTML/Template/IT.php"; $form = new HTML_QuickForm($_SERVER['SCRIPT_NAME'], 'GET'); $form->addElement('text', 'email', null, 'size="40"'); $form->addRule('email', 'Please enter email address', 'required', null, 'client'); $form->addElement('submit'); $form->addElement('hidden', 'mode', $mode); $form_html = $form->toHtml(); $tpl =& new HTML_Template_IT($template_dir); $tpl->loadTemplatefile("mail.tpl"); $tpl->setVariable("Node", $node); $tpl->setVariable("MailForm", $form_html); $tpl->show(); exit; } else { include_once "Mail.php"; include_once "Mail/mime.php"; $html = Wiki::process(Wiki::getNodeContents($node)); $text = unhtmlentities(strip_tags($html)); $hdrs = array( 'From' => $a->getUsername() . '@php.net', 'Subject' => 'PEAR Wiki: ' . Wiki::formatWord($node), ); $mime = new Mail_mime(); $mime->setTXTBody($text); $mime->setHTMLBody($html); $body = $mime->get(); $hdrs = $mime->headers($hdrs); $mail =& Mail::factory('mail'); $mail->send($_REQUEST['email'], $hdrs, $body); } } $tpl =& new HTML_Template_IT($template_dir); if ($mode == 'edit') { Wiki::displayEditor($tpl, $node); } elseif ($mode == 'new') { Wiki::displayEditor($tpl, '__new__'); } else { if (empty($node)) { if (isset($_REQUEST['node'])) { $node = $_REQUEST['node']; } else { $node = 'RootNode'; } } Wiki::displayNode($tpl, $node); } ob_end_flush(); ?> Index: presentations/slides/powerpear/examples/htdocs/prepend.php +++ presentations/slides/powerpear/examples/htdocs/prepend.php <?php error_reporting(E_ALL & ~E_NOTICE); require_once 'PEAR.php'; require_once 'Log.php'; require_once 'DB.php'; DEFINE('PEAR_WIKI_VERSION', '0.1'); PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'errorHandler'); $dsn = 'mysql://localhost/test'; $dbh = DB::connect($dsn); $dbh->setFetchMode(DB_FETCHMODE_ASSOC); $logger = Log::factory("syslog"); include 'auth.php'; function errorHandler($error) { ob_end_clean(); print '<h2 style="color:#990000">'; print $error->getMessage(); print "</h2>\n<pre>"; print $error->getUserInfo(); print "</pre>\n"; exit; } function unhtmlentities ($string) { $trans_tbl = get_html_translation_table(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl); return strtr($string, $trans_tbl); } function pre_dump($foo) { print "<pre>"; var_dump($foo); print "</pre>"; } ?> Index: presentations/slides/powerpear/examples/sql/pearwiki.sql +++ presentations/slides/powerpear/examples/sql/pearwiki.sql CREATE TABLE nodes ( name VARCHAR(200) NOT NULL, id INTEGER NOT NULL, content TEXT, mtime INTEGER, PRIMARY KEY(name), UNIQUE INDEX(id) ); CREATE TABLE users ( username VARCHAR(20) NOT NULL, password VARCHAR(32), PRIMARY KEY(username) ); Index: presentations/slides/powerpear/examples/sql/search.sql +++ presentations/slides/powerpear/examples/sql/search.sql CREATE TABLE dictionary ( word VARCHAR(200) NOT NULL, PRIMARY KEY(word) ); CREATE TABLE page_index ( word VARCHAR(200) NOT NULL, node INTEGER NOT NULL, position INTEGER, PRIMARY KEY(word,page) ); Index: presentations/slides/powerpear/examples/templates/404.tpl +++ presentations/slides/powerpear/examples/templates/404.tpl <!-- INCLUDE header.tpl --> <h1>Node not found!</h1> <a href="{Self}?mode=edit">Create it?</a> <!-- INCLUDE footer.tpl --> Index: presentations/slides/powerpear/examples/templates/edit.tpl +++ presentations/slides/powerpear/examples/templates/edit.tpl <!-- INCLUDE header.tpl --> <h3>{NewOrEdit} Node</h3> {EditForm} <!-- INCLUDE footer.tpl --> Index: presentations/slides/powerpear/examples/templates/footer.tpl +++ presentations/slides/powerpear/examples/templates/footer.tpl </body> </html> Index: presentations/slides/powerpear/examples/templates/header.tpl +++ presentations/slides/powerpear/examples/templates/header.tpl <html> <head> <title>{PageTitle}</title> <style type="text/css"> BODY, TD, P { font-family: sans-serif; } pageheader { color: #ffffff; background: #339900; font-family: sans-serif; } pagetitle { font-weight: bold; font-size: large; font-family: sans-serif; } pagesubtitle { font-size: x-small; font-family: sans-serif; } menubar { background: #66cc33; color: #ffffff; font-size: small; font-family: sans-serif; } menulink { color: #ffffff; } </style> </head> <body bgcolor="#ffffff"> <table width="100%" border="1" cellpadding="2" cellspacing="0"> <tr class="pageheader"> <td width="32" height="32" valign="top"> <img src="/pear-icon.png" width="32" height="32" alt="" /></td> <td valign="top" width="100%"> <div class="pagetitle">{NodeName} </div> <div class="pagesubtitle">PEAR Wiki {Version}, logged in as {User}</div> </td> </tr> <tr class="menubar"> <td width="100%" colspan="2"> <a class="menulink" href="{Self}">Root</a> | <a class="menulink" href="{Self}?mode=new">new</a> | <a class="menulink" href="{Self}/{Node}?mode=edit">edit</a> | <a class="menulink" href="{Self}/{Node}?mode=delete">delete</a> | <a class="menulink" href="{Self}?mode=logout">logout</a> | <a class="menulink" href="{Self}/{Node}?mode=mail">mail to a friend</a> </td> </tr> </table> Index: presentations/slides/powerpear/examples/templates/home.tpl +++ presentations/slides/powerpear/examples/templates/home.tpl <!-- INCLUDE header.tpl --> <!-- BEGIN display_node --> {Contents} <!-- END display_node --> foo <!-- INCLUDE footer.tpl --> Index: presentations/slides/powerpear/examples/templates/mail.tpl +++ presentations/slides/powerpear/examples/templates/mail.tpl <!-- INCLUDE header.tpl --> Mail {Node} to a friend. Please enter email address: <p> {MailForm} </p> <!-- INCLUDE footer.tpl --> Index: presentations/slides/powerpear/examples/templates/node.tpl +++ presentations/slides/powerpear/examples/templates/node.tpl <!-- INCLUDE header.tpl --> <!-- BEGIN display_node --> <p> {Contents} </p> <!-- END display_node --> <!-- INCLUDE footer.tpl -->
Index: presentations/powerpear.xml +++ presentations/powerpear.xml <presentation jskeyboard="1" template="php" logo1="/images/pear.png" logoimage1url="http://pear.php.net/" navbarbackground="#339900" backgroundcol="#f0f0f0" navsize="1.4em"> <title>Teach Yourself PEAR in 6 Hours</title> <topic>PEAR</topic> <event>International PHP Conference</event> <location>Frankfurt</location> <date>2002-11-03</date> <speaker>Stig Bakken</speaker> <company>Fast Search & Transfer</company> <email>ssb@fast.no</email> <url>http://conf.php.net/</url> <slide>slides/powerpear/titlepage.xml</slide> <slide>slides/powerpear/agenda.xml</slide> <slide>slides/powerpear/intro1.xml</slide> <slide>slides/powerpear/intro2.xml</slide> <slide>slides/powerpear/intro3.xml</slide> <slide>slides/powerpear/intro4.xml</slide> <slide>slides/powerpear/packages1.xml</slide> <slide>slides/powerpear/packages2.xml</slide> <slide>slides/powerpear/versioning.xml</slide> <slide>slides/powerpear/cs1.xml</slide> <slide>slides/powerpear/tools1.xml</slide> <slide>slides/powerpear/tools2.xml</slide> <slide>slides/powerpear/distnet.xml</slide> <slide>slides/powerpear/devcom.xml</slide> <slide>slides/powerpear/licensing.xml</slide> <slide>slides/powerpear/break.xml</slide> <slide>slides/powerpear/obtaining.xml</slide> <slide>slides/powerpear/go-pear.xml</slide> <slide>slides/powerpear/usinginstaller1.xml</slide> <slide>slides/powerpear/usinginstaller2.xml</slide> <slide>slides/powerpear/fund.xml</slide> <slide>slides/powerpear/errors1.xml</slide> <slide>slides/powerpear/errors2.xml</slide> <slide>slides/powerpear/errors3.xml</slide> <slide>slides/powerpear/errors4.xml</slide> <slide>slides/powerpear/errors5.xml</slide> <slide>slides/powerpear/errors6.xml</slide> <slide>slides/powerpear/wiki-intro.xml</slide> <slide>slides/powerpear/wiki-src-index.php.xml</slide> <slide>slides/powerpear/wiki-src-Wiki.php.xml</slide> <slide>slides/powerpear/wiki-src-node.tpl.xml</slide> <slide>slides/powerpear/wiki-src-header.tpl.xml</slide> <slide>slides/powerpear/wiki-src-footer.tpl.xml</slide> <slide>slides/powerpear/wiki-src-edit.tpl.xml</slide> </presentation> Index: presentations/slides/powerpear/agenda.xml +++ presentations/slides/powerpear/agenda.xml <slide title="(Power) Agenda"> <list fontsize="6em"> <bullet>(Power) Introduction to PEAR</bullet> <bullet>Obtaining PEAR</bullet> <bullet>Using the Installer</bullet> <bullet>PEAR Fundamentals</bullet> <bullet>Demo: PEAR Wiki</bullet> <bullet>Wiki Hacking</bullet> <bullet>Questions / Ideas</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/break.xml +++ presentations/slides/powerpear/break.xml <slide title="Break Time!"> <list fontsize="5em"> <title>Stretch Your Feet!</title> </list> </slide> Index: presentations/slides/powerpear/cs1.xml +++ presentations/slides/powerpear/cs1.xml <slide title="PEAR Coding Standard"> <list fontsize="5em" effect="hide"> <bullet>Indentation: 4 spaces</bullet> <bullet>Package Naming: Foo, Foo_Bar</bullet> <bullet>Symbol Naming:</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>Functions: Package_function()</bullet> <bullet>Classes: Package, Package_Anotherclass</bullet> <bullet>Methods: public(), publicMethod(), _privateMethod()</bullet> <bullet>Globals: $_Package_globalname</bullet> <bullet>Constants: PACKAGE_CONSTANT</bullet> </list> <list fontsize="5em" effect="hide"> <bullet>PhpDoc Comments</bullet> <bullet>Including PEAR Code</bullet> <bullet>Use of PHP Short Tags</bullet> <bullet>Handling php.ini Settings</bullet> <bullet>CVS Rules (for cvs.php.net)</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/devcom.xml +++ presentations/slides/powerpear/devcom.xml <slide title="PEAR Developer Community"> <list fontsize="6em" effect="hide"> <bullet>pear-general@lists.php.net</bullet> </list> <list marginleft="2em" fontsize="5em" effect="hide"> <bullet>For users of PEAR packages</bullet> <bullet>General questions</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>pear-dev@lists.php.net</bullet> </list> <list marginleft="2em" fontsize="5em" effect="hide"> <bullet>For developers of PEAR packages</bullet> <bullet>Package Naming Discussions</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/distnet.xml +++ presentations/slides/powerpear/distnet.xml <slide title="PEAR Package Registry"> <list fontsize="6em" effect="hide"> <bullet>pear.php.net</bullet> <bullet>HTML interface</bullet> </list> <list marginleft="2em" fontsize="5em" effect="hide"> <bullet>Documentation</bullet> <bullet>Release Uploads</bullet> <bullet>Package Browsing</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>XML-RPC interface</bullet> </list> <list marginleft="2em" fontsize="5em" effect="hide"> <bullet>browsing, retrieving info</bullet> <bullet>manage releases</bullet> <bullet>list upgrades</bullet> <bullet>misc. administration methods</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/errors1.xml +++ presentations/slides/powerpear/errors1.xml <slide title="PEAR Errors"> <list fontsize="5em"> <bullet>How to distinguish an error?</bullet> <bullet>Errors as types</bullet> <bullet>Classes are types</bullet> <bullet>Exceptions coming in PHP 5</bullet> <bullet>Forward compatibility</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/errors2.xml +++ presentations/slides/powerpear/errors2.xml <slide title="PEAR Errors (2)"> <list fontsize="5em"> <bullet>PEAR::raiseError()</bullet> </list> <example type="php"> <text><![CDATA[ if (!@fopen($file, "r")) { return PEAR::raiseError($php_errormsg); } ]]></text></example> <list fontsize="5em"> <bullet>PEAR::isError()</bullet> </list> <example type="php"> <text><![CDATA[ $res = open_file(); if (PEAR::isError($res)) { die("Couldn't open file: " . $res->getMessage()); } ]]></text></example> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/errors3.xml +++ presentations/slides/powerpear/errors3.xml <slide title="PEAR::isError"> <list fontsize="5em"> <bullet>PEAR::isError() Implementation</bullet> </list> <example type="php"> <text><![CDATA[ function isError($data) { return (bool)(is_object($data) && (get_class($data) == 'pear_error' || is_subclass_of($data, 'pear_error'))); } ]]></text></example> <list fontsize="5em"> <bullet>PEAR_Error may be subclassed</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/errors4.xml +++ presentations/slides/powerpear/errors4.xml <slide title="PEAR::raiseError"> <list fontsize="5em"> <bullet>Called statically</bullet> </list> <example type="php"> <text><![CDATA[ if (datacenter_is_burning()) { PEAR::raiseError("power failure imminent"); } ]]></text></example> <list fontsize="5em"> <bullet>Called as part of object</bullet> </list> <example type="php"> <text><![CDATA[ if ($this->datacenterIsBurning()) { return $this->raiseError("CPU on fire"); } ]]></text></example> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/errors5.xml +++ presentations/slides/powerpear/errors5.xml <slide title="PEAR::setErrorHandling"> <list fontsize="6em"> <bullet>Global default handling</bullet> </list> <example type="php"> <text><![CDATA[ PEAR::setErrorHandling(PEAR_ERROR_DIE); ]]></text></example> <list fontsize="6em"> <bullet>Per-object default handling</bullet> </list> <example type="php"> <text><![CDATA[ $object->setErrorHandling(PEAR_ERROR_DIE, "<blink>%s</blink>"); ]]></text></example> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/errors6.xml +++ presentations/slides/powerpear/errors6.xml <slide title="Error Modes"> <list fontsize="6em" effect="hide"> <bullet>PEAR_ERROR_RETURN</bullet> <bullet>PEAR_ERROR_PRINT</bullet> <bullet>PEAR_ERROR_DIE</bullet> <bullet>PEAR_ERROR_TRIGGER</bullet> <bullet>PEAR_ERROR_CALLBACK</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/fund.xml +++ presentations/slides/powerpear/fund.xml <slide title="Including Files"> <list fontsize="6em" effect="hide"> <bullet>Including Files</bullet> </list> <list fontsize="4em" marginleft="2em" effect="hide"> <bullet>Use include_path</bullet> <bullet>require_once / include_once</bullet> <bullet>always include what you use</bullet> <bullet>(do not include what you do not use)</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>Why dirname(__FILE__) is bad</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/go-pear.xml +++ presentations/slides/powerpear/go-pear.xml <slide title="go-pear"> <list fontsize="6em" effect="hide"> <bullet>Requires CLI/CGI version of PHP</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>PHP 4.2.x: configure ... --enable-cli</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>go-pear</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>%lynx -source go-pear.org | php%</bullet> <bullet>Up to date!</bullet> <bullet>Web version available</bullet> <bullet>Doesn't work too great on Windows/MacOS X yet</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>Demonstration</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/intro1.xml +++ presentations/slides/powerpear/intro1.xml <slide title="What is PEAR?"> <list fontsize="5em" effect="hide"> <bullet>PHP Extension and Application Repository</bullet> <bullet>PHP Extension Code Library (PECL)</bullet> <bullet>Coding Standards</bullet> <bullet>Versioning Standards</bullet> <bullet>Package Concept</bullet> <bullet>Package Format</bullet> <bullet>Installation Tools</bullet> <bullet>Package Registry</bullet> <bullet>Developer Community</bullet> <bullet>Licensing Options</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/intro2.xml +++ presentations/slides/powerpear/intro2.xml <slide title="PHP Ext. and App. Repository"> <list fontsize="5em" effect="hide"> <bullet>Code Follows PEAR Coding Standards</bullet> <bullet>Currently Only PHP Code</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>Nothing stopping PEAR C modules</bullet> <bullet>Naming Standards Still Apply</bullet> </list> <list fontsize="5em" effect="hide"> <bullet>Package Name Management</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>Discussion/voting on pear-dev</bullet> </list> <list fontsize="5em" effect="hide"> <bullet>Example packages</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>Auth, Cache, Date, DB, File_Find</bullet> <bullet>HTML_Table, HTML_Template_IT, HTTP_Request</bullet> <bullet>HTTP_WebDav_Server, I18N, Image_Transform</bullet> <bullet>Inline_C, Log, Mail_Mime, Math, MDB, Net_DNS</bullet> <bullet>Net_POP3, LiveUser, SOAP, SQL_Parser</bullet> <bullet>XML_Parser, XML_Transformer, XML_Tree, +++</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/intro3.xml +++ presentations/slides/powerpear/intro3.xml <slide title="PECL (PHP Extension Code Library)"> <list fontsize="5em" effect="hide"> <bullet>PHP Extensions Written in C/C++</bullet> <bullet>Code Follows PHP Coding Standards</bullet> <bullet>Many PHP Extensions Will Move to PECL</bullet> <bullet>Example packages</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>apc, apd, bcompiler</bullet> <bullet>iisfunc, printer, ixsfunc</bullet> <bullet>mailparse, phpdoc, python, satellite</bullet> <bullet>session_pgsql, soap, threads, xmms</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/intro4.xml +++ presentations/slides/powerpear/intro4.xml <slide title="PFC (PHP Foundation Classes)"> <list fontsize="6em" effect="hide"> <bullet>Not Yet Defined^tm^</bullet> <bullet>Core Subset of PEAR</bullet> <bullet>Additional QA on APIs and Design</bullet> <bullet>Interoperability</bullet> <bullet>Integration Testing</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/licensing.xml +++ presentations/slides/powerpear/licensing.xml <slide title="Licensing Options"> <list fontsize="5em" effect="hide"> <bullet>PHP License Recommended</bullet> <bullet>GPL problems</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>C code: PHP/GPL licenses incompatible</bullet> <bullet>PHP code: not really resolved</bullet> <bullet>Applies for _distribution_</bullet> </list> <list fontsize="5em" effect="hide"> <bullet>Compatible Licenses:</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>Lesser/Library GPL</bullet> <bullet>Apache / BSD</bullet> <bullet>MPL / QPL</bullet> </list> <list fontsize="5em" effect="hide"> <bullet>PEAR Tools are general</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>May be used to manage in-house packages</bullet> <bullet>Install from any URL</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/obtaining.xml +++ presentations/slides/powerpear/obtaining.xml <slide title="Obtaining PEAR"> <list fontsize="6em" effect="hide"> <bullet>Bundled with PHP</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>Lags behind (PHP RC takes too long)</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>go-pear</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>%lynx -source go-pear.org | php%</bullet> <bullet>Up to date!</bullet> <bullet>Web version available</bullet> <bullet>Doesn't work too great on Windows/MacOS X yet</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/packages1.xml +++ presentations/slides/powerpear/packages1.xml <slide title="Package Concept"> <list fontsize="6em" effect="hide"> <bullet>PEAR Packages</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>Small Independent Projects</bullet> <bullet>Registered on pear.php.net</bullet> <bullet>Distributed and Installed Separately</bullet> <bullet>State: alpha, beta, stable, snapshot, devel</bullet> <bullet>Leads, developers, helpers</bullet> <bullet>Code Organization</bullet> <bullet>Available through Releases</bullet> <bullet>Dependencies: pkg, ext, php, prog, os, sapi, zend, rtlib</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/packages2.xml +++ presentations/slides/powerpear/packages2.xml <slide title="Package Concept (2)"> <list fontsize="6em" effect="hide"> <bullet>Why not use .rpm/.deb/.jar/.xyz?</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>Portability</bullet> <bullet>Integration the wrong way</bullet> <bullet>Need specialized tools anyway</bullet> <bullet>Design for wrapping in other formats</bullet> <bullet>Proof of concept: "pear makerpm"</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/titlepage.xml +++ presentations/slides/powerpear/titlepage.xml <slide template="titlepage" fontsize="6em"> <title>Welcome!</title> </slide> Index: presentations/slides/powerpear/tools1.xml +++ presentations/slides/powerpear/tools1.xml <slide title="PEAR Tools"> <list fontsize="6em" effect="hide"> <bullet>The PEAR Installer</bullet> </list> <list marginleft="2em" fontsize="5em" effect="hide"> <bullet>Uses the PEAR Package Format</bullet> <bullet>Cross-Platform</bullet> <bullet>Multiple User Interfaces (CLI, Gtk, Web)</bullet> <bullet>Can be wrapped in for example RPM</bullet> <bullet>Queries central package registry</bullet> <bullet>Builds extensions from source</bullet> <bullet>MD5 checksums and GPG signatures</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/tools2.xml +++ presentations/slides/powerpear/tools2.xml <slide title="PEAR Tools (2)"> <list fontsize="6em" effect="hide"> <bullet>PEAR Installer Functions:</bullet> </list> <list marginleft="2em" fontsize="5em" effect="hide"> <bullet>install / upgrade / uninstall / download</bullet> <bullet>list upgrades</bullet> <bullet>upgrade-all</bullet> <bullet>package, sign and release packages</bullet> <bullet>generate RPM spec files</bullet> <bullet>browse locally installed packages</bullet> <bullet>browse remotely available packages</bullet> <bullet>search package registry</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/usinginstaller1.xml +++ presentations/slides/powerpear/usinginstaller1.xml <slide title="Using the Installer (1)"> <list fontsize="6em" effect="hide"> <bullet>Inventory</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>%pear list%</bullet> <bullet>%pear info //Package//%</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>New Packages</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>%pear install Package%</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>Catching Up</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>%pear upgrade-all%</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>Cleaning House</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>%pear uninstall Package%</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>Demonstration</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/usinginstaller2.xml +++ presentations/slides/powerpear/usinginstaller2.xml <slide title="Using the Gtk Installer"> <list fontsize="6em" effect="hide"> <bullet>Requires PHP-GTK</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>Not available though PECL, yet</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>Installing the Gtk Installer UI</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>%pear install PEAR_Frontend_Gtk%</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>Demonstration</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/versioning.xml +++ presentations/slides/powerpear/versioning.xml <slide title="Versioning Standard"> <list fontsize="6em" effect="hide"> <bullet>Why Standardize?</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>Common Perception of What X.Y Means</bullet> <bullet>Tools Need to Compare Versions</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>major [.minor [.patch]] [pre]</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>"major" version: numeric, 0 means "experimental"</bullet> <bullet>"minor" version: new features ok, BC maintained</bullet> <bullet>"patch" version: bug fixes, tiny changes</bullet> <bullet>"pre" element: {dev,a,b,RC,pl}//N//</bullet> </list> <list fontsize="6em" effect="hide"> <bullet>Comparing:</bullet> </list> <list marginleft="2em" fontsize="4em" effect="hide"> <bullet>version_compare() function (from PHP 4.1.0)</bullet> <bullet>0.x < 1.x < 2.x ...</bullet> <bullet>0.1 < 0.9 < 0.10 < 1.0 ...</bullet> <bullet>1.0dev1 < 1.0a1 < 1.0b1 < 1.0RC1 < 1.0 < 1.0pl1</bullet> </list> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/wiki-intro.xml +++ presentations/slides/powerpear/wiki-intro.xml <slide title="Case Study: PEAR Wiki"> <list fontsize="6em" effect="hide"> <bullet>Starting Simple:</bullet> </list> <list marginleft="2em" fontsize="5em" effect="hide"> <bullet>One MySQL table</bullet> <bullet>View Page</bullet> <bullet>Edit Page</bullet> </list> <example effect="slide"> <title>mywiki.sql</title> <filename>examples/sql/mywiki.sql</filename> </example> <list fontsize="2em" effect="hide"><bullet>next</bullet></list> </slide> Index: presentations/slides/powerpear/wiki-src-Wiki.php.xml +++ presentations/slides/powerpear/wiki-src-Wiki.php.xml <slide title="PEAR Wiki: Wiki.php"> <example type="php"> <title>Wiki.php</title> <filename>examples/htdocs/Wiki.php</filename> </example> </slide> Index: presentations/slides/powerpear/wiki-src-edit.tpl.xml +++ presentations/slides/powerpear/wiki-src-edit.tpl.xml <slide title="PEAR Wiki: edit.tpl"> <example> <title>edit.tpl</title> <filename>examples/templates/edit.tpl</filename> </example> </slide> Index: presentations/slides/powerpear/wiki-src-footer.tpl.xml +++ presentations/slides/powerpear/wiki-src-footer.tpl.xml <slide title="PEAR Wiki: footer.tpl"> <example> <title>footer.tpl</title> <filename>examples/templates/footer.tpl</filename> </example> </slide> Index: presentations/slides/powerpear/wiki-src-header.tpl.xml +++ presentations/slides/powerpear/wiki-src-header.tpl.xml <slide title="PEAR Wiki: header.tpl"> <example> <title>header.tpl</title> <filename>examples/templates/header.tpl</filename> </example> </slide> Index: presentations/slides/powerpear/wiki-src-index.php.xml +++ presentations/slides/powerpear/wiki-src-index.php.xml <slide title="PEAR Wiki: index.php"> <example type="php"> <title>index.php</title> <filename>examples/htdocs/index.php</filename> </example> </slide> Index: presentations/slides/powerpear/wiki-src-node.tpl.xml +++ presentations/slides/powerpear/wiki-src-node.tpl.xml <slide title="PEAR Wiki: node.tpl"> <example> <title>node.tpl</title> <filename>examples/templates/node.tpl</filename> </example> </slide> Index: presentations/slides/powerpear/examples/apache/pearwiki.conf +++ presentations/slides/powerpear/examples/apache/pearwiki.conf <VirtualHost *> ServerName pearwiki.localdomain DirectoryIndex index.php DocumentRoot /home/ssb/cvs/php/pres2/presentations/slides/powerpear/examples/htdocs php_flag register_globals on php_value include_path .:/home/ssb/cvs/php/pres2/presentations/slides/powerpear/examples:/usr/share/pear php_value error_reporting 7 php_value auto_prepend_file prepend.php ErrorDocument 404 /error-404.php </VirtualHost> Index: presentations/slides/powerpear/examples/htdocs/Wiki.php +++ presentations/slides/powerpear/examples/htdocs/Wiki.php <?php class Wiki { function matchWord($word) { return preg_match('^[A-Z]+[a-z]+[A-Za-z0-9]*$', $word); } function formatWord($word) { $word = preg_replace('/([a-z])([A-Z])/', '\1 \2', $word); $word = preg_replace('/([a-zA-Z])(\d)/', '\1 \2', $word); return $word; } function process($contents) { if (preg_match_all('/{([a-z-]+)\s*([^}]*?)}/s', $contents, $matches)) { list($strings, $funcs, $args) = $matches; for ($i = 0; $i < sizeof($strings); $i++) { $replace = Wiki::runMacro($funcs[$i], $args[$i]); $contents = str_replace($strings[$i], $replace, $contents); } } if (preg_match_all('#\b([A-Z]+[a-z]+[A-Z\d][A-Za-z\d]*)\b#s', $contents, $matches)) { list($strings, $nodes) = $matches; $self = $_SERVER['SCRIPT_NAME']; for ($i = 0; $i < sizeof($strings); $i++) { // if (Wiki::nodeExists($nodes[$i])) { $spaced = Wiki::formatWord($nodes[$i]); $replace = "<a href=\"{$self}/{$nodes[$i]}\">$spaced</a>"; $contents = str_replace($strings[$i], $replace, $contents, 1); // } } } //$contents = str_replace('@@@', "{$self}/", $contents); return nl2br($contents); } function nodeExists($node) { static $cache = array(); if (isset($cache[$node])) { return $cache[$node]; } global $dbh; $id = $dbh->getOne('SELECT id FROM nodes WHERE name = ?', $node); if ($id !== null) { $cache[$node] = $id; } return (bool)$id; } function runMacro($func, $arg) { global $dbh; $ret = ''; switch ($func) { case 'list': $arg = str_replace('?', '_', $arg); $arg = str_replace('*', '%', $arg); $sql = "SELECT name FROM nodes WHERE name LIKE '$arg'"; // catch errors $dbh->pushErrorHandling(PEAR_ERROR_RETURN); $nodes = $dbh->getCol($sql, 0); $dbh->popErrorHandling(); if (is_array($nodes)) { $ret = implode("\n", $nodes); } break; case 'phpdoc': $url = "http://php.net/$arg"; $ret = "<a href=\"$url\">$arg (php.net)</a>"; break; case 'pear-listall': include_once "PEAR/Config.php"; include_once "PEAR/Remote.php"; $config = &PEAR_Config::singleton(); @$remote =& new PEAR_Remote($config); @$packages = $remote->call('package.listAll'); $ret = implode("\n", array_keys($packages)); break; case 'recent': include_once "Date.php"; $arg = (int)$arg; $res = $dbh->limitQuery("SELECT name, mtime FROM nodes ORDER BY mtime DESC", 0, $arg); $ret = ''; while ($res->fetchInto($tmp)) { $date = new Date($tmp['mtime']); $ret .= "$tmp[name] " . $date->getDate() . "\n"; } $res->free(); break; } return $ret; } function displayEditor(&$tpl, $node) { $tpl->loadTemplatefile('edit.tpl'); if ($node != '__new__') { $contents = Wiki::getNodeContents($node); } if ($contents === null) { // new node $tpl->setVariable("NewOrEdit", "New"); $nodename = "new node"; if ($node == '__new__') { $node = ""; } $new = true; } else { $tpl->setVariable("NewOrEdit", "Edit"); $nodename = Wiki::formatWord($node); $new = false; } $tpl->setVariable("NodeName", $nodename); $tpl->setVariable("PageTitle", "PEAR Wiki Editor: $nodename"); $form = &Wiki::buildEditForm($node, $new); $tpl->setVariable("EditForm", $form->toHtml()); $tpl->show(); } function displayNode(&$tpl, $node) { if ($node == 'RootNode') { // hack to display a default Root node $contents = Wiki::getNodeContents($node); if ($contents === null) { $contents = '(Empty Root Node)'; } } $nodename = Wiki::formatWord($node); if (empty($contents)) { $contents = Wiki::getNodeContents($node); } if ($contents === null) { $tpl->loadTemplatefile('404.tpl'); } else { $tpl->loadTemplatefile('node.tpl'); $tpl->setVariable('Contents', Wiki::process($contents)); } $tpl->setVariable('User', $GLOBALS['a']->getUsername()); $tpl->setVariable('Self', $_SERVER['SCRIPT_NAME']); $tpl->setVariable('Version', PEAR_WIKI_VERSION); $tpl->setVariable('Node', $node); $tpl->setVariable('NodeName', $nodename); $tpl->setVariable('PageTitle', "PEAR Wiki: $nodename"); $tpl->show(); } function getNodeContents($node) { global $dbh; if (empty($dbh)) { return null; } return $dbh->getOne('SELECT content FROM nodes WHERE name = ?', array($node)); } function &buildEditForm($node, $new) { include_once 'HTML/QuickForm.php'; $form =& new HTML_QuickForm('editForm', 'POST'); $form->clearAllTemplates(); $constants['node'] = $node; $defaults['contents'] = Wiki::getNodeContents($node); $form->setConstants($constants); $form->setDefaults($defaults); $form->addData('<table border="0" cellpadding="0" cellspacing="2" bgcolor="#eeeeee">'); $form->addData('<tr><td colspan="2" align="left">Node:'); if ($new) { $form->addElement('text', 'node', null, 'size="60"'); $form->addRule('node', 'Must have a node name', 'required', null, 'client'); } else { $form->addElement('hidden', 'node', $node); $form->addData("<tt>$node</tt>"); } $form->addData('</td></tr><tr><td align="center" colspan="2">'); $form->addElement('textarea', 'contents', null, 'cols="60" rows="20" wrap="virtual"'); $form->addData('</td></tr><tr><td align="center" colspan="2">'); $form->addElement('submit', 'mode', 'submit'); $form->addData('</td></tr></table>'); return $form; } function storeNode($node, $contents) { global $dbh, $logger, $a; $now = time(); $sql = 'UPDATE nodes SET content = ?, mtime = ? WHERE name = ?'; $dbh->query($sql, array($contents, $now, $node)); if ($dbh->affectedRows() == 0) { $sql = 'INSERT INTO nodes VALUES(?,?,?,?)'; $id = $dbh->nextId('nodes'); $ret = $dbh->query($sql, array($node, $id, $contents, $now)); $logger->log($a->getUsername() . " added $node"); } else { $logger->log($a->getUsername() . " modified $node"); } return $ret; } function deleteNode($node) { global $dbh, $logger, $a; $sql = 'DELETE FROM nodes WHERE name = ?'; $logger->log($a->getUsername() . " deleted $node"); return $dbh->query($sql, array($node)); } } ?> Index: presentations/slides/powerpear/examples/htdocs/auth.php +++ presentations/slides/powerpear/examples/htdocs/auth.php <?php require_once 'Auth/Auth.php'; require_once 'HTML/QuickForm.php'; function loginFunction() { $form =& new HTML_QuickForm('editForm', 'POST'); $form->addData('<h1>Please log in!</h1>'); //$form->addData('<br />User name: '); $form->addElement('text', 'username', null, 'size="10"'); $form->addRule('username', 'Please enter your user name', 'required', null, 'client'); //$form->addData('<br />Password: '); $form->addElement('password', 'password'); $form->addRule('password', 'Please enter your password', 'required', null, 'client'); $form->addElement('submit'); $form->display(); exit; } $auth_options = array( 'dsn' => $dsn, 'table' => 'users', 'usernamecol' => 'username', 'passwordcol' => 'password', ); $a = new Auth("DB", $auth_options, "loginFunction"); $a->start(); ?> Index: presentations/slides/powerpear/examples/htdocs/index.php +++ presentations/slides/powerpear/examples/htdocs/index.php <?php // PEAR includes require_once 'HTML/Template/IT.php'; // non-PEAR includes require 'Wiki.php'; ob_start(); $node = preg_replace(':^/:', '', $_SERVER['PATH_INFO']); $mode = $_REQUEST['mode']; $template_dir = dirname(dirname(__FILE__)) . '/templates'; if ($mode == 'submit') { if (Wiki::storeNode($_REQUEST['node'], $_REQUEST['contents'])) { header("Location: $_SERVER[SCRIPT_NAME]/$_REQUEST[node]"); } else { header("Location: $_SERVER[SCRIPT_NAME]"); } exit; } if ($mode == 'logout') { $a->logout(); $a->start(); } if ($mode == 'delete') { Wiki::deleteNode($node); header("Location: $_SERVER[SCRIPT_NAME]"); exit; } if ($mode == 'mail') { if (empty($_REQUEST['email'])) { include_once "HTML/QuickForm.php"; include_once "HTML/Template/IT.php"; $form = new HTML_QuickForm($_SERVER['SCRIPT_NAME'], 'GET'); $form->addElement('text', 'email', null, 'size="40"'); $form->addRule('email', 'Please enter email address', 'required', null, 'client'); $form->addElement('submit'); $form->addElement('hidden', 'mode', $mode); $form_html = $form->toHtml(); $tpl =& new HTML_Template_IT($template_dir); $tpl->loadTemplatefile("mail.tpl"); $tpl->setVariable("Node", $node); $tpl->setVariable("MailForm", $form_html); $tpl->show(); exit; } else { include_once "Mail.php"; include_once "Mail/mime.php"; $html = Wiki::process(Wiki::getNodeContents($node)); $text = unhtmlentities(strip_tags($html)); $hdrs = array( 'From' => $a->getUsername() . '@php.net', 'Subject' => 'PEAR Wiki: ' . Wiki::formatWord($node), ); $mime = new Mail_mime(); $mime->setTXTBody($text); $mime->setHTMLBody($html); $body = $mime->get(); $hdrs = $mime->headers($hdrs); $mail =& Mail::factory('mail'); $mail->send($_REQUEST['email'], $hdrs, $body); } } $tpl =& new HTML_Template_IT($template_dir); if ($mode == 'edit') { Wiki::displayEditor($tpl, $node); } elseif ($mode == 'new') { Wiki::displayEditor($tpl, '__new__'); } else { if (empty($node)) { if (isset($_REQUEST['node'])) { $node = $_REQUEST['node']; } else { $node = 'RootNode'; } } Wiki::displayNode($tpl, $node); } ob_end_flush(); ?> Index: presentations/slides/powerpear/examples/htdocs/prepend.php +++ presentations/slides/powerpear/examples/htdocs/prepend.php <?php error_reporting(E_ALL & ~E_NOTICE); require_once 'PEAR.php'; require_once 'Log.php'; require_once 'DB.php'; DEFINE('PEAR_WIKI_VERSION', '0.1'); PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'errorHandler'); $dsn = 'mysql://localhost/test'; $dbh = DB::connect($dsn); $dbh->setFetchMode(DB_FETCHMODE_ASSOC); $logger = Log::factory("syslog"); include 'auth.php'; function errorHandler($error) { ob_end_clean(); print '<h2 style="color:#990000">'; print $error->getMessage(); print "</h2>\n<pre>"; print $error->getUserInfo(); print "</pre>\n"; exit; } function unhtmlentities ($string) { $trans_tbl = get_html_translation_table(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl); return strtr($string, $trans_tbl); } function pre_dump($foo) { print "<pre>"; var_dump($foo); print "</pre>"; } ?> Index: presentations/slides/powerpear/examples/sql/pearwiki.sql +++ presentations/slides/powerpear/examples/sql/pearwiki.sql CREATE TABLE nodes ( name VARCHAR(200) NOT NULL, id INTEGER NOT NULL, content TEXT, mtime INTEGER, PRIMARY KEY(name), UNIQUE INDEX(id) ); CREATE TABLE users ( username VARCHAR(20) NOT NULL, password VARCHAR(32), PRIMARY KEY(username) ); Index: presentations/slides/powerpear/examples/sql/search.sql +++ presentations/slides/powerpear/examples/sql/search.sql CREATE TABLE dictionary ( word VARCHAR(200) NOT NULL, PRIMARY KEY(word) ); CREATE TABLE page_index ( word VARCHAR(200) NOT NULL, node INTEGER NOT NULL, position INTEGER, PRIMARY KEY(word,page) ); Index: presentations/slides/powerpear/examples/templates/404.tpl +++ presentations/slides/powerpear/examples/templates/404.tpl <!-- INCLUDE header.tpl --> <h1>Node not found!</h1> <a href="{Self}?mode=edit">Create it?</a> <!-- INCLUDE footer.tpl --> Index: presentations/slides/powerpear/examples/templates/edit.tpl +++ presentations/slides/powerpear/examples/templates/edit.tpl <!-- INCLUDE header.tpl --> <h3>{NewOrEdit} Node</h3> {EditForm} <!-- INCLUDE footer.tpl --> Index: presentations/slides/powerpear/examples/templates/footer.tpl +++ presentations/slides/powerpear/examples/templates/footer.tpl </body> </html> Index: presentations/slides/powerpear/examples/templates/header.tpl +++ presentations/slides/powerpear/examples/templates/header.tpl <html> <head> <title>{PageTitle}</title> <style type="text/css"> BODY, TD, P { font-family: sans-serif; } pageheader { color: #ffffff; background: #339900; font-family: sans-serif; } pagetitle { font-weight: bold; font-size: large; font-family: sans-serif; } pagesubtitle { font-size: x-small; font-family: sans-serif; } menubar { background: #66cc33; color: #ffffff; font-size: small; font-family: sans-serif; } menulink { color: #ffffff; } </style> </head> <body bgcolor="#ffffff"> <table width="100%" border="1" cellpadding="2" cellspacing="0"> <tr class="pageheader"> <td width="32" height="32" valign="top"> <img src="/pear-icon.png" width="32" height="32" alt="" /></td> <td valign="top" width="100%"> <div class="pagetitle">{NodeName} </div> <div class="pagesubtitle">PEAR Wiki {Version}, logged in as {User}</div> </td> </tr> <tr class="menubar"> <td width="100%" colspan="2"> <a class="menulink" href="{Self}">Root</a> | <a class="menulink" href="{Self}?mode=new">new</a> | <a class="menulink" href="{Self}/{Node}?mode=edit">edit</a> | <a class="menulink" href="{Self}/{Node}?mode=delete">delete</a> | <a class="menulink" href="{Self}?mode=logout">logout</a> | <a class="menulink" href="{Self}/{Node}?mode=mail">mail to a friend</a> </td> </tr> </table> Index: presentations/slides/powerpear/examples/templates/home.tpl +++ presentations/slides/powerpear/examples/templates/home.tpl <!-- INCLUDE header.tpl --> <!-- BEGIN display_node --> {Contents} <!-- END display_node --> foo <!-- INCLUDE footer.tpl --> Index: presentations/slides/powerpear/examples/templates/mail.tpl +++ presentations/slides/powerpear/examples/templates/mail.tpl <!-- INCLUDE header.tpl --> Mail {Node} to a friend. Please enter email address: <p> {MailForm} </p> <!-- INCLUDE footer.tpl --> Index: presentations/slides/powerpear/examples/templates/node.tpl +++ presentations/slides/powerpear/examples/templates/node.tpl <!-- INCLUDE header.tpl --> <!-- BEGIN display_node --> <p> {Contents} </p> <!-- END display_node --> <!-- INCLUDE footer.tpl -->