SproutCMS

This is the code documentation for the SproutCMS project

namespace Sprout\Helpers

Namespaces

Classes

Admin

Useful functions for the admin

AdminAuth

Provides user authentication functions for the admin

AdminDashboard

Dashboard shown when a user first logs in to the admin

AdminError

Handles errors in the admin.
These should be returned in the _getAddForm(), _getEditForm() and _getDeleteForm() functions.

AdminPerms

Provides user permisison functions for the admin

AdminSeo

Provide Search Engine Optimisation functionality

Archive

Class for creating archives in various formats - zip, tar.bz2, etc

AttrEditor

Specialised input field for page attributes

AttrEditorFilename

Specialised file selector input field for page attributes

AttrEditorImage

Specialised image selector input field for page attributes

AttrEditorMultiline

Specialised multiline text input field for page attributes

AttrEditorTextbox

Specialised text input field for page attributes

Auth

Provides user authentication functions for the admin

Cache

Provides a driver-based interface for finding, creating, and deleting cached
resources. Caches are identified by a unique string. Tagging of caches is
also supported, and caches can be found and deleted by id or tag.

Calendar

Renders a calendar

Captcha

Means to generate and process CAPTCHAs of various implementations

ColModifier

Base class for modifying values for main_columns of an ItemList,
e.g. in ManagedAdminController::_getContents

ColModifierActionLogData

Tries to extract a name from an action log entry to display with an ID

ColModifierDate

Converts a MySQL date into something friendlier. Works for DATE, TIME, DATETIME AND [BIG]INT.

The default output format is d/m/Y, but can be changed in the constructor.
Format strings are anything supported by the PHP function date().

ColModifierHexIP

Converts a hex-packed IP back into readable form

Packing:
  bin2hex(inet_pton($ip))

Unpacking:
  Use this ColModifier

ColModifierLnk

Formats a Lnk field into something appealing

ColModifierLookupArray

Returns data straight from an array (e.g. constants)

ColModifierLookupTable

Returns data from a database table.

This is basically than ColModifierLookupArray(Pdb::lookup),
but it doesn't call the Pdb::lookup until right before it's needed,
so if the itemlist doesn't get used, we aren't wasting a db call.

ColModifierSize

Converts byte value into human readable sizes

ColModifierSubRecordCount

Counts records in a subtable.

E.g. count the records in a gallery_images table associated with records in a galleries table
The database query isn't done until the first record lookup

ColModifierTruncate

Truncate the word count of a column with given word limit trailed by ellipsis symbol, with the full text in a title attribute

Constants

A bunch of different constants

ContentReplace

No description yet.

Cookie

Eases reading and writing cookies.

Cors

Cross Origin Resource Sharing.

TODO conditional safe headers: content-type, accept, accept-language, content-language
TODO conditional safe is unsafe: >128 characters
TODO restricting origins
TODO support for max-age, caching 'options' requests

CountryConstants

Generated class containing ISO-3166 country mappings for alpha-2 and alpha-3

Cron

Methods for initialising, recording the progress of, and finalising and cron scripts

CropImageTransform

Does image resizing, etc

Csrf

Protection against Cross Site Request Forgery (CSRF) attacks

DatabaseSync

Provides a system for syncing a database to a database definition.

The database definition is stored in one or more XML files, which get merged
together before the sync is done.
Contains code that may be MySQL specific.

Database_Expression

Database expression class to allow for explicit joins and where expressions.

Debug

Useful methods for debugging

DefaultCaptcha

Default Sprout CAPTCHA; doesn't need to talk to external servers

Email

Sends emails using HTML content generated by a View, wrapped in a standard template

EmbedVideo

No description yet.

Enc

Encoding of data for various outputs

Encrypt

The Encrypt library provides two-way encryption of text and binary strings
using the MCrypt extension (http://php.net/mcrypt)

Event_Observer

Kohana event observer. Uses the SPL observer pattern.

Event_Subject

Kohana event subject. Uses the SPL observer pattern.

Fb

Quick and easy form builder

File

Methods for working with files, including images

FileConstants

A bunch of different constants

FileConvert

Converter between various file types

For all features to work, the following programs need to be installed:
- convert (e.g. from the graphicsmagick-imagemagick-compat Debian package)
- exiftool (e.g. from the libimage-exiftool-perl Debian package)
- libreoffice (e.g. from the libreoffice-common Debian package)

FileIndexing

Does indexing for various file formats

FilesBackend

Abstract class for a backend storage for the database-managed files

FilesBackendDirectory

Backend for the files module which stores files in a local directory

FileUpload

Used for managing backend processing of fields which have had data submitted via chunked file uploads,
i.e. where chunked upload data has been stitched together by FileUploadController

Form

Helper functions for outputting form elements.

Wraps form fields (e.g. from Fb) with additional HTML.

Most wrapping will done using the __callStatic method which actually just calls Form::fieldAuto.
That method uses reflection to look for a custom docblock tag, @wrap-in-fieldset.
If that docblock tag is found, the field is wrapped in Form::fieldFieldset
If that docblock tag is not found (the most common case), the field is wrapped in Form::fieldPlain

If the field being wrapped isn't in the Fb helper, the methods fieldAuto, fieldPlain, and fieldFieldset
can be invoked directly.

The outermost wrapper DIV around the field has a class of "field-element".
Additional classes are also added:
 - The method and class name, in the format 'field-element--id-<name>'
 - If an "id" attribute is set, in the format 'field-element--id-<id>'
 - If the field is required, 'field-element--required'
 - If the field is disabled, 'field-element--disabled'
 - If the field has an error, 'field-element--error'
 - One or more custom classes can be specified using the attribute "-wrapper-class".
   Each (array or space separated) class is prefixed with 'field-element--'

FPDF

A compatibility class - this is just a tFPDF wrapper.

See https://github.com/Setasign/FPDI

Fpdi

Implements FPDI library without having to hack up its source code (much).
FPDI is a PDF document importer which works with FPDF, so you can use nicely designed PDFs as templates,
and then dynamically add data to them.
See https://github.com/Setasign/FPDI or https://www.setasign.com/products/fpdi/about/

Html

Helper functions for outputting HTML elements.

HttpReq

Simple HTTP(s) request wrapper

I18n

Formats data according to local conventions.
This is an easier-to-use helper version of the LocaleInfo set of classes.

To set the locale, set the config param:
   sprout.locale

The default is AUS - Australia

Image

Manipulate images using standard methods such as resize, crop, rotate, etc.
This class must be re-initialized for every image you wish to manipulate.

ImportCSV

Facilitates the cimple importing of CSV files
Loads up the CSV and allows for sequential reading of the file as data records.

Inflector

Language inflection such as pluralisation.

Itemlist

Used to generate HTML for a table of database records.
This is usually used for the admin/contents/* route which provides the main
UI to operators for a given ManagedAdminController

Jquery

Simple class to ensure uniform jQuery version(s) used

Json

Methods for handling JSON output, usually for AJAX responses

JsonForm

Processes forms using configuration stored in a JSON file which specifies database columns, their HTML input fields,
and validation rules.
A generic implementation which should work for most cases is found in ManagedAdminController::_getEditForm
(generates the form) and Controller::saveJsonData (saves the POST submission)

LaunchChecks

Copyright (C) 2017 Karmabunny Pty Ltd.

This file is a part of SproutCMS.

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

For more information, visit <http://getsproutcms.com>.

This class was originally from Kohana 2.3.4
Copyright 2007-2008 Kohana Team

LightweightForm

A variation of the Form helper which doesn't output errors, labels or helptext
Wraps form fields (e.g. from Fb) with additional HTML.

LinkSpec

Base class for the backend of the extensible link system: Lnk

Lnk

This is a system of portable, extensible link management.

The system is based around the "link specification", which is a string.
Link specifications should be stored in a TEXT field.

These specs relate to classes which extend LinkSpec.
The class name needs to start with "LinkSpec" too.

Model

Base model class

MultiEdit

UI system for rapid adding/editing of any number of (sub-)records

Navigation

Provides navigation functions

NavigationGroups

Menu groups for front end main navigation

NavigationMenu

Renders a menu for the page node structure

If you would like to edit this, it would be much wiser to sub-class it
and override the various methods

Needs

Provides a system for injecting CSS and Javascript includes into the head of a document even after the head has been outputted.
Also does replacement for the string "SITE/", which gets changed into the Kohana root directory.

Notification

Provides user event notification functions

Page

Methods for working with CMS pages

Pagenode

Represents a page in a page tree

PageRouting

Logic for selecting the page if no controller matches

Pdb

Class for doing database queries via PDO (PDO Database => Pdb)

PerRecordPerms

Helper for implementing per-record permissions

Preview

Somewhat complicated preview system which copies existing data into
temporary tables, then renders the preview via a front-end method call

QualityImageTransform

Sets the image quality for JPEGs.
If you don't use one of these, the default is 95

QueryTo

No description yet.

RateLimit

Rate-limiting system, to prefent people form doing hacky stuff

Rdb

Redis wrapper + utilities.

Recaptcha

Implementation of Google (No CAPTCHA) ReCAPTCHA

RefineBar

Provides the search refinement options in the admin UI

RefineWidget

Base class for widgets included in a RefineBar

RefineWidgetAutocomplete

An autocomplete widget for the refine bar

RefineWidgetDatepicker

A datepicker widget for the refine bar

RefineWidgetSelect

A textbox widget

RefineWidgetTextbox

A textbox widget

Register

This will one day have methods for various different aspects of the cms
incl. widgets, search handlers, tabs, etc.
Dare to dream

Replication

Functions for database replication.
I guess it could be used for cluster situations too.

This default class has replication disabled.
To enable, replace this class with your own.

Request

Get information about the incoming HTTP request.

ResizeImageTransform

Does image resizing, etc

RichText

Interface the display of a richtext field

RichTextSanitiser

Helper that strictly validates and sanitises user submitted HTML
Intended for use with front-end instances of TinyMCE to ensure XSS is impossible.

Router

Router

Rs

Functions to hack database query result sets

RssFeed

Copyright (C) 2017 Karmabunny Pty Ltd.

This file is a part of SproutCMS.

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

For more information, visit <http://getsproutcms.com>.

This class was originally from Kohana 2.3.4
Copyright 2007-2008 Kohana Team

RteLibContainer

Returned by RteLibrary classes to represent a "container" (e.g. directories) in the browse structure

RteLibObject

Returned by RteLibrary classes to represent a "object" (e.g. files) in the browse structure

RteLibraryDocuments

Richtext library for media repository documents

RteLibraryHasCategories

Abstract richtext library for bog-standard "has categories" modules, such as news articles, blog posts, etc.

RteLibraryImages

Richtext library for media repository sounds, they launch in a popup audio player

RteLibraryPages

Richtext library for pages

RteLibrarySounds

Richtext library for media repository sounds, they launch in a popup audio player

Search

Functions for front-end search indexing

SearchHandler

Defines a table which can be searched against using the front-end search

Security

Functions for implementing security, including secure random numbers

Session

Session library.

Skin

Skin stuff - autoversioning mainly.

Slug

Generate and validate slugs - i.e. unique, SEO-friendly URL segments.
See e.g. https://en.wikipedia.org/wiki/Semantic_URL#Slug

SocialMeta

Management of social meta data tags, such as Facebook OpenGraph and Twitter Cards

SocialNetworking

Has methods for outputting links for submitting to a number of social networking sites

SortedColModifier

Extend this instead of ColModifier, if your output sort order matches the database sort order.
This means we can reliably show the sort arrows for a list, and it all still makes sense.

Spam

Helper for a simple mechanism to dissuade and annoy entry-level spammers.

For rigorous protection, use a CAPTCHA. @see Captcha

Sprout

Useful functions for sprout in general

Ssl

Used to force an SSL (i.e. HTTPS) connection for configured controllers and methods.

Subscribe

Base class for the content subscription handlers

Subsites

Provides functions for getting information about subsites

Tags

No description yet.

Text

Various text helpers such as limiting.

TextareaRichText

Interface the display of a richtext field

TinyMCE4RichText

Interface the display of a richtext field

Treenode

Represents a node in the tree

TreenodeContainsMatcher

Matches a node which has a specific key containing a specific value

TreenodeFrontendMatcher

Matches a node which has a specific key matching a specific value

TreenodeHasWidgetMatcher

Matches a node which has a specific key matching a specific value

TreenodeIdsMatcher

Matches a node which which has an id of one of the ids in the list

TreenodeInMenuMatcher

Matches a node which has a specific key matching a specific value

TreenodePageAttrMatcher

Matches a node which has a specific key matching a specific value

TreenodePathMatcher

Matches a node which has a specified path.
Path can be specified with either slash (/) or backslash (\)

TreenodeRedirectMatcher

Matches a node which has a specific key matching a specific value

TreenodeRegexMatcher

Matches a node which has a specific key containing a specific value

TreenodeValueMatcher

Matches a node which has a specific key matching a specific value

TwigSkinLoader

File loader for twig templates.

This obeys the same path rules as PHP views:
 - using the unavailable skin
 - using module/ sprout/ skin/ prefixes

TODO Some actual caching.

TwigView

Renderer for twig engine

UnescapedColModifier

Extend this instead of ColModifier, if your output SHOULD NOT be escaped, i.e. it is already HTML

Upload

Upload helper class for working with the global $_FILES array and Validation library.

Url

Helper functions for working with URLs.

UserAgent

Implementation of parser for user-agents.json file

UserAuth

Stub class for when the users module is not installed

Makes use of the fact that it's legal to call static
methods from instances

Will load the 'Helpers\UserAuth' class from the namespace
registered for the feature "users".

UserPerms

Stub class for when the users module is not installed

Makes use of the fact that it's legal to call static
methods from instances

Will load the 'Helpers\UserPerms' class from the namespace
registered for the feature "users".

Validator

New validation class for Sprout 3.
Used with the Validity class.

Validity

New validation class for Sprout 3.
All of its methods should give useful errors by throwing a ValidationException.
Used with the Validator class.

View

Loads and displays Kohana view files.

WidgetArea

Stores information about an individual widget area, including the names of all widgets
that are allowed to be in this area.

Widgets

Provided functions for the display of widgets

Worker

Functions called by worker libraries to indicate status, etc

WorkerBase

Base class for worker jobs, which are run via CLI in a separate process

WorkerCtrl

Functions to update and report on worker status

Interfaces

FrontEndEntrance

Defines that a specific controller is able to handle front-end entrances from the pages module

ImageTransform

Does image resizing, or whatever transforms wanted really.

TreenodeMatcher

Interface for matching nodes in the treenode

Functions

cc2kc

Changes camelCase to kebab-case

jsdate

A wrapper around strtotime. Pretty handy.

jsonPretty

Shorthand pretty print JSON.

kc2cc

Changes kebab-case to camelCase

truncate

Trim a string if it's too long. Adds a ... ellipsis character.

_widgetSort

Sorter for widgets