Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

BaseImage Class Reference
[Base Objects]

Inheritance diagram for BaseImage:

MyObject BaseObject MyModule BaseModule List of all members.

Detailed Description

BaseImage is a class for dealing with images.

A class that simplifies loading, editing, deleting, resizing, and saving of an image linked to a mysql database.

Todo:
de-couple this so closely from albums, or 'content_id' stuff. perhaps add a new class, ContentImage that extends off this one.

Definition at line 12 of file base-image.inc.php.

Public Member Functions

 __construct ($data=null, $table= 'images', $dataDir=null, $webDir=null, $origDir=null)
 Our constructor.
 load ($data, $deep=true)
 load data, set paths too
 getPagesXml ()
 adds pages to the module, included are bulkconfig, bulkform, bulkpost and resize.
 init ($page= 'main', $vars=array())
 This initializes the module...
 delete ()
 This deletes our files and passes it off to our parent for database.
 deleteFiles ()
 this deletes all our files and directory structures
 setPaths ()
 this function sets our paths in our ImageSize objects
 getSize ($search)
 this will search for an ImageSize that has path info and such
 editFormAddFields ($form)
 this adds fields to the edit form.
 editPagePostSaveSync ($form)
 this handles the sync part...
 editPagePostSuccess ($form, $url)
 this handles resizing the images and such.
 prepFile ()
 this prepares a file for resizing and such.
 resizeUploadedFile ()
 this resizes the uploaded file.
 getResizeCommands ()
 get the commands to do the resizing.
 resize ()
 this does the real resizing of the image to each ImageSize
 resizeToSize ($size)
 this resizes an image to a particular size
 centerCrop ($size)
 this crops an image to a square, centered on the image.
 cleanName ($name)
 this cleans a name passed into it so its safe.
 drawViewPage ()
 draws our view page!
 drawViewNav ()
 draws navigation for our view page
 drawSizes ()
 draws a list of sizes bigger than 'web'
 url ($type="thumb")
 gets the url to an image size.
 getImage ($type="thumb", $link=true, $drawCaption=true)
 gets the html markup for the image.
 drawImage ($type="thumb", $link=true, $drawCaption=true)
 draws teh markup for the image.
 drawRow ()
 Draws teh thumbnail of the image in a div with id 'imageCell'.
 initBulkConfigPage ()
 inializes the bulk config page...
 drawBulkConfigPage ()
 draws teh bulk configuration page.
 initBulkFormPage ()
 inits the bulk form page.
 drawBulkFormPage ()
 draws our bulk form page.
 drawBulkFormSelect ()
 Draws teh select form for what album to upload to...
 drawBulkApplet ($contentId)
 draws teh markup for the bulk applet.
 initBulkPostPage ()
 inits the bulk post pages and authenticates.
 drawBulkPostPage ()
 handles the bulk post...
 drawBulkSuccessText ($contentId)
 draws the bulk post success
 moveUploadedFile ($tmp)
 moves our uploaded file to a safe location
 initResizePage ()
 initializes the resize page...
 drawResizePage ()
 calls teh resize functions.
 getRssItem ()
 gets the rss for the image.
 getPublicData ()
 gets public data for serialized formats.
 getCreateFieldsArray ()
 get an array of fields in the table that stores the images
 getCreateIndexesArray ()
 get an array of indexes on fields in the images table

Static Public Member Functions

 isImage ($path)
 determines whether something is a real image (gif, jpg, png...

Public Attributes

 $doResize = true
 protected $doResize tells us whether we want to resize or print out the commands.

Protected Attributes

 $sizeAr = array()
 protected $sizeAr is an array of ImageSize objects that it uses for various things including resizing.
 $fullPath = ''
 protected $fullPath is the system path where the image is stored...
 $origPath = ''
 protected $origPath is the system path where the original image is stored...

Static Protected Attributes

 $dataDir = ''
 protected $dataDir is the system path where to store resized images.
 $origDir = ''
 protected $origDir is the system path where to store original images.
 $webDir = ''
 protected $webDir is the path via the web where the datadir is located.


Member Function Documentation

BaseImage::__construct data = null,
table = 'images',
dataDir = null,
webDir = null,
origDir = null
 

Our constructor.

Parameters:
$data See BaseObject
$table See BaseObject
$dataDir the directory where to store images. no trailing slash.
$webDir the webpath to the image directory. use trailing slash.
$origDir the directory where we store original images. no trailing slash.

Definition at line 58 of file base-image.inc.php.

References $dataDir, $origDir, $webDir, Config::get(), and Config::set().

BaseImage::centerCrop size  ) 
 

this crops an image to a square, centered on the image.

Parameters:
$size an ImageSize with the appropriate sizes set.

Definition at line 420 of file base-image.inc.php.

References Util::shellExec().

Referenced by resizeToSize().

BaseImage::cleanName name  ) 
 

this cleans a name passed into it so its safe.

underscores to dashes, spaces to dashes, any non alphanumeric, dash, or dot gets removed.

Parameters:
$name the name to clean
Returns:
the name, cleaned

Definition at line 449 of file base-image.inc.php.

Referenced by prepFile().

BaseImage::delete  ) 
 

This deletes our files and passes it off to our parent for database.

Reimplemented from BaseObject.

Definition at line 162 of file base-image.inc.php.

References deleteFiles().

BaseImage::deleteFiles  ) 
 

this deletes all our files and directory structures

Definition at line 172 of file base-image.inc.php.

Referenced by delete(), and editPagePostSaveSync().

BaseImage::drawBulkApplet contentId  ) 
 

draws teh markup for the bulk applet.

Todo:
remove contentId in an extensible fashion

Definition at line 862 of file base-image.inc.php.

References Config::get().

Referenced by drawBulkFormPage().

BaseImage::drawBulkConfigPage  ) 
 

draws teh bulk configuration page.

see the url for options. needs to pass teh session and stuff since the java module doesnt have your cookies and shit.

Todo:
update to remove content_id in an extensible fashion

Definition at line 620 of file base-image.inc.php.

References BaseModule::getUrl(), and BaseModule::params().

BaseImage::drawBulkFormPage  ) 
 

draws our bulk form page.

links to download java, upload single images, and the bulk applet

Todo:
remove content id in extensible way

Definition at line 788 of file base-image.inc.php.

References drawBulkApplet(), drawBulkFormSelect(), BaseModule::getLink(), and BaseModule::params().

BaseImage::drawBulkFormSelect  ) 
 

Draws teh select form for what album to upload to...

Todo:
remove content id in an extensible fashion

Definition at line 827 of file base-image.inc.php.

References BaseModule::getLink(), and BaseModule::getUrl().

Referenced by drawBulkFormPage().

BaseImage::drawBulkPostPage  ) 
 

handles the bulk post...

spawns resize processes, etc.

Todo:
remove contentId in an extensible fashion

Definition at line 917 of file base-image.inc.php.

References drawBulkSuccessText(), and BaseModule::params().

BaseImage::drawBulkSuccessText contentId  ) 
 

draws the bulk post success

Parameters:
$contentId the id of the content if you want to link to it.

Definition at line 976 of file base-image.inc.php.

Referenced by drawBulkPostPage().

BaseImage::drawImage type = "thumb",
link = true,
drawCaption = true
 

draws teh markup for the image.

see getImage() for parameter descriptions.

Definition at line 580 of file base-image.inc.php.

References getImage().

Referenced by drawRow(), and drawViewPage().

BaseImage::drawResizePage  ) 
 

calls teh resize functions.

remember: called async.

Definition at line 1027 of file base-image.inc.php.

References resize().

BaseImage::drawRow  ) 
 

Draws teh thumbnail of the image in a div with id 'imageCell'.

Reimplemented from BaseObject.

Definition at line 588 of file base-image.inc.php.

References drawImage(), and getSize().

BaseImage::drawSizes  ) 
 

draws a list of sizes bigger than 'web'

Definition at line 495 of file base-image.inc.php.

References getSize().

Referenced by drawViewPage().

BaseImage::drawViewNav  ) 
 

draws navigation for our view page

Definition at line 483 of file base-image.inc.php.

References BaseObject::canDelete(), and BaseObject::canEdit().

Referenced by drawViewPage().

BaseImage::drawViewPage  ) 
 

draws our view page!

Definition at line 464 of file base-image.inc.php.

References BaseObject::canDelete(), BaseObject::canEdit(), drawImage(), drawSizes(), and drawViewNav().

BaseImage::editFormAddFields form  ) 
 

this adds fields to the edit form.

Reimplemented from BaseObject.

Definition at line 253 of file base-image.inc.php.

BaseImage::editPagePostSaveSync form  ) 
 

this handles the sync part...

if we didnt get a file, remove the upload field to prevent erasing.

Reimplemented from BaseObject.

Definition at line 271 of file base-image.inc.php.

References deleteFiles().

BaseImage::editPagePostSuccess form,
url
 

this handles resizing the images and such.

Parameters:
$url the url to redirect to afterwards.

Definition at line 294 of file base-image.inc.php.

References BaseModule::getUrl(), prepFile(), Util::redirect(), resizeUploadedFile(), and url().

BaseImage::getCreateFieldsArray  ) 
 

get an array of fields in the table that stores the images

Todo:
remove contentId in an extensible fashion
Returns:
an array of field definitions with keys that are the same as the field name.

Reimplemented from BaseObject.

Definition at line 1077 of file base-image.inc.php.

BaseImage::getCreateIndexesArray  ) 
 

get an array of indexes on fields in the images table

Todo:
remove contentId in an extensible fashion
Returns:
a keyed array with keys as the field/index name and values as the index creation sql.

Reimplemented from BaseObject.

Definition at line 1098 of file base-image.inc.php.

BaseImage::getImage type = "thumb",
link = true,
drawCaption = true
 

gets the html markup for the image.

Parameters:
$type the name of the ImageSize you want.
$link boolean if you want it to be linked to the view page.
$drawCaption boolean if you want the caption to be drawn.
Returns:
teh markup of the image.

Definition at line 547 of file base-image.inc.php.

References $sizeAr, getSize(), and BaseModule::getUrl().

Referenced by drawImage(), getPublicData(), and getRssItem().

BaseImage::getPagesXml  ) 
 

adds pages to the module, included are bulkconfig, bulkform, bulkpost and resize.

Returns:
See BaseObject

Reimplemented from BaseObject.

Definition at line 123 of file base-image.inc.php.

BaseImage::getPublicData  ) 
 

gets public data for serialized formats.

see BaseObject for more info.

Reimplemented from BaseObject.

Definition at line 1053 of file base-image.inc.php.

References getImage(), BaseObject::hasField(), and url().

BaseImage::getResizeCommands  ) 
 

get the commands to do the resizing.

this is intended for use when you are upgrading and need to do bulk resizing via shell scripts, etc.

Returns:
the shell commands to run

Definition at line 360 of file base-image.inc.php.

References resize().

BaseImage::getRssItem  ) 
 

gets the rss for the image.

you shouldnt have to define getRssItem() for your image... automatic image rss feeds!!

Returns:
see BaseObject

Reimplemented from BaseObject.

Definition at line 1040 of file base-image.inc.php.

References getImage().

BaseImage::getSize search  ) 
 

this will search for an ImageSize that has path info and such

Parameters:
$search the string name of the size.

Definition at line 240 of file base-image.inc.php.

Referenced by drawRow(), drawSizes(), getImage(), and url().

BaseImage::init page = 'main',
vars = array()
 

This initializes the module...

and sets the paths.

See also:
BaseObject::init()

Reimplemented from BaseModule.

Definition at line 151 of file base-image.inc.php.

References setPaths().

BaseImage::initBulkConfigPage  ) 
 

inializes the bulk config page...

Definition at line 599 of file base-image.inc.php.

References BaseModule::assertLogin(), BaseModule::params(), and BaseModule::setTemplate().

BaseImage::initBulkFormPage  ) 
 

inits the bulk form page.

Definition at line 776 of file base-image.inc.php.

References BaseModule::assertLogin().

BaseImage::initBulkPostPage  ) 
 

inits the bulk post pages and authenticates.

Definition at line 894 of file base-image.inc.php.

References BaseModule::params(), and BaseModule::setTemplate().

BaseImage::initResizePage  ) 
 

initializes the resize page...

intended to be called async

Definition at line 1013 of file base-image.inc.php.

References BaseModule::params(), and BaseModule::setTemplate().

BaseImage::isImage path  )  [static]
 

determines whether something is a real image (gif, jpg, png...

no bmps here bitch).

Parameters:
$path path to the image
Returns:
boolean of image status

Definition at line 989 of file base-image.inc.php.

BaseImage::load data,
deep = true
 

load data, set paths too

See also:
BaseObject::load()

Reimplemented from BaseObject.

Definition at line 104 of file base-image.inc.php.

References Config::get(), and setPaths().

BaseImage::moveUploadedFile tmp  ) 
 

moves our uploaded file to a safe location

Parameters:
$tmp the path to the temp file.

Definition at line 1005 of file base-image.inc.php.

BaseImage::prepFile  ) 
 

this prepares a file for resizing and such.

cleans the name, creates directories.

Definition at line 318 of file base-image.inc.php.

References cleanName(), BaseObject::save(), and setPaths().

Referenced by editPagePostSuccess().

BaseImage::resize  ) 
 

this does the real resizing of the image to each ImageSize

Definition at line 370 of file base-image.inc.php.

References resizeToSize(), BaseObject::save(), and setPaths().

Referenced by drawResizePage(), and getResizeCommands().

BaseImage::resizeToSize size  ) 
 

this resizes an image to a particular size

Definition at line 400 of file base-image.inc.php.

References centerCrop(), and Img::resize().

Referenced by resize().

BaseImage::resizeUploadedFile  ) 
 

this resizes the uploaded file.

to make it faster for the end user, it actually spawns an async http request. woot!

Definition at line 346 of file base-image.inc.php.

References Util::spawnHttpAsync().

Referenced by editPagePostSuccess().

BaseImage::setPaths  ) 
 

this function sets our paths in our ImageSize objects

Definition at line 192 of file base-image.inc.php.

Referenced by init(), load(), prepFile(), and resize().

BaseImage::url type = "thumb"  ) 
 

gets the url to an image size.

Parameters:
$type the name of an ImageSize you want
Returns:
the web url to the image.

Definition at line 530 of file base-image.inc.php.

References getSize().

Referenced by editPagePostSuccess(), and getPublicData().


Member Data Documentation

BaseImage::$dataDir = '' [static, protected]
 

protected $dataDir is the system path where to store resized images.

Definition at line 17 of file base-image.inc.php.

Referenced by __construct().

BaseImage::$doResize = true
 

protected $doResize tells us whether we want to resize or print out the commands.

Definition at line 47 of file base-image.inc.php.

BaseImage::$fullPath = '' [protected]
 

protected $fullPath is the system path where the image is stored...

auto generated.

Definition at line 37 of file base-image.inc.php.

BaseImage::$origDir = '' [static, protected]
 

protected $origDir is the system path where to store original images.

Definition at line 22 of file base-image.inc.php.

Referenced by __construct().

BaseImage::$origPath = '' [protected]
 

protected $origPath is the system path where the original image is stored...

auto generated.

Definition at line 42 of file base-image.inc.php.

BaseImage::$sizeAr = array() [protected]
 

protected $sizeAr is an array of ImageSize objects that it uses for various things including resizing.

Definition at line 32 of file base-image.inc.php.

Referenced by getImage().

BaseImage::$webDir = '' [static, protected]
 

protected $webDir is the path via the web where the datadir is located.

Definition at line 27 of file base-image.inc.php.

Referenced by __construct().


The documentation for this class was generated from the following file:
Generated on Fri Oct 27 12:26:41 2006 for BaseJumper by doxygen 1.3.9.1