classes/php5_classes/Image.class.php

Properties

Description

This file holds the geoImage class, which is responsible for stuff dealing with images and image processing.

Classes

geoImage

Properties

 
 
System  
No 
No 

Description

This class is responsible for a lot of the image processing, along with other aspects like generating the image tag for thumbnails.

Methods

__construct, _returnError, absoluteUrl, copyImages, display_image, display_thumbnail, fixDuplicates, generateFilename, getExtension, getInstance, getMimeType, getRemoteDims, getScaledSize, remove, resize, setAdConfig, shortenImageTitle,

__construct( ) : n/a

Description

This is private to force new instantiation to take place in getInstance.
It also sets up $this->db.

Return value

Type Description
n/a n/a

_returnError( string   $errorMsg, string   $errField = 'error', ) : n/a

Description

When called, returns JSON error and stops rest of page load.

Arguments

Name Type Description Default
$errorMsg string
$errField string 'error'

Return value

Type Description
n/a n/a

absoluteUrl( String   $url, ) : String

Description

Transforms a local image path into its full URL e.g. "user_images/myImage.jpg" => "http://mysite.com/user_images/myImage.jpg"

Arguments

Name Type Description Default
$url String

Return value

Type Description
String the full URL

copyImages( int   $id, ) : array

Description

Copy the images for a specific listing ID, and returns the images captured array that can be used to attach those new images to a new listing.

Arguments

Name Type Description Default
$id int

The listing ID to copy the images from

Return value

Type Description
array The images captured array, to be used to "attach" the new images to a new listing.

display_image( string   $url, int   $width = 0, int   $height = 0, string   $mime_type = 0, bool   $icon = 0, string   $alt_data = '', ) : string|bool

Description

Gets an tag for the given URL and other criteria.

Arguments

Name Type Description Default
$url string
$width int 0
$height int 0
$mime_type string 0
$icon bool

If $mime_type evaluates to false (empty string, null, etc) then this isn't used. If this is true, will use an icon instead of the image.

0
$alt_data string

Alt string to put into the alt attribute on the image tag.

''

Return value

Type Description
string|bool The image tag, or false/null if something went wrong.

display_thumbnail( int   $classified_id, int   $max_width = 0, int   $max_height = 0, bool   $skip_table_data = 0, int   $affiliate_id = 0, string   $aff_type = 'aff', bool   $force_full_image = 0, ) : string|bool

Description

Gets the tag for a thumbnail to be used to display the thumbnail for a given image.

Arguments

Name Type Description Default
$classified_id int
$max_width int 0
$max_height int 0
$skip_table_data bool 0
$affiliate_id int 0
$aff_type string

Either 'aff' or 'store' depending on if displaying image for affiliate page or storefront.

'aff'
$force_full_image bool 0

Return value

Type Description
string|bool The image tag to display a thumbnail for the given listing, or false if there is a problem getting the data.

fixDuplicates( int   $listingId, ) : n/a

Description

Sometimes 2 images can end up in the same "slot" (display_order value) for a given listing. This method fixes that by removing the older image where there is more than one image in a "slot" for a listing.

Arguments

Name Type Description Default
$listingId int

The listing ID to check.

Return value

Type Description
n/a n/a

Tags

Name Description
since Version 4.0.9

generateFilename( string   $uploadPath, string   $ext = '.jpg', ) : string

Description

Generate a new filename in the form of 123456789.[ext], making sure file does not already exist.

Arguments

Name Type Description Default
$uploadPath string

Location the file will be used

$ext string

The file's extension

'.jpg'

Return value

Type Description
string The filename relative to $uploadPath

getExtension( string   $mime_type, ) : string|null

Description

Gets an extension given the mime type. Note that this is currently a normal "non static" method, but since there is no real reason for it to be that way since it is not currently working like "an object" (like the geoListing class does), we may change it to be a static method in a future version.

Arguments

Name Type Description Default
$mime_type string

Return value

Type Description
string|null The extension if found, or null if the extension is not known for the given mime type.

getInstance( ) : \geoImage

Description

gets an instance of geoImage using the Singleton method.

Return value

Type Description
\geoImage

getMimeType( string   $file, string   $uploadName = '', string   $defaultMime = '', ) : string|bool

Description

This is an alias of {@see geoFile::getMimeType()}, see that method for more details. This calls that method passing in false for the 4th param $inJail.

Arguments

Name Type Description Default
$file string

The absolute location for the file to detect mime type for.

$uploadName string

The name that is "reported" as the actual filename, will be used to look up the mime type according to extension if no other methods work to determine the mime type.

''
$defaultMime string

The mime type set in file info when uploading file, will be used if no other methods work to determine the mime type.

''

Return value

Type Description
string|bool The mime type, or false on failure to detect mime type.

Tags

Name Description
since Version 4.1.0

getRemoteDims( int   $image_id, ) : Array

Description

Gets the dimensions of an image for which they're not already saved in the database.
Most likely, such an image was Bulk Uploaded or added by a similar addon that skips processing in the name of speed

Arguments

Name Type Description Default
$image_id int

Return value

Type Description
Array containing width/height/mime of selected image, or boolean false on failure.

getScaledSize( int   $w, int   $h, int   $maxW, int   $maxH, bool   $scaleUp = false, ) : array

Description

Get the scaled width and height of something given the original and max width and height.

Arguments

Name Type Description Default
$w int

Original width.

$h int

Original height

$maxW int

Max amount for width

$maxH int

Max size of height

$scaleUp bool

If true, and the start width and height are both less than the max width / height, it will scale the size up. {@since Version 7.2.0}

false

Return value

Type Description
array An array like this: array (width => #, height => #)

Tags

Name Description
since Version 4.1.0

remove( int   $imageId, ) : bool

Description

Removes an image specified by the image ID in the images table, from the file system and removes the record from the database.

Arguments

Name Type Description Default
$imageId int

Return value

Type Description
bool true if successful, false otherwise

Tags

Name Description
since Version 4.0.9

resize( string   $filename, int   $maxWidth, int   $maxHeight, bool   $alwaysResize = true, ) : array|bool

Description

Resize an image given the max width and height, and send back some info on the created image like the new width and height, and image resource.

Arguments

Name Type Description Default
$filename string
$maxWidth int
$maxHeight int
$alwaysResize bool

If false, and current width and height are less than the given max width and height, will return false.

true

Return value

Type Description
array|bool An array in the form array('image'=>$imageResource, 'width'=>int, 'height'=>int)

setAdConfig(   $ad_config, ) : n/a

Description

Set the configuration that will be used when processing images and generating image tags.

Arguments

Name Type Description Default
$ad_config n/a

Return value

Type Description
n/a n/a

shortenImageTitle( string   $text, int   $maxLength, ) : string

Description

Shortens the image title by a given max length, cutting off the title on a word boundry if possible to prevent broken words.

Arguments

Name Type Description Default
$text string
$maxLength int

Return value

Type Description
string

Tags

Name Description
since Version 4.1.0

Properties

$_extensions, $_instance, $ad_config, $db,

array  private  $_extensions = array()

Used to cache for the page load, the image extensions allowed.


\geoImage  private  static $_instance =

An instance of geoImage


\unknown_type  public  $ad_config =

The configuration. Currently coded to be ADO result set in object form, but will be re-coded to be an array (since $db->GetNextObject()) is known to be slower than working with arrays)


\DataAccess  public  $db =

Instance of the DataAccess object, for easy access by methods in this class.


Constants

  debug_image_delete = false

Set this to true to make it e-mail the admin user any time an image is deleted.


Documentation was generated by phpDocumentor 2.2.0 .

Namespaces

  • global

    Packages

    • Default
      • ExampleAddon
        • addon_example_admin
          In charge of doing stuff on the admin side, this is optional.
        • addon_example_info
          Required class for addons, this is the Addon information class, used by the addon system to determine what the addon can do. Also contains info about the addon that can be viewed in the addon management page in the admin.
        • addon_example_pages
          Addon page class, used by the addon system to display pages on the client side.
        • addon_example_setup
          This class is not required. If it, and the function for a particular routine exist, then that function will be called IN ADDITION TO the automated routines of the addon framework.
        • addon_example_tags
          Expects one function for each tag. Function name should be the same as the tag name. Can also have a constructor if anything needs to be constructed.
        • addon_example_util
          This is where to put functions that the main part of the addon will use.
        • eWidgetOrderItem
          This order item is designed to allow users on your site to purchase an eWidget.
      • System
        • DataAccess
          This is the main Database access object.
        • Singleton
          Singleton method class
        • _templateOrderItem
          Developers: use this file as a template to create a new order item.
        • _templatePaymentGateway
          This is the "developer template" payment gateway handler, a developer could use this file as a starting point for creating a new payment gateway in the system.
        • geoAPI
          The main system class for receiving and handling remote API calls, this acts as a translation layer between the communication with the "outside" and each API call.
        • geoAddon
          This is the class that handles anything and everything to do with addons.
        • geoArrayTools
          Utility functions for manipulating arrays
        • geoBrowse
          Contains functions common to browsing listings
        • geoBrowsingFilter
          System for activating, storing, and deactivating browsing filters.
        • geoCJAX
          Class that wraps the CJAX_FRAMEWORK, used to get the CJAX class.
        • geoCache
          This is the main part of the Geo cache system, it does all the "low level" stuff like writing files and escaping cache data.
        • geoCacheModule
          Part of Geo Cache system, specifically tuned to work best with cacheing module data (which will be an array).
        • geoCachePage
          Cache system specifically tuned to work best with cacheing output of pages and modules
        • geoCacheSetting
          Part of Geo Cache system, specifically tuned to work best with cacheing site-wide key=value type settings.
        • geoCacheText
          Part of Geo Cache system, this part specifically tuned to work best with cacheing language specific messages.
        • geoCalendar
          Holds utility method(s) for manipulating stuff dealing with calendar selector.
        • geoCart
          This class is behind the cart, loading all the order items and such and displaying, and processing all the different pages.
        • geoCategory
          Utility class that holds various methods to do stuff with categories in the system.
        • geoCombineResources
          This class helps to combine CSS and JS files, minify them, and optionally compress them.
        • geoCron
          This is the cron job backend, it handles all the communication and security and all that.
        • geoCrypt
          Class to use for encrypting information that needs to be able to be retrieved later.
        • geoDate
          Holds utility method(s) for manipulating stuff dealing with dates.
        • geoEmail
          Class that sends out e-mails.
        • geoFields
          Class that holds settings information for fields to use.
        • geoFieldsField
          A mini object to hold data about a specific field.
        • geoFile
          As the name implies, this is used for file-based utility methods.
        • geoFilter
          A few utility methods, good for filtering stuff.
        • geoFormatString
          Used to display a message nice and pretty, we'll probably be getting rid of this class though so don't go crazy using it.
        • geoHTML
          Class to generate chunks of HTML that are very common, used the most in the admin panel.
        • geoImage
          This class is responsible for a lot of the image processing, along with other aspects like generating the image tag for thumbnails.
        • geoInvoice
          This is the invoice object representing an invoice in the system.
        • geoLeveledField
          Class for doing common things with leveled fields.
        • geoListing
          A listing object, basically a container object for particular listing.
        • geoListingDisplay
          This is basically a container that is responsible for helping to display {listing .
        • geoListingFeed
          Class that helps to render RSS or other types of feeds based on list of listings.
        • geoMaster
          This is dedicated class for getting the value of, and setting, the various "master switches" within the software. Since this is meant as an easy way to get the values of master switches, most of the methods are static.
        • geoNumber
          Utility functions relating to number conversion/manipulation/validation ect.
        • geoOrder
          The geoOrder object, an object representation of an order in the system.
        • geoOrderItem
          The class that all order items must extend.
        • geoPC
          Used for login credential validation, password hashing, etc. along with software licensing.
        • geoPagination
          Utility functions useful for generating pagination of a results page such as when browing ads or searching
        • geoPaymentGateway
          This class should be extended by each different payment gateway, this will have some default functions that each gateway will inherit, and also has a few final static methods used by the system to affect all order items.
        • geoPlanItem
          A container to hold settings for a particular order item type, according to price plan ID, and optionally category ID for category specific settings.
        • geoRecurringBilling
          The geoRecurringBilling object, an object representation of a recurring billing in the system.
        • geoRegion
          Stuff for regions and sub-regions.
        • geoRegistry
          Handy little object, can be used to set registry type settings.
        • geoSearchUtils
          Class for search utilities.
        • geoSellerBuyer
          Handles back-end for the seller/buyer payment gateways, to allow the buyer to more easily pay the seller for a won auction. This handles the underlying system, but the actual work is done by individual seller/buyer gateways, for instance the Paypal buy-now functionality.
        • geoSession
          Manages session storage and session cookies for user sessions.
        • geoString
          Utility functions relating to languages and string manipulation.
        • geoStringData
          This class is to store accented chars, to be used by {@link geoString::removeAccents()}, mainly to keep the String.class.php file un-cluttered.
        • geoTable
          NOT FULLY IMPLEMENTED! Do not use this class yet as it is not finished and may change drastically before we are done with it, or may even be removed.
        • geoTableRow
          NOT FULLY IMPLEMENTED! Do not use this class yet as it is not finished and may change drastically before we are done with it, or may even be removed.
        • geoTableRowset
          NOT FULLY IMPLEMENTED! Do not use this class yet as it is not finished and may change drastically before we are done with it, or may even be removed.
        • geoTableSelect
          Class used to generate a select query, useful when multiple areas want to affect a single query, for instance when generating a search query and there are addons involved.
        • geoTables
          Used to hold database table names, used throughout the code.
        • geoTemplate
          Template object that extends the Smarty class (a 3rd party library) to enable using templates to display things.
        • geoTransaction
          This is the object used for a transaction in the order and invoice system.
        • geoUser
          An object representative of a certain user in the system.
        • geoUserRating
          Store, retrieve, and display inter-user ratings
        • geoUtil
          Misc utility functions
        • geoView
          As the name implies, this is used for creating the page view. It does take a little setup (like any class), the setup is normally done in the display_page method in geoSite, or display_page in geoAdmin if displaying a page in the admin.
        • iApiTransport
          Interface for API Transports, a transport must implement this interface for the system to use it.
        • iOrderItem
          You cannot have abstract static functions, so instead need to have an interface to force the given static functions to be defined.
        • metaDbTables
          Used so that old locations that use the old name geoTables will still work.