Anda di halaman 1dari 83

Welcome

Description
Snippet
Aggregates documents to create blogs, article/news collections,
and more,with full support for templating.

Snippet
Author
Mark Kaplan for MODx CMF
Wordpress Config

Version
2.1.0
Template Class

Summary

Ditto Snippet Aggregates documents to


create blogs, article/news
collections, and more,with
ATOM full support for templating.
JSON Parameters
ditto_base Location of Ditto files

XML id Unique ID for this Ditto instance


for connection with other scripts
(like Reflect) and unique URL
parameters
language language for defaults, debug, and
error messages
format Output format to use

Summary config Load a custom configuration

Tagging debug Output debugging information


phx Use PHx formatting
extenders Load an extender which adds
functionality to Ditto

Variables
extenders Array that can be added to by
configs or formats to load that
extender
placeholders Initialize custom placeholders
array for configs or extenders to
add to
filters Holds both the custom filters array
for configs or extenders to add to
and the parsed filters array.
orderBy An array that holds all criteria to
sort the result set by.
idType type of IDs provided; can be either
parents or documents

1 of 22
Parameters
parents IDs of containers for Ditto to
retrieve their children to &depth
depth
documents IDs of documents for Ditto to
retrieve

Variables
IDs Internal variable which holds the
set of IDs for Ditto to fetch

Parameters
depth Number of levels deep to retrieve
documents
paginate Paginate the results set into pages
of &display length.
dateSource Source of the [+date+]
placeholder
dateFormat Format the [+date+] placeholder
in human readable form
display Number of documents to display in
the results
total Number of documents to retrieve
showPublishedOnly Show only published documents
showInMenuOnly Show only documents visible in the
menu
hideFolders Don’t show folders in the returned
results
hidePrivate Don’t show documents the guest
or user does not have permission
to see
seeThruUnpub See through unpublished folders to
retrive their children Used when
depth is greater than 1
queryLimit Number of documents to retrieve
from the database, same as
MySQL LIMIT
where Custom MySQL WHERE statement
noResults Text or chunk to display when
there are no results
removeChunk Name of chunks to be stripped
from content separated by
commas
hiddenFields Allow Ditto to retrieve fields its
template parser cannot handle
such as nested placeholders and
[fields]
start Number of documents to skip in
the results
globalFilterDelimiter Filter delimiter used to separate
filters in the filter string
localFilterDelimiter Delimiter used to separate
individual parameters within each
filter string

2 of 22
filter Removes items not meeting a
critera.
keywords Enable fetching of associated
keywords for each document Can
be used as [+keywords+] or as a
tagData source
randomize Randomize the order of the output
save Saves the ditto object and results
set to placeholders for use by
other snippets
tpl User defined chunk to format the
documents
tplAlt User defined chunk to format
every other document
tplFirst User defined chunk to format the
first document
tplLast User defined chunk to format the
last document
tplCurrentDocument User defined chunk to format the
current document
orderBy Sort the result set
paginateAlwaysShowLinks Determine whether or not to
always show previous next links
paginateSplitterCharacter Splitter to use if always show is
disabled
tplPaginatePrevious Template for the previous link
tplPaginateNext Template for the next link
tplPaginateNextOff Template for the inside of the next
link
tplPaginatePreviousOff Template for the previous link
when it is off
tplPaginatePage Template for the page link
tplPaginateCurrentPage Template for the current page link

Placeholders
item[x] Individual items rendered output

ditto_base

Purpose
Location of Ditto files

Options
Any valid folder location containing the Ditto source code with
a trailing slash

Default

3 of 22
[(base_path)]assets/snippets/ditto/

id

Purpose
Unique ID for this Ditto instance for connection with other
scripts (like Reflect) and unique URL parameters

Options
Any combination of characters a-z, underscores, and numbers
0-9

Note
This is case sensitive

Default
”” blank

language

Purpose
language for defaults, debug, and error messages

Options
Any language name with a corresponding file in the
&ditto_base/lang folder

Default
”english”

format

Purpose
Output format to use

Options
”html”
”json”
”xml”
”atom”
”rss”

Default

4 of 22
”html”

config

Purpose
Load a custom configuration

Options
”default” default blank config file
CONFIG_NAME Other configs installed in the configs
folder or in any folder within the
MODx base path via @FILE

Default
”default”

Related
extenders

debug

Purpose
Output debugging information

Options
0 off
1 on

Default
0 off

Related
debug

phx

Purpose
Use PHx formatting

Options
0 off

5 of 22
1 on

Default
1 on

extenders

Purpose
Load an extender which adds functionality to Ditto

Options
Any extender in the extenders folder or in any folder within
the MODx base path via @FILE

Default
[NULL]

Related
config

Variables

extenders

Array that can be added to by configs or formats to load that


extender

placeholders

Initialize custom placeholders array for configs or extenders


to add to

filters

Holds both the custom filters array for configs or extenders to


add to and the parsed filters array. To add to this array, use the
following format

$filters["parsed"][] = array("name" => array("source"=>$source,


$filters["custom"][] = array("source","callback_function");

6 of 22
orderBy

An array that holds all criteria to sort the result set by. Note
that using a custom sort will disable all other sorting.

$orderBy["parsed"][] = array("sortBy","sortDir");
$orderBy["custom"][] = array("sortBy","callback_function");

idType

type of IDs provided; can be either parents or documents

parents

Purpose
IDs of containers for Ditto to retrieve their children to &depth
depth

Options
Any valid MODx document marked as a container

Default
Current MODx Document

Related
documents
depth

documents

Purpose
IDs of documents for Ditto to retrieve

Options
Any valid MODx document marked as a container

Default
None

7 of 22
Related
parents

Variables

IDs

Internal variable which holds the set of IDs for Ditto to fetch

depth

Purpose
Number of levels deep to retrieve documents

Options
Any number greater than or equal to 1 0 - infinite depth

Default
1

Related
seeThruUnpub

8 of 22
paginate

Purpose
Paginate the results set into pages of &display length. Use
&total to limit the number of documents retreived.

Options
0 off
1 on

Default
0 off

Related
paginateAlwaysShowLinks
paginateSplitterCharacter
display

dateSource

Purpose
Source of the [+date+] placeholder

Options
# Any UNIX timestamp from MODx fields or TVs
such as createdon, pub_date, or editedon

Default
”createdon”

Related
dateFormat

dateFormat

Purpose
Format the [+date+] placeholder in human readable form

Options
Any PHP valid strftime option

Default
[LANG]

9 of 22
Related
dateSource

display

Purpose
Number of documents to display in the results

Options
# Any number
”all” All documents found

Default
3

Related
queryLimit
total

total

Purpose
Number of documents to retrieve

Options
# Any number
”all” All documents found

Default
”all” All documents found

Related
display
queryLimit

showPublishedOnly

Purpose
Show only published documents

Options
0 show only unpublished documents

10 of 22
1 show both published and unpublished
documents

Default
1 show only published documents

Related
seeThruUnpub
hideFolders
showPublishedOnly
where

showInMenuOnly

Purpose
Show only documents visible in the menu

Options
0 show all documents
1 show only documents with the show in menu
flag checked

Default
0 show all documents

Related
seeThruUnpub
hideFolders
where

11 of 22
hideFolders

Purpose
Don’t show folders in the returned results

Options
0 keep folders
1 remove folders

Default
0 keep folders

Related
seeThruUnpub
showInMenuOnly
where

hidePrivate

Purpose
Don’t show documents the guest or user does not have
permission to see

Options
0 show private documents
1 hide private documents

Default
1 hide private documents

Related
seeThruUnpub
showInMenuOnly
where

seeThruUnpub

Purpose
See through unpublished folders to retrive their children Used
when depth is greater than 1

Options
0 off
1 on

12 of 22
Default
0 off

Related
hideFolders
showInMenuOnly
where

queryLimit

Purpose
Number of documents to retrieve from the database, same as
MySQL LIMIT

Options
# Any number
0 automatic

Default
0 automatic

Related
where

where

Purpose
Custom MySQL WHERE statement

Options
A valid MySQL WHERE statement using only document object
items (no TVs)

Default
[NULL]

Related
queryLimit

noResults

Purpose
Text or chunk to display when there are no results

13 of 22
Options
Any valid chunk name or text

Default
[LANG]

removeChunk

Purpose
Name of chunks to be stripped from content separated by
commas

Commonly used to remove comments

Options
Any valid chunkname that appears in the output

Default
[NULL]

hiddenFields

Purpose
Allow Ditto to retrieve fields its template parser cannot
handle such as nested placeholders and [fields]

Options
Any valid MODx fieldnames or TVs comma separated

Default
[NULL]

start

Purpose
Number of documents to skip in the results

Options
Any number

Default

14 of 22
0

globalFilterDelimiter

Purpose
Filter delimiter used to separate filters in the filter string

Options
Any character not used in the filters

Default
”|”

Related
localFilterDelimiter
filter
parseFilters

localFilterDelimiter

Purpose
Delimiter used to separate individual parameters within each
filter string

Options
Any character not used in the filter itself

Default
”,”

Related
globalFilterDelimiter
filter
parseFilters

filter

Purpose
Removes items not meeting a critera. Thus, if pagetitle ==
joe then it will be removed. Use in the format field,criteria,mode
with the comma being the local delimiter

Mode Meaning

15 of 22
1 !=
2 ==
3 <
4 >
5 <=
6 >=
7 Text not in field value
8 Text in field value
9 case insenstive version of #7
10 case insenstive version of #8
11 checks leading character of the field

@EVAL
@EVAL in filters works the same as it does in MODx exect it
can only be used with basic filtering, not custom filtering
(tagging, etc). Make sure that you return the value you wish
Ditto to filter by and that the code is valid PHP.

Default
[NULL]

Related
localFilterDelimiter
globalFilterDelimiter
parseFilters

keywords

Purpose
Enable fetching of associated keywords for each document
Can be used as [+keywords+] or as a tagData source

Options
0 off
1 on

Default
0 off

randomize

Purpose
Randomize the order of the output

16 of 22
Options
0 off
1 on Any MODx field or TV for weighted random

Default
0 off

save

Purpose
Saves the ditto object and results set to placeholders for use
by other snippets

Options
0 off; returns output
1 remaining; returns output
2 all;
3 all; returns ph only

Default
0 off; returns output

tpl

Purpose
User defined chunk to format the documents

Options
Any valid chunk name
Code via @CODE
File via @FILE

Default
[LANG]

tplAlt

Purpose
User defined chunk to format every other document

Options
Any valid chunk name

17 of 22
Code via @CODE
File via @FILE

Default
&tpl

tplFirst

Purpose
User defined chunk to format the first document

Options
Any valid chunk name
Code via @CODE
File via @FILE

Default
&tpl

tplLast

Purpose
User defined chunk to format the last document

Options
Any valid chunk name
Code via @CODE
File via @FILE

Default
&tpl

18 of 22
tplCurrentDocument

Purpose
User defined chunk to format the current document

Options
Any valid chunk name
Code via @CODE
File via @FILE

Default
&tpl

orderBy

Purpose
Sort the result set

Options
Any valid MySQL style orderBy statement

Default
createdon DESC

paginateAlwaysShowLinks

Purpose
Determine whether or not to always show previous next links

Options
0 off
1 on

Default
0 off

Related
paginate
paginateSplitterCharacter

paginateSplitterCharacter

19 of 22
Purpose
Splitter to use if always show is disabled

Options
Any valid character

Default
[LANG]

Related
paginate
paginateSplitterCharacter

tplPaginatePrevious

Purpose
Template for the previous link

Options
Any valid chunk name
Code via @CODE
File via @FILE

Placeholders
url URL for the previous link
lang:previous value of ‘prev’ from the language
file

Related
tplPaginateNext
paginateSplitterCharacter

tplPaginateNext

Purpose
Template for the next link

Options
Any valid chunk name
Code via @CODE
File via @FILE

Placeholders
url URL for the next link
lang:next value of ‘next’ from the language file

20 of 22
Related
tplPaginatePrevious
paginateSplitterCharacter

tplPaginateNextOff

Purpose
Template for the inside of the next link

Options
Any valid chunk name
Code via @CODE
File via @FILE

Placeholders
lang:next value of ‘next’ from the language file

Related
tplPaginatePrevious
paginateSplitterCharacter

tplPaginatePreviousOff

Purpose
Template for the previous link when it is off

Options
Any valid chunk name
Code via @CODE
File via @FILE

Placeholders
lang:previous value of ‘prev’ from the language
file

Related
tplPaginatePrevious
paginateSplitterCharacter

tplPaginatePage

Purpose
Template for the page link

Options
Any valid chunk name

21 of 22
Code via @CODE
File via @FILE

Placeholders
url url for the page
page number of the page

Related
tplPaginatePrevious
paginateSplitterCharacter

tplPaginateCurrentPage

Purpose
Template for the current page link

Options
Any valid chunk name
Code via @CODE
File via @FILE

Placeholders
page number of the page

Related
tplPaginatePrevious
paginateSplitterCharacter

item[x]

Content
Individual items rendered output

Generated by Natural Docs

22 of 22
Welcome
Purpose
Snippet
The Ditto class contains all functions relating to Ditto’s
functionality and any supporting functions they need

Snippet
Summary

Wordpress Config
Main Class The Ditto class contains
all functions relating to
Ditto’s functionality and
Main Class
any supporting functions
Template Class they need
Functions
getTVList Get a list of all available TVs
addField Add a field to the internal field
detection system
addFields Add a field to the internal field
ATOM detection system from an
array or delimited string
JSON
removeField Remove a field to the internal
field detection system
XML setDisplayFields Move the detected fields into
the Ditto fields array
getDocVarType Determine if the provided
field is a tv, a database field,
or something else
parseOrderBy Parse out orderBy parameter
string
Summary
checkAdvSort Check the advSortString
Tagging parseFilters Split up the filters into an
array and add the required
fields to the fields array
render Render the document output
parseFields Find the fields that are
contained in the custom
placeholders or those that are
needed in other functions
arrayUnique Make fields array unique
parseCustomPlaceholders Parse the required fields out
of the custom placeholders
parseDBFields Parse out the fields required
for each state
renderQELinks Render QE links when needed

1 of 10
getAuthor Get the author name, or if not
available the username
customSort Sort resource array if
advanced sorting is needed
userSort Sort the resource array by a
user defined function
multiSort Sort the resource array by
multiple fields
Rows->Columns portion by
Jon L.
determineIDs Get Document IDs for future
use
weightedRandom Execute a random order sort
getParentList Get a list of all available
parents
appendTV Apeend a TV to the
documents array
appendKeywords Append keywords’s to the
resource array
fetchKeywords Helper function to
appendKeywords
getChildIDs Get the IDs ready to be
processed Similar to the
modx version by the same
name but much faster
getDocuments Get documents and append
TVs + Prefetch Data, and sort
getDocumentsLite Get an array of documents
cleanIDs Clean the IDs of any
dangerous characters
buildURL Build a URL with regard to
Ditto ID
getParam Get a parameter or use the
default language value
paginate Paginate the documents
noResults Render the noResults output
relToAbs Convert relative urls to
absolute URLs Based on script
from
http://wintermute.com.au
/bits/2005-09/php-relative-
absolute-links/

getTVList

2 of 10
function getTVList()

Get a list of all available TVs

addField

function addField($name,
$location,
$type = false)

Add a field to the internal field detection system

addFields

function addFields($fields,
$location = '*',
$delimiter = ',',
$callback = false)

Add a field to the internal field detection system from an


array or delimited string

removeField

function removeField($name,
$location,
$type )

Remove a field to the internal field detection system

setDisplayFields

function setDisplayFields($fields,
$hiddenFields)

Move the detected fields into the Ditto fields array

3 of 10
getDocVarType

function getDocVarType($field)

Determine if the provided field is a tv, a database field,


or something else

parseOrderBy

function parseOrderBy($orderBy,
$randomize)

Parse out orderBy parameter string

checkAdvSort

function checkAdvSort($sortBy,
$sortDir = 'asc')

Check the advSortString

parseFilters

function parseFilters($filter = false,


$cFilters = false,
$pFilters = false,
$globalDelimiter,
$localDelimiter )

Split up the filters into an array and add the required


fields to the fields array

render

function render($resource,
$template,

4 of 10
$removeChunk,
$dateSource,
$dateFormat,
$ph = array(),
$phx = 1,
$x = 0 )

Render the document output

parseFields

function parseFields($placeholders,
$seeThruUnpub,
$dateSource,
$randomize )

Find the fields that are contained in the custom


placeholders or those that are needed in other functions

arrayUnique

function arrayUnique($array)

Make fields array unique

parseCustomPlaceholders

function parseCustomPlaceholders($placeholders)

Parse the required fields out of the custom placeholders

parseDBFields

function parseDBFields($seeThruUnpub)

Parse out the fields required for each state

5 of 10
renderQELinks

function renderQELinks($fields,
$resource,
$QEPrefix,
$placeholders)

Render QE links when needed

getAuthor

function getAuthor($createdby)

Get the author name, or if not available the username

customSort

function customSort($data,
$fields,
$order )

Sort resource array if advanced sorting is needed

userSort

function userSort($resource,
$sort )

Sort the resource array by a user defined function

multiSort

function multiSort($resource,
$orderBy )

Sort the resource array by multiple fields


Rows->Columns portion by Jon L. -- intel352@gmail.com

6 of 10
Link: http://de3.php.net /manual /en /function.array-
multisort.php#73498

determineIDs

function determineIDs($IDs,
$IDType,
$TVs,
$orderBy,
$depth,
$showPublishedOnly,
$seeThruUnpub,
$hideFolders,
$hidePrivate,
$showInMenuOnly,
$myWhere,
$keywords,
$dateSource,
$limit,
$summarize,
$filter,
$paginate,
$randomize )

Get Document IDs for future use

weightedRandom

function weightedRandom($resource,
$field,
$show )

Execute a random order sort

getParentList

function getParentList()

Get a list of all available parents

appendTV

7 of 10
function appendTV($tvname = "",
$docIDs )

Apeend a TV to the documents array

appendKeywords

function appendKeywords($resource)

Append keywords’s to the resource array

fetchKeywords

function fetchKeywords($resource)

Helper function to appendKeywords

getChildIDs

function getChildIDs($IDs,
$depth)

Get the IDs ready to be processed Similar to the modx


version by the same name but much faster

getDocuments

function getDocuments($ids = array


(),
$fields,
$TVs,
$orderBy,
$published = 1,
$deleted = 0,
$public = 1,
$where = '',
$limit = "",
$keywords = 0,
$randomize = 0,

8 of 10
$dateSource = false)

Get documents and append TVs + Prefetch Data, and sort

getDocumentsLite

Get an array of documents

cleanIDs

function cleanIDs($IDs)

Clean the IDs of any dangerous characters

buildURL

function buildURL($args,
$id = false,
$dittoIdentifier = false )

Build a URL with regard to Ditto ID

getParam

function getParam($param,
$langString)

Get a parameter or use the default language value

paginate

function paginate($start,
$stop,
$total,

9 of 10
$summarize,
$tplPaginateNext,
$tplPaginatePrevious,
$tplPaginateNextOff,
$tplPaginatePreviousOff,
$tplPaginatePage,
$tplPaginateCurrentPage,
$paginateAlwaysShowLinks,
$paginateSplitterCharacter)

Paginate the documents

noResults

function noResults($text,
$paginate)

Render the noResults output

relToAbs

function relToAbs($text,
$base )

Convert relative urls to absolute URLs Based on script


from http://wintermute.com.au /bits/2005-09 /php-relative-
absolute-links/

Generated by Natural Docs

10 of 10
Template Class
Welcome
Purpose
Snippet
The Template class contains all functions relating to Ditto’s
handling of templates and any supporting functions they
need
Snippet

Summary
Wordpress Config

Template Class The Template class contains all


functions relating to Ditto’s
handling of templates and any
Template Class supporting functions they need
Functions
template Set the class language and fields
variables
process Take the templates and parse them
for tempalte variables, Check to
make sure they have fields, and sort
ATOM
the fields
JSON findTemplateVars Find al the template variables in the
template

XML sortFields Sort the array of fields provided by


type
replace Replcae placeholders with their
values
determine Determine the correct template to
apply
fetch Get a template, based on version by
Summary Doze

Tagging get_file_contents Returns the contents of file name


passed

template

function template()

Set the class language and fields variables

1 of 3
process

function process($template)

Take the templates and parse them for tempalte


variables, Check to make sure they have fields, and sort the
fields

findTemplateVars

function findTemplateVars($tpl)

Find al the template variables in the template

sortFields

function sortFields ($fieldList)

Sort the array of fields provided by type

replace

function replace($placeholders,
$tpl )

Replcae placeholders with their values

2 of 3
determine

function determine($templates,
$x,
$start,
$stop,
$id )

Determine the correct template to apply

fetch

function fetch($tpl)

Get a template, based on version by Doze

http://modxcms.com/forums/index.php/topic
,5344.msg41096.html#msg41096

get_file_contents

function get_file_contents($filename)

Returns the contents of file name passed

From http://www.nutt.net /2006 /07 /08


/file_get_contents-function-for-php-4 /#more-210

Generated by Natural Docs

3 of 3
Welcome
Purpose
Snippet
The Filter class contains all functions relating to filtering, the
removing of documents from the result set

Snippet
Summary

Wordpress Config
Filter Class The Filter class contains all
functions relating to filtering,
the removing of documents
from the result set
Template Class
Functions
Filter Class
execute Filter documents via either a custom
filter or basic filter
basicFilter Do basic comparison filtering

ATOM
JSON

XML
execute

function execute($resource,
$filter )

Filter documents via either a custom filter or basic filter


Summary
Tagging

basicFilter

function basicFilter ($value)

Search
Do basic comparison filtering

Generated by Natural Docs

1 of 1
Welcome
Purpose
Snippet
The Debug class contains all functions relating to Ditto’s
implimentation of the MODx debug console

Snippet
Summary

Wordpress Config
Debug Class The Debug class contains all
functions relating to Ditto’s
implimentation of the MODx
debug console
Template Class
Functions
render_link Render the links to the debug
Debug Class console
render_popup Render the contents of the debug
console
preparePrefetch Create the content of the Prefetch
ATOM tab

JSON prepareFilters Create the content of the Filters


tab
prepareDocumentInfo Create the output for the
XML Document Info tab
prepareBasicInfo Create the outut for the Info ta
prepareTemplates Create the output for the
Templates tab

Summary
Tagging

render_link

function render_link($dittoID,
$ditto_base)

Render the links to the debug console

render_popup

1 of 3
function render_popup($ditto,
$ditto_base,
$ditto_version,
$ditto_params,
$IDs,
$fields,
$summarize,
$templates,
$orderBy,
$start,
$stop,
$total,
$filter,
$resource )

Render the contents of the debug console

preparePrefetch

function preparePrefetch($prefetch)

Create the content of the Prefetch tab

prepareFilters

function prepareFilters($filter)

Create the content of the Filters tab

prepareDocumentInfo

function prepareDocumentInfo($resource)

Create the output for the Document Info tab

prepareBasicInfo

function prepareBasicInfo($ditto,
$ditto_version,

2 of 3
$IDs,
$summarize,
$orderBy,
$start,
$stop,
$total )

Create the outut for the Info ta

prepareTemplates

function prepareTemplates($templates)

Create the output for the Templates tab

Generated by Natural Docs

3 of 3
Welcome
Purpose
Snippet
A class designed to help developers impliment a debug
console like to the one in Ditto 2

Snippet
Summary

Wordpress Config
MODx Debug A class designed to help
Console developers impliment a debug
console like to the one in Ditto
2
Template Class
Functions
render Render the contents of the debug
console
MODx Debug Console save Save the debug console as a file
makelink Render the links to the debug console
buildURL Build a URL with regard to a prefix
ATOM
makeTab Render a tab
JSON
makeMODxSafe Make all MODx tags safe for the
output
XML makeParamTable Turn an array of parameters in the
format [“param”] => “value” into a
table
cleanArray Remove empty items from the array
array2table Translate a result array into a HTML
table

Summary
Tagging

render

function render($cTabs,
$title,
$base_path)

Render the contents of the debug console

1 of 3
save

function save($html,
$filename)

Save the debug console as a file

makelink

Render the links to the debug console

buildURL

function buildURL($args,
$id = false,
$prefix = "" )

Build a URL with regard to a prefix

makeTab

function makeTab($title,
$content)

Render a tab

makeMODxSafe

function makeMODxSafe($value)

Make all MODx tags safe for the output

makeParamTable

2 of 3
function makeParamTable($parameters = array(),
$header = "",
$sort = true,
$prep = true,
$wordwrap = true )

Turn an array of parameters in the format [“param”] =>


“value” into a table

cleanArray

function cleanArray($array)

Remove empty items from the array

array2table

function array2table($array,
$recursive = false,
$return = false,
$null = '&nbsp;')

Translate a result array into a HTML table

Author: Aidan Lister aidan@php.net

Version: 1.3.1

Link: http://aidanlister.com/repos/v
/function.array2table.php

Generated by Natural Docs

3 of 3
ATOM
Welcome
Purpose
Snippet
Collection of parameters, functions, and classes that expand
Ditto’s output capabilities to include ATOM

Summary

Template Class
ATOM Collection of parameters,
functions, and classes that
expand Ditto’s output
capabilities to include ATOM
Parameters
abbrLanguage Language for the Atom feed
ATOM charset Charset to use for the Atom feed
JSON

XML

abbrLanguage

Purpose
Summary Language for the Atom feed

Tagging
Options
Any valid 2 character language abbreviation
Compatibility

Default
[LANG]

Related
language

charset

Purpose
Charset to use for the Atom feed

Options

1 of 2
Any valid charset identifier

Default
MODx default charset

Generated by Natural Docs

2 of 2
JSON
Welcome
Purpose
Snippet
Collection of parameters, functions, and classes that expand
Ditto’s output capabilities to include JSON

Summary

Template Class
JSON Collection of parameters,
functions, and classes that
expand Ditto’s output
capabilities to include JSON
Parameters
abbrLanguage Language for the JSON document
ATOM copyright Copyright message to embed in the
JSON JSON document
ttl Time to live for the JSON feed

XML

abbrLanguage
Summary
Purpose
Tagging
Language for the JSON document

Compatibility Options
Any valid 2 character language abbreviation

Default
[LANG]

Related
language

copyright

Purpose
Copyright message to embed in the JSON document

1 of 2
Options
Any text

Default
[LANG]

ttl

Purpose
Time to live for the JSON feed

Options
Any integer greater than 1

Default
120

Generated by Natural Docs

2 of 2
Welcome
Purpose
Snippet
Collection of parameters, functions, and classes that expand
Ditto’s output capabilities to include RSS

Summary

Template Class
RSS Collection of parameters,
functions, and classes that
expand Ditto’s output
capabilities to include RSS
Parameters
copyright Copyright message to embed in the
ATOM RSS feed

JSON abbrLanguage Language for the RSS feed


ttl Time to live for the RSS feed
RSS
charset Charset to use for the RSS feed
XML
xsl XSL Stylesheet to format the RSS
feed with

Summary
Tagging
copyright

Compatibility
Purpose
Copyright message to embed in the RSS feed

Options
Any text

Default
[LANG]

abbrLanguage

Purpose

1 of 3
Language for the RSS feed

Options
Any valid 2 character language abbreviation

Default
[LANG]

Related
language

ttl

Purpose
Time to live for the RSS feed

Options
Any integer greater than 1

Default
120

charset

Purpose
Charset to use for the RSS feed

Options
Any valid charset identifier

Default
MODx default charset

xsl

Purpose
XSL Stylesheet to format the RSS feed with

Options

2 of 3
The path to any valid XSL Stylesheet

Default
None

Generated by Natural Docs

3 of 3
XML
Welcome
Purpose
Snippet
Collection of parameters, functions, and classes that expand
Ditto’s output capabilities to include XML

Summary

Template Class
XML Collection of parameters,
functions, and classes that
expand Ditto’s output
capabilities to include XML
Parameters
copyright Copyright message to embed in the
ATOM XML feed

JSON abbrLanguage Language for the XML feed


ttl Time to live for the RSS feed
charset Charset to use for the RSS feed
XML
xsl XSL Stylesheet to format the XML
feed with

Summary
Tagging
copyright

Compatibility
Purpose
Copyright message to embed in the XML feed

Options
Any text

Default
[LANG]

abbrLanguage

Purpose

1 of 3
Language for the XML feed

Options
Any valid 2 character language abbreviation

Default
[LANG]

Related
language

ttl

Purpose
Time to live for the RSS feed

Options
Any integer greater than 1

Default
120

charset

Purpose
Charset to use for the RSS feed

Options
Any valid charset identifier

Default
MODx default charset

xsl

Purpose
XSL Stylesheet to format the XML feed with

Options

2 of 3
The path to any valid XSL Stylesheet

Default
None

Generated by Natural Docs

3 of 3
Welcome
Purpose
Snippet
Filtering companion to Reflect or other date based filtering

Summary

Date Filter Filtering companion to Reflect


ATOM or other date based filtering
JSON Parameters
dateFilterSource Source for the day, month, and year
to filter by
XML
dateSource Source of the [+date+] placeholder
dateFilterDefault Determine the default filter
Date Filter
month Month to filter by
year Year to filter by
day Day to filter by
Summary
Placeholders
Tagging
year Year being filtered by
month Month being filtered by
Compatibility month Numeric version of the month being
filtered by
day Day being filtered by

Italian

dateFilterSource

Purpose
Source for the day, month, and year to filter by

Options
get gets the value of year, month, and
day from the URL (pre-appended with
the Ditto ID)
params gets the value from the snippet cal
text name of the request variable to use

Default

1 of 4
get

dateSource

Purpose
Source of the [+date+] placeholder

Options
# Any UNIX timestamp from MODx fields or
TVs such as createdon, pub_date, or
editedon

Default
”createdon”

Related
dateFormat

dateFilterDefault

Purpose
Determine the default filter

Options
0 filter off
1 current year
2 current year and month
3 current year, month, and day

Default
0

month

Purpose
Month to filter by

Options
# Number between 1-12 (inclusive) that

2 of 4
corresponds to the month to filter by

Default
[NULL]

year

Purpose
Year to filter by

Options
# Any numerical year (4 numbers; ex: 2006)

Default
[NULL]

day

Purpose
Day to filter by

Options
# Any numerical day within the current
month

Default
[NULL]

year

Content
Year being filtered by

month

3 of 4
Content
Month being filtered by

month

Content
Numeric version of the month being filtered by

day

Content
Day being filtered by

Generated by Natural Docs

4 of 4
Welcome
Purpose
Snippet
Example file for basing new Extenders on

Summary

Example Example file for basing


ATOM new Extenders on
JSON Parameters Define any parameters
needed in the extender or
to override Ditto defaults
XML
param The purpose of your
parameter goes here

Placeholders Defin the values of


custom placeholders for
Example
access in the tpl like so
[+phname+]
Summary $placeholders[‘example’] Add the placeholder example
to the custom placeholders list
Tagging with the source pagetitle in
both display and backend
using the exampleFunction
Compatibility callback and pagetitle as the
field for QuickEdit.
exampleFunction Takes the resource array for
an individual document and
returns the value of the
placeholder, in this case the
uppercase version of the
Italian
pagetitle

Filters Define custom or basic


filters within the extender
to expand Ditto’s filtering
capabilities
$filters[“custom”] Add the filter exampleFilter to
[“exampleFilter”] the custom filters list with the
source pagetitle and the
callback exampleFilter
exampleFilter Takes the resource array for
an individual document and
asks for the return of a 0 or 1
with 1 removing the document
and 0 leaving it in the result
set.
$filters[“parsed”][] Add the pre-parsed filter to
the parsed filters list with the
source as id, the value of

1 of 3
9239423942 and the mode 2

Define any parameters needed in the extender or to


override Ditto defaults

param

Purpose
The purpose of your parameter goes here

Options
Any options that your parameter can have go here

Default
”default”

Defin the values of custom placeholders for access in the


tpl like so [+phname+]

$placeholders[‘example’]

Add the placeholder example to the custom placeholders


list with the source pagetitle in both display and backend
using the exampleFunction callback and pagetitle as the field
for QuickEdit. If you only needed the placeholder in the
frontent you would just use “pagetitle” as the first value of
the array. If the callback was in a class use the
array($initialized_class,”member”) method.

2 of 3
exampleFunction

function exampleFunction($resource)

Takes the resource array for an individual document and


returns the value of the placeholder, in this case the
uppercase version of the pagetitle

Define custom or basic filters within the extender to


expand Ditto’s filtering capabilities

$filters[“custom”][“exampleFilter”]

Add the filter exampleFilter to the custom filters list with


the source pagetitle and the callback exampleFilter

exampleFilter

function exampleFilter($resource)

Takes the resource array for an individual document and


asks for the return of a 0 or 1 with 1 removing the document
and 0 leaving it in the result set. In this case, if the lower
case value of the pagetitle is foo, it is removed while all
other documents are shown

$filters[“parsed”][]

Add the pre-parsed filter to the parsed filters list with the
source as id, the value of 9239423942 and the mode 2

Generated by Natural Docs

3 of 3
Welcome
Purpose
Snippet
Adds support for changing Ditto parameters via URL

Note
All variables must be prefixed with ditto_ for the snippet to recognize them!
If a Ditto id is set use the sntax
ATOM
Summary
JSON

Request Adds support for changing Ditto parameters via URL


XML
Parameters
stripTags Remove HTML tags from the parameters provided
bad Parameters that are not allowed to be set
good Parameters that are allowed to be set

Request dbg Output variables being set

Summary
Tagging

Compatibility

stripTags

Purpose
Remove HTML tags from the parameters provided
Italian

Options
0 off
1 on

Default
1 on

bad

Purpose
Parameters that are not allowed to be set

Options
Any valid Ditto options separated by commas

Default
”seeThroughtUnpub,showInMenuOnly,showPublishedOnly,debug,start,config,extenders,dittoID”

good

Purpose
Parameters that are allowed to be set

1 of 2
Options
Any valid Ditto options separated by commas

Default
All parameters execpt those in &bad

dbg

Purpose
Output variables being set

Options
0 off
1 on

Default
0 off

Generated by Natural Docs

2 of 2
Welcome
Purpose
Snippet
Legacy support for the [+summary+] placeholder

Summary

Summary Legacy support for the


ATOM [+summary+] placeholder
JSON Parameters
trunc Enable truncation on the summary
placeholder
XML
truncAt Location to split the content at
truncLen Number of characters to show of the
content
truncOffset Number of charactars to “wander”
either way of truncLen
truncText Text to be displayed in [+link+]
Summary
tplTrunc Template to be used for [+link+]
Tagging

Compatibility

trunc

Italian Purpose
Enable truncation on the summary placeholder

Options
0 off
1 on

Default
1 on

truncAt

Purpose
Location to split the content at

1 of 3
Options
Any unique text or code string that is contained in the
content of each document

Default
”<!-- splitter -->”

truncLen

Purpose
Number of characters to show of the content

Options
Any number greater than truncOffset

Default
300

truncOffset

Purpose
Number of charactars to “wander” either way of truncLen

Options
Any number greater less than truncLen

Default
30

truncText

Purpose
Text to be displayed in [+link+]

Options
Any valid text or html

Default

2 of 3
”Read more...”

tplTrunc

Purpose
Template to be used for [+link+]

Options
Any valid chunk name
Code via @CODE:
File via @FILE:

Placeholders
[+url+] URL of the document
[+text+] &truncText

Default
&truncText

Generated by Natural Docs

3 of 3
Tagging
Welcome
Purpose
Snippet
Collection of parameters, functions, and classes that expand
Ditto’s functionality to include tagging

Summary

ATOM Tagging Collection of parameters,


JSON functions, and classes that
expand Ditto’s functionality to
include tagging
XML
Parameters
tagDocumentID ID for tag links to point to
tagData Field to get the tags from
caseSensitive Determine whether or not tag
matching and duplicate tag removal
are case sensitive
Summary tagMode Filtering method to remove tags
Tagging tagDelimiter Delimiter that splits each tag in the
tagData source
tagDisplayDelimiter What separates the tags in
Compatibility [+tagLinks+]
tagSort Sort the tags alphanumerically
tagDisplayMode How to display the tags in
[+tagLinks+]
tags Allow the user to provide initial tags
Italian to be filtered
tplTagLinks Define a custom template for the
tagLinks placeholder
tagCallback Allow the user to modify both where
the tags come from and how they
are parsed.

Placeholders
tagLinks Nice ‘n beautiful tag list with links
pointing to tagDocumentID
tags Raw tags separated by tagDelimiter

tagDocumentID

1 of 6
Purpose
ID for tag links to point to

Options
Any MODx document with a Ditto call setup to receive
the tags

Default
Current MODx Document

tagData

Purpose
Field to get the tags from

Options
Comma separated list of MODx fields or TVs

Default
[NULL]

caseSensitive

Purpose
Determine whether or not tag matching and duplicate tag
removal are case sensitive

Options
0 off
1 on

Default
0 off

tagMode

Purpose
Filtering method to remove tags

2 of 6
Options
onlyAllTags show documents that have all
of the tags
onlyTags show documents that have
any of the tags
removeAllTags remove documents that have
all of the tags
removeTags documents that have any of
the tags

Default
”onlyTags”

tagDelimiter

Purpose
Delimiter that splits each tag in the tagData source

Options
Any character not included in the tags themselves

Default
” “ space

tagDisplayDelimiter

Purpose
What separates the tags in [+tagLinks+]

Options
Any character

Default
&tagDelimiter

tagSort

Purpose
Sort the tags alphanumerically

3 of 6
Options
0 off
1 on

Default
1 on

tagDisplayMode

Purpose
How to display the tags in [+tagLinks+]

Options
1 string of links &tagDisplayDelimiter
separated
2 ul/li list

Note
Output of individual items can be customized by
tplTagLinks

Default
1 string of links &tagDisplayDelimiter
separated

tags

Purpose
Allow the user to provide initial tags to be filtered

Options
Any valid tags separated by tagDelimiter

Default
[NULL]

tplTagLinks

Purpose
Define a custom template for the tagLinks placeholder

4 of 6
Options
Any valid chunk name
Code via @CODE
File via @FILE

Default
<a href="[+url+]" class="ditto_tag" rel="tag">[+tag+]</a>

tagCallback

Purpose
Allow the user to modify both where the tags come from
and how they are parsed.

Options
Any valid function name

Default
[NULL]

Notes
The function should expect to receive the following three
parameters: tagData - the provided source of the tags
resource - the resource array for the document being parsed
array - return the results in an array if true

tagLinks

Content
Nice ‘n beautiful tag list with links pointing to
tagDocumentID

tags

Content
Raw tags separated by tagDelimiter

5 of 6
Generated by Natural Docs

6 of 6
Welcome
Purpose
Snippet
Default templates for Reflect

Snippet Summary
Default Templates
Wordpress Config Default Default templates for Reflect
Templates
Variables
$defaultTemplates Holds the default templates
Template Class

Variables

$defaultTemplates
ATOM
JSON $defaultTemplates

XML Holds the default templates

Generated by Natural Docs

Summary
Tagging

Search

1 of 1
Welcome
Description
Snippet
Generates date based archives using Ditto

Snippet Author
Mark Kaplan for MODx CMF
Wordpress Config
Version
2.1.0

Template Class
Note
If Reflect is not retrieving its own documents, make sure that
the Ditto call feeding it has all of the fields in it that you plan
on calling in your Reflect template. Furthermore, Reflect will
ONLY show what is currently in the Ditto result set. Thus, if
pagination is on it will ONLY show that page’s items.
ATOM
JSON Summary

Reflect Snippet Generates date based archives


XML
using Ditto
Parameters
ditto_base Location of Ditto files
config Load a custom configuration
id Unique ID for this Ditto instance for
connection with other scripts (like
Summary
Reflect) and unique URL parameters
Tagging
getDocuments Force Reflect to get documents
showItems Show individual items in the archive
groupByYears Group the archive by years
targetID ID for archive links to point to
dateSource Date source to display for archive
items
dateFormat Format the [+date+] placeholder in
human readable form
yearSortDir Direction to sort documents
monthSortDir Direction to sort the months
start Number of documents to skip in the
results
phx Use PHx formatting

1 of 9
params Pass parameters to the Ditto instance
used to retreive the documents
source Name of the Ditto snippet to use
tplContainer Container template for the archive
tplYear Template for the year item
tplYearInner Template for the year item (the ul to
hold the year template)
tplMonth Template for the month item
tplMonthInner Template for the month item (the ul
to hold the month template)
tplItem Template for the individual item

ditto_base

Purpose
Location of Ditto files

Options
Any valid folder location containing the Ditto source code
with a trailing slash

Default
[(base_path)]assets/snippets/ditto/

config

Purpose
Load a custom configuration

Options
”default” default blank config file
CONFIG_NAME Other configs installed in the
configs folder or in any folder
within the MODx base path via
@FILE

Default
”default”

Related

2 of 9
extenders

id

Purpose
Unique ID for this Ditto instance for connection with
other scripts (like Reflect) and unique URL parameters

Options
Any valid folder location containing the Ditto source code
with a trailing slash

Default
”” blank

getDocuments

Purpose
Force Reflect to get documents

Options
0 off
1 on

Default
0 off

showItems

Purpose
Show individual items in the archive

Options
0 off
1 on

Default
1 on

3 of 9
groupByYears

Purpose
Group the archive by years

Options
0 off
1 on

Default
1 on

targetID

Purpose
ID for archive links to point to

Options
Any MODx document with a Ditto call setup with
extenders=`dateFilter`

Default
Current MODx Document

dateSource

Purpose
Date source to display for archive items

Options
# Any UNIX timestamp from MODx fields or
TVs such as createdon, pub_date, or
editedon

Default
”createdon”

Related
dateFormat

4 of 9
dateFormat

Purpose
Format the [+date+] placeholder in human readable
form

Options
Any PHP valid strftime option

Default
”%d-%b-%y %H:%M”

Related
dateSource

yearSortDir

Purpose
Direction to sort documents

Options
ASC ascending
DESC descending

Default
”DESC”

Related
monthSortDir

monthSortDir

Purpose
Direction to sort the months

Options
ASC ascending
DESC descending

Default
”ASC”

5 of 9
Related
yearSortDir

start

Purpose
Number of documents to skip in the results

Options
Any number

Default
0

phx

Purpose
Use PHx formatting

Options
0 off
1 on

Default
1 on

params

Purpose
Pass parameters to the Ditto instance used to retreive
the documents

Options
Any valid ditto parameters in the format name:value
with multiple parameters separated by a pipe (|)

Note
This parameter is only needed for config, start, and phx
as you can now simply use the parameter as if Reflect was
Ditto

6 of 9
Default
[NULL]

source

Purpose
Name of the Ditto snippet to use

Options
Any valid snippet name

Default
”Ditto”

tplContainer

Purpose
Container template for the archive

Options
Any valid chunk name
Code via @CODE:
File via @FILE:

Default
See default.tempates.php

7 of 9
tplYear

Purpose
Template for the year item

Options
Any valid chunk name
Code via @CODE:
File via @FILE:

Default
See default.tempates.php

tplYearInner

Purpose
Template for the year item (the ul to hold the year
template)

Options
Any valid chunk name
Code via @CODE:
File via @FILE:

Default
See default.tempates.php

tplMonth

Purpose
Template for the month item

Options
Any valid chunk name
Code via @CODE:
File via @FILE:

Default
See default.tempates.php

8 of 9
tplMonthInner

Purpose
Template for the month item (the ul to hold the month
template)

Options
Any valid chunk name
Code via @CODE:
File via @FILE:

Default
See default.tempates.php

tplItem

Purpose
Template for the individual item

Options
Any valid chunk name
Code via @CODE:
File via @FILE:

Default
See default.tempates.php

Generated by Natural Docs

9 of 9
Template Class
Welcome
Purpose
Snippet
The Template class contains all functions relating to Ditto’s
handling of templates and any supporting functions they
need
Snippet

Summary
Wordpress Config

Template Class The Template class contains all


functions relating to Ditto’s
handling of templates and any
Template Class supporting functions they need
Functions
template Set the class language and fields
variables
process Take the templates and parse them
for tempalte variables, Check to
make sure they have fields, and sort
ATOM
the fields
JSON findTemplateVars Find al the template variables in the
template

XML sortFields Sort the array of fields provided by


type
replace Replcae placeholders with their
values
determine Determine the correct template to
apply
fetch Get a template, based on version by
Summary Doze

Tagging get_file_contents Returns the contents of file name


passed

template

function template()

Set the class language and fields variables

1 of 3
process

function process($template)

Take the templates and parse them for tempalte


variables, Check to make sure they have fields, and sort the
fields

findTemplateVars

function findTemplateVars($tpl)

Find al the template variables in the template

sortFields

function sortFields ($fieldList)

Sort the array of fields provided by type

replace

function replace($placeholders,
$tpl )

Replcae placeholders with their values

2 of 3
determine

function determine($templates,
$x,
$start,
$stop,
$id )

Determine the correct template to apply

fetch

function fetch($tpl)

Get a template, based on version by Doze

http://modxcms.com/forums/index.php/topic
,5344.msg41096.html#msg41096

get_file_contents

function get_file_contents($filename)

Returns the contents of file name passed

From http://www.nutt.net /2006 /07 /08


/file_get_contents-function-for-php-4 /#more-210

Generated by Natural Docs

3 of 3

Anda mungkin juga menyukai