\LivePubHelper
Helper class to facilitate dynamic content inside staticpublisher produced php files.
- Author: Mark Guinn <mark@adaircreative.com>
Synopsis
class LivePubHelper
extends Object
{
- // members
- protected static boolean $is_publishing = false;
- protected static boolean $silverstripe_db_included = false;
- public static $vars $vars = ;
- public static $init_code $init_code = ;
- public static $base_init_code $base_init_code = '<?php $isAjax = (isset($_REQUEST["ajax"]) || (isset($_SERVER["HTTP_X_REQUESTED_WITH"]) && $_SERVER["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest")); ?>';
- public static $context $context = 'html';
- protected static $template_path $template_path = ;
- // methods
- public static void init_pub()
- public static void stop_pub()
- public static void clear_init_code()
- public static void get_init_code()
- public static void add_init_code()
- public static string get_init_code_and_clear()
- public static boolean is_publishing()
- public static string eval_php()
- public static none exec_php()
- public static string include_php()
- protected static void init_template_paths()
- public static void set_template_paths()
- public static void add_template_path()
- public static ViewableWrapper wrap()
- public static DataObjectSet wrap_set()
- public static void require_silverstripe_db()
- public static void require_session()
Hierarchy
Extends
- Object
Members
protected
- $is_publishing
- $silverstripe_db_included
- $template_path — $template_path
public
- $base_init_code — $base_init_code
- $context — $context
- $init_code — $init_code
- $vars — $vars
Methods
protected
- init_template_paths() — Sets up the default template paths
public
- add_init_code()
- add_template_path() — Path should be relative to BASE_PATH
- clear_init_code() — resets the init code to the base config file
- eval_php() — evaluates the given php code unless we're currently publishing, in which case it returns php code that will echo the return value of the eval'd code.
- exec_php() — evaluates the given php code unless we're currently publishing, in which case it adds the php code to the initialization code.
- get_init_code() — Outputs the static config code if needed. This should be placed in a function in Page_Controller and called from template.
- get_init_code_and_clear()
- include_php() — loads a php template from the templates/php folder (allowing for themes) returns either the result of executing the code, or the code itself, depending on whether we're staticpublishing or not
- init_pub() — this is only to be called when static publishing is starting
- is_publishing() — returns true if we are currently publishing
- require_session() — Ensures that the session will be available on the published page.
- require_silverstripe_db() — if this is called, the published version of the page will include and initialize the DB::query stub and connect to the main silverstripe database.
- set_template_paths()
- stop_pub() — called when publishing is done
- wrap() — factory method to create a new wrapper object. if we're static publishing and an appropriate helper class is available it will use that instead. A helper class shouldn't be needed very often but would be used if you wanted a totally different class for publishing vs normal mode
- wrap_set() — Takes an array of objects or arrays and creates a dataobjectset, calling {@link LivePubHelper::wrap} on each item in the array.