PHP interface to wikiservers
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README.md
Wikiclient.php
Wikirequest.php

README.md

PHP Wikiclient

This is a PHP interface to the wikifier server.

Sorry, this documentation is not up-to-date.

If you're using this API, you're more than likely capable of understanding it just by looking at the code. Also, the return value for these functions is usually just a standard object with the properties returned by the respective wikiserver command.

Constructor

Create a new wikiclient instance.

$wikiclient = new Wikiclient($path, $wiki_name, $wiki_pass, $session_id);
  • $path - Path the wikifier UNIX socket.
  • $wiki_name - shortname of the wiki. This is the one used in the wikiserver configuration file.
  • $wiki_pass - password for read access to the wiki. This is also set in the wikiserver configuration file.
  • $session_id - optional, a string which identifies a logged in user. Once the user logs in initially with ->login(), the session ID can be used to resume the session on each page load without having to send the username and password again. This is only useful if you need write access to the wiki from this wikiclient.

High-level methods

login

$wikiclient->login($username, $password, $session_id);

Used to obtain write access to this wiki. This is not needed if you are only going to be reading with this wikiclient.

  • $username - account username.
  • $password - account password.
  • $session_id - optional, a string which will later be used to re-identify the user without having to send the username and password again. See the constructor for more information.

Returns an object with properties.

  • ->logged_in - true if the login was successful.
  • ->incorrect - true if the credentials were incorrect.
  • ->name - user's real name, if configured.
  • ->email - user's email, if configured.
  • May return an error instead.

page

$wikiclient->page($name);

Requests the HTML for a page.

  • $name - the page name, with or without the .page extension.

Returns an object with properties:

  • ->title - human-readable title, as defined by @page.title.
  • ->content - HTML page content.
  • ->css - CSS page content.
  • ->categories - array of category names the page belongs to.
  • ->modified - time string at which the page was last modified. this is formatted for use in a Last-Modified header.
  • ->created - UNIX timestamp at which the page was created, if available.
  • ->generated - true if the page was just generated by this request.
  • ->cached - true if ->content came from a cached HTML file.
  • ->cache_gen - true if this request resulted in writing a new cache file.
  • ->file - page filename relative to the wiki's page root @dir.page.
  • ->path - absolute path to the page filename.
  • ->type - "page".
  • ->mime - "text/html". for Content-Type header.
  • ->length - byte length of ->content. for Content-Length header.
  • May return an error instead.

page_code

$wikiclient->page_code($name);

Requests the wikifier source code for a page.

Returns an object with properties:

  • ->content - page's wikifier source code.
  • ->file - page filename relative to the wiki's page root @dir.page.
  • ->path - absolute path to the page filename.
  • ->type - "page_code".
  • ->mime - "text/plain". for Content-Type header.
  • ->length - byte length of ->content. for Content-Length header.
  • May return an error instead.

page_list

$wikiclient->page_list($sort);

Fetches the list of all pages on the wiki.

  • $sort - a hint for how the pages should be sorted. Format is one of a (alphabetical by page name), c (by creation date), m (by modification date), or u (alphabetical by author name); followed by + for ascending or - for descending. Default m- (recently-modified first).

Returns an object with properties:

  • ->pages - array of page objects. Objects are in the same format as returned by cat_posts, except that the ->content is omitted.

image

$wikiclient->image($name, $width, $height);
  • $name - image filename, relative to the wiki image root @dir.image.
  • $width - optional, desired image width, in pixels. If provided, $height must also be provided.
  • $height - optional, desired image height, in pixels. If provided, $width must also be provided.
  • If neither $width nor $height are provided, the full-sized image is used.

Fetches information about an image. Note that the image data itself is not delivered via the wikiserver transport. Instead, the HTTPd should serve the image directly.

Returns an object with properties:

  • ->image_type - "jpeg" or "png".
  • ->modified - time string at which the image was last modified. this is formatted for use in a Last-Modified header.
  • ->file - image filename with requested dimensions, relative to wiki image root @dir.image.
  • ->path - absolute path to the image at requested dimensions.
  • ->fullsize_path - absolute path to the full-sized image.
  • ->mime - image mimetype. for Content-Type header.
  • ->length - image bytesize. for Content-Length header.
  • ->etag - string to identify this version of the image. for Etag header.
  • ->type - "image".
  • ->generated - true if the image was just generated by this request.
  • ->cached - true if the image is cached at the requested dimensions.
  • ->cache_gen - true if this request resulted in writing a new cached image.
  • May return an error instead.

cat_posts

$wikiclient->cat_posts($name, $page_n);

page_save

$wikiclient->page_save($name, $content, $message);

page_del

$wikiclient->page_del($name);

page_move

$wikiclient->page_move($name, $new_name);

Low-level methods

These methods usually aren't used directly.

connect

$wikiclient->connect();

Connects to the wikiserver. You don't have to call this directly, as other methods will automatically connect if needed.

command

$wikiclient->command($command, $opts);

Sends a raw command to the wikiserver. You shouldn't have to use this directly, since the other high-level methods wrap it.

Errors

Methods that might fail can return errors. In such a case, the return values listed elsewhere will not be present. These values will be there instead:

  • ->response: "error". Normally this would instead be the type of reply.
  • ->type: type of error.
  • ->reason: human-readable error message.
  • ->draft: true if the error is because the content is marked as draft and you are not allowed to see it yet.