classes/php5_classes/Template.class.php

Properties

Description

Holds the geoTemplate class.

Classes

geoTemplate

Properties

 
 
System  
No 
No 

Description

Template object that extends the Smarty class (a 3rd party library) to enable using templates to display things.

Methods

__construct, addPoweredBy, addTemplateSet, cleanFilename, cleanTemplateSetName, gResource, gType, getAddonHtml, getBaseUrl, getFilePath, getInvalidSetNames, getLoggedTemplates, getTemplateSets, getTemplateSetsLanguages, getTemplateSetsMeta, getUrl, loadInternalTemplate, loadTemplateResourceHandler, loadTemplateSets, logTemplateUsed, parseExternalTags, setAddon, setAdmin, setCategory, setLanguage, setMainPage, setModule, setPage, setSystem, template404, whichTemplateSet,

__construct( string   $template_type = null, string   $resource = null, ) : n/a

Description

Creates a new template object, and assigns values for things that the majority of templates can use, like text messages assigned to smarty variable messages. It also registers the following modifiers: fromDb: filters text that is coming from the database displayPrice: converts a number be formatted according to pre and post currency settings format_date: takes unix timestamp, and the specified format, and does date on it.

Arguments

Name Type Description Default
$template_type string

If specified, one of: ("module","system","addon","admin")

null
$resource string

Only used if template_type is specified and valid, and is not "admin". It is The resource that this template is used from, for example if using this template inside classes/browse_ads.php the resource would be "browse_ads".

null

Return value

Type Description
n/a n/a

addPoweredBy(   $tpl_source,   $smarty, ) : string

Description

For internal use only, used to add "Powered By" text to trial installations.

Arguments

Name Type Description Default
$tpl_source n/a
$smarty n/a

Return value

Type Description
string

Tags

Name Description
access private

addTemplateSet( string   $name, int   $language_id = 0, string   $device = self::DEVICE_ANY, ) : n/a

Description

Adds a template set to the template sets that it will retrieve templates from.

Arguments

Name Type Description Default
$name string

The same as the folder name, only alpha-numeric plus -_ and . (so no spaces)

$language_id int

If specified, the template set will only be used if the current user is using the specified language ID. (param added in version 6.0.0)

0
$device string

What device to load the template set on, default is all devices. Can set to any of the geoSession::DEVICE_* constants, for instance geoSession::DEVICE_MOBILE to only use for mobile devices. Parameter added {@since Version 7.3.0}

self::DEVICE_ANY

Return value

Type Description
n/a n/a

cleanFilename( string   $filename, ) : string

Description

Mostly used internally, to strip off [tset] part off of a filename like [tset]filename.tpl

Arguments

Name Type Description Default
$filename string

Return value

Type Description
string

cleanTemplateSetName( string   $name, ) : string

Description

Cleans the template set name given and makes sure it is "valid", if not valid it returns an empty string. If it starts with _ or . or is in the list of invalid names, the name is considered invalid.

Arguments

Name Type Description Default
$name string

Return value

Type Description
string Returns empty string if string given is "ivalid".

gResource( string|null   $set_value = null, ) : string

Description

Used internally, to both get and set the template resource at the compiled template level. If nothing passed in, it gets the current value, if something is passed in, it sets the value to that and then returns it.

Arguments

Name Type Description Default
$set_value string|null

If set, g_resource will be set to this value and returned as the return value.

null

Return value

Type Description
string

Tags

Name Description
since Version 6.0.0

gType( string|null   $set_value = null, ) : string

Description

Used internally, to both get and set the template type at the compiled template level. If nothing passed in, it gets the current value, if something is passed in, it sets the value to that and then returns it.

Arguments

Name Type Description Default
$set_value string|null

If set and valid, it will set the g_type and return that type. If invalid it will be ignored.

null

Return value

Type Description
string

Tags

Name Description
since Version 6.0.0

getAddonHtml( array   $params, \geoTemplate   $smarty, ) : string

Description

Used by "custom" smart tag {addon .
..} to display something for an addon tag.

Arguments

Name Type Description Default
$params array
$smarty \geoTemplate

Return value

Type Description
string

getBaseUrl( ) : string

Description

Convenience method, to get the base URL based on settings set in the admin. If currently using SSL connection, it uses SSL URL from admin settings.

Return value

Type Description
string

getFilePath( string   $g_type, string   $g_resource, string   $template_filename = 'index', bool   $dieOnError = true, bool   $falseOnError = false, ) : string

Description

Gets the absolute path to the template file based on the template type, the resource, and the template filename.
It will go through each of the template sets until it finds the file, if it doesn't find it in one template set, it looks at the next template set in the list, ending with the default template set. If the template type is addon, and it hasn't found the template in any of the template sets under template_set/addon/addon_name/template_filename it then looks in addons/addon_name/templates/template_name

Arguments

Name Type Description Default
$g_type string

The type of template, either system, addon, admin, or module

$g_resource string

Typically the file name that the template is used in

$template_filename string

The filename, if none specified it assumes index.tpl. Note that the template_filename can include directories, but must be relative to the resources directory. If set to index, and it finds the file with the resource name.tpl it will use that.

'index'
$dieOnError bool

If false, will NOT die if the file path is not found, instead it would continue and just return the path location that is attempting to be found.

true
$falseOnError bool

If true and dieOnError is false, will return false if file not found.

false

Return value

Type Description
string The absolute path to the template file, or the original tempalte_filename specified if the absolute path could not be found.

getInvalidSetNames( ) : array

Description

Gets a list of template set names that are "reserved names" which will be ignored by the template system.

Return value

Type Description
array

Tags

Name Description
since Version 5.0.0

getLoggedTemplates( ) : array

Description

Gets an array of what templates have been logged (used) so far.

Return value

Type Description
array

getTemplateSets( ) : array

Description

Gets the array of template sets in the order they are used

Return value

Type Description
array

getTemplateSetsLanguages( ) : array

Description

Gets an array of template sets for the keys and the language ID to use for the values. Will not include any template sets that are not set to a specific language.

Return value

Type Description
array

Tags

Name Description
since Version 6.0.0
deprecated in Version 7.3.0, use geoTemplate::getTemplateSetsMeta() instead.

getTemplateSetsMeta( ) : array

Description

Get all of the template sets and the meta information for each one, which is the language_id and the device the template set is loaded with.

Return value

Type Description
array

Tags

Name Description
since Version 7.3.0

getUrl( string   $g_resource = '', string   $filename = '', bool   $emptyOnFailure = false, bool   $forceDefault = false, ) : string

Description

Gets the URL for "external" template files, meaning things like css or js files that are located in the template set.

Arguments

Name Type Description Default
$g_resource string

Typically the file name that the template is used in

''
$filename string

The filename, if none specified it returns the url to the base of the templates directory, where all the template sets are located

''
$emptyOnFailure bool

If true, and not able to find specified file, will return empty string rather than relative path without tset.

false
$forceDefault bool

If true, will only use the url from the default template set (mainly used in admin panel), it will also skip checks to make sure file exists first. This param added in version 6.0.0

false

Return value

Type Description
string The URL for where the file exists inside TEMPLATE_SET/external/resource/filename or just resource/filename if file could not be found.

loadInternalTemplate( array   $params, \Smarty_Internal_Template   $smarty, string   $file, string   $g_type = null, string   $g_resource = null, array   $tpl_vars = array(), string   $pre = '', string   $post = '', ) : string

Description

Function to make it easy for things loaded through smarty functions, to use sub-template, and allow that sub-template to to work easy.

Arguments

Name Type Description Default
$params array
$smarty \Smarty_Internal_Template
$file string
$g_type string null
$g_resource string null
$tpl_vars array array()
$pre string

Stug on beginning

''
$post string

Stuck on the end

''

Return value

Type Description
string The value to return as a custom smarty function.

Tags

Name Description
since Geo version 7.1.0

loadTemplateResourceHandler( \unknown   $resource_type, ) : \unknown

Description

Loads the template resource handler

Arguments

Name Type Description Default
$resource_type \unknown

Return value

Type Description
\unknown

loadTemplateSets( bool   $force_reload = false, ) : n/a

Description

Loads the template sets to use by including the file GEO_TEMPLATE_DIR/t_sets.php
That file should be generated by the admin template control panel

Arguments

Name Type Description Default
$force_reload bool

If true, will force it to re-load the template sets even if it was already run in this page load.

false

Return value

Type Description
n/a n/a

logTemplateUsed( string   $t_set, string   $type, string   $file, ) : n/a

Description

Log a template that is used on the current page load. Normally used internally only.

Arguments

Name Type Description Default
$t_set string
$type string

Either main_page, external, system, module, or addon

$file string

The template file, including g_resource. So, relative to that template set and template type's folder.

Return value

Type Description
n/a n/a

parseExternalTags( string   $text, ) : string

Description

Parses the text for any {external file='url'} type tags, and replaces them with the URL, then returns the parsed text. This is good for allowing the use of {external .
..} tags inside of text.

Arguments

Name Type Description Default
$text string

Return value

Type Description
string

Tags

Name Description
since Version 5.0.0

setAddon( string   $addon_name, ) : \geoTemplate|bool

Description

This template is for the specified addon, and is located in one of 2 places: - GEO_TEMPLATE_DIR/template_set_name/addon/addon_name/ directory (searched first, to allow designers to include templates that override an addon's defaults) - addons/addon_name/templates/ directory
Note that for optimization reasons, it does not verify that the specified addon exists and is enabled, since typically only the addon itself will be using templates for the addon.

Arguments

Name Type Description Default
$addon_name string

The addon name, same as the addon's folder name and as set in the addon's info class.

Return value

Type Description
\geoTemplate|bool Returns itself if successful (to allow chaining), false if addon name is not valid

setAdmin( ) : \geoTemplate

Description

Specifies that the current template is an admin template. The admin templates are a much simplified version of the front side, in that there is no "resource" to specify, and there is no template sets, all templates are in the admin/templates/ directory, and when calling fetch() the filename should be relative to that dir.

Return value

Type Description
\geoTemplate Returns an instance of itself to allow chaining

setCategory( int   $category_id, ) : n/a

Description

Used to set category ID if displaying something specific for a category.

Arguments

Name Type Description Default
$category_id int

Return value

Type Description
n/a n/a

setLanguage( int   $lang_id, ) : n/a

Description

Used to set the language ID (going to a Geo language ID) for templates.

Arguments

Name Type Description Default
$lang_id int

Return value

Type Description
n/a n/a

setMainPage( int|string   $page_id, ) : \geoTemplate

Description

Set the page ID used for displaying a template in the main_page.

Arguments

Name Type Description Default
$page_id int|string

Return value

Type Description
\geoTemplate Returns itself for easy chaining.

setModule( string   $module_filename, ) : \geoTemplate|bool

Description

This template is for the specified module, and will be located under the module/module_name/ directory.

Arguments

Name Type Description Default
$module_filename string

The filename of the module (usually without the module_ before it)

Return value

Type Description
\geoTemplate|bool Returns itself if successful, false otherwise.

setPage( int|string   $page_id, ) : n/a

Description

Not used yet. Or is it?

Arguments

Name Type Description Default
$page_id int|string

Return value

Type Description
n/a n/a

setSystem( string   $system_filename, ) : boolean

Description

This is a system template, used somewhere like browse_ads or the cart or somewhere.

Arguments

Name Type Description Default
$system_filename string

The system file's filename, without the .class and all lowercase. If the file resides in a sub-directory of the classes folder (for instance, one of the payment gateways or order items), use the folder name instead (example: "order_item")

Return value

Type Description
boolean True if successful, false otherwise.

template404( string   $tplFile, string   $longMsg = '', ) : n/a

Description

Displays an error and stops the rest of the page from loading. Used when a template file cannot be found in any template sets.

Arguments

Name Type Description Default
$tplFile string

The file that could not be found

$longMsg string

Optional additional info, if supplied it will be displayed to the user.

''

Return value

Type Description
n/a n/a

Tags

Name Description
since Version 5.0.0

whichTemplateSet( string   $g_type, string   $g_resource, string   $template_filename = 'index', ) : string

Description

Gets which template set the the template file is in based on the template type, the resource, and the template filename.
It will go through each of the template sets until it finds the file, if it doesn't find it in one template set, it looks at the next template set in the list, ending with the default template set. If the file can not be found in any template sets, returns empty string.

Arguments

Name Type Description Default
$g_type string

The type of template, either self::SYSTEM, self::ADDON, self::MODULE, self::MAIN_PAGE, or self::EXTERNAL

$g_resource string

Typically the file name that the template is used in

$template_filename string

The filename, if none specified it assumes index.tpl. Note that the template_filename can include directories, but must be relative to the resource's directory. If set to index, and it finds the file with the resource name.tpl it will use that.

'index'

Return value

Type Description
string The name for the template set where the template was found, or empty string if not found.

Properties

$_filePaths, $_fileSets, $_g_category, $_g_language, $_g_page, $_g_resource, $_g_template_sets, $_g_template_type, $_invalidTSetNames,

array  protected  static $_filePaths =

Run-time cache used so we don't have to scan for a certain template more than once in a page load.


array  protected  static $_fileSets =

Run-time cache used so we don't have to scan for a certain template more than once in a page load.


int  protected  static $_g_category =

The current category id.


int  protected  static $_g_language =

The current language ID.


int  protected  static $_g_page =

The page currently being loaded. Mostly used when the template type is "main_page"


string  protected  $_g_resource =

This should be "where" the template is used from. For example, if using a template in the file classes/Cart.class.php the resource might be "cart".


array  protected  static $_g_template_sets = array('default' => 'default')

An array of "template sets" that will be searched through when looking for a template. The array is sorted by key prior to doing template searching, so a key of "default" will always be last when the rest of the keys are numeric.


string  protected  $_g_template_type =

What this is set to determines the search behavior and where the template file is located.

One of: self::ADMIN, self::MODULE, self::SYSTEM, self::ADDON, self::MAIN_PAGE, or self::EXTERNAL




array  private  static $_invalidTSetNames = array('all', 'active', 'merged', '_temp')

Array of reserved names, any template sets using these names will be ignored


Constants

  ADDON = 'addon'

G-Type: Addon


  ADMIN = 'admin'

G-Type: Admin


  DEVICE_ANY = 'any'

Used to specify a template set that is loaded for all devices.


  EXTERNAL = 'external'

G-Type: External


  MAIN_PAGE = 'main_page'

G-Type: Main_page


  MODULE = 'module'

G-Type: Module


  SYSTEM = 'system'

G-Type: System


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.