├── 9781430229254.jpg ├── LICENSE.txt ├── README.md ├── contributing.md └── popp-code ├── 3 ├── listing.001.php ├── listing.002.php ├── listing.003.php ├── listing.004.php ├── listing.005.php ├── listing.006.php ├── listing.007.php ├── listing.008.php ├── listing.009.php ├── listing.010.php ├── listing.011.xml ├── listing.012.php ├── listing.013.php ├── listing.014.php ├── listing.015.php ├── listing.016.php ├── listing.017.php ├── listing.018.php ├── listing.019.php ├── listing.020.php ├── listing.021.php ├── listing.022.php ├── listing.023.php ├── listing.024.php └── listing.025.php ├── 4 ├── back_products.db ├── closures.php ├── conf.broken.xml ├── conf.unwriteable.xml ├── conf01.xml ├── generate_product_pdo.php ├── listing04.01.php ├── listing04.02.php ├── listing04.03.php ├── listing04.04.php ├── listing04.05.php ├── listing04.06.php ├── listing04.07.php ├── listing04.08.php ├── listing04.10.php ├── listing04.11.php ├── listing04.12.php ├── listing04.13.php ├── listing04.14.php ├── listing04.15.php ├── listing04.16.php ├── listing04.17.php ├── listing04.18.php ├── listing04.19.php ├── listing04.20.php ├── listing04.21.php ├── listing04.22.php ├── listing04.23.php ├── listing04.24.php ├── listing04.25.php ├── listing04.26.php ├── listing04.27.php ├── listing04.28.php ├── listing04.29.php ├── listing04.30.php ├── listing04.31.php ├── products.db ├── products.pdo └── xmltest.php ├── 5 ├── ShopProduct.php ├── business │ ├── ShopProduct.php │ ├── ShopProduct2.php │ └── ShopProduct3.php ├── fullshop.php ├── global.php ├── listing5.01.php ├── listing5.02.php ├── listing5.03.php ├── listing5.04.php ├── listing5.05.php ├── listing5.06.php ├── listing5.07.php ├── listing5.08.php ├── listing5.09.php ├── listing5.10.php ├── listing5.11.php ├── listing5.12.php ├── listing5.13.php ├── listing5.14.php ├── listing5.15.php ├── listing5.16.php ├── listing5.17.php ├── listing5.18.php ├── listing5.19.php ├── listing5.20.php ├── listing5.21.php ├── listing5.22.php ├── listing5.23.php ├── listing5.24.php ├── listing5.25.php ├── listing5.26.php ├── listing5.27.php ├── listing5.28.php ├── listing5.29.php ├── listing5.30.php ├── listing5.31.php ├── tasks │ └── Task.php └── useful │ ├── Outputter1.php │ ├── Outputter2.php │ └── Outputter3.php ├── 6 ├── listing06.01.php ├── listing06.02.php ├── listing06.03.php └── listing06.04.php ├── 8 ├── listing1.php ├── listing2.php └── listing3.php ├── 9 ├── listing9.01.php ├── listing9.02.php ├── listing9.03.php ├── listing9.04.php ├── listing9.05.fragment.php ├── listing9.05.php ├── listing9.06.php ├── listing9.07.php ├── listing9.08.php ├── listing9.09.php ├── listing9.10.php ├── listing9.11.php └── listing9.12.php ├── 10 ├── listing10.01.php ├── listing10.02.php ├── listing10.03.php ├── listing10.04.php ├── listing10.05.php ├── listing10.06.php ├── listing10.07.php ├── listing10.08.php ├── listing10.09.php ├── listing10.10.php ├── listing10.11.php ├── listing10.12.php └── listing10.13.php ├── 11 ├── commands │ ├── Command.php │ ├── FeedbackCommand.php │ └── LoginCommand.php ├── listing11.01.php ├── listing11.02.php ├── listing11.03.php ├── listing11.04.php ├── listing11.05.php ├── listing11.06.5.php ├── listing11.06.php ├── listing11.07.php ├── listing11.08.php ├── listing11.09.php ├── listing11.10.php ├── listing11.11.php ├── listing11.12.php └── parse │ ├── ML_Interpreter.php │ ├── MarkLogic.php │ ├── Parser.php │ └── Scanner.php ├── 12 ├── VenueStub.php ├── add_venue.php ├── data │ ├── dsn │ ├── woo.db │ └── woo_options.xml ├── listing12.01.php ├── listing12.02.php ├── listing12.03.php ├── listing12.05.php ├── listing12.05.run.php ├── listing12.06.php ├── listing12.07.php ├── listing12.08.php ├── listing12.09.php ├── listing12.10.php ├── listing12.11.php ├── listing12.12.php ├── readme ├── runner.php ├── transaction-script-setup.php └── woo │ ├── base │ ├── Exceptions.php │ └── Registry.php │ ├── command │ ├── AddSpace.php │ ├── AddVenue.php │ ├── Command.php │ ├── DefaultCommand.php │ ├── DefaultCommand2.php │ └── ListVenues.php │ ├── controller │ ├── AppController.php │ ├── ApplicationHelper.php │ ├── Controller.php │ └── Request.php │ ├── domain.php │ ├── domain │ ├── Collections.php │ ├── DomainObject.php │ ├── Event.php │ ├── Finders.php │ ├── HelperFactory.php │ ├── ObjectWatcher.php │ ├── Space.php │ └── Venue.php │ ├── mapper │ ├── Collection.php │ ├── Collections.php │ ├── EventMapper.php │ ├── Mapper.php │ ├── SpaceMapper.php │ └── VenueMapper.php │ └── view │ ├── ViewHelper.php │ ├── addspace.php │ ├── addvenue.php │ ├── listvenues.php │ └── main.php ├── 13 ├── 001_Mapper_to_LazyLoad │ ├── build-db.php │ ├── data │ │ └── woo_options.xml │ ├── listing13.01.php │ ├── listing13.02.php │ ├── listing13.03.php │ ├── quicksetupscript │ ├── readme │ ├── runner.php │ └── woo │ │ ├── base │ │ ├── Exceptions.php │ │ └── Registry.php │ │ ├── command │ │ ├── AddSpace.php │ │ ├── AddVenue.php │ │ ├── Command.php │ │ ├── DefaultCommand.php │ │ ├── DefaultCommand2.php │ │ └── ListVenues.php │ │ ├── controller │ │ ├── AppController.php │ │ ├── ApplicationHelper.php │ │ ├── Controller.php │ │ └── Request.php │ │ ├── domain.php │ │ ├── domain │ │ ├── Collections.php │ │ ├── DomainObject.php │ │ ├── Event.php │ │ ├── Finders.php │ │ ├── HelperFactory.php │ │ ├── ObjectWatcher.php │ │ ├── Space.php │ │ └── Venue.php │ │ ├── mapper │ │ ├── Collection.php │ │ ├── Collections.php │ │ ├── EventMapper.php │ │ ├── Mapper.php │ │ ├── SpaceMapper.php │ │ └── VenueMapper.php │ │ └── view │ │ ├── ViewHelper.php │ │ ├── addspace.php │ │ ├── addvenue.php │ │ ├── listvenues.php │ │ └── main.php ├── 002_DomainObjectFactory │ ├── runner.php │ └── woo │ │ ├── base │ │ ├── Exceptions.php │ │ └── Registry.php │ │ ├── command │ │ ├── AddSpace.php │ │ ├── AddVenue.php │ │ ├── Command.php │ │ ├── DefaultCommand.php │ │ ├── DefaultCommand2.php │ │ └── ListVenues.php │ │ ├── controller │ │ ├── AppController.php │ │ ├── ApplicationHelper.php │ │ ├── Controller.php │ │ └── Request.php │ │ ├── domain.php │ │ ├── domain │ │ ├── Collections.php │ │ ├── DomainObject.php │ │ ├── Event.php │ │ ├── Finders.php │ │ ├── HelperFactory.php │ │ ├── ObjectWatcher.php │ │ ├── Space.php │ │ └── Venue.php │ │ ├── mapper │ │ ├── Collection.php │ │ ├── Collections.php │ │ ├── DomainObjectFactory.php │ │ ├── EventMapper.php │ │ ├── Mapper.php │ │ ├── PersistenceFactory.php │ │ ├── SpaceMapper.php │ │ └── VenueMapper.php │ │ └── view │ │ ├── ViewHelper.php │ │ ├── addspace.php │ │ ├── addvenue.php │ │ ├── listvenues.php │ │ └── main.php └── 003_QueryFactories │ ├── VenueIdentityObject.php │ ├── runner.php │ └── woo │ ├── base │ ├── Exceptions.php │ └── Registry.php │ ├── command │ ├── AddSpace.php │ ├── AddVenue.php │ ├── Command.php │ ├── DefaultCommand.php │ ├── DefaultCommand2.php │ └── ListVenues.php │ ├── controller │ ├── AppController.php │ ├── ApplicationHelper.php │ ├── Controller.php │ └── Request.php │ ├── domain.php │ ├── domain │ ├── Collections.php │ ├── DomainObject.php │ ├── Event.php │ ├── Finders.php │ ├── HelperFactory.php │ ├── ObjectWatcher.php │ ├── Space.php │ └── Venue.php │ ├── mapper │ ├── Collection.php │ ├── Collections.php │ ├── DomainObjectAssembler.php │ ├── DomainObjectFactory.php │ ├── EventIdentityObject.php │ ├── EventMapper.php │ ├── EventSelectionFactory.php │ ├── EventUpdateFactory.php │ ├── IdentityObject.php │ ├── IdentityObject2.php │ ├── IdentityObject3.php │ ├── Mapper.php │ ├── PersistenceFactory.php │ ├── SelectionFactory.php │ ├── SpaceIdentityObject.php │ ├── SpaceMapper.php │ ├── SpaceSelectionFactory.php │ ├── SpaceUpdateFactory.php │ ├── UpdateFactory.php │ ├── VenueIdentityObject.php │ ├── VenueMapper.php │ ├── VenueSelectionFactory.php │ └── VenueUpdateFactory.php │ └── view │ ├── ViewHelper.php │ ├── addspace.php │ ├── addvenue.php │ ├── listvenues.php │ └── main.php ├── 15 ├── PEAR2_SimpleChannelServer-0.1.0.phar ├── dialekt │ ├── .test.xml │ ├── baddialekt │ │ ├── Dialekt.php │ │ ├── Dialekt │ │ │ ├── AliG.php │ │ │ └── Dalek.php │ │ ├── cli-dialekt.php │ │ ├── data │ │ │ ├── alig.txt │ │ │ └── dalek.txt │ │ ├── dialekt-0.2.tgz │ │ └── script │ │ │ ├── dialekt.bat │ │ │ └── dialekt.sh │ └── dialekt-1.2.1 │ │ ├── Dialekt-1.2.1.tgz │ │ ├── Dialekt.php │ │ ├── Dialekt │ │ ├── AliG.php │ │ └── Dalek.php │ │ ├── cli-dialekt.php │ │ ├── data │ │ ├── alig.txt │ │ └── dalek.txt │ │ ├── package.xml │ │ └── script │ │ ├── dialekt.bat │ │ └── dialekt.sh ├── listing15.01.php ├── listing15.02.php ├── listing15.03.php ├── listing15.04.php ├── my.conf ├── test.broken.conf └── test.conf ├── 16 ├── docs │ ├── megaquiz │ │ ├── blank.html │ │ ├── classtrees_megaquiz.html │ │ ├── elementindex.html │ │ ├── elementindex_megaquiz.html │ │ ├── errors.html │ │ ├── index.html │ │ ├── li_megaquiz.html │ │ ├── media │ │ │ ├── banner.css │ │ │ └── stylesheet.css │ │ ├── megaquiz │ │ │ ├── AccessManager.html │ │ │ ├── Command.html │ │ │ ├── CommandContext.html │ │ │ ├── FeedbackCommand.html │ │ │ ├── LoginCommand.html │ │ │ ├── ReceiverFactory.html │ │ │ ├── User.html │ │ │ ├── _command---Command.php.html │ │ │ ├── _command---CommandContext.php.html │ │ │ ├── _command---FeedbackCommand.php.html │ │ │ ├── _command---LoginCommand.php.html │ │ │ ├── _main.php.html │ │ │ ├── _quizobjects---User.php.html │ │ │ └── _quiztools---AccessManager.php.html │ │ └── packages.html │ ├── megaquiz2 │ │ ├── blank.html │ │ ├── classtrees_command.html │ │ ├── classtrees_megaquiz.html │ │ ├── classtrees_quiztools.html │ │ ├── command │ │ │ ├── Command.html │ │ │ ├── CommandContext.html │ │ │ ├── FeedbackCommand.html │ │ │ ├── LoginCommand.html │ │ │ ├── _command---Command.php.html │ │ │ ├── _command---CommandContext.php.html │ │ │ ├── _command---FeedbackCommand.php.html │ │ │ └── _command---LoginCommand.php.html │ │ ├── elementindex.html │ │ ├── elementindex_command.html │ │ ├── elementindex_megaquiz.html │ │ ├── elementindex_quiztools.html │ │ ├── errors.html │ │ ├── index.html │ │ ├── li_command.html │ │ ├── li_megaquiz.html │ │ ├── li_quiztools.html │ │ ├── media │ │ │ ├── banner.css │ │ │ └── stylesheet.css │ │ ├── megaquiz │ │ │ ├── User.html │ │ │ ├── _main.php.html │ │ │ └── _quizobjects---User.php.html │ │ ├── packages.html │ │ └── quiztools │ │ │ ├── AccessManager.html │ │ │ ├── ReceiverFactory.html │ │ │ └── _quiztools---AccessManager.php.html │ ├── megaquiz3 │ │ ├── blank.html │ │ ├── classtrees_command.html │ │ ├── classtrees_megaquiz.html │ │ ├── classtrees_quizobjects.html │ │ ├── classtrees_quiztools.html │ │ ├── command │ │ │ ├── Command.html │ │ │ ├── CommandContext.html │ │ │ ├── FeedbackCommand.html │ │ │ ├── LoginCommand.html │ │ │ ├── _command---Command.php.html │ │ │ ├── _command---CommandContext.php.html │ │ │ ├── _command---FeedbackCommand.php.html │ │ │ └── _command---LoginCommand.php.html │ │ ├── elementindex.html │ │ ├── elementindex_command.html │ │ ├── elementindex_megaquiz.html │ │ ├── elementindex_quizobjects.html │ │ ├── elementindex_quiztools.html │ │ ├── errors.html │ │ ├── index.html │ │ ├── li_command.html │ │ ├── li_megaquiz.html │ │ ├── li_quizobjects.html │ │ ├── li_quiztools.html │ │ ├── media │ │ │ ├── banner.css │ │ │ └── stylesheet.css │ │ ├── megaquiz │ │ │ └── _main.php.html │ │ ├── packages.html │ │ ├── quizobjects │ │ │ ├── User.html │ │ │ └── _quizobjects---User.php.html │ │ └── quiztools │ │ │ ├── AccessManager.html │ │ │ ├── ReceiverFactory.html │ │ │ └── _quiztools---AccessManager.php.html │ └── megaquiz4 │ │ ├── blank.html │ │ ├── classtrees_command.html │ │ ├── classtrees_megaquiz.html │ │ ├── classtrees_quizobjects.html │ │ ├── classtrees_quiztools.html │ │ ├── command │ │ ├── Command.html │ │ ├── CommandContext.html │ │ ├── FeedbackCommand.html │ │ ├── LoginCommand.html │ │ ├── _command---Command.php.html │ │ ├── _command---CommandContext.php.html │ │ ├── _command---FeedbackCommand.php.html │ │ └── _command---LoginCommand.php.html │ │ ├── elementindex.html │ │ ├── elementindex_command.html │ │ ├── elementindex_megaquiz.html │ │ ├── elementindex_quizobjects.html │ │ ├── elementindex_quiztools.html │ │ ├── errors.html │ │ ├── index.html │ │ ├── li_command.html │ │ ├── li_megaquiz.html │ │ ├── li_quizobjects.html │ │ ├── li_quiztools.html │ │ ├── media │ │ ├── banner.css │ │ └── stylesheet.css │ │ ├── megaquiz │ │ └── _main.php.html │ │ ├── packages.html │ │ ├── quizobjects │ │ ├── User.html │ │ └── _quizobjects---User.php.html │ │ └── quiztools │ │ ├── AccessManager.html │ │ ├── ReceiverFactory.html │ │ └── _quiztools---AccessManager.php.html ├── megaquiz │ ├── command │ │ ├── Command.php │ │ ├── CommandContext.php │ │ ├── FeedbackCommand.php │ │ ├── LoginCommand.php │ │ └── cvs │ │ │ ├── Entries │ │ │ ├── Repository │ │ │ └── Root │ ├── cvs │ │ ├── Entries │ │ ├── Entries.Log │ │ ├── Repository │ │ └── Root │ ├── main.php │ ├── quizobjects │ │ ├── User.php │ │ └── cvs │ │ │ ├── Entries │ │ │ ├── Repository │ │ │ └── Root │ └── quiztools │ │ ├── AccessManager.php │ │ └── cvs │ │ ├── Entries │ │ ├── Repository │ │ └── Root ├── megaquiz2 │ ├── command │ │ ├── Command.php │ │ ├── CommandContext.php │ │ ├── FeedbackCommand.php │ │ ├── LoginCommand.php │ │ └── cvs │ │ │ ├── Entries │ │ │ ├── Repository │ │ │ └── Root │ ├── cvs │ │ ├── Entries │ │ ├── Entries.Log │ │ ├── Repository │ │ └── Root │ ├── main.php │ ├── quizobjects │ │ ├── User.php │ │ └── cvs │ │ │ ├── Entries │ │ │ ├── Repository │ │ │ └── Root │ └── quiztools │ │ ├── AccessManager.php │ │ └── cvs │ │ ├── Entries │ │ ├── Repository │ │ └── Root ├── megaquiz3 │ ├── command │ │ ├── Command.php │ │ ├── CommandContext.php │ │ ├── FeedbackCommand.php │ │ ├── LoginCommand.php │ │ └── cvs │ │ │ ├── Entries │ │ │ ├── Repository │ │ │ └── Root │ ├── cvs │ │ ├── Entries │ │ ├── Entries.Log │ │ ├── Repository │ │ └── Root │ ├── main.php │ ├── quizobjects │ │ ├── User.php │ │ └── cvs │ │ │ ├── Entries │ │ │ ├── Repository │ │ │ └── Root │ └── quiztools │ │ ├── AccessManager.php │ │ └── cvs │ │ ├── Entries │ │ ├── Repository │ │ └── Root └── megaquiz4 │ ├── command │ ├── Command.php │ ├── CommandContext.php │ ├── FeedbackCommand.php │ ├── LoginCommand.php │ └── cvs │ │ ├── Entries │ │ ├── Repository │ │ └── Root │ ├── cvs │ ├── Entries │ ├── Entries.Log │ ├── Repository │ └── Root │ ├── main.php │ ├── quizobjects │ ├── User.php │ └── cvs │ │ ├── Entries │ │ ├── Repository │ │ └── Root │ └── quiztools │ ├── AccessManager.php │ └── cvs │ ├── Entries │ ├── Repository │ └── Root ├── 17 └── megaquiz.orig │ └── trunk │ ├── command │ ├── Command.php │ ├── CommandContext.php │ ├── FeedbackCommand.php │ └── LoginCommand.php │ ├── main.php │ ├── quizobjects │ └── User.php │ └── quiztools │ └── AccessManager.php ├── 18 ├── after_change │ ├── User.php │ ├── UserStore.php │ ├── Validator.php │ └── test │ │ ├── SomeTests.php │ │ ├── UserStoreTest.php │ │ └── ValidatorTest.php ├── before_change │ ├── UserStore.php │ ├── Validator.php │ └── test │ │ ├── SomeTests.php │ │ ├── UserStoreTest.php │ │ ├── UserStoreTestBasic.php │ │ ├── ValidatorTest.php │ │ └── ValidatorTestBasic.php ├── inmemory_example │ ├── DBFace.php │ └── ToolTest.php ├── listing21.01.php ├── listing21.02.php └── webandselenium │ ├── seleniumtest.php │ └── webwoo │ ├── AddSpace.php │ ├── AddVenue.php │ ├── Main.php │ └── index.php ├── 19 ├── build.xml.1 ├── build.xml.10 ├── build.xml.11 ├── build.xml.2 ├── build.xml.3 ├── build.xml.4 ├── build.xml.5 ├── build.xml.6 ├── build.xml.7 ├── build.xml.8 ├── build.xml.9 ├── build.xml.full ├── build │ └── lib │ │ ├── Config.php │ │ ├── command │ │ ├── Command.php │ │ ├── CommandContext.php │ │ ├── FeedbackCommand.php │ │ └── LoginCommand.php │ │ ├── quizobjects │ │ ├── Tree.php │ │ └── User.php │ │ └── quiztools │ │ └── AccessManager.php └── src │ ├── config │ └── Config.php │ ├── lib │ ├── .htaccess │ ├── Config.php │ ├── command │ │ ├── Command.php │ │ ├── CommandContext.php │ │ ├── FeedbackCommand.php │ │ └── LoginCommand.php │ ├── quizobjects │ │ ├── FinishedTest.php │ │ ├── Tree.php │ │ ├── TreeTest.php │ │ ├── User.php │ │ ├── User_test.php │ │ └── description.txt │ └── quiztools │ │ └── AccessManager.php │ ├── main.php │ └── views │ └── index.html ├── 20 ├── build.xml ├── config.xml └── userthing.orig │ └── trunk │ └── src │ ├── package.xml │ ├── test │ ├── UserStoreTest.php │ ├── UserTests.php │ └── ValidatorTest.php │ └── userthing │ ├── domain │ └── User.php │ ├── persist │ └── UserStore.php │ └── util │ └── Validator.php └── AppendixB ├── gi └── parse │ ├── Context.php │ ├── Parser.php │ ├── Reader.php │ ├── Scanner.php │ └── StringReader.php ├── listingApp.01.php ├── listingApp.02.php ├── parse ├── ML_Interpreter.php └── MarkLogic.php ├── run-unit-tests ├── test-parser.php └── test ├── parse ├── ParserTest.php ├── ScannerTest.php └── res │ ├── sample1.txt │ └── sample2.txt └── testutil ├── BaseTest.php └── SuiteWrapper.php /9781430229254.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/php-objects-patterns-practice/6f6913b60a35e0f60dfefd8f8e5863bf005fcd3f/9781430229254.jpg -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/php-objects-patterns-practice/6f6913b60a35e0f60dfefd8f8e5863bf005fcd3f/LICENSE.txt -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Apress Source Code 2 | 3 | This repository accompanies [*PHP Objects, Patterns and Practice*](http://www.apress.com/9781430229254) by Matt Zandstra (Apress, 2010). 4 | 5 | ![Cover image](9781430229254.jpg) 6 | 7 | Download the files as a zip using the green button, or clone the repository to your machine using Git. 8 | 9 | ## Releases 10 | 11 | Release v1.0 corresponds to the code in the published book, without corrections or updates. 12 | 13 | ## Contributions 14 | 15 | See the file Contributing.md for more information on how you can contribute to this repository. 16 | -------------------------------------------------------------------------------- /contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing to Apress Source Code 2 | 3 | Copyright for Apress source code belongs to the author(s). However, under fair use you are encouraged to fork and contribute minor corrections and updates for the benefit of the author(s) and other readers. 4 | 5 | ## How to Contribute 6 | 7 | 1. Make sure you have a GitHub account. 8 | 2. Fork the repository for the relevant book. 9 | 3. Create a new branch on which to make your change, e.g. 10 | `git checkout -b my_code_contribution` 11 | 4. Commit your change. Include a commit message describing the correction. Please note that if your commit message is not clear, the correction will not be accepted. 12 | 5. Submit a pull request. 13 | 14 | Thank you for your contribution! -------------------------------------------------------------------------------- /popp-code/10/listing10.01.php: -------------------------------------------------------------------------------- 1 | 19 | -------------------------------------------------------------------------------- /popp-code/10/listing10.02.php: -------------------------------------------------------------------------------- 1 | units, $unit ); 25 | } 26 | 27 | function bombardStrength() { 28 | $ret = 0; 29 | foreach( $this->units as $unit ) { 30 | $ret += $unit->bombardStrength(); 31 | } 32 | return $ret; 33 | } 34 | } 35 | 36 | $unit1 = new Archer(); 37 | $unit2 = new LaserCannonUnit(); 38 | $army = new Army(); 39 | $army->addUnit( $unit1 ); 40 | $army->addUnit( $unit2 ); 41 | print $army->bombardStrength(); 42 | ?> 43 | -------------------------------------------------------------------------------- /popp-code/10/listing10.09.php: -------------------------------------------------------------------------------- 1 | wealthfactor; 10 | } 11 | } 12 | 13 | class DiamondPlains extends Plains { 14 | function getWealthFactor() { 15 | return parent::getWealthFactor() + 2; 16 | } 17 | } 18 | 19 | class PollutedPlains extends Plains { 20 | function getWealthFactor() { 21 | return parent::getWealthFactor() - 4; 22 | } 23 | } 24 | $tile = new PollutedPlains(); 25 | print $tile->getWealthFactor(); 26 | ?> 27 | -------------------------------------------------------------------------------- /popp-code/10/listing10.10.php: -------------------------------------------------------------------------------- 1 | wealthfactor; 11 | } 12 | } 13 | 14 | abstract class TileDecorator extends Tile { 15 | protected $tile; 16 | function __construct( Tile $tile ) { 17 | $this->tile = $tile; 18 | } 19 | } 20 | 21 | class DiamondDecorator extends TileDecorator { 22 | function getWealthFactor() { 23 | return $this->tile->getWealthFactor()+2; 24 | } 25 | } 26 | 27 | class PollutionDecorator extends TileDecorator { 28 | function getWealthFactor() { 29 | return $this->tile->getWealthFactor()-4; 30 | } 31 | } 32 | 33 | $tile = new Plains(); 34 | print $tile->getWealthFactor(); // 2 35 | 36 | $tile = new DiamondDecorator( new Plains() ); 37 | print $tile->getWealthFactor(); // 4 38 | 39 | $tile = new PollutionDecorator( 40 | new DiamondDecorator( new Plains() )); 41 | print $tile->getWealthFactor(); // 0 42 | ?> 43 | -------------------------------------------------------------------------------- /popp-code/10/listing10.12.php: -------------------------------------------------------------------------------- 1 | id = $id; 31 | $this->name = $name; 32 | } 33 | } 34 | 35 | $lines = getProductFileLines( 'test.txt' ); 36 | $objects = array(); 37 | foreach ( $lines as $line ) { 38 | $id = getIDFromLine( $line ); 39 | $name = getNameFromLine( $line ); 40 | $objects[$id] = getProductObjectFromID( $id, $name ); 41 | } 42 | 43 | print_r( $objects ); 44 | ?> 45 | -------------------------------------------------------------------------------- /popp-code/11/commands/Command.php: -------------------------------------------------------------------------------- 1 | 9 | -------------------------------------------------------------------------------- /popp-code/11/commands/FeedbackCommand.php: -------------------------------------------------------------------------------- 1 | get( 'email' ); 9 | $msg = $context->get( 'msg' ); 10 | $topic = $context->get( 'topic' ); 11 | $result = $msgSystem->send( $email, $msg, $topic ); 12 | if ( ! $result ) { 13 | $context->setError( $msgSystem->getError() ); 14 | return false; 15 | } 16 | return true; 17 | } 18 | } 19 | 20 | 21 | ?> 22 | -------------------------------------------------------------------------------- /popp-code/11/commands/LoginCommand.php: -------------------------------------------------------------------------------- 1 | get( 'username' ); 9 | $pass = $context->get( 'pass' ); 10 | $user_obj = $manager->login( $user, $pass ); 11 | if ( is_null( $user_obj ) ) { 12 | $context->setError( $manager->getError() ); 13 | return false; 14 | } 15 | $context->addParam( "user", $user_obj ); 16 | return true; 17 | } 18 | } 19 | ?> 20 | -------------------------------------------------------------------------------- /popp-code/12/VenueStub.php: -------------------------------------------------------------------------------- 1 | name = $name; 11 | $this->id = $id; 12 | } 13 | function getName() { 14 | return $this->name; 15 | } 16 | function getId() { 17 | return $this->id; 18 | } 19 | } 20 | 21 | $x = new Venue( null, 'bob' ); 22 | $x = new Venue( 55, 'bob' ); 23 | print $x->getName(); 24 | print $x->getId(); 25 | ?> 26 | -------------------------------------------------------------------------------- /popp-code/12/add_venue.php: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | Add Venue 8 | 9 | 10 |

Add Venue

11 | 12 | 13 | 14 | 19 | 20 |
15 | getFeedbackString("
"); 17 | ?> 18 |
21 | 22 |
23 | 24 | 25 |
26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /popp-code/12/data/dsn: -------------------------------------------------------------------------------- 1 | s:22:"sqlite://./data/woo.db"; -------------------------------------------------------------------------------- /popp-code/12/data/woo.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/php-objects-patterns-practice/6f6913b60a35e0f60dfefd8f8e5863bf005fcd3f/popp-code/12/data/woo.db -------------------------------------------------------------------------------- /popp-code/12/data/woo_options.xml: -------------------------------------------------------------------------------- 1 | 2 | sqlite://./data/woo.db 3 | 4 | 5 | main 6 | main 7 | error 8 | 9 | 10 | listvenues 11 | 12 | 13 | 14 | 15 | quickadd 16 | 17 | 18 | 19 | addvenue 20 | 21 | AddSpace 22 | 23 | 24 | 25 | 26 | 27 | addspace 28 | 29 | ListVenues 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /popp-code/12/listing12.01.php: -------------------------------------------------------------------------------- 1 | request; 16 | } 17 | 18 | function setRequest( Request $request ) { 19 | $this->request = $request; 20 | } 21 | } 22 | // empty class for testing 23 | class Request {} 24 | 25 | $reg = Registry::instance(); 26 | $reg->setRequest( new Request() ); 27 | 28 | $reg = Registry::instance(); 29 | print_r( $reg->getRequest() ); 30 | ?> 31 | -------------------------------------------------------------------------------- /popp-code/12/listing12.02.php: -------------------------------------------------------------------------------- 1 | values[$key] ) ) { 16 | return $this->values[$key]; 17 | } 18 | return null; 19 | } 20 | 21 | function set( $key, $value ) { 22 | $this->values[$key] = $value; 23 | } 24 | } 25 | 26 | // empty class for testing 27 | class Request {} 28 | 29 | $reg = Registry::instance(); 30 | $reg->set( 'request', new Request() ); 31 | 32 | $reg = Registry::instance(); 33 | print_r( $reg->get( 'request' ) ); 34 | 35 | ?> 36 | -------------------------------------------------------------------------------- /popp-code/12/listing12.05.run.php: -------------------------------------------------------------------------------- 1 | 12 | 13 | 14 | Venues 15 | 16 | 17 |

Venues

18 | 19 | 20 | getName(); ?>
21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /popp-code/12/readme: -------------------------------------------------------------------------------- 1 | copy the data/ directory to /tmp which is the expected, hard coded location (clearly not something we'd do in a real system!). The ApplicationController will look for /tmp/data/options.xml 2 | -------------------------------------------------------------------------------- /popp-code/12/runner.php: -------------------------------------------------------------------------------- 1 | 5 | -------------------------------------------------------------------------------- /popp-code/12/woo/base/Exceptions.php: -------------------------------------------------------------------------------- 1 | getMessage(), $error->getCode() ); 10 | $this->error = $db_error; 11 | } 12 | 13 | function getErrorObject() { 14 | return $this->error; 15 | } 16 | 17 | } 18 | 19 | 20 | ?> 21 | -------------------------------------------------------------------------------- /popp-code/12/woo/command/AddVenue.php: -------------------------------------------------------------------------------- 1 | getProperty("venue_name"); 9 | if ( ! $name ) { 10 | $request->addFeedback( "no name provided" ); 11 | return self::statuses('CMD_INSUFFICIENT_DATA'); 12 | } else { 13 | $venue_obj = new \woo\domain\Venue( null, $name ); 14 | $request->setObject( 'venue', $venue_obj ); 15 | //\woo\domain\ObjectWatcher::instance()->performOperations(); 16 | $venue_obj->finder()->insert( $venue_obj ); 17 | $request->addFeedback( "'$name' added ({$venue_obj->getId()})" ); 18 | return self::statuses('CMD_OK'); 19 | } 20 | return self::statuses('CMD_DEFAULT'); 21 | } 22 | } 23 | 24 | ?> 25 | -------------------------------------------------------------------------------- /popp-code/12/woo/command/Command.php: -------------------------------------------------------------------------------- 1 | 0, 9 | 'CMD_OK' => 1, 10 | 'CMD_ERROR' => 2, 11 | 'CMD_INSUFFICIENT_DATA' => 3 12 | ); 13 | 14 | private $status = 0; 15 | 16 | final function __construct() { } 17 | 18 | function execute( \woo\controller\Request $request ) { 19 | $this->status = $this->doExecute( $request ); 20 | $request->setCommand( $this ); 21 | } 22 | 23 | function getStatus() { 24 | return $this->status; 25 | } 26 | 27 | static function statuses( $str='CMD_DEFAULT' ) { 28 | if ( empty( $str ) ) { $str = 'CMD_DEFAULT'; } 29 | return self::$STATUS_STRINGS[$str]; 30 | } 31 | 32 | abstract function doExecute( \woo\controller\Request $request ); 33 | } 34 | ?> 35 | -------------------------------------------------------------------------------- /popp-code/12/woo/command/DefaultCommand.php: -------------------------------------------------------------------------------- 1 | addFeedback( "Welcome to WOO" ); 9 | } 10 | } 11 | 12 | ?> 13 | -------------------------------------------------------------------------------- /popp-code/12/woo/command/DefaultCommand2.php: -------------------------------------------------------------------------------- 1 | addFeedback( "Welcome to WOO" ); 9 | } 10 | } 11 | 12 | ?> 13 | -------------------------------------------------------------------------------- /popp-code/12/woo/command/ListVenues.php: -------------------------------------------------------------------------------- 1 | setObject( 'venues', $collection ); 10 | return self::statuses( 'CMD_OK' ); 11 | } 12 | } 13 | 14 | ?> 15 | -------------------------------------------------------------------------------- /popp-code/12/woo/domain.php: -------------------------------------------------------------------------------- 1 | 11 | -------------------------------------------------------------------------------- /popp-code/12/woo/domain/Collections.php: -------------------------------------------------------------------------------- 1 | 17 | -------------------------------------------------------------------------------- /popp-code/12/woo/domain/Finders.php: -------------------------------------------------------------------------------- 1 | 24 | -------------------------------------------------------------------------------- /popp-code/12/woo/domain/HelperFactory.php: -------------------------------------------------------------------------------- 1 | 31 | -------------------------------------------------------------------------------- /popp-code/12/woo/view/ViewHelper.php: -------------------------------------------------------------------------------- 1 | 13 | -------------------------------------------------------------------------------- /popp-code/12/woo/view/addspace.php: -------------------------------------------------------------------------------- 1 | getObject('venue'); 5 | ?> 6 | 7 | 8 | 9 | Add a Space for venue <?php echo $venue->getName() ?> 10 | 11 | 12 |

Add a Space for Venue 'getName() ?>'

13 | 14 | 15 | 16 | 19 | 20 |
17 | getFeedbackString("
"); ?> 18 |
21 | [add space] 22 |
23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /popp-code/12/woo/view/addvenue.php: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | Add a Venue 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 |
15 | getFeedbackString("
"); ?> 16 |
19 | 20 |
21 | 22 | 23 |
24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /popp-code/12/woo/view/listvenues.php: -------------------------------------------------------------------------------- 1 | getObject('venues'); 5 | ?> 6 | 7 | 8 | 9 | Here are the venues 10 | 11 | 12 | 13 | 14 | 15 | 18 | 19 |
16 | getFeedbackString("
"); ?> 17 |
20 | getName()}
\n"; 23 | foreach( $venue->getSpaces() as $space ) { 24 | print "  {$space->getName()}
\n"; 25 | foreach ( $space->getEvents() as $event ) { 26 | print "  {$event->getName()}\n"; 27 | } 28 | } 29 | } 30 | ?> 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /popp-code/12/woo/view/main.php: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | Woo! it's WOO! 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 |
15 | getFeedbackString("
"); ?> 16 |
19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /popp-code/13/001_Mapper_to_LazyLoad/data/woo_options.xml: -------------------------------------------------------------------------------- 1 | 2 | sqlite://tmp/data/woo.db 3 | 4 | 5 | main 6 | main 7 | error 8 | 9 | 10 | listvenues 11 | 12 | 13 | 14 | 15 | quickadd 16 | 17 | 18 | 19 | addvenue 20 | 21 | AddSpace 22 | 23 | 24 | 25 | 26 | 27 | addspace 28 | 29 | ListVenues 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /popp-code/13/001_Mapper_to_LazyLoad/listing13.03.php: -------------------------------------------------------------------------------- 1 | add( new \woo\domain\Venue( null, "Loud and Thumping" ) ); 5 | $collection->add( new \woo\domain\Venue( null, "Eeezy" ) ); 6 | $collection->add( new \woo\domain\Venue( null, "Duck and Badger" ) ); 7 | 8 | foreach( $collection as $venue ) { 9 | print $venue->getName()."\n"; 10 | } 11 | ?> 12 | -------------------------------------------------------------------------------- /popp-code/13/001_Mapper_to_LazyLoad/quicksetupscript: -------------------------------------------------------------------------------- 1 | mv /tmp/data /tmp/data.$$ 2 | cp -r data/ /tmp/data 3 | php ./build-db.php 4 | #php runner.php cmd=AddVenue venue_name="myvenue" 5 | #php runner.php cmd=AddSpace venue_id="1" space_name="my, er, space" 6 | -------------------------------------------------------------------------------- /popp-code/13/001_Mapper_to_LazyLoad/readme: -------------------------------------------------------------------------------- 1 | copy the data/ directory to /tmp which is the expected, hard coded location (clearly not something we'd do in a real system!). The ApplicationController will look for /tmp/data/options.xml 2 | 3 | 4 | STOP PRESS... 5 | 6 | see the little quicksetupscript -- this moves data/ for you and runs a sqlite setup script, and then demos a couple of GUI commands. This will probably destroy your machine and make off with your beer, so I didn't recommend that you run it, ok? 7 | -------------------------------------------------------------------------------- /popp-code/13/001_Mapper_to_LazyLoad/runner.php: -------------------------------------------------------------------------------- 1 | 5 | -------------------------------------------------------------------------------- /popp-code/13/001_Mapper_to_LazyLoad/woo/base/Exceptions.php: -------------------------------------------------------------------------------- 1 | getMessage(), $error->getCode() ); 10 | $this->error = $db_error; 11 | } 12 | 13 | function getErrorObject() { 14 | return $this->error; 15 | } 16 | 17 | } 18 | 19 | 20 | ?> 21 | -------------------------------------------------------------------------------- /popp-code/13/001_Mapper_to_LazyLoad/woo/command/AddVenue.php: -------------------------------------------------------------------------------- 1 | getProperty("venue_name"); 10 | if ( ! $name ) { 11 | $request->addFeedback( "no name provided" ); 12 | return self::statuses('CMD_INSUFFICIENT_DATA'); 13 | } else { 14 | $venue_obj = new \woo\domain\Venue( null, $name ); 15 | $request->setObject( 'venue', $venue_obj ); 16 | //\woo\domain\ObjectWatcher::instance()->performOperations(); 17 | $venue_obj->finder()->insert( $venue_obj ); 18 | $request->addFeedback( "'$name' added ({$venue_obj->getId()})" ); 19 | return self::statuses('CMD_OK'); 20 | } 21 | return self::statuses('CMD_DEFAULT'); 22 | } 23 | } 24 | 25 | ?> 26 | -------------------------------------------------------------------------------- /popp-code/13/001_Mapper_to_LazyLoad/woo/command/Command.php: -------------------------------------------------------------------------------- 1 | 0, 9 | 'CMD_OK' => 1, 10 | 'CMD_ERROR' => 2, 11 | 'CMD_INSUFFICIENT_DATA' => 3 12 | ); 13 | 14 | private $status = 0; 15 | 16 | final function __construct() { } 17 | 18 | function execute( \woo\controller\Request $request ) { 19 | $this->status = $this->doExecute( $request ); 20 | $request->setCommand( $this ); 21 | } 22 | 23 | function getStatus() { 24 | return $this->status; 25 | } 26 | 27 | static function statuses( $str='CMD_DEFAULT' ) { 28 | if ( empty( $str ) ) { $str = 'CMD_DEFAULT'; } 29 | return self::$STATUS_STRINGS[$str]; 30 | } 31 | 32 | abstract function doExecute( \woo\controller\Request $request ); 33 | } 34 | ?> 35 | -------------------------------------------------------------------------------- /popp-code/13/001_Mapper_to_LazyLoad/woo/command/DefaultCommand.php: -------------------------------------------------------------------------------- 1 | addFeedback( "Welcome to WOO" ); 9 | //include( "woo/view/main.php"); 10 | } 11 | } 12 | 13 | ?> 14 | -------------------------------------------------------------------------------- /popp-code/13/001_Mapper_to_LazyLoad/woo/command/DefaultCommand2.php: -------------------------------------------------------------------------------- 1 | addFeedback( "Welcome to WOO" ); 9 | } 10 | } 11 | 12 | ?> 13 | -------------------------------------------------------------------------------- /popp-code/13/001_Mapper_to_LazyLoad/woo/command/ListVenues.php: -------------------------------------------------------------------------------- 1 | setObject( 'venues', $collection ); 10 | return self::statuses( 'CMD_OK' ); 11 | } 12 | } 13 | 14 | ?> 15 | -------------------------------------------------------------------------------- /popp-code/13/001_Mapper_to_LazyLoad/woo/domain.php: -------------------------------------------------------------------------------- 1 | 11 | -------------------------------------------------------------------------------- /popp-code/13/001_Mapper_to_LazyLoad/woo/domain/Collections.php: -------------------------------------------------------------------------------- 1 | 17 | -------------------------------------------------------------------------------- /popp-code/13/001_Mapper_to_LazyLoad/woo/domain/Finders.php: -------------------------------------------------------------------------------- 1 | 24 | -------------------------------------------------------------------------------- /popp-code/13/001_Mapper_to_LazyLoad/woo/domain/HelperFactory.php: -------------------------------------------------------------------------------- 1 | 31 | -------------------------------------------------------------------------------- /popp-code/13/001_Mapper_to_LazyLoad/woo/view/ViewHelper.php: -------------------------------------------------------------------------------- 1 | 13 | -------------------------------------------------------------------------------- /popp-code/13/001_Mapper_to_LazyLoad/woo/view/addspace.php: -------------------------------------------------------------------------------- 1 | getObject('venue'); 5 | ?> 6 | 7 | 8 | 9 | Add a Space for venue <?php echo $venue->getName() ?> 10 | 11 | 12 |

Add a Space for Venue 'getName() ?>'

13 | 14 | 15 | 16 | 19 | 20 |
17 | getFeedbackString("
"); ?> 18 |
21 | [add space] 22 |
23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /popp-code/13/001_Mapper_to_LazyLoad/woo/view/addvenue.php: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | Add a Venue 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 |
15 | getFeedbackString("
"); ?> 16 |
19 | 20 |
21 | 22 | 23 |
24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /popp-code/13/001_Mapper_to_LazyLoad/woo/view/listvenues.php: -------------------------------------------------------------------------------- 1 | getObject('venues'); 5 | ?> 6 | 7 | 8 | 9 | Here are the venues 10 | 11 | 12 | 13 | 14 | 15 | 18 | 19 |
16 | getFeedbackString("
"); ?> 17 |
20 | getName()}
\n"; 23 | foreach( $venue->getSpaces() as $space ) { 24 | print "  {$space->getName()}
\n"; 25 | foreach ( $space->getEvents() as $event ) { 26 | print "  {$event->getName()}\n"; 27 | } 28 | } 29 | } 30 | ?> 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /popp-code/13/001_Mapper_to_LazyLoad/woo/view/main.php: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | Woo! it's WOO! 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 |
15 | getFeedbackString("
"); ?> 16 |
19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /popp-code/13/002_DomainObjectFactory/runner.php: -------------------------------------------------------------------------------- 1 | 5 | -------------------------------------------------------------------------------- /popp-code/13/002_DomainObjectFactory/woo/base/Exceptions.php: -------------------------------------------------------------------------------- 1 | getMessage(), $error->getCode() ); 10 | $this->error = $db_error; 11 | } 12 | 13 | function getErrorObject() { 14 | return $this->error; 15 | } 16 | 17 | } 18 | 19 | 20 | ?> 21 | -------------------------------------------------------------------------------- /popp-code/13/002_DomainObjectFactory/woo/command/AddVenue.php: -------------------------------------------------------------------------------- 1 | getProperty("venue_name"); 10 | if ( ! $name ) { 11 | $request->addFeedback( "no name provided" ); 12 | return self::statuses('CMD_INSUFFICIENT_DATA'); 13 | } else { 14 | $venue_obj = new \woo\domain\Venue( null, $name ); 15 | $request->setObject( 'venue', $venue_obj ); 16 | //\woo\domain\ObjectWatcher::instance()->performOperations(); 17 | $venue_obj->finder()->insert( $venue_obj ); 18 | $request->addFeedback( "'$name' added ({$venue_obj->getId()})" ); 19 | return self::statuses('CMD_OK'); 20 | } 21 | return self::statuses('CMD_DEFAULT'); 22 | } 23 | } 24 | 25 | ?> 26 | -------------------------------------------------------------------------------- /popp-code/13/002_DomainObjectFactory/woo/command/Command.php: -------------------------------------------------------------------------------- 1 | 0, 9 | 'CMD_OK' => 1, 10 | 'CMD_ERROR' => 2, 11 | 'CMD_INSUFFICIENT_DATA' => 3 12 | ); 13 | 14 | private $status = 0; 15 | 16 | final function __construct() { } 17 | 18 | function execute( \woo\controller\Request $request ) { 19 | $this->status = $this->doExecute( $request ); 20 | $request->setCommand( $this ); 21 | } 22 | 23 | function getStatus() { 24 | return $this->status; 25 | } 26 | 27 | static function statuses( $str='CMD_DEFAULT' ) { 28 | if ( empty( $str ) ) { $str = 'CMD_DEFAULT'; } 29 | return self::$STATUS_STRINGS[$str]; 30 | } 31 | 32 | abstract function doExecute( \woo\controller\Request $request ); 33 | } 34 | ?> 35 | -------------------------------------------------------------------------------- /popp-code/13/002_DomainObjectFactory/woo/command/DefaultCommand.php: -------------------------------------------------------------------------------- 1 | addFeedback( "Welcome to WOO" ); 9 | //include( "woo/view/main.php"); 10 | } 11 | } 12 | 13 | ?> 14 | -------------------------------------------------------------------------------- /popp-code/13/002_DomainObjectFactory/woo/command/DefaultCommand2.php: -------------------------------------------------------------------------------- 1 | addFeedback( "Welcome to WOO" ); 9 | } 10 | } 11 | 12 | ?> 13 | -------------------------------------------------------------------------------- /popp-code/13/002_DomainObjectFactory/woo/command/ListVenues.php: -------------------------------------------------------------------------------- 1 | setObject( 'venues', $collection ); 10 | return self::statuses( 'CMD_OK' ); 11 | } 12 | } 13 | 14 | ?> 15 | -------------------------------------------------------------------------------- /popp-code/13/002_DomainObjectFactory/woo/domain.php: -------------------------------------------------------------------------------- 1 | 11 | -------------------------------------------------------------------------------- /popp-code/13/002_DomainObjectFactory/woo/domain/Collections.php: -------------------------------------------------------------------------------- 1 | 17 | -------------------------------------------------------------------------------- /popp-code/13/002_DomainObjectFactory/woo/domain/Finders.php: -------------------------------------------------------------------------------- 1 | 24 | -------------------------------------------------------------------------------- /popp-code/13/002_DomainObjectFactory/woo/domain/HelperFactory.php: -------------------------------------------------------------------------------- 1 | 31 | -------------------------------------------------------------------------------- /popp-code/13/002_DomainObjectFactory/woo/view/ViewHelper.php: -------------------------------------------------------------------------------- 1 | 13 | -------------------------------------------------------------------------------- /popp-code/13/002_DomainObjectFactory/woo/view/addspace.php: -------------------------------------------------------------------------------- 1 | getObject('venue'); 5 | ?> 6 | 7 | 8 | 9 | Add a Space for venue <?php echo $venue->getName() ?> 10 | 11 | 12 |

Add a Space for Venue 'getName() ?>'

13 | 14 | 15 | 16 | 19 | 20 |
17 | getFeedbackString("
"); ?> 18 |
21 | [add space] 22 |
23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /popp-code/13/002_DomainObjectFactory/woo/view/addvenue.php: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | Add a Venue 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 |
15 | getFeedbackString("
"); ?> 16 |
19 | 20 |
21 | 22 | 23 |
24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /popp-code/13/002_DomainObjectFactory/woo/view/listvenues.php: -------------------------------------------------------------------------------- 1 | getObject('venues'); 5 | ?> 6 | 7 | 8 | 9 | Here are the venues 10 | 11 | 12 | 13 | 14 | 15 | 18 | 19 |
16 | getFeedbackString("
"); ?> 17 |
20 | getName()}
\n"; 23 | foreach( $venue->getSpaces() as $space ) { 24 | print "  {$space->getName()}
\n"; 25 | foreach ( $space->getEvents() as $event ) { 26 | print "  {$event->getName()}\n"; 27 | } 28 | } 29 | } 30 | ?> 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /popp-code/13/002_DomainObjectFactory/woo/view/main.php: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | Woo! it's WOO! 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 |
15 | getFeedbackString("
"); ?> 16 |
19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /popp-code/13/003_QueryFactories/runner.php: -------------------------------------------------------------------------------- 1 | 5 | -------------------------------------------------------------------------------- /popp-code/13/003_QueryFactories/woo/base/Exceptions.php: -------------------------------------------------------------------------------- 1 | getMessage(), $error->getCode() ); 10 | $this->error = $db_error; 11 | } 12 | 13 | function getErrorObject() { 14 | return $this->error; 15 | } 16 | 17 | } 18 | 19 | 20 | ?> 21 | -------------------------------------------------------------------------------- /popp-code/13/003_QueryFactories/woo/command/AddVenue.php: -------------------------------------------------------------------------------- 1 | getProperty("venue_name"); 10 | if ( ! $name ) { 11 | $request->addFeedback( "no name provided" ); 12 | return self::statuses('CMD_INSUFFICIENT_DATA'); 13 | } else { 14 | $venue_obj = new \woo\domain\Venue( null, $name ); 15 | $request->setObject( 'venue', $venue_obj ); 16 | //\woo\domain\ObjectWatcher::instance()->performOperations(); 17 | $venue_obj->finder()->insert( $venue_obj ); 18 | $request->addFeedback( "'$name' added ({$venue_obj->getId()})" ); 19 | return self::statuses('CMD_OK'); 20 | } 21 | return self::statuses('CMD_DEFAULT'); 22 | } 23 | } 24 | 25 | ?> 26 | -------------------------------------------------------------------------------- /popp-code/13/003_QueryFactories/woo/command/Command.php: -------------------------------------------------------------------------------- 1 | 0, 9 | 'CMD_OK' => 1, 10 | 'CMD_ERROR' => 2, 11 | 'CMD_INSUFFICIENT_DATA' => 3 12 | ); 13 | 14 | private $status = 0; 15 | 16 | final function __construct() { } 17 | 18 | function execute( \woo\controller\Request $request ) { 19 | $this->status = $this->doExecute( $request ); 20 | $request->setCommand( $this ); 21 | } 22 | 23 | function getStatus() { 24 | return $this->status; 25 | } 26 | 27 | static function statuses( $str='CMD_DEFAULT' ) { 28 | if ( empty( $str ) ) { $str = 'CMD_DEFAULT'; } 29 | return self::$STATUS_STRINGS[$str]; 30 | } 31 | 32 | abstract function doExecute( \woo\controller\Request $request ); 33 | } 34 | ?> 35 | -------------------------------------------------------------------------------- /popp-code/13/003_QueryFactories/woo/command/DefaultCommand.php: -------------------------------------------------------------------------------- 1 | addFeedback( "Welcome to WOO" ); 9 | //include( "woo/view/main.php"); 10 | } 11 | } 12 | 13 | ?> 14 | -------------------------------------------------------------------------------- /popp-code/13/003_QueryFactories/woo/command/DefaultCommand2.php: -------------------------------------------------------------------------------- 1 | addFeedback( "Welcome to WOO" ); 9 | } 10 | } 11 | 12 | ?> 13 | -------------------------------------------------------------------------------- /popp-code/13/003_QueryFactories/woo/command/ListVenues.php: -------------------------------------------------------------------------------- 1 | setObject( 'venues', $collection ); 10 | 11 | $factory = \woo\mapper\PersistenceFactory::getFactory( 'woo\domain\Venue' ); 12 | $finder = new \woo\mapper\DomainObjectAssembler( $factory ); 13 | $idobj = $factory->getIdentityObject()->field('name')->eq('The Eyeball Inn'); 14 | $collection = $finder->find( $idobj ); 15 | foreach ( $collection as $venue ) { 16 | print_r( $venue ); 17 | } 18 | 19 | return self::statuses( 'CMD_OK' ); 20 | } 21 | } 22 | 23 | ?> 24 | -------------------------------------------------------------------------------- /popp-code/13/003_QueryFactories/woo/domain.php: -------------------------------------------------------------------------------- 1 | 11 | -------------------------------------------------------------------------------- /popp-code/13/003_QueryFactories/woo/domain/Collections.php: -------------------------------------------------------------------------------- 1 | 17 | -------------------------------------------------------------------------------- /popp-code/13/003_QueryFactories/woo/domain/Finders.php: -------------------------------------------------------------------------------- 1 | 24 | -------------------------------------------------------------------------------- /popp-code/13/003_QueryFactories/woo/domain/HelperFactory.php: -------------------------------------------------------------------------------- 1 | getCollection( $array ); 21 | } 22 | 23 | } 24 | ?> 25 | -------------------------------------------------------------------------------- /popp-code/13/003_QueryFactories/woo/mapper/EventIdentityObject.php: -------------------------------------------------------------------------------- 1 | 12 | -------------------------------------------------------------------------------- /popp-code/13/003_QueryFactories/woo/mapper/EventSelectionFactory.php: -------------------------------------------------------------------------------- 1 | getObjectFields() ); 11 | $core = "SELECT $fields FROM event"; 12 | list( $where, $values ) = $this->buildWhere( $obj ); 13 | return array( $core." ".$where, $values ); 14 | } 15 | } 16 | ?> 17 | -------------------------------------------------------------------------------- /popp-code/13/003_QueryFactories/woo/mapper/EventUpdateFactory.php: -------------------------------------------------------------------------------- 1 | getId(); 11 | $cond = null; 12 | $values['name'] = $obj->getName(); 13 | $values['space'] = $obj->getSpace()->getId(); 14 | 15 | if ( $id > -1 ) { 16 | $cond['id'] = $id; 17 | } 18 | return $this->buildStatement( "event", $values, $cond ); 19 | } 20 | } 21 | ?> 22 | -------------------------------------------------------------------------------- /popp-code/13/003_QueryFactories/woo/mapper/SelectionFactory.php: -------------------------------------------------------------------------------- 1 | isVoid() ) { 12 | return array( "", array() ); 13 | } 14 | $compstrings = array(); 15 | $values = array(); 16 | foreach ( $obj->getComps() as $comp ) { 17 | $compstrings[] = "{$comp['name']} {$comp['operator']} ?"; 18 | $values[] = $comp['value']; 19 | } 20 | $where = "WHERE " . implode( " AND ", $compstrings ); 21 | return array( $where, $values ); 22 | } 23 | } 24 | 25 | ?> 26 | -------------------------------------------------------------------------------- /popp-code/13/003_QueryFactories/woo/mapper/SpaceIdentityObject.php: -------------------------------------------------------------------------------- 1 | 13 | -------------------------------------------------------------------------------- /popp-code/13/003_QueryFactories/woo/mapper/SpaceSelectionFactory.php: -------------------------------------------------------------------------------- 1 | getObjectFields() ); 11 | $core = "SELECT $fields FROM space"; 12 | list( $where, $values ) = $this->buildWhere( $obj ); 13 | return array( $core." ".$where, $values ); 14 | } 15 | 16 | } 17 | ?> 18 | -------------------------------------------------------------------------------- /popp-code/13/003_QueryFactories/woo/mapper/SpaceUpdateFactory.php: -------------------------------------------------------------------------------- 1 | getId(); 11 | $cond = null; 12 | $values['name'] = $obj->getName(); 13 | $values['venue'] = $obj->getVenue()->getId(); 14 | 15 | if ( $id > -1 ) { 16 | $cond['id'] = $id; 17 | } 18 | return $this->buildStatement( "space", $values, $cond ); 19 | } 20 | } 21 | ?> 22 | -------------------------------------------------------------------------------- /popp-code/13/003_QueryFactories/woo/mapper/VenueIdentityObject.php: -------------------------------------------------------------------------------- 1 | 13 | -------------------------------------------------------------------------------- /popp-code/13/003_QueryFactories/woo/mapper/VenueSelectionFactory.php: -------------------------------------------------------------------------------- 1 | getObjectFields() ); 11 | $core = "SELECT $fields FROM venue"; 12 | list( $where, $values ) = $this->buildWhere( $obj ); 13 | return array( $core." ".$where, $values ); 14 | } 15 | 16 | } 17 | ?> 18 | -------------------------------------------------------------------------------- /popp-code/13/003_QueryFactories/woo/mapper/VenueUpdateFactory.php: -------------------------------------------------------------------------------- 1 | getId(); 11 | $cond = null; 12 | $values['name'] = $obj->getName(); 13 | if ( $id > -1 ) { 14 | $cond['id'] = $id; 15 | } 16 | return $this->buildStatement( "venue", $values, $cond ); 17 | } 18 | 19 | } 20 | ?> 21 | -------------------------------------------------------------------------------- /popp-code/13/003_QueryFactories/woo/view/ViewHelper.php: -------------------------------------------------------------------------------- 1 | 13 | -------------------------------------------------------------------------------- /popp-code/13/003_QueryFactories/woo/view/addspace.php: -------------------------------------------------------------------------------- 1 | getObject('venue'); 5 | ?> 6 | 7 | 8 | 9 | Add a Space for venue <?php echo $venue->getName() ?> 10 | 11 | 12 |

Add a Space for Venue 'getName() ?>'

13 | 14 | 15 | 16 | 19 | 20 |
17 | getFeedbackString("
"); ?> 18 |
21 | [add space] 22 |
23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /popp-code/13/003_QueryFactories/woo/view/addvenue.php: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | Add a Venue 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 |
15 | getFeedbackString("
"); ?> 16 |
19 | 20 |
21 | 22 | 23 |
24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /popp-code/13/003_QueryFactories/woo/view/listvenues.php: -------------------------------------------------------------------------------- 1 | getObject('venues'); 5 | ?> 6 | 7 | 8 | 9 | Here are the venues 10 | 11 | 12 | 13 | 14 | 15 | 18 | 19 |
16 | getFeedbackString("
"); ?> 17 |
20 | getName()}
\n"; 23 | foreach( $venue->getSpaces() as $space ) { 24 | print "  {$space->getName()}
\n"; 25 | foreach ( $space->getEvents() as $event ) { 26 | print "  {$event->getName()}\n"; 27 | } 28 | } 29 | } 30 | ?> 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /popp-code/13/003_QueryFactories/woo/view/main.php: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | Woo! it's WOO! 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 |
15 | getFeedbackString("
"); ?> 16 |
19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /popp-code/15/PEAR2_SimpleChannelServer-0.1.0.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/php-objects-patterns-practice/6f6913b60a35e0f60dfefd8f8e5863bf005fcd3f/popp-code/15/PEAR2_SimpleChannelServer-0.1.0.phar -------------------------------------------------------------------------------- /popp-code/15/dialekt/baddialekt/Dialekt.php: -------------------------------------------------------------------------------- 1 | getMessage() ."\n"; 24 | print "code: ". $db->getCode() ."\n\n"; 25 | print "Backtrace:\n"; 26 | 27 | foreach ( $db->getBacktrace() as $caller ) { 28 | print $caller['class'].$caller['type'].$caller['function']."() "; 29 | print "line ".$caller['line']."\n"; 30 | } 31 | } 32 | ?> 33 | -------------------------------------------------------------------------------- /popp-code/15/dialekt/baddialekt/Dialekt/AliG.php: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /popp-code/15/dialekt/baddialekt/Dialekt/Dalek.php: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /popp-code/15/dialekt/baddialekt/cli-dialekt.php: -------------------------------------------------------------------------------- 1 | 5 | -------------------------------------------------------------------------------- /popp-code/15/dialekt/baddialekt/data/alig.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/php-objects-patterns-practice/6f6913b60a35e0f60dfefd8f8e5863bf005fcd3f/popp-code/15/dialekt/baddialekt/data/alig.txt -------------------------------------------------------------------------------- /popp-code/15/dialekt/baddialekt/data/dalek.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/php-objects-patterns-practice/6f6913b60a35e0f60dfefd8f8e5863bf005fcd3f/popp-code/15/dialekt/baddialekt/data/dalek.txt -------------------------------------------------------------------------------- /popp-code/15/dialekt/baddialekt/dialekt-0.2.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/php-objects-patterns-practice/6f6913b60a35e0f60dfefd8f8e5863bf005fcd3f/popp-code/15/dialekt/baddialekt/dialekt-0.2.tgz -------------------------------------------------------------------------------- /popp-code/15/dialekt/baddialekt/script/dialekt.bat: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | exec @php_bin@ -d include_dir=@php_dir@ @php_dir@/dialekt_cli.php "$@" 4 | -------------------------------------------------------------------------------- /popp-code/15/dialekt/baddialekt/script/dialekt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | exec @php_bin@ -d include_dir=@php_dir@ @php_dir@/dialekt_cli.php "$@" 4 | -------------------------------------------------------------------------------- /popp-code/15/dialekt/dialekt-1.2.1/Dialekt-1.2.1.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/php-objects-patterns-practice/6f6913b60a35e0f60dfefd8f8e5863bf005fcd3f/popp-code/15/dialekt/dialekt-1.2.1/Dialekt-1.2.1.tgz -------------------------------------------------------------------------------- /popp-code/15/dialekt/dialekt-1.2.1/Dialekt.php: -------------------------------------------------------------------------------- 1 | getMessage() ."\n"; 24 | print "code: ". $db->getCode() ."\n\n"; 25 | print "Backtrace:\n"; 26 | 27 | foreach ( $db->getBacktrace() as $caller ) { 28 | print $caller['class'].$caller['type'].$caller['function']."() "; 29 | print "line ".$caller['line']."\n"; 30 | } 31 | } 32 | ?> 33 | -------------------------------------------------------------------------------- /popp-code/15/dialekt/dialekt-1.2.1/Dialekt/AliG.php: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /popp-code/15/dialekt/dialekt-1.2.1/Dialekt/Dalek.php: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /popp-code/15/dialekt/dialekt-1.2.1/cli-dialekt.php: -------------------------------------------------------------------------------- 1 | 5 | -------------------------------------------------------------------------------- /popp-code/15/dialekt/dialekt-1.2.1/data/alig.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/php-objects-patterns-practice/6f6913b60a35e0f60dfefd8f8e5863bf005fcd3f/popp-code/15/dialekt/dialekt-1.2.1/data/alig.txt -------------------------------------------------------------------------------- /popp-code/15/dialekt/dialekt-1.2.1/data/dalek.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/php-objects-patterns-practice/6f6913b60a35e0f60dfefd8f8e5863bf005fcd3f/popp-code/15/dialekt/dialekt-1.2.1/data/dalek.txt -------------------------------------------------------------------------------- /popp-code/15/dialekt/dialekt-1.2.1/script/dialekt.bat: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | exec @php_bin@ -d include_dir=@php_dir@ @php_dir@/dialekt_cli.php "$@" 4 | -------------------------------------------------------------------------------- /popp-code/15/dialekt/dialekt-1.2.1/script/dialekt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | exec @php_bin@ -d include_dir=@php_dir@ @php_dir@/dialekt_cli.php "$@" 4 | -------------------------------------------------------------------------------- /popp-code/15/listing15.03.php: -------------------------------------------------------------------------------- 1 | getMessage() ."\n"; 13 | print "code: ". $e->getCode() ."\n"; 14 | print "error class: ". $e->getErrorClass() ."\n"; 15 | print "error method: ".$e->getErrorMethod() ."\n"; 16 | print "trace: ". $e->getTraceAsString()."\n"; 17 | print "error data: "; 18 | print_r( $e->getErrorData() ); 19 | } 20 | ?> 21 | -------------------------------------------------------------------------------- /popp-code/15/my.conf: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /popp-code/15/test.broken.conf: -------------------------------------------------------------------------------- 1 | 2 | 3 | /tmp/myapp/prefs 4 | /tmp/ 5 | 6 | 1.0 8 | 9 | 10 | -------------------------------------------------------------------------------- /popp-code/15/test.conf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | /tmp/myapp/prefs 5 | /tmp/ 6 | 7 | 8 | 1.0 9 | 10 | 11 | -------------------------------------------------------------------------------- /popp-code/16/docs/megaquiz/blank.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Mega Quiz 4 | 5 | 6 | 7 | 8 |

Mega Quiz

9 | Welcome to megaquiz!
10 |
11 | This documentation was generated by phpDocumentor v1.4.3
12 | 13 | -------------------------------------------------------------------------------- /popp-code/16/docs/megaquiz/index.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | Mega Quiz 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | <H2>Frame Alert</H2> 20 | <P>This document is designed to be viewed using the frames feature. 21 | If you see this message, you are using a non-frame-capable web client.</P> 22 | 23 | 24 | -------------------------------------------------------------------------------- /popp-code/16/docs/megaquiz/media/banner.css: -------------------------------------------------------------------------------- 1 | body 2 | { 3 | background-color: #CCCCFF; 4 | margin: 0px; 5 | padding: 0px; 6 | } 7 | 8 | /* Banner (top bar) classes */ 9 | 10 | .banner { } 11 | 12 | .banner-menu 13 | { 14 | clear: both; 15 | padding: .5em; 16 | border-top: 2px solid #6666AA; 17 | } 18 | 19 | .banner-title 20 | { 21 | text-align: right; 22 | font-size: 20pt; 23 | font-weight: bold; 24 | margin: .2em; 25 | } 26 | 27 | .package-selector 28 | { 29 | background-color: #AAAADD; 30 | border: 1px solid black; 31 | color: yellow; 32 | } 33 | -------------------------------------------------------------------------------- /popp-code/16/docs/megaquiz/packages.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 26 | 27 | -------------------------------------------------------------------------------- /popp-code/16/docs/megaquiz2/blank.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Mega Quiz 4 | 5 | 6 | 7 | 8 |

Mega Quiz

9 | Welcome to megaquiz!
10 |
11 | This documentation was generated by phpDocumentor v1.4.3
12 | 13 | -------------------------------------------------------------------------------- /popp-code/16/docs/megaquiz2/classtrees_megaquiz.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

14 | 15 |

16 |

Root class User

17 | 19 | 20 |

21 | Documentation generated on Mon, 08 Feb 2010 21:27:54 -0800 by phpDocumentor 1.4.3 22 |

23 | 24 | -------------------------------------------------------------------------------- /popp-code/16/docs/megaquiz2/classtrees_quiztools.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

14 | 15 |

16 |

Root class AccessManager

17 | 19 | 20 |

Root class ReceiverFactory

21 | 23 | 24 |

25 | Documentation generated on Mon, 08 Feb 2010 21:27:54 -0800 by phpDocumentor 1.4.3 26 |

27 | 28 | -------------------------------------------------------------------------------- /popp-code/16/docs/megaquiz2/index.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | Mega Quiz 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | <H2>Frame Alert</H2> 20 | <P>This document is designed to be viewed using the frames feature. 21 | If you see this message, you are using a non-frame-capable web client.</P> 22 | 23 | 24 | -------------------------------------------------------------------------------- /popp-code/16/docs/megaquiz2/media/banner.css: -------------------------------------------------------------------------------- 1 | body 2 | { 3 | background-color: #CCCCFF; 4 | margin: 0px; 5 | padding: 0px; 6 | } 7 | 8 | /* Banner (top bar) classes */ 9 | 10 | .banner { } 11 | 12 | .banner-menu 13 | { 14 | clear: both; 15 | padding: .5em; 16 | border-top: 2px solid #6666AA; 17 | } 18 | 19 | .banner-title 20 | { 21 | text-align: right; 22 | font-size: 20pt; 23 | font-weight: bold; 24 | margin: .2em; 25 | } 26 | 27 | .package-selector 28 | { 29 | background-color: #AAAADD; 30 | border: 1px solid black; 31 | color: yellow; 32 | } 33 | -------------------------------------------------------------------------------- /popp-code/16/docs/megaquiz3/blank.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Mega Quiz 4 | 5 | 6 | 7 | 8 |

Mega Quiz

9 | Welcome to megaquiz!
10 |
11 | This documentation was generated by phpDocumentor v1.4.3
12 | 13 | -------------------------------------------------------------------------------- /popp-code/16/docs/megaquiz3/classtrees_megaquiz.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

14 | 15 |

16 |

17 | Documentation generated on Mon, 08 Feb 2010 21:28:24 -0800 by phpDocumentor 1.4.3 18 |

19 | 20 | -------------------------------------------------------------------------------- /popp-code/16/docs/megaquiz3/classtrees_quizobjects.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

14 | 15 |

16 |

Root class User

17 | 19 | 20 |

21 | Documentation generated on Mon, 08 Feb 2010 21:28:24 -0800 by phpDocumentor 1.4.3 22 |

23 | 24 | -------------------------------------------------------------------------------- /popp-code/16/docs/megaquiz3/classtrees_quiztools.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

14 | 15 |

16 |

Root class AccessManager

17 | 19 | 20 |

Root class ReceiverFactory

21 | 23 | 24 |

25 | Documentation generated on Mon, 08 Feb 2010 21:28:24 -0800 by phpDocumentor 1.4.3 26 |

27 | 28 | -------------------------------------------------------------------------------- /popp-code/16/docs/megaquiz3/errors.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | phpDocumentor Parser Errors and Warnings 7 | 8 | 9 | 10 | 11 | Post-parsing
12 | 13 |

main.php

14 |

Warnings:


15 | Warning on line 15 - File "/home/mattz/Documents/usb/Documents/code/popp3/002_firstpass_outgoing/code/16/megaquiz3/main.php" has no page-level DocBlock, use @package in the first DocBlock to create one
16 |

17 | Documentation generated on Mon, 08 Feb 2010 21:28:25 -0800 by phpDocumentor 1.4.3 18 |

19 | 20 | -------------------------------------------------------------------------------- /popp-code/16/docs/megaquiz3/index.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | Mega Quiz 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | <H2>Frame Alert</H2> 20 | <P>This document is designed to be viewed using the frames feature. 21 | If you see this message, you are using a non-frame-capable web client.</P> 22 | 23 | 24 | -------------------------------------------------------------------------------- /popp-code/16/docs/megaquiz3/media/banner.css: -------------------------------------------------------------------------------- 1 | body 2 | { 3 | background-color: #CCCCFF; 4 | margin: 0px; 5 | padding: 0px; 6 | } 7 | 8 | /* Banner (top bar) classes */ 9 | 10 | .banner { } 11 | 12 | .banner-menu 13 | { 14 | clear: both; 15 | padding: .5em; 16 | border-top: 2px solid #6666AA; 17 | } 18 | 19 | .banner-title 20 | { 21 | text-align: right; 22 | font-size: 20pt; 23 | font-weight: bold; 24 | margin: .2em; 25 | } 26 | 27 | .package-selector 28 | { 29 | background-color: #AAAADD; 30 | border: 1px solid black; 31 | color: yellow; 32 | } 33 | -------------------------------------------------------------------------------- /popp-code/16/docs/megaquiz4/blank.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Mega Quiz 4 | 5 | 6 | 7 | 8 |

Mega Quiz

9 | Welcome to megaquiz!
10 |
11 | This documentation was generated by phpDocumentor v1.4.3
12 | 13 | -------------------------------------------------------------------------------- /popp-code/16/docs/megaquiz4/classtrees_megaquiz.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

14 | 15 |

16 |

17 | Documentation generated on Mon, 08 Feb 2010 21:57:29 -0800 by phpDocumentor 1.4.3 18 |

19 | 20 | -------------------------------------------------------------------------------- /popp-code/16/docs/megaquiz4/classtrees_quizobjects.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

14 | 15 |

16 |

Root class User

17 | 19 | 20 |

21 | Documentation generated on Mon, 08 Feb 2010 21:57:29 -0800 by phpDocumentor 1.4.3 22 |

23 | 24 | -------------------------------------------------------------------------------- /popp-code/16/docs/megaquiz4/classtrees_quiztools.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

14 | 15 |

16 |

Root class AccessManager

17 | 19 | 20 |

Root class ReceiverFactory

21 | 23 | 24 |

25 | Documentation generated on Mon, 08 Feb 2010 21:57:29 -0800 by phpDocumentor 1.4.3 26 |

27 | 28 | -------------------------------------------------------------------------------- /popp-code/16/docs/megaquiz4/errors.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | phpDocumentor Parser Errors and Warnings 7 | 8 | 9 | 10 | 11 | Post-parsing
12 | 13 |

main.php

14 |

Warnings:


15 | Warning on line 15 - File "/home/mattz/Documents/usb/Documents/code/popp3/002_firstpass_outgoing/code/16/megaquiz4/main.php" has no page-level DocBlock, use @package in the first DocBlock to create one
16 |

17 | Documentation generated on Mon, 08 Feb 2010 21:57:30 -0800 by phpDocumentor 1.4.3 18 |

19 | 20 | -------------------------------------------------------------------------------- /popp-code/16/docs/megaquiz4/index.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | Mega Quiz 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | <H2>Frame Alert</H2> 20 | <P>This document is designed to be viewed using the frames feature. 21 | If you see this message, you are using a non-frame-capable web client.</P> 22 | 23 | 24 | -------------------------------------------------------------------------------- /popp-code/16/docs/megaquiz4/media/banner.css: -------------------------------------------------------------------------------- 1 | body 2 | { 3 | background-color: #CCCCFF; 4 | margin: 0px; 5 | padding: 0px; 6 | } 7 | 8 | /* Banner (top bar) classes */ 9 | 10 | .banner { } 11 | 12 | .banner-menu 13 | { 14 | clear: both; 15 | padding: .5em; 16 | border-top: 2px solid #6666AA; 17 | } 18 | 19 | .banner-title 20 | { 21 | text-align: right; 22 | font-size: 20pt; 23 | font-weight: bold; 24 | margin: .2em; 25 | } 26 | 27 | .package-selector 28 | { 29 | background-color: #AAAADD; 30 | border: 1px solid black; 31 | color: yellow; 32 | } 33 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz/command/Command.php: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz/command/CommandContext.php: -------------------------------------------------------------------------------- 1 | params = $_REQUEST; 8 | } 9 | 10 | function addParam( $key, $val ) { 11 | $this->params[$key]=$val; 12 | } 13 | 14 | function get( $key ) { 15 | return $this->params[$key]; 16 | } 17 | 18 | function setError( $error ) { 19 | $this->error = $error; 20 | } 21 | 22 | function getError() { 23 | return $this->error; 24 | } 25 | } 26 | 27 | ?> 28 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz/command/FeedbackCommand.php: -------------------------------------------------------------------------------- 1 | get( 'email' ); 9 | $msg = $context->get( 'pass' ); 10 | $topic = $context->get( 'topic' ); 11 | $result = $msgSystem->despatch( $email, $msg, $topic ); 12 | if ( ! $user ) { 13 | $this->context->setError( $msgSystem->getError() ); 14 | return false; 15 | } 16 | $context->addParam( "user", $user ); 17 | return true; 18 | } 19 | } 20 | 21 | 22 | ?> 23 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz/command/LoginCommand.php: -------------------------------------------------------------------------------- 1 | get( 'username' ); 10 | $pass = $context->get( 'pass' ); 11 | $user = $manager->login( $user, $pass ); 12 | if ( ! $user ) { 13 | $this->context->setError( $manager->getError() ); 14 | return false; 15 | } 16 | $context->addParam( "user", $user ); 17 | return true; 18 | } 19 | } 20 | ?> 21 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz/command/cvs/Entries: -------------------------------------------------------------------------------- 1 | /Command.php/1.1/Fri Jun 11 22:50:10 2004// 2 | /CommandContext.php/1.1/Fri Jun 11 22:50:10 2004// 3 | /FeedbackCommand.php/1.1/Fri Jun 11 22:50:10 2004// 4 | /LoginCommand.php/1.1/Fri Jun 11 22:50:10 2004// 5 | D 6 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz/command/cvs/Repository: -------------------------------------------------------------------------------- 1 | oophp-book/frontend/source/15/megaquiz/command 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz/command/cvs/Root: -------------------------------------------------------------------------------- 1 | :ext:triffid@fate16.com:/usr/local/cvs 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz/cvs/Entries: -------------------------------------------------------------------------------- 1 | /main.php/1.1/Fri Jun 11 22:50:09 2004// 2 | D 3 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz/cvs/Entries.Log: -------------------------------------------------------------------------------- 1 | A D/command//// 2 | A D/quizobjects//// 3 | A D/quiztools//// 4 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz/cvs/Repository: -------------------------------------------------------------------------------- 1 | oophp-book/frontend/source/15/megaquiz 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz/cvs/Root: -------------------------------------------------------------------------------- 1 | :ext:triffid@fate16.com:/usr/local/cvs 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz/main.php: -------------------------------------------------------------------------------- 1 | addParam( "username", "bob" ); 15 | $context->addParam( "pass", "tiddles" ); 16 | $cmd = new LoginCommand( new AccessManager() ); 17 | if ( ! $cmd->execute( $context ) ) { 18 | print "an error occurred: ".$context->getError(); 19 | } else { 20 | print "successful login\n"; 21 | $user_obj = $context->get( "user" ); 22 | } 23 | 24 | ?> 25 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz/quizobjects/User.php: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz/quizobjects/cvs/Entries: -------------------------------------------------------------------------------- 1 | /User.php/1.1/Fri Jun 11 22:50:10 2004// 2 | D 3 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz/quizobjects/cvs/Repository: -------------------------------------------------------------------------------- 1 | oophp-book/frontend/source/15/megaquiz/quizobjects 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz/quizobjects/cvs/Root: -------------------------------------------------------------------------------- 1 | :ext:triffid@fate16.com:/usr/local/cvs 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz/quiztools/AccessManager.php: -------------------------------------------------------------------------------- 1 | 22 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz/quiztools/cvs/Entries: -------------------------------------------------------------------------------- 1 | /AccessManager.php/1.1/Fri Jun 11 22:50:10 2004// 2 | D 3 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz/quiztools/cvs/Repository: -------------------------------------------------------------------------------- 1 | oophp-book/frontend/source/15/megaquiz/quiztools 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz/quiztools/cvs/Root: -------------------------------------------------------------------------------- 1 | :ext:triffid@fate16.com:/usr/local/cvs 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz2/command/Command.php: -------------------------------------------------------------------------------- 1 | 11 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz2/command/CommandContext.php: -------------------------------------------------------------------------------- 1 | params = $_REQUEST; 11 | } 12 | 13 | function addParam( $key, $val ) { 14 | $this->params[$key]=$val; 15 | } 16 | 17 | function get( $key ) { 18 | return $this->params[$key]; 19 | } 20 | 21 | function setError( $error ) { 22 | $this->error = $error; 23 | } 24 | 25 | function getError() { 26 | return $this->error; 27 | } 28 | } 29 | 30 | ?> 31 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz2/command/FeedbackCommand.php: -------------------------------------------------------------------------------- 1 | get( 'email' ); 12 | $msg = $context->get( 'pass' ); 13 | $topic = $context->get( 'topic' ); 14 | $result = $msgSystem->despatch( $email, $msg, $topic ); 15 | if ( ! $user ) { 16 | $this->context->setError( $msgSystem->getError() ); 17 | return false; 18 | } 19 | $context->addParam( "user", $user ); 20 | return true; 21 | } 22 | } 23 | 24 | 25 | ?> 26 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz2/command/LoginCommand.php: -------------------------------------------------------------------------------- 1 | get( 'username' ); 13 | $pass = $context->get( 'pass' ); 14 | $user = $manager->login( $user, $pass ); 15 | if ( ! $user ) { 16 | $this->context->setError( $manager->getError() ); 17 | return false; 18 | } 19 | $context->addParam( "user", $user ); 20 | return true; 21 | } 22 | } 23 | ?> 24 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz2/command/cvs/Entries: -------------------------------------------------------------------------------- 1 | /Command.php/1.1/Fri Jun 11 22:50:10 2004// 2 | /CommandContext.php/1.1/Fri Jun 11 22:50:10 2004// 3 | /FeedbackCommand.php/1.1/Fri Jun 11 22:50:10 2004// 4 | /LoginCommand.php/1.1/Fri Jun 11 22:50:10 2004// 5 | D 6 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz2/command/cvs/Repository: -------------------------------------------------------------------------------- 1 | oophp-book/frontend/source/15/megaquiz2/command 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz2/command/cvs/Root: -------------------------------------------------------------------------------- 1 | :ext:triffid@fate16.com:/usr/local/cvs 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz2/cvs/Entries: -------------------------------------------------------------------------------- 1 | /main.php/1.1/Fri Jun 11 22:50:10 2004// 2 | D 3 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz2/cvs/Entries.Log: -------------------------------------------------------------------------------- 1 | A D/command//// 2 | A D/quizobjects//// 3 | A D/quiztools//// 4 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz2/cvs/Repository: -------------------------------------------------------------------------------- 1 | oophp-book/frontend/source/15/megaquiz2 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz2/cvs/Root: -------------------------------------------------------------------------------- 1 | :ext:triffid@fate16.com:/usr/local/cvs 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz2/main.php: -------------------------------------------------------------------------------- 1 | addParam( "username", "bob" ); 7 | $context->addParam( "pass", "tiddles" ); 8 | $cmd = new LoginCommand( new AccessManager() ); 9 | if ( ! $cmd->execute( $context ) ) { 10 | print "an error occurred: ".$context->getError(); 11 | } else { 12 | print "successful login\n"; 13 | $user_obj = $context->get( "user" ); 14 | } 15 | 16 | ?> 17 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz2/quizobjects/User.php: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz2/quizobjects/cvs/Entries: -------------------------------------------------------------------------------- 1 | /User.php/1.1/Fri Jun 11 22:50:10 2004// 2 | D 3 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz2/quizobjects/cvs/Repository: -------------------------------------------------------------------------------- 1 | oophp-book/frontend/source/15/megaquiz2/quizobjects 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz2/quizobjects/cvs/Root: -------------------------------------------------------------------------------- 1 | :ext:triffid@fate16.com:/usr/local/cvs 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz2/quiztools/AccessManager.php: -------------------------------------------------------------------------------- 1 | 25 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz2/quiztools/cvs/Entries: -------------------------------------------------------------------------------- 1 | /AccessManager.php/1.1/Fri Jun 11 22:50:10 2004// 2 | D 3 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz2/quiztools/cvs/Repository: -------------------------------------------------------------------------------- 1 | oophp-book/frontend/source/15/megaquiz2/quiztools 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz2/quiztools/cvs/Root: -------------------------------------------------------------------------------- 1 | :ext:triffid@fate16.com:/usr/local/cvs 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz3/command/Command.php: -------------------------------------------------------------------------------- 1 | 33 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz3/command/FeedbackCommand.php: -------------------------------------------------------------------------------- 1 | get( 'email' ); 20 | $msg = $context->get( 'pass' ); 21 | $topic = $context->get( 'topic' ); 22 | $result = $msgSystem->despatch( $email, $msg, $topic ); 23 | if ( ! $user ) { 24 | $this->context->setError( $msgSystem->getError() ); 25 | return false; 26 | } 27 | $context->addParam( "user", $user ); 28 | return true; 29 | } 30 | } 31 | 32 | 33 | ?> 34 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz3/command/LoginCommand.php: -------------------------------------------------------------------------------- 1 | get( 'username' ); 21 | $pass = $context->get( 'pass' ); 22 | $user = $manager->login( $user, $pass ); 23 | if ( ! $user ) { 24 | $this->context->setError( $manager->getError() ); 25 | return false; 26 | } 27 | $context->addParam( "user", $user ); 28 | return true; 29 | } 30 | } 31 | ?> 32 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz3/command/cvs/Entries: -------------------------------------------------------------------------------- 1 | /Command.php/1.1/Fri Jun 11 22:50:10 2004// 2 | /CommandContext.php/1.1/Fri Jun 11 22:50:10 2004// 3 | /FeedbackCommand.php/1.1/Fri Jun 11 22:50:10 2004// 4 | /LoginCommand.php/1.1/Fri Jun 11 22:50:10 2004// 5 | D 6 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz3/command/cvs/Repository: -------------------------------------------------------------------------------- 1 | oophp-book/frontend/source/15/megaquiz3/command 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz3/command/cvs/Root: -------------------------------------------------------------------------------- 1 | :ext:triffid@fate16.com:/usr/local/cvs 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz3/cvs/Entries: -------------------------------------------------------------------------------- 1 | /main.php/1.1/Fri Jun 11 22:50:10 2004// 2 | D 3 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz3/cvs/Entries.Log: -------------------------------------------------------------------------------- 1 | A D/command//// 2 | A D/quizobjects//// 3 | A D/quiztools//// 4 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz3/cvs/Repository: -------------------------------------------------------------------------------- 1 | oophp-book/frontend/source/15/megaquiz3 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz3/cvs/Root: -------------------------------------------------------------------------------- 1 | :ext:triffid@fate16.com:/usr/local/cvs 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz3/main.php: -------------------------------------------------------------------------------- 1 | addParam( "username", "bob" ); 7 | $context->addParam( "pass", "tiddles" ); 8 | $cmd = new LoginCommand( new AccessManager() ); 9 | if ( ! $cmd->execute( $context ) ) { 10 | print "an error occurred: ".$context->getError(); 11 | } else { 12 | print "successful login\n"; 13 | $user_obj = $context->get( "user" ); 14 | } 15 | 16 | ?> 17 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz3/quizobjects/User.php: -------------------------------------------------------------------------------- 1 | 13 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz3/quizobjects/cvs/Entries: -------------------------------------------------------------------------------- 1 | /User.php/1.1/Fri Jun 11 22:50:10 2004// 2 | D 3 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz3/quizobjects/cvs/Repository: -------------------------------------------------------------------------------- 1 | oophp-book/frontend/source/15/megaquiz3/quizobjects 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz3/quizobjects/cvs/Root: -------------------------------------------------------------------------------- 1 | :ext:triffid@fate16.com:/usr/local/cvs 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz3/quiztools/AccessManager.php: -------------------------------------------------------------------------------- 1 | 36 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz3/quiztools/cvs/Entries: -------------------------------------------------------------------------------- 1 | /AccessManager.php/1.1/Fri Jun 11 22:50:10 2004// 2 | D 3 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz3/quiztools/cvs/Repository: -------------------------------------------------------------------------------- 1 | oophp-book/frontend/source/15/megaquiz3/quiztools 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz3/quiztools/cvs/Root: -------------------------------------------------------------------------------- 1 | :ext:triffid@fate16.com:/usr/local/cvs 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz4/command/Command.php: -------------------------------------------------------------------------------- 1 | 34 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz4/command/FeedbackCommand.php: -------------------------------------------------------------------------------- 1 | get( 'email' ); 20 | $msg = $context->get( 'pass' ); 21 | $topic = $context->get( 'topic' ); 22 | $result = $msgSystem->despatch( $email, $msg, $topic ); 23 | if ( ! $user ) { 24 | $this->context->setError( $msgSystem->getError() ); 25 | return false; 26 | } 27 | $context->addParam( "user", $user ); 28 | return true; 29 | } 30 | } 31 | 32 | 33 | ?> 34 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz4/command/LoginCommand.php: -------------------------------------------------------------------------------- 1 | get( 'username' ); 21 | $pass = $context->get( 'pass' ); 22 | $user = $manager->login( $user, $pass ); 23 | if ( ! $user ) { 24 | $this->context->setError( $manager->getError() ); 25 | return false; 26 | } 27 | $context->addParam( "user", $user ); 28 | return true; 29 | } 30 | } 31 | ?> 32 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz4/command/cvs/Entries: -------------------------------------------------------------------------------- 1 | /Command.php/1.1/Fri Jun 11 22:50:10 2004// 2 | /CommandContext.php/1.1/Fri Jun 11 22:50:10 2004// 3 | /FeedbackCommand.php/1.1/Fri Jun 11 22:50:10 2004// 4 | /LoginCommand.php/1.1/Fri Jun 11 22:50:10 2004// 5 | D 6 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz4/command/cvs/Repository: -------------------------------------------------------------------------------- 1 | oophp-book/frontend/source/15/megaquiz3/command 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz4/command/cvs/Root: -------------------------------------------------------------------------------- 1 | :ext:triffid@fate16.com:/usr/local/cvs 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz4/cvs/Entries: -------------------------------------------------------------------------------- 1 | /main.php/1.1/Fri Jun 11 22:50:10 2004// 2 | D 3 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz4/cvs/Entries.Log: -------------------------------------------------------------------------------- 1 | A D/command//// 2 | A D/quizobjects//// 3 | A D/quiztools//// 4 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz4/cvs/Repository: -------------------------------------------------------------------------------- 1 | oophp-book/frontend/source/15/megaquiz3 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz4/cvs/Root: -------------------------------------------------------------------------------- 1 | :ext:triffid@fate16.com:/usr/local/cvs 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz4/main.php: -------------------------------------------------------------------------------- 1 | addParam( "username", "bob" ); 7 | $context->addParam( "pass", "tiddles" ); 8 | $cmd = new LoginCommand( new AccessManager() ); 9 | if ( ! $cmd->execute( $context ) ) { 10 | print "an error occurred: ".$context->getError(); 11 | } else { 12 | print "successful login\n"; 13 | $user_obj = $context->get( "user" ); 14 | } 15 | 16 | ?> 17 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz4/quizobjects/User.php: -------------------------------------------------------------------------------- 1 | 13 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz4/quizobjects/cvs/Entries: -------------------------------------------------------------------------------- 1 | /User.php/1.1/Fri Jun 11 22:50:10 2004// 2 | D 3 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz4/quizobjects/cvs/Repository: -------------------------------------------------------------------------------- 1 | oophp-book/frontend/source/15/megaquiz3/quizobjects 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz4/quizobjects/cvs/Root: -------------------------------------------------------------------------------- 1 | :ext:triffid@fate16.com:/usr/local/cvs 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz4/quiztools/AccessManager.php: -------------------------------------------------------------------------------- 1 | 36 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz4/quiztools/cvs/Entries: -------------------------------------------------------------------------------- 1 | /AccessManager.php/1.1/Fri Jun 11 22:50:10 2004// 2 | D 3 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz4/quiztools/cvs/Repository: -------------------------------------------------------------------------------- 1 | oophp-book/frontend/source/15/megaquiz3/quiztools 2 | -------------------------------------------------------------------------------- /popp-code/16/megaquiz4/quiztools/cvs/Root: -------------------------------------------------------------------------------- 1 | :ext:triffid@fate16.com:/usr/local/cvs 2 | -------------------------------------------------------------------------------- /popp-code/17/megaquiz.orig/trunk/command/Command.php: -------------------------------------------------------------------------------- 1 | 34 | -------------------------------------------------------------------------------- /popp-code/17/megaquiz.orig/trunk/command/FeedbackCommand.php: -------------------------------------------------------------------------------- 1 | get( 'email' ); 20 | $msg = $context->get( 'pass' ); 21 | $topic = $context->get( 'topic' ); 22 | $result = $msgSystem->despatch( $email, $msg, $topic ); 23 | if ( ! $user ) { 24 | $this->context->setError( $msgSystem->getError() ); 25 | return false; 26 | } 27 | $context->addParam( "user", $user ); 28 | return true; 29 | } 30 | } 31 | 32 | 33 | ?> 34 | -------------------------------------------------------------------------------- /popp-code/17/megaquiz.orig/trunk/command/LoginCommand.php: -------------------------------------------------------------------------------- 1 | get( 'username' ); 21 | $pass = $context->get( 'pass' ); 22 | $user = $manager->login( $user, $pass ); 23 | if ( ! $user ) { 24 | $this->context->setError( $manager->getError() ); 25 | return false; 26 | } 27 | $context->addParam( "user", $user ); 28 | return true; 29 | } 30 | } 31 | ?> 32 | -------------------------------------------------------------------------------- /popp-code/17/megaquiz.orig/trunk/main.php: -------------------------------------------------------------------------------- 1 | addParam( "username", "bob" ); 7 | $context->addParam( "pass", "tiddles" ); 8 | $cmd = new LoginCommand( new AccessManager() ); 9 | if ( ! $cmd->execute( $context ) ) { 10 | print "an error occurred: ".$context->getError(); 11 | } else { 12 | print "successful login\n"; 13 | $user_obj = $context->get( "user" ); 14 | } 15 | 16 | ?> 17 | -------------------------------------------------------------------------------- /popp-code/17/megaquiz.orig/trunk/quizobjects/User.php: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /popp-code/17/megaquiz.orig/trunk/quiztools/AccessManager.php: -------------------------------------------------------------------------------- 1 | 36 | -------------------------------------------------------------------------------- /popp-code/18/after_change/User.php: -------------------------------------------------------------------------------- 1 | name = $name; 11 | $this->mail = $mail; 12 | if ( strlen( $pass ) < 5 ) { 13 | throw new Exception( 14 | "Password must have 5 or more letters"); 15 | } 16 | $this->pass = $pass; 17 | } 18 | 19 | function getMail() { 20 | return $this->mail; 21 | } 22 | 23 | function getPass() { 24 | return $this->pass; 25 | } 26 | 27 | function failed( $time ) { 28 | $this->failed = $time; 29 | } 30 | } 31 | ?> 32 | -------------------------------------------------------------------------------- /popp-code/18/after_change/UserStore.php: -------------------------------------------------------------------------------- 1 | users[$mail] ) ) { 10 | throw new Exception( 11 | "User {$mail} already in the system"); 12 | } 13 | 14 | $this->users[$mail] = new User( $name, $mail, $pass ); 15 | return true; 16 | } 17 | 18 | function notifyPasswordFailure( $mail ) { 19 | if ( isset( $this->users[$mail] ) ) { 20 | $this->users[$mail]->failed(time()); 21 | } 22 | } 23 | 24 | function getUser( $mail ) { 25 | if ( isset( $this->users[$mail] ) ) { 26 | return ( $this->users[$mail] ); 27 | } 28 | return null; 29 | } 30 | } 31 | /* 32 | $store=new UserStore(); 33 | $store->addUser( "bob williams", 34 | "bob@example.com", 35 | "12345" ); 36 | $user = $store->getUser( "bob@example.com" ); 37 | print_r( $user ); 38 | $store->notifyPasswordFailure( "bob@example.com" ); 39 | */ 40 | ?> 41 | -------------------------------------------------------------------------------- /popp-code/18/after_change/Validator.php: -------------------------------------------------------------------------------- 1 | store = $store; 8 | } 9 | 10 | public function validateUser( $mail, $pass ) { 11 | /* 12 | // this is the fix after tests fail 13 | $user = $this->store->getUser( $mail ); 14 | if ( is_null( $user ) ) { 15 | return null; 16 | } 17 | if ( $user->getPass() == $pass ) { 18 | return true; 19 | } 20 | $this->store->notifyPasswordFailure( $mail ); 21 | return false; 22 | */ 23 | if ( ! is_array($user = $this->store->getUser( $mail )) ) { 24 | return false; 25 | } 26 | if ( $user['pass'] == $pass ) { 27 | return true; 28 | } 29 | $this->store->notifyPasswordFailure( $mail ); 30 | return false; 31 | } 32 | } 33 | 34 | ?> 35 | -------------------------------------------------------------------------------- /popp-code/18/after_change/test/SomeTests.php: -------------------------------------------------------------------------------- 1 | addTestSuite('UserStoreTest'); 20 | $ts->addTestSuite('ValidatorTest'); 21 | return $ts; 22 | } 23 | } 24 | 25 | if (PHPUnit_MAIN_METHOD == 'SomeTests::main') { 26 | SomeTests::main(); 27 | } 28 | ?> 29 | -------------------------------------------------------------------------------- /popp-code/18/before_change/Validator.php: -------------------------------------------------------------------------------- 1 | store = $store; 8 | } 9 | 10 | public function validateUser( $mail, $pass ) { 11 | if ( ! is_array($user = $this->store->getUser( $mail )) ) { 12 | return false; 13 | } 14 | if ( $user['pass'] == $pass ) { 15 | return true; 16 | } 17 | $this->store->notifyPasswordFailure( $mail ); 18 | return false; 19 | } 20 | } 21 | /* 22 | $store = new UserStore(); 23 | $store->addUser( "bob williams", "bob@example.com", "12345" ); 24 | $validator = new Validator( $store ); 25 | if ( $validator->validateUser( "bob@example.com", "12345" ) ) { 26 | print "pass, friend!\n"; 27 | } 28 | */ 29 | ?> 30 | -------------------------------------------------------------------------------- /popp-code/18/before_change/test/SomeTests.php: -------------------------------------------------------------------------------- 1 | addTestSuite('UserStoreTest'); 20 | $ts->addTestSuite('ValidatorTest'); 21 | return $ts; 22 | } 23 | } 24 | 25 | if (PHPUnit_MAIN_METHOD == 'SomeTests::main') { 26 | SomeTests::main(); 27 | } 28 | ?> 29 | -------------------------------------------------------------------------------- /popp-code/18/before_change/test/UserStoreTestBasic.php: -------------------------------------------------------------------------------- 1 | store = new UserStore(); 11 | } 12 | 13 | public function tearDown() { 14 | } 15 | 16 | public function testGetUser() { 17 | $this->store->addUser( "bob williams", "a@b.com", "12345" ); 18 | $user = $this->store->getUser( "a@b.com" ); 19 | $this->assertEquals( $user['mail'], "a@b.com" ); 20 | $this->assertEquals( $user['name'], "bob williams" ); 21 | $this->assertEquals( $user['pass'], "12345" ); 22 | } 23 | 24 | public function testAddUser_ShortPass() { 25 | try { 26 | $this->store->addUser( "bob williams", "bob@example.com", "ff" ); 27 | } catch ( Exception $e ) { return; } 28 | $this->fail("Short password exception expected"); 29 | } 30 | } 31 | 32 | ?> 33 | -------------------------------------------------------------------------------- /popp-code/18/before_change/test/ValidatorTestBasic.php: -------------------------------------------------------------------------------- 1 | addUser( "bob williams", "bob@example.com", "12345" ); 13 | $this->validator = new Validator( $store ); 14 | } 15 | 16 | public function tearDown() { 17 | } 18 | 19 | public function testValidate_CorrectPass() { 20 | $this->assertTrue( 21 | $this->validator->validateUser( "bob@example.com", "12345" ), 22 | "Expecting successful validation" 23 | ); 24 | } 25 | } 26 | ?> 27 | -------------------------------------------------------------------------------- /popp-code/18/inmemory_example/DBFace.php: -------------------------------------------------------------------------------- 1 | pdo = new PDO( $dsn, $user, $pass ); 8 | $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 9 | } 10 | 11 | function query( $query ) { 12 | $stmt = $this->pdo->query( $query ); 13 | return $stmt; 14 | } 15 | } 16 | 17 | ?> 18 | -------------------------------------------------------------------------------- /popp-code/18/inmemory_example/ToolTest.php: -------------------------------------------------------------------------------- 1 | query("create table user ( id INTEGER PRIMARY KEY, name TEXT )"); 11 | $face->query("insert into user (name) values('bob')"); 12 | $face->query("insert into user (name) values('harry')"); 13 | $this->mapper = new ToolMapper( $face ); 14 | /* 15 | $result = $x->query("select * from user"); 16 | 17 | while ( $row = $result->fetch() ) { 18 | print_r( $row ); 19 | } 20 | */ 21 | } 22 | 23 | function testTool() { 24 | self::AssertTrue( true ); 25 | } 26 | } 27 | 28 | class ToolMapper { 29 | function __construct( DBFace $face ) { 30 | //.. 31 | } 32 | } 33 | ?> 34 | -------------------------------------------------------------------------------- /popp-code/18/listing21.02.php: -------------------------------------------------------------------------------- 1 | store = $store; 8 | } 9 | 10 | public function validateUser( $mail, $pass ) { 11 | if ( ! is_array($user = $this->store->getUser( $mail )) ) { 12 | return false; 13 | } 14 | if ( $user['pass'] == $pass ) { 15 | return true; 16 | } 17 | $this->store->notifyPasswordFailure( $mail ); 18 | return false; 19 | } 20 | } 21 | 22 | $store = new UserStore(); 23 | $store->addUser( "bob williams", "bob@example.com", "12345" ); 24 | $validator = new Validator( $store ); 25 | if ( $validator->validateUser( "bob@example.com", "12345" ) ) { 26 | print "pass, friend!\n"; 27 | } 28 | ?> 29 | -------------------------------------------------------------------------------- /popp-code/18/webandselenium/webwoo/AddSpace.php: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | Here are the venues 8 | 9 | 10 | 11 |

Here are the venues

12 | 13 | 14 | 15 | 17 | 18 | 22 | 23 | 24 |
16 | space '' added (47)
19 |
20 |  
21 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /popp-code/18/webandselenium/webwoo/Main.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | Woo! it's WOO! 4 | 5 | 6 | 7 | 8 | 9 | 11 | 12 |
10 | Welcome to WOO
13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /popp-code/18/webandselenium/webwoo/index.php: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /popp-code/19/build.xml.1: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /popp-code/19/build.xml.11: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 12 | 13 | 14 | 15 | pass: ${dbpass} 16 | 17 | 18 | -------------------------------------------------------------------------------- /popp-code/19/build.xml.2: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /popp-code/19/build.xml.3: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 9 | 12 | 15 | 16 | -------------------------------------------------------------------------------- /popp-code/19/build.xml.4: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | database: ${dbname} 13 | pass: ${dbpass} 14 | host: ${dbhost} 15 | 16 | 17 | -------------------------------------------------------------------------------- /popp-code/19/build.xml.5: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | database: ${dbname} 13 | pass: ${dbpass} 14 | host: ${dbhost} 15 | 16 | 17 | -------------------------------------------------------------------------------- /popp-code/19/build.xml.6: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | database: ${dbname} 13 | pass: ${dbpass} 14 | host: ${dbhost} 15 | 16 | 17 | -------------------------------------------------------------------------------- /popp-code/19/build.xml.7: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | pass: ${dbpass} 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /popp-code/19/build.xml.8: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | name: ${phing.project.name} 9 | base: ${project.basedir} 10 | home: ${user.home} 11 | pass: ${env.DBPASS} 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /popp-code/19/build.xml.9: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | pass: ${dbpass} 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /popp-code/19/build/lib/Config.php: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /popp-code/19/build/lib/command/Command.php: -------------------------------------------------------------------------------- 1 | 13 | -------------------------------------------------------------------------------- /popp-code/19/build/lib/command/CommandContext.php: -------------------------------------------------------------------------------- 1 | params = $_REQUEST; 18 | $this->applicationName = $appname; 19 | } 20 | 21 | function addParam( $key, $val ) { 22 | $this->params[$key]=$val; 23 | } 24 | 25 | function get( $key ) { 26 | return $this->params[$key]; 27 | } 28 | 29 | function setError( $error ) { 30 | $this->error = $error; 31 | } 32 | 33 | function getError() { 34 | return $this->error; 35 | } 36 | } 37 | 38 | ?> 39 | -------------------------------------------------------------------------------- /popp-code/19/build/lib/command/FeedbackCommand.php: -------------------------------------------------------------------------------- 1 | get( 'email' ); 13 | $msg = $context->get( 'pass' ); 14 | $topic = $context->get( 'topic' ); 15 | $result = $msgSystem->despatch( $email, $msg, $topic ); 16 | if ( ! $result ) { 17 | $this->context->setError( $msgSystem->getError() ); 18 | return false; 19 | } 20 | $context->addParam( "user", $user ); 21 | return true; 22 | } 23 | } 24 | 25 | 26 | ?> 27 | -------------------------------------------------------------------------------- /popp-code/19/build/lib/command/LoginCommand.php: -------------------------------------------------------------------------------- 1 | get( 'username' ); 14 | $pass = $context->get( 'pass' ); 15 | $user = $manager->login( $user, $pass ); 16 | if ( ! $user ) { 17 | $this->context->setError( $manager->getError() ); 18 | return false; 19 | } 20 | $context->addParam( "user", $user ); 21 | return true; 22 | } 23 | } 24 | ?> 25 | -------------------------------------------------------------------------------- /popp-code/19/build/lib/quizobjects/Tree.php: -------------------------------------------------------------------------------- 1 | kjx 2 | -------------------------------------------------------------------------------- /popp-code/19/build/lib/quizobjects/User.php: -------------------------------------------------------------------------------- 1 | >>>>>> 1.2 7 | class User {} 8 | ?> 9 | -------------------------------------------------------------------------------- /popp-code/19/build/lib/quiztools/AccessManager.php: -------------------------------------------------------------------------------- 1 | 27 | -------------------------------------------------------------------------------- /popp-code/19/src/config/Config.php: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /popp-code/19/src/lib/.htaccess: -------------------------------------------------------------------------------- 1 | #dummy 2 | -------------------------------------------------------------------------------- /popp-code/19/src/lib/Config.php: -------------------------------------------------------------------------------- 1 | 13 | -------------------------------------------------------------------------------- /popp-code/19/src/lib/command/Command.php: -------------------------------------------------------------------------------- 1 | 34 | -------------------------------------------------------------------------------- /popp-code/19/src/lib/command/FeedbackCommand.php: -------------------------------------------------------------------------------- 1 | get( 'email' ); 20 | $msg = $context->get( 'pass' ); 21 | $topic = $context->get( 'topic' ); 22 | $result = $msgSystem->despatch( $email, $msg, $topic ); 23 | if ( ! $result ) { 24 | $this->context->setError( $msgSystem->getError() ); 25 | return false; 26 | } 27 | $context->addParam( "user", $user ); 28 | return true; 29 | } 30 | } 31 | 32 | 33 | ?> 34 | -------------------------------------------------------------------------------- /popp-code/19/src/lib/command/LoginCommand.php: -------------------------------------------------------------------------------- 1 | get( 'username' ); 21 | $pass = $context->get( 'pass' ); 22 | $user = $manager->login( $user, $pass ); 23 | if ( ! $user ) { 24 | $this->context->setError( $manager->getError() ); 25 | return false; 26 | } 27 | $context->addParam( "user", $user ); 28 | return true; 29 | } 30 | } 31 | ?> 32 | -------------------------------------------------------------------------------- /popp-code/19/src/lib/quizobjects/FinishedTest.php: -------------------------------------------------------------------------------- 1 | jkjkj 2 | -------------------------------------------------------------------------------- /popp-code/19/src/lib/quizobjects/Tree.php: -------------------------------------------------------------------------------- 1 | kjx 2 | -------------------------------------------------------------------------------- /popp-code/19/src/lib/quizobjects/TreeTest.php: -------------------------------------------------------------------------------- 1 | kjkj 2 | -------------------------------------------------------------------------------- /popp-code/19/src/lib/quizobjects/User.php: -------------------------------------------------------------------------------- 1 | >>>>>> 1.2 12 | class User {} 13 | ?> 14 | -------------------------------------------------------------------------------- /popp-code/19/src/lib/quizobjects/User_test.php: -------------------------------------------------------------------------------- 1 | kksj 2 | -------------------------------------------------------------------------------- /popp-code/19/src/lib/quizobjects/description.txt: -------------------------------------------------------------------------------- 1 | jijkj 2 | -------------------------------------------------------------------------------- /popp-code/19/src/lib/quiztools/AccessManager.php: -------------------------------------------------------------------------------- 1 | 37 | -------------------------------------------------------------------------------- /popp-code/19/src/main.php: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /popp-code/19/src/views/index.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /popp-code/20/userthing.orig/trunk/src/test/UserTests.php: -------------------------------------------------------------------------------- 1 | addTestSuite('UserStoreTest'); 11 | $suite->addTestSuite('ValidatorTest'); 12 | 13 | return $suite; 14 | } 15 | } 16 | ?> 17 | -------------------------------------------------------------------------------- /popp-code/20/userthing.orig/trunk/src/userthing/domain/User.php: -------------------------------------------------------------------------------- 1 | name = $name; 12 | $this->mail = $mail; 13 | if ( strlen( $pass ) < 5 ) { 14 | throw new \Exception( 15 | "Password must have 5 or more letters"); 16 | } 17 | $this->pass = $pass; 18 | } 19 | 20 | function getMail() { 21 | return $this->mail; 22 | } 23 | 24 | function getPass() { 25 | return $this->pass; 26 | } 27 | 28 | function failed( $time ) { 29 | $this->failed = $time; 30 | } 31 | } 32 | ?> 33 | -------------------------------------------------------------------------------- /popp-code/20/userthing.orig/trunk/src/userthing/persist/UserStore.php: -------------------------------------------------------------------------------- 1 | users[$mail] ) ) { 12 | throw new \Exception( 13 | "User {$mail} already in the system"); 14 | } 15 | 16 | $this->users[$mail] = new \userthing\domain\User( $name, $mail, $pass ); 17 | return true; 18 | } 19 | 20 | function notifyPasswordFailure( $mail ) { 21 | if ( isset( $this->users[$mail] ) ) { 22 | $this->users[$mail]->failed(time()); 23 | } 24 | } 25 | 26 | function getUser( $mail ) { 27 | if ( isset( $this->users[$mail] ) ) { 28 | return ( $this->users[$mail] ); 29 | } 30 | return null; 31 | } 32 | } 33 | ?> 34 | -------------------------------------------------------------------------------- /popp-code/20/userthing.orig/trunk/src/userthing/util/Validator.php: -------------------------------------------------------------------------------- 1 | store = $store; 10 | } 11 | 12 | public function validateUser( $mail, $pass ) { 13 | $user = $this->store->getUser( $mail ); 14 | if ( is_null( $user ) ) { 15 | return null; 16 | } 17 | if ( $user->getPass() == $pass ) { 18 | return true; 19 | } 20 | $this->store->notifyPasswordFailure( $mail ); 21 | return false; 22 | } 23 | } 24 | 25 | ?> 26 | -------------------------------------------------------------------------------- /popp-code/3/listing.001.php: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /popp-code/3/listing.002.php: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /popp-code/3/listing.003.php: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /popp-code/3/listing.004.php: -------------------------------------------------------------------------------- 1 | 9 | -------------------------------------------------------------------------------- /popp-code/3/listing.005.php: -------------------------------------------------------------------------------- 1 | title; 11 | ?> 12 | -------------------------------------------------------------------------------- /popp-code/3/listing.006.php: -------------------------------------------------------------------------------- 1 | title="My Antonia"; 12 | $product2->title="Catch 22"; 13 | ?> 14 | -------------------------------------------------------------------------------- /popp-code/3/listing.007.php: -------------------------------------------------------------------------------- 1 | title = "My Antonia"; 11 | $product1->producerMainName = "Cather"; 12 | $product1->producerFirstName = "Willa"; 13 | $product1->price = 5.99; 14 | ?> 15 | -------------------------------------------------------------------------------- /popp-code/3/listing.008.php: -------------------------------------------------------------------------------- 1 | title = "My Antonia"; 11 | $product1->producerMainName = "Cather"; 12 | $product1->producerFirstName = "Willa"; 13 | $product1->price = 5.99; 14 | 15 | print "author: {$product1->producerFirstName} " 16 | ."{$product1->producerMainName}\n"; 17 | ?> 18 | -------------------------------------------------------------------------------- /popp-code/3/listing.009.php: -------------------------------------------------------------------------------- 1 | producerFirstName}". 11 | " {$this->producerMainName}"; 12 | } 13 | } 14 | 15 | $product1 = new ShopProduct(); 16 | $product1->title = "My Antonia"; 17 | $product1->producerMainName = "Cather"; 18 | $product1->producerFirstName = "Willa"; 19 | $product1->price = 5.99; 20 | print "author: {$product1->getProducer()}\n"; 21 | ?> 22 | -------------------------------------------------------------------------------- /popp-code/3/listing.010.php: -------------------------------------------------------------------------------- 1 | title = $title; 11 | $this->producerFirstName = $firstName; 12 | $this->producerMainName = $mainName; 13 | $this->price = $price; 14 | } 15 | 16 | function getProducer() { 17 | return "{$this->producerFirstName}". 18 | " {$this->producerMainName}"; 19 | } 20 | } 21 | 22 | $product1 = new ShopProduct( "My Antonia", 23 | "Willa", "Cather", 5.99 ); 24 | print "author: {$product1->getProducer()}\n"; 25 | ?> 26 | -------------------------------------------------------------------------------- /popp-code/3/listing.011.xml: -------------------------------------------------------------------------------- 1 | 2 | false 3 | 4 | -------------------------------------------------------------------------------- /popp-code/3/listing.012.php: -------------------------------------------------------------------------------- 1 | addresses as $address ) { 7 | print $address; 8 | if ( $resolve ) { 9 | print " (".gethostbyaddr( $address ).")"; 10 | } 11 | print "\n"; 12 | } 13 | } 14 | } 15 | 16 | $settings = simplexml_load_file("listing.011.xml"); 17 | $manager = new AddressManager(); 18 | $manager->outputAddresses( (string)$settings->resolvedomains ); 19 | ?> 20 | -------------------------------------------------------------------------------- /popp-code/3/listing.013.php: -------------------------------------------------------------------------------- 1 | addresses as $address ) { 13 | print $address; 14 | if ( $resolve ) { 15 | print " (".gethostbyaddr( $address ).")"; 16 | } 17 | print "\n"; 18 | } 19 | } 20 | } 21 | 22 | $settings = simplexml_load_file("listing.011.xml"); 23 | $manager = new AddressManager(); 24 | $manager->outputAddresses( (string)$settings->resolvedomains ); 25 | ?> 26 | -------------------------------------------------------------------------------- /popp-code/3/listing.014.php: -------------------------------------------------------------------------------- 1 | title = $title; 11 | $this->producerFirstName = $firstName; 12 | $this->producerMainName = $mainName; 13 | $this->price = $price; 14 | } 15 | 16 | function getProducer() { 17 | return "{$this->producerFirstName}". 18 | " {$this->producerMainName}"; 19 | } 20 | } 21 | 22 | 23 | class ShopProductWriter { 24 | public function write( $shopProduct ) { 25 | $str = "{$shopProduct->title}: " . 26 | $shopProduct->getProducer() . 27 | " ({$shopProduct->price})\n"; 28 | print $str; 29 | } 30 | } 31 | 32 | 33 | $product1 = new ShopProduct( "My Antonia", "Willa", "Cather", 5.99 ); 34 | $writer = new ShopProductWriter(); 35 | $writer->write( $product1 ); 36 | 37 | ?> 38 | -------------------------------------------------------------------------------- /popp-code/4/back_products.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/php-objects-patterns-practice/6f6913b60a35e0f60dfefd8f8e5863bf005fcd3f/popp-code/4/back_products.db -------------------------------------------------------------------------------- /popp-code/4/closures.php: -------------------------------------------------------------------------------- 1 | name = $name; 8 | $this->price = $price; 9 | } 10 | } 11 | 12 | class ProcessSale { 13 | private $callbacks; 14 | 15 | function registerCallback( $callback ) { 16 | if ( ! is_callable( $callback ) ) { 17 | throw new Exception( "callback not callable" ); 18 | } 19 | $this->callbacks[] = $callback; 20 | } 21 | 22 | function sale( $product ) { 23 | print "{$product->name}: processing \n"; 24 | foreach ( $this->callbacks as $callback ) { 25 | call_user_func( $callback, $product ); 26 | } 27 | } 28 | } 29 | ?> 30 | -------------------------------------------------------------------------------- /popp-code/4/conf.broken.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | bob 4 | newpass 5 | localhost 6 | 7 | -------------------------------------------------------------------------------- /popp-code/4/conf.unwriteable.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | bob 4 | newpass 5 | localhost 6 | 7 | -------------------------------------------------------------------------------- /popp-code/4/conf01.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | bob 4 | newpass 5 | localhost 6 | newpass 7 | -------------------------------------------------------------------------------- /popp-code/4/listing04.01.php: -------------------------------------------------------------------------------- 1 | 13 | -------------------------------------------------------------------------------- /popp-code/4/listing04.02.php: -------------------------------------------------------------------------------- 1 | 16 | -------------------------------------------------------------------------------- /popp-code/4/listing04.04.php: -------------------------------------------------------------------------------- 1 | 9 | -------------------------------------------------------------------------------- /popp-code/4/listing04.06.php: -------------------------------------------------------------------------------- 1 | products[]=$shopProduct; 9 | } 10 | 11 | abstract public function write( ); 12 | } 13 | 14 | class ErroredWriter extends ShopProductWriter{ 15 | } 16 | 17 | $writer = new ErroredWriter(); 18 | ?> 19 | -------------------------------------------------------------------------------- /popp-code/4/listing04.07.php: -------------------------------------------------------------------------------- 1 | price; 13 | } 14 | // ... 15 | 16 | } 17 | 18 | $product = new ShopProduct(); 19 | 20 | ?> 21 | -------------------------------------------------------------------------------- /popp-code/4/listing04.08.php: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /popp-code/4/listing04.10.php: -------------------------------------------------------------------------------- 1 | 22 | -------------------------------------------------------------------------------- /popp-code/4/listing04.11.php: -------------------------------------------------------------------------------- 1 | 16 | -------------------------------------------------------------------------------- /popp-code/4/listing04.12.php: -------------------------------------------------------------------------------- 1 | 16 | -------------------------------------------------------------------------------- /popp-code/4/listing04.13.php: -------------------------------------------------------------------------------- 1 | group = static::getGroup(); 6 | } 7 | 8 | public static function create() { 9 | return new static(); 10 | } 11 | 12 | static function getGroup() { 13 | return "default"; 14 | } 15 | } 16 | 17 | class User extends DomainObject { 18 | } 19 | 20 | class Document extends DomainObject { 21 | static function getGroup() { 22 | return "document"; 23 | } 24 | } 25 | 26 | class SpreadSheet extends Document { 27 | } 28 | 29 | print_r(User::create()); 30 | print_r(SpreadSheet::create()); 31 | ?> 32 | -------------------------------------------------------------------------------- /popp-code/4/listing04.14.php: -------------------------------------------------------------------------------- 1 | name})\n";' ); 6 | 7 | $processor = new ProcessSale(); 8 | $processor->registerCallback( $logger ); 9 | 10 | $processor->sale( new Product( "shoes", 6 ) ); 11 | print "\n"; 12 | $processor->sale( new Product( "coffee", 6 ) ); 13 | ?> 14 | -------------------------------------------------------------------------------- /popp-code/4/listing04.15.php: -------------------------------------------------------------------------------- 1 | name})\n"; 6 | }; 7 | 8 | $processor = new ProcessSale(); 9 | $processor->registerCallback( $logger2 ); 10 | 11 | $processor->sale( new Product( "shoes", 6 ) ); 12 | print "\n"; 13 | $processor->sale( new Product( "coffee", 6 ) ); 14 | ?> 15 | -------------------------------------------------------------------------------- /popp-code/4/listing04.16.php: -------------------------------------------------------------------------------- 1 | name})\n"; 7 | } 8 | } 9 | 10 | $processor = new ProcessSale(); 11 | $processor->registerCallback( array( new Mailer(), "doMail" ) ); 12 | 13 | $processor->sale( new Product( "shoes", 6 ) ); 14 | print "\n"; 15 | $processor->sale( new Product( "coffee", 6 ) ); 16 | ?> 17 | -------------------------------------------------------------------------------- /popp-code/4/listing04.17.php: -------------------------------------------------------------------------------- 1 | price > 5 ) { 8 | print " reached high price: {$product->price}\n"; 9 | } 10 | }; 11 | } 12 | } 13 | 14 | $processor = new ProcessSale(); 15 | $processor->registerCallback( Totalizer::warnAmount() ); 16 | 17 | $processor->sale( new Product( "shoes", 6 ) ); 18 | print "\n"; 19 | $processor->sale( new Product( "coffee", 6 ) ); 20 | ?> 21 | -------------------------------------------------------------------------------- /popp-code/4/listing04.18.php: -------------------------------------------------------------------------------- 1 | price; 9 | print " count: $count\n"; 10 | if ( $count > $amt ) { 11 | print " high price reached: {$count}\n"; 12 | } 13 | }; 14 | } 15 | } 16 | 17 | $processor = new ProcessSale(); 18 | $processor->registerCallback( Totalizer::warnAmount( 8) ); 19 | 20 | $processor->sale( new Product( "shoes", 6 ) ); 21 | print "\n"; 22 | $processor->sale( new Product( "coffee", 6 ) ); 23 | ?> 24 | -------------------------------------------------------------------------------- /popp-code/4/listing04.22.php: -------------------------------------------------------------------------------- 1 | 13 | -------------------------------------------------------------------------------- /popp-code/4/listing04.23.php: -------------------------------------------------------------------------------- 1 | 18 | -------------------------------------------------------------------------------- /popp-code/4/listing04.24.php: -------------------------------------------------------------------------------- 1 | $method(); 7 | } 8 | } 9 | 10 | function __isset( $property ) { 11 | $method = "get{$property}"; 12 | return ( method_exists( $this, $method ) ); 13 | } 14 | 15 | function getName() { 16 | return "Bob"; 17 | } 18 | 19 | function getAge() { 20 | return 44; 21 | } 22 | } 23 | 24 | $p = new Person(); 25 | if ( isset( $p->name ) ) { 26 | print $p->name; 27 | } else { 28 | print "nope\n"; 29 | } 30 | // output: 31 | // Bob 32 | ?> 33 | -------------------------------------------------------------------------------- /popp-code/4/listing04.25.php: -------------------------------------------------------------------------------- 1 | $method( $value ); 10 | } 11 | } 12 | 13 | function __unset( $property ) { 14 | $method = "set{$property}"; 15 | if ( method_exists( $this, $method ) ) { 16 | $this->$method( null ); 17 | } 18 | } 19 | 20 | function setName( $name ) { 21 | $this->_name = $name; 22 | if ( ! is_null( $name ) ) { 23 | $this->_name = strtoupper($this->_name); 24 | } 25 | } 26 | 27 | function setAge( $age ) { 28 | $this->_age = $age; 29 | } 30 | } 31 | 32 | $p = new Person(); 33 | $p->name = "bob"; 34 | $p->age = 44; 35 | print_r( $p ); 36 | unset($p->name); 37 | print_r( $p ); 38 | ?> 39 | -------------------------------------------------------------------------------- /popp-code/4/listing04.26.php: -------------------------------------------------------------------------------- 1 | getName()."\n"; 6 | } 7 | 8 | function writeAge( Person $p ) { 9 | print $p->getAge()."\n"; 10 | } 11 | } 12 | 13 | class Person { 14 | private $writer; 15 | 16 | function __construct( PersonWriter $writer ) { 17 | $this->writer = $writer; 18 | } 19 | 20 | function __call( $method, $args ) { 21 | if ( method_exists( $this->writer, $method ) ) { 22 | return $this->writer->$method( $this ); 23 | } 24 | } 25 | 26 | function getName() { return "Bob"; } 27 | function getAge() { return 44; } 28 | } 29 | 30 | $person= new Person( new PersonWriter() ); 31 | $person->writeName(); 32 | $person->writeAge(); 33 | ?> 34 | -------------------------------------------------------------------------------- /popp-code/4/listing04.27.php: -------------------------------------------------------------------------------- 1 | name = $name; 9 | $this->age = $age; 10 | } 11 | 12 | function setId( $id ) { 13 | $this->id = $id; 14 | } 15 | 16 | function __destruct() { 17 | if ( ! empty( $this->id ) ) { 18 | // save Person data 19 | print "saving person\n"; 20 | } 21 | } 22 | } 23 | 24 | $person = new Person( "bob", 44 ); 25 | $person->setId( 343 ); 26 | unset( $person ); 27 | 28 | ?> 29 | -------------------------------------------------------------------------------- /popp-code/4/listing04.28.php: -------------------------------------------------------------------------------- 1 | name = $name; 9 | $this->age = $age; 10 | } 11 | 12 | function setId( $id ) { 13 | $this->id = $id; 14 | } 15 | 16 | function __clone() { 17 | $this->id = 0; 18 | } 19 | } 20 | 21 | $person = new Person( "bob", 44 ); 22 | $person->setId( 343 ); 23 | $person2 = clone $person; 24 | print_r( $person ); 25 | print_r( $person2 ); 26 | 27 | ?> 28 | -------------------------------------------------------------------------------- /popp-code/4/listing04.29.php: -------------------------------------------------------------------------------- 1 | balance = $balance; 6 | } 7 | } 8 | 9 | class Person { 10 | private $name; 11 | private $age; 12 | private $id; 13 | public $account; 14 | 15 | function __construct( $name, $age, Account $account ) { 16 | $this->name = $name; 17 | $this->age = $age; 18 | $this->account = $account; 19 | } 20 | 21 | function setId( $id ) { 22 | $this->id = $id; 23 | } 24 | 25 | function __clone() { 26 | $this->id = 0; 27 | } 28 | } 29 | 30 | $person = new Person( "bob", 44, new Account( 200 ) ); 31 | $person->setId( 343 ); 32 | $person2 = clone $person; 33 | 34 | // give $person some money 35 | $person->account->balance += 10; 36 | // $person2 sees the credit too 37 | print $person2->account->balance; 38 | 39 | // output: 40 | // 210 41 | 42 | ?> 43 | -------------------------------------------------------------------------------- /popp-code/4/listing04.30.php: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /popp-code/4/listing04.31.php: -------------------------------------------------------------------------------- 1 | getName()." (age "; 8 | $desc .= $this->getAge().")"; 9 | return $desc; 10 | } 11 | } 12 | 13 | $person = new Person(); 14 | print $person; 15 | // Bob (age 44) 16 | ?> 17 | -------------------------------------------------------------------------------- /popp-code/4/products.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/php-objects-patterns-practice/6f6913b60a35e0f60dfefd8f8e5863bf005fcd3f/popp-code/4/products.db -------------------------------------------------------------------------------- /popp-code/4/products.pdo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/php-objects-patterns-practice/6f6913b60a35e0f60dfefd8f8e5863bf005fcd3f/popp-code/4/products.pdo -------------------------------------------------------------------------------- /popp-code/5/ShopProduct.php: -------------------------------------------------------------------------------- 1 | 9 | -------------------------------------------------------------------------------- /popp-code/5/business/ShopProduct.php: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /popp-code/5/business/ShopProduct2.php: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /popp-code/5/business/ShopProduct3.php: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /popp-code/5/global.php: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /popp-code/5/listing5.01.php: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /popp-code/5/listing5.02.php: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /popp-code/5/listing5.03.php: -------------------------------------------------------------------------------- 1 | 9 | -------------------------------------------------------------------------------- /popp-code/5/listing5.04.php: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /popp-code/5/listing5.05.php: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /popp-code/5/listing5.06.php: -------------------------------------------------------------------------------- 1 | 15 | -------------------------------------------------------------------------------- /popp-code/5/listing5.07.php: -------------------------------------------------------------------------------- 1 | 15 | -------------------------------------------------------------------------------- /popp-code/5/listing5.08.php: -------------------------------------------------------------------------------- 1 | 21 | -------------------------------------------------------------------------------- /popp-code/5/listing5.09.php: -------------------------------------------------------------------------------- 1 | 21 | -------------------------------------------------------------------------------- /popp-code/5/listing5.10.php: -------------------------------------------------------------------------------- 1 | 13 | -------------------------------------------------------------------------------- /popp-code/5/listing5.11.php: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /popp-code/5/listing5.12.php: -------------------------------------------------------------------------------- 1 | 20 | -------------------------------------------------------------------------------- /popp-code/5/listing5.13.php: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /popp-code/5/listing5.14.php: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /popp-code/5/listing5.15.php: -------------------------------------------------------------------------------- 1 | 30 | -------------------------------------------------------------------------------- /popp-code/5/listing5.16.php: -------------------------------------------------------------------------------- 1 | doSpeak(); 9 | ?> 10 | -------------------------------------------------------------------------------- /popp-code/5/listing5.17.php: -------------------------------------------------------------------------------- 1 | doSpeak(); 16 | 17 | 18 | ?> 19 | -------------------------------------------------------------------------------- /popp-code/5/listing5.18.php: -------------------------------------------------------------------------------- 1 | 15 | -------------------------------------------------------------------------------- /popp-code/5/listing5.19.php: -------------------------------------------------------------------------------- 1 | 15 | -------------------------------------------------------------------------------- /popp-code/5/listing5.20.php: -------------------------------------------------------------------------------- 1 | 19 | -------------------------------------------------------------------------------- /popp-code/5/listing5.22.php: -------------------------------------------------------------------------------- 1 | thirdpartyShop = new OtherShop(); 16 | } 17 | 18 | function __call( $method, $args ) { 19 | if ( method_exists( $this->thirdpartyShop, $method ) ) { 20 | return $this->thirdpartyShop->$method( ); 21 | } 22 | } 23 | } 24 | 25 | $d = new Delegator(); 26 | $d->thing(); 27 | 28 | ?> 29 | -------------------------------------------------------------------------------- /popp-code/5/listing5.23.php: -------------------------------------------------------------------------------- 1 | thirdpartyShop = new OtherShop(); 16 | } 17 | 18 | function __call( $method, $args ) { 19 | if ( method_exists( $this->thirdpartyShop, $method ) ) { 20 | return call_user_func_array( 21 | array( $this->thirdpartyShop, 22 | $method ), $args ); 23 | } 24 | } 25 | } 26 | 27 | $d = new Delegator(); 28 | $d->andAnotherThing( "a", "b" ); 29 | 30 | ?> 31 | -------------------------------------------------------------------------------- /popp-code/5/listing5.24.php: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /popp-code/5/listing5.25.php: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /popp-code/5/listing5.26.php: -------------------------------------------------------------------------------- 1 | getName(); 7 | if ( $class->isUserDefined() ) { 8 | $details .= "$name is user defined\n"; 9 | } 10 | if ( $class->isInternal() ) { 11 | $details .= "$name is built-in\n"; 12 | } 13 | if ( $class->isInterface() ) { 14 | $details .= "$name is interface\n"; 15 | } 16 | if ( $class->isAbstract() ) { 17 | $details .= "$name is an abstract class\n"; 18 | } 19 | if ( $class->isFinal() ) { 20 | $details .= "$name is a final class\n"; 21 | } 22 | if ( $class->isInstantiable() ) { 23 | $details .= "$name can be instantiated\n"; 24 | } else { 25 | $details .= "$name can not be instantiated\n"; 26 | } 27 | return $details; 28 | } 29 | 30 | $prod_class = new ReflectionClass( 'CdProduct' ); 31 | print classData( $prod_class ); 32 | 33 | ?> 34 | -------------------------------------------------------------------------------- /popp-code/5/listing5.27.php: -------------------------------------------------------------------------------- 1 | getFileName(); 8 | $lines = @file( $path ); 9 | $from = $class->getStartLine(); 10 | $to = $class->getEndLine(); 11 | $len = $to-$from+1; 12 | return implode( array_slice( $lines, $from-1, $len )); 13 | } 14 | } 15 | 16 | print ReflectionUtil::getClassSource( 17 | new ReflectionClass( 'CdProduct' ) ); 18 | print ReflectionUtil::getClassSource( 19 | new ReflectionClass( 'business\ShopProduct3' ) ); 20 | ?> 21 | -------------------------------------------------------------------------------- /popp-code/5/listing5.29.php: -------------------------------------------------------------------------------- 1 | getFileName(); 6 | $lines = @file( $path ); 7 | $from = $method->getStartLine(); 8 | $to = $method->getEndLine(); 9 | $len = $to-$from+1; 10 | return implode( array_slice( $lines, $from-1, $len )); 11 | } 12 | } 13 | 14 | $class = new ReflectionClass( 'CdProduct' ); 15 | $method = $class->getMethod( 'getSummaryLine' ); 16 | print ReflectionUtil::getMethodSource( $method ); 17 | ?> 18 | -------------------------------------------------------------------------------- /popp-code/5/listing5.30.php: -------------------------------------------------------------------------------- 1 | getMethod( "__construct" ); 6 | $params = $method->getParameters(); 7 | 8 | foreach ( $params as $param ) { 9 | print argData( $param )."\n"; 10 | } 11 | 12 | function argData( ReflectionParameter $arg ) { 13 | $details = ""; 14 | $declaringclass = $arg->getDeclaringClass(); 15 | $name = $arg->getName(); 16 | $class = $arg->getClass(); 17 | $position = $arg->getPosition(); 18 | $details .= "\$$name has position $position\n"; 19 | if ( ! empty( $class ) ) { 20 | $classname = $class->getName(); 21 | $details .= "\$$name must be a $classname object\n"; 22 | } 23 | 24 | if ( $arg->isPassedByReference() ) { 25 | $details .= "\$$name is passed by reference\n"; 26 | } 27 | 28 | if ( $arg->isDefaultValueAvailable() ) { 29 | $def = $arg->getDefaultValue(); 30 | $details .= "\$$name has default: $def\n"; 31 | } 32 | 33 | if ( $arg->allowsNull() ) { 34 | $details .= "\$$name can be null\n"; 35 | } 36 | 37 | return $details; 38 | } 39 | ?> 40 | -------------------------------------------------------------------------------- /popp-code/5/tasks/Task.php: -------------------------------------------------------------------------------- 1 | 11 | -------------------------------------------------------------------------------- /popp-code/5/useful/Outputter1.php: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /popp-code/5/useful/Outputter2.php: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /popp-code/5/useful/Outputter3.php: -------------------------------------------------------------------------------- 1 | 9 | -------------------------------------------------------------------------------- /popp-code/6/listing06.01.php: -------------------------------------------------------------------------------- 1 | $val ) { 22 | fputs( $fh, "$key:$val\n" ); 23 | } 24 | fclose( $fh ); 25 | } 26 | 27 | 28 | $file = "./params.txt"; 29 | $array['key1'] = "val1"; 30 | $array['key2'] = "val2"; 31 | $array['key3'] = "val3"; 32 | writeParams( $array, $file ); 33 | $output = readParams( $file ); 34 | print_r( $output ); 35 | 36 | 37 | ?> 38 | -------------------------------------------------------------------------------- /popp-code/6/listing06.04.php: -------------------------------------------------------------------------------- 1 | 20 | -------------------------------------------------------------------------------- /popp-code/9/listing9.01.php: -------------------------------------------------------------------------------- 1 | name = $name; 6 | } 7 | abstract function fire(); 8 | } 9 | 10 | class Minion extends Employee { 11 | function fire() { 12 | print "{$this->name}: I'll clear my desk\n"; 13 | } 14 | } 15 | 16 | class NastyBoss { 17 | private $employees = array(); 18 | 19 | function addEmployee( $employeeName ) { 20 | $this->employees[] = new Minion( $employeeName ); 21 | } 22 | 23 | function projectFails() { 24 | if ( count( $this->employees ) > 0 ) { 25 | $emp = array_pop( $this->employees ); 26 | $emp->fire(); 27 | } 28 | } 29 | } 30 | 31 | $boss = new NastyBoss(); 32 | $boss->addEmployee( "harry" ); 33 | $boss->addEmployee( "bob" ); 34 | $boss->addEmployee( "mary" ); 35 | $boss->projectFails(); 36 | 37 | // output: 38 | // mary: I'll clear my desk 39 | ?> 40 | -------------------------------------------------------------------------------- /popp-code/9/listing9.04.php: -------------------------------------------------------------------------------- 1 | props[$key] = $val; 18 | } 19 | 20 | public function getProperty( $key ) { 21 | return $this->props[$key]; 22 | } 23 | } 24 | 25 | 26 | $pref = Preferences::getInstance(); 27 | $pref->setProperty( "name", "matt" ); 28 | 29 | unset( $pref ); // remove the reference 30 | 31 | $pref2 = Preferences::getInstance(); 32 | print $pref2->getProperty( "name" ) ."\n"; // demonstrate value is not lost 33 | ?> 34 | -------------------------------------------------------------------------------- /popp-code/9/listing9.05.php: -------------------------------------------------------------------------------- 1 | 24 | -------------------------------------------------------------------------------- /popp-code/9/listing9.07.php: -------------------------------------------------------------------------------- 1 | 32 | -------------------------------------------------------------------------------- /popp-code/9/listing9.10.php: -------------------------------------------------------------------------------- 1 | sea = $sea; 22 | $this->plains = $plains; 23 | $this->forest = $forest; 24 | } 25 | 26 | function getSea( ) { 27 | return clone $this->sea; 28 | } 29 | 30 | function getPlains( ) { 31 | return clone $this->plains; 32 | } 33 | 34 | function getForest( ) { 35 | return clone $this->forest; 36 | } 37 | } 38 | 39 | $factory = new TerrainFactory( new EarthSea(), 40 | new EarthPlains(), 41 | new EarthForest() ); 42 | print_r( $factory->getSea() ); 43 | print_r( $factory->getPlains() ); 44 | print_r( $factory->getForest() ); 45 | ?> 46 | -------------------------------------------------------------------------------- /popp-code/AppendixB/gi/parse/Context.php: -------------------------------------------------------------------------------- 1 | resultstack, $mixed ); 9 | } 10 | 11 | function popResult( ) { 12 | return array_pop( $this->resultstack ); 13 | } 14 | 15 | function resultCount() { 16 | return count( $this->resultstack ); 17 | } 18 | 19 | function peekResult( ) { 20 | if ( empty( $this->resultstack ) ) { 21 | throw new Exception( "empty resultstack" ); 22 | } 23 | return $this->resultstack[count( $this->resultstack ) -1 ]; 24 | } 25 | 26 | /** 27 | * Get the stack as an array 28 | * 29 | * @return array mixed 30 | function resultArray() { 31 | return $this->resultstack; 32 | } 33 | */ 34 | } 35 | 36 | ?> 37 | 38 | -------------------------------------------------------------------------------- /popp-code/AppendixB/gi/parse/Reader.php: -------------------------------------------------------------------------------- 1 | 11 | -------------------------------------------------------------------------------- /popp-code/AppendixB/gi/parse/StringReader.php: -------------------------------------------------------------------------------- 1 | in = $in; 12 | $this->pos = 0; 13 | } 14 | 15 | function getChar() { 16 | if ( $this->pos >= strlen( $this->in ) ) { 17 | return false; 18 | } 19 | $char = substr( $this->in, $this->pos, 1 ); 20 | $this->pos++; 21 | return $char; 22 | } 23 | 24 | function getPos() { 25 | return $this->pos; 26 | } 27 | 28 | function pushBackChar() { 29 | $this->pos--; 30 | } 31 | 32 | function string() { 33 | return $this->in; 34 | } 35 | } 36 | ?> 37 | -------------------------------------------------------------------------------- /popp-code/AppendixB/listingApp.01.php: -------------------------------------------------------------------------------- 1 | nextToken() != \gi\parse\Scanner::EOF ) { 12 | print $scanner->token(); 13 | print "\t{$scanner->char_no()}"; 14 | print "\t{$scanner->getTypeString()}\n"; 15 | } 16 | ?> 17 | -------------------------------------------------------------------------------- /popp-code/AppendixB/listingApp.02.php: -------------------------------------------------------------------------------- 1 | evaluate( $input ); 11 | print "input: $input evaluating: $statement\n"; 12 | if ( $result ) { 13 | print "true!\n"; 14 | } else { 15 | print "false!\n"; 16 | } 17 | 18 | ?> 19 | -------------------------------------------------------------------------------- /popp-code/AppendixB/run-unit-tests: -------------------------------------------------------------------------------- 1 | #this probably isnt where your phpunit is.. amend accordingly 2 | 3 | phpunit test_parse_ParserTest 4 | -------------------------------------------------------------------------------- /popp-code/AppendixB/test/parse/res/sample1.txt: -------------------------------------------------------------------------------- 1 | this 2 | is a sample 3 | 4 | another test 5 | -------------------------------------------------------------------------------- /popp-code/AppendixB/test/parse/res/sample2.txt: -------------------------------------------------------------------------------- 1 | one 2 | 3 | two 4 | 5 | 6 | kjkj 7 | kjkj 8 | kjk 9 | -------------------------------------------------------------------------------- /popp-code/AppendixB/test/testutil/BaseTest.php: -------------------------------------------------------------------------------- 1 |