Skip to content

icms_view_theme_Object

Raimondas Rimkevičius edited this page Mar 9, 2020 · 1 revision
Notice: Wiki was automatic generated from project sources as project API documentation. Do not edit manually!

icms_view_theme_Object

Builds the theme components

  • Class name: icms_view_theme_Object
  • Namespace:

Properties

$folderName

public mixed $folderName

The name of this theme

  • Visibility: public

$path

public mixed $path

Physical path of this theme folder

  • Visibility: public

$url

public mixed $url
  • Visibility: public

$bufferOutput

public mixed $bufferOutput = \true

Whether or not the theme engine should include the output generated by php

  • Visibility: public

$canvasTemplate

public mixed $canvasTemplate = theme.html

Canvas-level template to use

  • Visibility: public

$contentTemplate

public mixed $contentTemplate

Content-level template to use

  • Visibility: public

$contentCacheLifetime

public mixed $contentCacheLifetime
  • Visibility: public

$contentCacheId

public mixed $contentCacheId = \null
  • Visibility: public

$content

public mixed $content

Text content to display right after the contentTemplate output

  • Visibility: public

$plugins

public mixed $plugins = array(icms_view_PageBuilder)

Page construction plug-ins to use

  • Visibility: public

$renderCount

public mixed $renderCount
  • Visibility: public

$template

public \icms_view_Tpl $template = \false

Pointer to the theme template engine

  • Visibility: public

$metas

public mixed $metas = array(head => array(), module => array(), foot => array())

Array containing the document meta-information

  • Visibility: public

$types

public mixed $types = array(http, meta, link, stylesheet, script)

Array of meta types - their order in the array determines their rendering sequence

  • Visibility: public

$htmlHeadStrings

public mixed $htmlHeadStrings = array()

Array of strings to be inserted in the head tag of HTML documents

  • Visibility: public

$templateVars

public mixed $templateVars = array()

Custom publiciables that will always be assigned to the template

  • Visibility: public

$use_extra_cache_id

public mixed $use_extra_cache_id = \true

User extra information for cache id, like language, user groups

  • Visibility: public

Methods

xoInit

bool icms_view_theme_Object::xoInit(array options)

Initializes this theme

Upon initialization, the theme creates its template engine and instanciates the plug-ins from the specified $plugins list. If the theme is a 2.0 theme, that does not display redirection messages, the HTTP redirections system is disabled to ensure users will see the redirection screen.

  • Visibility: public

Arguments

  • options array

generateCacheId

string icms_view_theme_Object::generateCacheId(string cache_id, string extraString)

Generate cache id based on extra information of language and user groups

User groups other than anonymous should be detected to avoid disclosing group sensitive contents

  • Visibility: public

Arguments

  • cache_id string - <p>raw cache id</p>
  • extraString string - <p>extra string</p>

checkCache

bool icms_view_theme_Object::checkCache()

Checks cache for a changed version of the template and renders template

  • Visibility: public

render

mixed icms_view_theme_Object::render(string canvasTpl, string pageTpl, string contentTpl, array vars)

Render the page

The theme engine builds pages from 2 templates: canvas and content.

A module can call this method directly and specify what templates the theme engine must use. If render() hasn't been called before, the theme defaults will be used for the canvas and page template (and xoopsOption['template_main'] for the content).

  • Visibility: public

Arguments

  • canvasTpl string - <p>The canvas template, if different from the theme default</p>
  • pageTpl string - <p>The page template, if different from the theme default (unsupported, 2.3+ only)</p>
  • contentTpl string - <p>The content template</p>
  • vars array - <p>Template variables to send to the template engine</p>

addScript

void icms_view_theme_Object::addScript(string src, array attributes, string content, \str zone, int weight)

Adds script code to the document head

This methods allows the insertion of an external script file (if $src is provided), or of a script snippet. The file URI is parsed to take benefit of the theme resource overloading system.

The $attributes parameter allows you to specify the attributes that will be added to the inserted <script> tag. If unspecified, the type attribute value will default to 'text/javascript'.

// Add an external script using a physical path $theme->addScript('www/script.js', NULL, ''); $theme->addScript('modules/newbb/script.js', NULL, ''); // Specify attributes for the <script> tag $theme->addScript('mod_xoops_SiteManager#common.js', array('type' => 'application/x-javascript'), ''); // Insert a code snippet $theme->addScript(NULL, array('type' => 'application/x-javascript'), 'window.open("Hello world");');
  • Visibility: public

Arguments

  • src string - <p>path to an external script file</p>
  • attributes array - <p>hash of attributes to add to the <script> tag</p>
  • content string - <p>Code snippet to output within the <script> tag</p>
  • zone str - <p>Area of the HTML page to place the script</p>
  • weight int - <p>Sort factor - lower weights are loaded first</p>

addStylesheet

void icms_view_theme_Object::addStylesheet(string src, array attributes, string content, \str zone, int weight)

Add StyleSheet or CSS code to the document head

  • Visibility: public

Arguments

  • src string - <p>path to .css file</p>
  • attributes array - <p>name => value paired array of attributes such as title</p>
  • content string - <p>CSS code to output between the <style> tags (in case $src is empty)</p>
  • zone str - <p>Area of the HTML page to place the stylesheet</p>
  • weight int - <p>Sort factor - lower weights are loaded first</p>

addLink

mixed icms_view_theme_Object::addLink(string rel, string href, array attributes, \str zone, int weight)

Add a to the header

  • Visibility: public

Arguments

  • rel string - <p>Relationship from the current doc to the anchored one</p>
  • href string - <p>URI of the anchored document</p>
  • attributes array - <p>Additional attributes to add to the <link> element</p>
  • zone str - <p>Area of the HTML page to place the link</p>
  • weight int - <p>Sort factor - lower weights are loaded first</p>

addHttpMeta

mixed icms_view_theme_Object::addHttpMeta(mixed name, mixed value, \str zone, int weight)

Set a meta http-equiv value

  • Visibility: public

Arguments

  • name mixed
  • value mixed
  • zone str - <p>Area of the HTML page to place the http meta</p>
  • weight int - <p>Sort factor - lower weights are loaded first</p>

addMeta

mixed icms_view_theme_Object::addMeta(\str type, \str name, \str value, \str zone, int weight)

Change output page meta-information

  • Visibility: public

Arguments

  • type str - <p>Type of meta tag: script, link, stylesheet, http</p>
  • name str - <p>Name</p>
  • value str
  • zone str - <p>Area of the HTML page to place the meta</p>
  • weight int - <p>Sort factor - lower weights are loaded first</p>

headContent

mixed icms_view_theme_Object::headContent(string params, string content, mixed smarty, mixed repeat)

Puts $content into the htmlheadstrings array

  • Visibility: public

Arguments

  • params string
  • content string - <p>content to put in the htmlheadstrings array</p>
  • smarty mixed
  • repeat mixed

renderMetas

bool icms_view_theme_Object::renderMetas(string type, string return, mixed zone)

Render the meta content in the metas array (carefull Recursive!)

  • Visibility: public

Arguments

  • type string - <p>what type of metacontent is it</p>
  • return string - <p>will we return to the calling function (just default setting)</p>
  • zone mixed

renderOldMetas

\str icms_view_theme_Object::renderOldMetas(\str type, bool return)

Legacy method to render all the zones as a single zone

  • Visibility: public

Arguments

  • type str
  • return bool

genElementId

string icms_view_theme_Object::genElementId(string tagName)

Generates a unique element ID

  • Visibility: public

Arguments

  • tagName string

renderAttributes

string icms_view_theme_Object::renderAttributes(array coll)

Transform an attributes collection to an XML string

  • Visibility: public

Arguments

  • coll array

resourcePath

string icms_view_theme_Object::resourcePath(string path)

Return a themable file resource path

  • Visibility: public

Arguments

  • path string
Clone this wiki locally