quiphooks.class.php

Classes 
package
quip
Classes
quipHooks

Description

Quip

Copyright 2010-11 by Shaun McCormick shaun@modx.com

This file is part of Quip, a simple commenting component for MODx Revolution.

Quip 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.

Quip 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 General Public License for more details.

You should have received a copy of the GNU General Public License along with Quip; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

\quipHooks

package
quip
Properties
$errors
$hooks
$modx
$quip
$redirectUrl
Methods
__construct
_process
addError
getErrorMessage
getValue
getValues
load
loadMultiple
math
redirect
setRedirectUrl
setValue
setValues
testFail

Description

Base Hooks handling class

Properties

$errors

array $errors = 'array'

Details

array
A collection of all the processed errors so far.
visibility
public
default
array
final
false
static
false
access
public

$hooks

array $hooks = 'array'

Details

array
A collection of all the processed hooks so far.
visibility
public
default
array
final
false
static
false
access
public

$modx

\modX $modx = 'null'

Details

\modX
A reference to the modX instance.
visibility
public
default
null
final
false
static
false
access
public

$quip

\Quip $quip = 'null'

Details

\Quip
A reference to the Quip instance.
visibility
public
default
null
final
false
static
false
access
public

$redirectUrl

string $redirectUrl = 'null'

Details

string
If a hook redirects, it needs to set this var to use proper order of execution on redirects/stores
visibility
public
default
null
final
false
static
false
access
public

Methods

__construct

__construct( \Quip $quip, array $config = array ) :

The constructor for the quipHooks class

Arguments
$quip
\Quip
A reference to the Quip class instance.
$config
array
Optional. An array of configuration parameters.
Details
visibility
public
final
false
static
false

_process

_process( string $str, array $placeholders = array ) : string

Processes string and sets placeholders

Arguments
$str
string
The string to process
$placeholders
array
An array of placeholders to replace with values
Output
string
The parsed string
Details
visibility
public
final
false
static
false

addError

addError( string $key, string $value ) : string

Adds an error to the stack.

Arguments
$key
string
The field to add the error to.
$value
string
The error message.
Output
string
The added error message with the error wrapper.
Details
visibility
public
final
false
static
false
access
private

getErrorMessage

getErrorMessage( string $delim = \n ) : string

Gets the error messages compiled into a single string.

Arguments
$delim
string
The delimiter between each message.
Output
string
The concatenated error message
Details
visibility
public
final
false
static
false
access
public

getValue

getValue( string $key ) : mixed

Gets the value of a field.

Arguments
$key
string
The field name to get.
Output
mixed
The value of the key, or null if non-existent.
Details
visibility
public
final
false
static
false

getValues

getValues( ) : array

Gets an associative array of field name and values.

Output
array
$values A key/name pair of fields and values.
Details
visibility
public
final
false
static
false

load

load( string $hook, array $fields = array, array $customProperties = array ) : boolean

Load a hook. Stores any errors for the hook to $this->errors.

Arguments
$hook
string
The name of the hook. May be a Snippet name.
$fields
array
The fields and values of the form.
$customProperties
array
Any other custom properties to load into a custom hook.
Output
boolean
True if hook was successful.
Details
visibility
public
final
false
static
false
access
public

loadMultiple

loadMultiple( array $hooks, array $fields = array, array $customProperties = array ) : array

Loads an array of hooks. If one fails, will not proceed.

Arguments
$hooks
array
The hooks to run.
$fields
array
The fields and values of the form
$customProperties
array
Any other custom properties to load into a custom hook
Output
array
An array of field name => value pairs.
Details
visibility
public
final
false
static
false
access
public

math

math( array $fields = array ) : boolean

Math field hook for anti-spam math input field.

Arguments
$fields
array
An array of cleaned POST fields
Output
boolean
True if email was successfully sent.
Details
visibility
public
final
false
static
false
access
public

redirect

redirect( array $fields = array ) : boolean

Redirect to a specified URL.

Properties needed: - redirectTo - the ID of the Resource to redirect to.

Arguments
$fields
array
An array of cleaned POST fields
Output
boolean
False if unsuccessful.
Details
visibility
public
final
false
static
false

setRedirectUrl

setRedirectUrl( string $url ) :

Set a URL to redirect to after all hooks run successfully.

Arguments
$url
string
The URL to redirect to after all hooks execute
Details
visibility
public
final
false
static
false

setValue

setValue( string $key, mixed $value ) : mixed

Sets the value of a field.

Arguments
$key
string
The field name to set.
$value
mixed
The value to set to the field.
Output
mixed
The set value.
Details
visibility
public
final
false
static
false

setValues

setValues( array $values = array ) :

Sets an associative array of field name and values.

Arguments
$values
array
A key/name pair of fields and values to set.
Details
visibility
public
final
false
static
false

testFail

testFail( ) : bool

Used for debugging to test preHooks.

Output
bool
Always false
Details
visibility
public
final
false
static
false
Documentation was generated by DocBlox 0.11.2.