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

Class: TextObject

Source Location: /zp-extensions/class-textobject/class-textobject_core.php

Class TextObject

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-textobject/class-textobject_core.php [line 63]

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

Properties

Methods

[ Top ]
Descendants
Child Class Description
AnyFile Core class for handling "non-image" files
WEBdocs Core class for handling "non-image" files

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

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 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 ]
Property Summary
mixed   $watermark  
mixed   $watermarkDefault  

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

[ Top ]
Properties
mixed   $watermark = NULL [line 65]
API Tags:
Access:  protected


[ Top ]
mixed   $watermarkDefault = NULL [line 66]
API Tags:
Access:  protected


[ Top ]
Methods
Constructor __construct  [line 75]

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

creates a textobject (image standin)

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


Redefinition of:
Image::__construct()
Constructor for class-image

Redefined in descendants as:

[ Top ]
common_instantiate  [line 88]

  void common_instantiate( $album $album, $filename $filename, [ $quiet = false]  )

Handles class common instantiation

Parameters:
$album   $album: 
$filename   $filename: 
   $quiet: 


[ Top ]
getBody  [line 176]

  void getBody( [ $w = NULL], [ $h = NULL]  )

Parameters:
   $w: 
   $h: 


[ Top ]
getContent  [line 188]

  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:
Image::getContent()
Returns the default sized image HTML

Redefined in descendants as:

[ Top ]
getCustomImage  [line 221]

  string getCustomImage( int $size, int $width, int $height, int $cropw, int $croph, int $cropx, int $cropy, [bool $thumbStandin = false], [bool $effects = NULL], string $alt, string $class, string $id  )

Get a custom sized version of this image based on the parameters.

Parameters:
string   $alt:  Alt text for the url
int   $size:  size
int   $width:  width
int   $height:  height
int   $cropw:  crop width
int   $croph:  crop height
int   $cropx:  crop x axis
int   $cropy:  crop y axis
string   $class:  Optional style class
string   $id:  Optional style id
bool   $thumbStandin:  set to true to treat as thumbnail
bool   $effects:  ignored


Redefinition of:
Image::getCustomImage()
Get a custom sized version of this image based on the parameters.

[ Top ]
getSizedImage  [line 252]

  void getSizedImage( $size  )

(non-PHPdoc)

Parameters:
   $size: 

API Tags:
See:  zp-core/Image::getSizedImage()


Redefinition of:
Image::getSizedImage()
Returns a path to a sized version of the image

[ Top ]
getThumb  [line 152]

  string getThumb( [string $type = 'image']  )

returns a link to the thumbnail for the text file.

Parameters:
string   $type:  'image' or 'album'


Redefinition of:
Image::getThumb()
Get a default-sized thumbnail of this image.

[ Top ]
getThumbImageFile  [line 125]

  s getThumbImageFile( [string $path = NULL]  )

Returns the image file name for the thumbnail image.

Parameters:
string   $path:  override path


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

Redefined in descendants as:

[ Top ]
updateDimensions  [line 273]

  void updateDimensions( )

(non-PHPdoc)


API Tags:
See:  zp-core/Image::updateDimensions()


Redefinition of:
Image::updateDimensions()
Update this object's values for width and height.

[ Top ]

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