Website Downloads Documentation Knowledgebase Wiki Issue tracker Commercial support

Daisy Repository PHP framework

Preliminary report

Obtaining the code

The code of the framework could be obtained from SVN using the following URL: http://svn.cocoondev.org/repos/daisy/contrib/gsoc2006/kostiantyn/DaisyLib/

You should use the latest version of PHP5. Particularly you should use a version that already supports type-hinting (http://www.php.net/manual/en/language.oop5.typehinting.php). The project was written using PHP 5.1.4 and failed at PHP 5.0.4 with an error "Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in ...". So if you encounter such an error it is better to update your PHP5.

Purpose

The project is dedicated to the developing of PHP5 framework for accessing Daisy Repository Publisher. The framework is intended to give a PHP developer ability to:

  1. Assemble any Publisher request;
  2. Make a publisher request and retrieve the response;
  3. Process the response to give a template-writer ability to use the data in an easy way;
  4. Apply any templates (any template engine).

Directory structure

DaisyConfig.php contains some configuration constants.

Temp directory contains Smarty template engine (in the project all templates are currently written using Smarty but you can use any template engine you want - just implement IDaisyPublisherResponseTemplate interface).

test.php contains some example code of the framework usage.

Implementations contains templates (you could place them anywhere; you only need to supply right paths to the framework classes). This directory should also contain some files that now in another folder (implementations of interfaces).

Classes - the heart of the project. The directory contains 3 main purpose classes and Publisher directory. Publisher interaction is one of the planned parts of the project but the most important. It has separate classes for composing Publisher requests and for preparing Publisher response for easy use by template-writers.

Using the framework

At the moment the best way to get in touch with the framework is looking inside of the test.php file. Using DaisyPublisherRequest and other publisher request objects you can compose any publisher request you want (for publisher request look: http://cocoondev.org/daisydocs-1_5/repository/general/194.html).

After getting sending the request and retrieving the reponse XML you should provide the XML to DaisyPublisherResponse object. The object should also be provided with a class descendant to ADaisyPublisherInlinedTagsConvertor and intended for converting daisy document and image links and some other stuff. You can have a look at PHP and Smarty realizations: PHPDaisyPublisherInlinedTagsConvertor and SmartyDaisyPublisherInlinedTagsConvertor classes.

DaisyPublisherResponsePreparedDocuments is the last object to be used but it has some more features to be configured. You should provide it with SimpleXML object created after processing XML by DaisyPublisherResponse object. The object must be also provided by ADaisyPublisherInlinedTagsConvertor descendant and IDaisyPublisherResponseTemplate interface implementations to process document templates (ADaisyPublisherInlinedTagsConvertor descendants can also use template engines for data processing – look through SmartyDaisyPublisherInlinedTagsConvertor class). The object must be also supplied with appropriate templates’ paths. One for <p:preparedDocuments> tag and one for <p:document>. A template for exceptional situations should be also supplied in case of errors.

The user can also specify different templates for different document types (see test.php).

The following documentation is too old. It left only for future rewriting

HTTP connection classes

DaisyUser class

Now intended just for storing repository user and password. The user is used while sending HTTP request to the repository server.

DaisyUser class

DaisyHTTPClient class

The main connection class.  Having sufficient parameters it connects to the repository server using sockets and send HTTP requests when needed. HTTP request are fully customizable using class methods. The class is made using singleton design pattern. In case of changing host or port parameters it automatically reconnects to the server.

HTTPClient class

Daisy Publisher interaction

As it's stated in the project plan I started working on interaction with Daisy CMS Publisher. First I started working on Publisher requests. I tried working through SimpleXML PHP extension but it is appeared to be too akward and yet buggy for editing XML so for the following classes I am going to try DOM XML PHP extension that seems to be more suitable for editing XML documents. Nevertheless I will try to use SimpleXML while working with publisher response.

DaisyPublisherRequest class

The class is used for creating Daisy Publisher XML request. It's designed being a container for specific publisher request tags. It also sends the request to the publisher through HTTP Client class using User class for authorization. Now it has the only method used for request specific tags - addDocument(). The method Initialize DaisyPublisherRequest class and returns a reference on it. The following methods will also initialize other classes for customizing XML tags used in the publisher request ( <p:preparedDocuments>, <p:preparedDocument>, <p:diff> etc)

PublisherRequest class

DaisyPublisherDocument class

The class methods are used to set <p:document> tag attributes values and to add different tags that can be enclosed by <p:document> (<p:aclInfo>, <p:comments> etc). Tags and attributes are added to the publisher request from which the DaisyPublisherDocument object was returned. Publisher request can instantiate several document objects that will be included to the request XML tree.PublisherDocument class

Classes Diagram

The following diagram represents the current classes interconnection.

classes diagram
Click to enlarge

Comments (0)
Advertisement

Daisy hosting, installation, support. Workshops and turnkey Daisy CMS projects. Get Daisy from its creators.

outerthought.org

Downloads provided by

SourceForge.net Logo

Open source stats