SmartyTheme.php

Summary
SmartyTheme.php
SmartyThemeClass abstraction of a Smarty theme
SmartyThemeSuperclass representing a Smarty-based theme
__constructBootstrap the Smarty instance for this theme
instantiateTemplates()Populate the Templates array of this theme with the system short_aliases
mapTemplatesDirSet the directory the theme’s Smarty instance is pulling templates from.
mapCompileDirSet the directory the theme’s Smarty instance is ompiling templates to.
mapTemplateSave the URL for a given short_alias for a template, in our internal Templates array.
retrieveTemplateRetrieve the template URL for the given short alias.
displayTemplate($short_alias)Have Smarty display the template with the given short_alias.
assignVariable($var, $value)Interface to the internal Smarty instance to assign variables used in templates.

SmartyTheme

Class abstraction of a Smarty theme

postActiv

the micro-blogging software

Copyright

Copyright © 2016-2017, Maiyannah Bishop

Derived from code copyright various sources

  • GNU Social © 2013-2016, Free Software Foundation, Inc
  • StatusNet © 2008-2012, StatusNet, Inc

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program.  If not, see http://www.gnu.org/licenses/.

https://www.gnu.org/licenses/agpl.html

About

Class abstraction of a Smarty theme

Copyright on this file belongs explicitly to Maiyannah Bishop.

PHP version

Tested with PHP 7

File Authors

Web

SmartyTheme

Superclass representing a Smarty-based theme

For now, since I’m doing this as a proof of concept back port I’m mostly concerned with seeing that this actually works.  As such a lot is missing and a lot is hardcoded

Properties

  • $name - Name of template we’re using
  • $templates - Array to hold template locations
  • $stylesheets - Array to hold stylesheets
  • $scripts - Array to hold scripts
Summary
__constructBootstrap the Smarty instance for this theme
instantiateTemplates()Populate the Templates array of this theme with the system short_aliases
mapTemplatesDirSet the directory the theme’s Smarty instance is pulling templates from.
mapCompileDirSet the directory the theme’s Smarty instance is ompiling templates to.
mapTemplateSave the URL for a given short_alias for a template, in our internal Templates array.
retrieveTemplateRetrieve the template URL for the given short alias.
displayTemplate($short_alias)Have Smarty display the template with the given short_alias.
assignVariable($var, $value)Interface to the internal Smarty instance to assign variables used in templates.

__construct

public function __construct($name)

Bootstrap the Smarty instance for this theme

instantiateTemplates()

private function instantiateTemplates()

Populate the Templates array of this theme with the system short_aliases

mapTemplatesDir

public function mapTemplatesDir($url)

Set the directory the theme’s Smarty instance is pulling templates from.

Parameters

  • url - URL of the Smarty templates directory

mapCompileDir

public function mapCompileDir($url)

Set the directory the theme’s Smarty instance is ompiling templates to.

Parameters

  • url - URL of the Smarty template compile directory.

mapTemplate

public function mapTemplate($short_alias,
$url)

Save the URL for a given short_alias for a template, in our internal Templates array.

Parameters

  • short_alias - alias of the template we are mapping
  • url - url we are mapping the template to

Returns

  • boolean true/false for success

retrieveTemplate

public function retrieveTemplate($short_alias)

Retrieve the template URL for the given short alias.

If you just want to do this to display a template, then use displayTemplate instead!

Parameters

  • short_alias - alias of the template we’re looking up

Returns

  • the URL on success, FALSE on failure.

displayTemplate($short_alias)

public function displayTemplate($short_alias)

Have Smarty display the template with the given short_alias.  Make sure you assign the appropriate template variables first!  You can use assignVariable($var, $value) for this.

Parameters

  • short_alias - alias of the template we are rendering

Returns

  • TRUE if successful, FALSE if not.

assignVariable($var, $value)

public function assignVariable($var,
$value)

Interface to the internal Smarty instance to assign variables used in templates.

Returns

  • TRUE if successful, FALSE if not.
public function __construct($name)
Bootstrap the Smarty instance for this theme
private function instantiateTemplates()
Populate the Templates array of this theme with the system short_aliases
public function mapTemplatesDir($url)
Set the directory the theme’s Smarty instance is pulling templates from.
public function mapCompileDir($url)
Set the directory the theme’s Smarty instance is ompiling templates to.
public function mapTemplate($short_alias,
$url)
Save the URL for a given short_alias for a template, in our internal Templates array.
public function retrieveTemplate($short_alias)
Retrieve the template URL for the given short alias.
public function displayTemplate($short_alias)
Have Smarty display the template with the given short_alias.
public function assignVariable($var,
$value)
Interface to the internal Smarty instance to assign variables used in templates.