[ class tree: plugins ] [ index: plugins ] [ all elements ]

Class: WEBdocs

Source Location: /zp-extensions/class-WEBdocs.php

Class WEBdocs

Class Overview

Core class for handling "non-image" files

Text type files can be displayed in place of an image in themes

supports files of the following types: .txt .htm .html The contents of these files are "dumpped" into a SPAN sized to a 24x36 ratioed box based on your theme "image size" option. This has a class of "textobject" so it can be styled.

What this plugin really is for is to serve as a model of how a plugin can be made to handle file types that zenphoto does not handle natively.

Some key points to note:

  1. The naming convention for these plugins is class-«handler class».php.
  2. The statement setting the plugin_is_filter variable must be near the front of the file. This is important
as it is the indicator to the Zenphoto plugin loader to load the script at the same point that other object modules are loaded. 3. These objects are extension to the zenphoto "Image" class. This means they have all the properties of an image plus whatever you add. Of course you will need to override some of the image class functions to implement the functionality of your new class. 4. There is one VERY IMPORTANT method that you must provide which is not part of the "Image" base class. That getContent() method. This method is called by template-functions.php in place of where it would normally put a URL to the image to show. This method must do everything needed to cause your image object to be viewable by the browser.

So, briefly, the first four lines of code below are the standard plugin interface to Admin. There is one small wrinkle you might notice--the code for 'plugin_description' includes a test which sets the variable $disable. As you might expect, there were some changes needed to zenphoto in order to get this concept to work. $disable is set to true if the revision of zenphoto that is attempting to load this plugin is lower than the one where the implementation first appeared. The interface variable 'plugin_disable' is set to this value telling Admin not to allow enabling of the plugin if the release level is too low.

The line that follows insures that the plugin will not load when it should be disabled--just in case.

Then there is a call on addPlginType(«file extension», «Object Name»); This function registers the plugin as the handler for files with the specified extension. If the plugin can handle more than one file extension, make a call to the registration function for each extension that it handles.

The rest is the object class for handling these files.

The code of the object instantiation function is mostly required. Plugin "images" follow the lead of videos in that if there is a real image file with the same name save the suffix, it will be considered the thumb image of the object. This image is fetched by the call on checkObjectsThumb(). There is also code in the getThumb() method to deal with this property.

Since text files have no natural height and width, we set them based on the image size option. This happens after the call PersistentObject(). The rest of the code there sets up the default title.

getThumb() is responsible for generating the thumbnail image for the object. As above, if there is a similar named real image, it will be used. Otherwise [for this object implementation] we will use a thumbnail image provided with the plugin. The particular form of the file name used when there is no thumb stand-in image allows zenphoto to choose an image in the plugin folder.

Located in /zp-extensions/class-WEBdocs.php [line 85]

PersistentObject
   |
   --ThemeObject
      |
      --MediaObject
         |
         --Image
            |
            --TextObject
               |
               --WEBdocs
Author(s):
  • Stephen Billard (sbillard)
Information Tags:

Methods

[ Top ]
Inherited Properties, Constants, and Methods
Inherited Properties Inherited Methods Inherited Constants

Inherited From TextObject

TextObject::$watermark
TextObject::$watermarkDefault

Inherited From Image

Image::$album
Image::$albumlink
Image::$albumname
Image::$albumnamealbum
Image::$displayname
Image::$exists
Image::$filemtime
Image::$filename
Image::$imagefolder
Image::$index
Image::$localpath
Image::$manage_rights
Image::$manage_some_rights
Image::$objectsThumb
Image::$sidecars
Image::$sortorder
Image::$view_rights
Image::$webpath

Inherited From ThemeObject

ThemeObject::$comments

Inherited From PersistentObject

PersistentObject::$id
PersistentObject::$loaded
PersistentObject::$table
PersistentObject::$transient

Inherited From TextObject

TextObject::__construct()
creates a textobject (image standin)
TextObject::common_instantiate()
Handles class common instantiation
TextObject::getBody()
TextObject::getContent()
Returns the content of the text file
TextObject::getCustomImage()
Get a custom sized version of this image based on the parameters.
TextObject::getSizedImage()
(non-PHPdoc)
TextObject::getThumb()
returns a link to the thumbnail for the text file.
TextObject::getThumbImageFile()
Returns the image file name for the thumbnail image.
TextObject::updateDimensions()
(non-PHPdoc)

Inherited From Image

Image::__construct()
Constructor for class-image
Image::checkAccess()
returns true if user is allowed to see the image
Image::checkforGuest()
Checks if guest is loggedin for the album
Image::classSetup()
generic "image" class setup code Returns true if valid image.
Image::copy()
Copies the image to a new album, along with all metadata.
Image::fileChanged()
Returns true if the file has changed since last time we looked
Image::getAlbum()
Returns the album that holds this image
Image::getAlbumName()
Retuns the folder name of the album that holds this image
Image::getCity()
Returns the city field of the image
Image::getContent()
Returns the default sized image HTML
Image::getCopyright()
Returns the copyright field of the image
Image::getCountry()
Returns the country field of the image
Image::getCredit()
Returns the credit field of the image
Image::getCustomImage()
Get a custom sized version of this image based on the parameters.
Image::getFileName()
Returns the image filename
Image::getFullImage()
Returns a path to the original image in the original folder.
Image::getFullImageURL()
returns URL to the original image
Image::getHeight()
Returns the height of the image
Image::getImageFootprint()
Returns the disk size of the image
Image::getImageLink()
Returns a path urlencoded image page link for the image
Image::getIndex()
Get the index of this image in the album, taking sorting into account.
Image::getLink()
Returns a path urlencoded image page link for the image
Image::getLocation()
Returns the location field of the image
Image::getMetaData()
Returns an array of EXIF data
Image::getNextImage()
Returns the next Image.
Image::getOwner()
Owner functions
Image::getPrevImage()
Return the previous Image
Image::getSizedImage()
Returns a path to a sized version of the image
Image::getState()
Returns the state field of the image
Image::getThumb()
Get a default-sized thumbnail of this image.
Image::getThumbCropping()
Returns an array of cropping parameters. Used as a "helper" function for various inherited getThumb() methods
Image::getThumbImageFile()
Returns the image file name for the thumbnail image.
Image::getWatermark()
Returns the custom watermark name
Image::getWidth()
Returns the width of the image
Image::getWMUse()
Returns the custom watermark usage
Image::isMyItem()
Image::isProtected()
returns true if there is any protection on the image
Image::move()
Moves an image to a new album and/or filename (rename).
Image::remove()
Permanently delete this image (permanent: be careful!)
Image::rename()
Renames an image to a new filename, keeping it in the same album. Convenience for move($image->album, $newfilename).
Image::setCity()
Stores the city field of the image
Image::setCopyright()
Stores the text for the copyright field of the image
Image::setCountry()
Stores the country field of the image
Image::setCredit()
Stores the credit field of the image
Image::setDefaults()
(non-PHPdoc)
Image::setLocation()
Stores the location field of the image
Image::setOwner()
Image::setState()
Stores the state field of the image
Image::setWatermark()
Set custom watermark
Image::setWMUse()
Sets the custom watermark usage
Image::updateDimensions()
Update this object's values for width and height.
Image::updateMetaData()
Parses Exif/IPTC data

Inherited From MediaObject

MediaObject::__construct()
Class instantiator
MediaObject::getDesc()
Returns the description
MediaObject::getExpireDate()
Returns the expire date
MediaObject::getPassword()
Returns the password
MediaObject::getPasswordHint()
Returns the password hint
MediaObject::getPublishDate()
Returns the publish date
MediaObject::getSortOrder()
Returns the sort order
MediaObject::getUser()
Returns the guest user
MediaObject::setDesc()
Stores the description
MediaObject::setExpireDate()
sets the expire date
MediaObject::setPassword()
Sets the encrypted password
MediaObject::setPasswordHint()
Sets the password hint
MediaObject::setPublishDate()
sets the publish date
MediaObject::setSortOrder()
Stores the sort order
MediaObject::setUser()
Sets the guest user

Inherited From ThemeObject

ThemeObject::__construct()
Class instantiator
ThemeObject::addComment()
Adds comments to the album assumes data is coming straight from GET or POST
ThemeObject::checkAccess()
Checks if viewing of object is allowed
ThemeObject::checkForGuest()
returns false (deny) if gallery is "private"
ThemeObject::countHit()
counts visits to the object
ThemeObject::getCodeblock()
Returns the codeblocks as an serialized array
ThemeObject::getCommentCount()
Returns the count of comments in the album. Ignores comments in moderation
ThemeObject::getComments()
Returns an array of comments for this album
ThemeObject::getCommentsAllowed()
Retuns true if comments are allowed
ThemeObject::getCustomData()
returns the custom data field
ThemeObject::getDateTime()
Returns the unformatted date
ThemeObject::getHitcounter()
Returns the hitcount
ThemeObject::getParentID()
Returns the partent id
ThemeObject::getShow()
Returns true published
ThemeObject::getTags()
Returns the tag data
ThemeObject::getTitle()
Returns the title
ThemeObject::hasTag()
Checks if an object has a tag assigned.
ThemeObject::isMyItem()
Checks basic access rights of an object
ThemeObject::setCodeblock()
set the codeblocks as an serialized array
ThemeObject::setCommentsAllowed()
Sets the comments allowed flag
ThemeObject::setCustomData()
Sets the custom data field
ThemeObject::setDateTime()
Stores the date
ThemeObject::setParentID()
Sets the ParentID field
ThemeObject::setShow()
Stores the published value
ThemeObject::setTags()
Stores tag information
ThemeObject::setTitle()
Stores the title

Inherited From PersistentObject

PersistentObject::PersistentObject()
PersistentObject::copy()
Copy this record to another unique set. Checks if the record exists there first, if so returns false. If successful returns true. No changes are made to this object and no other objects are created, just the database entry.
PersistentObject::get()
Get the value of a variable. If $current is false, return the value as of the last save of this object.
PersistentObject::getData()
returns the database record of the object
PersistentObject::getID()
Returns the id
PersistentObject::instantiate()
Prime instantiator for Zenphoto objects
PersistentObject::move()
Change one or more values of the unique set assigned to this record.
PersistentObject::remove()
Deletes object from the database
PersistentObject::save()
Save the updates made to this object since the last update. Returns true if successful, false if not.
PersistentObject::set()
Set a variable in this object. Does not persist to the database until save() is called. So, IMPORTANT: Call save() after set() to persist.
PersistentObject::setDefaults()
Sets default values for new objects using the set() method.
PersistentObject::__toString()
"Magic" function to return a string identifying the object when it is treated as a string

[ Top ]
Method Summary
TextObject   __construct()   creates a WEBdocs (image standin)
string   getContent()   Returns the content of the text file
s   getThumbImageFile()   Returns the image file name for the thumbnail image.

[ Top ]
Methods
Constructor __construct  [line 94]

  TextObject __construct( object $album, string $filename, [ $quiet = false]  )

creates a WEBdocs (image standin)

Parameters:
object   $album:  the owner album
string   $filename:  the filename of the text file
   $quiet: 


Redefinition of:
TextObject::__construct()
creates a textobject (image standin)

[ Top ]
getContent  [line 145]

  string getContent( [int $w = NULL], [int $h = NULL]  )

Returns the content of the text file

Parameters:
int   $w:  optional width
int   $h:  optional height


Redefinition of:
TextObject::getContent()
Returns the content of the text file

[ Top ]
getThumbImageFile  [line 109]

  s getThumbImageFile( [string $path = NULL]  )

Returns the image file name for the thumbnail image.

Parameters:
string   $path:  override path


Redefinition of:
TextObject::getThumbImageFile()
Returns the image file name for the thumbnail image.

[ Top ]

Documentation generated on Sat, 07 Jun 2014 18:03:19 +0200 by phpDocumentor 1.4.3